Hello,
I’m trying to make some interrupt statistics. In a first approach I just implemented a simple counter in the endFxn for each handle. But I can't get access to the data within the hook context from an external function, because the Hwi_Handle I receive with Hwi_Object_get does not correspond to the Hwi_Handle as parameter of the hook function. Is there a way to get the Hwi_handle used in the hook function from outside the hook?
BIOS: 6.40.2.27
Processor: OMAP-L138
Target: ti.targets.elf.C674
Following code snippets from my implementation:
------------------------------------- Configuration script ----------------------------------------------
var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
Hwi.dispatcherAutoNestingSupport = false;
Hwi.dispatcherSwiSupport = false;
Hwi.dispatcherTaskSupport = true;
Hwi.common$.namedInstance = true;
Hwi.addHookSet({
createFxn : '&hwiCreate',
endFxn : '&hwiEnd',
});
------------------------------------- C-code -------------------------------------
typedef struct {
Hwi_Handle hwi;
int counter;
} MyHwiStruct;
MyHwiStruct myHwi[MAX_HWI_HANDLE] = {0};
void hwiCreate(Hwi_Handle hwi, Error_Block *eb) {
int i;
for(i=0; i<MAX_HWI_HANDLE; i++) {
if(myHwi[i].hwi == 0) {
myHwi[i].hwi = hwi;
Ptr pEnv = (Ptr) &myHwi[i];
Hwi_setHookContext(hwi, 0, pEnv);
return;
}
}
}
void hwiEnd(Hwi_Handle hwi) {
Ptr pEnv = Hwi_getHookContext(hwi, 0);
((MyHwiStruct*)pEnv)->counter ++;
Hwi_setHookContext(hwi, 0, pEnv);
}
So far so good. Looping over myHwi shows me the increasing hwi counters. But I can’t match the Hwi_Handle from Hwi_Object_get and Hwi_Object_first/next to the handles in the hook functions:
void DspInterruptStatisticGet(void) {
int i;
for(i=0; i<MAX_HWI_HANDLE; i++) {
if(myHwi[i].hwi != 0) {
LogPrintf("%i: counter: %5i, handle: 0x%x'", i, myHwi[i].counter, myHwi[i].hwi);
}
if(myHwi[i].hwi == 0) {
continue;
}
}
Hwi_Instance_State* array = NULL;
for(i = 0; i < Hwi_Object_count(); i++){
Hwi_Handle staticHwi = Hwi_Object_get(array, i);
LogPrintf("static %5i: handle 0x%x '%s'", i, staticHwi, Hwi_Handle_name(staticHwi));
}
Hwi_Handle dynamicHwi = Hwi_Object_first();
while(dynamicHwi != NULL) {
LogPrintf("dynamic %5i: handle 0x%x '%s'", i++, dynamicHwi, Hwi_Handle_name(dynamicHwi));
dynamicHwi = Hwi_Object_next(dynamicHwi);
}
}
Resulting output:
LOG_DO: 0: counter: 6005, handle: 0xc4208288'
LOG_DO: 1: counter: 18, handle: 0xc3208338'
LOG_DO: 2: counter: 165, handle: 0xc3208378'
LOG_DO: 3: counter: 1, handle: 0xc3217e88'
LOG_DO: 4: counter: 0, handle: 0xc3217ec8'
LOG_DO: 5: counter: 0, handle: 0xc3217f80'
LOG_DO: static 0: handle 0xc4208400 '{empty-instance-name}'
LOG_DO: dynamic 1: handle 0xc3208320 'UIpcTx'
LOG_DO: dynamic 2: handle 0xc3208360 'UIpcRx'
LOG_DO: dynamic 3: handle 0xc3217e70 'FPGA Hwi General'
LOG_DO: dynamic 4: handle 0xc3217eb0 'FPGA Hwi Actors'
LOG_DO: dynamic 5: handle 0xc3217f68 'upp Interrupt'
Kind regards
Stéphane Peter