Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

RMC insertion and removal notifications

This section contains information on RMC insertion and removal notification prerequisites, implementation details, and OEMDeviceNotifier.c details.

Prerequisites

The following are RMC insertion and removal notification prerequisites:

  • EFS VU MSMSHARED_EFS.01.02.48 or higher implements the HotPlug Manager feature needed by this feature.
  • If an OEM uses a file system other than EFS, an equivalent of HotPlug Manager functionality of EFS must be present to enable this feature in Brew MP by modifying \platform\brewmp\system\brewcore\src\oem\ishellbased\OEMDeviceNotifier.c to interface with the alternate file system chosen.

Implementation details

The following are RMC insertion and removal notification implementation details.

  • A new nmask is added for MMC insertion and removal notification in \platform\brewmp\system\brewcore\inc\oem\AEEDeviceNotifier.h:
    • NMASK_DEVICENOTIFIER_MMC
    • #define NMASK_DEVICENOTIFIER_MMC 0x00000080
  • The MMC removal and insertion events are defined by following macros in AEEDeviceNotifier.h:
    • #define AEE_INSERT_MMC 0
    • #define AEE_REMOVE_MMC 1

See AEEDeviceNotifier.h for a detailed description of the nmask and insertion and removal macros.

  • When a removable media device is inserted or removed, the OEM layer notifies Brew MP of these events using the following macro (defined in OEMDeviceNotifier.h):
    • #define AEE_SEND_MMC_NOTIFY(p) {\
    • (void) AEE_Notify(AEECLSID_DEVICENOTIFIER, NMASK_DEVICENOTIFIER_MMC, p);}

See the OEMDeviceNotifier.h file for a detailed description of the macro and its fields.

This feature is active in the OEM layer if FEATURE_EFS_HOTPLUG is defined in the build. This feature flag indicates that EFS provides the HotPlug Manager functionality necessary for RMC insertion and removal notifications to work.

OEMDeviceNotifier.c details

The reference implementation caters only to the Brew MP supported MMC, specified via the AEEFS_CARD0_DIR (fs:/card0/) path. The default device mapping of this path is /mmc1.

AEEDeviceNotifier_New() calls CDeviceNotifier_HpmInit(). The CDeviceNotifier_HpmInit() function registers a callback handler with EFS for RMC insertion and removal notification using the EFS provided hotplug_notify_register() API. The callback function is registered in CDeviceNotifier_HpmNotify().

CDeviceNotifier_HpmNotify() is the callback function invoked from EFS when RMC insertion or removal is detected. This notification function checks that the event received is for the MMC card supported in the implementation, and then it schedules a Brew MP system callback via AEE_SYS_RESUME().

The Brew MP system callback is processed by the following function that calls AEE_SEND_MMC_NOTIFY to dispatch the notification event to interested applications.

static void CDeviceNotifier_HpmSysNotify(void* pv)

{

   CDeviceNotifier* pMe = (CDeviceNotifier*) pv;
   AEEDeviceNotify devNtfy;
   FARF(DEVNTFY,("CDeviceNotifier_HpmSysNotify"));
   if (pMe->m_lastEvent == HOTPLUG_NOTIFY_EVENT_CARD_INSERTED) {
      FARF(DEVNTFY,("AEE_INSERT_MMC"));
      devNtfy.wParam = AEE_INSERT_MMC;
   }
   else {  // this is fine. no other event can come here.
      FARF(DEVNTFY,("AEE_REMOVE_MMC"));
      devNtfy.wParam = AEE_REMOVE_MMC;
   }
   devNtfy.dwParam  = pMe->m_mmcId;
   AEE_SEND_MMC_NOTIFY(&devNtfy);
}