Desktop/xinu_mips-1.0.2.tar/xinu_mips-1.0.2/include/kernel.h File Reference

Go to the source code of this file.

Defines

#define FALSE   0
#define TRUE   1
#define NULL   0
#define EMPTY   (-1)
#define syscall   long
#define devcall   long
#define local   static long
#define command   long
#define process   long
#define interrupt   void
#define OK   1
#define SYSERR   (-1)
#define EOF   (-2)
#define RESCHED_YES   1
#define RESCHED_NO   0
#define RTCLOCK   TRUE
#define NPROC   50
#define NSEM   100
#define ASSERT(cond)   if ( !(cond) ) return SYSERR
#define ASSERTFUNC(func_call)   ASSERT((func_call) == OK)

Typedefs

typedef unsigned char uchar
typedef unsigned short ushort
typedef unsigned long ulong
typedef unsigned long irqmask
typedef char bool

Functions

int nulluser (void)
syscall kprintf (char *fmt,...)
irqmask disable (void)
irqmask restore (irqmask)
irqmask enable (void)
irqmask enable_irq (irqmask)
syscall create (void *, ulong, ushort, char *, ulong,...)
syscall getpid (void)
syscall kill (int)
syscall ready (long, bool)
syscall resched (void)
syscall sleep (int n)


Detailed Description

The base include file for the XINU kernel. Defines symbolic constants, universal return constants, intialization constants, machine size definitions, inline utility functions, and include types

Id
kernel.h 231 2007-07-12 14:15:16Z agember

Definition in file kernel.h.


Define Documentation

#define ASSERT ( cond   )     if ( !(cond) ) return SYSERR

Definition at line 55 of file kernel.h.

Referenced by freemem(), ready(), sleep(), ttyClose(), ttyControl(), ttyOpen(), ttyRead(), ttyWrite(), and uartRead().

#define ASSERTFUNC ( func_call   )     ASSERT((func_call) == OK)

Definition at line 56 of file kernel.h.

#define command   long

shell command declaration

Definition at line 36 of file kernel.h.

#define devcall   long

device call declaration

Definition at line 34 of file kernel.h.

Referenced by open().

#define EMPTY   (-1)

null pointer for queues

Definition at line 30 of file kernel.h.

Referenced by dequeue(), fscanf(), getch(), newqueue(), test_deltaQueue(), test_procQueue(), and ungetch().

#define EOF   (-2)

End-of-file (usually from read)

Definition at line 43 of file kernel.h.

Referenced by _doscan(), _innum(), _instr(), getch(), sgetch(), and ttyRead().

#define FALSE   0

#define interrupt   void

interrupt procedure

Definition at line 38 of file kernel.h.

#define local   static long

local procedure declaration

Definition at line 35 of file kernel.h.

#define NPROC   50

number of user processes

Definition at line 51 of file kernel.h.

Referenced by dequeue(), newpid(), sysinit(), xsh_memstat(), and xsh_ps().

#define NSEM   100

number of semaphores

Definition at line 52 of file kernel.h.

Referenced by allocsem(), and sysinit().

#define NULL   0

#define OK   1

#define process   long

process declaration

Definition at line 37 of file kernel.h.

#define RESCHED_NO   0

tell ready not to reschedule

Definition at line 47 of file kernel.h.

Referenced by freesem(), main(), nulluser(), send(), shell(), signaln(), test_semaphore2(), test_semaphore3(), and wakeup().

#define RESCHED_YES   1

tell ready to reschedule

Definition at line 46 of file kernel.h.

Referenced by shell(), signal(), test_bigargs(), test_semaphore(), test_semaphore2(), test_semaphore3(), test_semaphore4(), and testItem().

#define RTCLOCK   TRUE

now have RTC support

Definition at line 50 of file kernel.h.

#define syscall   long

system call declaration

Definition at line 33 of file kernel.h.

Referenced by shell().

#define SYSERR   (-1)

#define TRUE   1


Typedef Documentation

typedef char bool

boolean type

Definition at line 24 of file kernel.h.

typedef unsigned long irqmask

machine status for disable/restore

Definition at line 21 of file kernel.h.

typedef unsigned char uchar

unsigned char type

Definition at line 18 of file kernel.h.

typedef unsigned long ulong

unsigned long type

Definition at line 20 of file kernel.h.

typedef unsigned short ushort

unsigned short type

