Main Page   Modules   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

KERNEL component


Files

file  context.h
file  cubeos.h
file  e_handle.c
file  iobuf.h
file  ivtab.c
file  ivtab.h
file  kerror.c
file  kerror.h
file  ptimer.c
file  ptimer.h
file  schedule.c
file  schedule.h
file  seminl.h
file  sleep.c
file  softreset.c
file  softreset.h
file  ssem.h
file  sys_var.c
file  sys_var.h
file  taskconst.h
file  trap.c
file  trap.h

Compounds

struct  iobuf
 This forms an io buffer. More...

struct  process
 process/thread table entry. More...

struct  regs
 register structure for context switch. More...

struct  sem_s
 contains all data about a semaphore. More...


Typedefs

typedef regs reglist
 register structure for context switch. More...

typedef sem_s sem_t
 contains all data about a semaphore. More...


Functions

void KERN_contextsw (regptr oldarea, regptr newarea)
 switch CPU context. More...

void KERN_exphandler (unsigned long par1, unsigned long par2,...)
 KERN_exphandler - Exception handler. More...

void iobuf_init (struct iobuf *x, short bl)
 prepares an iobuf for use. More...

int put (struct iobuf *x, char c)
 writes one char into an io buffer. More...

char get (struct iobuf *x)
 reads one char from an io buffer. More...

void KERN_panic ()
 This function shuts down the system the hard way. More...

void KERN_complain (int i, char *text)
 This is the general error-reporting function of the kernel. More...

int KERN_installdispatcher (void(*dispatcher)())
 installs a timer dispatcher routine that is called every tick. More...

int KERN_removedispatcher ()
 removes the installed timer dispatcher routine. More...

int KERN_ptint (void)
 periodic timer interrupt routine. More...

void KERN_init_ptimer (void)
 initializes the periodic timer of the '332 SIM. More...

unsigned long _getseconds ()
 returns the second counter. More...

int _gettimeofday (struct timeval *tp, struct timezone *ignore)
 fills a struct timeval with the current internal time. More...

unsigned long _settimeofday (unsigned long val)
 sets the internal time from an integer. More...

void _KERN_taskend ()
 this ends a thread. More...

regptr _KERN_initcontext (regptr context, short sr, void *sp, void *function)
 initalizes a context. More...

int KERN_create_prio (void *function, int prio)
 create a new threas. More...

int KERN_create (void *function)
 starts a new thread. More...

void KERN_schedule (void)
 this is the scheduler. It is either called by the periodic timer interrupt or from a user thread. More...

int KERN_schedinit ()
 initalizes the scheduler. More...

int KERN_suspend (int i)
 suspend a thread. More...

int KERN_wakeup (int i)
 wakes up a thread. More...

int KERN_delta_handler ()
 this is the kernel delta list handler. It is called by the periodic timer interrupe. More...

void sem_post (sem_t x)
 post operation on a semaphore. More...

void sem_wait (sem_t x)
 wait operation on a semaphore. More...

int sem_init (sem_t x, int i, int v)
 prepares a semaphore. More...

int sem_destroy (sem_t x)
 destroys a semaphore and releases all threads waiting on it. More...

void KERN_softreset ()
 resets the hardware by using a dirty hack. More...

void KERN_sysvarinit ()
 initializes some system variables. More...

void trap0 (void)
 Trap Handler. More...

void disable ()
 disables interrupt processing. More...

void enable ()
 enable interrupt processing. More...

void _KERN_IVTab_init ()
 initializes the interrupt vector table. More...

int _KERN_IVTab_setvector (unsigned short vector, void(*isr)(void))
 sets a vector in the interrupt vector table. More...

int _KERN_IVTab_clearvector (unsigned short vector, void(*isr)(void))
 resets the interrupt vector table. More...


Detailed Description

This component form the CubeOS Kernel. Includes multitasking, semaphores, exception handling, interrupt management and initialisation.

Typedef Documentation

typedef struct regs reglist
 

register structure for context switch.

typedef struct sem_s sem_t
 

contains all data about a semaphore.


Function Documentation

unsigned long _getseconds  
 

