This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Hwi_Handle in hwi hooks

Other Parts Discussed in Thread: OMAP-L138, SYSBIOS

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

  • Hi Stéphane,
    The Hwi module is designed with 2 layers of abstraction. The higher-level one is the Hal Hwi and it points to the lower-level corresponding family specific Hwi module of the device you're building for. The family specific Hwi is simply a delegate of the higher-level Hal Hwi. Since you have #include <ti/sysbios/hal/Hwi.h> in your source file, the handle returned by Hwi_Object_get is the Hal Hwi handle while in your hook functions, the Hwi handle you're seeing is the handle of the family specific Hwi module. If you replace the Hal Hwi #include with the family specific one: #include <ti/sysbios/family/c64p/Hwi.h>, Hwi_Object_get should now return the same Hwi handle as that in you hook functions.

    Try this out and let me know.

    Regards,
    Moses
  • Hi Moses,

    Thanks for your hint with the include file. After changing that, both functions (hook and Hwi_Object_get) return the same Hwi_Handle.

    But calling Hwi_Handle_name with the lower-layer handles as argument, always returns '{unknown-instance-name}'…

    Do you have a suggestion to get the name information as well?

     

    Regards

    Stéphane

  • Hi Stéphane,

            The Hwi_Handle name is stored in either the HAL Hwi object or the delegate (family Hwi) depending on how you create the Hwi object. If you want to retrieve the name from the Delegate Hwi (lower level Hwi object) then in your cfg file you'll replace this line:

    var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');

    with this:

    var Hwi = xdc.useModule("ti.sysbios.family.c64p.Hwi");

     

    Let me know if this helps.

    Regards,

    Moses

  • Perfect! Thanks!
    Stéphane