Definition at line 19 of file kernel.h.


Function Documentation

syscall create ( void *  procaddr,
ulong  ssize,
ushort  priority,
char *  name,
ulong  nargs,
  ... 
)

Create a process to start running a procedure.

Parameters:
procaddr procedure address
ssize stack stack size in words
priority process priority, must be > 0
name name of the process, used for debugging
nargs,number of arguments that follow
Returns:
the new process' process id

Definition at line 28 of file create.c.

References CONTEXT_WORDS, getmem(), getpid(), INITRET, MINSTK, pentry::name, newpid(), numproc, pentry::parent, PNMLEN, pentry::prio, proctab, PRSUSP, roundew, STACKMAGIC, pentry::state, pentry::stkbase, pentry::stklen, pentry::stkptr, strncpy(), SYSERR, va_arg, va_end, and va_start.

Referenced by main(), nulluser(), shell(), test_bigargs(), test_deltaQueue(), test_procQueue(), test_recursion(), test_schedule(), test_semaphore(), test_semaphore2(), test_semaphore3(), test_semaphore4(), and testItem().

irqmask disable ( void   ) 

irqmask enable ( void   ) 

Referenced by main(), and nulluser().

irqmask enable_irq ( irqmask   ) 

Referenced by uartInit().

syscall getpid ( void   ) 

Get the process id of currently executing process.

Returns:
process id of the currently running process

Definition at line 16 of file getpid.c.

References currpid.

Referenced by create(), userret(), xsh_exit(), and xsh_kill().

syscall kill ( int   ) 

syscall kprintf ( char *  fmt,
  ... 
)

kprintf - kernel printf: formatted, unbuffered output to CONSOLE

Parameters:
*fmt pointer to string being printed
Returns:
OK on success

Definition at line 55 of file kprintf.c.

Referenced by nulluser(), xdone(), and xtrap().

int nulluser ( void   ) 

Intializes the system and becomes the null process. This is where the system begins after the C environment has been established. Interrupts are initially DISABLED, and must eventually be enabled explicitly. This routine turns itself into the null process after initialization. Because the null process must always remain ready to run, it cannot execute code that might cause it to be suspended, wait for a semaphore, or put to sleep, or exit. In particular, it must not do I/O unless it uses kprintf for synchronous output.

Definition at line 64 of file initialize.c.

References _start(), CONSOLE, cpuid, create(), enable(), end, INITPRIO, INITSTK, kprintf(), KSEG0_BASE, main(), minheap, nonempty, NULL, numproc, open(), platforminit(), ready(), readylist, resched(), RESCHED_NO, SERIAL0, sysinit(), and xdone().

syscall ready ( long  pid,
bool  resch 
)

Make a process eligible for CPU service.

Parameters:
pid process id of the process to move to the ready state
resch if TRUE, reschedule will be called
Returns:
OK if the process has been added to the ready list, else SYSERR

Definition at line 19 of file ready.c.

References ASSERT, insert(), isbadpid, OK, pentry::prio, proctab, PRREADY, readylist, resched(), and pentry::state.

Referenced by freesem(), main(), nulluser(), send(), shell(), signal(), signaln(), test_bigargs(), test_recursion(), test_schedule(), test_semaphore(), test_semaphore2(), test_semaphore3(), test_semaphore4(), testItem(), and wakeup().

syscall resched ( void   ) 

Reschedule processor to highest priority ready process. Upon entry, currpid gives current process id. Proctab[currpid].pstate gives correct NEXT state for current process if other than PRREADY.

Returns:
OK when the process is context switched back

Definition at line 21 of file resched.c.

Referenced by clockintr(), kill(), nulluser(), ready(), receive(), send(), sleep(), t4(), t5(), test_recursion(), test_schedule(), wait(), and wakeup().

irqmask restore ( irqmask   ) 

syscall sleep ( int  ms  ) 

Delay the calling process n milliseconds.

Parameters:
ms number of milliseconds to sleep
Returns:
OK if process is sleeping, SYSERR if no clock

Definition at line 19 of file sleep.c.

References ASSERT, currpid, disable(), insertd(), OK, proctab, PRSLEEP, resched(), restore(), sleepq, pentry::state, and SYSERR.

Referenced by shell(), testItem(), xsh_exit(), xsh_kill(), and xsh_sleep().


Generated on Thu Oct 9 22:34:34 2008 for xinu by  doxygen 1.5.5