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