returns the second counter.

Definition at line 130 of file ptimer.c.

int _gettimeofday struct timeval *    tp,
struct timezone *    ignore
 

fills a struct timeval with the current internal time.

Todo:
gettimeofday does not work

Definition at line 141 of file ptimer.c.

References TICKS_PER_SECOND.

regptr _KERN_initcontext regptr    context,
short    sr,
void *    sp,
void *    function
 

initalizes a context.

Definition at line 61 of file schedule.c.

References _KERN_taskend, MAGIC, PNREGS, POS_PC, POS_SR, POS_SSP, sp, and writeint.

Referenced by KERN_create_prio.

int _KERN_IVTab_clearvector unsigned short    vector,
void(*    isr)(void)
 

resets the interrupt vector table.

Parameters:
vector  - the vector number to clear
isr  - the previously installed isr
Resets the interrupt vector table entry to its original setting. The isr pointer is used to verify that a driver can only remove an isr that it has set before.

Definition at line 79 of file ivtab.c.

References _KERN_IVTab_oldvector.

void _KERN_IVTab_init  
 

initializes the interrupt vector table.

Reads out the VBR register of the CPU and stores it in the _KERN_IVTab pointer. Resets the old vectors to zero. _KERN_IVTab_init() is called by crt0.S during initialisation.

Definition at line 33 of file ivtab.c.

References _KERN_IVTab_oldvector.

int _KERN_IVTab_setvector unsigned short    vector,
void(*    isr)(void)
 

sets a vector in the interrupt vector table.

Parameters:
vector  - Number of the vector to set
isr  - memory location of the isr
_KERN_IVTab_setvector sets the content of the interrupt vector table entry vector to isr. It saves the old content of the entry to restore it later.

Definition at line 56 of file ivtab.c.

References _KERN_IVTab_oldvector.

void _KERN_taskend  
 

this ends a thread.

Definition at line 50 of file schedule.c.

References KERN_schedule, and process::signal.

Referenced by _KERN_initcontext.

unsigned long _settimeofday unsigned long    val
 

sets the internal time from an integer.

Definition at line 163 of file ptimer.c.

References PTIMER_PITR_VAL, SIM_PITR, and writeshort.

static inline void disable   [inline, static]
 

disables interrupt processing.

disable() disabled interrupt processing by setting the interrupt mask in the CPU status register. Note: This functions should be used with extreme care since it also disables IO processing and preemptive scheduling.

Definition at line 69 of file cubeos.h.

Referenced by I2C_slprocess, I2C_Start_I2C_Transfer, KERN_create_prio, KERN_installdispatcher, KERN_psleep, KERN_removedispatcher, KERN_ssleep, KERN_suspend, KERN_usleep, RSM_getframe, sem_destroy, sem_init, sem_post, sem_wait, TTY_inchar, TTY_outchar, TTY_readchar, and TTY_writechar.

static inline void enable   [inline, static]
 

enable interrupt processing.

enable() enables interrupt processing by clearing the interrupt mask in the CPU status register. Note: This functions should be used with extreme care since it also re-enables IO processing and preemptive scheduling.

Definition at line 73 of file cubeos.h.

Referenced by I2C_slprocess, I2C_Start_I2C_Transfer, KERN_create_prio, KERN_installdispatcher, KERN_psleep, KERN_removedispatcher, KERN_ssleep, KERN_suspend, KERN_usleep, RSM_getframe, sem_destroy, sem_init, sem_post, sem_wait, TTY_inchar, TTY_outchar, TTY_readchar, and TTY_writechar.

char get struct iobuf   x [inline, static]
 

reads one char from an io buffer.

Parameters:
x  is a pointer to the iobuf structure
The function returns the character
Todo:
this function performs a spinlock busy wait on an empty buffer. This needs to be changed.

Definition at line 89 of file iobuf.h.

References iobuf::buflen, iobuf::cnt, iobuf::data, and iobuf::tail.

void iobuf_init struct iobuf   x,
short    bl
[inline, static]
 

prepares an iobuf for use.

Parameters:
x  is a pointer to an iobuf structure
bl  is the bufferlength for this iobuf.

