/* * System dependent file for Ultrix 4.2A */ /* * Ricardo E Gonzalez, Stanford University * based on code by * Salvador P. Abreu, U.Nova de Lisboa, PORTUGAL * based on code by * Chris Siebenmann, University of Toronto */ /* LINTLIBRARY */ #include #include #include #include #include #include #include #define kmseek(N) if (lseek(kmem, (long) (N), 0) != (long) (N)) perror ("lseek kmem"); #define KMEM "/dev/kmem" extern char *xmalloc(/* int nbytes */); extern int open(), read(); extern long lseek(); extern char *kernelSymbols; struct cpudata *cpu_data[MAXCPU]; long **cptime_old = NULL; int kmem; /* file descriptor of /dev/kmem. */ struct nlist nl[] = { #define X_ACTIVECPU 0 { "_cpu_avail" }, /* number of active CPUs */ #define X_CPUDATA 1 { "_cpudata" }, /* cpudata[] array */ #define X_LOWCPU 2 { "_lowcpu" }, /* lowest cpu number */ #define X_HIGHCPU 3 { "_highcpu" }, /* highest cpu number */ { 0 }, }; int activecpu; int lowcpu = 0; int highcpu = 0; static unsigned long cpudata_offset = 0; /* Called by -version */ void version() { printf("Ultrix: maxcpu=%d, maxdisk=0\n", MAXCPU); } /* Called at the beginning to inquire how many bars are needed. */ int num_bars() { if ((kmem = open("/dev/kmem", 0)) < 0) { perror("/dev/kmem"); exit(1); } (void) nlist(kernelSymbols?kernelSymbols:"/vmunix", nl); /* printf("ACTIVE : %x\n", nl[X_ACTIVECPU].n_value); printf("CPUDATA: %x\n", nl[X_CPUDATA].n_value); fflush(stdout); */ (void) getkval(nl[X_LOWCPU].n_value, (int *)(&lowcpu), sizeof(lowcpu), nl[X_LOWCPU].n_name); (void) getkval(nl[X_HIGHCPU].n_value, (int *)(&highcpu), sizeof(highcpu), nl[X_HIGHCPU].n_name); activecpu = highcpu - lowcpu + 1; cpudata_offset = nl[X_CPUDATA].n_value; /* printf("CPUS : %d\n", activecpu); fflush(stdout); return (activecpu); */ } /* * Indicates how many levels each bar has. For most machines, each bar will * have the same stuff. But one can, for instance, display memory use on one * bar, processor levels on others, etc. */ void bar_items(nbars, items) int nbars; int items[]; /* nbars items in this */ { int i; for(i = 0; i < nbars; i++) items[i] = CPUSTATES; } /* Called after num_bars to ask for the bar names */ /* ARGSUSED */ char ** label_bars(nbars) { static char **names; static char hname[MAXHOSTNAMELEN]; int i; names = (char **) malloc (nbars * sizeof (char *)); for (i=0; i