Home | History | Annotate | Download | only in Ppi
      1 /** @file
      2   Provides the services required to access a block I/O 2 device during PEI recovery
      3   boot mode.
      4 
      5 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
      6 This program and the accompanying materials are licensed and made available under
      7 the terms and conditions of the BSD License that accompanies this distribution.
      8 The full text of the license may be found at
      9 http://opensource.org/licenses/bsd-license.php.
     10 
     11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     13 
     14   @par Revision Reference:
     15   This PPI is defined in UEFI Platform Initialization Specification 1.4 Volume 1:
     16   Pre-EFI Initalization Core Interface.
     17 
     18 **/
     19 
     20 #ifndef _PEI_BLOCK_IO2_H_
     21 #define _PEI_BLOCK_IO2_H_
     22 
     23 #include <Ppi/BlockIo.h>
     24 #include <Protocol/DevicePath.h>
     25 
     26 ///
     27 /// Global ID for EFI_PEI_RECOVERY_BLOCK_IO2_PPI
     28 ///
     29 #define EFI_PEI_RECOVERY_BLOCK_IO2_PPI_GUID \
     30   { \
     31     0x26cc0fad, 0xbeb3, 0x478a, { 0x91, 0xb2, 0xc, 0x18, 0x8f, 0x72, 0x61, 0x98 } \
     32   }
     33 
     34 ///
     35 /// The forward declaration for EFI_PEI_RECOVERY_BLOCK_IO_PPI.
     36 ///
     37 typedef struct _EFI_PEI_RECOVERY_BLOCK_IO2_PPI  EFI_PEI_RECOVERY_BLOCK_IO2_PPI;
     38 
     39 #define EFI_PEI_RECOVERY_BLOCK_IO2_PPI_REVISION 0x00010000
     40 
     41 typedef struct {
     42   ///
     43   /// A type of interface that the device being referenced by DeviceIndex is
     44   /// attached to. This field re-uses Messaging Device Path Node sub-type values
     45   /// as defined by Section 9.3.5 Messaging Device Path of UEFI Specification.
     46   /// When more than one sub-type is associated with the interface, sub-type with
     47   /// the smallest number must be used.
     48   ///
     49   UINT8                      InterfaceType;
     50   ///
     51   /// A flag that indicates if media is removable.
     52   ///
     53   BOOLEAN                    RemovableMedia;
     54   ///
     55   /// A flag that indicates if media is present. This flag is always set for
     56   /// non-removable media devices.
     57   ///
     58   BOOLEAN                    MediaPresent;
     59   ///
     60   /// A flag that indicates if media is read-only.
     61   ///
     62   BOOLEAN                    ReadOnly;
     63   ///
     64   /// The size of a logical block in bytes.
     65   ///
     66   UINT32                     BlockSize;
     67   ///
     68   /// The last logical block that the device supports.
     69   ///
     70   EFI_PEI_LBA                LastBlock;
     71 } EFI_PEI_BLOCK_IO2_MEDIA;
     72 
     73 /**
     74   Gets the count of block I/O devices that one specific block driver detects.
     75 
     76   This function is used for getting the count of block I/O devices that one
     77   specific block driver detects.  To the PEI ATAPI driver, it returns the number
     78   of all the detected ATAPI devices it detects during the enumeration process.
     79   To the PEI legacy floppy driver, it returns the number of all the legacy
     80   devices it finds during its enumeration process. If no device is detected,
     81   then the function will return zero.
     82 
     83   @param[in]  PeiServices          General-purpose services that are available
     84                                    to every PEIM.
     85   @param[in]  This                 Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI
     86                                    instance.
     87   @param[out] NumberBlockDevices   The number of block I/O devices discovered.
     88 
     89   @retval     EFI_SUCCESS          The operation performed successfully.
     90 
     91 **/
     92 typedef
     93 EFI_STATUS
     94 (EFIAPI *EFI_PEI_GET_NUMBER_BLOCK_DEVICES2)(
     95   IN  EFI_PEI_SERVICES               **PeiServices,
     96   IN  EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
     97   OUT UINTN                          *NumberBlockDevices
     98   );
     99 
    100 /**
    101   Gets a block device's media information.
    102 
    103   This function will provide the caller with the specified block device's media
    104   information. If the media changes, calling this function will update the media
    105   information accordingly.
    106 
    107   @param[in]  PeiServices   General-purpose services that are available to every
    108                             PEIM
    109   @param[in]  This          Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.
    110   @param[in]  DeviceIndex   Specifies the block device to which the function wants
    111                             to talk. Because the driver that implements Block I/O
    112                             PPIs will manage multiple block devices, the PPIs that
    113                             want to talk to a single device must specify the
    114                             device index that was assigned during the enumeration
    115                             process. This index is a number from one to
    116                             NumberBlockDevices.
    117   @param[out] MediaInfo     The media information of the specified block media.
    118                             The caller is responsible for the ownership of this
    119                             data structure.
    120 
    121   @par Note:
    122       The MediaInfo structure describes an enumeration of possible block device
    123       types.  This enumeration exists because no device paths are actually passed
    124       across interfaces that describe the type or class of hardware that is publishing
    125       the block I/O interface. This enumeration will allow for policy decisions
    126       in the Recovery PEIM, such as "Try to recover from legacy floppy first,
    127       LS-120 second, CD-ROM third." If there are multiple partitions abstracted
    128       by a given device type, they should be reported in ascending order; this
    129       order also applies to nested partitions, such as legacy MBR, where the
    130       outermost partitions would have precedence in the reporting order. The
    131       same logic applies to systems such as IDE that have precedence relationships
    132       like "Master/Slave" or "Primary/Secondary". The master device should be
    133       reported first, the slave second.
    134 
    135   @retval EFI_SUCCESS        Media information about the specified block device
    136                              was obtained successfully.
    137   @retval EFI_DEVICE_ERROR   Cannot get the media information due to a hardware
    138                              error.
    139 
    140 **/
    141 typedef
    142 EFI_STATUS
    143 (EFIAPI *EFI_PEI_GET_DEVICE_MEDIA_INFORMATION2)(
    144   IN  EFI_PEI_SERVICES               **PeiServices,
    145   IN  EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
    146   IN  UINTN                          DeviceIndex,
    147   OUT EFI_PEI_BLOCK_IO2_MEDIA        *MediaInfo
    148   );
    149 
    150 /**
    151   Reads the requested number of blocks from the specified block device.
    152 
    153   The function reads the requested number of blocks from the device. All the
    154   blocks are read, or an error is returned. If there is no media in the device,
    155   the function returns EFI_NO_MEDIA.
    156 
    157   @param[in]  PeiServices   General-purpose services that are available to
    158                             every PEIM.
    159   @param[in]  This          Indicates the EFI_PEI_RECOVERY_BLOCK_IO2_PPI instance.
    160   @param[in]  DeviceIndex   Specifies the block device to which the function wants
    161                             to talk. Because the driver that implements Block I/O
    162                             PPIs will manage multiple block devices, PPIs that
    163                             want to talk to a single device must specify the device
    164                             index that was assigned during the enumeration process.
    165                             This index is a number from one to NumberBlockDevices.
    166   @param[in]  StartLBA      The starting logical block address (LBA) to read from
    167                             on the device
    168   @param[in]  BufferSize    The size of the Buffer in bytes. This number must be
    169                             a multiple of the intrinsic block size of the device.
    170   @param[out] Buffer        A pointer to the destination buffer for the data.
    171                             The caller is responsible for the ownership of the
    172                             buffer.
    173 
    174   @retval EFI_SUCCESS             The data was read correctly from the device.
    175   @retval EFI_DEVICE_ERROR        The device reported an error while attempting
    176                                   to perform the read operation.
    177   @retval EFI_INVALID_PARAMETER   The read request contains LBAs that are not
    178                                   valid, or the buffer is not properly aligned.
    179   @retval EFI_NO_MEDIA            There is no media in the device.
    180   @retval EFI_BAD_BUFFER_SIZE     The BufferSize parameter is not a multiple of
    181                                   the intrinsic block size of the device.
    182 
    183 **/
    184 typedef
    185 EFI_STATUS
    186 (EFIAPI *EFI_PEI_READ_BLOCKS2)(
    187   IN  EFI_PEI_SERVICES               **PeiServices,
    188   IN  EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This,
    189   IN  UINTN                          DeviceIndex,
    190   IN  EFI_PEI_LBA                    StartLBA,
    191   IN  UINTN                          BufferSize,
    192   OUT VOID                           *Buffer
    193   );
    194 
    195 ///
    196 ///  EFI_PEI_RECOVERY_BLOCK_IO_PPI provides the services that are required
    197 ///  to access a block I/O device during PEI recovery boot mode.
    198 ///
    199 struct _EFI_PEI_RECOVERY_BLOCK_IO2_PPI {
    200   ///
    201   /// The revision to which the interface adheres.
    202   /// All future revisions must be backwards compatible.
    203   ///
    204   UINT64                                 Revision;
    205   ///
    206   /// Gets the number of block I/O devices that the specific block driver manages.
    207   ///
    208   EFI_PEI_GET_NUMBER_BLOCK_DEVICES2      GetNumberOfBlockDevices;
    209 
    210   ///
    211   /// Gets the specified media information.
    212   ///
    213   EFI_PEI_GET_DEVICE_MEDIA_INFORMATION2  GetBlockDeviceMediaInfo;
    214 
    215   ///
    216   /// Reads the requested number of blocks from the specified block device.
    217   ///
    218   EFI_PEI_READ_BLOCKS2                   ReadBlocks;
    219 };
    220 
    221 extern EFI_GUID gEfiPeiVirtualBlockIo2PpiGuid;
    222 
    223 #endif
    224