#include <exec/chTrap.h>int svTrapConnect(unsigned int trapno, KnTrapHdl routine);
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
The svTrapConnect() system call connects a trap handler to the hardware trap specified by trapno . The trapno value is machine-dependent. The routine pointer points to the handler. The handler is a function which takes two arguments: int handler (ctx, itno)
KnThreadCtx* ctx ; unsigned int itno ;After being connected, a handler is activated upon invocation of the trap trapno by a thread. The current thread register context is saved. The handler takes as arguments a pointer to the saved context ctx and the trap number trapno .
Only one handler may be connected to a given trap number at a time. The svTrapDisConnect() system call disconnects the handler routine previously associated with the trapno trap number. These calls are restricted to SUPERVISOR threads. Trap handlers are executed in SUPERVISOR execution mode. The handler's code and data accessed must be parts of locked-in-memory regions of a SUPERVISOR actor.
When a thread executes a trap handler (via a hardware trap invocation), its execution actor is changed to match the actor that declared the handler. It is still attached to the actor within which it was created, although the executed code is part of another actor's address space (a SUPERVISOR actor).
The execution actor of a thread determines the actor that must be used for the invocation of exception handlers (see svExcHandler(2K) ) if the thread encounters an exception. It also determines when abort handlers are invoked (see svAbortHandler(2K) ).
The execution actor does not determine the interpretation of actor references - the thread's home actor is always used. Consequently, care must be taken when invoking actorSelf(2K) or using the K_MYACTOR value in actor-related calls (such as threadCreate(2K) ) within a trap handler. They refer to the thread's home actor. The execution actor must be explicitly named by its capability, if required, if the handler is to manage this actor's address space, for example.
When the trap handler returns, the previous thread's execution actor is restored.
There is already a valid descriptor installed for the trap number.
Incorrect trap number.
See attributes(5) for descriptions of the following attributes:
|ATTRIBUTE TYPE||ATTRIBUTE VALUE|