PlatformHelperLib.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. /** @file
  2. PlatformHelperLib function prototype definitions.
  3. Copyright (c) 2013 - 2016 Intel Corporation.
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef __PLATFORM_HELPER_LIB_H__
  7. #define __PLATFORM_HELPER_LIB_H__
  8. #include "Platform.h"
  9. //
  10. // Function prototypes for routines exported by this library.
  11. //
  12. /**
  13. Find pointer to RAW data in Firmware volume file.
  14. @param FvNameGuid Firmware volume to search. If == NULL search all.
  15. @param FileNameGuid Firmware volume file to search for.
  16. @param SectionData Pointer to RAW data section of found file.
  17. @param SectionDataSize Pointer to UNITN to get size of RAW data.
  18. @retval EFI_SUCCESS Raw Data found.
  19. @retval EFI_INVALID_PARAMETER FileNameGuid == NULL.
  20. @retval EFI_NOT_FOUND Firmware volume file not found.
  21. @retval EFI_UNSUPPORTED Unsupported in current enviroment (PEI or DXE).
  22. **/
  23. EFI_STATUS
  24. EFIAPI
  25. PlatformFindFvFileRawDataSection (
  26. IN CONST EFI_GUID *FvNameGuid OPTIONAL,
  27. IN CONST EFI_GUID *FileNameGuid,
  28. OUT VOID **SectionData,
  29. OUT UINTN *SectionDataSize
  30. );
  31. /**
  32. Find free spi protect register and write to it to protect a flash region.
  33. @param DirectValue Value to directly write to register.
  34. if DirectValue == 0 the use Base & Length below.
  35. @param BaseAddress Base address of region in Flash Memory Map.
  36. @param Length Length of region to protect.
  37. @retval EFI_SUCCESS Free spi protect register found & written.
  38. @retval EFI_NOT_FOUND Free Spi protect register not found.
  39. @retval EFI_DEVICE_ERROR Unable to write to spi protect register.
  40. **/
  41. EFI_STATUS
  42. EFIAPI
  43. PlatformWriteFirstFreeSpiProtect (
  44. IN CONST UINT32 DirectValue,
  45. IN CONST UINT32 BaseAddress,
  46. IN CONST UINT32 Length
  47. );
  48. /**
  49. Lock legacy SPI static configuration information.
  50. Function will assert if unable to lock config.
  51. **/
  52. VOID
  53. EFIAPI
  54. PlatformFlashLockConfig (
  55. VOID
  56. );
  57. /**
  58. Lock regions and config of SPI flash given the policy for this platform.
  59. Function will assert if unable to lock regions or config.
  60. @param PreBootPolicy If TRUE do Pre Boot Flash Lock Policy.
  61. **/
  62. VOID
  63. EFIAPI
  64. PlatformFlashLockPolicy (
  65. IN CONST BOOLEAN PreBootPolicy
  66. );
  67. /** Check if System booted with recovery Boot Stage1 image.
  68. @retval TRUE If system booted with recovery Boot Stage1 image.
  69. @retval FALSE If system booted with normal stage1 image.
  70. **/
  71. BOOLEAN
  72. EFIAPI
  73. PlatformIsBootWithRecoveryStage1 (
  74. VOID
  75. );
  76. /**
  77. Clear SPI Protect registers.
  78. @retval EFI_SUCESS SPI protect registers cleared.
  79. @retval EFI_ACCESS_DENIED Unable to clear SPI protect registers.
  80. **/
  81. EFI_STATUS
  82. EFIAPI
  83. PlatformClearSpiProtect (
  84. VOID
  85. );
  86. /**
  87. Determine if an SPI address range is protected.
  88. @param SpiBaseAddress Base of SPI range.
  89. @param Length Length of SPI range.
  90. @retval TRUE Range is protected.
  91. @retval FALSE Range is not protected.
  92. **/
  93. BOOLEAN
  94. EFIAPI
  95. PlatformIsSpiRangeProtected (
  96. IN CONST UINT32 SpiBaseAddress,
  97. IN CONST UINT32 Length
  98. );
  99. /**
  100. Set Legacy GPIO Level
  101. @param LevelRegOffset GPIO level register Offset from GPIO Base Address.
  102. @param GpioNum GPIO bit to change.
  103. @param HighLevel If TRUE set GPIO High else Set GPIO low.
  104. **/
  105. VOID
  106. EFIAPI
  107. PlatformLegacyGpioSetLevel (
  108. IN CONST UINT32 LevelRegOffset,
  109. IN CONST UINT32 GpioNum,
  110. IN CONST BOOLEAN HighLevel
  111. );
  112. /**
  113. Get Legacy GPIO Level
  114. @param LevelRegOffset GPIO level register Offset from GPIO Base Address.
  115. @param GpioNum GPIO bit to check.
  116. @retval TRUE If bit is SET.
  117. @retval FALSE If bit is CLEAR.
  118. **/
  119. BOOLEAN
  120. EFIAPI
  121. PlatformLegacyGpioGetLevel (
  122. IN CONST UINT32 LevelRegOffset,
  123. IN CONST UINT32 GpioNum
  124. );
  125. /**
  126. Set the direction of Pcal9555 IO Expander GPIO pin.
  127. @param Pcal9555SlaveAddr I2c Slave address of Pcal9555 Io Expander.
  128. @param GpioNum Gpio direction to configure - values 0-7 for Port0
  129. and 8-15 for Port1.
  130. @param CfgAsInput If TRUE set pin direction as input else set as output.
  131. **/
  132. VOID
  133. EFIAPI
  134. PlatformPcal9555GpioSetDir (
  135. IN CONST UINT32 Pcal9555SlaveAddr,
  136. IN CONST UINT32 GpioNum,
  137. IN CONST BOOLEAN CfgAsInput
  138. );
  139. /**
  140. Set the level of Pcal9555 IO Expander GPIO high or low.
  141. @param Pcal9555SlaveAddr I2c Slave address of Pcal9555 Io Expander.
  142. @param GpioNum Gpio to change values 0-7 for Port0 and 8-15
  143. for Port1.
  144. @param HighLevel If TRUE set pin high else set pin low.
  145. **/
  146. VOID
  147. EFIAPI
  148. PlatformPcal9555GpioSetLevel (
  149. IN CONST UINT32 Pcal9555SlaveAddr,
  150. IN CONST UINT32 GpioNum,
  151. IN CONST BOOLEAN HighLevel
  152. );
  153. /**
  154. Enable pull-up/pull-down resistors of Pcal9555 GPIOs.
  155. @param Pcal9555SlaveAddr I2c Slave address of Pcal9555 Io Expander.
  156. @param GpioNum Gpio to change values 0-7 for Port0 and 8-15
  157. for Port1.
  158. **/
  159. VOID
  160. EFIAPI
  161. PlatformPcal9555GpioEnablePull (
  162. IN CONST UINT32 Pcal9555SlaveAddr,
  163. IN CONST UINT32 GpioNum
  164. );
  165. /**
  166. Disable pull-up/pull-down resistors of Pcal9555 GPIOs.
  167. @param Pcal9555SlaveAddr I2c Slave address of Pcal9555 Io Expander.
  168. @param GpioNum Gpio to change values 0-7 for Port0 and 8-15
  169. for Port1.
  170. **/
  171. VOID
  172. EFIAPI
  173. PlatformPcal9555GpioDisablePull (
  174. IN CONST UINT32 Pcal9555SlaveAddr,
  175. IN CONST UINT32 GpioNum
  176. );
  177. BOOLEAN
  178. EFIAPI
  179. PlatformPcal9555GpioGetState (
  180. IN CONST UINT32 Pcal9555SlaveAddr,
  181. IN CONST UINT32 GpioNum
  182. );
  183. /**
  184. Init platform LEDs into known state.
  185. @param PlatformType Executing platform type.
  186. @retval EFI_SUCCESS Operation success.
  187. **/
  188. EFI_STATUS
  189. EFIAPI
  190. PlatformLedInit (
  191. IN CONST EFI_PLATFORM_TYPE Type
  192. );
  193. /**
  194. Turn on or off platform flash update LED.
  195. @param PlatformType Executing platform type.
  196. @param TurnOn If TRUE turn on else turn off.
  197. @retval EFI_SUCCESS Operation success.
  198. **/
  199. EFI_STATUS
  200. EFIAPI
  201. PlatformFlashUpdateLed (
  202. IN CONST EFI_PLATFORM_TYPE Type,
  203. IN CONST BOOLEAN TurnOn
  204. );
  205. #endif // #ifndef __PLATFORM_HELPER_LIB_H__