Exemple #1
0
int
initsyscall(void)
{
    static char name[] = "name";

    hertz = stathz ? stathz : hz;

    syscall_order(name);

    /* drvinit gets number of cpus! */
    drvinit(1);

    counts_mib_len = __arraycount(counts_mib);
    if (sysctlnametomib("kern.syscalls.counts", counts_mib,
                        &counts_mib_len))
        counts_mib_len = 0;

    times_mib_len = __arraycount(times_mib);
    if (sysctlnametomib("kern.syscalls.times", times_mib, &times_mib_len))
        times_mib_len = 0;

    getinfo(&s2, SHOW_COUNTS | SHOW_TIMES);
    s1 = s2;

    return(1);
}
Exemple #2
0
int main() {
    UINT8 pinvalue;

    DRVCTRL example;

    drvinit(example);

	pinvalue = gpio_read_pin(&example,PORTD, 1);

	init_gpio(DRV_PORTB);
	init_gpio(DRV_PORTD);

    /* I would really like to be able to implement a 
	   function where I could just pass a pointer to a
	   function that would be called when the timer
	   overflowed, like the one below.
    */
    /* schedulePeriodicTask(timePeriod,&task); */
    init_timer();

    init_usart0();

    init_eeprom();
    
    while (1) {
	;
    }


}
Exemple #3
0
int
initvmstat(void)
{
	static char *intrnamebuf;
	char *cp;
	int i;

	if (intrnamebuf)
		free(intrnamebuf);
	if (intrname)
		free(intrname);
	if (intrloc)
		free(intrloc);

	if (namelist[0].n_type == 0) {
		if (kvm_nlist(kd, namelist) &&
		    namelist[X_ALLEVENTS].n_type == 0) {
			nlisterr(namelist);
			return(0);
		}
	}
	hertz = stathz ? stathz : hz;
	if (!drvinit(1))
		return(0);

	/* Old style interrupt counts - deprecated */
	nintr = (namelist[X_EINTRCNT].n_value -
		namelist[X_INTRCNT].n_value) / sizeof (long);
	if (nintr) {
		intrloc = calloc(nintr, sizeof (long));
		intrname = calloc(nintr, sizeof (long));
		intrnamebuf = malloc(namelist[X_EINTRNAMES].n_value -
				     namelist[X_INTRNAMES].n_value);
		if (intrnamebuf == NULL || intrname == 0 || intrloc == 0) {
			error("Out of memory\n");
			nintr = 0;
			return(0);
		}
		NREAD(X_INTRNAMES, intrnamebuf, NVAL(X_EINTRNAMES) -
		      NVAL(X_INTRNAMES));
		for (cp = intrnamebuf, i = 0; i < nintr; i++) {
			intrname[i] = cp;
			cp += strlen(cp) + 1;
		}
	}

	/* event counter interrupt counts */
	get_interrupt_events();

	nextintsrow = INTSROW + 1;
	allocinfo(&s);
	allocinfo(&s1);
	allocinfo(&s2);
	allocinfo(&z);

	getinfo(&s2);
	copyinfo(&s2, &s1);
	return(1);
}
Exemple #4
0
int
main(int argc, char *argv[])
{
	int ch, hdrcnt, ndrives, lines;
	struct timespec	tv;
	struct ttysize ts;

	while ((ch = getopt(argc, argv, "Cc:dDITw:x")) != -1)
		switch (ch) {
		case 'c':
			if ((reps = atoi(optarg)) <= 0)
				errx(1, "repetition count <= 0.");
			break;
		case 'C':
			todo |= SHOW_CPU;
			break;
		case 'd':
			todo &= ~SHOW_STATS_ALL;
			todo |= SHOW_STATS_1;
			break;
		case 'D':
			todo &= ~SHOW_STATS_ALL;
			todo |= SHOW_STATS_2;
			break;
		case 'I':
			todo |= SHOW_TOTALS;
			break;
		case 'T':
			todo |= SHOW_TTY;
			break;
		case 'w':
			if ((interval = atoi(optarg)) <= 0)
				errx(1, "interval <= 0.");
			break;
		case 'x':
			todo &= ~SHOW_STATS_ALL;
			todo |= SHOW_STATS_X;
			break;
		case '?':
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	if (!ISSET(todo, SHOW_CPU | SHOW_TTY | SHOW_STATS_ALL))
		todo |= SHOW_CPU | SHOW_TTY | SHOW_STATS_1;
	if (ISSET(todo, SHOW_STATS_X)) {
		todo &= ~(SHOW_CPU | SHOW_TTY | SHOW_STATS_ALL);
		todo |= SHOW_STATS_X;
	}

	if (ioctl(STDOUT_FILENO, TIOCGSIZE, &ts) != -1) {
		if (ts.ts_lines)
			winlines = ts.ts_lines;
		if (ts.ts_cols)
			wincols = ts.ts_cols;
	}

	defdrives = wincols;
	if (ISSET(todo, SHOW_CPU))
		defdrives -= 16;	/* XXX magic number */
	if (ISSET(todo, SHOW_TTY))
		defdrives -= 10;	/* XXX magic number */
	defdrives /= 18;		/* XXX magic number */

	drvinit(0);
	cpureadstats();
	drvreadstats();
	ndrives = selectdrives(argc, argv);
	if (ndrives == 0) {
		/* No drives are selected.  No need to show drive stats. */
		todo &= ~SHOW_STATS_ALL;
		if (todo == 0)
			errx(1, "no drives");
	}
	if (ISSET(todo, SHOW_STATS_X))
		lines = ndrives;
	else
		lines = 1;

	tv.tv_sec = interval;
	tv.tv_nsec = 0;

	/* print a new header on sigcont */
	(void)signal(SIGCONT, sig_header);

	for (hdrcnt = 1;;) {
		if (do_header || lines > 1 || (hdrcnt -= lines) <= 0) {
			do_header = 0;
			header();
			hdrcnt = winlines - 4;
		}

		if (!ISSET(todo, SHOW_TOTALS)) {
			cpuswap();
			drvswap();
			tkswap();
		}

		display();

		if (reps >= 0 && --reps <= 0)
			break;
		nanosleep(&tv, NULL);
		cpureadstats();
		drvreadstats();
	}
	exit(0);
}