0

I'm a newbie. I'm working in WinCE7 SDHC driver. During initialization, certain functions are assigned to a structure variable as handlers. Those functions are automatically called. That is, I'm not able to trace out which function calls it.

I referred this stackoverflow link. Still, I'd like to know, how to trace, which handler is called when. Please guide me.

typedef struct _SDCARD_HC_CONTEXT {
    DWORD                       dwVersion;          // version of context structure

    WCHAR                       HostControllerName[SD_HC_MAX_NAME_LENGTH];  // friendly name
    CRITICAL_SECTION            HCCritSection;      // host controller critical section
    PSD_BUS_REQUEST_HANDLER     pBusRequestHandler; // bus request handler
    PSD_GET_SET_SLOT_OPTION     pSlotOptionHandler; // slot option handler
    PSD_CANCEL_REQUEST_HANDLER  pCancelIOHandler;   // cancel request handler
    PSD_INITIALIZE_CONTROLLER   pInitHandler;       // init handler       
    PSD_DEINITIALIZE_CONTROLLER pDeinitHandler;     // deinit handler
    PVOID                       pHCSpecificContext; // host controller specific context
    PSD_CHANGE_CARD_POWER       pChangeCardPowerHandler; // Pointer to power control handler
} SDCARD_HC_CONTEXT, *PSDCARD_HC_CONTEXT;

This is the structure to which functions are assigned.

Community
  • 1
  • 1
Gomu
  • 1,004
  • 5
  • 16
  • 36

1 Answers1

2

In this particular case (your SDHC driver), these are the function pointers which will be used by SDBus driver. You can check the SDBus driver source code in path:

%WINCE700%\public\COMMON\oak\drivers\sdcard\sdbus

You can find some lines like, for example,

SD_API_STATUS   BusRequestHandler(DWORD dwSlot, PSD_BUS_REQUEST pSdBusRequest)  {
        return pBusRequestHandler((PSDCARD_HC_CONTEXT)this,dwSlot,pSdBusRequest);

This is the function pointer that you have assigned in your SDHC driver source code, and being used by your SDBus driver source code.

Keshava GN
  • 4,195
  • 2
  • 36
  • 47
  • Thank you! So, wherever necessary, the SDBus will call these functions (BusRequestHandler, for eg), so at that point of time, the corresponding functions assigned to the structure will be invoked. Am I right? – Gomu Jan 13 '14 at 05:48