FvbSmmDxe.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /** @file
  2. The internal header file includes the common header files, defines
  3. internal structure and functions used by FVB module.
  4. Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved. <BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef _SMM_FVB_DXE_H_
  8. #define _SMM_FVB_DXE_H_
  9. #include <PiDxe.h>
  10. #include <Protocol/SmmFirmwareVolumeBlock.h>
  11. #include <Protocol/SmmCommunication.h>
  12. #include <Library/UefiBootServicesTableLib.h>
  13. #include <Library/UefiDriverEntryPoint.h>
  14. #include <Library/DebugLib.h>
  15. #include <Library/BaseMemoryLib.h>
  16. #include <Library/UefiLib.h>
  17. #include <Library/BaseLib.h>
  18. #include <Library/MemoryAllocationLib.h>
  19. #include <Library/DevicePathLib.h>
  20. #include <Guid/EventGroup.h>
  21. #include "FvbSmmCommon.h"
  22. #define FVB_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'V', 'B', 'S')
  23. #define FVB_DEVICE_FROM_THIS(a) CR (a, EFI_FVB_DEVICE, FvbInstance, FVB_DEVICE_SIGNATURE)
  24. typedef struct {
  25. MEDIA_FW_VOL_DEVICE_PATH FvDevPath;
  26. EFI_DEVICE_PATH_PROTOCOL EndDevPath;
  27. } FV_PIWG_DEVICE_PATH;
  28. typedef struct {
  29. MEMMAP_DEVICE_PATH MemMapDevPath;
  30. EFI_DEVICE_PATH_PROTOCOL EndDevPath;
  31. } FV_MEMMAP_DEVICE_PATH;
  32. typedef struct {
  33. UINTN Signature;
  34. EFI_DEVICE_PATH_PROTOCOL *DevicePath;
  35. EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FvbInstance;
  36. EFI_SMM_FIRMWARE_VOLUME_BLOCK_PROTOCOL *SmmFvbInstance;
  37. } EFI_FVB_DEVICE;
  38. /**
  39. This function retrieves the attributes and current settings of the block.
  40. @param[in] This Indicates the EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL instance.
  41. @param[out] Attributes Pointer to EFI_FVB_ATTRIBUTES_2 in which the attributes
  42. and current settings are returned. Type EFI_FVB_ATTRIBUTES_2
  43. is defined in EFI_FIRMWARE_VOLUME_HEADER.
  44. @retval EFI_SUCCESS The firmware volume attributes were returned.
  45. **/
  46. EFI_STATUS
  47. EFIAPI
  48. FvbGetAttributes (
  49. IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
  50. OUT EFI_FVB_ATTRIBUTES_2 *Attributes
  51. );
  52. /**
  53. Sets Volume attributes. No polarity translations are done.
  54. @param[in] This Calling context.
  55. @param[out] Attributes Output buffer which contains attributes.
  56. @retval EFI_SUCCESS The function always return successfully.
  57. **/
  58. EFI_STATUS
  59. EFIAPI
  60. FvbSetAttributes (
  61. IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
  62. IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
  63. );
  64. /**
  65. Retrieves the physical address of the device.
  66. @param[in] This A pointer to EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL.
  67. @param[out] Address Output buffer containing the address.
  68. @retval EFI_SUCCESS The function always return successfully.
  69. **/
  70. EFI_STATUS
  71. EFIAPI
  72. FvbGetPhysicalAddress (
  73. IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
  74. OUT EFI_PHYSICAL_ADDRESS *Address
  75. );
  76. /**
  77. Retrieve the size of a logical block.
  78. @param[in] This Calling context.
  79. @param[in] Lba Indicates which block to return the size for.
  80. @param[out] BlockSize A pointer to a caller allocated UINTN in which
  81. the size of the block is returned.
  82. @param[out] NumOfBlocks A pointer to a caller allocated UINTN in which the
  83. number of consecutive blocks starting with Lba is
  84. returned. All blocks in this range have a size of
  85. BlockSize.
  86. @retval EFI_SUCCESS The function always return successfully.
  87. **/
  88. EFI_STATUS
  89. EFIAPI
  90. FvbGetBlockSize (
  91. IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
  92. IN EFI_LBA Lba,
  93. OUT UINTN *BlockSize,
  94. OUT UINTN *NumOfBlocks
  95. );
  96. /**
  97. Reads data beginning at Lba:Offset from FV. The Read terminates either
  98. when *NumBytes of data have been read, or when a block boundary is
  99. reached. *NumBytes is updated to reflect the actual number of bytes
  100. written. The write opertion does not include erase. This routine will
  101. attempt to write only the specified bytes. If the writes do not stick,
  102. it will return an error.
  103. @param[in] This Calling context.
  104. @param[in] Lba Block in which to begin write.
  105. @param[in] Offset Offset in the block at which to begin write
  106. @param[in,out] NumBytes On input, indicates the requested write size. On
  107. output, indicates the actual number of bytes written
  108. @param[in] Buffer Buffer containing source data for the write.
  109. @retval EFI_SUCCESS The firmware volume was read successfully and
  110. contents are in Buffer
  111. @retval EFI_BAD_BUFFER_SIZE Read attempted across a LBA boundary. On output,
  112. NumBytes contains the total number of bytes returned
  113. in Buffer
  114. @retval EFI_ACCESS_DENIED The firmware volume is in the ReadDisabled state
  115. @retval EFI_DEVICE_ERROR The block device is not functioning correctly and
  116. could not be read
  117. @retval EFI_INVALID_PARAMETER NumBytes or Buffer are NULL
  118. **/
  119. EFI_STATUS
  120. EFIAPI
  121. FvbRead (
  122. IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
  123. IN EFI_LBA Lba,
  124. IN UINTN Offset,
  125. IN OUT UINTN *NumBytes,
  126. OUT UINT8 *Buffer
  127. );
  128. /**
  129. Writes data beginning at Lba:Offset from FV. The write terminates either
  130. when *NumBytes of data have been written, or when a block boundary is
  131. reached. *NumBytes is updated to reflect the actual number of bytes
  132. written. The write opertion does not include erase. This routine will
  133. attempt to write only the specified bytes. If the writes do not stick,
  134. it will return an error.
  135. @param[in] This Calling context.
  136. @param[in] Lba Block in which to begin write.
  137. @param[in] Offset Offset in the block at which to begin write.
  138. @param[in,out] NumBytes On input, indicates the requested write size. On
  139. output, indicates the actual number of bytes written
  140. @param[in] Buffer Buffer containing source data for the write.
  141. @retval EFI_SUCCESS The firmware volume was written successfully
  142. @retval EFI_BAD_BUFFER_SIZE Write attempted across a LBA boundary. On output,
  143. NumBytes contains the total number of bytes
  144. actually written.
  145. @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state
  146. @retval EFI_DEVICE_ERROR The block device is not functioning correctly and
  147. could not be written.
  148. @retval EFI_INVALID_PARAMETER NumBytes or Buffer are NULL.
  149. **/
  150. EFI_STATUS
  151. EFIAPI
  152. FvbWrite (
  153. IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
  154. IN EFI_LBA Lba,
  155. IN UINTN Offset,
  156. IN OUT UINTN *NumBytes,
  157. IN UINT8 *Buffer
  158. );
  159. /**
  160. The EraseBlock() function erases one or more blocks as denoted by the
  161. variable argument list. The entire parameter list of blocks must be verified
  162. prior to erasing any blocks. If a block is requested that does not exist
  163. within the associated firmware volume (it has a larger index than the last
  164. block of the firmware volume), the EraseBlock() function must return
  165. EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.
  166. @param[in] This Calling context.
  167. @param[in] ... Starting LBA followed by Number of Lba to erase.
  168. a -1 to terminate the list.
  169. @retval EFI_SUCCESS The erase request was successfully completed.
  170. @retval EFI_ACCESS_DENIED The firmware volume is in the WriteDisabled state
  171. @retval EFI_DEVICE_ERROR The block device is not functioning correctly and
  172. could not be written. Firmware device may have been
  173. partially erased.
  174. **/
  175. EFI_STATUS
  176. EFIAPI
  177. FvbEraseBlocks (
  178. IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
  179. ...
  180. );
  181. #endif