Home | History | Annotate | Download | only in Protocol
      1 /** @file
      2   This file declares the Firmware Volume Protocol.
      3 
      4   The Firmware Volume Protocol provides file-level access to the firmware volume.
      5   Each firmware volume driver must produce an instance of the Firmware Volume
      6   Protocol if the firmware volume is to be visible to the system. The Firmware
      7   Volume Protocol also provides mechanisms for determining and modifying some
      8   attributes of the firmware volume.
      9 
     10 Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
     11 This program and the accompanying materials are licensed and made available under
     12 the terms and conditions of the BSD License that accompanies this distribution.
     13 The full text of the license may be found at
     14 http://opensource.org/licenses/bsd-license.php.
     15 
     16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     17 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     18 
     19   @par Revision Reference:
     20   This protocol is defined in Firmware Volume specification.
     21   Version 0.9.
     22 
     23 **/
     24 
     25 #ifndef _FIRMWARE_VOLUME_H_
     26 #define _FIRMWARE_VOLUME_H_
     27 
     28 
     29 //
     30 // Firmware Volume Protocol GUID definition
     31 //
     32 #define EFI_FIRMWARE_VOLUME_PROTOCOL_GUID \
     33   { \
     34     0x389F751F, 0x1838, 0x4388, {0x83, 0x90, 0xCD, 0x81, 0x54, 0xBD, 0x27, 0xF8 } \
     35   }
     36 
     37 #define FV_DEVICE_SIGNATURE SIGNATURE_32 ('_', 'F', 'V', '_')
     38 
     39 typedef struct _EFI_FIRMWARE_VOLUME_PROTOCOL  EFI_FIRMWARE_VOLUME_PROTOCOL;
     40 
     41 //
     42 // FRAMEWORK_EFI_FV_ATTRIBUTES bit definitions
     43 //
     44 typedef UINT64  FRAMEWORK_EFI_FV_ATTRIBUTES;
     45 
     46 //
     47 // ************************************************************
     48 // FRAMEWORK_EFI_FV_ATTRIBUTES bit definitions
     49 // ************************************************************
     50 //
     51 #define EFI_FV_READ_DISABLE_CAP       0x0000000000000001ULL
     52 #define EFI_FV_READ_ENABLE_CAP        0x0000000000000002ULL
     53 #define EFI_FV_READ_STATUS            0x0000000000000004ULL
     54 
     55 #define EFI_FV_WRITE_DISABLE_CAP      0x0000000000000008ULL
     56 #define EFI_FV_WRITE_ENABLE_CAP       0x0000000000000010ULL
     57 #define EFI_FV_WRITE_STATUS           0x0000000000000020ULL
     58 
     59 #define EFI_FV_LOCK_CAP               0x0000000000000040ULL
     60 #define EFI_FV_LOCK_STATUS            0x0000000000000080ULL
     61 #define EFI_FV_WRITE_POLICY_RELIABLE  0x0000000000000100ULL
     62 
     63 #define EFI_FV_ALIGNMENT_CAP          0x0000000000008000ULL
     64 #define EFI_FV_ALIGNMENT_2            0x0000000000010000ULL
     65 #define EFI_FV_ALIGNMENT_4            0x0000000000020000ULL
     66 #define EFI_FV_ALIGNMENT_8            0x0000000000040000ULL
     67 #define EFI_FV_ALIGNMENT_16           0x0000000000080000ULL
     68 #define EFI_FV_ALIGNMENT_32           0x0000000000100000ULL
     69 #define EFI_FV_ALIGNMENT_64           0x0000000000200000ULL
     70 #define EFI_FV_ALIGNMENT_128          0x0000000000400000ULL
     71 #define EFI_FV_ALIGNMENT_256          0x0000000000800000ULL
     72 #define EFI_FV_ALIGNMENT_512          0x0000000001000000ULL
     73 #define EFI_FV_ALIGNMENT_1K           0x0000000002000000ULL
     74 #define EFI_FV_ALIGNMENT_2K           0x0000000004000000ULL
     75 #define EFI_FV_ALIGNMENT_4K           0x0000000008000000ULL
     76 #define EFI_FV_ALIGNMENT_8K           0x0000000010000000ULL
     77 #define EFI_FV_ALIGNMENT_16K          0x0000000020000000ULL
     78 #define EFI_FV_ALIGNMENT_32K          0x0000000040000000ULL
     79 #define EFI_FV_ALIGNMENT_64K          0x0000000080000000ULL
     80 
     81 //
     82 // Protocol API definitions
     83 //
     84 
     85 /**
     86   Retrieves attributes, insures positive polarity of attribute bits, and returns
     87   resulting attributes in an output parameter.
     88 
     89   @param  This                  Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
     90   @param  Attributes            Output buffer containing attributes.
     91 
     92   @retval EFI_SUCCESS           The firmware volume attributes were returned.
     93 **/
     94 typedef
     95 EFI_STATUS
     96 (EFIAPI *FRAMEWORK_EFI_FV_GET_ATTRIBUTES)(
     97   IN  EFI_FIRMWARE_VOLUME_PROTOCOL            *This,
     98   OUT FRAMEWORK_EFI_FV_ATTRIBUTES             *Attributes
     99   );
    100 
    101 /**
    102   Sets volume attributes
    103 
    104   @param  This                  Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
    105   @param  Attributes            On input, Attributes is a pointer to an
    106                                 EFI_FV_ATTRIBUTES containing the desired firmware
    107                                 volume settings. On successful return, it contains
    108                                 the new settings of the firmware volume. On
    109                                 unsuccessful return, Attributes is not modified
    110                                 and the firmware volume settings are not changed.
    111 
    112   @retval EFI_INVALID_PARAMETER A bit in Attributes was invalid.
    113   @retval EFI_SUCCESS           The requested firmware volume attributes were set
    114                                 and the resulting EFI_FV_ATTRIBUTES is returned in
    115                                 Attributes.
    116   @retval EFI_ACCESS_DENIED     The Device is locked and does not permit modification.
    117 
    118 **/
    119 typedef
    120 EFI_STATUS
    121 (EFIAPI *FRAMEWORK_EFI_FV_SET_ATTRIBUTES)(
    122   IN EFI_FIRMWARE_VOLUME_PROTOCOL       *This,
    123   IN OUT FRAMEWORK_EFI_FV_ATTRIBUTES    *Attributes
    124   );
    125 
    126 /**
    127   Read the requested file (NameGuid) or file information from the firmware volume
    128   and returns data in Buffer.
    129 
    130   @param  This                  The EFI_FIRMWARE_VOLUME_PROTOCOL instance.
    131   @param  NameGuid              The pointer to EFI_GUID, which is the filename of
    132                                 the file to read.
    133   @param  Buffer                The pointer to pointer to buffer in which contents of file are returned.
    134                                 <br>
    135                                 If Buffer is NULL, only type, attributes, and size
    136                                 are returned as there is no output buffer.
    137                                 <br>
    138                                 If Buffer != NULL and *Buffer == NULL, the output
    139                                 buffer is allocated from BS pool by ReadFile.
    140                                 <br>
    141                                 If Buffer != NULL and *Buffer != NULL, the output
    142                                 buffer has been allocated by the caller and is being
    143                                 passed in.
    144   @param  BufferSize            On input: The buffer size. On output: The size
    145                                 required to complete the read.
    146   @param  FoundType             The pointer to the type of the file whose data
    147                                 is returned.
    148   @param  FileAttributes        The pointer to attributes of the file whose data
    149                                 is returned.
    150   @param  AuthenticationStatus  The pointer to the authentication status of the data.
    151 
    152   @retval EFI_SUCCESS               The call completed successfully.
    153   @retval EFI_WARN_BUFFER_TOO_SMALL The buffer is too small to contain the requested output.
    154                                     The buffer filled, and the output is truncated.
    155   @retval EFI_NOT_FOUND             NameGuid was not found in the firmware volume.
    156   @retval EFI_DEVICE_ERROR          A hardware error occurred when attempting to
    157                                     access the firmware volume.
    158   @retval EFI_ACCESS_DENIED         The firmware volume is configured to disallow reads.
    159   @retval EFI_OUT_OF_RESOURCES      An allocation failure occurred.
    160 
    161 **/
    162 typedef
    163 EFI_STATUS
    164 (EFIAPI *FRAMEWORK_EFI_FV_READ_FILE)(
    165   IN EFI_FIRMWARE_VOLUME_PROTOCOL   *This,
    166   IN EFI_GUID                       *NameGuid,
    167   IN OUT VOID                       **Buffer,
    168   IN OUT UINTN                      *BufferSize,
    169   OUT EFI_FV_FILETYPE               *FoundType,
    170   OUT EFI_FV_FILE_ATTRIBUTES        *FileAttributes,
    171   OUT UINT32                        *AuthenticationStatus
    172   );
    173 
    174 /**
    175   Read the requested section from the specified file and returns data in Buffer.
    176 
    177   @param  This                  Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
    178   @param  NameGuid              Filename identifying the file from which to read.
    179   @param  SectionType           The section type to retrieve.
    180   @param  SectionInstance       The instance of SectionType to retrieve.
    181   @param  Buffer                Pointer to pointer to buffer in which contents of
    182                                 a file are returned.
    183                                 <br>
    184                                 If Buffer is NULL, only type, attributes, and size
    185                                 are returned as there is no output buffer.
    186                                 <br>
    187                                 If Buffer != NULL and *Buffer == NULL, the output
    188                                 buffer is allocated from BS pool by ReadFile.
    189                                 <br>
    190                                 If Buffer != NULL and *Buffer != NULL, the output
    191                                 buffer has been allocated by the caller and is being
    192                                 passed in.
    193   @param  BufferSize            The pointer to the buffer size passed in, and on
    194                                 output the size required to complete the read.
    195   @param  AuthenticationStatus  The pointer to the authentication status of the data.
    196 
    197   @retval EFI_SUCCESS                The call completed successfully.
    198   @retval EFI_WARN_BUFFER_TOO_SMALL  The buffer is too small to contain the requested output.
    199                                      The buffer is filled and the output is truncated.
    200   @retval EFI_OUT_OF_RESOURCES       An allocation failure occurred.
    201   @retval EFI_NOT_FOUND              The name was not found in the firmware volume.
    202   @retval EFI_DEVICE_ERROR           A hardware error occurred when attempting to
    203                                      access the firmware volume.
    204   @retval EFI_ACCESS_DENIED          The firmware volume is configured to disallow reads.
    205 
    206 **/
    207 typedef
    208 EFI_STATUS
    209 (EFIAPI *FRAMEWORK_EFI_FV_READ_SECTION)(
    210   IN EFI_FIRMWARE_VOLUME_PROTOCOL   *This,
    211   IN EFI_GUID                       *NameGuid,
    212   IN EFI_SECTION_TYPE               SectionType,
    213   IN UINTN                          SectionInstance,
    214   IN OUT VOID                       **Buffer,
    215   IN OUT UINTN                      *BufferSize,
    216   OUT UINT32                        *AuthenticationStatus
    217   );
    218 
    219 typedef UINT32  FRAMEWORK_EFI_FV_WRITE_POLICY;
    220 
    221 #define FRAMEWORK_EFI_FV_UNRELIABLE_WRITE 0x00000000
    222 #define FRAMEWORK_EFI_FV_RELIABLE_WRITE   0x00000001
    223 
    224 typedef struct {
    225   EFI_GUID                *NameGuid;
    226   EFI_FV_FILETYPE         Type;
    227   EFI_FV_FILE_ATTRIBUTES  FileAttributes;
    228   VOID                    *Buffer;
    229   UINT32                  BufferSize;
    230 } FRAMEWORK_EFI_FV_WRITE_FILE_DATA;
    231 
    232 /**
    233   Write the supplied file (NameGuid) to the FV.
    234 
    235   @param  This                  Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
    236   @param  NumberOfFiles         Indicates the number of file records pointed to
    237                                 by FileData.
    238   @param  WritePolicy           Indicates the level of reliability of the write
    239                                 with respect to things like power failure events.
    240   @param  FileData              A pointer to an array of EFI_FV_WRITE_FILE_DATA
    241                                 structures. Each element in the array indicates
    242                                 a file to write, and there are NumberOfFiles
    243                                 elements in the input array.
    244 
    245   @retval EFI_SUCCESS           The write completed successfully.
    246   @retval EFI_OUT_OF_RESOURCES  The firmware volume does not have enough free
    247                                 space to store file(s).
    248   @retval EFI_DEVICE_ERROR      A hardware error occurred when attempting to
    249                                 access the firmware volume.
    250   @retval EFI_WRITE_PROTECTED   The firmware volume is configured to disallow writes.
    251   @retval EFI_NOT_FOUND         A delete was requested, but the requested file was
    252                                 not found in the firmware volume.
    253   @retval EFI_INVALID_PARAMETER A delete was requested with a multiple file write.
    254                                 An unsupported WritePolicy was requested.
    255                                 An unknown file type was specified.
    256                                 A file system specific error has occurred.
    257 **/
    258 typedef
    259 EFI_STATUS
    260 (EFIAPI *FRAMEWORK_EFI_FV_WRITE_FILE)(
    261   IN EFI_FIRMWARE_VOLUME_PROTOCOL             *This,
    262   IN UINT32                                   NumberOfFiles,
    263   IN FRAMEWORK_EFI_FV_WRITE_POLICY            WritePolicy,
    264   IN FRAMEWORK_EFI_FV_WRITE_FILE_DATA         *FileData
    265   );
    266 
    267 /**
    268   Given the input key, search for the next matching file in the volume.
    269 
    270   @param  This                  Indicates the EFI_FIRMWARE_VOLUME_PROTOCOL instance.
    271   @param  Key                   Pointer to a caller allocated buffer that contains
    272                                 an implementation-specific key that is used to track
    273                                 where to begin searching on successive calls.
    274   @param  FileType              The pointer to the file type to filter for.
    275   @param  NameGuid              The pointer to Guid filename of the file found.
    276   @param  Attributes            The pointer to Attributes of the file found.
    277   @param  Size                  The pointer to Size in bytes of the file found.
    278 
    279   @retval EFI_SUCCESS           The output parameters are filled with data obtained from
    280                                 the first matching file that was found.
    281   @retval EFI_NOT_FOUND         No files of type FileType were found.
    282   @retval EFI_DEVICE_ERROR      A hardware error occurred when attempting to access
    283                                 the firmware volume.
    284   @retval EFI_ACCESS_DENIED     The firmware volume is configured to disallow reads.
    285 
    286 **/
    287 typedef
    288 EFI_STATUS
    289 (EFIAPI *FRAMEWORK_EFI_FV_GET_NEXT_FILE)(
    290   IN EFI_FIRMWARE_VOLUME_PROTOCOL   *This,
    291   IN OUT VOID                       *Key,
    292   IN OUT EFI_FV_FILETYPE            *FileType,
    293   OUT EFI_GUID                      *NameGuid,
    294   OUT EFI_FV_FILE_ATTRIBUTES        *Attributes,
    295   OUT UINTN                         *Size
    296   );
    297 
    298 //
    299 // Protocol interface structure
    300 //
    301 struct _EFI_FIRMWARE_VOLUME_PROTOCOL {
    302   ///
    303   /// Retrieves volume capabilities and current settings.
    304   ///
    305   FRAMEWORK_EFI_FV_GET_ATTRIBUTES GetVolumeAttributes;
    306 
    307   ///
    308   /// Modifies the current settings of the firmware volume.
    309   ///
    310   FRAMEWORK_EFI_FV_SET_ATTRIBUTES SetVolumeAttributes;
    311 
    312   ///
    313   /// Reads an entire file from the firmware volume.
    314   ///
    315   FRAMEWORK_EFI_FV_READ_FILE      ReadFile;
    316 
    317   ///
    318   /// Reads a single section from a file into a buffer.
    319   ///
    320   FRAMEWORK_EFI_FV_READ_SECTION   ReadSection;
    321 
    322   ///
    323   /// Writes an entire file into the firmware volume.
    324   ///
    325   FRAMEWORK_EFI_FV_WRITE_FILE     WriteFile;
    326 
    327   ///
    328   /// Provides service to allow searching the firmware volume.
    329   ///
    330   FRAMEWORK_EFI_FV_GET_NEXT_FILE  GetNextFile;
    331 
    332   ///
    333   ///  Data field that indicates the size in bytes of the Key input buffer for
    334   ///  the GetNextFile() API.
    335   ///
    336   UINT32                KeySize;
    337 
    338   ///
    339   ///  Handle of the parent firmware volume.
    340   ///
    341   EFI_HANDLE            ParentHandle;
    342 };
    343 
    344 extern EFI_GUID gEfiFirmwareVolumeProtocolGuid;
    345 
    346 #endif
    347