This page is available in: en

td_hok_svc

Define 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 the service call


	FP	leave	Hook routine after calling the service call

[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 system calls (tk_xxx) and extended SVC. Depending on the implementation, generally tk_ret_int is not the object of a trace.

Debugger support function system calls (td_xxx) 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 to be 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 on to the corresponding leave(). This makes it possible to confirm 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 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, only leave() 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

Click here to Post a Comment