BdsPlatform.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /** @file
  2. Header file for BDS Platform specific code
  3. Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _BDS_PLATFORM_H
  7. #define _BDS_PLATFORM_H
  8. #include <PiDxe.h>
  9. #include <Protocol/DevicePath.h>
  10. #include <Protocol/SimpleNetwork.h>
  11. #include <Protocol/PciRootBridgeIo.h>
  12. #include <Protocol/LoadFile.h>
  13. #include <Protocol/PciIo.h>
  14. #include <Protocol/CpuIo2.h>
  15. #include <Protocol/LoadedImage.h>
  16. #include <Protocol/DiskInfo.h>
  17. #include <Protocol/GraphicsOutput.h>
  18. #include <Protocol/GenericMemoryTest.h>
  19. #include <Protocol/DevicePathToText.h>
  20. #include <Protocol/FirmwareVolume2.h>
  21. #include <Protocol/SimpleFileSystem.h>
  22. #include <Guid/CapsuleVendor.h>
  23. #include <Guid/MemoryTypeInformation.h>
  24. #include <Guid/GlobalVariable.h>
  25. #include <Guid/MemoryOverwriteControl.h>
  26. #include <Guid/FileInfo.h>
  27. #include <Library/DebugLib.h>
  28. #include <Library/BaseMemoryLib.h>
  29. #include <Library/UefiBootServicesTableLib.h>
  30. #include <Library/UefiRuntimeServicesTableLib.h>
  31. #include <Library/MemoryAllocationLib.h>
  32. #include <Library/BaseLib.h>
  33. #include <Library/PcdLib.h>
  34. #include <Library/PlatformBootManagerLib.h>
  35. #include <Library/DevicePathLib.h>
  36. #include <Library/UefiLib.h>
  37. #include <Library/HobLib.h>
  38. #include <Library/DxeServicesLib.h>
  39. #include <Library/DxeServicesTableLib.h>
  40. #include <Library/PrintLib.h>
  41. #include <Library/HiiLib.h>
  42. #include <Library/CapsuleLib.h>
  43. #include <Library/PerformanceLib.h>
  44. #include <IndustryStandard/Pci30.h>
  45. #include <IndustryStandard/PciCodeId.h>
  46. ///
  47. /// ConnectType
  48. ///
  49. #define CONSOLE_OUT 0x00000001
  50. #define STD_ERROR 0x00000002
  51. #define CONSOLE_IN 0x00000004
  52. #define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
  53. extern EFI_GUID gUefiShellFileGuid;
  54. extern EFI_BOOT_MODE gBootMode;
  55. #define PCI_DEVICE_PATH_NODE(Func, Dev) \
  56. { \
  57. HARDWARE_DEVICE_PATH, \
  58. HW_PCI_DP, \
  59. { \
  60. (UINT8) (sizeof (PCI_DEVICE_PATH)), \
  61. (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \
  62. }, \
  63. (Func), \
  64. (Dev) \
  65. }
  66. #define PNPID_DEVICE_PATH_NODE(PnpId) \
  67. { \
  68. { \
  69. ACPI_DEVICE_PATH, \
  70. ACPI_DP, \
  71. { \
  72. (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
  73. (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
  74. } \
  75. }, \
  76. EISA_PNP_ID((PnpId)), \
  77. 0 \
  78. }
  79. #define gPciRootBridge \
  80. { \
  81. { \
  82. ACPI_DEVICE_PATH, \
  83. ACPI_DP, \
  84. { \
  85. (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
  86. (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
  87. }, \
  88. }, \
  89. EISA_PNP_ID (0x0A03), \
  90. 0 \
  91. }
  92. #define gPciIsaBridge \
  93. PCI_DEVICE_PATH_NODE(0, 0x1f)
  94. #define gPnp16550ComPort \
  95. PNPID_DEVICE_PATH_NODE(0x0501)
  96. #define gUart(BaudRate, DataBits, Parity, StopBits) \
  97. { \
  98. { \
  99. MESSAGING_DEVICE_PATH, \
  100. MSG_UART_DP, \
  101. { \
  102. (UINT8) (sizeof (UART_DEVICE_PATH)), \
  103. (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \
  104. } \
  105. }, \
  106. 0, \
  107. (BaudRate), \
  108. (DataBits), \
  109. (Parity), \
  110. (StopBits) \
  111. }
  112. #define gPcAnsiTerminal \
  113. { \
  114. { \
  115. MESSAGING_DEVICE_PATH, \
  116. MSG_VENDOR_DP, \
  117. { \
  118. (UINT8) (sizeof (VENDOR_DEVICE_PATH)), \
  119. (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \
  120. } \
  121. }, \
  122. DEVICE_PATH_MESSAGING_PC_ANSI \
  123. }
  124. #define gEndEntire \
  125. { \
  126. END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PATH_LENGTH, 0 } \
  127. }
  128. typedef struct {
  129. EFI_DEVICE_PATH_PROTOCOL *DevicePath;
  130. UINTN ConnectType;
  131. } BDS_CONSOLE_CONNECT_ENTRY;
  132. //
  133. // Platform Root Bridge
  134. //
  135. typedef struct {
  136. ACPI_HID_DEVICE_PATH PciRootBridge;
  137. EFI_DEVICE_PATH_PROTOCOL End;
  138. } PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
  139. //
  140. // Below is the platform console device path
  141. //
  142. typedef struct {
  143. ACPI_HID_DEVICE_PATH PciRootBridge;
  144. PCI_DEVICE_PATH IsaBridge;
  145. ACPI_HID_DEVICE_PATH Keyboard;
  146. EFI_DEVICE_PATH_PROTOCOL End;
  147. } PLATFORM_KEYBOARD_DEVICE_PATH;
  148. typedef struct {
  149. ACPI_HID_DEVICE_PATH PciRootBridge;
  150. PCI_DEVICE_PATH PciDevice;
  151. EFI_DEVICE_PATH_PROTOCOL End;
  152. } PLATFORM_ONBOARD_CONTROLLER_DEVICE_PATH;
  153. typedef struct {
  154. ACPI_HID_DEVICE_PATH PciRootBridge;
  155. PCI_DEVICE_PATH Pci0Device;
  156. EFI_DEVICE_PATH_PROTOCOL End;
  157. } PLATFORM_PEG_ROOT_CONTROLLER_DEVICE_PATH;
  158. typedef struct {
  159. ACPI_HID_DEVICE_PATH PciRootBridge;
  160. PCI_DEVICE_PATH PciBridge;
  161. PCI_DEVICE_PATH PciDevice;
  162. EFI_DEVICE_PATH_PROTOCOL End;
  163. } PLATFORM_PCI_CONTROLLER_DEVICE_PATH;
  164. //
  165. // Below is the boot option device path
  166. //
  167. #define CLASS_HID 3
  168. #define SUBCLASS_BOOT 1
  169. #define PROTOCOL_KEYBOARD 1
  170. typedef struct {
  171. USB_CLASS_DEVICE_PATH UsbClass;
  172. EFI_DEVICE_PATH_PROTOCOL End;
  173. } USB_CLASS_FORMAT_DEVICE_PATH;
  174. typedef struct {
  175. ACPI_HID_DEVICE_PATH PciRootBridge;
  176. PCI_DEVICE_PATH IsaBridge;
  177. ACPI_HID_DEVICE_PATH IsaSerial;
  178. UART_DEVICE_PATH Uart;
  179. VENDOR_DEVICE_PATH TerminalType;
  180. EFI_DEVICE_PATH_PROTOCOL End;
  181. } PLATFORM_ISA_SERIAL_DEVICE_PATH;
  182. //
  183. // Platform BDS Functions
  184. //
  185. /**
  186. Perform the memory test base on the memory test intensive level,
  187. and update the memory resource.
  188. @param Level The memory test intensive level.
  189. @retval EFI_STATUS Success test all the system memory and update
  190. the memory resource
  191. **/
  192. EFI_STATUS
  193. MemoryTest (
  194. IN EXTENDMEM_COVERAGE_LEVEL Level
  195. );
  196. VOID
  197. ConnectSequence (
  198. IN EFI_BOOT_MODE BootMode
  199. );
  200. INTN
  201. EFIAPI
  202. CompareBootOption (
  203. CONST VOID *Left,
  204. CONST VOID *Right
  205. );
  206. VOID
  207. RegisterStaticHotkey (
  208. VOID
  209. );
  210. VOID
  211. RegisterDefaultBootOption (
  212. VOID
  213. );
  214. #endif