TianoCore EDK2 master
Loading...
Searching...
No Matches
EmmcBlockIoPei.h
Go to the documentation of this file.
1
8#ifndef _EMMC_BLOCK_IO_PEI_H_
9#define _EMMC_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
28
31typedef struct _EMMC_TRB EMMC_TRB;
32
33#include "EmmcHci.h"
34#include "EmmcHcMem.h"
35
36#define EMMC_PEIM_SIG SIGNATURE_32 ('E', 'M', 'C', 'P')
37#define EMMC_PEIM_SLOT_SIG SIGNATURE_32 ('E', 'M', 'C', 'S')
38
39#define EMMC_PEIM_MAX_SLOTS 6
40#define EMMC_PEIM_MAX_PARTITIONS 8
41
43 UINT32 Signature;
44 EFI_PEI_BLOCK_IO2_MEDIA Media[EMMC_PEIM_MAX_PARTITIONS];
45 UINT8 MediaNum;
46 EMMC_PARTITION_TYPE PartitionType[EMMC_PEIM_MAX_PARTITIONS];
47
48 UINTN EmmcHcBase;
49 EMMC_HC_SLOT_CAP Capability;
50 EMMC_CSD Csd;
51 EMMC_EXT_CSD ExtCsd;
52 BOOLEAN SectorAddressing;
54};
55
57 UINT32 Signature;
61 EFI_PEI_PPI_DESCRIPTOR BlkIoPpiList;
62 EFI_PEI_PPI_DESCRIPTOR BlkIo2PpiList;
63
64 //
65 // EndOfPei callback is used to do the cleanups before exit of PEI phase.
66 //
67 EFI_PEI_NOTIFY_DESCRIPTOR EndOfPeiNotifyList;
68
69 EMMC_PEIM_HC_SLOT Slot[EMMC_PEIM_MAX_SLOTS];
70 UINT8 SlotNum;
71 UINT8 TotalBlkIoDevices;
72};
73
74#define EMMC_TIMEOUT MultU64x32((UINT64)(3), 1000000)
75#define GET_EMMC_PEIM_HC_PRIVATE_DATA_FROM_THIS(a) CR (a, EMMC_PEIM_HC_PRIVATE_DATA, BlkIoPpi, EMMC_PEIM_SIG)
76#define GET_EMMC_PEIM_HC_PRIVATE_DATA_FROM_THIS2(a) CR (a, EMMC_PEIM_HC_PRIVATE_DATA, BlkIo2Ppi, EMMC_PEIM_SIG)
77#define GET_EMMC_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY(a) CR (a, EMMC_PEIM_HC_PRIVATE_DATA, EndOfPeiNotifyList, EMMC_PEIM_SIG)
78
79struct _EMMC_TRB {
81 UINT16 BlockSize;
82
83 EMMC_COMMAND_PACKET *Packet;
84 VOID *Data;
85 UINT32 DataLen;
86 BOOLEAN Read;
88 VOID *DataMap;
89 EMMC_HC_TRANSFER_MODE Mode;
90
91 UINT64 Timeout;
92
93 EMMC_HC_ADMA_DESC_LINE *AdmaDesc;
94 UINTN AdmaDescSize;
95};
96
117EFIAPI
119 IN EFI_PEI_SERVICES **PeiServices,
121 OUT UINTN *NumberBlockDevices
122 );
123
166EFIAPI
168 IN EFI_PEI_SERVICES **PeiServices,
170 IN UINTN DeviceIndex,
171 OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo
172 );
173
209EFIAPI
211 IN EFI_PEI_SERVICES **PeiServices,
213 IN UINTN DeviceIndex,
214 IN EFI_PEI_LBA StartLBA,
215 IN UINTN BufferSize,
216 OUT VOID *Buffer
217 );
218
239EFIAPI
241 IN EFI_PEI_SERVICES **PeiServices,
243 OUT UINTN *NumberBlockDevices
244 );
245
288EFIAPI
290 IN EFI_PEI_SERVICES **PeiServices,
292 IN UINTN DeviceIndex,
294 );
295
331EFIAPI
333 IN EFI_PEI_SERVICES **PeiServices,
335 IN UINTN DeviceIndex,
336 IN EFI_PEI_LBA StartLBA,
337 IN UINTN BufferSize,
338 OUT VOID *Buffer
339 );
340
353 );
354
367 );
368
379VOID *
382 IN UINTN Size
383 );
384
393VOID
396 IN VOID *Mem,
397 IN UINTN Size
398 );
399
403VOID
404IoMmuInit (
405 VOID
406 );
407
428IoMmuMap (
429 IN EDKII_IOMMU_OPERATION Operation,
430 IN VOID *HostAddress,
431 IN OUT UINTN *NumberOfBytes,
432 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
433 OUT VOID **Mapping
434 );
435
447 IN VOID *Mapping
448 );
449
470 IN UINTN Pages,
471 OUT VOID **HostAddress,
472 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
473 OUT VOID **Mapping
474 );
475
490 IN UINTN Pages,
491 IN VOID *HostAddress,
492 IN VOID *Mapping
493 );
494
507EFIAPI
509 IN EFI_PEI_SERVICES **PeiServices,
510 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
511 IN VOID *Ppi
512 );
513
514#endif
UINT64 UINTN
EFI_STATUS EFIAPI EmmcBlockIoPeimReadBlocks2(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)
EFI_STATUS EFIAPI EmmcBlockIoPeimGetDeviceNo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, OUT UINTN *NumberBlockDevices)
EFI_STATUS EFIAPI EmmcBlockIoPeimGetMediaInfo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, IN UINTN DeviceIndex, OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo)
EFI_STATUS IoMmuUnmap(IN VOID *Mapping)
Definition: DmaMem.c:132
EFI_STATUS EFIAPI EmmcBlockIoPeimGetDeviceNo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, OUT UINTN *NumberBlockDevices)
EFI_STATUS IoMmuAllocateBuffer(IN UINTN Pages, OUT VOID **HostAddress, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
Definition: DmaMem.c:170
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 EmmcBlockIoPeimGetMediaInfo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, IN UINTN DeviceIndex, OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo)
EFI_STATUS EmmcPeimFreeMemPool(IN EMMC_PEIM_MEM_POOL *Pool)
Definition: EmmcHcMem.c:263
VOID EmmcPeimFreeMem(IN EMMC_PEIM_MEM_POOL *Pool, IN VOID *Mem, IN UINTN Size)
Definition: EmmcHcMem.c:366
VOID * EmmcPeimAllocateMem(IN EMMC_PEIM_MEM_POOL *Pool, IN UINTN Size)
Definition: EmmcHcMem.c:294
EFI_STATUS EmmcPeimInitMemPool(IN EMMC_PEIM_HC_PRIVATE_DATA *Private)
Definition: EmmcHcMem.c:223
EFI_STATUS EFIAPI EmmcBlockIoPeimEndOfPei(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
EFI_STATUS EFIAPI EmmcBlockIoPeimReadBlocks(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)
EFI_STATUS IoMmuFreeBuffer(IN UINTN Pages, IN VOID *HostAddress, IN VOID *Mapping)
Definition: DmaMem.c:251
VOID IoMmuInit(VOID)
Definition: DmaMem.c:375
#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
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
Definition: Emmc.h:84