td_hoc_svc

De.ne System Call/Extended SVC Hook Routine

[C Language Interface]

ER ercd = td_hok_svc ( TD_HSVC *hsvc ) ;

[Parameters]

TD_HSVC hsvc Hook routine definition information

hsvc detail:

FP enter Hook routine before calling

FP leave Hook routine after calling

[Return Parameters]

ER ercd Error code

[Description]

Sets hook routines before and after the issuing of a system call or extended SVC. Setting NULL in hsvc cancels a hook routine.

The objects of a trace are T-Kernel/OS system calls (tk_.) and extended SVC. Depending on the implementation, generally tk_ret_int is not an object of a trace.

T-Kernel/DS service calls (td_.) are not objects of a trace.

A hook routine is called in the context from which the system call or extended SVC was called. For example, the invoking task in a hook routine is the same as the task that invoked the system call or extended SVC.

Since task dispatching and interrupts can occur inside system call processing, enter() and leave() are not necessarily called in succession as a pair in every case. If a system call is one that does not return, leave() will not be called.

VP enter( FN fncd, TD_CALINF *calinf, … )

fncd Function code

< 0 System call

> 0 Extended SVC

calinf Caller information

… Parameters (variable number)

return code Any value passed to leave()

typedef struct td_calinf {

As information for determining the address from which a system call or extended SVC was called, it is preferable to include information for performing a stack back-trace. The contents are implementation-dependent, but generally consist of register values such as stack pointer and program counter.

} TD_CALINF;

This is called right before a system call or extended SVC. The value passed in the return code is passed transparently to the corresponding leave(). This makes it possible to con.rm the pairing of enter() and leave() calls or to pass any other information.


exinf = enter(fncd, &calinf, ... )
ret = system call or extended SVC execution
leave(fncd , ret, exinf)
  • System call The parameters are the same as the system call parameters.

Example:

For system call tk_wai_sem( ID semid, INT cnt, TMO tmout )


	enter(TFN_WAI_SEM, &calinf, semid, cnt, tmout)
  • Extended SVC The parameters are as in the packet passed to the extended SVC handler. fncd is likewise the same as that passed to the extended SVC handler.

	enter( FN fncd, TD\_CALINF *calinf, VP pk\_para )

void leave( FN fncd, INT ret, VP exinf )

fncd Function code

ret Return code of the system call or extended SVC

exinf Any value returned by enter()

This is called right after returning from a system call or extended SVC.

When a hook routine is set after a system call or extended SVC is called (while the system call or extended SVC is executing), in some cases leave() only may be called without calling enter(). In such a case NULL is passed in exinf. If, on the other hand, a hook routine is canceled after a system call or extended SVC is called, there may be cases when enter() is called but not leave().

Comments