index previous next 

file name: interupt.hpp, interupt.cpp
classification: simulation
contents: class CNeedInterrupt, interrupt handling functions
use: provides everything that is necessary for interrupt handling, including an "interrupt handler" that can call all ISRs of objects associated with a given interrupt vector.
 

global items used:

 
local items used:

class CInterruptHandler: manages the interrupt vector table and stores object ISRs with the interrupt vector as key.

void ClearISRs(): The function only exists if NO_RESOURCE is not defined. It is not declared in the header file, so you have to declare it in your own file. The function should only be used in the software controller and only if NO_RESOURCE is not defined. It removes all ISRs from the vector table, leaving the table empty.
 
void ClearISRs (SINT32 nodeID, int area): The function only exists if NO_RESOURCE is not defined. It is not declared in the header file, so you have to declare it in your own file. The function should only be used in the software controller and only if NO_RESOURCE is not defined. It removes all ISRs of the particular CSA (Clock Synchronization Application) with the ID <nodeID, area> from the vector table.
 

local variables defined in the implementation file:

CInterruptHandler handler_: the interrupt handler used for installing object ISRs as interrupt service routines. SetISR() puts an object ISR into its vector table, InvokeISR() calls the object ISR that is stored for the given interrupt vector.
 

class CNeedInterrupt:

This is the base class needed for all classes that have an interrupt service routine.
 

friend void CallISR (CNeedInterrupt *obj): This call function is used to invoke the default ISR of an object. It should only be used by the interrupt handler!

void isr(): pure virtual
This is the default ISR of the object. It must be implemented by the derived class and is called by InvokeISR() if no call function is specified in SetISR().
 

type of all call functions:

typedef void (*CallFunc)(CNeedInterrupt*): A CallFunc is a global function that takes a CNeedInterrupt* as argument. The default call function is CallISR(), which will call the default ISR CNeedInterrupt::isr(). The call function is executed by the interrupt handler and should call the appropriate ISR of the object that is passed as its argument.
 

global functions:

INT8 GetClockIntLevel(): Returns the interrupt level of the UTCSU and LANCE interrupts. The levels should be equal (if they are not, correct behaviour of the simulation cannot be guaranteed).
Note: implementations for pure and hardware-based simulation differ.

int GetClockIntvec (SINT32 nodeID, int area): Returns the clock interrupt vector for the area on the given node. If area is greater or equal to the minimum of MAXASICS (ci.h) and 16, an assert fails.
Note: implementations for pure and hardware-based simulation differ.

int GetGpsIntvec (SINT32 nodeID, int area, INT8 gpu): Returns the GPS-receiver interrupt vector for the area and GPU on the given node (gpu=0,1,2 for GPU1,2,3). If area is greater or equal to the minimum of MAXASICS (ci.h) and 16, or if gpu is not equal to 0,1 or 2, an assert fails.
Note: implementations for pure and hardware-based simulation differ.

void InvokeISR (int vector): Calls all object ISRs that are associated with this vector. If PSOS_SIM is not defined and there is not at least one ISR stored for the given vector, an assert fails.

void RemoveISR (int vector, CNeedInterrupt *obj, CallFunc caller = CallISR): Removes the object with the given vector and call function from the interrupt vector table. Please use only this function to remove the object (ISR) from the vector table!

void SetISR (int vector, CNeedInterrupt *obj, CallFunc caller = CallISR): Stores the object with the given vector and call function in the interrupt vector table. The function caller() will be invoked by the interrupt. If the vector is in use, the object is simply added to a list of ISRs that are called by InvokeISR(). Please use only this function to add an object (ISR) to the vector table!
 

implementation file:

The file contains class CInterruptHandler and a static object of that type.
 

-) member variables of CInterruptHandler:

CVectorTable table_: stores the interrupt vector table.
 

-) member functions of CInterruptHandler:

EBool ClearTable (): This function only exists if NO_RESOURCE is not defined. In that case, C++SIM does not delete processes. However, all ISRs of an object are only removed when it is deleted. So, in this particular case, the ISRs of an object that does not participate in the simulation anymore are still left in the vector table and still executed whenever their vectors are generated, and we need special  functions to remove them even if their object does not. Function Cleartable() can be used to remove all entries from the vector table. It is useful when all objects are deleted at once (p.e., after a reset of the simulation).

EBool ClearTable (SINT32 nodeID, int area): This function also only exists if NO_RESOURCE is not defined. It removes all entries of the CSA with the ID <nodeID, area> from the vector table. The function removes all vectors that can be generated by calling GetClockIntvec() and OR-ing INTA, INTN and INTT, and all vectors that are obtained by calling GetGpsIntvec() with GPS1-3.

EBool Find (int vector, CNeedInterrupt **obj, CallFunc *caller): Gets the first object and ISR that correspond to this vector and stores them in obj and caller. If an entry was found, True is returned. Otherwise, False is returned and the parameters are not modified. If obj or caller is NULL, an assert fails.

EBool FindNext (CNeedInterrupt **obj, CallFunc *caller): Gets the next object and ISR that correspond to the vector specified in the last call to Find() and stores them in obj and caller. If another entry was found, True is returned. Otherwise, False is returned and the parameters are not modified. If obj or caller is NULL, an assert fails.

void Insert (int vector, CNeedInterrupt *obj, CallFunc caller): Stores the ISR with this vector.


last modified: Fri Feb 5 18:56:22 1999