Share via


Slot Event Callback

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

A Secure Digital (SD) card client driver has the option to register a slot event callback. The callback provides asynchronous notification about changes in the slot state. The following code example shows a typical slot event callback.

VOID SlotEventCallBack(SD_DEVICE_HANDLE hDevice,
  PVOID pContext,
  SD_SLOT_EVENT_TYPE SlotEventType,
  PVOID pData,
  DWORD DataLength)
{
  PSD_MY_DEVICE_INSTANCE pDevice = (PSD_MEMCARD_INFO)pContext;
  switch (SlotEventType) {
    case SDCardEjected :
    // mark that the card is being ejected
    pDevice->CardEjected = TRUE;
    break;
    }
}

The client driver uses the registration information structure to provide a pointer to the function of the client. The following code example shows a typical registration information structure.

memset(&ClientInfo, 0, sizeof(ClientInfo));
// set client options and register as a client device
_tcscpy(ClientInfo.ClientName, TEXT("MyDriver"));

// set the callback, we want slot events
ClientInfo.pSlotEventCallBack = SlotEventCallBack;

// register the client
Status = SDRegisterClient(hClientHandle, 
  pDevice,
  &ClientInfo);

The slot event type is passed as a parameter to the callback. The callback can be called in any thread context and the slot event type can restrict what can and cannot be done when the callback is invoked.

The SDCardEjected notification is made when a card is removed from a slot. When this event type is indicated, the client driver should not submit any bus requests within the callback.

The callback is invoked, with this event type, prior to calling the XXX_Deinit (Device Manager) entry point of the client driver. This gives the client driver an opportunity to set an internal device state prior to its final uninitialization. For example, the callback can set a flag that directs the client driver to reject future user application I/O requests.

See Also

Reference

XXX_Deinit (Device Manager)

Concepts

Secure Digital Card Client Driver