Definition at line 43 of file iobuf.h.

References iobuf::buflen, BUFLEN, iobuf::cnt, iobuf::head, and iobuf::tail.

Referenced by DUART_duart, QSM_sciinit, and TTY_init.

void KERN_complain int    i,
char *    text
 

This is the general error-reporting function of the kernel.

Parameters:
i  is the severity of the error (see kerror.h for details)
text  is a string to be reported to the user

Definition at line 52 of file kerror.c.

References ERR_PANIC, and KERN_panic.

void KERN_contextsw regptr    oldarea,
regptr    newarea
 

switch CPU context.

Parameters:
oldarea  is a pointer to the old context area
newarea  is a pointer to the old context area
KERN_contextsw() saves the current CPU state in the oldarea and restores the context from newarea into the CPU.

Referenced by KERN_schedule.

int KERN_create void *    function
 

starts a new thread.

Parameters:
function  is a pointer to the function to be executed by the thread

Definition at line 166 of file schedule.c.

References KERN_create_prio.

int KERN_create_prio void *    function,
int    prio
 

create a new threas.

Parameters:
function  is a pointer to the function to be executed by the thread
prio  is the priority of the thread to be created

Definition at line 106 of file schedule.c.

References _KERN_initcontext, _LIBC_init_reent, disable, enable, ERR_EMERG, getpid, process::irq, KERN_complain, LIST_insert_tail, malloc, MAX_PRIONUM, process::next, NO_TASK, PNREGS, process::ppid, process::prio, regs::regs, process::regs, process::signal, process::stack, process::state, STATE_EMPTY, STATE_READY, TASK_INIT_IRQLVL, TASK_INIT_SR, TASK_INIT_STACKSIZE, and process::time_delta.

Referenced by KERN_create.

int KERN_delta_handler  
 

this is the kernel delta list handler. It is called by the periodic timer interrupe.

Definition at line 426 of file schedule.c.

References _KERN_delta, KERN_wakeup, and LIST_entries.

Referenced by KERN_ptint.

void KERN_exphandler unsigned long    par1,
unsigned long    par2,
...   
 

KERN_exphandler - Exception handler.

Parameters:
The  parameters are just placeholders for the exception stack frame that is parsed by the function
KERN_exphandler prints out the content of an exception stack frame to the current console. Output is polling and blocked, interrupts are disabled and the hardware watchdog is triggered to reset the hardware afterwards. exp_handler should never be called from an user program.

Definition at line 38 of file e_handle.c.

References readshort, SIM_MCR, TTY_MODE_RXBLOCKING, TTY_MODE_TXBLOCKING, TTY_MODE_TXUNBUF, TTY_soutchar, and writeshort.

void KERN_init_ptimer void   
 

initializes the periodic timer of the '332 SIM.

Definition at line 103 of file ptimer.c.

References PTIMER_IRQ_LEVEL, PTIMER_PITR_VAL, PTIMER_VECTOR, SIM_PICR, SIM_PITR, writeshort, and writeshortpos.

int KERN_installdispatcher void(*    dispatcher)()
 

installs a timer dispatcher routine that is called every tick.

Definition at line 34 of file ptimer.c.

References _KERN_call_dispatcher, disable, and enable.

void KERN_panic  
 

This function shuts down the system the hard way.

Definition at line 29 of file kerror.c.

References readshort, SIM_MCR, and writeshort.

Referenced by KERN_complain.

int KERN_ptint void   
 

periodic timer interrupt routine.

This function is called by the periodic timer interrupt.

Definition at line 69 of file ptimer.c.

References _DUART_duart_bugfix, _KERN_call_dispatcher, KERN_delta_handler, QUANTUM, and TICKS_PER_SECOND.

int KERN_removedispatcher  
 

removes the installed timer dispatcher routine.

Definition at line 48 of file ptimer.c.

References _KERN_call_dispatcher, disable, and enable.

int KERN_schedinit  
 

initalizes the scheduler.

Definition at line 317 of file schedule.c.

