80CreateMmcHostInstance (
90 if (MmcHostInstance ==
NULL) {
94 MmcHostInstance->Signature = MMC_HOST_INSTANCE_SIGNATURE;
96 MmcHostInstance->State = MmcHwInitializationState;
99 if (MmcHostInstance->BlockIo.
Media ==
NULL) {
104 MmcHostInstance->BlockIo.Reset =
MmcReset;
109 MmcHostInstance->MmcHost = MmcHost;
112 Status = MmcHost->BuildDevicePath (MmcHost, &NewDevicePathNode);
113 if (EFI_ERROR (Status)) {
118 if (DevicePath ==
NULL) {
126 Status =
gBS->InstallMultipleProtocolInterfaces (
127 &MmcHostInstance->MmcHandle,
128 &gEfiBlockIoProtocolGuid,
129 &MmcHostInstance->BlockIo,
130 &gEfiDevicePathProtocolGuid,
131 MmcHostInstance->DevicePath,
134 if (EFI_ERROR (Status)) {
135 goto FREE_DEVICE_PATH;
138 return MmcHostInstance;
153DestroyMmcHostInstance (
160 Status =
gBS->UninstallMultipleProtocolInterfaces (
161 MmcHostInstance->MmcHandle,
162 &gEfiBlockIoProtocolGuid,
163 &(MmcHostInstance->BlockIo),
164 &gEfiDevicePathProtocolGuid,
165 MmcHostInstance->DevicePath,
171 if (MmcHostInstance->BlockIo.Media) {
172 FreePool (MmcHostInstance->BlockIo.Media);
175 if (MmcHostInstance->CardInfo.ECSDData) {
203 if (RemainingDevicePath !=
NULL) {
213 Node.DevPath = RemainingDevicePath;
218 return EFI_UNSUPPORTED;
226 Status =
gBS->OpenProtocol (
228 &gEmbeddedMmcHostProtocolGuid,
230 This->DriverBindingHandle,
232 EFI_OPEN_PROTOCOL_BY_DRIVER
234 if (Status == EFI_ALREADY_STARTED) {
238 if (EFI_ERROR (Status)) {
247 &gEmbeddedMmcHostProtocolGuid,
248 This->DriverBindingHandle,
260MmcDriverBindingStart (
273 if (RemainingDevicePath !=
NULL) {
286 Status =
gBS->OpenProtocol (
288 &gEmbeddedMmcHostProtocolGuid,
290 This->DriverBindingHandle,
292 EFI_OPEN_PROTOCOL_BY_DRIVER
294 if (EFI_ERROR (Status)) {
295 if (Status == EFI_ALREADY_STARTED) {
302 MmcHostInstance = CreateMmcHostInstance (MmcHost);
303 if (MmcHostInstance !=
NULL) {
307 MmcHostInstance->Initialized =
FALSE;
321MmcDriverBindingStop (
332 MMC_TRACE (
"MmcDriverBindingStop()");
335 CurrentLink = mMmcHostPool.ForwardLink;
336 while (CurrentLink !=
NULL && CurrentLink != &mMmcHostPool && (Status ==
EFI_SUCCESS)) {
337 MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK (CurrentLink);
338 ASSERT (MmcHostInstance !=
NULL);
341 Status =
gBS->CloseProtocol (
343 &gEmbeddedMmcHostProtocolGuid,
344 This->DriverBindingHandle,
349 RemoveMmcHost (MmcHostInstance);
352 DestroyMmcHostInstance (MmcHostInstance);
369 CurrentLink = mMmcHostPool.ForwardLink;
370 while (CurrentLink !=
NULL && CurrentLink != &mMmcHostPool) {
371 MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK (CurrentLink);
372 ASSERT (MmcHostInstance !=
NULL);
374 if (MmcHostInstance->MmcHost->IsCardPresent (MmcHostInstance->MmcHost) == !MmcHostInstance->Initialized) {
375 MmcHostInstance->State = MmcHwInitializationState;
377 MmcHostInstance->Initialized = !MmcHostInstance->Initialized;
380 InitializeMmcDevice (MmcHostInstance);
383 Status =
gBS->ReinstallProtocolInterface (
384 (MmcHostInstance->MmcHandle),
385 &gEfiBlockIoProtocolGuid,
386 &(MmcHostInstance->BlockIo),
387 &(MmcHostInstance->BlockIo)
390 if (EFI_ERROR (Status)) {
391 Print (L
"MMC Card: Error reinstalling BlockIo interface\n");
395 CurrentLink = CurrentLink->ForwardLink;
401 MmcDriverBindingStart,
402 MmcDriverBindingStop,
439 Status =
gBS->InstallMultipleProtocolInterfaces (
441 &gEfiDriverDiagnostics2ProtocolGuid,
442 &gMmcDriverDiagnostics2,
448 Status =
gBS->CreateEvent (
449 EVT_NOTIFY_SIGNAL | EVT_TIMER,
457 Status =
gBS->SetTimer (
460 (UINT64)(10*1000*200)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
#define HARDWARE_DEVICE_PATH
UINTN EFIAPI DevicePathNodeLength(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
VOID EFIAPI SetDevicePathEndNode(OUT VOID *Node)
VOID EFIAPI FreePages(IN VOID *Buffer, IN UINTN Pages)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#define SIGNATURE_32(A, B, C, D)
#define ASSERT_EFI_ERROR(StatusParameter)
#define EFI_BLOCK_IO_INTERFACE_REVISION
EFI_STATUS EFIAPI MmcDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
VOID InitializeMmcHostPool(VOID)
EFI_EVENT gCheckCardsEvent
VOID InsertMmcHost(IN MMC_HOST_INSTANCE *MmcHostInstance)
EFI_STATUS EFIAPI MmcFlushBlocks(IN EFI_BLOCK_IO_PROTOCOL *This)
EFI_STATUS EFIAPI MmcReadBlocks(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI MmcWriteBlocks(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI MmcReset(IN EFI_BLOCK_IO_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
#define EFI_SIZE_TO_PAGES(Size)
UINTN EFIAPI Print(IN CONST CHAR16 *Format,...)
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
EFI_BLOCK_IO_MEDIA * Media