Go to index, previous page

trap.cc

This modules contains the trap handling functions.

This module exports:

GETVECTADDRESS( type, old ) macro that returns a state_t * to the BIOS area related to the interrupt type. old specifies whether you're interested in the new or old area.
NEW
OLD
definition of values to be used with the above macro
void InitTrapHandlers( void ) explained below


Look at the header file: trap.e


Local data:

RestartRoutine RestartVect[ 4 ]; Pointers to the restart routines for the different trap types.

Since all the traps are handled with the same function this array lets us quickly pick up the right function to use.


Module functions:

void InitTrapHandlers( void ) This function sets up the stack needed by the trap handler and sets the NEW areas of the BIOS to point to our trap handler.

All the traps will be handled by the same function, which will be called with the type as first parameter.

void InitHandler( int type, void *func ) Sets the NEW area of the BIOS related to the trap type in order to call the func routine.

type is placed in a0, as it'll be the argument of the function.

void TrapHandler( int type ) This is the actual trap handling routine.

It saves the current thread status, handles the trap using the functions from the other modules, then restart.

For further details, please have a look at the code: there should be enough comments to let you understand how it works in a clear way.

void PassUp( Thread *current, int type, cpu_t cause ) This function invokes the trap manager for the current thread, passing it the content of the CAUSE register when the exception was thrown. Then the thread is placed in the wait queue, waiting for the answer from the trap manager thread.

If the thread doesn't have a trap manager for the trap type it will be killed.


Look at the code: trap.cc


Go to index, previous page