TianoCore EDK2 master
Loading...
Searching...
No Matches
EmmcDxe.h
Go to the documentation of this file.
1
12#ifndef _EMMC_DXE_H_
13#define _EMMC_DXE_H_
14
15#include <Uefi.h>
17
19#include <Protocol/BlockIo.h>
20#include <Protocol/BlockIo2.h>
22#include <Protocol/EraseBlock.h>
23#include <Protocol/DiskInfo.h>
24
25#include <Protocol/DevicePath.h>
26
27#include <Library/DebugLib.h>
29#include <Library/BaseLib.h>
30#include <Library/UefiLib.h>
36
37#include "EmmcBlockIo.h"
38#include "EmmcDiskInfo.h"
39
40//
41// Global Variables
42//
43extern EFI_DRIVER_BINDING_PROTOCOL gEmmcDxeDriverBinding;
44extern EFI_COMPONENT_NAME_PROTOCOL gEmmcDxeComponentName;
45extern EFI_COMPONENT_NAME2_PROTOCOL gEmmcDxeComponentName2;
46
47#define EMMC_PARTITION_SIGNATURE SIGNATURE_32 ('E', 'm', 'm', 'P')
48
49#define EMMC_PARTITION_DATA_FROM_BLKIO(a) \
50 CR(a, EMMC_PARTITION, BlockIo, EMMC_PARTITION_SIGNATURE)
51
52#define EMMC_PARTITION_DATA_FROM_BLKIO2(a) \
53 CR(a, EMMC_PARTITION, BlockIo2, EMMC_PARTITION_SIGNATURE)
54
55#define EMMC_PARTITION_DATA_FROM_SSP(a) \
56 CR(a, EMMC_PARTITION, StorageSecurity, EMMC_PARTITION_SIGNATURE)
57
58#define EMMC_PARTITION_DATA_FROM_ERASEBLK(a) \
59 CR(a, EMMC_PARTITION, EraseBlock, EMMC_PARTITION_SIGNATURE)
60
61#define EMMC_PARTITION_DATA_FROM_DISKINFO(a) \
62 CR(a, EMMC_PARTITION, DiskInfo, EMMC_PARTITION_SIGNATURE)
63
64//
65// Take 2.5 seconds as generic time out value, 1 microsecond as unit.
66//
67#define EMMC_GENERIC_TIMEOUT 2500 * 1000
68
69#define EMMC_REQUEST_SIGNATURE SIGNATURE_32 ('E', 'm', 'R', 'e')
70
71typedef struct _EMMC_DEVICE EMMC_DEVICE;
73
74//
75// Asynchronous I/O request.
76//
77typedef struct {
78 UINT32 Signature;
79 LIST_ENTRY Link;
80
81 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
82 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
84
85 BOOLEAN IsEnd;
86
88 EFI_EVENT Event;
90
91#define EMMC_REQUEST_FROM_LINK(a) \
92 CR(a, EMMC_REQUEST, Link, EMMC_REQUEST_SIGNATURE)
93
94typedef struct {
95 UINT32 Signature;
96 BOOLEAN Enable;
97 EMMC_PARTITION_TYPE PartitionType;
98 EFI_HANDLE Handle;
99 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
100 EFI_BLOCK_IO_PROTOCOL BlockIo;
101 EFI_BLOCK_IO2_PROTOCOL BlockIo2;
102 EFI_BLOCK_IO_MEDIA BlockMedia;
104 EFI_ERASE_BLOCK_PROTOCOL EraseBlock;
105 EFI_DISK_INFO_PROTOCOL DiskInfo;
106
107 LIST_ENTRY Queue;
108
109 EMMC_DEVICE *Device;
111
112//
113// Up to 6 slots per EMMC PCI host controller
114//
115#define EMMC_MAX_DEVICES 6
116//
117// Up to 8 partitions per EMMC device.
118//
119#define EMMC_MAX_PARTITIONS 8
120#define EMMC_MODEL_NAME_MAX_LEN 32
121
123 EFI_HANDLE Handle;
124 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
125 UINT8 Slot;
126 BOOLEAN SectorAddressing;
127
128 EMMC_PARTITION Partition[EMMC_MAX_PARTITIONS];
129 EMMC_CSD Csd;
130 EMMC_CID Cid;
131 EMMC_EXT_CSD ExtCsd;
132 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
133 //
134 // The model name consists of three fields in CID register
135 // 1) OEM/Application ID (2 bytes)
136 // 2) Product Name (5 bytes)
137 // 3) Product Serial Number (4 bytes)
138 // The delimiters of these fields are whitespace.
139 //
140 CHAR16 ModelName[EMMC_MODEL_NAME_MAX_LEN];
142};
143
144//
145// EMMC DXE driver private data structure
146//
149 EFI_HANDLE Controller;
150 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
151 EFI_HANDLE DriverBindingHandle;
152
153 EMMC_DEVICE Device[EMMC_MAX_DEVICES];
154};
155
199EFIAPI
202 IN EFI_HANDLE Controller,
203 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
204 );
205
242EFIAPI
245 IN EFI_HANDLE Controller,
246 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
247 );
248
276EFIAPI
279 IN EFI_HANDLE Controller,
280 IN UINTN NumberOfChildren,
281 IN EFI_HANDLE *ChildHandleBuffer
282 );
283
324EFIAPI
327 IN CHAR8 *Language,
328 OUT CHAR16 **DriverName
329 );
330
400EFIAPI
403 IN EFI_HANDLE ControllerHandle,
404 IN EFI_HANDLE ChildHandle OPTIONAL,
405 IN CHAR8 *Language,
406 OUT CHAR16 **ControllerName
407 );
408
422 IN EMMC_DEVICE *Device,
423 IN UINT16 Rca
424 );
425
440 IN EMMC_DEVICE *Device,
441 IN UINT16 Rca,
442 OUT UINT32 *DevStatus
443 );
444
459 IN EMMC_DEVICE *Device,
460 IN UINT16 Rca,
461 OUT EMMC_CSD *Csd
462 );
463
478 IN EMMC_DEVICE *Device,
479 IN UINT16 Rca,
480 OUT EMMC_CID *Cid
481 );
482
496 IN EMMC_DEVICE *Device,
497 OUT EMMC_EXT_CSD *ExtCsd
498 );
499
500#endif
UINT64 UINTN
EFI_STATUS EFIAPI EmmcDxeComponentNameGetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
EFI_STATUS EFIAPI EmmcDxeComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
Definition: ComponentName.c:86
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 EmmcSendStatus(IN EMMC_DEVICE *Device, IN UINT16 Rca, OUT UINT32 *DevStatus)
Definition: EmmcBlockIo.c:114
EFI_STATUS EmmcGetCsd(IN EMMC_DEVICE *Device, IN UINT16 Rca, OUT EMMC_CSD *Csd)
Definition: EmmcBlockIo.c:161
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 EmmcGetExtCsd(IN EMMC_DEVICE *Device, OUT EMMC_EXT_CSD *ExtCsd)
Definition: EmmcBlockIo.c:264
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 EmmcGetCid(IN EMMC_DEVICE *Device, IN UINT16 Rca, OUT EMMC_CID *Cid)
Definition: EmmcBlockIo.c:213
EFI_STATUS EmmcSelect(IN EMMC_DEVICE *Device, IN UINT16 Rca)
Definition: EmmcBlockIo.c:71
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
Definition: Emmc.h:71
Definition: Emmc.h:84