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