TianoCore EDK2 master
Loading...
Searching...
No Matches
SdBlockIoPei.h
Go to the documentation of this file.
1
8#ifndef _SD_BLOCK_IO_PEI_H_
9#define _SD_BLOCK_IO_PEI_H_
10
11#include <PiPei.h>
12
14#include <Ppi/BlockIo.h>
15#include <Ppi/BlockIo2.h>
16#include <Ppi/IoMmu.h>
17#include <Ppi/EndOfPeiPhase.h>
18
19#include <Library/DebugLib.h>
20#include <Library/BaseLib.h>
23#include <Library/IoLib.h>
24#include <Library/TimerLib.h>
26
27#include <IndustryStandard/Sd.h>
28
31typedef struct _SD_TRB SD_TRB;
32
33#include "SdHci.h"
34#include "SdHcMem.h"
35
36#define SD_PEIM_SIG SIGNATURE_32 ('S', 'D', 'C', 'P')
37#define SD_PEIM_SLOT_SIG SIGNATURE_32 ('S', 'D', 'C', 'S')
38
39#define SD_PEIM_MAX_SLOTS 6
40
42 UINT32 Signature;
44
45 UINTN SdHcBase;
46 SD_HC_SLOT_CAP Capability;
47 SD_CSD Csd;
48 BOOLEAN SectorAddressing;
50};
51
53 UINT32 Signature;
54 SD_PEIM_MEM_POOL *Pool;
57 EFI_PEI_PPI_DESCRIPTOR BlkIoPpiList;
58 EFI_PEI_PPI_DESCRIPTOR BlkIo2PpiList;
59
60 //
61 // EndOfPei callback is used to do the cleanups before exit of PEI phase.
62 //
63 EFI_PEI_NOTIFY_DESCRIPTOR EndOfPeiNotifyList;
64
65 SD_PEIM_HC_SLOT Slot[SD_PEIM_MAX_SLOTS];
66 UINT8 SlotNum;
67 UINT8 TotalBlkIoDevices;
68};
69
70#define SD_TIMEOUT MultU64x32((UINT64)(3), 1000000)
71#define GET_SD_PEIM_HC_PRIVATE_DATA_FROM_THIS(a) CR (a, SD_PEIM_HC_PRIVATE_DATA, BlkIoPpi, SD_PEIM_SIG)
72#define GET_SD_PEIM_HC_PRIVATE_DATA_FROM_THIS2(a) CR (a, SD_PEIM_HC_PRIVATE_DATA, BlkIo2Ppi, SD_PEIM_SIG)
73#define GET_SD_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY(a) CR (a, SD_PEIM_HC_PRIVATE_DATA, EndOfPeiNotifyList, SD_PEIM_SIG)
74
75struct _SD_TRB {
76 SD_PEIM_HC_SLOT *Slot;
77 UINT16 BlockSize;
78
79 SD_COMMAND_PACKET *Packet;
80 VOID *Data;
81 UINT32 DataLen;
82 BOOLEAN Read;
84 VOID *DataMap;
85 SD_HC_TRANSFER_MODE Mode;
86
87 UINT64 Timeout;
88
89 SD_HC_ADMA_DESC_LINE *AdmaDesc;
90 UINTN AdmaDescSize;
91};
92
113EFIAPI
115 IN EFI_PEI_SERVICES **PeiServices,
117 OUT UINTN *NumberBlockDevices
118 );
119
162EFIAPI
164 IN EFI_PEI_SERVICES **PeiServices,
166 IN UINTN DeviceIndex,
167 OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
168 );
169
205EFIAPI
207 IN EFI_PEI_SERVICES **PeiServices,
209 IN UINTN DeviceIndex,
210 IN EFI_PEI_LBA StartLBA,
211 IN UINTN BufferSize,
212 OUT VOID *Buffer
213 );
214
235EFIAPI
237 IN EFI_PEI_SERVICES **PeiServices,
239 OUT UINTN *NumberBlockDevices
240 );
241
284EFIAPI
286 IN EFI_PEI_SERVICES **PeiServices,
288 IN UINTN DeviceIndex,
290 );
291
327EFIAPI
329 IN EFI_PEI_SERVICES **PeiServices,
331 IN UINTN DeviceIndex,
332 IN EFI_PEI_LBA StartLBA,
333 IN UINTN BufferSize,
334 OUT VOID *Buffer
335 );
336
349 );
350
362 IN SD_PEIM_MEM_POOL *Pool
363 );
364
375VOID *
377 IN SD_PEIM_MEM_POOL *Pool,
378 IN UINTN Size
379 );
380
389VOID
391 IN SD_PEIM_MEM_POOL *Pool,
392 IN VOID *Mem,
393 IN UINTN Size
394 );
395
399VOID
400IoMmuInit (
401 VOID
402 );
403
424IoMmuMap (
425 IN EDKII_IOMMU_OPERATION Operation,
426 IN VOID *HostAddress,
427 IN OUT UINTN *NumberOfBytes,
428 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
429 OUT VOID **Mapping
430 );
431
443 IN VOID *Mapping
444 );
445
466 IN UINTN Pages,
467 OUT VOID **HostAddress,
468 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
469 OUT VOID **Mapping
470 );
471
486 IN UINTN Pages,
487 IN VOID *HostAddress,
488 IN VOID *Mapping
489 );
490
503EFIAPI
505 IN EFI_PEI_SERVICES **PeiServices,
506 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
507 IN VOID *Ppi
508 );
509
510#endif
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
UINT64 EFI_PEI_LBA
Definition: BlockIo.h:41
EDKII_IOMMU_OPERATION
Definition: IoMmu.h:44
EFI_STATUS IoMmuUnmap(IN VOID *Mapping)
Definition: DmaMem.c:132
EFI_STATUS IoMmuAllocateBuffer(IN UINTN Pages, OUT VOID **HostAddress, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
Definition: DmaMem.c:170
VOID SdPeimFreeMem(IN SD_PEIM_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size)
Definition: SdHcMem.c:366
EFI_STATUS SdPeimFreeMemPool(IN SD_PEIM_MEM_POOL *Pool)
Definition: SdHcMem.c:263
EFI_STATUS IoMmuMap(IN EDKII_IOMMU_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
Definition: DmaMem.c:60
EFI_STATUS EFIAPI SdBlockIoPeimGetDeviceNo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, OUT UINTN *NumberBlockDevices)
Definition: SdBlockIoPei.c:111
EFI_STATUS EFIAPI SdBlockIoPeimGetMediaInfo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, IN UINTN DeviceIndex, OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo)
Definition: SdBlockIoPei.c:381
EFI_STATUS SdPeimInitMemPool(IN SD_PEIM_HC_PRIVATE_DATA *Private)
Definition: SdHcMem.c:223
EFI_STATUS EFIAPI SdBlockIoPeimReadBlocks2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, IN UINTN DeviceIndex, IN EFI_PEI_LBA StartLBA, IN UINTN BufferSize, OUT VOID *Buffer)
Definition: SdBlockIoPei.c:444
EFI_STATUS EFIAPI SdBlockIoPeimGetMediaInfo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, IN UINTN DeviceIndex, OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo)
Definition: SdBlockIoPei.c:167
EFI_STATUS EFIAPI SdBlockIoPeimEndOfPei(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
Definition: SdBlockIoPei.c:483
EFI_STATUS IoMmuFreeBuffer(IN UINTN Pages, IN VOID *HostAddress, IN VOID *Mapping)
Definition: DmaMem.c:251
VOID * SdPeimAllocateMem(IN SD_PEIM_MEM_POOL *Pool, IN UINTN Size)
Definition: SdHcMem.c:294
VOID IoMmuInit(VOID)
Definition: DmaMem.c:375
EFI_STATUS EFIAPI SdBlockIoPeimGetDeviceNo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, OUT UINTN *NumberBlockDevices)
Definition: SdBlockIoPei.c:324
EFI_STATUS EFIAPI SdBlockIoPeimReadBlocks(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, IN UINTN DeviceIndex, IN EFI_PEI_LBA StartLBA, IN UINTN BufferSize, OUT VOID *Buffer)
Definition: SdBlockIoPei.c:226
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
Definition: Sd.h:78