BoardBdsHook.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /** @file
  2. Header file for BDS Hook Library
  3. Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _BOARD_BDS_HOOK_H_
  7. #define _BOARD_BDS_HOOK_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/UgaDraw.h>
  19. #include <Protocol/GenericMemoryTest.h>
  20. #include <Protocol/DevicePathToText.h>
  21. #include <Protocol/FirmwareVolume2.h>
  22. #include <Protocol/SimpleFileSystem.h>
  23. #include <Guid/CapsuleVendor.h>
  24. #include <Guid/MemoryTypeInformation.h>
  25. #include <Guid/GlobalVariable.h>
  26. #include <Guid/MemoryOverwriteControl.h>
  27. #include <Guid/FileInfo.h>
  28. #include <Library/DebugLib.h>
  29. #include <Library/BaseMemoryLib.h>
  30. #include <Library/UefiBootServicesTableLib.h>
  31. #include <Library/UefiRuntimeServicesTableLib.h>
  32. #include <Library/MemoryAllocationLib.h>
  33. #include <Library/BaseLib.h>
  34. #include <Library/PcdLib.h>
  35. #include <Library/PlatformBootManagerLib.h>
  36. #include <Library/DevicePathLib.h>
  37. #include <Library/UefiLib.h>
  38. #include <Library/HobLib.h>
  39. #include <Library/DxeServicesLib.h>
  40. #include <Library/DxeServicesTableLib.h>
  41. #include <Library/PrintLib.h>
  42. #include <Library/HiiLib.h>
  43. #include <Library/CapsuleLib.h>
  44. #include <Library/PerformanceLib.h>
  45. #include <IndustryStandard/Pci30.h>
  46. #include <IndustryStandard/PciCodeId.h>
  47. #include <Protocol/PciEnumerationComplete.h>
  48. ///
  49. /// ConnectType
  50. ///
  51. #define CONSOLE_OUT 0x00000001
  52. #define STD_ERROR 0x00000002
  53. #define CONSOLE_IN 0x00000004
  54. #define CONSOLE_ALL (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
  55. extern EFI_GUID gUefiShellFileGuid;
  56. extern EFI_BOOT_MODE gBootMode;
  57. #define gPciRootBridge \
  58. { \
  59. { \
  60. ACPI_DEVICE_PATH, \
  61. ACPI_DP, \
  62. { \
  63. (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
  64. (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
  65. }, \
  66. }, \
  67. EISA_PNP_ID (0x0A03), \
  68. 0 \
  69. }
  70. #define gEndEntire \
  71. { \
  72. END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PATH_LENGTH, 0 } \
  73. }
  74. typedef struct {
  75. EFI_DEVICE_PATH_PROTOCOL *DevicePath;
  76. UINTN ConnectType;
  77. } BDS_CONSOLE_CONNECT_ENTRY;
  78. //
  79. // Platform Root Bridge
  80. //
  81. typedef struct {
  82. ACPI_HID_DEVICE_PATH PciRootBridge;
  83. EFI_DEVICE_PATH_PROTOCOL End;
  84. } PLATFORM_ROOT_BRIDGE_DEVICE_PATH;
  85. //
  86. // Below is the platform console device path
  87. //
  88. typedef struct {
  89. ACPI_HID_DEVICE_PATH PciRootBridge;
  90. PCI_DEVICE_PATH IsaBridge;
  91. ACPI_HID_DEVICE_PATH Keyboard;
  92. EFI_DEVICE_PATH_PROTOCOL End;
  93. } PLATFORM_KEYBOARD_DEVICE_PATH;
  94. typedef struct {
  95. ACPI_HID_DEVICE_PATH PciRootBridge;
  96. PCI_DEVICE_PATH PciDevice;
  97. EFI_DEVICE_PATH_PROTOCOL End;
  98. } PLATFORM_ONBOARD_CONTROLLER_DEVICE_PATH;
  99. typedef struct {
  100. ACPI_HID_DEVICE_PATH PciRootBridge;
  101. PCI_DEVICE_PATH Pci0Device;
  102. EFI_DEVICE_PATH_PROTOCOL End;
  103. } PLATFORM_PEG_ROOT_CONTROLLER_DEVICE_PATH;
  104. typedef struct {
  105. ACPI_HID_DEVICE_PATH PciRootBridge;
  106. PCI_DEVICE_PATH PciBridge;
  107. PCI_DEVICE_PATH PciDevice;
  108. EFI_DEVICE_PATH_PROTOCOL End;
  109. } PLATFORM_PCI_CONTROLLER_DEVICE_PATH;
  110. //
  111. // Below is the boot option device path
  112. //
  113. #define CLASS_HID 3
  114. #define SUBCLASS_BOOT 1
  115. #define PROTOCOL_KEYBOARD 1
  116. typedef struct {
  117. USB_CLASS_DEVICE_PATH UsbClass;
  118. EFI_DEVICE_PATH_PROTOCOL End;
  119. } USB_CLASS_FORMAT_DEVICE_PATH;
  120. extern USB_CLASS_FORMAT_DEVICE_PATH gUsbClassKeyboardDevicePath;
  121. //
  122. // Platform BDS Functions
  123. //
  124. /**
  125. Perform the memory test base on the memory test intensive level,
  126. and update the memory resource.
  127. @param Level The memory test intensive level.
  128. @retval EFI_STATUS Success test all the system memory and update
  129. the memory resource
  130. **/
  131. EFI_STATUS
  132. MemoryTest (
  133. IN EXTENDMEM_COVERAGE_LEVEL Level
  134. );
  135. /**
  136. Connect with predeined platform connect sequence,
  137. the OEM/IBV can customize with their own connect sequence.
  138. @param[in] BootMode Boot mode of this boot.
  139. **/
  140. VOID
  141. ConnectSequence (
  142. IN EFI_BOOT_MODE BootMode
  143. );
  144. /**
  145. Compares boot priorities of two boot options
  146. @param Left The left boot option
  147. @param Right The right boot option
  148. @return The difference between the Left and Right
  149. boot options
  150. **/
  151. INTN
  152. EFIAPI
  153. CompareBootOption (
  154. CONST VOID *Left,
  155. CONST VOID *Right
  156. );
  157. /**
  158. This function is called after all the boot options are enumerated and ordered properly.
  159. **/
  160. VOID
  161. RegisterStaticHotkey (
  162. VOID
  163. );
  164. /**
  165. Registers/Unregisters boot option hotkey
  166. @param OptionNumber The boot option number for the key option.
  167. @param Key The the key input
  168. @param Add Flag to indicate to add or remove a key
  169. **/
  170. VOID
  171. RegisterDefaultBootOption (
  172. VOID
  173. );
  174. #endif