28 gBS->CloseEvent (Event);
35 "Sd Async Request: CmdIndex[%d] Arg[%08x] %r\n",
36 Request->SdMmcCmdBlk.CommandIndex,
37 Request->SdMmcCmdBlk.CommandArgument,
38 Request->Packet.TransactionStatus
42 if (EFI_ERROR (Request->Packet.TransactionStatus)) {
49 gBS->SignalEvent (Request->Token->
Event);
78 PassThru = Device->Private->PassThru;
80 ZeroMem (&SdMmcCmdBlk,
sizeof (SdMmcCmdBlk));
81 ZeroMem (&SdMmcStatusBlk,
sizeof (SdMmcStatusBlk));
82 ZeroMem (&Packet,
sizeof (Packet));
83 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
84 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
85 Packet.Timeout = SD_GENERIC_TIMEOUT;
87 SdMmcCmdBlk.CommandIndex = SD_SET_RELATIVE_ADDR;
88 SdMmcCmdBlk.CommandType = SdMmcCommandTypeBcr;
89 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR6;
91 Status = PassThru->PassThru (PassThru, Device->Slot, &Packet,
NULL);
92 if (!EFI_ERROR (Status)) {
93 DEBUG ((DEBUG_INFO,
"Set RCA succeeds with Resp0 = 0x%x\n", SdMmcStatusBlk.Resp0));
94 *Rca = (UINT16)(SdMmcStatusBlk.Resp0 >> 16);
123 PassThru = Device->Private->PassThru;
125 ZeroMem (&SdMmcCmdBlk,
sizeof (SdMmcCmdBlk));
126 ZeroMem (&SdMmcStatusBlk,
sizeof (SdMmcStatusBlk));
127 ZeroMem (&Packet,
sizeof (Packet));
128 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
129 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
130 Packet.Timeout = SD_GENERIC_TIMEOUT;
132 SdMmcCmdBlk.CommandIndex = SD_SELECT_DESELECT_CARD;
133 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
135 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1b;
138 SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
140 Status = PassThru->PassThru (PassThru, Device->Slot, &Packet,
NULL);
161 OUT UINT32 *DevStatus
170 PassThru = Device->Private->PassThru;
172 ZeroMem (&SdMmcCmdBlk,
sizeof (SdMmcCmdBlk));
173 ZeroMem (&SdMmcStatusBlk,
sizeof (SdMmcStatusBlk));
174 ZeroMem (&Packet,
sizeof (Packet));
175 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
176 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
177 Packet.Timeout = SD_GENERIC_TIMEOUT;
179 SdMmcCmdBlk.CommandIndex = SD_SEND_STATUS;
180 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
181 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
182 SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
184 Status = PassThru->PassThru (PassThru, Device->Slot, &Packet,
NULL);
185 if (!EFI_ERROR (Status)) {
186 CopyMem (DevStatus, &SdMmcStatusBlk.Resp0, sizeof (UINT32));
217 PassThru = Device->Private->PassThru;
219 ZeroMem (&SdMmcCmdBlk,
sizeof (SdMmcCmdBlk));
220 ZeroMem (&SdMmcStatusBlk,
sizeof (SdMmcStatusBlk));
221 ZeroMem (&Packet,
sizeof (Packet));
224 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
225 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
226 Packet.Timeout = SD_GENERIC_TIMEOUT;
228 SdMmcCmdBlk.CommandIndex = SD_SEND_CSD;
229 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
230 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR2;
231 SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
233 Status = PassThru->PassThru (PassThru, Device->Slot, &Packet,
NULL);
235 if (!EFI_ERROR (Status)) {
239 CopyMem (((UINT8 *)Csd) + 1, &SdMmcStatusBlk.Resp0, sizeof (
SD_CSD) - 1);
270 PassThru = Device->Private->PassThru;
272 ZeroMem (&SdMmcCmdBlk,
sizeof (SdMmcCmdBlk));
273 ZeroMem (&SdMmcStatusBlk,
sizeof (SdMmcStatusBlk));
274 ZeroMem (&Packet,
sizeof (Packet));
277 Packet.SdMmcCmdBlk = &SdMmcCmdBlk;
278 Packet.SdMmcStatusBlk = &SdMmcStatusBlk;
279 Packet.Timeout = SD_GENERIC_TIMEOUT;
281 SdMmcCmdBlk.CommandIndex = SD_SEND_CID;
282 SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
283 SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR2;
284 SdMmcCmdBlk.CommandArgument = (UINT32)Rca << 16;
286 Status = PassThru->PassThru (PassThru, Device->Slot, &Packet,
NULL);
288 if (!EFI_ERROR (Status)) {
292 CopyMem (((UINT8 *)Cid) + 1, &SdMmcStatusBlk.Resp0, sizeof (
SD_CID) - 1);
333 RwSingleBlkReq =
NULL;
334 PassThru = Device->Private->PassThru;
337 if (RwSingleBlkReq ==
NULL) {
338 Status = EFI_OUT_OF_RESOURCES;
342 RwSingleBlkReq->Signature = SD_REQUEST_SIGNATURE;
343 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
345 gBS->RestoreTPL (OldTpl);
346 RwSingleBlkReq->Packet.SdMmcCmdBlk = &RwSingleBlkReq->SdMmcCmdBlk;
347 RwSingleBlkReq->Packet.SdMmcStatusBlk = &RwSingleBlkReq->SdMmcStatusBlk;
355 RwSingleBlkReq->Packet.Timeout = (BufferSize / (2 * 1024 * 1024) + 1) * 1000 * 1000;
358 RwSingleBlkReq->Packet.InDataBuffer = Buffer;
359 RwSingleBlkReq->Packet.InTransferLength = (UINT32)BufferSize;
361 RwSingleBlkReq->SdMmcCmdBlk.CommandIndex = SD_READ_SINGLE_BLOCK;
362 RwSingleBlkReq->SdMmcCmdBlk.CommandType = SdMmcCommandTypeAdtc;
363 RwSingleBlkReq->SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
365 RwSingleBlkReq->Packet.OutDataBuffer = Buffer;
366 RwSingleBlkReq->Packet.OutTransferLength = (UINT32)BufferSize;
368 RwSingleBlkReq->SdMmcCmdBlk.CommandIndex = SD_WRITE_SINGLE_BLOCK;
369 RwSingleBlkReq->SdMmcCmdBlk.CommandType = SdMmcCommandTypeAdtc;
370 RwSingleBlkReq->SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
373 if (Device->SectorAddressing) {
374 RwSingleBlkReq->SdMmcCmdBlk.CommandArgument = (UINT32)Lba;
376 RwSingleBlkReq->SdMmcCmdBlk.CommandArgument = (UINT32)
MultU64x32 (Lba, Device->BlockMedia.BlockSize);
379 RwSingleBlkReq->IsEnd = IsEnd;
380 RwSingleBlkReq->Token = Token;
382 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
383 Status =
gBS->CreateEvent (
388 &RwSingleBlkReq->Event
390 if (EFI_ERROR (Status)) {
394 RwSingleBlkReq->Event =
NULL;
397 Status = PassThru->PassThru (PassThru, Device->Slot, &RwSingleBlkReq->Packet, RwSingleBlkReq->Event);
400 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
405 if (EFI_ERROR (Status) && (RwSingleBlkReq !=
NULL)) {
406 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
408 gBS->RestoreTPL (OldTpl);
409 if (RwSingleBlkReq->Event !=
NULL) {
410 gBS->CloseEvent (RwSingleBlkReq->Event);
419 if (RwSingleBlkReq !=
NULL) {
420 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
422 gBS->RestoreTPL (OldTpl);
465 RwMultiBlkReq =
NULL;
467 PassThru = Device->Private->PassThru;
470 if (RwMultiBlkReq ==
NULL) {
471 Status = EFI_OUT_OF_RESOURCES;
475 RwMultiBlkReq->Signature = SD_REQUEST_SIGNATURE;
476 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
478 gBS->RestoreTPL (OldTpl);
479 RwMultiBlkReq->Packet.SdMmcCmdBlk = &RwMultiBlkReq->SdMmcCmdBlk;
480 RwMultiBlkReq->Packet.SdMmcStatusBlk = &RwMultiBlkReq->SdMmcStatusBlk;
488 RwMultiBlkReq->Packet.Timeout = (BufferSize / (2 * 1024 * 1024) + 1) * 1000 * 1000;
491 RwMultiBlkReq->Packet.InDataBuffer = Buffer;
492 RwMultiBlkReq->Packet.InTransferLength = (UINT32)BufferSize;
494 RwMultiBlkReq->SdMmcCmdBlk.CommandIndex = SD_READ_MULTIPLE_BLOCK;
495 RwMultiBlkReq->SdMmcCmdBlk.CommandType = SdMmcCommandTypeAdtc;
496 RwMultiBlkReq->SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
498 RwMultiBlkReq->Packet.OutDataBuffer = Buffer;
499 RwMultiBlkReq->Packet.OutTransferLength = (UINT32)BufferSize;
501 RwMultiBlkReq->SdMmcCmdBlk.CommandIndex = SD_WRITE_MULTIPLE_BLOCK;
502 RwMultiBlkReq->SdMmcCmdBlk.CommandType = SdMmcCommandTypeAdtc;
503 RwMultiBlkReq->SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
506 if (Device->SectorAddressing) {
507 RwMultiBlkReq->SdMmcCmdBlk.CommandArgument = (UINT32)Lba;
509 RwMultiBlkReq->SdMmcCmdBlk.CommandArgument = (UINT32)
MultU64x32 (Lba, Device->BlockMedia.BlockSize);
512 RwMultiBlkReq->IsEnd = IsEnd;
513 RwMultiBlkReq->Token = Token;
515 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
516 Status =
gBS->CreateEvent (
521 &RwMultiBlkReq->Event
523 if (EFI_ERROR (Status)) {
527 RwMultiBlkReq->Event =
NULL;
530 Status = PassThru->PassThru (PassThru, Device->Slot, &RwMultiBlkReq->Packet, RwMultiBlkReq->Event);
533 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
538 if (EFI_ERROR (Status) && (RwMultiBlkReq !=
NULL)) {
539 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
541 gBS->RestoreTPL (OldTpl);
542 if (RwMultiBlkReq->Event !=
NULL) {
543 gBS->CloseEvent (RwMultiBlkReq->Event);
552 if (RwMultiBlkReq !=
NULL) {
553 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
555 gBS->RestoreTPL (OldTpl);
607 Media = &Device->BlockMedia;
610 if (MediaId != Media->
MediaId) {
611 return EFI_MEDIA_CHANGED;
615 return EFI_WRITE_PROTECTED;
621 if (Buffer ==
NULL) {
622 return EFI_INVALID_PARAMETER;
625 if (BufferSize == 0) {
626 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
628 gBS->SignalEvent (Token->Event);
635 if ((BufferSize % BlockSize) != 0) {
636 return EFI_BAD_BUFFER_SIZE;
639 BlockNum = BufferSize / BlockSize;
640 if ((Lba + BlockNum - 1) > Media->
LastBlock) {
641 return EFI_INVALID_PARAMETER;
645 if ((IoAlign > 0) && (((
UINTN)Buffer & (IoAlign - 1)) != 0)) {
646 return EFI_INVALID_PARAMETER;
649 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
656 Remaining = BlockNum;
659 while (Remaining > 0) {
660 if (Remaining <= MaxBlock) {
661 BlockNum = Remaining;
667 BufferSize = BlockNum * BlockSize;
669 Status =
SdRwSingleBlock (Device, Lba, Buffer, BufferSize, IsRead, Token, LastRw);
671 Status =
SdRwMultiBlocks (Device, Lba, Buffer, BufferSize, IsRead, Token, LastRw);
674 if (EFI_ERROR (Status)) {
680 "Sd%a(): Lba 0x%x BlkNo 0x%x Event %p with %r\n",
681 IsRead ?
"Read" :
"Write",
684 (Token !=
NULL) ? Token->Event :
NULL,
688 Buffer = (UINT8 *)Buffer + BufferSize;
689 Remaining -= BlockNum;
710 IN BOOLEAN ExtendedVerification
717 Device = SD_DEVICE_DATA_FROM_BLKIO (This);
719 PassThru = Device->Private->PassThru;
720 Status = PassThru->ResetDevice (PassThru, Device->Slot);
721 if (EFI_ERROR (Status)) {
722 Status = EFI_DEVICE_ERROR;
760 Device = SD_DEVICE_DATA_FROM_BLKIO (This);
799 Device = SD_DEVICE_DATA_FROM_BLKIO (This);
842 IN BOOLEAN ExtendedVerification
851 Device = SD_DEVICE_DATA_FROM_BLKIO2 (This);
853 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
855 !
IsNull (&Device->Queue, Link);
861 Request = SD_REQUEST_FROM_LINK (Link);
863 gBS->CloseEvent (Request->Event);
866 if (Request->IsEnd) {
867 gBS->SignalEvent (Request->Token->
Event);
873 gBS->RestoreTPL (OldTpl);
918 Device = SD_DEVICE_DATA_FROM_BLKIO2 (This);
920 Status =
SdReadWrite (Device, MediaId, Lba, Buffer, BufferSize,
TRUE, Token);
960 Device = SD_DEVICE_DATA_FROM_BLKIO2 (This);
962 Status =
SdReadWrite (Device, MediaId, Lba, Buffer, BufferSize,
FALSE, Token);
987 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
989 gBS->SignalEvent (Token->Event);
1022 EraseBlockStart =
NULL;
1023 PassThru = Device->Private->PassThru;
1026 if (EraseBlockStart ==
NULL) {
1027 Status = EFI_OUT_OF_RESOURCES;
1031 EraseBlockStart->Signature = SD_REQUEST_SIGNATURE;
1032 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1034 gBS->RestoreTPL (OldTpl);
1035 EraseBlockStart->Packet.SdMmcCmdBlk = &EraseBlockStart->SdMmcCmdBlk;
1036 EraseBlockStart->Packet.SdMmcStatusBlk = &EraseBlockStart->SdMmcStatusBlk;
1037 EraseBlockStart->Packet.Timeout = SD_GENERIC_TIMEOUT;
1039 EraseBlockStart->SdMmcCmdBlk.CommandIndex = SD_ERASE_WR_BLK_START;
1040 EraseBlockStart->SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
1041 EraseBlockStart->SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
1043 if (Device->SectorAddressing) {
1044 EraseBlockStart->SdMmcCmdBlk.CommandArgument = (UINT32)StartLba;
1046 EraseBlockStart->SdMmcCmdBlk.CommandArgument = (UINT32)
MultU64x32 (StartLba, Device->BlockMedia.BlockSize);
1049 EraseBlockStart->IsEnd = IsEnd;
1050 EraseBlockStart->Token = Token;
1052 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1053 Status =
gBS->CreateEvent (
1058 &EraseBlockStart->Event
1060 if (EFI_ERROR (Status)) {
1064 EraseBlockStart->Event =
NULL;
1067 Status = PassThru->PassThru (PassThru, Device->Slot, &EraseBlockStart->Packet, EraseBlockStart->Event);
1070 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1075 if (EFI_ERROR (Status) && (EraseBlockStart !=
NULL)) {
1076 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1078 gBS->RestoreTPL (OldTpl);
1079 if (EraseBlockStart->Event !=
NULL) {
1080 gBS->CloseEvent (EraseBlockStart->Event);
1089 if (EraseBlockStart !=
NULL) {
1090 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1092 gBS->RestoreTPL (OldTpl);
1127 EraseBlockEnd =
NULL;
1128 PassThru = Device->Private->PassThru;
1131 if (EraseBlockEnd ==
NULL) {
1132 Status = EFI_OUT_OF_RESOURCES;
1136 EraseBlockEnd->Signature = SD_REQUEST_SIGNATURE;
1137 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1139 gBS->RestoreTPL (OldTpl);
1140 EraseBlockEnd->Packet.SdMmcCmdBlk = &EraseBlockEnd->SdMmcCmdBlk;
1141 EraseBlockEnd->Packet.SdMmcStatusBlk = &EraseBlockEnd->SdMmcStatusBlk;
1142 EraseBlockEnd->Packet.Timeout = SD_GENERIC_TIMEOUT;
1144 EraseBlockEnd->SdMmcCmdBlk.CommandIndex = SD_ERASE_WR_BLK_END;
1145 EraseBlockEnd->SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
1146 EraseBlockEnd->SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1;
1148 if (Device->SectorAddressing) {
1149 EraseBlockEnd->SdMmcCmdBlk.CommandArgument = (UINT32)EndLba;
1151 EraseBlockEnd->SdMmcCmdBlk.CommandArgument = (UINT32)
MultU64x32 (EndLba, Device->BlockMedia.BlockSize);
1154 EraseBlockEnd->IsEnd = IsEnd;
1155 EraseBlockEnd->Token = Token;
1157 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1158 Status =
gBS->CreateEvent (
1163 &EraseBlockEnd->Event
1165 if (EFI_ERROR (Status)) {
1169 EraseBlockEnd->Event =
NULL;
1172 Status = PassThru->PassThru (PassThru, Device->Slot, &EraseBlockEnd->Packet, EraseBlockEnd->Event);
1175 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1180 if (EFI_ERROR (Status) && (EraseBlockEnd !=
NULL)) {
1181 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1183 gBS->RestoreTPL (OldTpl);
1184 if (EraseBlockEnd->Event !=
NULL) {
1185 gBS->CloseEvent (EraseBlockEnd->Event);
1194 if (EraseBlockEnd !=
NULL) {
1195 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1197 gBS->RestoreTPL (OldTpl);
1231 PassThru = Device->Private->PassThru;
1234 if (EraseBlock ==
NULL) {
1235 Status = EFI_OUT_OF_RESOURCES;
1239 EraseBlock->Signature = SD_REQUEST_SIGNATURE;
1240 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1242 gBS->RestoreTPL (OldTpl);
1243 EraseBlock->Packet.SdMmcCmdBlk = &EraseBlock->SdMmcCmdBlk;
1244 EraseBlock->Packet.SdMmcStatusBlk = &EraseBlock->SdMmcStatusBlk;
1245 EraseBlock->Packet.Timeout = SD_GENERIC_TIMEOUT;
1247 EraseBlock->SdMmcCmdBlk.CommandIndex = SD_ERASE;
1248 EraseBlock->SdMmcCmdBlk.CommandType = SdMmcCommandTypeAc;
1249 EraseBlock->SdMmcCmdBlk.ResponseType = SdMmcResponseTypeR1b;
1251 EraseBlock->IsEnd = IsEnd;
1252 EraseBlock->Token = Token;
1254 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1255 Status =
gBS->CreateEvent (
1262 if (EFI_ERROR (Status)) {
1266 EraseBlock->Event =
NULL;
1269 Status = PassThru->PassThru (PassThru, Device->Slot, &EraseBlock->Packet, EraseBlock->Event);
1272 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1277 if (EFI_ERROR (Status) && (EraseBlock !=
NULL)) {
1278 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1280 gBS->RestoreTPL (OldTpl);
1281 if (EraseBlock->Event !=
NULL) {
1282 gBS->CloseEvent (EraseBlock->Event);
1291 if (EraseBlock !=
NULL) {
1292 OldTpl =
gBS->RaiseTPL (TPL_NOTIFY);
1294 gBS->RestoreTPL (OldTpl);
1347 Device = SD_DEVICE_DATA_FROM_ERASEBLK (This);
1348 Media = &Device->BlockMedia;
1350 if (MediaId != Media->
MediaId) {
1351 return EFI_MEDIA_CHANGED;
1355 return EFI_WRITE_PROTECTED;
1362 if ((Size % BlockSize) != 0) {
1363 return EFI_INVALID_PARAMETER;
1366 BlockNum = Size / BlockSize;
1367 if ((Lba + BlockNum - 1) > Media->
LastBlock) {
1368 return EFI_INVALID_PARAMETER;
1371 if ((Token !=
NULL) && (Token->Event !=
NULL)) {
1375 LastLba = Lba + BlockNum - 1;
1378 if (EFI_ERROR (Status)) {
1383 if (EFI_ERROR (Status)) {
1388 if (EFI_ERROR (Status)) {
1394 "SdEraseBlocks(): Lba 0x%x BlkNo 0x%x Event %p with %r\n",
1397 (Token !=
NULL) ? Token->Event :
NULL,
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)
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 InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define DEBUG_CODE_BEGIN()
#define DEBUG(Expression)
EFI_STATUS SdRwMultiBlocks(IN SD_DEVICE *Device, IN EFI_LBA Lba, IN VOID *Buffer, IN UINTN BufferSize, IN BOOLEAN IsRead, IN EFI_BLOCK_IO2_TOKEN *Token, IN BOOLEAN IsEnd)
EFI_STATUS EFIAPI SdFlushBlocks(IN EFI_BLOCK_IO_PROTOCOL *This)
EFI_STATUS SdSelect(IN SD_DEVICE *Device, IN UINT16 Rca)
EFI_STATUS SdRwSingleBlock(IN SD_DEVICE *Device, IN EFI_LBA Lba, IN VOID *Buffer, IN UINTN BufferSize, IN BOOLEAN IsRead, IN EFI_BLOCK_IO2_TOKEN *Token, IN BOOLEAN IsEnd)
EFI_STATUS SdEraseBlock(IN SD_DEVICE *Device, IN EFI_BLOCK_IO2_TOKEN *Token, IN BOOLEAN IsEnd)
EFI_STATUS EFIAPI SdReset(IN EFI_BLOCK_IO_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
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)
EFI_STATUS SdEraseBlockEnd(IN SD_DEVICE *Device, IN EFI_LBA EndLba, IN EFI_BLOCK_IO2_TOKEN *Token, IN BOOLEAN IsEnd)
EFI_STATUS SdEraseBlockStart(IN SD_DEVICE *Device, IN EFI_LBA StartLba, IN EFI_BLOCK_IO2_TOKEN *Token, IN BOOLEAN IsEnd)
EFI_STATUS SdGetCsd(IN SD_DEVICE *Device, IN UINT16 Rca, OUT SD_CSD *Csd)
EFI_STATUS SdSendStatus(IN SD_DEVICE *Device, IN UINT16 Rca, OUT UINT32 *DevStatus)
EFI_STATUS EFIAPI SdWriteBlocks(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, IN VOID *Buffer)
EFI_STATUS SdSetRca(IN SD_DEVICE *Device, OUT UINT16 *Rca)
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)
EFI_STATUS SdGetCid(IN SD_DEVICE *Device, IN UINT16 Rca, OUT SD_CID *Cid)
EFI_STATUS EFIAPI SdFlushBlocksEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN OUT EFI_BLOCK_IO2_TOKEN *Token)
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)
EFI_STATUS EFIAPI SdResetEx(IN EFI_BLOCK_IO2_PROTOCOL *This, IN BOOLEAN ExtendedVerification)
VOID EFIAPI AsyncIoCallback(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI SdReadBlocks(IN EFI_BLOCK_IO_PROTOCOL *This, IN UINT32 MediaId, IN EFI_LBA Lba, IN UINTN BufferSize, OUT VOID *Buffer)
EFI_STATUS SdReadWrite(IN SD_DEVICE *Device, IN UINT32 MediaId, IN EFI_LBA Lba, IN OUT VOID *Buffer, IN UINTN BufferSize, IN BOOLEAN IsRead, IN OUT EFI_BLOCK_IO2_TOKEN *Token)
EFI_STATUS TransactionStatus