TianoCore EDK2 master
Loading...
Searching...
No Matches
EmmcDxe.c
Go to the documentation of this file.
1
12#include "EmmcDxe.h"
13
14//
15// EmmcDxe Driver Binding Protocol Instance
16//
17EFI_DRIVER_BINDING_PROTOCOL gEmmcDxeDriverBinding = {
21 0x10,
22 NULL,
23 NULL
24};
25
26//
27// Template for Emmc Partitions.
28//
29EMMC_PARTITION mEmmcPartitionTemplate = {
30 EMMC_PARTITION_SIGNATURE, // Signature
31 FALSE, // Enable
32 EmmcPartitionUnknown, // PartitionType
33 NULL, // Handle
34 NULL, // DevicePath
35 { // BlockIo
36 EFI_BLOCK_IO_PROTOCOL_REVISION,
37 NULL,
42 },
43 { // BlockIo2
44 NULL,
49 },
50 { // BlockMedia
51 0, // MediaId
52 FALSE, // RemovableMedia
53 TRUE, // MediaPresent
54 FALSE, // LogicPartition
55 FALSE, // ReadOnly
56 FALSE, // WritingCache
57 0x200, // BlockSize
58 0, // IoAlign
59 0 // LastBlock
60 },
61 { // StorageSecurity
64 },
65 { // EraseBlock
66 EFI_ERASE_BLOCK_PROTOCOL_REVISION,
67 1,
69 },
70 { // DiskInfo
76 },
77 {
78 NULL,
79 NULL
80 },
81 NULL // Device
82};
83
93 IN EMMC_CSD *Csd
94 )
95{
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));
129
130 return EFI_SUCCESS;
131}
132
142 IN EMMC_EXT_CSD *ExtCsd
143 )
144{
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));
188 DEBUG ((
189 DEBUG_INFO,
190 " Max Enhanced Area Size 0x%02x%02x%02x\n", \
191 ExtCsd->MaxEnhSizeMult[2],
192 ExtCsd->MaxEnhSizeMult[1],
193 ExtCsd->MaxEnhSizeMult[0]
194 ));
195 DEBUG ((DEBUG_INFO, " Partitions attribute 0x%x\n", ExtCsd->PartitionsAttribute));
196 DEBUG ((DEBUG_INFO, " Partitioning Setting 0x%x\n", ExtCsd->PartitionSettingCompleted));
197 DEBUG ((
198 DEBUG_INFO,
199 " General Purpose Partition 1 Size 0x%02x%02x%02x\n", \
200 ExtCsd->GpSizeMult[2],
201 ExtCsd->GpSizeMult[1],
202 ExtCsd->GpSizeMult[0]
203 ));
204 DEBUG ((
205 DEBUG_INFO,
206 " General Purpose Partition 2 Size 0x%02x%02x%02x\n", \
207 ExtCsd->GpSizeMult[5],
208 ExtCsd->GpSizeMult[4],
209 ExtCsd->GpSizeMult[3]
210 ));
211 DEBUG ((
212 DEBUG_INFO,
213 " General Purpose Partition 3 Size 0x%02x%02x%02x\n", \
214 ExtCsd->GpSizeMult[8],
215 ExtCsd->GpSizeMult[7],
216 ExtCsd->GpSizeMult[6]
217 ));
218 DEBUG ((
219 DEBUG_INFO,
220 " General Purpose Partition 4 Size 0x%02x%02x%02x\n", \
221 ExtCsd->GpSizeMult[11],
222 ExtCsd->GpSizeMult[10],
223 ExtCsd->GpSizeMult[9]
224 ));
225 DEBUG ((
226 DEBUG_INFO,
227 " Enhanced User Data Area Size 0x%02x%02x%02x\n", \
228 ExtCsd->EnhSizeMult[2],
229 ExtCsd->EnhSizeMult[1],
230 ExtCsd->EnhSizeMult[0]
231 ));
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));
237
238 return EFI_SUCCESS;
239}
240
252 IN OUT EMMC_DEVICE *Device,
253 IN EMMC_CID *Cid
254 )
255{
256 CHAR8 String[EMMC_MODEL_NAME_MAX_LEN];
257
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));
264
265 AsciiStrToUnicodeStrS (String, Device->ModelName, sizeof (Device->ModelName) / sizeof (Device->ModelName[0]));
266
267 return EFI_SUCCESS;
268}
269
281 IN EMMC_DEVICE *Device
282 )
283{
284 EFI_STATUS Status;
285 EMMC_PARTITION *Partition;
286 EMMC_CSD *Csd;
287 EMMC_CID *Cid;
288 EMMC_EXT_CSD *ExtCsd;
289 UINT8 Slot;
290 UINT64 Capacity;
291 UINT32 DevStatus;
292 UINT8 Index;
293 UINT32 SecCount;
294 UINT32 GpSizeMult;
295
296 Slot = Device->Slot;
297
298 Status = EmmcSendStatus (Device, Slot + 1, &DevStatus);
299 if (EFI_ERROR (Status)) {
300 return Status;
301 }
302
303 //
304 // Deselect the device to force it enter stby mode before getting CSD
305 // register content.
306 // Note here we don't judge return status as some EMMC devices return
307 // error but the state has been stby.
308 //
309 EmmcSelect (Device, 0);
310
311 Status = EmmcSendStatus (Device, Slot + 1, &DevStatus);
312 if (EFI_ERROR (Status)) {
313 return Status;
314 }
315
316 Csd = &Device->Csd;
317 Status = EmmcGetCsd (Device, Slot + 1, Csd);
318 if (EFI_ERROR (Status)) {
319 return Status;
320 }
321
322 DumpCsd (Csd);
323
324 if ((Csd->CSizeLow | Csd->CSizeHigh << 2) == 0xFFF) {
325 Device->SectorAddressing = TRUE;
326 } else {
327 Device->SectorAddressing = FALSE;
328 }
329
330 Cid = &Device->Cid;
331 Status = EmmcGetCid (Device, Slot + 1, Cid);
332 if (EFI_ERROR (Status)) {
333 return Status;
334 }
335
336 Status = EmmcSelect (Device, Slot + 1);
337 if (EFI_ERROR (Status)) {
338 return Status;
339 }
340
341 ExtCsd = &Device->ExtCsd;
342 Status = EmmcGetExtCsd (Device, ExtCsd);
343 if (EFI_ERROR (Status)) {
344 return Status;
345 }
346
347 DumpExtCsd (ExtCsd);
348
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;
352 }
353
354 if ((ExtCsd->PartitioningSupport & BIT0) != BIT0) {
355 DEBUG ((DEBUG_ERROR, "The EMMC device doesn't support Partition Feature!!!\n"));
356 return EFI_UNSUPPORTED;
357 }
358
359 for (Index = 0; Index < EMMC_MAX_PARTITIONS; Index++) {
360 Partition = &Device->Partition[Index];
361 CopyMem (Partition, &mEmmcPartitionTemplate, sizeof (EMMC_PARTITION));
362 Partition->Device = Device;
363 InitializeListHead (&Partition->Queue);
364 Partition->BlockIo.Media = &Partition->BlockMedia;
365 Partition->BlockIo2.Media = &Partition->BlockMedia;
366 Partition->PartitionType = Index;
367 Partition->BlockMedia.IoAlign = Device->Private->PassThru->IoAlign;
368 Partition->BlockMedia.BlockSize = 0x200;
369 Partition->BlockMedia.LastBlock = 0x00;
370 Partition->BlockMedia.RemovableMedia = FALSE;
371 Partition->BlockMedia.MediaPresent = TRUE;
372 Partition->BlockMedia.LogicalPartition = FALSE;
373
374 switch (Index) {
375 case EmmcPartitionUserData:
376 SecCount = *(UINT32 *)&ExtCsd->SecCount;
377 Capacity = MultU64x32 ((UINT64)SecCount, 0x200);
378 break;
379 case EmmcPartitionBoot1:
380 case EmmcPartitionBoot2:
381 Capacity = ExtCsd->BootSizeMult * SIZE_128KB;
382 break;
383 case EmmcPartitionRPMB:
384 Capacity = ExtCsd->RpmbSizeMult * SIZE_128KB;
385 break;
386 case EmmcPartitionGP1:
387 GpSizeMult = (UINT32)(ExtCsd->GpSizeMult[0] | (ExtCsd->GpSizeMult[1] << 8) | (ExtCsd->GpSizeMult[2] << 16));
388 Capacity = MultU64x32 (MultU64x32 (MultU64x32 ((UINT64)GpSizeMult, ExtCsd->HcWpGrpSize), ExtCsd->HcEraseGrpSize), SIZE_512KB);
389 break;
390 case EmmcPartitionGP2:
391 GpSizeMult = (UINT32)(ExtCsd->GpSizeMult[3] | (ExtCsd->GpSizeMult[4] << 8) | (ExtCsd->GpSizeMult[5] << 16));
392 Capacity = MultU64x32 (MultU64x32 (MultU64x32 ((UINT64)GpSizeMult, ExtCsd->HcWpGrpSize), ExtCsd->HcEraseGrpSize), SIZE_512KB);
393 break;
394 case EmmcPartitionGP3:
395 GpSizeMult = (UINT32)(ExtCsd->GpSizeMult[6] | (ExtCsd->GpSizeMult[7] << 8) | (ExtCsd->GpSizeMult[8] << 16));
396 Capacity = MultU64x32 (MultU64x32 (MultU64x32 ((UINT64)GpSizeMult, ExtCsd->HcWpGrpSize), ExtCsd->HcEraseGrpSize), SIZE_512KB);
397 break;
398 case EmmcPartitionGP4:
399 GpSizeMult = (UINT32)(ExtCsd->GpSizeMult[9] | (ExtCsd->GpSizeMult[10] << 8) | (ExtCsd->GpSizeMult[11] << 16));
400 Capacity = MultU64x32 (MultU64x32 (MultU64x32 ((UINT64)GpSizeMult, ExtCsd->HcWpGrpSize), ExtCsd->HcEraseGrpSize), SIZE_512KB);
401 break;
402 default:
403 ASSERT (FALSE);
404 return EFI_INVALID_PARAMETER;
405 }
406
407 if (Capacity != 0) {
408 Partition->Enable = TRUE;
409 Partition->BlockMedia.LastBlock = DivU64x32 (Capacity, Partition->BlockMedia.BlockSize) - 1;
410 }
411
412 if ((ExtCsd->EraseGroupDef & BIT0) == 0) {
413 if (Csd->WriteBlLen < 9) {
414 Partition->EraseBlock.EraseLengthGranularity = 1;
415 } else {
416 Partition->EraseBlock.EraseLengthGranularity = (Csd->EraseGrpMult + 1) * (Csd->EraseGrpSize + 1) * (1 << (Csd->WriteBlLen - 9));
417 }
418 } else {
419 Partition->EraseBlock.EraseLengthGranularity = 1024 * ExtCsd->HcEraseGrpSize;
420 }
421 }
422
423 return EFI_SUCCESS;
424}
425
438 IN EMMC_DEVICE *Device,
439 IN UINT8 Index
440 )
441{
442 EFI_STATUS Status;
443 EMMC_PARTITION *Partition;
444 CONTROLLER_DEVICE_PATH ControlNode;
445 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
446 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
447 EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
448 EFI_HANDLE DeviceHandle;
449
450 //
451 // Build device path
452 //
453 ParentDevicePath = Device->DevicePath;
454
455 ControlNode.Header.Type = HARDWARE_DEVICE_PATH;
456 ControlNode.Header.SubType = HW_CONTROLLER_DP;
457 SetDevicePathNodeLength (&ControlNode.Header, sizeof (CONTROLLER_DEVICE_PATH));
458 ControlNode.ControllerNumber = Index;
459
460 DevicePath = AppendDevicePathNode (ParentDevicePath, (EFI_DEVICE_PATH_PROTOCOL *)&ControlNode);
461 if (DevicePath == NULL) {
462 Status = EFI_OUT_OF_RESOURCES;
463 goto Error;
464 }
465
466 DeviceHandle = NULL;
467 RemainingDevicePath = DevicePath;
468 Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &DeviceHandle);
469 if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd (RemainingDevicePath)) {
470 Status = EFI_ALREADY_STARTED;
471 goto Error;
472 }
473
474 Partition = &Device->Partition[Index];
475 Partition->DevicePath = DevicePath;
476 if (Partition->Enable) {
477 //
478 // Install BlkIo/BlkIo2/Ssp for the specified partition
479 //
480 if (Partition->PartitionType != EmmcPartitionRPMB) {
481 Status = gBS->InstallMultipleProtocolInterfaces (
482 &Partition->Handle,
483 &gEfiDevicePathProtocolGuid,
484 Partition->DevicePath,
485 &gEfiBlockIoProtocolGuid,
486 &Partition->BlockIo,
487 &gEfiBlockIo2ProtocolGuid,
488 &Partition->BlockIo2,
489 &gEfiEraseBlockProtocolGuid,
490 &Partition->EraseBlock,
491 &gEfiDiskInfoProtocolGuid,
492 &Partition->DiskInfo,
493 NULL
494 );
495 if (EFI_ERROR (Status)) {
496 goto Error;
497 }
498
499 if (((Partition->PartitionType == EmmcPartitionUserData) ||
500 (Partition->PartitionType == EmmcPartitionBoot1) ||
501 (Partition->PartitionType == EmmcPartitionBoot2)) &&
502 ((Device->Csd.Ccc & BIT10) != 0))
503 {
504 Status = gBS->InstallProtocolInterface (
505 &Partition->Handle,
506 &gEfiStorageSecurityCommandProtocolGuid,
508 &Partition->StorageSecurity
509 );
510 if (EFI_ERROR (Status)) {
511 gBS->UninstallMultipleProtocolInterfaces (
512 Partition->Handle,
513 &gEfiDevicePathProtocolGuid,
514 Partition->DevicePath,
515 &gEfiBlockIoProtocolGuid,
516 &Partition->BlockIo,
517 &gEfiBlockIo2ProtocolGuid,
518 &Partition->BlockIo2,
519 &gEfiEraseBlockProtocolGuid,
520 &Partition->EraseBlock,
521 &gEfiDiskInfoProtocolGuid,
522 &Partition->DiskInfo,
523 NULL
524 );
525 goto Error;
526 }
527 }
528
529 gBS->OpenProtocol (
530 Device->Private->Controller,
531 &gEfiSdMmcPassThruProtocolGuid,
532 (VOID **)&(Device->Private->PassThru),
533 Device->Private->DriverBindingHandle,
534 Partition->Handle,
535 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
536 );
537 }
538 } else {
539 Status = EFI_INVALID_PARAMETER;
540 }
541
542Error:
543 if (EFI_ERROR (Status) && (DevicePath != NULL)) {
544 FreePool (DevicePath);
545 }
546
547 return Status;
548}
549
566EFIAPI
569 IN UINT8 Slot,
570 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
571 )
572{
573 EFI_STATUS Status;
574 EMMC_DEVICE *Device;
575 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
576 EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
577 EFI_DEVICE_PATH_PROTOCOL *RemainingEmmcDevPath;
578 EFI_DEV_PATH *Node;
579 EFI_HANDLE DeviceHandle;
581 UINT8 Index;
582
583 Device = NULL;
584 DevicePath = NULL;
585 NewDevicePath = NULL;
586 RemainingDevicePath = NULL;
587 PassThru = Private->PassThru;
588 Device = &Private->Device[Slot];
589
590 //
591 // Build Device Path to check if the EMMC device present at the slot.
592 //
593 Status = PassThru->BuildDevicePath (
594 PassThru,
595 Slot,
596 &DevicePath
597 );
598 if (EFI_ERROR (Status)) {
599 return Status;
600 }
601
602 if (DevicePath->SubType != MSG_EMMC_DP) {
603 Status = EFI_UNSUPPORTED;
604 goto Error;
605 }
606
607 NewDevicePath = AppendDevicePathNode (
608 Private->ParentDevicePath,
609 DevicePath
610 );
611 if (NewDevicePath == NULL) {
612 Status = EFI_OUT_OF_RESOURCES;
613 goto Error;
614 }
615
616 DeviceHandle = NULL;
617 RemainingEmmcDevPath = NewDevicePath;
618 Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingEmmcDevPath, &DeviceHandle);
619 //
620 // The device path to the EMMC device doesn't exist. It means the corresponding device private data hasn't been initialized.
621 //
622 if (EFI_ERROR (Status) || (DeviceHandle == NULL) || !IsDevicePathEnd (RemainingEmmcDevPath)) {
623 Device->DevicePath = NewDevicePath;
624 Device->Slot = Slot;
625 Device->Private = Private;
626 //
627 // Expose user area in the Sd memory card to upper layer.
628 //
629 Status = DiscoverAllPartitions (Device);
630 if (EFI_ERROR (Status)) {
631 FreePool (NewDevicePath);
632 goto Error;
633 }
634
635 Status = gBS->InstallProtocolInterface (
636 &Device->Handle,
637 &gEfiDevicePathProtocolGuid,
639 Device->DevicePath
640 );
641 if (EFI_ERROR (Status)) {
642 FreePool (NewDevicePath);
643 goto Error;
644 }
645
646 Device->ControllerNameTable = NULL;
647 GetEmmcModelName (Device, &Device->Cid);
649 "eng",
650 gEmmcDxeComponentName.SupportedLanguages,
651 &Device->ControllerNameTable,
652 Device->ModelName,
653 TRUE
654 );
656 "en",
657 gEmmcDxeComponentName2.SupportedLanguages,
658 &Device->ControllerNameTable,
659 Device->ModelName,
660 FALSE
661 );
662 }
663
664 if (RemainingDevicePath == NULL) {
665 //
666 // Expose all partitions in the Emmc device to upper layer.
667 //
668 for (Index = 0; Index < EMMC_MAX_PARTITIONS; Index++) {
669 InstallProtocolOnPartition (Device, Index);
670 }
671 } else if (!IsDevicePathEnd (RemainingDevicePath)) {
672 //
673 // Enumerate the specified partition
674 //
675 Node = (EFI_DEV_PATH *)RemainingDevicePath;
676 if ((DevicePathType (&Node->DevPath) != HARDWARE_DEVICE_PATH) ||
677 (DevicePathSubType (&Node->DevPath) != HW_CONTROLLER_DP) ||
678 (DevicePathNodeLength (&Node->DevPath) != sizeof (CONTROLLER_DEVICE_PATH)))
679 {
680 Status = EFI_INVALID_PARAMETER;
681 goto Error;
682 }
683
684 Index = (UINT8)Node->Controller.ControllerNumber;
685 if (Index >= EMMC_MAX_PARTITIONS) {
686 Status = EFI_INVALID_PARAMETER;
687 goto Error;
688 }
689
690 Status = InstallProtocolOnPartition (Device, Index);
691 }
692
693Error:
694 FreePool (DevicePath);
695
696 return Status;
697}
698
742EFIAPI
745 IN EFI_HANDLE Controller,
746 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
747 )
748{
749 EFI_STATUS Status;
750 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
752 UINT8 Slot;
753
754 //
755 // Test EFI_SD_MMC_PASS_THRU_PROTOCOL on the controller handle.
756 //
757 Status = gBS->OpenProtocol (
758 Controller,
759 &gEfiSdMmcPassThruProtocolGuid,
760 (VOID **)&PassThru,
761 This->DriverBindingHandle,
762 Controller,
763 EFI_OPEN_PROTOCOL_BY_DRIVER
764 );
765
766 if (Status == EFI_ALREADY_STARTED) {
767 return EFI_SUCCESS;
768 }
769
770 if (EFI_ERROR (Status)) {
771 return Status;
772 }
773
774 //
775 // Test RemainingDevicePath is valid or not.
776 //
777 if ((RemainingDevicePath != NULL) && !IsDevicePathEnd (RemainingDevicePath)) {
778 Status = PassThru->GetSlotNumber (PassThru, RemainingDevicePath, &Slot);
779 if (EFI_ERROR (Status)) {
780 //
781 // Close the I/O Abstraction(s) used to perform the supported test
782 //
783 gBS->CloseProtocol (
784 Controller,
785 &gEfiSdMmcPassThruProtocolGuid,
786 This->DriverBindingHandle,
787 Controller
788 );
789 return Status;
790 }
791 }
792
793 //
794 // Close the I/O Abstraction(s) used to perform the supported test
795 //
796 gBS->CloseProtocol (
797 Controller,
798 &gEfiSdMmcPassThruProtocolGuid,
799 This->DriverBindingHandle,
800 Controller
801 );
802
803 //
804 // Open the EFI Device Path protocol needed to perform the supported test
805 //
806 Status = gBS->OpenProtocol (
807 Controller,
808 &gEfiDevicePathProtocolGuid,
809 (VOID **)&ParentDevicePath,
810 This->DriverBindingHandle,
811 Controller,
812 EFI_OPEN_PROTOCOL_GET_PROTOCOL
813 );
814 return Status;
815}
816
853EFIAPI
856 IN EFI_HANDLE Controller,
857 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
858 )
859{
860 EFI_STATUS Status;
862 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
864 UINT8 Slot;
865
866 Private = NULL;
867 PassThru = NULL;
868 Status = gBS->OpenProtocol (
869 Controller,
870 &gEfiSdMmcPassThruProtocolGuid,
871 (VOID **)&PassThru,
872 This->DriverBindingHandle,
873 Controller,
874 EFI_OPEN_PROTOCOL_BY_DRIVER
875 );
876 if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {
877 return Status;
878 }
879
880 //
881 // Check EFI_ALREADY_STARTED to reuse the original EMMC_DRIVER_PRIVATE_DATA.
882 //
883 if (Status != EFI_ALREADY_STARTED) {
884 Private = AllocateZeroPool (sizeof (EMMC_DRIVER_PRIVATE_DATA));
885 if (Private == NULL) {
886 Status = EFI_OUT_OF_RESOURCES;
887 goto Error;
888 }
889
890 Status = gBS->OpenProtocol (
891 Controller,
892 &gEfiDevicePathProtocolGuid,
893 (VOID **)&ParentDevicePath,
894 This->DriverBindingHandle,
895 Controller,
896 EFI_OPEN_PROTOCOL_GET_PROTOCOL
897 );
898 ASSERT_EFI_ERROR (Status);
899 Private->PassThru = PassThru;
900 Private->Controller = Controller;
901 Private->ParentDevicePath = ParentDevicePath;
902 Private->DriverBindingHandle = This->DriverBindingHandle;
903
904 Status = gBS->InstallProtocolInterface (
905 &Controller,
906 &gEfiCallerIdGuid,
908 Private
909 );
910 if (EFI_ERROR (Status)) {
911 goto Error;
912 }
913 } else {
914 Status = gBS->OpenProtocol (
915 Controller,
916 &gEfiCallerIdGuid,
917 (VOID **)&Private,
918 This->DriverBindingHandle,
919 Controller,
920 EFI_OPEN_PROTOCOL_GET_PROTOCOL
921 );
922 if (EFI_ERROR (Status)) {
923 goto Error;
924 }
925 }
926
927 if (RemainingDevicePath == NULL) {
928 Slot = 0xFF;
929 while (TRUE) {
930 Status = PassThru->GetNextSlot (PassThru, &Slot);
931 if (EFI_ERROR (Status)) {
932 //
933 // Cannot find more legal slots.
934 //
935 Status = EFI_SUCCESS;
936 break;
937 }
938
939 Status = DiscoverEmmcDevice (Private, Slot, NULL);
940 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
941 break;
942 }
943 }
944 } else if (!IsDevicePathEnd (RemainingDevicePath)) {
945 Status = PassThru->GetSlotNumber (PassThru, RemainingDevicePath, &Slot);
946 if (!EFI_ERROR (Status)) {
947 Status = DiscoverEmmcDevice (Private, Slot, NextDevicePathNode (RemainingDevicePath));
948 }
949 }
950
951Error:
952 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
953 gBS->CloseProtocol (
954 Controller,
955 &gEfiSdMmcPassThruProtocolGuid,
956 This->DriverBindingHandle,
957 Controller
958 );
959
960 if (Private != NULL) {
961 gBS->UninstallMultipleProtocolInterfaces (
962 Controller,
963 &gEfiCallerIdGuid,
964 Private,
965 NULL
966 );
967 FreePool (Private);
968 }
969 }
970
971 return Status;
972}
973
1001EFIAPI
1004 IN EFI_HANDLE Controller,
1005 IN UINTN NumberOfChildren,
1006 IN EFI_HANDLE *ChildHandleBuffer
1007 )
1008{
1009 EFI_STATUS Status;
1010 BOOLEAN AllChildrenStopped;
1011 UINTN Index;
1012 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
1013 EMMC_DRIVER_PRIVATE_DATA *Private;
1014 EMMC_DEVICE *Device;
1015 EMMC_PARTITION *Partition;
1016 EFI_BLOCK_IO_PROTOCOL *BlockIo;
1017 EFI_BLOCK_IO2_PROTOCOL *BlockIo2;
1019 LIST_ENTRY *Link;
1020 LIST_ENTRY *NextLink;
1021 EMMC_REQUEST *Request;
1022
1023 BlockIo = NULL;
1024 BlockIo2 = NULL;
1025 if (NumberOfChildren == 0) {
1026 Status = gBS->OpenProtocol (
1027 Controller,
1028 &gEfiCallerIdGuid,
1029 (VOID **)&Private,
1030 This->DriverBindingHandle,
1031 Controller,
1032 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1033 );
1034 if (EFI_ERROR (Status)) {
1035 return EFI_DEVICE_ERROR;
1036 }
1037
1038 for (Index = 0; Index < EMMC_MAX_DEVICES; Index++) {
1039 Device = &Private->Device[Index];
1040 Status = gBS->OpenProtocol (
1041 Device->Handle,
1042 &gEfiDevicePathProtocolGuid,
1043 (VOID **)&DevicePath,
1044 This->DriverBindingHandle,
1045 Controller,
1046 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1047 );
1048 if (EFI_ERROR (Status)) {
1049 continue;
1050 }
1051
1052 ASSERT (DevicePath == Device->DevicePath);
1053 gBS->UninstallProtocolInterface (
1054 Device->Handle,
1055 &gEfiDevicePathProtocolGuid,
1056 DevicePath
1057 );
1058 FreePool (Device->DevicePath);
1059 }
1060
1061 gBS->UninstallProtocolInterface (
1062 Controller,
1063 &gEfiCallerIdGuid,
1064 Private
1065 );
1066 gBS->CloseProtocol (
1067 Controller,
1068 &gEfiSdMmcPassThruProtocolGuid,
1069 This->DriverBindingHandle,
1070 Controller
1071 );
1072 FreePool (Private);
1073
1074 return EFI_SUCCESS;
1075 }
1076
1077 AllChildrenStopped = TRUE;
1078
1079 for (Index = 0; Index < NumberOfChildren; Index++) {
1080 Status = gBS->OpenProtocol (
1081 ChildHandleBuffer[Index],
1082 &gEfiBlockIoProtocolGuid,
1083 (VOID **)&BlockIo,
1084 This->DriverBindingHandle,
1085 Controller,
1086 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1087 );
1088 if (EFI_ERROR (Status)) {
1089 Status = gBS->OpenProtocol (
1090 ChildHandleBuffer[Index],
1091 &gEfiBlockIo2ProtocolGuid,
1092 (VOID **)&BlockIo2,
1093 This->DriverBindingHandle,
1094 Controller,
1095 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1096 );
1097 if (EFI_ERROR (Status)) {
1098 AllChildrenStopped = FALSE;
1099 continue;
1100 }
1101 }
1102
1103 if (BlockIo != NULL) {
1104 Partition = EMMC_PARTITION_DATA_FROM_BLKIO (BlockIo);
1105 } else {
1106 ASSERT (BlockIo2 != NULL);
1107 Partition = EMMC_PARTITION_DATA_FROM_BLKIO2 (BlockIo2);
1108 }
1109
1110 for (Link = GetFirstNode (&Partition->Queue);
1111 !IsNull (&Partition->Queue, Link);
1112 Link = NextLink)
1113 {
1114 NextLink = GetNextNode (&Partition->Queue, Link);
1115
1116 RemoveEntryList (Link);
1117 Request = EMMC_REQUEST_FROM_LINK (Link);
1118
1119 gBS->CloseEvent (Request->Event);
1120 Request->Token->TransactionStatus = EFI_ABORTED;
1121
1122 if (Request->IsEnd) {
1123 gBS->SignalEvent (Request->Token->Event);
1124 }
1125
1126 FreePool (Request);
1127 }
1128
1129 //
1130 // Close the child handle
1131 //
1132 Status = gBS->CloseProtocol (
1133 Controller,
1134 &gEfiSdMmcPassThruProtocolGuid,
1135 This->DriverBindingHandle,
1136 ChildHandleBuffer[Index]
1137 );
1138
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,
1151 NULL
1152 );
1153 if (EFI_ERROR (Status)) {
1154 AllChildrenStopped = FALSE;
1155 gBS->OpenProtocol (
1156 Controller,
1157 &gEfiSdMmcPassThruProtocolGuid,
1158 (VOID **)&Partition->Device->Private->PassThru,
1159 This->DriverBindingHandle,
1160 ChildHandleBuffer[Index],
1161 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1162 );
1163 continue;
1164 }
1165
1166 //
1167 // If Storage Security Command Protocol is installed, then uninstall this protocol.
1168 //
1169 Status = gBS->OpenProtocol (
1170 ChildHandleBuffer[Index],
1171 &gEfiStorageSecurityCommandProtocolGuid,
1172 (VOID **)&StorageSecurity,
1173 This->DriverBindingHandle,
1174 Controller,
1175 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1176 );
1177
1178 if (!EFI_ERROR (Status)) {
1179 Status = gBS->UninstallProtocolInterface (
1180 ChildHandleBuffer[Index],
1181 &gEfiStorageSecurityCommandProtocolGuid,
1182 &Partition->StorageSecurity
1183 );
1184 if (EFI_ERROR (Status)) {
1185 gBS->OpenProtocol (
1186 Controller,
1187 &gEfiSdMmcPassThruProtocolGuid,
1188 (VOID **)&Partition->Device->Private->PassThru,
1189 This->DriverBindingHandle,
1190 ChildHandleBuffer[Index],
1191 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
1192 );
1193 AllChildrenStopped = FALSE;
1194 continue;
1195 }
1196 }
1197
1198 FreePool (Partition->DevicePath);
1199 }
1200
1201 if (!AllChildrenStopped) {
1202 return EFI_DEVICE_ERROR;
1203 }
1204
1205 return EFI_SUCCESS;
1206}
1207
1219EFIAPI
1221 IN EFI_HANDLE ImageHandle,
1222 IN EFI_SYSTEM_TABLE *SystemTable
1223 )
1224{
1225 EFI_STATUS Status;
1226
1227 //
1228 // Install driver model protocol(s).
1229 //
1231 ImageHandle,
1232 SystemTable,
1233 &gEmmcDxeDriverBinding,
1234 ImageHandle,
1235 &gEmmcDxeComponentName,
1236 &gEmmcDxeComponentName2
1237 );
1238 ASSERT_EFI_ERROR (Status);
1239
1240 return Status;
1241}
UINT64 UINTN
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:443
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:333
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
Definition: DivU64x32.c:29
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
Definition: LinkedList.c:298
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
Definition: MultU64x32.c:27
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
RETURN_STATUS EFIAPI AsciiStrToUnicodeStrS(IN CONST CHAR8 *Source, OUT CHAR16 *Destination, IN UINTN DestMax)
Definition: SafeString.c:2873
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
Definition: DevicePath.h:68
#define MSG_EMMC_DP
Definition: DevicePath.h:916
#define HW_CONTROLLER_DP
Definition: DevicePath.h:154
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
Definition: DiskInfo.h:81
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)
Definition: EmmcBlockIo.c:1496
EFI_STATUS EFIAPI EmmcWriteBlocks(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, IN VOID *Buffer)
Definition: EmmcBlockIo.c:1024
EFI_STATUS EFIAPI EmmcResetEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
Definition: EmmcBlockIo.c:1076
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)
Definition: EmmcBlockIo.c:1142
EFI_STATUS EFIAPI EmmcReadBlocks(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
Definition: EmmcBlockIo.c:985
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)
Definition: EmmcBlockIo.c:1184
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)
Definition: EmmcBlockIo.c:2010
EFI_STATUS EFIAPI EmmcFlushBlocksEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN OUT EFI_BLOCK_IO2_TOKEN *Token)
Definition: EmmcBlockIo.c:1215
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)
Definition: EmmcBlockIo.c:1593
EFI_STATUS EmmcGetCid(IN EMMC_DEVICE *Device, IN UINT16 Rca, OUT EMMC_CID *Cid)
Definition: EmmcBlockIo.c:213
EFI_STATUS EFIAPI EmmcFlushBlocks(IN EFI_BLOCK_IO_PROTOCOL *This)
Definition: EmmcBlockIo.c:1053
EFI_STATUS EmmcSendStatus(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, OUT UINT32 *DevStatus)
Definition: EmmcDevice.c:399
EFI_STATUS EmmcGetExtCsd(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, OUT EMMC_EXT_CSD *ExtCsd)
Definition: EmmcDevice.c:303
EFI_STATUS EmmcSelect(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca)
Definition: EmmcDevice.c:260
EFI_STATUS EmmcReset(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot)
Definition: EmmcDevice.c:26
EFI_STATUS EmmcGetCsd(IN EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru, IN UINT8 Slot, IN UINT16 Rca, OUT EMMC_CSD *Csd)
Definition: EmmcDevice.c:210
EFI_STATUS EFIAPI EmmcDiskInfoSenseData(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *SenseData, IN OUT UINT32 *SenseDataSize, OUT UINT8 *SenseDataNumber)
Definition: EmmcDiskInfo.c:102
EFI_STATUS EFIAPI EmmcDiskInfoIdentify(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *IdentifyData, IN OUT UINT32 *IdentifyDataSize)
Definition: EmmcDiskInfo.c:74
EFI_STATUS EFIAPI EmmcDiskInfoInquiry(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *InquiryData, IN OUT UINT32 *InquiryDataSize)
Definition: EmmcDiskInfo.c:29
EFI_STATUS EFIAPI EmmcDiskInfoWhichIde(IN EFI_DISK_INFO_PROTOCOL *This, OUT UINT32 *IdeChannel, OUT UINT32 *IdeDevice)
Definition: EmmcDiskInfo.c:127
EFI_STATUS InstallProtocolOnPartition(IN EMMC_DEVICE *Device, IN UINT8 Index)
Definition: EmmcDxe.c:437
EFI_STATUS EFIAPI DiscoverEmmcDevice(IN EMMC_DRIVER_PRIVATE_DATA *Private, IN UINT8 Slot, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: EmmcDxe.c:567
EFI_STATUS EFIAPI EmmcDxeDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: EmmcDxe.c:1002
EFI_STATUS GetEmmcModelName(IN OUT EMMC_DEVICE *Device, IN EMMC_CID *Cid)
Definition: EmmcDxe.c:251
EFI_STATUS DiscoverAllPartitions(IN EMMC_DEVICE *Device)
Definition: EmmcDxe.c:280
EFI_STATUS DumpCsd(IN EMMC_CSD *Csd)
Definition: EmmcDxe.c:92
EFI_STATUS DumpExtCsd(IN EMMC_EXT_CSD *ExtCsd)
Definition: EmmcDxe.c:141
EFI_STATUS EFIAPI EmmcDxeDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: EmmcDxe.c:743
EFI_STATUS EFIAPI EmmcDxeDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: EmmcDxe.c:854
EFI_STATUS EFIAPI InitializeEmmcDxe(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: EmmcDxe.c:1220
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
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)
Definition: UefiLib.c:1087
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_NATIVE_INTERFACE
Definition: UefiSpec.h:1193
EFI_BLOCK_IO_MEDIA * Media
Definition: BlockIo2.h:187
EFI_BLOCK_IO_MEDIA * Media
Definition: BlockIo.h:224
EFI_EVENT Event
Definition: BlockIo2.h:34
EFI_STATUS TransactionStatus
Definition: BlockIo2.h:39
BOOLEAN RemovableMedia
Definition: BlockIo.h:137
BOOLEAN LogicalPartition
Definition: BlockIo.h:150
UINT32 BlockSize
Definition: BlockIo.h:167
EFI_LBA LastBlock
Definition: BlockIo.h:178
BOOLEAN MediaPresent
Definition: BlockIo.h:144
Definition: Emmc.h:71
Definition: Emmc.h:84