a.out.h
/*
* Format of an a.out header
*/
struct exec { /* a.out header */
int a_magic; /* magic number */
unsigned a_text; /* size of text segment */
unsigned a_data; /* size of initialized data */
unsigned a_bss; /* size of uninitialized data */
unsigned a_syms; /* size of symbol table */
unsigned a_entry; /* entry point */
unsigned a_trsize; /* size of text relocation */
unsigned a_drsize; /* size of data relocation */
};
#define A_MAGIC1 0407 /* normal */
#define A_MAGIC2 0410 /* read-only text */
#define A_MAGIC3 0411 /* separated I&D */
#define A_MAGIC4 0405 /* overlay */
struct nlist { /* symbol table entry */
char n_name[8]; /* symbol name */
char n_type; /* type flag */
char n_other;
short n_desc;
unsigned n_value; /* value */
};
/* values for type flag */
#define N_UNDF 0 /* undefined */
#define N_ABS 02 /* absolute */
#define N_TEXT 04 /* text */
#define N_DATA 06 /* data */
#define N_BSS 08
#define N_TYPE 037
#define N_FN 037 /* file name symbol */
#define N_GSYM 0040 /* global sym: name,,type,0 */
#define N_FUN 0044 /* function: name,,linenumber,address */
#define N_STSYM 0046 /* static symbol: name,,type,address */
#define N_RSYM 0100 /* register sym: name,,register,offset */
#define N_SLINE 0104 /* src line: ,,linenumber,address */
#define N_SSYM 0140 /* structure elt: name,,type,struct_offset */
#define N_SO 0144 /* source file name: name,,,address */
#define N_LSYM 0200 /* local sym: name,,type,offset */
#define N_SOL 0204 /* #line source filename: name,,,address */
#define N_PSYM 0240 /* parameter: name,,type,offset */
#define N_LBRAC 0300 /* left bracket: ,,nesting level,address */
#define N_RBRAC 0340 /* right bracket: ,,nesting level,address */
#define N_LENG 0376 /* second stab entry with length information */
#define N_EXT 01 /* external bit, or'ed in */
#define FORMAT "%08x"
#define STABTYPES 0340
ar.h
#define ARMAG 0177545
struct ar_hdr {
char ar_name[14];
long ar_date;
char ar_uid;
char ar_gid;
int ar_mode;
long ar_size;
};
assert.h
# ifndef NDEBUG
# define _assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file %s, line %d\n", __FILE__, __LINE__);exit(1);}}
# define assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file %s, line %d\n", __FILE__, __LINE__);exit(1);}}
# else
# define _assert(ex) ;
# define assert(ex) ;
# endif
core.h
/* machine dependent stuff for core files */
#define TXTRNDSIZ 512L
#define stacktop(siz) (0x80000000L)
#define stackbas(siz) (0x80000000L-siz)
ctype.h
#define _U 01
#define _L 02
#define _N 04
#define _S 010
#define _P 020
#define _C 040
#define _X 0100
extern char _ctype_[];
#define isalpha(c) ((_ctype_+1)[c]&(_U|_L))
#define isupper(c) ((_ctype_+1)[c]&_U)
#define islower(c) ((_ctype_+1)[c]&_L)
#define isdigit(c) ((_ctype_+1)[c]&_N)
#define isxdigit(c) ((_ctype_+1)[c]&(_N|_X))
#define isspace(c) ((_ctype_+1)[c]&_S)
#define ispunct(c) ((_ctype_+1)[c]&_P)
#define isalnum(c) ((_ctype_+1)[c]&(_U|_L|_N))
#define isprint(c) ((_ctype_+1)[c]&(_P|_U|_L|_N))
#define iscntrl(c) ((_ctype_+1)[c]&_C)
#define isascii(c) ((unsigned)(c)<=0177)
#define toupper(c) ((c)-'a'+'A')
#define tolower(c) ((c)-'A'+'a')
#define toascii(c) ((c)&0177)
dir.h
#ifndef DIRSIZ
#define DIRSIZ 14
#endif
struct dir
{
ino_t d_ino;
char d_name[DIRSIZ];
};
dk.h
/*
* switch commands
*/
#define RAM_ON 0226
#define ROM_ON 0322
#define R_CNTL 0264
#define W_CNTL 0170
/*
* dk command channel mode
*/
#define DKCMD 04000
/*
* library routine declarations
*/
extern long cmread();
extern long ocmread();
dumprestor.h
#define NTREC 20
#define MLEN 16
#define MSIZ 4096
#define TS_TAPE 1
#define TS_INODE 2
#define TS_BITS 3
#define TS_ADDR 4
#define TS_END 5
#define TS_CLRI 6
#define MAGIC (int)60011
#define CHECKSUM (int)84446
struct spcl
{
int c_type;
time_t c_date;
time_t c_ddate;
int c_volume;
daddr_t c_tapea;
ino_t c_inumber;
int c_magic;
int c_checksum;
struct dinode c_dinode;
int c_count;
char c_addr[BSIZE];
} spcl;
struct idates
{
char id_name[16];
char id_incno;
time_t id_ddate;
};
errno.h
/*
* Error codes
*/
#define EPERM 1
#define ENOENT 2
#define ESRCH 3
#define EINTR 4
#define EIO 5
#define ENXIO 6
#define E2BIG 7
#define ENOEXEC 8
#define EBADF 9
#define ECHILD 10
#define EAGAIN 11
#define ENOMEM 12
#define EACCES 13
#define EFAULT 14
#define ENOTBLK 15
#define EBUSY 16
#define EEXIST 17
#define EXDEV 18
#define ENODEV 19
#define ENOTDIR 20
#define EISDIR 21
#define EINVAL 22
#define ENFILE 23
#define EMFILE 24
#define ENOTTY 25
#define ETXTBSY 26
#define EFBIG 27
#define ENOSPC 28
#define ESPIPE 29
#define EROFS 30
#define EMLINK 31
#define EPIPE 32
/* math software */
#define EDOM 33
#define ERANGE 34
execargs.h
char **execargs = (char**)(0x7ffffffc);
grp.h
struct group { /* see getgrent(3) */
char *gr_name;
char *gr_passwd;
int gr_gid;
char **gr_mem;
};
ident.h
char myname[] = "research VAX-11/780";
math.h
extern double fabs(), floor(), ceil(), fmod(), ldexp();
extern double sqrt(), hypot(), atof();
extern double sin(), cos(), tan(), asin(), acos(), atan(), atan2();
extern double exp(), log(), log10(), pow();
extern double sinh(), cosh(), tanh();
extern double gamma();
extern double j0(), j1(), jn(), y0(), y1(), yn();
#define HUGE 1.701411733192644270e38
mp.h
#define MINT struct mint
MINT
{ int len;
short *val;
};
#define FREE(x) {if(x.len!=0) {free((char *)x.val); x.len=0;}}
#ifndef DBG
#define shfree(u) free((char *)u)
#else
#include "stdio.h"
#define shfree(u) { if(dbg) fprintf(stderr, "free %o\n", u); free((char *)u);}
extern int dbg;
#endif
#ifndef vax
struct half
{ short high;
short low;
};
#else
struct half
{ short low;
short high;
};
#endif
extern MINT *itom();
extern short *xalloc();
#ifdef lint
extern xv_oid;
#define VOID xv_oid =
#else
#define VOID
#endif
olddump.h
#define MAXSIZE 500 /* max size in blocks of dumped files */
#define NILIST 100 /* max files extracted at once */
#define BFACT 20 /* tape blocking factor */
int tden 1600; /* tape density */
int tlen 2200; /* tape length (feet) */
char *dump_cmd[] = { /* default args for dump */
"dump",
"i",
"/dev/rp0",
0
};
char *rest_cmd[] = { /* defaults for restor */
"restor",
"t",
0
};
char *tape "/dev/rmt1";
char dfile[] "/dev/dtab";
char tfile[] "/tmp/dtmp";
char name[100];
#define NDTAB 10
struct {
char dt_name[16];
time_t dt_date;
} dtab[NDTAB];
struct thdr {
ino_t isize;
ino_t maxi;
daddr_t fsize;
time_t cdate;
time_t ddate;
long tsize;
int nflg;
};
struct fhdr {
short xmagic;
ino_t xino;
short xmode;
short xnlink;
short xuid;
short xgid;
daddr_t xaddr;
off_t xsize;
time_t xatime;
time_t xmtime;
time_t xctime;
};
#define FMAGIC 012345
#define SMAGIC 031415
#define DAPTB 127 /* (BSIZE-2*sizeof(short))/sizeof(daddr_t)) */
FILE *tmpf;
long
getsize()
{
register c;
long j;
c = getc(tmpf);
if(c == EOF)
return((long)-1);
if(c <= 253)
return((long)c);
if(c == 255)
return((long)-1);
j = 0;
for(c=0;c<3;c++)
j = (j<<8) + (getc(tmpf)&0377);
return(j);
}
putsize(s)
long s;
{
if(s <= 253) {
putc((char)s, tmpf);
return;
}
putc(254, tmpf);
putc((char)(s>>16), tmpf);
putc((char)(s>>8), tmpf);
putc((char)s, tmpf);
}
pack.h
struct header {
char sync;
char ksize;
unsigned short sum;
char cntl;
char ccntl;
};
#define HDRSIZ 6
struct pack {
short p_state; /* line state */
short p_bits; /* mask for getepack */
short p_rsize; /* input packet size */
short p_xsize; /* output packet size */
struct header p_ihbuf; /* input header */
struct header p_ohbuf; /* output header */
char *p_rptr;
char p_mode;
char **p_ipool;
char p_xcount; /* # active output buffers */
char p_rcount;
char p_nout,p_tout;
char p_lpsize; /* log(psize/32) */
char p_timer;
char p_obusy;
char p_srxmit;
char p_rwindow; /* window size */
char p_swindow;
char p_msg; /* control msg */
char p_rmsg; /* repeated control msg */
char p_ps,p_pr; /* last packet sent, recv'd */
char p_rpr;
char p_nxtps; /* next output seq number */
char p_imap; /* bit map of input buffers */
char p_pscopy; /* newest output packet */
char *p_ob[8]; /* output buffers */
char *p_ib[8]; /* input buffers */
char p_os[8]; /* output buffer status */
char p_is[8]; /* input buffer status */
short p_osum[8]; /* output checksums */
short p_isum[8]; /* input checksums */
DSYSTEM;
};
#define CHECK 0125252
#define SYN 020
#define MOD8 7
#define ISCNTL(a) ((a & 0300)==0)
#define MIN(a,b) ((a<b)? a:b)
char next[8];
char mask[8];
int npbits;
int pkactive;
/*
* driver state
*/
#define DEAD 0
#define INITa 1
#define INITb 2
#define INITab 3
#define LIVE 010
#define RXMIT 020
#define RREJ 040
#define PDEBUG 0200
#define DRAINO 0400
#define WAITO 01000
#define DOWN 02000
#define RCLOSE 04000
#define BADFRAME 020000
/*
* io buffer states
*/
#define B_NULL 0
#define B_READY 1
#define B_SENT 2
#define B_RESID 010
#define B_COPY 020
#define B_MARK 040
#define B_SHORT 0100
/*
* control messages
*/
#define CLOSE 1
#define RJ 2
#define SRJ 3
#define RR 4
#define INITC 5
#define INITB 6
#define INITA 7
#define M_RJ 4
#define M_SRJ 010
#define M_RR 020
#define M_INITC 040
#define M_CLOSE 2
#define M_INITA 0200
#define M_INITB 0100
#define PKOPRI 31
#define PKIPRI 30
#define NPLINES 8
/*
* packet ioctl buf
*/
struct piocb {
unsigned t;
short psize;
short mode;
short state;
char window;
};
int pkdebug;
int pksizes[];
pwd.h
struct passwd { /* see getpwent(3) */
char *pw_name;
char *pw_passwd;
int pw_uid;
int pw_gid;
int pw_quota;
char *pw_comment;
char *pw_gecos;
char *pw_dir;
char *pw_shell;
};
saio.h
/*
* header file for standalone package
*/
/*
* io block: includes an
* inode, cells for the use of seek, etc,
* and a buffer.
*/
struct iob {
char i_flgs;
struct inode i_ino;
int i_unit;
daddr_t i_boff;
daddr_t i_cyloff;
off_t i_offset;
daddr_t i_bn;
char *i_ma;
int i_cc;
char i_buf[512];
};
#define F_READ 01
#define F_WRITE 02
#define F_ALLOC 04
#define F_FILE 010
/*
* dev switch
*/
struct devsw {
char *dv_name;
int (*dv_strategy)();
int (*dv_open)();
int (*dv_close)();
};
struct devsw devsw[];
/*
* request codes. Must be the same a F_XXX above
*/
#define READ 1
#define WRITE 2
#define NBUFS 4
char b[NBUFS][512];
daddr_t blknos[NBUFS];
#define NFILES 4
struct iob iob[NFILES];
/*
* Set to which 32Kw segment the code is physically running in.
* Must be set by the users main (or there abouts).
*/
int segflag;
setjmp.h
typedef int jmp_buf[10];
sgtty.h
/*
* Structure for stty and gtty system calls.
*/
struct sgttyb {
char sg_ispeed; /* input speed */
char sg_ospeed; /* output speed */
char sg_erase; /* erase character */
char sg_kill; /* kill character */
int sg_flags; /* mode flags */
};
/*
* Modes
*/
#define TANDEM 01
#define CBREAK 02
#define LCASE 04
#define ECHO 010
#define CRMOD 020
#define RAW 040
#define ODDP 0100
#define EVENP 0200
#define ANYP 0300
#define NLDELAY 001400
#define TBDELAY 006000
#define XTABS 06000
#define CRDELAY 030000
#define VTDELAY 040000
#define BSDELAY 0100000
#define ALLDELAY 0177400
/*
* Delay algorithms
*/
#define CR0 0
#define CR1 010000
#define CR2 020000
#define CR3 030000
#define NL0 0
#define NL1 000400
#define NL2 001000
#define NL3 001400
#define TAB0 0
#define TAB1 002000
#define TAB2 004000
#define FF0 0
#define FF1 040000
#define BS0 0
#define BS1 0100000
/*
* Speeds
*/
#define B0 0
#define B50 1
#define B75 2
#define B110 3
#define B134 4
#define B150 5
#define B200 6
#define B300 7
#define B600 8
#define B1200 9
#define B1800 10
#define B2400 11
#define B4800 12
#define B9600 13
#define EXTA 14
#define EXTB 15
/*
* tty ioctl commands
*/
#define TIOCGETD (('t'<<8)|0)
#define TIOCSETD (('t'<<8)|1)
#define TIOCHPCL (('t'<<8)|2)
#define TIOCMODG (('t'<<8)|3)
#define TIOCMODS (('t'<<8)|4)
#define TIOCGETP (('t'<<8)|8)
#define TIOCSETP (('t'<<8)|9)
#define TIOCSETN (('t'<<8)|10)
#define TIOCEXCL (('t'<<8)|13)
#define TIOCNXCL (('t'<<8)|14)
#define TIOCTSTP (('t'<<8)|16)
#define DIOCGETP (('d'<<8)|8)
#define DIOCSETP (('d'<<8)|9)
#define FIOCLEX (('f'<<8)|1)
#define FIONCLEX (('f'<<8)|2)
#define MXLSTN (('x'<<8)|1)
#define MXNBLK (('x'<<8)|2)
signal.h
#define NSIG 17
#define SIGHUP 1 /* hangup */
#define SIGINT 2 /* interrupt */
#define SIGQUIT 3 /* quit */
#define SIGILL 4 /* illegal instruction (not reset when caught) */
#define SIGTRAP 5 /* trace trap (not reset when caught) */
#define SIGIOT 6 /* IOT instruction */
#define SIGEMT 7 /* EMT instruction */
#define SIGFPE 8 /* floating point exception */
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
#define SIGBUS 10 /* bus error */
#define SIGSEGV 11 /* segmentation violation */
#define SIGSYS 12 /* bad argument to system call */
#define SIGPIPE 13 /* write on a pipe with no one to read it */
#define SIGALRM 14 /* alarm clock */
#define SIGTERM 15 /* software termination signal from kill */
int (*signal())();
#define SIG_DFL (int (*)())0
#define SIG_IGN (int (*)())1
stat.h
struct stat
{
dev_t st_dev;
ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
dev_t st_rdev;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
#define S_IFMT 0170000 /* type of file */
#define S_IFDIR 0040000 /* directory */
#define S_IFCHR 0020000 /* character special */
#define S_IFBLK 0060000 /* block special */
#define S_IFREG 0100000 /* regular */
#define S_IFMPC 0030000 /* multiplexed char special */
#define S_IFMPB 0070000 /* multiplexed block special */
#define S_ISUID 0004000 /* set user id on execution */
#define S_ISGID 0002000 /* set group id on execution */
#define S_ISVTX 0001000 /* save swapped text even after use */
#define S_IREAD 0000400 /* read permission, owner */
#define S_IWRITE 0000200 /* write permission, owner */
#define S_IEXEC 0000100 /* execute/search permission, owner */
stdio.h
#define BUFSIZ 512
#define _NFILE 20
# ifndef FILE
extern struct _iobuf {
int _cnt;
char *_ptr;
char *_base;
char _flag;
char _file;
} _iob[_NFILE];
# endif
#define _IOREAD 01
#define _IOWRT 02
#define _IONBF 04
#define _IOMYBUF 010
#define _IOEOF 020
#define _IOERR 040
#define _IOSTRG 0100
#define NULL 0
#define FILE struct _iobuf
#define EOF (-1)
#define stdin (&_iob[0])
#define stdout (&_iob[1])
#define stderr (&_iob[2])
#define getc(p) (--(p)->_cnt>=0? *(p)->_ptr++&0377:_filbuf(p))
#define getchar() getc(stdin)
#define putc(x,p) (--(p)->_cnt>=0? ((int)(*(p)->_ptr++=(unsigned)(x))):_flsbuf((unsigned)(x),p))
#define putchar(x) putc(x,stdout)
#define feof(p) (((p)->_flag&_IOEOF)!=0)
#define ferror(p) (((p)->_flag&_IOERR)!=0)
#define fileno(p) p->_file
FILE *fopen();
FILE *fdopen();
FILE *freopen();
long ftell();
char *fgets();
symbol.h
/*
* Structure of a symbol table entry
*/
struct symbol {
char sy_name[8];
char sy_type;
int sy_value;
};
sys/acct.h
/*
* Accounting structures
*/
typedef unsigned short comp_t; /* "floating pt": 3 bits base 8 exp, 13 bits fraction */
struct acct
{
char ac_comm[10]; /* Accounting command name */
comp_t ac_utime; /* Accounting user time */
comp_t ac_stime; /* Accounting system time */
comp_t ac_etime; /* Accounting elapsed time */
time_t ac_btime; /* Beginning time */
short ac_uid; /* Accounting user ID */
short ac_gid; /* Accounting group ID */
short ac_mem; /* average memory usage */
comp_t ac_io; /* number of disk IO blocks */
dev_t ac_tty; /* control typewriter */
char ac_flag; /* Accounting flag */
};
#define AFORK 01 /* has executed fork, but no exec */
#define ASU 02 /* used super-user privileges */
sys/buf.h
/*
* Each buffer in the pool is usually doubly linked into 2 lists:
* the device with which it is currently associated (always)
* and also on a list of blocks available for allocation
* for other use (usually).
* The latter list is kept in last-used order, and the two
* lists are doubly linked to make it easy to remove
* a buffer from one list when it was found by
* looking through the other.
* A buffer is on the available list, and is liable
* to be reassigned to another disk block, if and only
* if it is not marked BUSY. When a buffer is busy, the
* available-list pointers can be used for other purposes.
* Most drivers use the forward ptr as a link in their I/O
* active queue.
* A buffer header contains all the information required
* to perform I/O.
* Most of the routines which manipulate these things
* are in bio.c.
*/
struct buf
{
int b_flags; /* see defines below */
struct buf *b_forw; /* headed by d_tab of conf.c */
struct buf *b_back; /* " */
struct buf *av_forw; /* position on free list, */
struct buf *av_back; /* if not BUSY*/
dev_t b_dev; /* major+minor device name */
unsigned b_bcount; /* transfer count */
union {
caddr_t b_addr; /* low order core address */
int *b_words; /* words for clearing */
struct filsys *b_filsys; /* superblocks */
struct dinode *b_dino; /* ilist */
daddr_t *b_daddr; /* indirect block */
} b_un;
daddr_t b_blkno; /* block # on device */
char b_xmem; /* high order core address */
char b_error; /* returned after I/O */
unsigned int b_resid; /* words not transferred after error */
struct proc *b_proc; /* process doing physical or swap I/O */
};
extern struct buf buf[]; /* The buffer pool itself */
extern struct buf bfreelist; /* head of available list */
/*
* These flags are kept in b_flags.
*/
#define B_WRITE 0 /* non-read pseudo-flag */
#define B_READ 01 /* read when I/O occurs */
#define B_DONE 02 /* transaction finished */
#define B_ERROR 04 /* transaction aborted */
#define B_BUSY 010 /* not on av_forw/back list */
#define B_PHYS 020 /* Physical IO potentially using UNIBUS map */
#define B_MAP 040 /* This block has the UNIBUS map allocated */
#define B_WANTED 0100 /* issue wakeup when BUSY goes off */
#define B_AGE 0200 /* delayed write for correct aging */
#define B_ASYNC 0400 /* don't wait for I/O completion */
#define B_DELWRI 01000 /* don't write till block leaves available list */
#define B_UAREA 04000 /* add u-area to a swap operation */
#define B_TAPE 02000 /* this is a magtape (no bdwrite) */
/*
* special redeclarations for
* the head of the queue per
* device driver.
*/
#define b_actf av_forw
#define b_actl av_back
#define b_active b_bcount
#define b_errcnt b_resid
sys/callo.h
/*
* The callout structure is for
* a routine arranging
* to be called by the clock interrupt
* (clock.c) with a specified argument,
* in a specified amount of time.
* Used, for example, to time tab
* delays on typewriters.
*/
struct callo
{
int c_time; /* incremental time */
caddr_t c_arg; /* argument to routine */
int (*c_func)(); /* routine */
};
struct callo callout[NCALL];
sys/chan.h
#define NGROUPS 10
#define NCHANS 20
#define DCHAN 1
#define CCHAN 0
struct chan {
short c_flags;
char c_index;
char c_msg;
struct group *c_group;
struct tty *c_ttyp;
struct file *c_fy;
int c_pgrp;
union {
struct clist datq;
} cx;
union {
struct clist datq;
struct chan *c_chan;
} cy;
struct clist c_ctlx;
struct clist c_ctly;
};
struct group {
short g_state;
char g_mindex;
short g_index;
short g_count;
struct inode *g_inode;
struct group *g_master;
struct clist g_cntl;
struct clist g_datq;
};
/*
* flags
*/
#define INUSE 01
#define COPEN 02
#define XGRP 04
#define YGRP 010
#define WCLOSE 020
#define TTYO 040
#define SUBGRP 0100
#define BLOCK 0200
#define BLOCK1 0400
#define SIGBLK 01000
#define BLKMSG 01000
#define ENAMSG 02000
#define WFLUSH 04000
#define RZERO 010000
/*
* mpxchan command codes
*/
#define GROUP 5
#define GROUPN 6
#define CHAN 1
#define JOIN 2
#define EXTR 3
#define ATTACH 4
#define CONNECT 7
#define DETACH 8
#define DISCON 9
#define DEBUG 10
#define NPGRP 11
#define CSIG 12
#define PACK 13
#define NDEBUGS 30
/*
* control channel message codes
*/
#define WATTCH 1
#define M_WATCH 1
#define SCLOSE 2
#define M_CLOSE 2
#define M_ATTACH 3
#define M_BLK 4
#define M_UBLK 5
#define DO_BLK 6
#define DO_UBLK 7
#define M_XINT 8
#define M_RINT 9
#define M_ACK 10
#define M_NAK 11
/*
* debug codes other than mpxchan cmds
*/
#define MCCLOSE 29
#define MCOPEN 28
#define ALL 27
#define SCON 26
#define MSREAD 25
#define SDATA 24
#define MCREAD 23
#define MCWRITE 22
/* HDRSIZE == NLEVELS + sizeof (short) */
#define HDRSIZE 4
#define NLEVELS 2
union u_index {
short val;
char bytes[NLEVELS];
};
typedef union u_index index_t;
sys/conf.h
/*
* Declaration of block device
* switch. Each entry (row) is
* the only link between the
* main unix code and the driver.
* The initialization of the
* device switches is in the
* file conf.c.
*/
extern struct bdevsw
{
int (*d_open)();
int (*d_close)();
int (*d_strategy)();
struct buf *d_tab;
} bdevsw[];
/*
* Character device switch.
*/
extern struct cdevsw
{
int (*d_open)();
int (*d_close)();
int (*d_read)();
int (*d_write)();
int (*d_ioctl)();
struct tty *d_ttys;
} cdevsw[];
/*
* tty line control switch.
*/
extern struct linesw
{
int (*l_open)();
int (*l_close)();
int (*l_read)();
int (*l_write)();
int (*l_ioctl)();
int (*l_rint)();
int (*l_start)();
} linesw[];
sys/dir.h
#ifndef DIRSIZ
#define DIRSIZ 14
#endif
struct direct
{
ino_t d_ino;
char d_name[DIRSIZ];
};
sys/fblk.h
struct fblk
{
int df_nfree;
daddr_t df_free[NICFREE];
};
sys/file.h
/*
* One file structure is allocated
* for each open/creat/pipe call.
* Main use is to hold the read/write
* pointer associated with each open
* file.
*/
struct file
{
char f_flag;
char f_count; /* reference count */
struct inode *f_inode; /* pointer to inode structure */
union {
off_t f_offset; /* read/write character pointer */
struct chan *f_chan; /* mpx channel pointer */
} f_un;
};
extern struct file file[]; /* The file table itself */
/* flags */
#define FREAD 01
#define FWRITE 02
#define FPIPE 04
#define FMPX 010
#define FMPY 020
#define FMP 030
sys/filsys.h
/*
* Structure of the super-block
*/
struct filsys {
unsigned short s_isize; /* size in blocks of i-list */
daddr_t s_fsize; /* size in blocks of entire volume */
short s_nfree; /* number of addresses in s_free */
daddr_t s_free[NICFREE];/* free block list */
short s_ninode; /* number of i-nodes in s_inode */
ino_t s_inode[NICINOD];/* free i-node list */
char s_flock; /* lock during free list manipulation */
char s_ilock; /* lock during i-list manipulation */
char s_fmod; /* super block modified flag */
char s_ronly; /* mounted read-only flag */
time_t s_time; /* last super block update */
/* remainder not maintained by this version of the system */
daddr_t s_tfree; /* total free blocks*/
ino_t s_tinode; /* total free inodes */
short s_m; /* interleave factor */
short s_n; /* " " */
char s_fname[6]; /* file system name */
char s_fpack[6]; /* file system pack name */
};
sys/ino.h
/* Inode structure as it appears on a disk block. */
struct dinode
{
unsigned short di_mode; /* mode and type of file */
short di_nlink; /* number of links to file */
short di_uid; /* owner's user id */
short di_gid; /* owner's group id */
off_t di_size; /* number of bytes in file */
char di_addr[40]; /* disk block addresses */
time_t di_atime; /* time last accessed */
time_t di_mtime; /* time last modified */
time_t di_ctime; /* time created */
};
#define INOPB 8 /* 8 inodes per block */
/*
* the 40 address bytes:
* 39 used; 13 addresses
* of 3 bytes each.
*/
sys/inode.h
/*
* The I node is the focus of all
* file activity in unix. There is a unique
* inode allocated for each active file,
* each current directory, each mounted-on
* file, text file, and the root. An inode is 'named'
* by its dev/inumber pair. (iget/iget.c)
* Data, from mode on, is read in
* from permanent inode on volume.
*/
#define NADDR 13
#define NINDEX 15
struct group {
short g_state;
char g_index;
char g_rot;
struct group *g_group;
struct inode *g_inode;
struct file *g_file;
short g_rotmask;
short g_datq;
struct chan *g_chans[NINDEX];
};
struct inode
{
char i_flag;
char i_count; /* reference count */
dev_t i_dev; /* device where inode resides */
ino_t i_number; /* i number, 1-to-1 with device address */
unsigned short i_mode;
short i_nlink; /* directory entries */
short i_uid; /* owner */
short i_gid; /* group of owner */
off_t i_size; /* size of file */
union {
struct {
daddr_t i_addr[NADDR]; /* if normal file/directory */
daddr_t i_lastr; /* last logical block read (for read-ahead) */
};
struct {
daddr_t i_rdev; /* i_addr[0] */
struct group i_group; /* multiplexor group file */
};
} i_un;
};
extern struct inode inode[]; /* The inode table itself */
/* flags */
#define ILOCK 01 /* inode is locked */
#define IUPD 02 /* file has been modified */
#define IACC 04 /* inode access time to be updated */
#define IMOUNT 010 /* inode is mounted on */
#define IWANT 020 /* some process waiting on lock */
#define ITEXT 040 /* inode is pure text prototype */
#define ICHG 0100 /* inode has been changed */
/* modes */
#define IFMT 0170000 /* type of file */
#define IFDIR 0040000 /* directory */
#define IFCHR 0020000 /* character special */
#define IFBLK 0060000 /* block special */
#define IFREG 0100000 /* regular */
#define IFMPC 0030000 /* multiplexed char special */
#define IFMPB 0070000 /* multiplexed block special */
#define ISUID 04000 /* set user id on execution */
#define ISGID 02000 /* set group id on execution */
#define ISVTX 01000 /* save swapped text even after use */
#define IREAD 0400 /* read, write, execute permissions */
#define IWRITE 0200
#define IEXEC 0100
sys/map.h
struct map
{
short m_size;
unsigned short m_addr;
};
int memmap[CMAPSIZ]; /* space for core allocation */
struct map swapmap[SMAPSIZ]; /* space for swap allocation */
/*
uba
*/
char bdpwant , umrwant ;
struct map ubamap[UAMSIZ];
struct map bdpmap[15];
sys/mount.h
/*
* Mount structure.
* One allocated on every mount.
* Used to find the super block.
*/
struct mount
{
dev_t m_dev; /* device mounted */
struct buf *m_bufp; /* pointer to superblock */
struct inode *m_inodp; /* pointer to mounted on inode */
} mount[NMOUNT];
sys/mpx.h
#define M 3
#define C 100
/*
* character Q structure
*/
struct clist
{
int c_cc;
int c_cf;
int c_cl;
};
struct chan
{
char cflag;
char m, c;
struct chan *dest;
struct clist ioq;
};
/* c flags */
#define BLOCK 01
struct line
{
char xbuf[24+2];
char rbuf[100+2];
char rseq;
char xseq;
char ackf;
char xflag;
char state;
char time;
int sum;
char *ip;
char *ep;
};
#define WWAIT 02
#define CRUN 04
#define RWAIT 010
#define ALLOC 020
#define DIS 040
#define DLY 0100
/*
* machine structure
*/
struct mach
{
char mflag;
char rchan;
char rcount;
char xchan;
char xcount;
struct clist ackq;
struct clist datq;
struct clist disq;
struct chan *chanp[128];
};
/* m flags */
#define RNEXT 01
#define MRUN 04
#define XNEXT 010
/*
* trace buffer
*/
#define TBSIZ 100
sys/pack.h
struct pack {
short p_state; /* line state */
short p_bits; /* mask for getepack */
short p_psize; /* packet size */
short p_icount; /* input byte count */
char p_ostate; /* output state */
char p_istate; /* input state */
char p_msgs; /* # cntl msgs sent */
char p_window; /* window size */
char p_iseq; /* input SEQ byte */
char p_oseq; /* output SEQ byte */
char p_msg; /* control msg */
char p_msg2; /* extra msg bits */
char p_ps,p_pr; /* last packet sent, recv'd */
char p_rps,p_rpr; /* remote (received) ps and pr */
char p_nxtps; /* next output seq number */
char p_nxtpr; /* expected input seq number */
char p_prcopy; /* oldest received packet in kernel */
char p_pscopy; /* newest output packet */
char *p_input; /* points into input buffer */
char p_iobuf[6]; /* cntl packet buffer */
char *p_ob[8]; /* output buffers */
char *p_ib[8]; /* input buffers */
char p_bstate[8]; /* output buffer status */
char p_cstate[8]; /* input buffer status */
short p_checks[8];
short p_rcheck;
struct tty *p_ttyp;
int p_timer;
int xcount,rcount;
};
#define NPSTRUCT (1+(sizeof(struct pack))/64)
#define NPERBUF (8/NPSTRUCT)
#define CHECK 0125252
int npbits;
/*
* driver state
*/
#define DEAD 0
#define INITa 1
#define INITb 2
#define ISINIT 3
#define LIVE 4
#define RESYNC 010
#define DOWN 020
#define RREJ 040
#define RXMIT 0100
#define PDEBUG 0200
#define DRAINO 0400
#define WAITO 01000
/*
* input side states
*/
#define P_IDLE 1
#define P_SCAN 2
#define P_SEQ1 3
#define P_PACK 4
#define P_CHK1 5
#define P_CHK2 6
#define P_SEQ2 7
#define P_FLUSH 8
#define SYN 026
/*
* output side states
*/
#define T_IDLE 0
#define T_READY 1
#define T_HDR 2
#define T_PACK 3
#define T_TAIL 4
/*
* io buffer states
*/
#define B_FREE 0
#define B_READY 1
#define B_SENT 2
#define B_PACK 4
#define B_COPY 010
#define B_XMIT 020
/*
* frame control messages
*/
#define RR 1
#define RWR 2
#define REJ 3
#define CLOSE 4
#define RESET 6
#define INIT 7
#define UA 8
#define PKOPRI 31
#define PKIPRI 30
#define NPLINES 8
/*
* packet ioctl buf
*/
struct piocb {
unsigned t;
short psize;
short mode;
short state;
char window;
};
sys/param.h
/*
* tunable variables
*/
#define NBUF 32 /* size of buffer cache */
#define NINODE 150 /* number of in core inodes */
#define NFILE 175 /* number of in core file structures */
#define NMOUNT 8 /* number of mountable file systems */
#define MAXMEM 1024 /* max core in 512-byte clicks */
/*
***********************************************************
* NOTE: For the moment, MAXUMEM must be less than 12*128 *
***********************************************************
*/
#define MAXUMEM (MAXMEM - 128) /* max no. clicks per process */
#define SWAPSIZE 16 /* granularity of partial swaps (in clicks) */
#define MAXUPRC 25 /* max processes per user */
#define SSIZE 4 /* initial stack size (*512 bytes) */
#define SINCR 2 /* increment of stack (*512 bytes) */
#define NOFILE 20 /* max open files per process */
#define CANBSIZ 256 /* max size of typewriter line */
#define CMAPSIZ (PHYSPAGES/32) /* size of core allocation area */
#define SMAPSIZ 70 /* size of swap allocation area */
#define NCALL 20 /* max simultaneous time callouts */
#define NPROC 125 /* max number of processes */
#define NTEXT 80 /* max number of pure texts */
#define NCLIST 200 /* max total clist size */
#define HZ 60 /* Ticks/second of the clock */
#define TIMEZONE (5*60) /* Minutes westward from Greenwich */
#define DSTFLAG 1 /* Daylight Saving Time applies in this locality */
#define MSGBUFS 128 /* Characters saved from error messages */
#define NCARGS 5120 /* # characters in exec arglist */
#define USRSTACK 0x80000000 /* Start of user stack */
#define PHYSPAGES 2048 /* max number of real memory pages */
/*
* priorities
* probably should not be
* altered too much
*/
#define PSWP 0
#define PINOD 10
#define PRIBIO 20
#define PZERO 25
#define NZERO 20
#define PPIPE 26
#define PWAIT 30
#define PSLEP 40
#define PUSER 50
/*
* signals
* dont change
*/
#define NSIG 17
/*
* No more than 16 signals (1-16) because they are
* stored in bits in a word.
*/
#define SIGHUP 1 /* hangup */
#define SIGINT 2 /* interrupt (rubout) */
#define SIGQUIT 3 /* quit (FS) */
#define SIGINS 4 /* illegal instruction */
#define SIGTRC 5 /* trace or breakpoint */
#define SIGIOT 6 /* iot */
#define SIGEMT 7 /* emt */
#define SIGFPT 8 /* floating exception */
#define SIGKIL 9 /* kill, uncatchable termination */
#define SIGBUS 10 /* bus error */
#define SIGSEG 11 /* segmentation violation */
#define SIGSYS 12 /* bad system call */
#define SIGPIPE 13 /* end of pipe */
#define SIGCLK 14 /* alarm clock */
#define SIGTRM 15 /* Catchable termination */
/*
* fundamental constants of the implementation--
* cannot be changed easily
*/
#define NBPW sizeof(int) /* number of bytes in an integer */
#define BSIZE 512 /* size of secondary block (bytes) */
/* BSLOP can be 0 unless you have a TIU/Spider */
# define BSLOP 0 /* In case some device needs bigger buffers */
#define NINDIR (BSIZE/sizeof(daddr_t))
#define BMASK 0777 /* BSIZE-1 */
#define BSHIFT 9 /* LOG2(BSIZE) */
#define NMASK 0177 /* NINDIR-1 */
#define NSHIFT 7 /* LOG2(NINDIR) */
#define UPAGES 4 /* pages of u-area (not including page tables ) */
#define USIZE (UPAGES + u.u_pcb.pcb_szpt) /* size of user block (*512) */
#define NULL 0
#define CMASK 0 /* default mask for file creation */
#define NODEV (dev_t)(-1)
#define ROOTINO ((ino_t)2) /* i number of all roots */
#define SUPERB ((daddr_t)1) /* block number of the super block */
#define DIRSIZ 14 /* max characters per directory */
#define NICINOD 100 /* number of superblock inodes */
#define NICFREE 50 /* number of superblock free blocks */
#define NICMEM 100 /* number of "cheap" free page frames */
#define CBSIZE 12 /* number of chars in a clist block */
#define CROUND 0xF /* clist rounding; sizeof(int *) + CBSIZE -1*/
#define CLKTICK (1000000/HZ) /* microseconds in a clock tick */
/*
* Some macros for units conversion
*/
/* Core clicks (512 bytes) to segments and vice versa */
#define ctos(x) (x)
#define stoc(x) (x)
/* Core clicks (512 bytes) to disk blocks */
#define ctod(x) (x)
/* inumber to disk address */
#define itod(x) (daddr_t)((((unsigned)x+15)>>3))
/* inumber to disk offset */
#define itoo(x) (int)((x+15)&07)
/* clicks to bytes */
#define ctob(x) (x<<9)
/* bytes to clicks */
#define btoc(x) ((((unsigned)x+511)>>9))
/* major part of a device */
#define major(x) (int)(((unsigned)x>>8)&0377)
/* minor part of a device */
#define minor(x) (int)(x&0377)
/* make a device number */
#define makedev(x,y) (dev_t)(((x)<<8) | (y))
typedef struct { int r[1]; } * physadr;
typedef int daddr_t;
typedef char * caddr_t;
typedef unsigned short ino_t;
typedef int time_t;
typedef int label_t[10];
typedef short dev_t;
typedef int off_t;
/*
* Machine-dependent bits and macros
*/
#define UMODE PSL_CURMOD /* usermode bits */
#define USERMODE(ps) ((ps & UMODE) == UMODE)
#define BASEPRI(ps) ((ps & PSL_IPL) != 0)
sys/pcb.h
/*
VAX process control block
*/
struct pcb {
int
pcb_ksp, /* kernal stack pointer */
pcb_esp, /* exec stack pointer */
pcb_ssp, /* supervisor stack pointer */
pcb_usp, /* user stack pointer */
pcb_r0,
pcb_r1,
pcb_r2,
pcb_r3,
pcb_r4,
pcb_r5,
pcb_r6,
pcb_r7,
pcb_r8,
pcb_r9,
pcb_r10,
pcb_r11,
pcb_r12,
pcb_r13,
pcb_pc, /* program counter */
pcb_psl, /* program status longword */
pcb_p0br, /* seg 0 base register */
pcb_p0lr, /* seg 0 length register and astlevel */
pcb_p1br, /* seg 1 base register */
pcb_p1lr, /* seg 1 length register and pme */
/*
Software pcb (extension)
*/
pcb_szpt; /* number of pages of user page table */
};
sys/pk.h
struct header {
char sync;
char ksize;
unsigned short sum;
char cntl;
char ccntl;
};
#define HDRSIZ 6
struct pack {
short p_state; /* line state */
short p_bits; /* mask for getepack */
short p_rsize; /* input packet size */
short p_xsize; /* output packet size */
struct header p_ihbuf; /* input header */
struct header p_ohbuf; /* output header */
char *p_rptr;
char p_mode;
char **p_ipool;
char p_xcount; /* # active output buffers */
char p_rcount;
char p_nout,p_tout;
char p_lpsize; /* log(psize/32) */
char p_timer;
char p_obusy;
char p_srxmit;
char p_rwindow; /* window size */
char p_swindow;
char p_msg; /* control msg */
char p_rmsg; /* repeated control msg */
char p_ps,p_pr; /* last packet sent, recv'd */
char p_rpr;
char p_nxtps; /* next output seq number */
char p_imap; /* bit map of input buffers */
char p_pscopy; /* newest output packet */
char *p_ob[8]; /* output buffers */
char *p_ib[8]; /* input buffers */
char p_os[8]; /* output buffer status */
char p_is[8]; /* input buffer status */
short p_osum[8]; /* output checksums */
short p_isum[8]; /* input checksums */
DSYSTEM;
};
#define CHECK 0125252
#define SYN 020
#define MOD8 7
#define ISCNTL(a) ((a & 0300)==0)
#define MIN(a,b) ((a<b)? a:b)
char next[8];
char mask[8];
int npbits;
int pkactive;
/*
* driver state
*/
#define DEAD 0
#define INITa 1
#define INITb 2
#define INITab 3
#define LIVE 010
#define RXMIT 020
#define RREJ 040
#define PDEBUG 0200
#define DRAINO 0400
#define WAITO 01000
#define DOWN 02000
#define RCLOSE 04000
#define BADFRAME 020000
/*
* io buffer states
*/
#define B_NULL 0
#define B_READY 1
#define B_SENT 2
#define B_RESID 010
#define B_COPY 020
#define B_MARK 040
#define B_SHORT 0100
/*
* control messages
*/
#define CLOSE 1
#define RJ 2
#define SRJ 3
#define RR 4
#define INITC 5
#define INITB 6
#define INITA 7
#define M_RJ 4
#define M_SRJ 010
#define M_RR 020
#define M_INITC 040
#define M_CLOSE 2
#define M_INITA 0200
#define M_INITB 0100
#define PKOPRI 31
#define PKIPRI 30
#define NPLINES 8
/*
* packet ioctl buf
*/
struct piocb {
unsigned t;
short psize;
short mode;
short state;
char window;
};
int pkdebug;
int pksizes[];
sys/pk.p
/*
* kernel level
*/
#ifdef KERNEL
#define PADDR ((struct pack *)tp->t_linep)
#define TURNOFF pkturnoff(tp)
#define UCOUNT u.u_count
#define S tp
#define P pk->p_ttyp
#define SDEF struct tty *tp
#define FS , tp
#define SIGNAL signal(pk->p_ttyp->t_pgrp, SIGPIPE)
#define TERROR pk->p_istate == R_ERROR
#define SETERROR u.u_error = EIO
#define OBUSY tp->t_state&BUSY
#define GETEPACK getepack(pk->p_bits)
char * getepack();
#define FREEPACK(a,b) freepack(a, b)
#define q1 tp->t_rawq
#define q2 tp->t_canq
#define q3 tp->t_outq
#define LOCK s = spl6()
#define UNLOCK splx(s)
#define DSYSTEM struct tty *p_ttyp
#define ISYSTEM tp = pk->p_ttyp
#define SLEEP(a, b) sleep((caddr_t)a, b)
#define SLEEPNO (tp->t_chan!=NULL)
#define WAKEUP(a) wakeup((caddr_t)a)
#define IOMOVE(p, c, f) iomove(p, c, f)
#define PKGETPKT(p)
#define DTOM(a) dtom(a)
#include "../h/param.h"
#include "../h/dir.h"
#include "../h/user.h"
#include "../h/pk.h"
#include "../h/tty.h"
#include "../h/buf.h"
#include "../h/proc.h"
#endif
/*
* user level
*/
#ifdef USER
#define SLEEP(a, b)
#define SIGNAL
#define WAKEUP(a)
#define DSYSTEM int p_ifn, p_ofn
#define ISYSTEM
#define GETEPACK malloc(pk->p_xsize)
#define FREEPACK(a, b) free(a)
#define OBUSY 0
#define PKGETPKT(p) pkgetpack(p);
#define DTOM(a) 1;
#define S ipk, ibuf, icount
#define SDEF int icount; char *ibuf; struct pack *ipk
#define UCOUNT icount
#define IOMOVE(p, c, f) pkmove(p, ibuf, c, f) ; ibuf += c; UCOUNT -= c
#define PADDR ipk
#define TURNOFF
#define LOCK
#define UNLOCK
#define SETERROR
#define GENERROR(p, s)
#define PACKSIZE 64
#define WINDOWS 3
#define PKDEBUG(l, f, s) { extern Debug; if (Debug >= l) fprintf(stderr, f, s);}
#define PKASSERT(e, f, v) if (!(e)) {\
fprintf(stderr, "AERROR - (%s) ", "e");\
fprintf(stderr, f, v);\
pkfail();};
#endif
sys/prim.h
#define NOSLEEP 0400
#define FORCE 01000
#define NORM 02000
#define KEEP 04000
#define CLR 010000
int bwaiting,wcount;
char *getepack();
sys/proc.h
/*
* One structure allocated per active
* process. It contains all data needed
* about the process while the
* process may be swapped out.
* Other per process data (user.h)
* is swapped with the process.
*/
struct proc {
char p_stat;
char p_flag;
char p_pri; /* priority, negative is high */
char p_time; /* resident time for scheduling */
char p_cpu; /* cpu usage for scheduling */
char p_nice; /* nice for cpu usage */
short p_sig; /* signals pending to this process */
short p_uid; /* user id, used to direct tty signals */
short p_pgrp; /* name of process group leader */
short p_pid; /* unique process id */
short p_ppid; /* process id of parent */
short p_addr[UPAGES]; /* page table entries of u-area */
short p_size; /* size of swappable image (clicks) */
short p_swaddr; /* disk address when swapped */
short p_swsize; /* number of clicks already swapped */
short p_tsize; /* size of text (used by exec/swapin) */
caddr_t p_wchan; /* event process is awaiting */
struct text *p_textp; /* pointer to text structure */
struct proc *p_link; /* linked list of running processes */
int p_clktim; /* time to alarm clock signal */
};
extern struct proc proc[]; /* the proc table itself */
/* stat codes */
#define SSLEEP 1 /* awaiting an event */
#define SWAIT 2 /* (abandoned state) */
#define SRUN 3 /* running */
#define SIDL 4 /* intermediate state in process creation */
#define SZOMB 5 /* intermediate state in process termination */
#define SSTOP 6 /* process being traced */
/* flag codes */
#define SLOAD 01 /* in core */
#define SSYS 02 /* scheduling process */
#define SLOCK 04 /* process cannot be swapped */
#define SSWAP 010 /* process is being swapped out */
#define STRC 020 /* process is being traced */
#define SWTED 040 /* another tracing flag */
#define SULOCK 0100 /* user settable lock in core */
#define SSPART 0200 /* process is partially swapped out */
/*
* parallel proc structure
* to replace part with times
* to be passed to parent process
* in ZOMBIE state.
*/
struct xproc {
char xp_stat;
char xp_flag;
char xp_pri; /* priority, negative is high */
char xp_time; /* resident time for scheduling */
char xp_cpu; /* cpu usage for scheduling */
char xp_nice; /* nice for cpu usage */
short xp_sig; /* signals pending to this process */
short xp_uid; /* user id, used to direct tty signals */
short xp_pgrp; /* name of process group leader */
short xp_pid; /* unique process id */
short xp_ppid; /* process id of parent */
short xp_xstat; /* Exit status for wait */
time_t xp_utime; /* user time, this proc */
time_t xp_stime; /* system time, this proc */
};
sys/psl.h
/*
VAX program status longword
*/
#define PSL_C 0x1 /* carry bit */
#define PSL_V 0x2 /* overflow bit */
#define PSL_Z 0x4 /* zero bit */
#define PSL_N 0x8 /* negative bit */
#define PSL_T 0x10 /* trace enable bit */
#define PSL_IV 0x20 /* integer overflow enable bit */
#define PSL_FU 0x40 /* floating point underflow enable bit */
#define PSL_DV 0x80 /* decimal overflow enable bit */
#define PSL_IPL 0x1f0000 /* interrupt priority level */
#define PSL_PRVMOD 0xc00000 /* previous mode */
#define PSL_CURMOD 0x3000000 /* current mode */
#define PSL_IS 0x4000000 /* interrupt stack */
#define PSL_FPD 0x8000000 /* first part done */
#define PSL_TP 0x40000000 /* trace pending */
#define PSL_CM 0x80000000 /* compatibility mode */
sys/reg.h
/*
* Location of the users' stored
* registers relative to R0.
* Usage is u.u_ar0[XX].
*/
#define R0 0
#define R1 1
#define R2 2
#define R3 3
#define R4 4
#define R5 5
#define R6 6
#define R7 7
#define R8 8
#define R9 9
#define R10 10
#define R11 11
#define R12 12
#define R13 13
#define AP 12
#define FP 13
#define SP 14
#define PS 18
#define PC 17
sys/seg.h
/*
* Mapper addresses and bits
*/
#define RO PG_URKR /* access abilities */
#define RW PG_UW
sys/stat.h
struct stat
{
dev_t st_dev;
ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
dev_t st_rdev;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
#define S_IFMT 0170000 /* type of file */
#define S_IFDIR 0040000 /* directory */
#define S_IFCHR 0020000 /* character special */
#define S_IFBLK 0060000 /* block special */
#define S_IFREG 0100000 /* regular */
#define S_IFMPC 0030000 /* multiplexed char special */
#define S_IFMPB 0070000 /* multiplexed block special */
#define S_ISUID 0004000 /* set user id on execution */
#define S_ISGID 0002000 /* set group id on execution */
#define S_ISVTX 0001000 /* save swapped text even after use */
#define S_IREAD 0000400 /* read permission, owner */
#define S_IWRITE 0000200 /* write permission, owner */
#define S_IEXEC 0000100 /* execute/search permission, owner */
sys/systm.h
/*
* Random set of variables
* used by more than one
* routine.
*/
char canonb[CANBSIZ]; /* buffer for erase and kill (#@) */
struct inode *rootdir; /* pointer to inode of root directory */
struct proc *runq; /* head of linked list of running processes */
int cputype; /* type of cpu =40, 45, or 70 */
int lbolt; /* time of day in 60th not in time */
time_t time; /* time in sec from 1970 */
/*
* Nblkdev is the number of entries
* (rows) in the block switch. It is
* set in binit/bio.c by making
* a pass over the switch.
* Used in bounds checking on major
* device numbers.
*/
int nblkdev;
/*
* Number of character switch entries.
* Set by cinit/tty.c
*/
int nchrdev;
int mpid; /* generic for unique process id's */
char runin; /* scheduling flag */
char runout; /* scheduling flag */
char runrun; /* scheduling flag */
char curpri; /* more scheduling */
int maxmem; /* actual max memory per process */
int physmem; /* physical memory on this CPU */
int freemem; /* remaining blocks of free memory */
daddr_t swplo; /* block number of swap space */
int nswap; /* size of swap space */
int updlock; /* lock for sync */
daddr_t rablock; /* block to be read ahead */
char msgbuf[MSGBUFS]; /* saved "printf" characters */
int intstack[512]; /* stack for interrupts */
dev_t rootdev; /* device of the root */
dev_t swapdev; /* swapping device */
dev_t pipedev; /* pipe device */
extern int icode[]; /* user init code */
extern int szicode; /* its size */
dev_t getmdev();
daddr_t bmap();
struct inode *ialloc();
struct inode *iget();
struct inode *owner();
struct inode *maknode();
struct inode *namei();
struct buf *alloc();
struct buf *getblk();
struct buf *geteblk();
struct buf *bread();
struct buf *breada();
struct filsys *getfs();
struct file *getf();
struct file *falloc();
int uchar();
caddr_t realaddr();
caddr_t checkio();
/*
* Instrumentation
*/
int dk_busy;
long dk_time[32];
long dk_numb[3];
long dk_wds[3];
long tk_nin;
long tk_nout;
/*
* Structure of the system-entry table
*/
extern struct sysent {
char sy_narg; /* total number of arguments */
char sy_nrarg; /* number of args in registers */
int (*sy_call)(); /* handler */
} sysent[];
sys/text.h
/*
* Text structure.
* One allocated per pure
* procedure on swap device.
* Manipulated by text.c
*/
struct text
{
short x_daddr; /* disk address of segment (relative to swplo) */
short x_size; /* size (clicks) */
struct proc *x_caddr; /* ptr to linked proc, if loaded */
struct inode *x_iptr; /* inode of prototype */
char x_count; /* reference count */
char x_ccount; /* number of loaded references */
char x_flag; /* traced, written flags */
};
extern struct text text[];
#define XTRC 01 /* Text may be written, exclusive use */
#define XWRIT 02 /* Text written into, must swap out */
#define XLOAD 04 /* Currently being read from file */
#define XLOCK 010 /* Being swapped in or out */
#define XWANT 020 /* Wanted for swapping */
sys/timeb.h
/*
* Structure returned by ftime system call
*/
struct timeb {
time_t time;
unsigned short millitm;
short timezone;
short dstflag;
};
sys/times.h
/*
* Structure returned by times()
*/
struct tms {
time_t tms_utime; /* user time */
time_t tms_stime; /* system time */
time_t tms_cutime; /* user time, children */
time_t tms_cstime; /* system time, children */
};
sys/tty.h
/*
* A clist structure is the head
* of a linked list queue of characters.
* The characters are stored in 4-word
* blocks containing a link and several characters.
* The routines getc and putc
* manipulate these structures.
*/
struct clist
{
int c_cc; /* character count */
char *c_cf; /* pointer to first char */
char *c_cl; /* pointer to last char */
};
/*
* A tty structure is needed for
* each UNIX character device that
* is used for normal terminal IO.
* The routines in tty.c handle the
* common code associated with
* these structures.
* The definition and device dependent
* code is in each driver. (kl.c dc.c dh.c)
*/
struct tty
{
struct clist t_rawq; /* input chars right off device */
struct clist t_canq; /* input chars after erase and kill */
struct clist t_outq; /* output list to device */
int (* t_oproc)(); /* routine to start output */
int (* t_iproc)(); /* routine to start input */
struct chan *t_chan; /* destination channel */
caddr_t t_linep; /* aux line discipline pointer */
caddr_t t_addr; /* device address */
short t_flags; /* mode, settable by ioctl call */
short t_state; /* internal state, not visible externally */
short t_pgrp; /* process group name */
char t_delct; /* number of delimiters in raw q */
char t_line; /* line discipline */
char t_col; /* printing column of device */
char t_erase; /* erase character */
char t_kill; /* kill character */
char t_char; /* character temporary */
char t_ispeed; /* input speed */
char t_ospeed; /* output speed */
};
/*
* structure of arg for ioctl
*/
struct ttiocb {
char ioc_ispeed;
char ioc_ospeed;
char ioc_erase;
char ioc_kill;
int ioc_flags;
};
#define TTIPRI 28
#define TTOPRI 29
#define CERASE '#' /* default special characters */
#define CEOT 004
#define CKILL '@'
#define CQUIT 034 /* FS, cntl shift L */
#define CINTR 0177 /* DEL */
#define CSTOP 023 /* Stop output: ctl-s */
#define CSTART 021 /* Start output: ctl-q */
/* limits */
#define TTHIWAT 100
#define TTLOWAT 50
#define TTYHOG 256
/* modes */
#define TANDEM 01
#define CBREAK 02
#define LCASE 04
#define ECHO 010
#define CRMOD 020
#define RAW 040
#define ODDP 0100
#define EVENP 0200
#define NLDELAY 001400
#define TBDELAY 006000
#define XTABS 006000
#define CRDELAY 030000
#define VTDELAY 040000
/* Hardware bits */
#define DONE 0200
#define IENABLE 0100
/* Internal state bits */
#define TIMEOUT 01 /* Delay timeout in progress */
#define WOPEN 02 /* Waiting for open to complete */
#define ISOPEN 04 /* Device is open */
#define CARR_ON 020 /* Software copy of carrier-present */
#define BUSY 040 /* Output in progress */
#define ASLEEP 0100 /* Wakeup when output done */
#define XCLUDE 0200 /* exclusive-use flag against open */
#define TTSTOP 0400 /* Output stopped by ctl-s */
#define HUPCLS 01000 /* Hang up upon last close */
#define TBLOCK 02000 /* tandem queue blocked */
/*
* tty ioctl commands
*/
#define TIOCGETD (('t'<<8)|0)
#define TIOCSETD (('t'<<8)|1)
#define TIOCHPCL (('t'<<8)|2)
#define TIOCMODG (('t'<<8)|3)
#define TIOCMODS (('t'<<8)|4)
#define TIOCGETP (('t'<<8)|8)
#define TIOCSETP (('t'<<8)|9)
#define TIOCSETN (('t'<<8)|10)
#define TIOCEXCL (('t'<<8)|13)
#define TIOCNXCL (('t'<<8)|14)
#define TIOCTSTP (('t'<<8)|16)
#define DIOCLSTN (('d'<<8)|1)
#define DIOCGETP (('d'<<8)|8)
#define DIOCSETP (('d'<<8)|9)
#define FIOCLEX (('f'<<8)|1)
#define FIONCLEX (('f'<<8)|2)
#define MXLSTN (('x'<<8)|1)
#define MXNBLK (('x'<<8)|2)
sys/types.h
typedef struct { int r[1]; } * physadr;
typedef long daddr_t;
typedef char * caddr_t;
typedef unsigned short ino_t;
typedef long time_t;
typedef int label_t[10];
typedef short dev_t;
typedef long off_t;
/* major part of a device */
#define major(x) (int)(((unsigned)x>>8)&0377)
/* minor part of a device */
#define minor(x) (int)(x&0377)
/* make a device number */
#define makedev(x,y) (dev_t)(((x)<<8) | (y))
sys/user.h
#include <sys/pcb.h>
/*
* The user structure.
* One allocated per process.
* Contains all per process data
* that doesn't need to be referenced
* while the process is swapped.
* The user block is USIZE*512 bytes
* long; resides at virtual kernel
* loc 80020000; contains the system
* stack per user; is cross referenced
* with the proc structure for the
* same process.
*/
#define EXCLOSE 01
struct user
{
struct pcb u_pcb; /* pcb, save area when exchanging stacks */
int u_ptable[(MAXUMEM+127)/128]; /* click nums of user page table */
label_t u_rsav;
char u_segflg; /* IO flag: 0:user D; 1:system; 2:user I */
char u_error; /* return error code */
short u_uid; /* effective user id */
short u_gid; /* effective group id */
short u_ruid; /* real user id */
short u_rgid; /* real group id */
struct proc *u_procp; /* pointer to proc structure */
int *u_ap; /* pointer to arglist */
union { /* syscall return values */
struct {
int r_val1;
int r_val2;
};
off_t r_off;
time_t r_time;
} u_r;
caddr_t u_base; /* base address for IO */
unsigned int u_count; /* bytes remaining for IO */
off_t u_offset; /* offset in file for IO */
struct inode *u_cdir; /* pointer to inode of current directory */
struct inode *u_rdir; /* root directory of current process */
char u_dbuf[DIRSIZ]; /* current pathname component */
caddr_t u_dirp; /* pathname pointer */
struct direct u_dent; /* current directory entry */
struct inode *u_pdir; /* inode of parent directory of dirp */
struct file *u_ofile[NOFILE]; /* pointers to file structures of open files */
char u_pofile[NOFILE]; /* per-process flags of open files */
int u_arg[5]; /* arguments to current system call */
unsigned u_tsize; /* text size (clicks) */
unsigned u_dsize; /* data size (clicks) */
unsigned u_ssize; /* stack size (clicks) */
label_t u_qsav; /* label variable for quits and interrupts */
label_t u_ssav; /* label variable for swapping */
int u_signal[NSIG]; /* disposition of signals */
time_t u_utime; /* this process user time */
time_t u_stime; /* this process system time */
time_t u_cutime; /* sum of childs' utimes */
time_t u_cstime; /* sum of childs' stimes */
int *u_ar0; /* address of users saved R0 */
struct { /* profile arguments */
short *pr_base; /* buffer base */
unsigned pr_size; /* buffer size */
unsigned pr_off; /* pc offset */
unsigned pr_scale; /* pc scaling */
} u_prof;
char u_intflg; /* catch intr from sys */
char u_sep; /* flag for I and D separation */
struct tty *u_ttyp; /* controlling tty pointer */
dev_t u_ttyd; /* controlling tty dev */
struct { /* header of executable file */
int ux_mag; /* magic number */
unsigned ux_tsize; /* text size */
unsigned ux_dsize; /* data size */
unsigned ux_bsize; /* bss size */
unsigned ux_ssize; /* symbol table size */
unsigned ux_entloc; /* entry location */
unsigned ux_unused;
unsigned ux_relflg;
} u_exdata;
char u_comm[DIRSIZ];
time_t u_start;
char u_acflag;
short u_fpflag; /* unused now, will be later */
short u_cmask; /* mask for file creation */
int u_stack[1];
/* kernel stack per user
* extends from u + USIZE*64
* backward not to reah here
*/
};
/* u_error codes */
#define EPERM 1
#define ENOENT 2
#define ESRCH 3
#define EINTR 4
#define EIO 5
#define ENXIO 6
#define E2BIG 7
#define ENOEXEC 8
#define EBADF 9
#define ECHILD 10
#define EAGAIN 11
#define ENOMEM 12
#define EACCES 13
#define EFAULT 14
#define ENOTBLK 15
#define EBUSY 16
#define EEXIST 17
#define EXDEV 18
#define ENODEV 19
#define ENOTDIR 20
#define EISDIR 21
#define EINVAL 22
#define ENFILE 23
#define EMFILE 24
#define ENOTTY 25
#define ETXTBSY 26
#define EFBIG 27
#define ENOSPC 28
#define ESPIPE 29
#define EROFS 30
#define EMLINK 31
#define EPIPE 32
#define EDOM 33
#define ERANGE 34
sys.s
.set exit,1
.set fork,2
.set read,3
.set write,4
.set open,5
.set close,6
.set wait,7
.set creat,8
.set link,9
.set unlink,10
.set exec,11
.set chdir,12
.set time,13
.set mknod,14
.set chmod,15
.set chown,16
.set break,17
.set stat,18
.set lseek,19
.set getpid,20
.set mount,21
.set umount,22
.set setuid,23
.set getuid,24
.set stime,25
.set ptrace,26
.set alarm,27
.set fstat,28
.set pause,29
.set utime,30
.set smdate,30
.set stty,31
.set gtty,32
.set access,33
.set nice,34
.set sleep,35
.set sync,36
.set kill,37
.set switch,38
.set setpgrp,39
.set dup,41
.set pipe,42
.set times,43
.set prof,44
.set setgid,46
.set getgid,47
.set signal,48
# USG 49
# USG 50
.set acct,51
.set setphys,52
.set syslock,53
.set ioctl,54
.set reboot,55
.set mpx,56
# USG 57
# USG 58
.set setinf,59
.set umask,60
time.h
struct tm { /* see ctime(3) */
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
tp_defs.h
char mt[] = "/dev/mt0";
char tc[] = "/dev/tapx";
int flags = flu;
char mheader[] = "/usr/mdec/mboot";
char theader[] = "/usr/mdec/tboot";
utmp.h
struct utmp {
char ut_line[8]; /* tty name */
char ut_name[8]; /* user id */
long ut_time; /* time on */
};
varargs.h
typedef char *va_list;
# define va_dcl int va_alist;
# define va_start(list) list = (char *) &va_alist
# define va_end(list)
# define va_arg(list,mode) ((mode *)(list += sizeof(mode)))[-1]