--- xinu/h/kernel.h 2018/04/24 17:39:02 1.1 +++ xinu/h/kernel.h 2018/04/24 17:39:11 1.1.1.2 @@ -1,80 +1,100 @@ -/* kernel.h - halt, isodd, pause, min */ +/* kernel.h - disable, enable, halt, restore, isodd */ /* Symbolic constants used throughout Xinu */ -#ifndef ASM typedef char Bool; /* Boolean type */ -typedef long PStype[1]; /* type of PS save location */ -#endif ASM +/* Machine size definitions */ + +typedef char CHAR; /* sizeof the unit the holds a character*/ +typedef int WORD; /* maximum of (int, char *) */ +typedef char *PTR; /* sizeof a char. or fcnt. pointer */ +typedef int INT; /* sizeof compiler integer */ +typedef int REG; /* sizeof machine register */ + +/* Machine dependent type definitions */ + +#ifdef lsi11 +#define SAVEDPS CHAR /* Saved processor status type */ +#else +#define SAVEDPS INT +#endif + +#define SYSCALL WORD /* System call declaration */ +#define LOCAL static WORD /* Local procedure declaration */ +#define INTPROC WORD /* Interrupt procedure " */ +#define PROCESS WORD /* Process declaration */ #define FALSE 0 /* Boolean constants */ #define TRUE 1 #define NULL (char *)0 /* Null pointer for linked lists*/ -#define NULLCH '\0' /* The null character */ -#define NULLSTR "" /* Pointer to empty string */ -#define SYSCALL int /* System call declaration */ -#define LOCAL static /* Local procedure declaration */ -#define COMMAND int /* Shell command declaration */ -#define BUILTIN int /* Shell builtin " " */ -#define INTPROC int /* Interrupt procedure " */ -#define PROCESS int /* Process declaration */ #define RESCHYES 1 /* tell ready to reschedule */ #define RESCHNO 0 /* tell ready not to resch. */ -#define MINSHORT 0100000 /* minimum short integer */ -#define MAXSHORT 077777 /* maximum short integer */ -#define LOWBYTE 0377 /* mask for low-order 8 bits */ -#define LOW6 077 /* mask for low-order 6 bits */ -#define LOW16 0177777 /* mask for low-order 16 bits */ - /* Following are indexes of */ - /* saved values of registers */ - /* in the process table */ - /* register save area: */ -#define SPINDX 0 /* kernel stack pointer */ -#define APINDX 16 /* argument pointer */ -#define FPINDX 17 /* frame pointer */ -#define PCINDX 18 /* program counter */ -#define PSINDX 19 /* program status longword */ -#define P0BRINDX 20 /* p0 base register */ -#define P0LRINDX 21 /* p0 length register */ -#define P1BRINDX 22 /* p1 base register */ -#define MINSTK 128 /* minimum process stack size */ -#define NULLSTK 1024 /* process 0 stack size */ -#define MAGIC 0xaaaaaaaa /* unusual value for top of stk */ - -/* Universal return constants */ - -#define OK 1 /* returned when system call ok */ +#define MINSTK 800 /* minimum process stack size */ +#define NULLSTK 800 /* process 0 stack size */ +#define OK 1 /* returned when system call ok */ + +/* Machine dependent constants */ + +#ifdef lsi11 +#define SP 6 /* reg. 6 is stack pointer */ +#define PC 7 /* reg. 7 is program counter */ +#define PS 8 /* proc. status in 8th reg. loc */ +#define INITPS 0 /* initial proc. status */ +#define MININT 0x8000 /* minimum integer (-32768) */ +#define MAXINT 0x7fff /* maximum integer */ +#define MINLONG 0x8000 /* minimum long (-32768) */ +#define MAXLONG 0x7fff /* maximum long */ #define SYSERR -1 /* returned when sys. call fails*/ -#define EOF -2 /* returned for end-of-file */ -#define TIMEOUT -3 /* returned " " " times out */ -#define INTRMSG -4 /* keyboard "intr" key pressed */ - /* (usu. defined as ^B) */ +#define DISABLE 0340 /* PS to disable interrupts */ + +#else +#define SSP 15 /* Supervisor stack pointer */ +#define PS 16 +#define PC 17 +#define USP 18 /* User stack pointer */ +#define INITPS 0x2000 /* initial proc. status */ +#define MININT 0x80000000 +#define MAXINT 0x7fffffff +#define MAXLONG 0x7fffffff +#define MINLONG 0x80000000 +#define SYSERR -1 +#define DISABLE 0x2700 +#endif -/* Initialization constants */ +/* initialization constants */ -#define INITSTK 1024 /* initial process stack */ +#define INITARGC 1 /* initial process argc */ +#define INITSTK 1000 /* initial process stack size */ #define INITPRIO 20 /* initial process priority */ #define INITNAME "main" /* initial process name */ -#define INITARGS 1,0 /* initial count/arguments */ -#define INITRET userret /* INITRET=process' return point*/ -#define INITPS 0x00000000 /* initial process PSL: */ - /* integer oflow trap disabled, */ - /* interrupts enabled */ -#define INITBR 0x80000000 /* P0 & P1 base register */ -#define INITLR 0x04000000 /* P0LR-> ASTLVL==none pending */ +#define INITRET userret /* processes return address */ #define INITREG 0 /* initial register contents */ #define QUANTUM 10 /* clock ticks until preemption */ -/* Miscellaneous utility inline functions */ +/* misc. utility inline functions */ -#ifndef ASM -#define isodd(x) (01&(int)(x)) -#define pause() asm("nop") /* pause-like instruction */ -#define halt() asm("jmp __halt") -#define min(a,b) ((a) < (b) ? (a) : (b)) -#endif ASM +#define isodd(x) (01&(WORD)(x)) + +/* Machine dependent machine status functions */ + +#ifdef lsi11 +#define disable(ps) asm("mfps ~ps");asm("mtps $0340") +#define restore(ps) asm("mtps ~ps") /* restore interrupt status */ +#define enable() asm("mtps $000")/* enable interrupts */ +#define pause() asm("wait") /* machine "wait for interr." */ +#define halt() asm("halt") /* machine halt instruction */ + +#else +/* Note: disable and restore are now true procedures */ +#define enable() asm(" movw #0x2000, sr") + /* machine wait for intr. */ +#define pause() asm("pause: jmp pause") + /* machine halt instruction */ +#define halt() asm("halt: jmp halt") +#endif -#ifndef ASM extern int rdyhead, rdytail; + +#ifdef RTCLOCK extern int preempt; -#endif ASM +#endif