mirror of https://github.com/zrafa/xinu-avr.git
6 changed files with 133 additions and 33 deletions
@ -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); |
||||
@ -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) |
||||
@ -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 */ |
||||
Loading…
Reference in new issue