wht@n4hgf.Mt-Park.GA.US (Warren Tucker) (02/17/91)
Submitted-by: wht@n4hgf Archive-name: x386monx100/part03 #!/bin/sh # This is part 03 of x386monx100 # ============= x386mon/disp_info.h ============== if test ! -d 'x386mon'; then echo 'x - creating directory x386mon' mkdir 'x386mon' fi if test -f 'x386mon/disp_info.h' -a X"$1" != X"-c"; then echo 'x - skipping x386mon/disp_info.h (File already exists)' else echo 'x - extracting x386mon/disp_info.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'x386mon/disp_info.h' && X/*+------------------------------------------------------------------------- X disp_info.h - function and macro declarations for disp_info.c users X wht@n4hgf.Mt-Park.GA.US X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */ X X#ifdef __STDC__ Xvoid disp_info(int,int,char *,int,long); Xvoid disp_static(int,int,char *,int,long); Xvoid disp_info_units(int,int,char *,int,char *,long); Xvoid disp_info_units_color(int,int,char *,int,char *,long,unsigned long); Xvoid disp_static_units(int,int,char *,int,char *,long); Xint disp_info_text(int,int,unsigned long,char *); Xvoid disp_static_text(int,int,char *); X#else Xvoid disp_info(); Xvoid disp_static(); Xvoid disp_info_units(); Xvoid disp_info_units_color(); Xvoid disp_static_units(); Xint disp_info_text(); Xvoid disp_static_text(); X#endif X X#define disp_info_long(x,y,label,flen,value)\ X disp_info(x,y,label,flen,value) X#define disp_info_int(x,y,label,flen,value)\ X disp_info(x,y,label,flen,(unsigned long)(value)) X#define disp_info_long_units(x,y,label,flen,units,value)\ X disp_info_units(x,y,label,flen,units,value) X#define disp_info_int_units(x,y,label,flen,units,value)\ X disp_info_units(x,y,label,flen,units,(unsigned long)(value)) X#define disp_static_long(x,y,label,flen,value)\ X disp_static(x,y,label,flen,value) X#define disp_static_int(x,y,label,flen,value)\ X disp_static(x,y,label,flen,(unsigned long)(value)) X#define disp_static_long_units(x,y,label,flen,units,value)\ X disp_static_units(x,y,label,flen,units,value) X#define disp_static_int_units(x,y,label,flen,units,value)\ X disp_static_units(x,y,label,flen,units,(unsigned long)(value)) X X/* vi: set tabstop=4 shiftwidth=4: */ X/* end of disp_info.h */ SHAR_EOF chmod 0644 x386mon/disp_info.h || echo 'restore of x386mon/disp_info.h failed' Wc_c="`wc -c < 'x386mon/disp_info.h'`" test 1804 -eq "$Wc_c" || echo 'x386mon/disp_info.h: original size 1804, current size' "$Wc_c" fi # ============= x386mon/exits.c ============== if test -f 'x386mon/exits.c' -a X"$1" != X"-c"; then echo 'x - skipping x386mon/exits.c (File already exists)' else echo 'x - extracting x386mon/exits.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'x386mon/exits.c' && X/*+------------------------------------------------------------------------- X exits.c - X386MON exit processor X wht@n4hgf.Mt-Park.GA.US X X Defined functions: X adb_trap() X caught_signal(sig) X leave(exit_code) X leave_text(text,exit_code) X leaving() X X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */ X X#include "x386mon.h" X#include <stdio.h> X#include <signal.h> X X/*+------------------------------------------------------------------------- X leaving() - perform leave() basic processing and return X--------------------------------------------------------------------------*/ Xvoid Xleaving() X{ X if(window) X { X XDestroyWindow(display,window); X XCloseDisplay(display); X } X} /* end of leaving */ X X/*+------------------------------------------------------------------------- X leave(exit_code) - leave program with exit code X--------------------------------------------------------------------------*/ Xvoid Xleave(exit_code) Xint exit_code; X{ X leaving(); X exit(exit_code); X} /* end of leave */ X X/*+------------------------------------------------------------------------- X leave_text(text,exit_code) - leave program with message and exit code XIf exit_code == 255, do wperror X--------------------------------------------------------------------------*/ Xvoid Xleave_text(text,exit_code) Xchar *text; Xint exit_code; X{ X fputs("\nx386mon: ",stdout); X X if (text && *text) X { X if(window) X disp_msg(colorRed.pixel,text); X fputs(text,stdout); X fputs("\n",stdout); X } X X if(exit_code == 255) X { X extern int errno; X extern int sys_nerr; X extern char *sys_errlist[]; X X if(errno < sys_nerr) X printf("system-provided error status: %s\n",sys_errlist[errno]); X } X X fflush(stdout); X leave(exit_code); X X} /* end of leave_text */ X X/*+------------------------------------------------------------------------- X adb_trap() - convenient trap for catching abort X X Get a look at stack before abort() botches it X--------------------------------------------------------------------------*/ X#if defined(ADB_DEBUG) Xvoid Xadb_trap() X{ X printf("too bad .... goodbye\n"); X} /* end of adb_trap */ X#endif X X/*+------------------------------------------------------------------------- X caught_signal(sig) - SIGHUP thru SIGSYS: leave with possible abort X--------------------------------------------------------------------------*/ Xvoid Xcaught_signal(sig) Xint sig; X{ X leaving(); X switch(sig) X { X case SIGQUIT: X case SIGILL: X case SIGTRAP: X case SIGIOT: X case SIGEMT: X case SIGFPE: X case SIGBUS: X case SIGSEGV: X case SIGSYS: X#if defined(ADB_DEBUG) X adb_trap(); /* if debugging, stop at convenient breakpoint */ X#endif X abort(); X } X exit(128 + sig); X} /* end of caught_signal */ X X/* vi: set tabstop=4 shiftwidth=4: */ X/* end of exits.c */ SHAR_EOF chmod 0644 x386mon/exits.c || echo 'restore of x386mon/exits.c failed' Wc_c="`wc -c < 'x386mon/exits.c'`" test 2809 -eq "$Wc_c" || echo 'x386mon/exits.c: original size 2809, current size' "$Wc_c" fi # ============= x386mon/libkmem.c ============== if test -f 'x386mon/libkmem.c' -a X"$1" != X"-c"; then echo 'x - skipping x386mon/libkmem.c (File already exists)' else echo 'x - extracting x386mon/libkmem.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'x386mon/libkmem.c' && X/*LINTLIBRARY*/ X/*+------------------------------------------------------------------------- X libkmem.c -- /dev/kmem routines for SCO UNIX/386 (maybe other *NIX) X ...!{gatech,emory}!n4hgf!wht X X Defined functions: X kinit(write_needed) X kread(caddr,kaddr,len) X kwrite(kaddr,caddr,len) X X routines were originally written by Mike "Ford" Ditto: kudos!!! X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */ X X#include <sys/types.h> X#include <sys/errno.h> X#include <fcntl.h> X#include "libkmem.h" X Xvoid leave_text(); X Xextern int errno; X Xstatic int fdkmem = -2; Xdaddr_t lseek(); X X/*+------------------------------------------------------------------------- X kinit(write_needed) X--------------------------------------------------------------------------*/ Xvoid Xkinit(write_needed) Xint write_needed; X{ X if(fdkmem >= 0) X return; X if((fdkmem=open("/dev/kmem",(write_needed) ? O_RDWR : O_RDONLY,0)) < 0) X { X if (write_needed) X { X leave_text("can't open /dev/kmem for read/write access",255); X } X else X { X leave_text("can't open /dev/kmem for read access",255); X } X } X X} /* end of kinit */ X X/*+------------------------------------------------------------------------- X kread(caddr,kaddr,len) X--------------------------------------------------------------------------*/ Xvoid Xkread(caddr,kaddr,len) Xcaddr_t caddr; Xdaddr_t kaddr; Xint len; X{ Xchar s80[80]; Xextern daddr_t myreadlen; Xextern int myreadcnt; X X#if defined(M_I286) X kaddr &= 0xFFFFL; X#endif X#if defined(mips) X kaddr &= 0x7FFFFFFFL; X#endif X X if(fdkmem == -2) X leave_text("kinit() not called",1); X X if(lseek(fdkmem,kaddr,0) == -1L) X { X (void)sprintf(s80,"kmem read seek error addr %08lx",kaddr); X leave_text(s80,255); X } X X if(read(fdkmem,caddr,len) != len) X { X (void)sprintf(s80,"kmem read error len %d addr %08lx",len,kaddr); X leave_text(s80,255); X } X myreadlen += len; X myreadcnt++; X} /* end of kread */ X X/*+------------------------------------------------------------------------- X kwrite(kaddr,caddr,len) X--------------------------------------------------------------------------*/ X#ifdef KWRITE_NEEDED Xvoid Xkwrite(kaddr,caddr,len) Xdaddr_t kaddr; Xcaddr_t caddr; Xint len; X{ Xchar s80[80]; X X#if defined(M_I286) X kaddr &= 0xFFFFL; X#endif X#if defined(mips) X kaddr &= 0x7FFFFFFFL; X#endif X X if(fdkmem == -2) X leave_text("kinit() not called",1); X X if(lseek(fdkmem,kaddr,0) == -1L) X { X (void)sprintf(s80, X "/dev/kmem write seek error addr %08lx",kaddr); X leave_text(s80,255); X } X if(write(fdkmem,caddr,len) != len) X { X (void)sprintf(s80, X "/dev/kmem write error addr %08lx len %08lx",kaddr,len); X leave_text(s80,255); X } X} /* end of kwrite */ X#endif X X/* vi: set tabstop=4 shiftwidth=4: */ SHAR_EOF chmod 0644 x386mon/libkmem.c || echo 'restore of x386mon/libkmem.c failed' Wc_c="`wc -c < 'x386mon/libkmem.c'`" test 2748 -eq "$Wc_c" || echo 'x386mon/libkmem.c: original size 2748, current size' "$Wc_c" fi # ============= x386mon/libkmem.h ============== if test -f 'x386mon/libkmem.h' -a X"$1" != X"-c"; then echo 'x - skipping x386mon/libkmem.h (File already exists)' else echo 'x - extracting x386mon/libkmem.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'x386mon/libkmem.h' && X/*+----------------------------------------------------------------------- X libkmem.h X ...!{gatech,emory}!n4hgf!wht X------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */ X X#ifndef BUILDING_PROTOTYPES X#ifdef __STDC__ X X/* libkmem.c */ Xvoid kinit(int ); Xvoid kread(char *,long ,int ); Xvoid kwrite(long ,char *,int ); X X#else /* compiler doesn't know about prototyping */ X X/* libkmem.c */ Xvoid kinit(); Xvoid kread(); Xvoid kwrite(); X X#endif /* __STDC__ */ X#endif /* BUILDING_PROTOTYPES */ X X/* end of libkmem.h */ SHAR_EOF chmod 0644 x386mon/libkmem.h || echo 'restore of x386mon/libkmem.h failed' Wc_c="`wc -c < 'x386mon/libkmem.h'`" test 605 -eq "$Wc_c" || echo 'x386mon/libkmem.h: original size 605, current size' "$Wc_c" fi # ============= x386mon/libmem.c ============== if test -f 'x386mon/libmem.c' -a X"$1" != X"-c"; then echo 'x - skipping x386mon/libmem.c (File already exists)' else echo 'x - extracting x386mon/libmem.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'x386mon/libmem.c' && X/*LINTLIBRARY*/ X/*+------------------------------------------------------------------------- X libmem.c -- /dev/mem routines for SCO UNIX/386 (maybe other *NIX) X ...!{gatech,emory}!n4hgf!wht X X Defined functions: X minit(write_needed) X mread(caddr,maddr,len) X mwrite(maddr,caddr,len) X X routines were originally written by Mike "Ford" Ditto: kudos!!! X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */ X X#include <sys/types.h> X#include <fcntl.h> X#include "libmem.h" X Xvoid leave_text(); X Xextern int errno; X Xstatic int fdmem = -2; Xdaddr_t lseek(); X X/*+------------------------------------------------------------------------- X minit(write_needed) X--------------------------------------------------------------------------*/ Xvoid Xminit(write_needed) Xint write_needed; X{ X if(fdmem >= 0) X return; X if((fdmem=open("/dev/mem",(write_needed) ? O_RDWR : O_RDONLY,0)) < 0) X leave_text("can't open /dev/mem",255); X X} /* end of minit */ X X/*+------------------------------------------------------------------------- X mread(caddr,maddr,len) X--------------------------------------------------------------------------*/ Xvoid Xmread(caddr,maddr,len) Xcaddr_t caddr; Xdaddr_t maddr; Xint len; X{ Xchar s80[80]; Xextern daddr_t myreadlen; Xextern int myreadcnt; X X#if defined(M_I286) X maddr &= 0xFFFFL; X#endif X X if(fdmem == -2) X leave_text("minit() not called",1); X X if(lseek(fdmem,maddr,0) == -1L) X { X (void)sprintf(s80,"mem seek err (%08lx)",maddr); X leave_text(s80,1); X } X X if(read(fdmem,caddr,len) != len) X { X (void)sprintf(s80, X "mem read errno %d len %d addr %08lx",errno,len,maddr); X leave_text(s80,1); X } X myreadlen += len; X myreadcnt++; X} /* end of mread */ X X/*+------------------------------------------------------------------------- X mwrite(maddr,caddr,len) X--------------------------------------------------------------------------*/ X#ifdef MWRITE_NEEDED Xvoid Xmwrite(maddr,caddr,len) Xdaddr_t maddr; Xcaddr_t caddr; Xint len; X{ Xchar s80[80]; X X#if defined(M_I286) X maddr &= 0xFFFFL; X#endif X X if(fdmem == -2) X leave_text("minit() not called",1); X X if(lseek(fdkmem,kaddr,0) == -1L) X { X (void)sprintf(s80, X "/dev/kmem seek error addr %08lx",kaddr); X leave_text(s80,255); X } X if(write(fdkmem,caddr,len) != len) X { X (void)sprintf(s80, X "/dev/kmem write error addr %08lx len %08lx",kaddr,len); X leave_text(s80,255); X } X} /* end of mwrite */ X#endif /* MWRITE_NEEDED */ X X/* vi: set tabstop=4 shiftwidth=4: */ SHAR_EOF chmod 0644 x386mon/libmem.c || echo 'restore of x386mon/libmem.c failed' Wc_c="`wc -c < 'x386mon/libmem.c'`" test 2497 -eq "$Wc_c" || echo 'x386mon/libmem.c: original size 2497, current size' "$Wc_c" fi # ============= x386mon/libmem.h ============== if test -f 'x386mon/libmem.h' -a X"$1" != X"-c"; then echo 'x - skipping x386mon/libmem.h (File already exists)' else echo 'x - extracting x386mon/libmem.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'x386mon/libmem.h' && X/*+----------------------------------------------------------------------- X libmem.h X ...!{gatech,emory}!n4hgf!wht X------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */ X X#ifndef BUILDING_PROTOTYPES X#ifdef __STDC__ X X/* libmem.c */ Xvoid minit(int ); Xvoid mread(char *,long ,int ); Xvoid mwrite(long ,char *,int ); X X#else /* compiler doesn't mnow about prototyping */ X X/* libmem.c */ Xvoid minit(); Xvoid mread(); Xvoid mwrite(); X X#endif /* __STDC__ */ X#endif /* BUILDING_PROTOTYPES */ X X/* end of libmem.h */ SHAR_EOF chmod 0644 x386mon/libmem.h || echo 'restore of x386mon/libmem.h failed' Wc_c="`wc -c < 'x386mon/libmem.h'`" test 601 -eq "$Wc_c" || echo 'x386mon/libmem.h: original size 601, current size' "$Wc_c" fi # ============= x386mon/libnlsym.c ============== if test -f 'x386mon/libnlsym.c' -a X"$1" != X"-c"; then echo 'x - skipping x386mon/libnlsym.c (File already exists)' else echo 'x - extracting x386mon/libnlsym.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'x386mon/libnlsym.c' && X/*LINTLIBRARY*/ X/*+------------------------------------------------------------------------- X libnlsym.c -- common runtime for nlsym users X ...!{gatech,emory}!n4hgf!wht X X Defined functions: X nlsym_error(text) X nlsym_read() X X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */ X X#include "config.h" X#include <stdio.h> X#include <sys/types.h> X#include <sys/stat.h> X#include <fcntl.h> X#include <nlist.h> X#if defined(mips) X#define n_sclass n_type X#endif X Xvoid leave_text(); X X#define DEFINE_NLSYM X#include "nlsym.h" X#include "libnlsym.h" X Xextern int errno; Xextern char *sys_errlist[]; X Xint nlsym_has_been_read = 0; X X/*+------------------------------------------------------------------------- X nlsym_error(text) X--------------------------------------------------------------------------*/ Xvoid Xnlsym_error(text) Xchar *text; X{ Xchar s128[128]; X X (void)strcpy(s128,text); X (void)strcat(s128,": run nlsym"); X leave_text(s128,(errno) ? 255 : 1); X} /* end of nlsym_error */ X X/*+------------------------------------------------------------------------- X nlsym_read() X--------------------------------------------------------------------------*/ Xvoid Xnlsym_read() X{ Xchar s80[80]; Xint fdnlsym; Xstruct stat curstat; /* current /unix status */ Xstruct stat unixstat; /* /unix status at nlsym run (void)time */ Xlong unique1 = 0; Xlong unique2 = 0; X X if(nlsym_has_been_read) X return; X X if(stat(UNIX_KERNEL,&curstat) < 0) X { X (void)sprintf(s80,"cannot stat %s",UNIX_KERNEL); X nlsym_error(s80); X } X X errno = 0; X if((fdnlsym = open(UNIX_NLSYM,O_RDONLY,0)) < 0) X { X (void)sprintf(s80,"%s open error",UNIX_NLSYM); X nlsym_error(s80); X } X X if(read(fdnlsym,(char *)&unixstat,sizeof(unixstat)) != sizeof(unixstat)) X nlsym_error("nlsym_read: /unix stat read error"); X X if(read(fdnlsym,(char *)nlsym,sizeof(nlsym)) != sizeof(nlsym)) X nlsym_error("nlsym_read: nlsym read error"); X X if(read(fdnlsym,(char *)&unique1,sizeof(unique1)) != sizeof(unique1)) X nlsym_error("nlsym_read: `unique' read error"); X X if(read(fdnlsym,(char *)&unique2,sizeof(unique2)) != sizeof(unique2)) X nlsym_error("nlsym_read: `unique' read error"); X X (void)close(fdnlsym); X X if( (unique1 != NLSYM_UNIQUE1) || X (unique2 != NLSYM_UNIQUE2) || X (unixstat.st_ino != curstat.st_ino) || X (unixstat.st_mtime != curstat.st_mtime) || X (unixstat.st_size != curstat.st_size)) X { X (void)sprintf(s80,"%s out of date",UNIX_NLSYM); X nlsym_error(s80); X } X nlsym_has_been_read = 1; X X} /* end of nlsym_read */ SHAR_EOF chmod 0644 x386mon/libnlsym.c || echo 'restore of x386mon/libnlsym.c failed' Wc_c="`wc -c < 'x386mon/libnlsym.c'`" test 2546 -eq "$Wc_c" || echo 'x386mon/libnlsym.c: original size 2546, current size' "$Wc_c" fi # ============= x386mon/libnlsym.h ============== if test -f 'x386mon/libnlsym.h' -a X"$1" != X"-c"; then echo 'x - skipping x386mon/libnlsym.h (File already exists)' else echo 'x - extracting x386mon/libnlsym.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'x386mon/libnlsym.h' && X/*+----------------------------------------------------------------------- X libnlsym.h X ...!{gatech,emory}!n4hgf!wht X------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */ X X#ifndef BUILDING_PROTOTYPES X#ifdef __STDC__ X X/* libnlsym.c */ Xvoid nlsym_error(char * ); Xvoid nlsym_read(void); X X#else /* compiler doesn't know about prototyping */ X X/* libnlsym.c */ Xvoid nlsym_error(); Xvoid nlsym_read(); X X#endif /* __STDC__ */ X#endif /* BUILDING_PROTOTYPES */ X X/* end of libnlsym.h */ SHAR_EOF chmod 0644 x386mon/libnlsym.h || echo 'restore of x386mon/libnlsym.h failed' Wc_c="`wc -c < 'x386mon/libnlsym.h'`" test 572 -eq "$Wc_c" || echo 'x386mon/libnlsym.h: original size 572, current size' "$Wc_c" fi # ============= x386mon/libswap.c ============== if test -f 'x386mon/libswap.c' -a X"$1" != X"-c"; then echo 'x - skipping x386mon/libswap.c (File already exists)' else echo 'x - extracting x386mon/libswap.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'x386mon/libswap.c' && X/*LINTLIBRARY*/ X/*+------------------------------------------------------------------------- X libswap.c -- /dev/swap routines for SCO UNIX/386 (maybe other *NIX) X ...!{gatech,emory}!n4hgf!wht X X Defined functions: X sinit() X sread(caddr,maddr,len) X X routines were originally written by Mike "Ford" Ditto: kudos!!! X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */ X X#include <sys/types.h> X#include <fcntl.h> X#include "libswap.h" X Xvoid leave_text(); X Xextern int errno; X Xstatic int fdswap = -2; Xdaddr_t lseek(); X X/*+------------------------------------------------------------------------- X sinit() X--------------------------------------------------------------------------*/ Xvoid Xsinit() X{ X if(fdswap >= 0) X return; X if((fdswap=open("/dev/swap",O_RDONLY)) < 0) X#ifdef M_SYS5 X leave_text("can't open /dev/swap (chgrp mem /dev/swap)",1); X#else X leave_text("can't open /dev/swap (chgrp sys /dev/swap)",1); X#endif X X} /* end of sinit */ X X/*+------------------------------------------------------------------------- X sread(caddr,maddr,len) X--------------------------------------------------------------------------*/ Xvoid Xsread(caddr,maddr,len) Xcaddr_t caddr; Xdaddr_t maddr; Xint len; X{ Xchar s80[80]; Xextern daddr_t myreadlen; Xextern int myreadcnt; X X#if defined(M_I286) X maddr &= 0xFFFFL; X#endif X X if(fdswap == -2) X leave_text("sinit() not called",1); X X if(lseek(fdswap,maddr,0) == -1L) X { X (void)sprintf(s80,"swap seek error addr %08lx",maddr); X leave_text(s80,1); X } X X if(read(fdswap,caddr,len) != len) X { X (void)sprintf(s80,"swap read error len %d addr %08lx",len,maddr); X leave_text(s80,255); X } X myreadlen += len; X myreadcnt++; X} /* end of sread */ X X/* vi: set tabstop=4 shiftwidth=4: */ SHAR_EOF chmod 0644 x386mon/libswap.c || echo 'restore of x386mon/libswap.c failed' Wc_c="`wc -c < 'x386mon/libswap.c'`" test 1793 -eq "$Wc_c" || echo 'x386mon/libswap.c: original size 1793, current size' "$Wc_c" fi # ============= x386mon/libswap.h ============== if test -f 'x386mon/libswap.h' -a X"$1" != X"-c"; then echo 'x - skipping x386mon/libswap.h (File already exists)' else echo 'x - extracting x386mon/libswap.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'x386mon/libswap.h' && X/*+----------------------------------------------------------------------- X libswap.h X ...!{gatech,emory}!n4hgf!wht X------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */ X X#ifndef BUILDING_PROTOTYPES X#ifdef __STDC__ X X/* libswap.c */ Xvoid sinit(void ); Xvoid sread(char *,long ,int ); X X#else /* compiler doesn't mnow about prototyping */ X X/* libswap.c */ Xvoid sinit(); Xvoid sread(); Xvoid swrite(); X X#endif /* __STDC__ */ X#endif /* BUILDING_PROTOTYPES */ X X/* end of libswap.h */ SHAR_EOF chmod 0644 x386mon/libswap.h || echo 'restore of x386mon/libswap.h failed' Wc_c="`wc -c < 'x386mon/libswap.h'`" test 573 -eq "$Wc_c" || echo 'x386mon/libswap.h: original size 573, current size' "$Wc_c" fi # ============= x386mon/nlsym.c ============== if test -f 'x386mon/nlsym.c' -a X"$1" != X"-c"; then echo 'x - skipping x386mon/nlsym.c (File already exists)' else echo 'x - extracting x386mon/nlsym.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'x386mon/nlsym.c' && X/*+------------------------------------------------------------------------- X nlsym.c -- utility nlist - fast access to kernel /dev/kmem offsets X ...!{gatech,emory}!n4hgf!wht X X Defined functions: X main(argc,argv,envp) X nlsym_write_error(code) X X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:08-10-1990-14:12-jmd@p1so/wht@n4hgf-2.20-add Tandem Integrity S2 */ X/*:08-07-1990-14:24-wht@n4hgf-nba@sysware.sysware.dk S5R31 updates */ X/*:08-02-1990-15:36-wht@n4hgf-2.12-old curses hacks+minor 3.2 formalizations */ X/*:07-28-1990-18:06-wht@n4hgf-2.10 release */ X/*:06-27-1990-01:57-wht@n4hgf-1.10-incorporate suggestions from alpha testers */ X/*:06-27-1990-01:55-wht@n4hgf-use 64 bits of unique check */ X/*:06-25-1990-04:14-wht@n4hgf-1.02-better error handling */ X/*:06-24-1990-20:53-wht@n4hgf-v1.01-add ISC support thanks to peter@radig.de */ X/*:06-21-1990-14:26-r@n4hgf-version x0.12 seems bug free */ X/*:05-12-1989-18:27-wht-fix endless loop error on cannot nlist */ X/*:10-27-1988-10:58-wht-creation */ X X#include "config.h" X#include <stdio.h> X#include <sys/types.h> X#include <sys/stat.h> X#include <fcntl.h> X#include <nlist.h> X#if defined(mips) X#define n_sclass n_type X#endif X X#define DEFINE_NLSYM X#include "nlsym.h" X X/*+------------------------------------------------------------------------- X nlsym_write_error(code) X--------------------------------------------------------------------------*/ Xvoid Xnlsym_write_error(code) Xint code; X{ X (void)fprintf(stderr,"code %d: ",code); X perror(UNIX_NLSYM); X exit(1); X} /* end of nlsym_write_error */ X X/*+------------------------------------------------------------------------- X main(argc,argv,envp) X--------------------------------------------------------------------------*/ X/*ARGSUSED*/ Xmain(argc,argv,envp) Xint argc; Xchar **argv; Xchar **envp; X{ Xregister int itmp; Xregister struct nlist *nn; Xstruct stat unixstat; /* /unix status at nlsym run (void)time */ Xint fdnlsym; Xint nlist_error = 0; Xlong unique; XFILE *kludge; X X (void)nlist(UNIX_KERNEL,nlsym); X X nn = nlsym; X while(nn->n_name) X { X if(!nn->n_sclass) X { X#if !defined(mips) X (void)printf("%s: can't nlist\n", nn->n_name); X nlist_error = 1; X#endif X nn++; X continue; X } X (void)printf("%-12.12s storage class: %04x value: %08lx\n", X nn->n_name, X nn->n_sclass, X nn->n_value); X nn++; X } X X if(nlist_error > 1) X { X (void)fprintf(stderr,"%s NOT produced\n",UNIX_NLSYM); X exit(1); X } X X if((kludge = fopen(UNIX_NLSYM,"w")) == NULL) /* scratch/create */ X nlsym_write_error(-1); X (void)fclose(kludge); X X if((fdnlsym = open(UNIX_NLSYM,O_WRONLY,0)) < 0) X nlsym_write_error(fdnlsym); X X if(stat(UNIX_KERNEL,&unixstat) < 0) X { X (void)fputs("cannot stat ",stderr); X perror(UNIX_KERNEL); X exit(1); X } X X if((itmp = write(fdnlsym,&unixstat,sizeof(unixstat))) != sizeof(unixstat)) X nlsym_write_error(itmp); X X if((itmp = write(fdnlsym,nlsym,sizeof(nlsym))) != sizeof(nlsym)) X nlsym_write_error(itmp); X X unique = NLSYM_UNIQUE1; X if((itmp = write(fdnlsym,&unique,sizeof(unique))) != sizeof(unique)) X nlsym_write_error(itmp); X X unique = NLSYM_UNIQUE2; X if((itmp = write(fdnlsym,&unique,sizeof(unique))) != sizeof(unique)) X nlsym_write_error(itmp); X X (void)close(fdnlsym); X exit(0); X /*NOTREACHED*/ X} /* end of main */ X X/* vi: set tabstop=4 shiftwidth=4: */ SHAR_EOF chmod 0644 x386mon/nlsym.c || echo 'restore of x386mon/nlsym.c failed' Wc_c="`wc -c < 'x386mon/nlsym.c'`" test 3306 -eq "$Wc_c" || echo 'x386mon/nlsym.c: original size 3306, current size' "$Wc_c" fi # ============= x386mon/nlsym.h ============== if test -f 'x386mon/nlsym.h' -a X"$1" != X"-c"; then echo 'x - skipping x386mon/nlsym.h (File already exists)' else echo 'x - extracting x386mon/nlsym.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'x386mon/nlsym.h' && X/*+------------------------------------------------------------------------- X nlsym.h -- utility nlist - fast access to kernel /dev/kmem offsets X ...!{gatech,emory}!n4hgf!wht X XThe nlsym file contains three records: X1. struct stat unixstat - stat buffer from /unix at file creation time X2. struct nlist nlsym - the structure of nlist'd information X3. long unique - a unique identifier to help ensure correct nlsym length X X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */ X X#define UNIX_KERNEL "/unix" X#define UNIX_NLSYM "/unix.nlsym" X#define NLSYM_UNIQUE1 0x1BADD00DL X#define NLSYM_UNIQUE2 0xDEADB1FFL X X#define Nindex_AVAILRMEM 0 X#define Nindex_AVAILSMEM 1 X#define Nindex_BDEVCNT 2 X#define Nindex_BDEVSW 3 X#if defined(HAS_BOOTINFO) X#define Nindex_BOOTINFO 4 X#endif X#define Nindex_CDEVCNT 5 X#define Nindex_CDEVSW 6 X#define Nindex_CFREE 7 X#define Nindex_CFREECNT 8 X#define Nindex_CFREELIST 9 X#define Nindex_CONSSW 10 X#define Nindex_CURPROC 11 X#define Nindex_DINFO 12 X#define Nindex_DSTFLAG 13 X#define Nindex_DUMPDEV 14 X#define Nindex_EMAP 15 X#define Nindex_FFREELIST 16 X#define Nindex_FILE 17 X#define Nindex_FMODCNT 18 X#define Nindex_FMODSW 19 X#define Nindex_FREEMEM 20 X#define Nindex_FSINFO 21 X#define Nindex_FSTYPSW 22 X#define Nindex_HZ 23 X#define Nindex_IDLESERVER 24 X#define Nindex_IFREELIST 25 X#define Nindex_INODE 26 X#define Nindex_KPTBL 27 X#define Nindex_LBOLT 28 X#define Nindex_LINECNT 29 X#define Nindex_LINESW 30 X#define Nindex_MAXCLICK 31 X#define Nindex_MAXMEM 32 X#define Nindex_MINFO 33 X#define Nindex_MOUNT 34 X#define Nindex_MSGLISTCNT 35 X#define Nindex_NFSTYP 36 X#define Nindex_NPTALLOCED 37 X#define Nindex_NPTFREE 38 X#define Nindex_NSERVERS 39 X#define Nindex_NSWAP 40 X#define Nindex_NSYSENT 41 X#define Nindex_OLDPROC 42 X#define Nindex_OLD_CURPROC 43 X#define Nindex_PANICSTR 44 X#define Nindex_PHYSMEM 45 X#define Nindex_PIPEDEV 46 X#define Nindex_PROC 47 X#define Nindex_RCINFO 48 X#define Nindex_ROOTDEV 49 X#define Nindex_RUNQ 50 X#define Nindex_SHLBINFO 51 X#define Nindex_SWAPDEV 52 X#define Nindex_SWPLO 53 X#define Nindex_SYSERR 54 X#define Nindex_SYSINFO 55 X#define Nindex_SYSSEGS 56 X#define Nindex_SYSWAIT 57 X#define Nindex_TIME 58 X#define Nindex_TIMEZONE 59 X#define Nindex_TTHIWAT 60 X#define Nindex_TTLOWAT 61 X#define Nindex_TUNE 62 X#define Nindex_U 63 X#define Nindex_USERTABLE 64 X#define Nindex_V 65 X#define Nindex_WIN_UBLK 66 X#define Nindex_REGION 67 X#ifdef M_UNIX X#define Nindex_SIO_TTY 68 X#endif X X#if defined(HAS_BOOTINFO) X#define bootinfoaddr (nlsym[Nindex_BOOTINFO].n_value) X#endif X#define freememaddr (nlsym[Nindex_FREEMEM].n_value) X#define lboltaddr (nlsym[Nindex_LBOLT].n_value) X#define maxmemaddr (nlsym[Nindex_MAXMEM].n_value) X#define minfoaddr (nlsym[Nindex_MINFO].n_value) X#define nswapaddr (nlsym[Nindex_NSWAP].n_value) X#define physmemaddr (nlsym[Nindex_PHYSMEM].n_value) X#define procaddr (nlsym[Nindex_PROC].n_value) X#define regionaddr (nlsym[Nindex_REGION].n_regionalue) X#define sysinfoaddr (nlsym[Nindex_SYSINFO].n_value) X#define tuneaddr (nlsym[Nindex_TUNE].n_value) X#define vaddr (nlsym[Nindex_V].n_value) X#ifdef M_UNIX X#define sio_ttyaddr (nlsym[Nindex_SIO_TTY].n_value) X#endif X X#ifdef DEFINE_NLSYM Xstruct nlist nlsym[] = X{ X { "availrmem" }, X { "availsmem" }, X { "bdevcnt" }, X { "bdevsw" }, X#if defined(HAS_BOOTINFO) X { "bootinfo" }, X#else X { "spl" }, X#endif X { "cdevcnt" }, X { "cdevsw" }, X { "cfree" }, X { "cfreecnt" }, X { "cfreelist" }, X { "conssw" }, X { "curproc" }, X { "dinfo" }, X { "Dstflag" }, X { "dumpdev" }, X { "emap" }, X { "ffreelist" }, X { "file" }, X { "fmodcnt" }, X { "fmodsw" }, X { "freemem" }, X { "fsinfo" }, X { "fstypsw" }, X { "Hz" }, X { "idleserver" }, X { "ifreelist" }, X { "inode" }, X { "kptbl" }, X { "lbolt" }, X { "linecnt" }, X { "linesw" }, X { "maxclick" }, X { "maxmem" }, X { "minfo" }, X { "mount" }, X { "msglistcnt" }, X { "nfstyp" }, X { "nptalloced" }, X { "nptfree" }, X { "nservers" }, X { "nswap" }, X { "nsysent" }, X { "oldproc" }, X { "old_curproc" }, X { "panicstr" }, X { "physmem" }, X { "pipedev" }, X { "proc" }, X { "rcinfo" }, X { "rootdev" }, X { "runq" }, X { "shlbinfo" }, X { "swapdev" }, X { "swplo" }, X { "syserr" }, X { "sysinfo" }, X { "syssegs" }, X { "syswait" }, X { "time" }, X { "Timezone" }, X { "tthiwat" }, X { "ttlowat" }, X { "tune" }, X { "u" }, X { "usertable" }, X { "v" }, X { "win_ublk" }, X { "region" }, X#ifdef M_UNIX X { "sio_tty" }, X#endif X { (char *)0 } X}; X#else Xextern struct nlist nlsym[]; X#endif X X/* vi: set tabstop=4 shiftwidth=4: */ SHAR_EOF chmod 0644 x386mon/nlsym.h || echo 'restore of x386mon/nlsym.h failed' Wc_c="`wc -c < 'x386mon/nlsym.h'`" test 5373 -eq "$Wc_c" || echo 'x386mon/nlsym.h: original size 5373, current size' "$Wc_c" fi # ============= x386mon/proc.c ============== if test -f 'x386mon/proc.c' -a X"$1" != X"-c"; then echo 'x - skipping x386mon/proc.c (File already exists)' else echo 'x - extracting x386mon/proc.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'x386mon/proc.c' && X/*+------------------------------------------------------------------------- X proc.c - X386MON proc table handler X wht@n4hgf.Mt-Park.GA.US X X Defined functions: X draw_Proc(x,y,initial) X initialize_Proc() X grok_proc() X pstat_text(pstat) X X--------------------------------------------------------------------------*/ X/*+:EDITS:*/ X/*:01-12-1991-04:35-wht@n4hgf-x1.00 (flush old edit notes) */ X X#include "unixincs.h" X#define WANT_MON_EXTERNS X#include "x386mon.h" X#include "buttons.h" X#include "disp_info.h" X X#undef NGROUPS_MAX X#undef NULL X#include <sys/param.h> X#if defined(mips) X#include <sys/sbd.h> X#endif X#include <nlist.h> X#include "nlsym.h" X#include "libkmem.h" X#include "libnlsym.h" X Xextern struct var v; X Xstruct proc *procs = (struct proc *)0; Xstruct proc *oldprocs = (struct proc *)0; Xstruct proc **pprocs = (struct proc **)0; Xstruct proc **poldprocs = (struct proc **)0; X Xint procs_per_pstat[SXBRK + 1]; Xint procs_in_core; Xint procs_alive; X Xstatic int line_style = LineSolid; Xstatic int cap_style = CapButt; Xstatic int join_style = JoinMiter; X X/*+------------------------------------------------------------------------- X pstat_text(pstat) X--------------------------------------------------------------------------*/ Xchar * Xpstat_text(pstat) Xchar pstat; X{ Xstatic char errant[10]; X X switch(pstat) X { X case SSLEEP: return("sleep "); X case SRUN: return("run "); X case SZOMB: return("zombie"); X case SSTOP: return("stop "); X case SIDL: return("idle "); X case SONPROC: return("onproc"); X case SXBRK: return("xbrk "); X } X (void)sprintf(errant,"%06u?",(unsigned char)pstat); X return(errant); X X} /* end of pstat_text */ X X/*+------------------------------------------------------------------------- X grok_proc() - read and examine kernel process table X--------------------------------------------------------------------------*/ Xvoid Xgrok_proc() X{ Xregister iproc; Xregister struct proc *tproc; X X kread((caddr_t)procs,procaddr,sizeof(struct proc) * v.v_proc); X for(iproc = 0; iproc < SXBRK + 1; iproc++) X procs_per_pstat[iproc] = 0; X procs_in_core = 0; X procs_alive = 0; X X for(iproc = 0; iproc < v.v_proc; iproc++) X { X tproc = pprocs[iproc] = (procs + iproc); X X if(tproc->p_stat) X procs_alive++; X X procs_per_pstat[tproc->p_stat]++; /* count # procs in each state */ X X if(tproc->p_flag & SLOAD) /* count # procs in memory */ X procs_in_core++; X } X X} /* end of grok_proc */ X X/*+------------------------------------------------------------------------- X draw_Proc(x,y,initial) X--------------------------------------------------------------------------*/ Xvoid Xdraw_Proc(x,y,initial) Xint y; Xint x; Xint initial; X{ Xregister istat; Xregister itmp; Xchar *cptr; Xchar s80[80]; Xint fwidth = FWIDTH; Xint fheight = FHEIGHT; Xint len; Xint x2 = x; Xint yl1 = y + (FASCENT / 2); Xint yl2 = y + (fheight / 2) - 1; Xint ys = y + FASCENT; X X switch(current_display_mode) X { X case BUTTON_main: X break; X default: X return; X } X X if(DrawAreaXYWH.height < (y + (fheight * 2))) X return; X X if(initial) X { X cptr = "---Proc----"; X len = strlen(cptr); X /* the "background" bar */ X XSetForeground(display,gc,colorSlate.pixel); X XSetLineAttributes(display,gc,fheight, X line_style,cap_style,join_style); X XDrawLine(display,window,gc, x,yl1, x + (len * fwidth),yl1); X X /* draw the black line before "Proc" */ X XSetForeground(display,gc,foreground); X XSetLineAttributes(display,gc,FASCENT / 2, X line_style,cap_style,join_style); X XDrawLine(display,window,gc, X x2,yl1, X x2 + (len = (fwidth * 3)) - FGAP,yl1); X x2 += len; X X /* draw "Proc" */ X cptr = "Proc"; X XDrawString(display,window,gc, x2, ys, cptr,len = strlen(cptr)); X XDrawString(display,window,gc, x2+1,ys, cptr,len); X x2 += fwidth * len; X X /* draw the black line after "Proc" */ X XDrawLine(display,window,gc, X x2 + FGAP + 1,yl1, X x2 + (len = (fwidth * 4)),yl1); X } X y += fheight; X X grok_proc(); X X for(istat = SSLEEP; istat <= SXBRK; istat++) X { X disp_info_int(x,y,pstat_text(istat),5,procs_per_pstat[istat]); X y += fheight; X } X disp_info_int(x,y,"total ",5,procs_alive); X y += fheight; X disp_info_int(x,y,"in mem",5,procs_in_core); X X} /* end of draw_Proc */ X X/*+------------------------------------------------------------------------- X initialize_Proc() X--------------------------------------------------------------------------*/ Xinitialize_Proc() X{ Xstatic char *memfail = "cannot alloc memory for proc table"; X X if(!(procs = (struct proc *)malloc(sizeof(struct proc) * v.v_proc))) X leave_text(memfail,1); X if(!(oldprocs = (struct proc *)malloc(sizeof(struct proc) * v.v_proc))) X leave_text(memfail,1); X if(!(pprocs = (struct proc **)malloc(sizeof(struct proc *) * v.v_proc))) X leave_text(memfail,1); X if(!(poldprocs=(struct proc **)malloc(sizeof(struct proc *)*v.v_proc))) X leave_text(memfail,1); X X} /* end of initialize_Proc */ X X/* vi: set tabstop=4 shiftwidth=4: */ X/* end of proc.c */ SHAR_EOF chmod 0644 x386mon/proc.c || echo 'restore of x386mon/proc.c failed' Wc_c="`wc -c < 'x386mon/proc.c'`" test 4886 -eq "$Wc_c" || echo 'x386mon/proc.c: original size 4886, current size' "$Wc_c" fi true || echo 'restore of x386mon/ps.c failed' echo End of part 3, continue with part 4 exit 0 ----------------------------------------------------------------------- Warren Tucker, TuckerWare gatech!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US Many [Nobel physics] prizes have been given to people for telling us the universe is not as simple as we thought it was. -Stephen Hawking in A Brief History of Time In computing, there are no such prizes. -me