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