References _KERN_delta, _LIBC_init_reent, entry_s::data, entry_s::len, LIST_init, LIST_makeentry, LIST_TYPE_PRIO, LIST_TYPE_SYS, MAX_PRIONUM, process::me, process::pid, PNREGS, process::ppid, process::prio, process::reent, regs::regs, process::regs, process::signal, process::stack, process::state, STATE_EMPTY, STATE_RUNNING, and list_s::type.

void KERN_schedule void   
 

this is the scheduler. It is either called by the periodic timer interrupt or from a user thread.

Definition at line 175 of file schedule.c.

References ERR_PANIC, getpid, KERN_complain, KERN_contextsw, LIST_delete, LIST_entries, LIST_head, LIST_insert_tail, MAX_PRIONUM, process::reent, process::signal, process::state, STATE_EMPTY, STATE_READY, STATE_RUNNING, and STATE_SUSPEND.

Referenced by _KERN_taskend, and KERN_suspend.

void KERN_softreset  
 

resets the hardware by using a dirty hack.

This function disables the clock output of the 68332 that is used to retrigger the external DS1232 watchdog chip. After losing the retrigger signal for about 500ms, the DS1232 will pull the reset line low. I would like to use the RESET assembler instruction, but that would only reset the external devices and leave the CPU running, which might not be as clean as I'd like it to be.

Definition at line 32 of file softreset.c.

References readshort, SIM_MCR, and writeshort.

Referenced by QSM_sci_int.

int KERN_suspend int    i
 

suspend a thread.

Parameters:
i  is the process id of the thread to be suspended. -1 suspends the current thread.

Definition at line 361 of file schedule.c.

References disable, enable, KERN_schedule, entry_s::list, LIST_delete, LIST_TYPE_PRIO, process::me, process::state, STATE_EMPTY, STATE_SUSPEND, and list_s::type.

void KERN_sysvarinit  
 

initializes some system variables.

Todo:
maybe the heap pointer reset fits in here

Definition at line 37 of file sys_var.c.

References _KERN_disablecount, and KERN_srsave.

int KERN_wakeup int    i
 

wakes up a thread.

Parameters:
i  ist the process id of the thread to be woken up

Definition at line 405 of file schedule.c.

References LIST_delete, LIST_insert_head, process::state, STATE_READY, and STATE_SUSPEND.

Referenced by KERN_delta_handler.

int put struct iobuf   x,
char    c
[inline, static]
 

writes one char into an io buffer.

Parameters:
x  is a pointer to the iobuf structure
c  is the char to be written
The function returns 0 on success, -1 on failure.

Definition at line 68 of file iobuf.h.

References iobuf::buflen, iobuf::cnt, iobuf::data, and iobuf::head.

int sem_destroy sem_t    x [inline, static]
 

destroys a semaphore and releases all threads waiting on it.

Parameters:
x  is a semaphore

Definition at line 118 of file seminl.h.

References disable, enable, sem_s::init, NO_TASK, sem_s::task, and wakeup.

int sem_init sem_t    x,
int    i,
int    v
[inline, static]
 

prepares a semaphore.

Parameters:
x  is a semaphore

Definition at line 102 of file seminl.h.

References sem_s::c, disable, enable, sem_s::init, NO_TASK, and sem_s::task.

void sem_post sem_t    x [inline, static]
 

post operation on a semaphore.

Parameters:
x  is a semaphore
Todo:
Should this be changed into a pointer ?

instead of the simple list, this should also use the LIST component

Definition at line 45 of file seminl.h.

References sem_s::c, disable, enable, sem_s::init, NO_TASK, sem_s::task, and wakeup.

void sem_wait sem_t    x [inline, static]
 

wait operation on a semaphore.

Parameters:
x  is a semaphore
Todo:
Should this be changed into a pointer ?

instead of the simple list, this should also use the LIST component

Definition at line 69 of file seminl.h.

References sem_s::c, disable, enable, getpid, sem_s::init, KERN_suspend, NO_TASK, and sem_s::task.

void trap0 void   
 

Trap Handler.

Definition at line 31 of file trap.c.


Generated on Thu Feb 20 15:39:02 2003 for cubeOS by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002