TianoCore EDK2 master
Loading...
Searching...
No Matches
SdDxe.c
Go to the documentation of this file.
1
12#include "SdDxe.h"
13
14//
15// SdDxe Driver Binding Protocol Instance
16//
17EFI_DRIVER_BINDING_PROTOCOL gSdDxeDriverBinding = {
21 0x10,
22 NULL,
23 NULL
24};
25
26//
27// Template for SD_DEVICE data structure.
28//
29SD_DEVICE mSdDeviceTemplate = {
30 SD_DEVICE_SIGNATURE, // Signature
31 NULL, // Handle
32 NULL, // DevicePath
33 0xFF, // Slot
34 FALSE, // SectorAddressing
35 { // BlockIo
36 EFI_BLOCK_IO_PROTOCOL_REVISION,
37 NULL,
38 SdReset,
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 { // EraseBlock
62 EFI_ERASE_BLOCK_PROTOCOL_REVISION,
63 1,
65 },
66 { // DiskInfo
72 },
73 { // Queue
74 NULL,
75 NULL
76 },
77 { // Csd
78 0,
79 },
80 { // Cid
81 0,
82 },
83 NULL, // ControllerNameTable
84 { // ModelName
85 0,
86 },
87 NULL // Private
88};
89
99 IN SD_CSD *Csd
100 )
101{
102 SD_CSD2 *Csd2;
103
104 DEBUG ((DEBUG_INFO, "== Dump Sd Csd Register==\n"));
105 DEBUG ((DEBUG_INFO, " CSD structure 0x%x\n", Csd->CsdStructure));
106 DEBUG ((DEBUG_INFO, " Data read access-time 1 0x%x\n", Csd->Taac));
107 DEBUG ((DEBUG_INFO, " Data read access-time 2 0x%x\n", Csd->Nsac));
108 DEBUG ((DEBUG_INFO, " Max. bus clock frequency 0x%x\n", Csd->TranSpeed));
109 DEBUG ((DEBUG_INFO, " Device command classes 0x%x\n", Csd->Ccc));
110 DEBUG ((DEBUG_INFO, " Max. read data block length 0x%x\n", Csd->ReadBlLen));
111 DEBUG ((DEBUG_INFO, " Partial blocks for read allowed 0x%x\n", Csd->ReadBlPartial));
112 DEBUG ((DEBUG_INFO, " Write block misalignment 0x%x\n", Csd->WriteBlkMisalign));
113 DEBUG ((DEBUG_INFO, " Read block misalignment 0x%x\n", Csd->ReadBlkMisalign));
114 DEBUG ((DEBUG_INFO, " DSR implemented 0x%x\n", Csd->DsrImp));
115 if (Csd->CsdStructure == 0) {
116 DEBUG ((DEBUG_INFO, " Device size 0x%x\n", Csd->CSizeLow | (Csd->CSizeHigh << 2)));
117 DEBUG ((DEBUG_INFO, " Max. read current @ VDD min 0x%x\n", Csd->VddRCurrMin));
118 DEBUG ((DEBUG_INFO, " Max. read current @ VDD max 0x%x\n", Csd->VddRCurrMax));
119 DEBUG ((DEBUG_INFO, " Max. write current @ VDD min 0x%x\n", Csd->VddWCurrMin));
120 DEBUG ((DEBUG_INFO, " Max. write current @ VDD max 0x%x\n", Csd->VddWCurrMax));
121 } else {
122 Csd2 = (SD_CSD2 *)(VOID *)Csd;
123 DEBUG ((DEBUG_INFO, " Device size 0x%x\n", Csd2->CSizeLow | (Csd->CSizeHigh << 16)));
124 }
125
126 DEBUG ((DEBUG_INFO, " Erase sector size 0x%x\n", Csd->SectorSize));
127 DEBUG ((DEBUG_INFO, " Erase single block enable 0x%x\n", Csd->EraseBlkEn));
128 DEBUG ((DEBUG_INFO, " Write protect group size 0x%x\n", Csd->WpGrpSize));
129 DEBUG ((DEBUG_INFO, " Write protect group enable 0x%x\n", Csd->WpGrpEnable));
130 DEBUG ((DEBUG_INFO, " Write speed factor 0x%x\n", Csd->R2WFactor));
131 DEBUG ((DEBUG_INFO, " Max. write data block length 0x%x\n", Csd->WriteBlLen));
132 DEBUG ((DEBUG_INFO, " Partial blocks for write allowed 0x%x\n", Csd->WriteBlPartial));
133 DEBUG ((DEBUG_INFO, " File format group 0x%x\n", Csd->FileFormatGrp));
134 DEBUG ((DEBUG_INFO, " Copy flag (OTP) 0x%x\n", Csd->Copy));
135 DEBUG ((DEBUG_INFO, " Permanent write protection 0x%x\n", Csd->PermWriteProtect));
136 DEBUG ((DEBUG_INFO, " Temporary write protection 0x%x\n", Csd->TmpWriteProtect));
137 DEBUG ((DEBUG_INFO, " File format 0x%x\n", Csd->FileFormat));
138
139 return EFI_SUCCESS;
140}
141
153 IN OUT SD_DEVICE *Device,
154 IN SD_CID *Cid
155 )
156{
157 CHAR8 String[SD_MODEL_NAME_MAX_LEN];
158
159 ZeroMem (String, sizeof (String));
160 CopyMem (String, Cid->OemId, sizeof (Cid->OemId));
161 String[sizeof (Cid->OemId)] = ' ';
162 CopyMem (String + sizeof (Cid->OemId) + 1, Cid->ProductName, sizeof (Cid->ProductName));
163 String[sizeof (Cid->OemId) + sizeof (Cid->ProductName)] = ' ';
164 CopyMem (String + sizeof (Cid->OemId) + sizeof (Cid->ProductName) + 1, Cid->ProductSerialNumber, sizeof (Cid->ProductSerialNumber));
165
166 AsciiStrToUnicodeStrS (String, Device->ModelName, sizeof (Device->ModelName) / sizeof (Device->ModelName[0]));
167
168 return EFI_SUCCESS;
169}
170
182 IN SD_DEVICE *Device
183 )
184{
185 EFI_STATUS Status;
186 SD_CSD *Csd;
187 SD_CSD2 *Csd2;
188 SD_CID *Cid;
189 UINT64 Capacity;
190 UINT32 DevStatus;
191 UINT16 Rca;
192 UINT32 CSize;
193 UINT32 CSizeMul;
194 UINT32 ReadBlLen;
195
196 //
197 // Deselect the device to force it enter stby mode.
198 // Note here we don't judge return status as some SD devices return
199 // error but the state has been stby.
200 //
201 SdSelect (Device, 0);
202
203 Status = SdSetRca (Device, &Rca);
204 if (EFI_ERROR (Status)) {
205 DEBUG ((DEBUG_ERROR, "DiscoverUserArea(): Assign new Rca = 0x%x fails with %r\n", Rca, Status));
206 return Status;
207 }
208
209 Csd = &Device->Csd;
210 Status = SdGetCsd (Device, Rca, Csd);
211 if (EFI_ERROR (Status)) {
212 return Status;
213 }
214
215 DumpCsd (Csd);
216
217 Cid = &Device->Cid;
218 Status = SdGetCid (Device, Rca, Cid);
219 if (EFI_ERROR (Status)) {
220 return Status;
221 }
222
223 GetSdModelName (Device, Cid);
224
225 Status = SdSelect (Device, Rca);
226 if (EFI_ERROR (Status)) {
227 DEBUG ((DEBUG_ERROR, "DiscoverUserArea(): Reselect the device 0x%x fails with %r\n", Rca, Status));
228 return Status;
229 }
230
231 Status = SdSendStatus (Device, Rca, &DevStatus);
232 if (EFI_ERROR (Status)) {
233 return Status;
234 }
235
236 if (Csd->CsdStructure == 0) {
237 Device->SectorAddressing = FALSE;
238 CSize = (Csd->CSizeHigh << 2 | Csd->CSizeLow) + 1;
239 CSizeMul = (1 << (Csd->CSizeMul + 2));
240 ReadBlLen = (1 << (Csd->ReadBlLen));
241 Capacity = MultU64x32 (MultU64x32 ((UINT64)CSize, CSizeMul), ReadBlLen);
242 } else {
243 Device->SectorAddressing = TRUE;
244 Csd2 = (SD_CSD2 *)(VOID *)Csd;
245 CSize = (Csd2->CSizeHigh << 16 | Csd2->CSizeLow) + 1;
246 Capacity = MultU64x32 ((UINT64)CSize, SIZE_512KB);
247 }
248
249 Device->BlockIo.Media = &Device->BlockMedia;
250 Device->BlockIo2.Media = &Device->BlockMedia;
251 Device->BlockMedia.IoAlign = Device->Private->PassThru->IoAlign;
252 Device->BlockMedia.BlockSize = 0x200;
253 Device->BlockMedia.LastBlock = 0x00;
254 Device->BlockMedia.RemovableMedia = TRUE;
255 Device->BlockMedia.MediaPresent = TRUE;
256 Device->BlockMedia.LogicalPartition = FALSE;
257 Device->BlockMedia.LastBlock = DivU64x32 (Capacity, Device->BlockMedia.BlockSize) - 1;
258
259 if (Csd->EraseBlkEn) {
260 Device->EraseBlock.EraseLengthGranularity = 1;
261 } else {
262 Device->EraseBlock.EraseLengthGranularity = (Csd->SectorSize + 1) * (1 << (Csd->WriteBlLen - 9));
263 }
264
265 return Status;
266}
267
283EFIAPI
285 IN SD_DRIVER_PRIVATE_DATA *Private,
286 IN UINT8 Slot
287 )
288{
289 EFI_STATUS Status;
290 SD_DEVICE *Device;
291 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
292 EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
293 EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath;
294 EFI_HANDLE DeviceHandle;
296
297 Device = NULL;
298 DevicePath = NULL;
299 NewDevicePath = NULL;
300 RemainingDevicePath = NULL;
301 PassThru = Private->PassThru;
302
303 //
304 // Build Device Path
305 //
306 Status = PassThru->BuildDevicePath (
307 PassThru,
308 Slot,
309 &DevicePath
310 );
311 if (EFI_ERROR (Status)) {
312 return Status;
313 }
314
315 if (DevicePath->SubType != MSG_SD_DP) {
316 Status = EFI_UNSUPPORTED;
317 goto Error;
318 }
319
320 NewDevicePath = AppendDevicePathNode (
321 Private->ParentDevicePath,
322 DevicePath
323 );
324
325 if (NewDevicePath == NULL) {
326 Status = EFI_OUT_OF_RESOURCES;
327 goto Error;
328 }
329
330 DeviceHandle = NULL;
331 RemainingDevicePath = NewDevicePath;
332 Status = gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &RemainingDevicePath, &DeviceHandle);
333 if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd (RemainingDevicePath)) {
334 //
335 // The device has been started, directly return to fast boot.
336 //
337 Status = EFI_ALREADY_STARTED;
338 goto Error;
339 }
340
341 //
342 // Allocate buffer to store SD_DEVICE private data.
343 //
344 Device = AllocateCopyPool (sizeof (SD_DEVICE), &mSdDeviceTemplate);
345 if (Device == NULL) {
346 Status = EFI_OUT_OF_RESOURCES;
347 goto Error;
348 }
349
350 Device->DevicePath = NewDevicePath;
351 Device->Slot = Slot;
352 Device->Private = Private;
353 InitializeListHead (&Device->Queue);
354
355 //
356 // Expose user area in the Sd memory card to upper layer.
357 //
358 Status = DiscoverUserArea (Device);
359 if (EFI_ERROR (Status)) {
360 goto Error;
361 }
362
363 Device->ControllerNameTable = NULL;
365 "eng",
366 gSdDxeComponentName.SupportedLanguages,
367 &Device->ControllerNameTable,
368 Device->ModelName,
369 TRUE
370 );
372 "en",
373 gSdDxeComponentName2.SupportedLanguages,
374 &Device->ControllerNameTable,
375 Device->ModelName,
376 FALSE
377 );
378
379 Status = gBS->InstallMultipleProtocolInterfaces (
380 &Device->Handle,
381 &gEfiDevicePathProtocolGuid,
382 Device->DevicePath,
383 &gEfiBlockIoProtocolGuid,
384 &Device->BlockIo,
385 &gEfiBlockIo2ProtocolGuid,
386 &Device->BlockIo2,
387 &gEfiEraseBlockProtocolGuid,
388 &Device->EraseBlock,
389 &gEfiDiskInfoProtocolGuid,
390 &Device->DiskInfo,
391 NULL
392 );
393
394 if (!EFI_ERROR (Status)) {
395 gBS->OpenProtocol (
396 Private->Controller,
397 &gEfiSdMmcPassThruProtocolGuid,
398 (VOID **)&(Private->PassThru),
399 Private->DriverBindingHandle,
400 Device->Handle,
401 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
402 );
403 }
404
405Error:
406 FreePool (DevicePath);
407
408 if (EFI_ERROR (Status) && (NewDevicePath != NULL)) {
409 FreePool (NewDevicePath);
410 }
411
412 if (EFI_ERROR (Status) && (Device != NULL)) {
413 FreePool (Device);
414 }
415
416 return Status;
417}
418
462EFIAPI
465 IN EFI_HANDLE Controller,
466 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
467 )
468{
469 EFI_STATUS Status;
470 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
472 UINT8 Slot;
473
474 //
475 // Test EFI_SD_MMC_PASS_THRU_PROTOCOL on the controller handle.
476 //
477 Status = gBS->OpenProtocol (
478 Controller,
479 &gEfiSdMmcPassThruProtocolGuid,
480 (VOID **)&PassThru,
481 This->DriverBindingHandle,
482 Controller,
483 EFI_OPEN_PROTOCOL_BY_DRIVER
484 );
485
486 if (Status == EFI_ALREADY_STARTED) {
487 return EFI_SUCCESS;
488 }
489
490 if (EFI_ERROR (Status)) {
491 return Status;
492 }
493
494 //
495 // Test RemainingDevicePath is valid or not.
496 //
497 if ((RemainingDevicePath != NULL) && !IsDevicePathEnd (RemainingDevicePath)) {
498 Status = PassThru->GetSlotNumber (PassThru, RemainingDevicePath, &Slot);
499 if (EFI_ERROR (Status)) {
500 //
501 // Close the I/O Abstraction(s) used to perform the supported test
502 //
503 gBS->CloseProtocol (
504 Controller,
505 &gEfiSdMmcPassThruProtocolGuid,
506 This->DriverBindingHandle,
507 Controller
508 );
509 return Status;
510 }
511 }
512
513 //
514 // Close the I/O Abstraction(s) used to perform the supported test
515 //
516 gBS->CloseProtocol (
517 Controller,
518 &gEfiSdMmcPassThruProtocolGuid,
519 This->DriverBindingHandle,
520 Controller
521 );
522
523 //
524 // Open the EFI Device Path protocol needed to perform the supported test
525 //
526 Status = gBS->OpenProtocol (
527 Controller,
528 &gEfiDevicePathProtocolGuid,
529 (VOID **)&ParentDevicePath,
530 This->DriverBindingHandle,
531 Controller,
532 EFI_OPEN_PROTOCOL_GET_PROTOCOL
533 );
534 return Status;
535}
536
573EFIAPI
576 IN EFI_HANDLE Controller,
577 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
578 )
579{
580 EFI_STATUS Status;
582 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
583 SD_DRIVER_PRIVATE_DATA *Private;
584 UINT8 Slot;
585
586 Private = NULL;
587 PassThru = NULL;
588 Status = gBS->OpenProtocol (
589 Controller,
590 &gEfiSdMmcPassThruProtocolGuid,
591 (VOID **)&PassThru,
592 This->DriverBindingHandle,
593 Controller,
594 EFI_OPEN_PROTOCOL_BY_DRIVER
595 );
596 if ((EFI_ERROR (Status)) && (Status != EFI_ALREADY_STARTED)) {
597 return Status;
598 }
599
600 //
601 // Check EFI_ALREADY_STARTED to reuse the original SD_DRIVER_PRIVATE_DATA.
602 //
603 if (Status != EFI_ALREADY_STARTED) {
604 Private = AllocateZeroPool (sizeof (SD_DRIVER_PRIVATE_DATA));
605 if (Private == NULL) {
606 Status = EFI_OUT_OF_RESOURCES;
607 goto Error;
608 }
609
610 Status = gBS->OpenProtocol (
611 Controller,
612 &gEfiDevicePathProtocolGuid,
613 (VOID **)&ParentDevicePath,
614 This->DriverBindingHandle,
615 Controller,
616 EFI_OPEN_PROTOCOL_GET_PROTOCOL
617 );
618 ASSERT_EFI_ERROR (Status);
619 Private->PassThru = PassThru;
620 Private->Controller = Controller;
621 Private->ParentDevicePath = ParentDevicePath;
622 Private->DriverBindingHandle = This->DriverBindingHandle;
623
624 Status = gBS->InstallProtocolInterface (
625 &Controller,
626 &gEfiCallerIdGuid,
628 Private
629 );
630 if (EFI_ERROR (Status)) {
631 goto Error;
632 }
633 } else {
634 Status = gBS->OpenProtocol (
635 Controller,
636 &gEfiCallerIdGuid,
637 (VOID **)&Private,
638 This->DriverBindingHandle,
639 Controller,
640 EFI_OPEN_PROTOCOL_GET_PROTOCOL
641 );
642 if (EFI_ERROR (Status)) {
643 goto Error;
644 }
645 }
646
647 if (RemainingDevicePath == NULL) {
648 Slot = 0xFF;
649 while (TRUE) {
650 Status = PassThru->GetNextSlot (PassThru, &Slot);
651 if (EFI_ERROR (Status)) {
652 //
653 // Cannot find more legal slots.
654 //
655 Status = EFI_SUCCESS;
656 break;
657 }
658
659 Status = DiscoverSdDevice (Private, Slot);
660 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
661 break;
662 }
663 }
664 } else if (!IsDevicePathEnd (RemainingDevicePath)) {
665 Status = PassThru->GetSlotNumber (PassThru, RemainingDevicePath, &Slot);
666 if (!EFI_ERROR (Status)) {
667 Status = DiscoverSdDevice (Private, Slot);
668 }
669 }
670
671Error:
672 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
673 gBS->CloseProtocol (
674 Controller,
675 &gEfiSdMmcPassThruProtocolGuid,
676 This->DriverBindingHandle,
677 Controller
678 );
679
680 if (Private != NULL) {
681 gBS->UninstallMultipleProtocolInterfaces (
682 Controller,
683 &gEfiCallerIdGuid,
684 Private,
685 NULL
686 );
687 FreePool (Private);
688 }
689 }
690
691 return Status;
692}
693
721EFIAPI
724 IN EFI_HANDLE Controller,
725 IN UINTN NumberOfChildren,
726 IN EFI_HANDLE *ChildHandleBuffer
727 )
728{
729 EFI_STATUS Status;
730 BOOLEAN AllChildrenStopped;
731 UINTN Index;
732 SD_DRIVER_PRIVATE_DATA *Private;
733 SD_DEVICE *Device;
735 EFI_BLOCK_IO2_PROTOCOL *BlockIo2;
736 EFI_BLOCK_IO_PROTOCOL *BlockIo;
737 LIST_ENTRY *Link;
738 LIST_ENTRY *NextLink;
739 SD_REQUEST *Request;
740 EFI_TPL OldTpl;
741
742 if (NumberOfChildren == 0) {
743 Status = gBS->OpenProtocol (
744 Controller,
745 &gEfiCallerIdGuid,
746 (VOID **)&Private,
747 This->DriverBindingHandle,
748 Controller,
749 EFI_OPEN_PROTOCOL_GET_PROTOCOL
750 );
751 if (EFI_ERROR (Status)) {
752 return EFI_DEVICE_ERROR;
753 }
754
755 gBS->UninstallProtocolInterface (
756 Controller,
757 &gEfiCallerIdGuid,
758 Private
759 );
760 gBS->CloseProtocol (
761 Controller,
762 &gEfiSdMmcPassThruProtocolGuid,
763 This->DriverBindingHandle,
764 Controller
765 );
766
767 FreePool (Private);
768
769 return EFI_SUCCESS;
770 }
771
772 AllChildrenStopped = TRUE;
773
774 for (Index = 0; Index < NumberOfChildren; Index++) {
775 BlockIo = NULL;
776 BlockIo2 = NULL;
777 Status = gBS->OpenProtocol (
778 ChildHandleBuffer[Index],
779 &gEfiBlockIoProtocolGuid,
780 (VOID **)&BlockIo,
781 This->DriverBindingHandle,
782 Controller,
783 EFI_OPEN_PROTOCOL_GET_PROTOCOL
784 );
785 if (EFI_ERROR (Status)) {
786 Status = gBS->OpenProtocol (
787 ChildHandleBuffer[Index],
788 &gEfiBlockIo2ProtocolGuid,
789 (VOID **)&BlockIo2,
790 This->DriverBindingHandle,
791 Controller,
792 EFI_OPEN_PROTOCOL_GET_PROTOCOL
793 );
794 if (EFI_ERROR (Status)) {
795 AllChildrenStopped = FALSE;
796 continue;
797 }
798 }
799
800 if (BlockIo != NULL) {
801 Device = SD_DEVICE_DATA_FROM_BLKIO (BlockIo);
802 } else {
803 ASSERT (BlockIo2 != NULL);
804 Device = SD_DEVICE_DATA_FROM_BLKIO2 (BlockIo2);
805 }
806
807 //
808 // Free all on-going async tasks.
809 //
810 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
811 for (Link = GetFirstNode (&Device->Queue);
812 !IsNull (&Device->Queue, Link);
813 Link = NextLink)
814 {
815 NextLink = GetNextNode (&Device->Queue, Link);
816 RemoveEntryList (Link);
817
818 Request = SD_REQUEST_FROM_LINK (Link);
819
820 gBS->CloseEvent (Request->Event);
821 Request->Token->TransactionStatus = EFI_ABORTED;
822
823 if (Request->IsEnd) {
824 gBS->SignalEvent (Request->Token->Event);
825 }
826
827 FreePool (Request);
828 }
829
830 gBS->RestoreTPL (OldTpl);
831
832 //
833 // Close the child handle
834 //
835 Status = gBS->CloseProtocol (
836 Controller,
837 &gEfiSdMmcPassThruProtocolGuid,
838 This->DriverBindingHandle,
839 ChildHandleBuffer[Index]
840 );
841
842 Status = gBS->UninstallMultipleProtocolInterfaces (
843 ChildHandleBuffer[Index],
844 &gEfiDevicePathProtocolGuid,
845 Device->DevicePath,
846 &gEfiBlockIoProtocolGuid,
847 &Device->BlockIo,
848 &gEfiBlockIo2ProtocolGuid,
849 &Device->BlockIo2,
850 &gEfiEraseBlockProtocolGuid,
851 &Device->EraseBlock,
852 &gEfiDiskInfoProtocolGuid,
853 &Device->DiskInfo,
854 NULL
855 );
856 if (EFI_ERROR (Status)) {
857 AllChildrenStopped = FALSE;
858 gBS->OpenProtocol (
859 Controller,
860 &gEfiSdMmcPassThruProtocolGuid,
861 (VOID **)&PassThru,
862 This->DriverBindingHandle,
863 ChildHandleBuffer[Index],
864 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
865 );
866 } else {
867 FreePool (Device->DevicePath);
868 FreeUnicodeStringTable (Device->ControllerNameTable);
869 FreePool (Device);
870 }
871 }
872
873 if (!AllChildrenStopped) {
874 return EFI_DEVICE_ERROR;
875 }
876
877 return EFI_SUCCESS;
878}
879
891EFIAPI
893 IN EFI_HANDLE ImageHandle,
894 IN EFI_SYSTEM_TABLE *SystemTable
895 )
896{
897 EFI_STATUS Status;
898
899 //
900 // Install driver model protocol(s).
901 //
903 ImageHandle,
904 SystemTable,
905 &gSdDxeDriverBinding,
906 ImageHandle,
907 &gSdDxeComponentName,
908 &gSdDxeComponentName2
909 );
910 ASSERT_EFI_ERROR (Status);
911
912 return Status;
913}
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 MSG_SD_DP
Definition: DevicePath.h:907
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)
#define EFI_DISK_INFO_SD_MMC_INTERFACE_GUID
Definition: DiskInfo.h:81
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#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
EFI_STATUS EFIAPI SdFlushBlocks(IN EFI_BLOCK_IO_PROTOCOL *This)
Definition: SdBlockIo.c:817
EFI_STATUS SdSelect(IN SD_DEVICE *Device, IN UINT16 Rca)
Definition: SdBlockIo.c:112
EFI_STATUS EFIAPI SdReset(IN EFI_BLOCK_IO_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
Definition: SdBlockIo.c:708
EFI_STATUS EFIAPI SdReadBlocksEx(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: SdBlockIo.c:906
EFI_STATUS SdGetCsd(IN SD_DEVICE *Device, IN UINT16 Rca, OUT SD_CSD *Csd)
Definition: SdBlockIo.c:205
EFI_STATUS SdSendStatus(IN SD_DEVICE *Device, IN UINT16 Rca, OUT UINT32 *DevStatus)
Definition: SdBlockIo.c:158
EFI_STATUS EFIAPI SdWriteBlocks(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, IN VOID *Buffer)
Definition: SdBlockIo.c:788
EFI_STATUS SdSetRca(IN SD_DEVICE *Device, OUT UINT16 *Rca)
Definition: SdBlockIo.c:67
EFI_STATUS EFIAPI SdEraseBlocks(IN EFI_ERASE_BLOCK_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN OUT EFI_ERASE_BLOCK_TOKEN *Token, IN UINTN Size)
Definition: SdBlockIo.c:1331
EFI_STATUS SdGetCid(IN SD_DEVICE *Device, IN UINT16 Rca, OUT SD_CID *Cid)
Definition: SdBlockIo.c:258
EFI_STATUS EFIAPI SdFlushBlocksEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN OUT EFI_BLOCK_IO2_TOKEN *Token)
Definition: SdBlockIo.c:979
EFI_STATUS EFIAPI SdWriteBlocksEx(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: SdBlockIo.c:948
EFI_STATUS EFIAPI SdResetEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
Definition: SdBlockIo.c:840
EFI_STATUS EFIAPI SdReadBlocks(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
Definition: SdBlockIo.c:749
EFI_STATUS EFIAPI SdDiskInfoInquiry(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *InquiryData, IN OUT UINT32 *InquiryDataSize)
Definition: SdDiskInfo.c:29
EFI_STATUS EFIAPI SdDiskInfoSenseData(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *SenseData, IN OUT UINT32 *SenseDataSize, OUT UINT8 *SenseDataNumber)
Definition: SdDiskInfo.c:100
EFI_STATUS EFIAPI SdDiskInfoWhichIde(IN EFI_DISK_INFO_PROTOCOL *This, OUT UINT32 *IdeChannel, OUT UINT32 *IdeDevice)
Definition: SdDiskInfo.c:125
EFI_STATUS EFIAPI SdDiskInfoIdentify(IN EFI_DISK_INFO_PROTOCOL *This, IN OUT VOID *IdentifyData, IN OUT UINT32 *IdentifyDataSize)
Definition: SdDiskInfo.c:72
EFI_STATUS EFIAPI InitializeSdDxe(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: SdDxe.c:892
EFI_STATUS EFIAPI SdDxeDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: SdDxe.c:722
EFI_STATUS EFIAPI SdDxeDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: SdDxe.c:463
EFI_STATUS EFIAPI SdDxeDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: SdDxe.c:574
EFI_STATUS DiscoverUserArea(IN SD_DEVICE *Device)
Definition: SdDxe.c:181
EFI_STATUS DumpCsd(IN SD_CSD *Csd)
Definition: SdDxe.c:98
EFI_STATUS EFIAPI DiscoverSdDevice(IN SD_DRIVER_PRIVATE_DATA *Private, IN UINT8 Slot)
Definition: SdDxe.c:284
EFI_STATUS GetSdModelName(IN OUT SD_DEVICE *Device, IN SD_CID *Cid)
Definition: SdDxe.c:152
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
UINTN EFI_TPL
Definition: UefiBaseType.h:41
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_STATUS EFIAPI FreeUnicodeStringTable(IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable)
Definition: UefiLib.c:1257
@ EFI_NATIVE_INTERFACE
Definition: UefiSpec.h:1193
EFI_EVENT Event
Definition: BlockIo2.h:34
EFI_STATUS TransactionStatus
Definition: BlockIo2.h:39
Definition: Sd.h:66
Definition: Sd.h:120
Definition: Sd.h:78