30 EMMC_PARTITION_SIGNATURE,
36 EFI_BLOCK_IO_PROTOCOL_REVISION,
66 EFI_ERASE_BLOCK_PROTOCOL_REVISION,
96 DEBUG ((DEBUG_INFO,
"== Dump Emmc Csd Register==\n"));
97 DEBUG ((DEBUG_INFO,
" CSD structure 0x%x\n", Csd->CsdStructure));
98 DEBUG ((DEBUG_INFO,
" System specification version 0x%x\n", Csd->SpecVers));
99 DEBUG ((DEBUG_INFO,
" Data read access-time 1 0x%x\n", Csd->Taac));
100 DEBUG ((DEBUG_INFO,
" Data read access-time 2 0x%x\n", Csd->Nsac));
101 DEBUG ((DEBUG_INFO,
" Max. bus clock frequency 0x%x\n", Csd->TranSpeed));
102 DEBUG ((DEBUG_INFO,
" Device command classes 0x%x\n", Csd->Ccc));
103 DEBUG ((DEBUG_INFO,
" Max. read data block length 0x%x\n", Csd->ReadBlLen));
104 DEBUG ((DEBUG_INFO,
" Partial blocks for read allowed 0x%x\n", Csd->ReadBlPartial));
105 DEBUG ((DEBUG_INFO,
" Write block misalignment 0x%x\n", Csd->WriteBlkMisalign));
106 DEBUG ((DEBUG_INFO,
" Read block misalignment 0x%x\n", Csd->ReadBlkMisalign));
107 DEBUG ((DEBUG_INFO,
" DSR implemented 0x%x\n", Csd->DsrImp));
108 DEBUG ((DEBUG_INFO,
" Device size 0x%x\n", Csd->CSizeLow | (Csd->CSizeHigh << 2)));
109 DEBUG ((DEBUG_INFO,
" Max. read current @ VDD min 0x%x\n", Csd->VddRCurrMin));
110 DEBUG ((DEBUG_INFO,
" Max. read current @ VDD max 0x%x\n", Csd->VddRCurrMax));
111 DEBUG ((DEBUG_INFO,
" Max. write current @ VDD min 0x%x\n", Csd->VddWCurrMin));
112 DEBUG ((DEBUG_INFO,
" Max. write current @ VDD max 0x%x\n", Csd->VddWCurrMax));
113 DEBUG ((DEBUG_INFO,
" Device size multiplier 0x%x\n", Csd->CSizeMult));
114 DEBUG ((DEBUG_INFO,
" Erase group size 0x%x\n", Csd->EraseGrpSize));
115 DEBUG ((DEBUG_INFO,
" Erase group size multiplier 0x%x\n", Csd->EraseGrpMult));
116 DEBUG ((DEBUG_INFO,
" Write protect group size 0x%x\n", Csd->WpGrpSize));
117 DEBUG ((DEBUG_INFO,
" Write protect group enable 0x%x\n", Csd->WpGrpEnable));
118 DEBUG ((DEBUG_INFO,
" Manufacturer default ECC 0x%x\n", Csd->DefaultEcc));
119 DEBUG ((DEBUG_INFO,
" Write speed factor 0x%x\n", Csd->R2WFactor));
120 DEBUG ((DEBUG_INFO,
" Max. write data block length 0x%x\n", Csd->WriteBlLen));
121 DEBUG ((DEBUG_INFO,
" Partial blocks for write allowed 0x%x\n", Csd->WriteBlPartial));
122 DEBUG ((DEBUG_INFO,
" Content protection application 0x%x\n", Csd->ContentProtApp));
123 DEBUG ((DEBUG_INFO,
" File format group 0x%x\n", Csd->FileFormatGrp));
124 DEBUG ((DEBUG_INFO,
" Copy flag (OTP) 0x%x\n", Csd->Copy));
125 DEBUG ((DEBUG_INFO,
" Permanent write protection 0x%x\n", Csd->PermWriteProtect));
126 DEBUG ((DEBUG_INFO,
" Temporary write protection 0x%x\n", Csd->TmpWriteProtect));
127 DEBUG ((DEBUG_INFO,
" File format 0x%x\n", Csd->FileFormat));
128 DEBUG ((DEBUG_INFO,
" ECC code 0x%x\n", Csd->Ecc));
145 DEBUG ((DEBUG_INFO,
"==Dump Emmc ExtCsd Register==\n"));
146 DEBUG ((DEBUG_INFO,
" Supported Command Sets 0x%x\n", ExtCsd->CmdSet));
147 DEBUG ((DEBUG_INFO,
" HPI features 0x%x\n", ExtCsd->HpiFeatures));
148 DEBUG ((DEBUG_INFO,
" Background operations support 0x%x\n", ExtCsd->BkOpsSupport));
149 DEBUG ((DEBUG_INFO,
" Background operations status 0x%x\n", ExtCsd->BkopsStatus));
150 DEBUG ((DEBUG_INFO,
" Number of correctly programmed sectors 0x%x\n", *((UINT32 *)&ExtCsd->CorrectlyPrgSectorsNum[0])));
151 DEBUG ((DEBUG_INFO,
" Initialization time after partitioning 0x%x\n", ExtCsd->IniTimeoutAp));
152 DEBUG ((DEBUG_INFO,
" TRIM Multiplier 0x%x\n", ExtCsd->TrimMult));
153 DEBUG ((DEBUG_INFO,
" Secure Feature support 0x%x\n", ExtCsd->SecFeatureSupport));
154 DEBUG ((DEBUG_INFO,
" Secure Erase Multiplier 0x%x\n", ExtCsd->SecEraseMult));
155 DEBUG ((DEBUG_INFO,
" Secure TRIM Multiplier 0x%x\n", ExtCsd->SecTrimMult));
156 DEBUG ((DEBUG_INFO,
" Boot information 0x%x\n", ExtCsd->BootInfo));
157 DEBUG ((DEBUG_INFO,
" Boot partition size 0x%x\n", ExtCsd->BootSizeMult));
158 DEBUG ((DEBUG_INFO,
" Access size 0x%x\n", ExtCsd->AccSize));
159 DEBUG ((DEBUG_INFO,
" High-capacity erase unit size 0x%x\n", ExtCsd->HcEraseGrpSize));
160 DEBUG ((DEBUG_INFO,
" High-capacity erase timeout 0x%x\n", ExtCsd->EraseTimeoutMult));
161 DEBUG ((DEBUG_INFO,
" Reliable write sector count 0x%x\n", ExtCsd->RelWrSecC));
162 DEBUG ((DEBUG_INFO,
" High-capacity write protect group size 0x%x\n", ExtCsd->HcWpGrpSize));
163 DEBUG ((DEBUG_INFO,
" Sleep/awake timeout 0x%x\n", ExtCsd->SATimeout));
164 DEBUG ((DEBUG_INFO,
" Sector Count 0x%x\n", *((UINT32 *)&ExtCsd->SecCount[0])));
165 DEBUG ((DEBUG_INFO,
" Partition switching timing 0x%x\n", ExtCsd->PartitionSwitchTime));
166 DEBUG ((DEBUG_INFO,
" Out-of-interrupt busy timing 0x%x\n", ExtCsd->OutOfInterruptTime));
167 DEBUG ((DEBUG_INFO,
" I/O Driver Strength 0x%x\n", ExtCsd->DriverStrength));
168 DEBUG ((DEBUG_INFO,
" Device type 0x%x\n", ExtCsd->DeviceType));
169 DEBUG ((DEBUG_INFO,
" CSD STRUCTURE 0x%x\n", ExtCsd->CsdStructure));
170 DEBUG ((DEBUG_INFO,
" Extended CSD revision 0x%x\n", ExtCsd->ExtCsdRev));
171 DEBUG ((DEBUG_INFO,
" Command set 0x%x\n", ExtCsd->CmdSet));
172 DEBUG ((DEBUG_INFO,
" Command set revision 0x%x\n", ExtCsd->CmdSetRev));
173 DEBUG ((DEBUG_INFO,
" Power class 0x%x\n", ExtCsd->PowerClass));
174 DEBUG ((DEBUG_INFO,
" High-speed interface timing 0x%x\n", ExtCsd->HsTiming));
175 DEBUG ((DEBUG_INFO,
" Bus width mode 0x%x\n", ExtCsd->BusWidth));
176 DEBUG ((DEBUG_INFO,
" Erased memory content 0x%x\n", ExtCsd->ErasedMemCont));
177 DEBUG ((DEBUG_INFO,
" Partition configuration 0x%x\n", ExtCsd->PartitionConfig));
178 DEBUG ((DEBUG_INFO,
" Boot config protection 0x%x\n", ExtCsd->BootConfigProt));
179 DEBUG ((DEBUG_INFO,
" Boot bus Conditions 0x%x\n", ExtCsd->BootBusConditions));
180 DEBUG ((DEBUG_INFO,
" High-density erase group definition 0x%x\n", ExtCsd->EraseGroupDef));
181 DEBUG ((DEBUG_INFO,
" Boot write protection status register 0x%x\n", ExtCsd->BootWpStatus));
182 DEBUG ((DEBUG_INFO,
" Boot area write protection register 0x%x\n", ExtCsd->BootWp));
183 DEBUG ((DEBUG_INFO,
" User area write protection register 0x%x\n", ExtCsd->UserWp));
184 DEBUG ((DEBUG_INFO,
" FW configuration 0x%x\n", ExtCsd->FwConfig));
185 DEBUG ((DEBUG_INFO,
" RPMB Size 0x%x\n", ExtCsd->RpmbSizeMult));
186 DEBUG ((DEBUG_INFO,
" H/W reset function 0x%x\n", ExtCsd->RstFunction));
187 DEBUG ((DEBUG_INFO,
" Partitioning Support 0x%x\n", ExtCsd->PartitioningSupport));
190 " Max Enhanced Area Size 0x%02x%02x%02x\n", \
191 ExtCsd->MaxEnhSizeMult[2],
192 ExtCsd->MaxEnhSizeMult[1],
193 ExtCsd->MaxEnhSizeMult[0]
195 DEBUG ((DEBUG_INFO,
" Partitions attribute 0x%x\n", ExtCsd->PartitionsAttribute));
196 DEBUG ((DEBUG_INFO,
" Partitioning Setting 0x%x\n", ExtCsd->PartitionSettingCompleted));
199 " General Purpose Partition 1 Size 0x%02x%02x%02x\n", \
200 ExtCsd->GpSizeMult[2],
201 ExtCsd->GpSizeMult[1],
202 ExtCsd->GpSizeMult[0]
206 " General Purpose Partition 2 Size 0x%02x%02x%02x\n", \
207 ExtCsd->GpSizeMult[5],
208 ExtCsd->GpSizeMult[4],
209 ExtCsd->GpSizeMult[3]
213 " General Purpose Partition 3 Size 0x%02x%02x%02x\n", \
214 ExtCsd->GpSizeMult[8],
215 ExtCsd->GpSizeMult[7],
216 ExtCsd->GpSizeMult[6]
220 " General Purpose Partition 4 Size 0x%02x%02x%02x\n", \
221 ExtCsd->GpSizeMult[11],
222 ExtCsd->GpSizeMult[10],
223 ExtCsd->GpSizeMult[9]
227 " Enhanced User Data Area Size 0x%02x%02x%02x\n", \
228 ExtCsd->EnhSizeMult[2],
229 ExtCsd->EnhSizeMult[1],
230 ExtCsd->EnhSizeMult[0]
232 DEBUG ((DEBUG_INFO,
" Enhanced User Data Start Address 0x%x\n", *((UINT32 *)&ExtCsd->EnhStartAddr[0])));
233 DEBUG ((DEBUG_INFO,
" Bad Block Management mode 0x%x\n", ExtCsd->SecBadBlkMgmnt));
234 DEBUG ((DEBUG_INFO,
" Native sector size 0x%x\n", ExtCsd->NativeSectorSize));
235 DEBUG ((DEBUG_INFO,
" Sector size emulation 0x%x\n", ExtCsd->UseNativeSector));
236 DEBUG ((DEBUG_INFO,
" Sector size 0x%x\n", ExtCsd->DataSectorSize));
256 CHAR8 String[EMMC_MODEL_NAME_MAX_LEN];
258 ZeroMem (String,
sizeof (String));
259 CopyMem (String, &Cid->OemId, sizeof (Cid->OemId));
260 String[
sizeof (Cid->OemId)] =
' ';
261 CopyMem (String +
sizeof (Cid->OemId) + 1, Cid->ProductName, sizeof (Cid->ProductName));
262 String[
sizeof (Cid->OemId) +
sizeof (Cid->ProductName)] =
' ';
263 CopyMem (String +
sizeof (Cid->OemId) + sizeof (Cid->ProductName) + 1, Cid->ProductSerialNumber, sizeof (Cid->ProductSerialNumber));
265 AsciiStrToUnicodeStrS (String, Device->ModelName, sizeof (Device->ModelName) / sizeof (Device->ModelName[0]));
299 if (EFI_ERROR (Status)) {
312 if (EFI_ERROR (Status)) {
318 if (EFI_ERROR (Status)) {
324 if ((Csd->CSizeLow | Csd->CSizeHigh << 2) == 0xFFF) {
325 Device->SectorAddressing =
TRUE;
327 Device->SectorAddressing =
FALSE;
332 if (EFI_ERROR (Status)) {
337 if (EFI_ERROR (Status)) {
341 ExtCsd = &Device->ExtCsd;
343 if (EFI_ERROR (Status)) {
349 if (ExtCsd->ExtCsdRev < 5) {
350 DEBUG ((DEBUG_ERROR,
"The EMMC device version is too low, we don't support!!!\n"));
351 return EFI_UNSUPPORTED;
354 if ((ExtCsd->PartitioningSupport & BIT0) != BIT0) {
355 DEBUG ((DEBUG_ERROR,
"The EMMC device doesn't support Partition Feature!!!\n"));
356 return EFI_UNSUPPORTED;
359 for (Index = 0; Index < EMMC_MAX_PARTITIONS; Index++) {
360 Partition = &Device->Partition[Index];
362 Partition->Device = Device;
364 Partition->BlockIo.
Media = &Partition->BlockMedia;
365 Partition->BlockIo2.
Media = &Partition->BlockMedia;
366 Partition->PartitionType = Index;
367 Partition->BlockMedia.
IoAlign = Device->Private->PassThru->IoAlign;
375 case EmmcPartitionUserData:
376 SecCount = *(UINT32 *)&ExtCsd->SecCount;
377 Capacity =
MultU64x32 ((UINT64)SecCount, 0x200);
379 case EmmcPartitionBoot1:
380 case EmmcPartitionBoot2:
381 Capacity = ExtCsd->BootSizeMult * SIZE_128KB;
383 case EmmcPartitionRPMB:
384 Capacity = ExtCsd->RpmbSizeMult * SIZE_128KB;
386 case EmmcPartitionGP1:
387 GpSizeMult = (UINT32)(ExtCsd->GpSizeMult[0] | (ExtCsd->GpSizeMult[1] << 8) | (ExtCsd->GpSizeMult[2] << 16));
390 case EmmcPartitionGP2:
391 GpSizeMult = (UINT32)(ExtCsd->GpSizeMult[3] | (ExtCsd->GpSizeMult[4] << 8) | (ExtCsd->GpSizeMult[5] << 16));
394 case EmmcPartitionGP3:
395 GpSizeMult = (UINT32)(ExtCsd->GpSizeMult[6] | (ExtCsd->GpSizeMult[7] << 8) | (ExtCsd->GpSizeMult[8] << 16));
398 case EmmcPartitionGP4:
399 GpSizeMult = (UINT32)(ExtCsd->GpSizeMult[9] | (ExtCsd->GpSizeMult[10] << 8) | (ExtCsd->GpSizeMult[11] << 16));
404 return EFI_INVALID_PARAMETER;
408 Partition->Enable =
TRUE;
412 if ((ExtCsd->EraseGroupDef & BIT0) == 0) {
413 if (Csd->WriteBlLen < 9) {
414 Partition->EraseBlock.EraseLengthGranularity = 1;
416 Partition->EraseBlock.EraseLengthGranularity = (Csd->EraseGrpMult + 1) * (Csd->EraseGrpSize + 1) * (1 << (Csd->WriteBlLen - 9));
419 Partition->EraseBlock.EraseLengthGranularity = 1024 * ExtCsd->HcEraseGrpSize;
453 ParentDevicePath = Device->DevicePath;
461 if (DevicePath ==
NULL) {
462 Status = EFI_OUT_OF_RESOURCES;
467 RemainingDevicePath = DevicePath;
468 Status =
gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &DeviceHandle);
469 if (!EFI_ERROR (Status) && (DeviceHandle !=
NULL) &&
IsDevicePathEnd (RemainingDevicePath)) {
470 Status = EFI_ALREADY_STARTED;
474 Partition = &Device->Partition[Index];
475 Partition->DevicePath = DevicePath;
476 if (Partition->Enable) {
480 if (Partition->PartitionType != EmmcPartitionRPMB) {
481 Status =
gBS->InstallMultipleProtocolInterfaces (
483 &gEfiDevicePathProtocolGuid,
484 Partition->DevicePath,
485 &gEfiBlockIoProtocolGuid,
487 &gEfiBlockIo2ProtocolGuid,
488 &Partition->BlockIo2,
489 &gEfiEraseBlockProtocolGuid,
490 &Partition->EraseBlock,
491 &gEfiDiskInfoProtocolGuid,
492 &Partition->DiskInfo,
495 if (EFI_ERROR (Status)) {
499 if (((Partition->PartitionType == EmmcPartitionUserData) ||
500 (Partition->PartitionType == EmmcPartitionBoot1) ||
501 (Partition->PartitionType == EmmcPartitionBoot2)) &&
502 ((Device->Csd.Ccc & BIT10) != 0))
504 Status =
gBS->InstallProtocolInterface (
506 &gEfiStorageSecurityCommandProtocolGuid,
508 &Partition->StorageSecurity
510 if (EFI_ERROR (Status)) {
511 gBS->UninstallMultipleProtocolInterfaces (
513 &gEfiDevicePathProtocolGuid,
514 Partition->DevicePath,
515 &gEfiBlockIoProtocolGuid,
517 &gEfiBlockIo2ProtocolGuid,
518 &Partition->BlockIo2,
519 &gEfiEraseBlockProtocolGuid,
520 &Partition->EraseBlock,
521 &gEfiDiskInfoProtocolGuid,
522 &Partition->DiskInfo,
530 Device->Private->Controller,
531 &gEfiSdMmcPassThruProtocolGuid,
532 (VOID **)&(Device->Private->PassThru),
533 Device->Private->DriverBindingHandle,
535 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
539 Status = EFI_INVALID_PARAMETER;
543 if (EFI_ERROR (Status) && (DevicePath !=
NULL)) {
585 NewDevicePath =
NULL;
586 RemainingDevicePath =
NULL;
587 PassThru = Private->PassThru;
588 Device = &Private->Device[Slot];
593 Status = PassThru->BuildDevicePath (
598 if (EFI_ERROR (Status)) {
603 Status = EFI_UNSUPPORTED;
608 Private->ParentDevicePath,
611 if (NewDevicePath ==
NULL) {
612 Status = EFI_OUT_OF_RESOURCES;
617 RemainingEmmcDevPath = NewDevicePath;
618 Status =
gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingEmmcDevPath, &DeviceHandle);
622 if (EFI_ERROR (Status) || (DeviceHandle ==
NULL) || !
IsDevicePathEnd (RemainingEmmcDevPath)) {
623 Device->DevicePath = NewDevicePath;
625 Device->Private = Private;
630 if (EFI_ERROR (Status)) {
635 Status =
gBS->InstallProtocolInterface (
637 &gEfiDevicePathProtocolGuid,
641 if (EFI_ERROR (Status)) {
646 Device->ControllerNameTable =
NULL;
651 &Device->ControllerNameTable,
658 &Device->ControllerNameTable,
664 if (RemainingDevicePath ==
NULL) {
668 for (Index = 0; Index < EMMC_MAX_PARTITIONS; Index++) {
680 Status = EFI_INVALID_PARAMETER;
685 if (Index >= EMMC_MAX_PARTITIONS) {
686 Status = EFI_INVALID_PARAMETER;
757 Status =
gBS->OpenProtocol (
759 &gEfiSdMmcPassThruProtocolGuid,
761 This->DriverBindingHandle,
763 EFI_OPEN_PROTOCOL_BY_DRIVER
766 if (Status == EFI_ALREADY_STARTED) {
770 if (EFI_ERROR (Status)) {
778 Status = PassThru->GetSlotNumber (PassThru, RemainingDevicePath, &Slot);
779 if (EFI_ERROR (Status)) {
785 &gEfiSdMmcPassThruProtocolGuid,
786 This->DriverBindingHandle,
798 &gEfiSdMmcPassThruProtocolGuid,
799 This->DriverBindingHandle,
806 Status =
gBS->OpenProtocol (
808 &gEfiDevicePathProtocolGuid,
809 (VOID **)&ParentDevicePath,
810 This->DriverBindingHandle,
812 EFI_OPEN_PROTOCOL_GET_PROTOCOL
868 Status =
gBS->OpenProtocol (
870 &gEfiSdMmcPassThruProtocolGuid,
872 This->DriverBindingHandle,
874 EFI_OPEN_PROTOCOL_BY_DRIVER
876 if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {
883 if (Status != EFI_ALREADY_STARTED) {
885 if (Private ==
NULL) {
886 Status = EFI_OUT_OF_RESOURCES;
890 Status =
gBS->OpenProtocol (
892 &gEfiDevicePathProtocolGuid,
893 (VOID **)&ParentDevicePath,
894 This->DriverBindingHandle,
896 EFI_OPEN_PROTOCOL_GET_PROTOCOL
899 Private->PassThru = PassThru;
900 Private->Controller = Controller;
901 Private->ParentDevicePath = ParentDevicePath;
902 Private->DriverBindingHandle = This->DriverBindingHandle;
904 Status =
gBS->InstallProtocolInterface (
910 if (EFI_ERROR (Status)) {
914 Status =
gBS->OpenProtocol (
918 This->DriverBindingHandle,
920 EFI_OPEN_PROTOCOL_GET_PROTOCOL
922 if (EFI_ERROR (Status)) {
927 if (RemainingDevicePath ==
NULL) {
930 Status = PassThru->GetNextSlot (PassThru, &Slot);
931 if (EFI_ERROR (Status)) {
940 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
945 Status = PassThru->GetSlotNumber (PassThru, RemainingDevicePath, &Slot);
946 if (!EFI_ERROR (Status)) {
952 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
955 &gEfiSdMmcPassThruProtocolGuid,
956 This->DriverBindingHandle,
960 if (Private !=
NULL) {
961 gBS->UninstallMultipleProtocolInterfaces (
1010 BOOLEAN AllChildrenStopped;
1025 if (NumberOfChildren == 0) {
1026 Status =
gBS->OpenProtocol (
1030 This->DriverBindingHandle,
1032 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1034 if (EFI_ERROR (Status)) {
1035 return EFI_DEVICE_ERROR;
1038 for (Index = 0; Index < EMMC_MAX_DEVICES; Index++) {
1039 Device = &Private->Device[Index];
1040 Status =
gBS->OpenProtocol (
1042 &gEfiDevicePathProtocolGuid,
1043 (VOID **)&DevicePath,
1044 This->DriverBindingHandle,
1046 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1048 if (EFI_ERROR (Status)) {
1052 ASSERT (DevicePath == Device->DevicePath);
1053 gBS->UninstallProtocolInterface (
1055 &gEfiDevicePathProtocolGuid,
1061 gBS->UninstallProtocolInterface (
1066 gBS->CloseProtocol (
1068 &gEfiSdMmcPassThruProtocolGuid,
1069 This->DriverBindingHandle,
1077 AllChildrenStopped =
TRUE;
1079 for (Index = 0; Index < NumberOfChildren; Index++) {
1080 Status =
gBS->OpenProtocol (
1081 ChildHandleBuffer[Index],
1082 &gEfiBlockIoProtocolGuid,
1084 This->DriverBindingHandle,
1086 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1088 if (EFI_ERROR (Status)) {
1089 Status =
gBS->OpenProtocol (
1090 ChildHandleBuffer[Index],
1091 &gEfiBlockIo2ProtocolGuid,
1093 This->DriverBindingHandle,
1095 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1097 if (EFI_ERROR (Status)) {
1098 AllChildrenStopped =
FALSE;
1103 if (BlockIo !=
NULL) {
1104 Partition = EMMC_PARTITION_DATA_FROM_BLKIO (BlockIo);
1106 ASSERT (BlockIo2 !=
NULL);
1107 Partition = EMMC_PARTITION_DATA_FROM_BLKIO2 (BlockIo2);
1111 !
IsNull (&Partition->Queue, Link);
1117 Request = EMMC_REQUEST_FROM_LINK (Link);
1119 gBS->CloseEvent (Request->Event);
1122 if (Request->IsEnd) {
1123 gBS->SignalEvent (Request->Token->
Event);
1132 Status =
gBS->CloseProtocol (
1134 &gEfiSdMmcPassThruProtocolGuid,
1135 This->DriverBindingHandle,
1136 ChildHandleBuffer[Index]
1139 Status =
gBS->UninstallMultipleProtocolInterfaces (
1140 ChildHandleBuffer[Index],
1141 &gEfiDevicePathProtocolGuid,
1142 Partition->DevicePath,
1143 &gEfiBlockIoProtocolGuid,
1144 &Partition->BlockIo,
1145 &gEfiBlockIo2ProtocolGuid,
1146 &Partition->BlockIo2,
1147 &gEfiEraseBlockProtocolGuid,
1148 &Partition->EraseBlock,
1149 &gEfiDiskInfoProtocolGuid,
1150 &Partition->DiskInfo,
1153 if (EFI_ERROR (Status)) {
1154 AllChildrenStopped =
FALSE;
1157 &gEfiSdMmcPassThruProtocolGuid,
1158 (VOID **)&Partition->Device->Private->PassThru,
1159 This->DriverBindingHandle,
1160 ChildHandleBuffer[Index],
1161 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1169 Status =
gBS->OpenProtocol (
1170 ChildHandleBuffer[Index],
1171 &gEfiStorageSecurityCommandProtocolGuid,
1172 (VOID **)&StorageSecurity,
1173 This->DriverBindingHandle,
1175 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1178 if (!EFI_ERROR (Status)) {
1179 Status =
gBS->UninstallProtocolInterface (
1180 ChildHandleBuffer[Index],
1181 &gEfiStorageSecurityCommandProtocolGuid,
1182 &Partition->StorageSecurity
1184 if (EFI_ERROR (Status)) {
1187 &gEfiSdMmcPassThruProtocolGuid,
1188 (VOID **)&Partition->Device->Private->PassThru,
1189 This->DriverBindingHandle,
1190 ChildHandleBuffer[Index],
1191 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1193 AllChildrenStopped =
FALSE;
1201 if (!AllChildrenStopped) {
1202 return EFI_DEVICE_ERROR;
1233 &gEmmcDxeDriverBinding,
1235 &gEmmcDxeComponentName,
1236 &gEmmcDxeComponentName2
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
RETURN_STATUS EFIAPI AsciiStrToUnicodeStrS(IN CONST CHAR8 *Source, OUT CHAR16 *Destination, IN UINTN DestMax)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define HARDWARE_DEVICE_PATH
UINT8 EFIAPI DevicePathType(IN CONST VOID *Node)
UINT16 EFIAPI SetDevicePathNodeLength(IN OUT VOID *Node, IN UINTN Length)
UINTN EFIAPI DevicePathNodeLength(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(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)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
#define EFI_DISK_INFO_SD_MMC_INTERFACE_GUID
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI EmmcSecurityProtocolIn(IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This, IN UINT32 MediaId, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, OUT VOID *PayloadBuffer, OUT UINTN *PayloadTransferSize)
EFI_STATUS EFIAPI EmmcWriteBlocks(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI EmmcResetEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
EFI_STATUS EFIAPI EmmcReadBlocksEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN OUT EFI_BLOCK_IO2_TOKEN *Token, IN UINTN BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI EmmcReadBlocks(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI EmmcWriteBlocksEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN OUT EFI_BLOCK_IO2_TOKEN *Token, IN UINTN BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI EmmcEraseBlocks(IN EFI_ERASE_BLOCK_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN OUT EFI_ERASE_BLOCK_TOKEN *Token, IN UINTN Size)
EFI_STATUS EFIAPI EmmcFlushBlocksEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN OUT EFI_BLOCK_IO2_TOKEN *Token)
EFI_STATUS EFIAPI EmmcSecurityProtocolOut(IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This, IN UINT32 MediaId, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, IN VOID *PayloadBuffer)
EFI_STATUS EmmcGetCid(IN EMMC_DEVICE *Device, IN UINT16 Rca, OUT EMMC_CID *Cid)
EFI_STATUS EFIAPI EmmcFlushBlocks(IN EFI_BLOCK_IO_PROTOCOL *This)
EFI_STATUS EmmcSendStatus(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, OUT UINT32 *DevStatus)
EFI_STATUS EmmcGetExtCsd(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, OUT EMMC_EXT_CSD *ExtCsd)
EFI_STATUS EmmcSelect(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca)
EFI_STATUS EmmcReset(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot)
EFI_STATUS EmmcGetCsd(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, OUT EMMC_CSD *Csd)
EFI_STATUS EFIAPI EmmcDiskInfoSenseData(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *SenseData, IN OUT UINT32 *SenseDataSize, OUT UINT8 *SenseDataNumber)
EFI_STATUS EFIAPI EmmcDiskInfoIdentify(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *IdentifyData, IN OUT UINT32 *IdentifyDataSize)
EFI_STATUS EFIAPI EmmcDiskInfoInquiry(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *InquiryData, IN OUT UINT32 *InquiryDataSize)
EFI_STATUS EFIAPI EmmcDiskInfoWhichIde(IN EFI_DISK_INFO_PROTOCOL *This, OUT UINT32 *IdeChannel, OUT UINT32 *IdeDevice)
EFI_STATUS InstallProtocolOnPartition(IN EMMC_DEVICE *Device, IN UINT8 Index)
EFI_STATUS EFIAPI DiscoverEmmcDevice(IN EMMC_DRIVER_PRIVATE_DATA *Private, IN UINT8 Slot, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI EmmcDxeDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS GetEmmcModelName(IN OUT EMMC_DEVICE *Device, IN EMMC_CID *Cid)
EFI_STATUS DiscoverAllPartitions(IN EMMC_DEVICE *Device)
EFI_STATUS DumpCsd(IN EMMC_CSD *Csd)
EFI_STATUS DumpExtCsd(IN EMMC_EXT_CSD *ExtCsd)
EFI_STATUS EFIAPI EmmcDxeDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI EmmcDxeDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI InitializeEmmcDxe(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
EFI_STATUS EFIAPI AddUnicodeString2(IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable, IN CONST CHAR16 *UnicodeString, IN BOOLEAN Iso639Language)
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
EFI_BLOCK_IO_MEDIA * Media
CHAR8 * SupportedLanguages
CHAR8 * SupportedLanguages
EFI_STATUS TransactionStatus