2 Provides the services required to access a block I/O 2 device during PEI recovery
5 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
8 @par Revision Reference:
9 This PPI is defined in UEFI Platform Initialization Specification 1.4 Volume 1:
10 Pre-EFI Initalization Core Interface.
14 #ifndef _PEI_BLOCK_IO2_H_
15 #define _PEI_BLOCK_IO2_H_
17 #include <Ppi/BlockIo.h>
18 #include <Protocol/DevicePath.h>
21 /// Global ID for EFI_PEI_RECOVERY_BLOCK_IO2_PPI
23 #define EFI_PEI_RECOVERY_BLOCK_IO2_PPI_GUID \
25 0x26cc0fad, 0xbeb3, 0x478a, { 0x91, 0xb2, 0xc, 0x18, 0x8f, 0x72, 0x61, 0x98 } \
29 /// The forward declaration for EFI_PEI_RECOVERY_BLOCK_IO_PPI.
31 typedef struct _EFI_PEI_RECOVERY_BLOCK_IO2_PPI EFI_PEI_RECOVERY_BLOCK_IO2_PPI
;
33 #define EFI_PEI_RECOVERY_BLOCK_IO2_PPI_REVISION 0x00010000
37 /// A type of interface that the device being referenced by DeviceIndex is
38 /// attached to. This field re-uses Messaging Device Path Node sub-type values
39 /// as defined by Section 9.3.5 Messaging Device Path of UEFI Specification.
40 /// When more than one sub-type is associated with the interface, sub-type with
41 /// the smallest number must be used.
45 /// A flag that indicates if media is removable.
47 BOOLEAN RemovableMedia
;
49 /// A flag that indicates if media is present. This flag is always set for
50 /// non-removable media devices.
54 /// A flag that indicates if media is read-only.
58 /// The size of a logical block in bytes.
62 /// The last logical block that the device supports.
64 EFI_PEI_LBA LastBlock
;
65 } EFI_PEI_BLOCK_IO2_MEDIA
;
68 Gets the count of block I/O devices that one specific block driver detects.
70 This function is used for getting the count of block I/O devices that one
71 specific block driver detects. To the PEI ATAPI driver, it returns the number
72 of all the detected ATAPI devices it detects during the enumeration process.
73 To the PEI legacy floppy driver, it returns the number of all the legacy
74 devices it finds during its enumeration process. If no device is detected,
75 then the function will return zero.
77 @param[in] PeiServices General-purpose services that are available
79 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI
81 @param[out] NumberBlockDevices The number of block I/O devices discovered.
83 @retval EFI_SUCCESS The operation performed successfully.
88 (EFIAPI
*EFI_PEI_GET_NUMBER_BLOCK_DEVICES2
)(
89 IN EFI_PEI_SERVICES
**PeiServices
,
90 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI
*This
,
91 OUT UINTN
*NumberBlockDevices
95 Gets a block device's media information.
97 This function will provide the caller with the specified block device's media
98 information. If the media changes, calling this function will update the media
99 information accordingly.
101 @param[in] PeiServices General-purpose services that are available to every
103 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.
104 @param[in] DeviceIndex Specifies the block device to which the function wants
105 to talk. Because the driver that implements Block I/O
106 PPIs will manage multiple block devices, the PPIs that
107 want to talk to a single device must specify the
108 device index that was assigned during the enumeration
109 process. This index is a number from one to
111 @param[out] MediaInfo The media information of the specified block media.
112 The caller is responsible for the ownership of this
116 The MediaInfo structure describes an enumeration of possible block device
117 types. This enumeration exists because no device paths are actually passed
118 across interfaces that describe the type or class of hardware that is publishing
119 the block I/O interface. This enumeration will allow for policy decisions
120 in the Recovery PEIM, such as "Try to recover from legacy floppy first,
121 LS-120 second, CD-ROM third." If there are multiple partitions abstracted
122 by a given device type, they should be reported in ascending order; this
123 order also applies to nested partitions, such as legacy MBR, where the
124 outermost partitions would have precedence in the reporting order. The
125 same logic applies to systems such as IDE that have precedence relationships
126 like "Master/Slave" or "Primary/Secondary". The master device should be
127 reported first, the slave second.
129 @retval EFI_SUCCESS Media information about the specified block device
130 was obtained successfully.
131 @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware
137 (EFIAPI
*EFI_PEI_GET_DEVICE_MEDIA_INFORMATION2
)(
138 IN EFI_PEI_SERVICES
**PeiServices
,
139 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI
*This
,
140 IN UINTN DeviceIndex
,
141 OUT EFI_PEI_BLOCK_IO2_MEDIA
*MediaInfo
145 Reads the requested number of blocks from the specified block device.
147 The function reads the requested number of blocks from the device. All the
148 blocks are read, or an error is returned. If there is no media in the device,
149 the function returns EFI_NO_MEDIA.
151 @param[in] PeiServices General-purpose services that are available to
153 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.
154 @param[in] DeviceIndex Specifies the block device to which the function wants
155 to talk. Because the driver that implements Block I/O
156 PPIs will manage multiple block devices, PPIs that
157 want to talk to a single device must specify the device
158 index that was assigned during the enumeration process.
159 This index is a number from one to NumberBlockDevices.
160 @param[in] StartLBA The starting logical block address (LBA) to read from
162 @param[in] BufferSize The size of the Buffer in bytes. This number must be
163 a multiple of the intrinsic block size of the device.
164 @param[out] Buffer A pointer to the destination buffer for the data.
165 The caller is responsible for the ownership of the
168 @retval EFI_SUCCESS The data was read correctly from the device.
169 @retval EFI_DEVICE_ERROR The device reported an error while attempting
170 to perform the read operation.
171 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not
172 valid, or the buffer is not properly aligned.
173 @retval EFI_NO_MEDIA There is no media in the device.
174 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of
175 the intrinsic block size of the device.
180 (EFIAPI
*EFI_PEI_READ_BLOCKS2
)(
181 IN EFI_PEI_SERVICES
**PeiServices
,
182 IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI
*This
,
183 IN UINTN DeviceIndex
,
184 IN EFI_PEI_LBA StartLBA
,
190 /// EFI_PEI_RECOVERY_BLOCK_IO_PPI provides the services that are required
191 /// to access a block I/O device during PEI recovery boot mode.
193 struct _EFI_PEI_RECOVERY_BLOCK_IO2_PPI
{
195 /// The revision to which the interface adheres.
196 /// All future revisions must be backwards compatible.
200 /// Gets the number of block I/O devices that the specific block driver manages.
202 EFI_PEI_GET_NUMBER_BLOCK_DEVICES2 GetNumberOfBlockDevices
;
205 /// Gets the specified media information.
207 EFI_PEI_GET_DEVICE_MEDIA_INFORMATION2 GetBlockDeviceMediaInfo
;
210 /// Reads the requested number of blocks from the specified block device.
212 EFI_PEI_READ_BLOCKS2 ReadBlocks
;
215 extern EFI_GUID gEfiPeiVirtualBlockIo2PpiGuid
;