The following three examples illustrate how to connect, disconnect, and get trap handlers in the ChorusOS operating system.
A trap handler specified as a LAP handler can be connected to a given trap number by calling the primitive:
#include <exec/chTrap.h> int svSysTrapHandlerConnect( unsigned int trapNumber, KnLapDesc *trapLapDesc );
This call returns K_OK if it is successful and returns a negative value if unsuccessful.
Value |
Error |
---|---|
K_EBUSY |
trapNumber is already connected |
K_EINVAL |
trapNumber is invalid |
A trap handler previously connected to a trap number with a call to svSysTrapHandlerConnect() can be disconnected by calling the primitive:
#include <exec/chTrap.h> int svSysTrapHandlerDisconnect( unsigned int trapNumber, KnLapDesc *currentTrapLapDesc );
The value of currentTrapLapDesc can be K_CONNECTED_LAP. If this is not the case, the value must point to a LAP descriptor that is identical to the LAP desciptor currently connected to the trap number.
The function will K_OK if successful or a negative value if an error occurs.
Value |
Error |
---|---|
K_EINVAL |
currentTrapLapDesc is not K_CONNECTED_LAP and does not match the LAP descriptor of the current trap handler. |
A copy of the LAP descriptor corresponding to the trap handler that is currently connected to the trap number can be obtained by calling the primitive:
#include <exec/chTrap.h> int svSysTrapHandlerGetConnected( unsigned int trapNumber, KnLapDesc *currentTrapLapDesc );
The function returns K_OK on success and K_EINVAL if an error occurs.