TianoCore EDK2 master
Loading...
Searching...
No Matches
SdDxe.h
Go to the documentation of this file.
1
12#ifndef _SD_DXE_H_
13#define _SD_DXE_H_
14
15#include <Uefi.h>
16#include <IndustryStandard/Sd.h>
17
19#include <Protocol/BlockIo.h>
20#include <Protocol/BlockIo2.h>
21#include <Protocol/EraseBlock.h>
22#include <Protocol/DiskInfo.h>
23
24#include <Protocol/DevicePath.h>
25
26#include <Library/DebugLib.h>
28#include <Library/BaseLib.h>
29#include <Library/UefiLib.h>
35
36#include "SdBlockIo.h"
37#include "SdDiskInfo.h"
38
39//
40// Global Variables
41//
42extern EFI_DRIVER_BINDING_PROTOCOL gSdDxeDriverBinding;
43extern EFI_COMPONENT_NAME_PROTOCOL gSdDxeComponentName;
44extern EFI_COMPONENT_NAME2_PROTOCOL gSdDxeComponentName2;
45
46#define SD_DEVICE_SIGNATURE SIGNATURE_32 ('S', 'D', 't', 'f')
47
48#define SD_DEVICE_DATA_FROM_BLKIO(a) \
49 CR(a, SD_DEVICE, BlockIo, SD_DEVICE_SIGNATURE)
50
51#define SD_DEVICE_DATA_FROM_BLKIO2(a) \
52 CR(a, SD_DEVICE, BlockIo2, SD_DEVICE_SIGNATURE)
53
54#define SD_DEVICE_DATA_FROM_ERASEBLK(a) \
55 CR(a, SD_DEVICE, EraseBlock, SD_DEVICE_SIGNATURE)
56
57#define SD_DEVICE_DATA_FROM_DISKINFO(a) \
58 CR(a, SD_DEVICE, DiskInfo, SD_DEVICE_SIGNATURE)
59
60//
61// Take 2.5 seconds as generic time out value, 1 microsecond as unit.
62//
63#define SD_GENERIC_TIMEOUT 2500 * 1000
64
65#define SD_REQUEST_SIGNATURE SIGNATURE_32 ('S', 'D', 'R', 'E')
66
67#define SD_MODEL_NAME_MAX_LEN 32
68
69typedef struct _SD_DEVICE SD_DEVICE;
71
72//
73// Asynchronous I/O request.
74//
75typedef struct {
76 UINT32 Signature;
77 LIST_ENTRY Link;
78
79 EFI_SD_MMC_COMMAND_BLOCK SdMmcCmdBlk;
80 EFI_SD_MMC_STATUS_BLOCK SdMmcStatusBlk;
82
83 BOOLEAN IsEnd;
84
86
87 EFI_EVENT Event;
89
90#define SD_REQUEST_FROM_LINK(a) \
91 CR(a, SD_REQUEST, Link, SD_REQUEST_SIGNATURE)
92
93struct _SD_DEVICE {
94 UINT32 Signature;
95 EFI_HANDLE Handle;
96 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
97 UINT8 Slot;
98 BOOLEAN SectorAddressing;
100 EFI_BLOCK_IO2_PROTOCOL BlockIo2;
101 EFI_BLOCK_IO_MEDIA BlockMedia;
102 EFI_ERASE_BLOCK_PROTOCOL EraseBlock;
103 EFI_DISK_INFO_PROTOCOL DiskInfo;
104
105 LIST_ENTRY Queue;
106
107 SD_CSD Csd;
108 SD_CID Cid;
109 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
110 //
111 // The model name consists of three fields in CID register
112 // 1) OEM/Application ID (2 bytes)
113 // 2) Product Name (5 bytes)
114 // 3) Product Serial Number (4 bytes)
115 // The delimiters of these fields are whitespace.
116 //
117 CHAR16 ModelName[SD_MODEL_NAME_MAX_LEN];
118 SD_DRIVER_PRIVATE_DATA *Private;
119};
120
121//
122// SD DXE driver private data structure
123//
126 EFI_HANDLE Controller;
127 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
128 EFI_HANDLE DriverBindingHandle;
129};
130
174EFIAPI
177 IN EFI_HANDLE Controller,
178 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
179 );
180
217EFIAPI
220 IN EFI_HANDLE Controller,
221 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
222 );
223
251EFIAPI
254 IN EFI_HANDLE Controller,
255 IN UINTN NumberOfChildren,
256 IN EFI_HANDLE *ChildHandleBuffer
257 );
258
299EFIAPI
302 IN CHAR8 *Language,
303 OUT CHAR16 **DriverName
304 );
305
375EFIAPI
378 IN EFI_HANDLE ControllerHandle,
379 IN EFI_HANDLE ChildHandle OPTIONAL,
380 IN CHAR8 *Language,
381 OUT CHAR16 **ControllerName
382 );
383
396SdSetRca (
397 IN SD_DEVICE *Device,
398 OUT UINT16 *Rca
399 );
400
413SdSelect (
414 IN SD_DEVICE *Device,
415 IN UINT16 Rca
416 );
417
431 IN SD_DEVICE *Device,
432 IN UINT16 Rca,
433 OUT UINT32 *DevStatus
434 );
435
449SdGetCsd (
450 IN SD_DEVICE *Device,
451 IN UINT16 Rca,
452 OUT SD_CSD *Csd
453 );
454
468SdGetCid (
469 IN SD_DEVICE *Device,
470 IN UINT16 Rca,
471 OUT SD_CID *Cid
472 );
473
474#endif
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_STATUS EFIAPI SdDxeComponentNameGetDriverName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
Definition: ComponentName.c:86
EFI_STATUS SdSelect(IN SD_DEVICE *Device, IN UINT16 Rca)
Definition: SdBlockIo.c:112
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 SdGetCsd(IN SD_DEVICE *Device, IN UINT16 Rca, OUT SD_CSD *Csd)
Definition: SdBlockIo.c:205
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 SdSendStatus(IN SD_DEVICE *Device, IN UINT16 Rca, OUT UINT32 *DevStatus)
Definition: SdBlockIo.c:158
EFI_STATUS SdSetRca(IN SD_DEVICE *Device, OUT UINT16 *Rca)
Definition: SdBlockIo.c:67
EFI_STATUS EFIAPI SdDxeComponentNameGetControllerName(IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
EFI_STATUS SdGetCid(IN SD_DEVICE *Device, IN UINT16 Rca, OUT SD_CID *Cid)
Definition: SdBlockIo.c:258
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
Definition: Sd.h:66
Definition: Sd.h:78