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