HOOK Module
2-138
In addition, each HOOK object can maintain private data environments
for each task for use by its hook functions.
The key execution points at which hook functions can be executed are
during program initialization and at several TSK execution points.
The HOOK module manages objects that reference a set of hook
functions. Each HOOK object is assigned a numeric identifier during
DSP/BIOS initialization. If your program calls HOOK API functions, you
must implement an initialization function for the HOOK instance that
records the identifier in a variable of type HOOK_Id. DSP/BIOS passes
the HOOK object’s ID to the initialization function as the lone parameter.
The following function, myInit, could be configured as the Initialization
function for a HOOK object using Tconf.
#include <hook.h>
HOOK_Id myId;
Void myInit(HOOK_Id id)
{
myId = id;
}
The HOOK_setenv function allows you to associate an environment
pointer to any data structure with a particular HOOK object and TSK
object combination.
There is no limit to the number of HOOK objects that can be created.
However, each object requires a small amount of memory in the .bss
section to contain the object.
A HOOK object initially has all of its functions set to FXN_F_nop. You can
set some hook functions and use this no-op function for the remaining
events. Since the switch and ready events occur frequently during real-
time processing, a separate property controls whether any function is
called.
When you create a HOOK object, any TSK module hook functions you
have specified are automatically placed in a HOOK object called
HOOK_KNL. To set any properties of this object other than the
Initialization function, use the TSK module. To set the Initialization
function property of the HOOK_KNL object, use the HOOK module.
When an event occurs, all HOOK functions for that event are called in the
order set by the order property in the configuration. When you select the
HOOK manager in the DSP/BIOS Configuration Tool, you can change
the execution order by dragging objects within the ordered list.