]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Ppi/BlockIo.h
MdePkg/Ppi: Fix various typos
[mirror_edk2.git] / MdePkg / Include / Ppi / BlockIo.h
CommitLineData
1cddf2ef 1/** @file\r
9095d37b 2 Provides the services required to access a block I/O device during PEI recovery\r
1cddf2ef 3 boot mode.\r
4\r
9095d37b
LG
5 The Recovery Module PPI and the Device Recovery Module PPI are device neutral.\r
6 This PPI is device specific and addresses the most common form of recovery\r
1cddf2ef 7 media-block I/O devices such as legacy floppy, CD-ROM, or IDE devices.\r
8\r
9095d37b
LG
9 The Recovery Block I/O PPI is used to access block devices. Because the Recovery\r
10 Block I/O PPIs that are provided by the PEI ATAPI driver and PEI legacy floppy\r
1cddf2ef 11 driver are the same, here we define a set of general PPIs for both drivers to use.\r
9095d37b
LG
12\r
13Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 14SPDX-License-Identifier: BSD-2-Clause-Patent\r
1cddf2ef 15\r
16 @par Revision Reference:\r
9095d37b 17 This PPI is defined in UEFI Platform Initialization Specification 1.2 Volume 1:\r
43516263 18 Pre-EFI Initialization Core Interface.\r
1cddf2ef 19\r
20**/\r
21\r
22#ifndef _PEI_BLOCK_IO_H_\r
23#define _PEI_BLOCK_IO_H_\r
24\r
25///\r
26/// Global ID for EFI_PEI_RECOVERY_BLOCK_IO_PPI\r
27///\r
28#define EFI_PEI_RECOVERY_BLOCK_IO_PPI_GUID \\r
29 { \\r
30 0x695d8aa1, 0x42ee, 0x4c46, { 0x80, 0x5c, 0x6e, 0xa6, 0xbc, 0xe7, 0x99, 0xe3 } \\r
31 }\r
32\r
33///\r
af2dc6a7 34/// The forward declaration for EFI_PEI_RECOVERY_BLOCK_IO_PPI.\r
1cddf2ef 35///\r
36typedef struct _EFI_PEI_RECOVERY_BLOCK_IO_PPI EFI_PEI_RECOVERY_BLOCK_IO_PPI;\r
37\r
38///\r
af2dc6a7 39/// All blocks on the recovery device are addressed with a 64-bit Logical Block Address (LBA).\r
1cddf2ef 40///\r
41typedef UINT64 EFI_PEI_LBA;\r
42\r
43///\r
44/// EFI_PEI_BLOCK_DEVICE_TYPE\r
45///\r
46typedef enum {\r
9095d37b 47 LegacyFloppy = 0, ///< The recovery device is a floppy.\r
1cddf2ef 48 IdeCDROM = 1, ///< The recovery device is an IDE CD-ROM\r
49 IdeLS120 = 2, ///< The recovery device is an IDE LS-120\r
50 UsbMassStorage= 3, ///< The recovery device is a USB Mass Storage device\r
52306166
FT
51 SD = 4, ///< The recovery device is a Secure Digital device\r
52 EMMC = 5, ///< The recovery device is a eMMC device\r
53 UfsDevice = 6, ///< The recovery device is a Universal Flash Storage device\r
1cddf2ef 54 MaxDeviceType\r
55} EFI_PEI_BLOCK_DEVICE_TYPE;\r
56\r
57///\r
9095d37b 58/// Specification inconsistency here:\r
1cddf2ef 59/// PEI_BLOCK_IO_MEDIA has been changed to EFI_PEI_BLOCK_IO_MEDIA.\r
9095d37b 60/// Inconsistency exists in UEFI Platform Initialization Specification 1.2\r
43516263 61/// Volume 1: Pre-EFI Initialization Core Interface, where all references to\r
9095d37b
LG
62/// this structure name are with the "EFI_" prefix, except for the definition\r
63/// which is without "EFI_". So the name of PEI_BLOCK_IO_MEDIA is taken as the\r
64/// exception, and EFI_PEI_BLOCK_IO_MEDIA is used to comply with most of\r
1cddf2ef 65/// the specification.\r
66///\r
67typedef struct {\r
68 ///\r
9095d37b 69 /// The type of media device being referenced by DeviceIndex.\r
1cddf2ef 70 ///\r
71 EFI_PEI_BLOCK_DEVICE_TYPE DeviceType;\r
72 ///\r
9095d37b 73 /// A flag that indicates if media is present. This flag is always set for\r
1cddf2ef 74 /// nonremovable media devices.\r
75 ///\r
76 BOOLEAN MediaPresent;\r
77 ///\r
78 /// The last logical block that the device supports.\r
79 ///\r
80 UINTN LastBlock;\r
81 ///\r
82 /// The size of a logical block in bytes.\r
83 ///\r
84 UINTN BlockSize;\r
85} EFI_PEI_BLOCK_IO_MEDIA;\r
86\r
87/**\r
88 Gets the count of block I/O devices that one specific block driver detects.\r
89\r
9095d37b 90 This function is used for getting the count of block I/O devices that one\r
1cddf2ef 91 specific block driver detects. To the PEI ATAPI driver, it returns the number\r
9095d37b
LG
92 of all the detected ATAPI devices it detects during the enumeration process.\r
93 To the PEI legacy floppy driver, it returns the number of all the legacy\r
94 devices it finds during its enumeration process. If no device is detected,\r
95 then the function will return zero.\r
96\r
97 @param[in] PeiServices General-purpose services that are available\r
1cddf2ef 98 to every PEIM.\r
9095d37b 99 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI\r
1cddf2ef 100 instance.\r
101 @param[out] NumberBlockDevices The number of block I/O devices discovered.\r
102\r
af2dc6a7 103 @retval EFI_SUCCESS The operation performed successfully.\r
d69f66d6 104\r
1cddf2ef 105**/\r
106typedef\r
107EFI_STATUS\r
108(EFIAPI *EFI_PEI_GET_NUMBER_BLOCK_DEVICES)(\r
109 IN EFI_PEI_SERVICES **PeiServices,\r
110 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r
111 OUT UINTN *NumberBlockDevices\r
112 );\r
113\r
114/**\r
115 Gets a block device's media information.\r
116\r
9095d37b
LG
117 This function will provide the caller with the specified block device's media\r
118 information. If the media changes, calling this function will update the media\r
1cddf2ef 119 information accordingly.\r
120\r
121 @param[in] PeiServices General-purpose services that are available to every\r
122 PEIM\r
123 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.\r
9095d37b
LG
124 @param[in] DeviceIndex Specifies the block device to which the function wants\r
125 to talk. Because the driver that implements Block I/O\r
126 PPIs will manage multiple block devices, the PPIs that\r
127 want to talk to a single device must specify the\r
1cddf2ef 128 device index that was assigned during the enumeration\r
9095d37b 129 process. This index is a number from one to\r
1cddf2ef 130 NumberBlockDevices.\r
9095d37b
LG
131 @param[out] MediaInfo The media information of the specified block media.\r
132 The caller is responsible for the ownership of this\r
1cddf2ef 133 data structure.\r
134\r
9095d37b
LG
135 @par Note:\r
136 The MediaInfo structure describes an enumeration of possible block device\r
137 types. This enumeration exists because no device paths are actually passed\r
138 across interfaces that describe the type or class of hardware that is publishing\r
1cddf2ef 139 the block I/O interface. This enumeration will allow for policy decisions\r
9095d37b
LG
140 in the Recovery PEIM, such as "Try to recover from legacy floppy first,\r
141 LS-120 second, CD-ROM third." If there are multiple partitions abstracted\r
142 by a given device type, they should be reported in ascending order; this\r
143 order also applies to nested partitions, such as legacy MBR, where the\r
144 outermost partitions would have precedence in the reporting order. The\r
145 same logic applies to systems such as IDE that have precedence relationships\r
146 like "Master/Slave" or "Primary/Secondary". The master device should be\r
1cddf2ef 147 reported first, the slave second.\r
9095d37b
LG
148\r
149 @retval EFI_SUCCESS Media information about the specified block device\r
1cddf2ef 150 was obtained successfully.\r
9095d37b 151 @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware\r
1cddf2ef 152 error.\r
153\r
154**/\r
155typedef\r
156EFI_STATUS\r
157(EFIAPI *EFI_PEI_GET_DEVICE_MEDIA_INFORMATION)(\r
158 IN EFI_PEI_SERVICES **PeiServices,\r
159 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r
160 IN UINTN DeviceIndex,\r
161 OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo\r
162 );\r
163\r
164/**\r
165 Reads the requested number of blocks from the specified block device.\r
166\r
9095d37b 167 The function reads the requested number of blocks from the device. All the\r
1cddf2ef 168 blocks are read, or an error is returned. If there is no media in the device,\r
169 the function returns EFI_NO_MEDIA.\r
170\r
9095d37b 171 @param[in] PeiServices General-purpose services that are available to\r
1cddf2ef 172 every PEIM.\r
173 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.\r
9095d37b
LG
174 @param[in] DeviceIndex Specifies the block device to which the function wants\r
175 to talk. Because the driver that implements Block I/O\r
176 PPIs will manage multiple block devices, PPIs that\r
177 want to talk to a single device must specify the device\r
178 index that was assigned during the enumeration process.\r
1cddf2ef 179 This index is a number from one to NumberBlockDevices.\r
180 @param[in] StartLBA The starting logical block address (LBA) to read from\r
181 on the device\r
182 @param[in] BufferSize The size of the Buffer in bytes. This number must be\r
183 a multiple of the intrinsic block size of the device.\r
184 @param[out] Buffer A pointer to the destination buffer for the data.\r
9095d37b 185 The caller is responsible for the ownership of the\r
1cddf2ef 186 buffer.\r
9095d37b 187\r
1cddf2ef 188 @retval EFI_SUCCESS The data was read correctly from the device.\r
9095d37b 189 @retval EFI_DEVICE_ERROR The device reported an error while attempting\r
1cddf2ef 190 to perform the read operation.\r
9095d37b 191 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not\r
1cddf2ef 192 valid, or the buffer is not properly aligned.\r
193 @retval EFI_NO_MEDIA There is no media in the device.\r
194 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of\r
195 the intrinsic block size of the device.\r
196\r
197**/\r
198typedef\r
199EFI_STATUS\r
200(EFIAPI *EFI_PEI_READ_BLOCKS)(\r
201 IN EFI_PEI_SERVICES **PeiServices,\r
202 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r
203 IN UINTN DeviceIndex,\r
204 IN EFI_PEI_LBA StartLBA,\r
205 IN UINTN BufferSize,\r
206 OUT VOID *Buffer\r
207 );\r
208\r
209///\r
210/// EFI_PEI_RECOVERY_BLOCK_IO_PPI provides the services that are required\r
211/// to access a block I/O device during PEI recovery boot mode.\r
212///\r
213struct _EFI_PEI_RECOVERY_BLOCK_IO_PPI {\r
214 ///\r
215 /// Gets the number of block I/O devices that the specific block driver manages.\r
216 ///\r
217 EFI_PEI_GET_NUMBER_BLOCK_DEVICES GetNumberOfBlockDevices;\r
9095d37b 218\r
1cddf2ef 219 ///\r
220 /// Gets the specified media information.\r
221 ///\r
222 EFI_PEI_GET_DEVICE_MEDIA_INFORMATION GetBlockDeviceMediaInfo;\r
9095d37b 223\r
1cddf2ef 224 ///\r
225 /// Reads the requested number of blocks from the specified block device.\r
226 ///\r
227 EFI_PEI_READ_BLOCKS ReadBlocks;\r
228};\r
229\r
230extern EFI_GUID gEfiPeiVirtualBlockIoPpiGuid;\r
231\r
232#endif\r