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.

HookSet Functions in SysBios_v6.31

Other Parts Discussed in Thread: SYSBIOS

I am trying to use hookset functionality for Hwi, Tasks in sysbios. I could not understand, how to use them. Can anybody have any examples?

 

  • Hi Rahul,

    1145.hooksExample.zip

    I've attached a .c and .cfg that shows an example of Task hook functions. Below is the output on a C64+ device.

    Todd

    myRegister1: assigned HookSet Id = 0
    myRegister2: assigned HookSet Id = 1
    myCreate1: task name = 'ti.sysbios.knl.Task.IdleTask', pEnv = 0x0
    myCreate2: task name = 'ti.sysbios.knl.Task.IdleTask', pEnv = 0x0
    myReady1: task name = 'ti.sysbios.knl.Task.IdleTask', pEnv = 0xdead1
    myReady2: task name = 'ti.sysbios.knl.Task.IdleTask', pEnv = 0xdead2
    myCreate1: task name = 'myTsk0', pEnv = 0x0
    myCreate2: task name = 'myTsk0', pEnv = 0x0
    myReady1: task name = 'myTsk0', pEnv = 0xdead1
    myReady2: task name = 'myTsk0', pEnv = 0xdead2
    ti.sysbios.heaps.HeapMem: line 296: out of memory: handle=0x80e1e0, size=2048
    xdc.runtime.Error.raise: terminating execution
    myRegister1: assigned HookSet Id = 0
    myRegister2: assigned HookSet Id = 1
    myCreate1: task name = 'ti.sysbios.knl.Task.IdleTask', pEnv = 0x0
    myCreate2: task name = 'ti.sysbios.knl.Task.IdleTask', pEnv = 0x0
    myReady1: task name = 'ti.sysbios.knl.Task.IdleTask', pEnv = 0xdead1
    myReady2: task name = 'ti.sysbios.knl.Task.IdleTask', pEnv = 0xdead2
    myCreate1: task name = 'myTsk0', pEnv = 0x0
    myCreate2: task name = 'myTsk0', pEnv = 0x0
    myReady1: task name = 'myTsk0', pEnv = 0xdead1
    myReady2: task name = 'myTsk0', pEnv = 0xdead2
    mySwitch1: ignoring dummy 1st prev Task
    next name = 'myTsk0', pNextEnv = 0xc0de1
    mySwitch2: ignoring dummy 1st prev Task
    next name = 'myTsk0', pNextEnv = 0xc0de2
    myTsk0 Entering
    myTsk0 Calling Task_yield
    mySwitch1: prev name = 'myTsk0', pPrevEnv = 0xc001c0de
    next name = 'myTsk0', pNextEnv = 0xc0de0ff1
    mySwitch2: prev name = 'myTsk0', pPrevEnv = 0xc002c0de
    next name = 'myTsk0', pNextEnv = 0xc0de0ff2
    myTsk0 Exiting
    myExit1: curTask name = 'myTsk0', pEnv = 0xc001c0de
    myExit2: curTask name = 'myTsk0', pEnv = 0xc002c0de
    mySwitch1: prev name = 'myTsk0', pPrevEnv = 0xdedbeef1
    next name = 'ti.sysbios.knl.Task.IdleTask', pNextEnv = 0xc0de1
    mySwitch2: prev name = 'myTsk0', pPrevEnv = 0xdedbeef2
    next name = 'ti.sysbios.knl.Task.IdleTask', pNextEnv = 0xc0de2
    Entering idleFunc().
    myDelete1: task name = 'myTsk0', pEnv = 0xc0de0ff1
    myDelete2: task name = 'myTsk0', pEnv = 0xc0de0ff2

  •  

    Hi Todd,

    Thank you for your reply. Examples are very helpful. I have the following questions.

    1. If there are multiple HookSet functions, Do all HookSet functions will be called corresponding to a task operation? For example, if there are mySwitch1,mySwitch2,mySwitch3 hook functions for a Task switch operation, Do all three mySwitch1,mySwitch2,mySwitch3 functions will be called whenever a Task switch happens?. If yes, what is the advantage of having multiple HookSet functions?

    2. In .cfg sysbios file, when I clicked and highlighted the "ti.sysbios.knl.Task", I see a "hooks" field in the properties window. But, when I clicked and highlighted the "ti.sysbios.hal.Hwi", I don't see "hooks" field in the properties window. Does this mean, hook functions are not supported for Hwi or am I missing anything in the setup?

    3. I read in the sysbios documentation that the Hook functions are also supported for HWI, SWI. If I have to add the hooks for HWI, Do I have to write in the similar way as Tasks in your example? Below is an example:

    Hwi.addHookSet({
        registerFxn: '&myRegister1',
        createFxn: '&myCreate1',
        beginFxn: '&myReady1',
        endFxn: '&mySwitch1',
        deleteFxn: '&myDelete1',
    });

     

    Thanks a lot,

    Rahul

     

     

  • Hi Rahul,

    #1: Each hook set is called. This allows different developers (or middle-ware) providers to have their own set of hooks. If there was only one set, management would be be harder to coordinate.

    #2: Not sure about this. I'll look into it. You can manually enter them in the .cfg file (i.e. you text-view)

    #3: Yes.

    Todd

  • Hi Todd,

    Thank you for your answers. Your answers are very helpful.

     

    Thanks,

    Rahul