diff --git a/include/kernel.h b/include/kernel.h index 73c0551..aaba988 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -1,5 +1,7 @@ /* kernel.h */ +/* avr specific values. Original saved under orig/ folder */ + /* General type declarations used throughout the kernel */ typedef unsigned char byte; @@ -12,27 +14,15 @@ typedef unsigned long long uint64; /* Xinu-specific types */ -// typedef int32 sid32; /* semaphore ID */ -// typedef int16 qid16; /* queue ID */ -// typedef int32 pid32; /* process ID */ -// typedef int32 did32; /* device ID */ typedef int16 pri16; /* process priority */ typedef uint32 umsg32; /* message passed among processes */ typedef int32 bpid32; /* buffer pool ID */ typedef byte bool8; /* Boolean type */ -// typedef uint32 intmask; /* saved interrupt mask */ -// typedef int32 ibid32; /* index block ID (used in file system) */ -// typedef int32 dbid32; /* data block ID (used in file system) */ -// typedef int32 uid32; /* ID for UDP table descriptor */ typedef char sid32; /* semaphore ID */ typedef char qid16; /* queue ID */ typedef char pid32; /* process ID */ typedef char did32; /* device ID */ -// RAFA typedef char pri16; /* process priority */ -// RAFA typedef char umsg32; /* message passed among processes */ -// RAFA typedef char bpid32; /* buffer pool ID */ -// RAFA typedef byte bool8; /* Boolean type */ typedef char intmask; /* saved interrupt mask */ typedef char ibid32; /* index block ID (used in file system) */ typedef char dbid32; /* data block ID (used in file system) */ @@ -40,18 +30,12 @@ typedef char uid32; /* ID for UDP table descriptor */ /* Function declaration return types */ -// typedef int32 syscall; /* system call declaration */ -// typedef int32 devcall; /* device call declaration */ -// typedef int32 shellcmd; /* shell command declaration */ typedef int32 process; /* top-level function of a process */ typedef void interrupt; /* interrupt procedure */ -// typedef int32 status; /* returned status value (OK/SYSERR) */ typedef char syscall; /* system call declaration */ typedef char devcall; /* device call declaration */ typedef char shellcmd; /* shell command declaration */ -// RAFA typedef char process; /* top-level function of a process */ -// RAFA typedef void interrupt; /* interrupt procedure */ typedef char status; /* returned status value (OK/SYSERR) */ #define local static /* Local procedure or variable declar. */ @@ -76,8 +60,6 @@ typedef char status; /* returned status value (OK/SYSERR) */ extern qid16 readylist; /* global ID for list of ready processes*/ -// RAFA #define MINSTK 400 /* minimum stack size in bytes */ -// #define MINSTK 256 /* minimum stack size in bytes */ #define MINSTK 64 /* minimum stack size in bytes */ #define CONTEXT 64 /* bytes in a function call context on */ @@ -86,7 +68,6 @@ extern qid16 readylist; /* global ID for list of ready processes*/ /* Size of the stack for the null process */ -// #define NULLSTK 4096 /* stack size for null process */ #define NULLSTK 256 /* stack size for null process */ /* Prototypes of I/O functions used throughout the kernel */ diff --git a/include/mark.h b/include/mark.h index 72a6457..44b5999 100644 --- a/include/mark.h +++ b/include/mark.h @@ -1,6 +1,7 @@ /* mark.h - notmarked */ -// RAFA #define MAXMARK 20 /* Maximum number of marked locations */ +/* avr specific values. Original saved under orig/ folder */ + #define MAXMARK 10 /* Maximum number of marked locations */ extern int32 *(marks[]); diff --git a/include/memory.h b/include/memory.h index fce2cfc..b3a9d98 100644 --- a/include/memory.h +++ b/include/memory.h @@ -1,5 +1,7 @@ /* memory.h - roundmb, truncmb, freestk */ +/* avr specific values. Original saved under orig/ folder */ + #define PAGE_SIZE 1024 // TODO: unused? /*---------------------------------------------------------------------- @@ -25,14 +27,3 @@ struct memblk { /* See roundmb & truncmb */ extern struct memblk memlist; /* Head of free memory list */ extern void *minheap; /* Start of heap */ extern void *maxheap; /* Highest valid heap address */ - - -/* Added by linker */ - -// extern uint32 text; /* Start of text segment */ -// extern uint32 etext; /* End of text segment */ -// extern uint32 data; /* Start of data segment */ -// extern uint32 edata; /* End of data segment */ -// extern uint32 bss; /* Start of bss segment */ -// extern uint32 ebss; /* End of bss segment */ -// extern uint32 end; /* End of program */ diff --git a/include/orig/kernel.h b/include/orig/kernel.h new file mode 100644 index 0000000..718e486 --- /dev/null +++ b/include/orig/kernel.h @@ -0,0 +1,73 @@ +/* kernel.h */ + +/* General type declarations used throughout the kernel */ + +typedef unsigned char byte; +typedef unsigned char uint8; +typedef int int32; +typedef short int16; +typedef unsigned int uint32; +typedef unsigned short uint16; +typedef unsigned long long uint64; + +/* Xinu-specific types */ + +typedef int32 sid32; /* semaphore ID */ +typedef int16 qid16; /* queue ID */ +typedef int32 pid32; /* process ID */ +typedef int32 did32; /* device ID */ +typedef int16 pri16; /* process priority */ +typedef uint32 umsg32; /* message passed among processes */ +typedef int32 bpid32; /* buffer pool ID */ +typedef byte bool8; /* Boolean type */ +typedef uint32 intmask; /* saved interrupt mask */ +typedef int32 ibid32; /* index block ID (used in file system) */ +typedef int32 dbid32; /* data block ID (used in file system) */ +typedef int32 uid32; /* ID for UDP table descriptor */ + +/* Function declaration return types */ + +typedef int32 syscall; /* system call declaration */ +typedef int32 devcall; /* device call declaration */ +typedef int32 shellcmd; /* shell command declaration */ +typedef int32 process; /* top-level function of a process */ +typedef void interrupt; /* interrupt procedure */ +typedef int32 status; /* returned status value (OK/SYSERR) */ + +#define local static /* Local procedure or variable declar. */ + +/* Boolean constants */ + +#define FALSE 0 /* Boolean False */ +#define TRUE 1 /* Boolean True */ + +/* Null pointer, character, and string definintions */ + +#define NULL 0 /* null pointer for linked lists */ +#define NULLCH '\0' /* null character */ +#define NULLSTR "" /* null string */ + +/* Universal return constants */ + +#define OK ( 1) /* normal system call return */ +#define SYSERR (-1) /* system call failed */ +#define EOF (-2) /* End-of-file (usually from read) */ +#define TIMEOUT (-3) /* system call timed out */ + +extern qid16 readylist; /* global ID for list of ready processes*/ + +#define MINSTK 400 /* minimum stack size in bytes */ + +#define CONTEXT 64 /* bytes in a function call context on */ + /* the run-time stack */ +#define QUANTUM 2 /* time slice in milliseconds */ + +/* Size of the stack for the null process */ + +#define NULLSTK 8192 /* stack size for null process */ + +/* Prototypes of I/O functions used throughout the kernel */ + +syscall kprintf(char *fmt, ...); +syscall kputc(byte); +syscall kgetc(void); diff --git a/include/orig/mark.h b/include/orig/mark.h new file mode 100644 index 0000000..2579015 --- /dev/null +++ b/include/orig/mark.h @@ -0,0 +1,16 @@ +/* mark.h - notmarked */ + +#define MAXMARK 20 /* Maximum number of marked locations */ + +extern int32 *(marks[]); +extern int32 nmarks; +extern sid32 mkmutex; +typedef int32 memmark[1]; /* Declare a memory mark to be an array */ + /* so user can reference the name */ + /* without a leading & */ + +/*------------------------------------------------------------------------ + * notmarked - Return nonzero if a location has not been marked + *------------------------------------------------------------------------ + */ +#define notmarked(L) (L[0]<0 || L[0]>=nmarks || marks[L[0]]!=L) diff --git a/include/orig/memory.h b/include/orig/memory.h new file mode 100644 index 0000000..7916cf9 --- /dev/null +++ b/include/orig/memory.h @@ -0,0 +1,38 @@ +/* memory.h - roundmb, truncmb, freestk */ + +#define PAGE_SIZE 4096 + +/*---------------------------------------------------------------------- + * roundmb, truncmb - Round or truncate address to memory block size + *---------------------------------------------------------------------- + */ +#define roundmb(x) (char *)( (7 + (uint32)(x)) & (~7) ) +#define truncmb(x) (char *)( ((uint32)(x)) & (~7) ) + +/*---------------------------------------------------------------------- + * freestk -- Free stack memory allocated by getstk + *---------------------------------------------------------------------- + */ +#define freestk(p,len) freemem((char *)((uint32)(p) \ + - ((uint32)roundmb(len)) \ + + (uint32)sizeof(uint32)), \ + (uint32)roundmb(len) ) + +struct memblk { /* See roundmb & truncmb */ + struct memblk *mnext; /* Ptr to next free memory blk */ + uint32 mlength; /* Size of blk (includes memblk)*/ + }; +extern struct memblk memlist; /* Head of free memory list */ +extern void *minheap; /* Start of heap */ +extern void *maxheap; /* Highest valid heap address */ + + +/* Added by linker */ + +extern int text; /* Start of text segment */ +extern int etext; /* End of text segment */ +extern int data; /* Start of data segment */ +extern int edata; /* End of data segment */ +extern int bss; /* Start of bss segment */ +extern int ebss; /* End of bss segment */ +extern int end; /* End of program */