PciPlatform.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /** @file
  2. This is PCI platform initialization code.
  3. @copyright
  4. Copyright 2004 - 2021 Intel Corporation. <BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #ifndef _PCI_PLATFORM_MODULE_H_
  8. #define _PCI_PLATFORM_MODULE_H_
  9. #include <PiDxe.h>
  10. #include <Register/PchRegsEva.h>
  11. #include <PchAccess.h>
  12. #include <Platform.h>
  13. #include <Library/BaseLib.h>
  14. #include <Library/BaseMemoryLib.h>
  15. #include <Library/DebugLib.h>
  16. #include <Library/S3PciLib.h>
  17. #include <Library/PciLib.h>
  18. #include <Library/UefiRuntimeServicesTableLib.h>
  19. #include <Library/MemoryAllocationLib.h>
  20. #include <Library/UefiBootServicesTableLib.h>
  21. #include <Library/HobLib.h>
  22. #include <Library/SetupLib.h>
  23. #include <Protocol/Runtime.h>
  24. #include <Protocol/CpuIo2.h>
  25. #include <Protocol/PciCallback.h>
  26. #include <Protocol/PciPlatform.h>
  27. #include <Protocol/PciIovPlatform.h>
  28. #include <Protocol/PciIo.h>
  29. #include <Protocol/FirmwareVolume2.h>
  30. #include <SystemBoard.h>
  31. #include <Guid/SetupVariable.h>
  32. #include <Guid/SocketVariable.h>
  33. #include <Guid/PlatformInfo.h>
  34. #include <IndustryStandard/Pci.h>
  35. #ifndef NELEMENTS
  36. #define NELEMENTS(Array) (sizeof(Array)/sizeof((Array)[0]))
  37. #endif
  38. //
  39. // Global variables for Option ROMs
  40. //
  41. #define INVALID 0xBD
  42. #define PCI_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('P', 'c', 'i', 'c')
  43. typedef struct {
  44. UINT32 Signature;
  45. LIST_ENTRY Link;
  46. EFI_PCI_CALLBACK_FUNC Function;
  47. EFI_PCI_ENUMERATION_PHASE Phase;
  48. } PCI_CALLBACK_DATA;
  49. typedef struct {
  50. EFI_HANDLE PciPlatformHandle;
  51. EFI_HANDLE RootBridgeHandle;
  52. EFI_PCI_PLATFORM_PROTOCOL PciPlatform;
  53. EFI_PCI_CALLBACK_PROTOCOL PciCallback;
  54. #ifdef EFI_PCI_IOV_SUPPORT
  55. EFI_PCI_IOV_PLATFORM_PROTOCOL PciIovPlatform;
  56. #endif
  57. EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo[MAX_SOCKET][MAX_IIO_STACK];
  58. EFI_CPU_IO2_PROTOCOL *CpuIo;
  59. EFI_LIST_ENTRY PciCallbackList;
  60. EFI_PCI_CALLBACK_CONTEXT Context;
  61. EFI_PCI_ENUMERATION_PHASE PciEnumerationPhase;
  62. EFI_PLATFORM_INFO *PlatformInfo;
  63. UINT8 BusAssignedTime;
  64. } PCI_PLATFORM_PRIVATE_DATA;
  65. #define PCI_CALLBACK_DATA_FROM_LINK(_node) \
  66. CR ( \
  67. _node, \
  68. PCI_CALLBACK_DATA, \
  69. Link, \
  70. PCI_CALLBACK_DATA_SIGNATURE \
  71. )
  72. extern PCI_PLATFORM_PRIVATE_DATA mPciPrivateData;
  73. extern EFI_GUID gPchSataEfiLoadProtocolGuid;
  74. /**
  75. Perform initialization by the phase indicated.
  76. @param This - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance.
  77. @param HostBridge - The associated PCI Host bridge handle.
  78. @param Phase - The phase of the PCI controller enumeration.
  79. @param ChipsetPhase - Defines the execution phase of the PCI chipset driver.
  80. @retval EFI_SUCCESS - Must return with success.
  81. **/
  82. EFI_STATUS
  83. EFIAPI
  84. PhaseNotify (
  85. IN EFI_PCI_PLATFORM_PROTOCOL *This,
  86. IN EFI_HANDLE HostBridge,
  87. IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase,
  88. IN EFI_PCI_CHIPSET_EXECUTION_PHASE ChipsetPhase
  89. )
  90. ;
  91. /**
  92. The PlatformPrepController() function can be used to notify the platform driver so that
  93. it can perform platform-specific actions. No specific actions are required.
  94. Several notification points are defined at this time. More synchronization points may be
  95. added as required in the future. The PCI bus driver calls the platform driver twice for
  96. every PCI controller-once before the PCI Host Bridge Resource Allocation Protocol driver
  97. is notified, and once after the PCI Host Bridge Resource Allocation Protocol driver has
  98. been notified.
  99. This member function may not perform any error checking on the input parameters. It also
  100. does not return any error codes. If this member function detects any error condition, it
  101. needs to handle those errors on its own because there is no way to surface any errors to
  102. the caller.
  103. @param This - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance.
  104. @param HostBridge - The associated PCI Host bridge handle.
  105. @param RootBridge - The associated PCI root bridge handle.
  106. @param PciAddress - The address of the PCI device on the PCI bus.
  107. @param Phase - The phase of the PCI controller enumeration.
  108. @param ChipsetPhase - Defines the execution phase of the PCI chipset driver.
  109. @retval EFI_SUCCESS - The function completed successfully.
  110. **/
  111. EFI_STATUS
  112. EFIAPI
  113. PlatformPrepController (
  114. IN EFI_PCI_PLATFORM_PROTOCOL *This,
  115. IN EFI_HANDLE HostBridge,
  116. IN EFI_HANDLE RootBridge,
  117. IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,
  118. IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase,
  119. IN EFI_PCI_CHIPSET_EXECUTION_PHASE ChipsetPhase
  120. )
  121. ;
  122. /**
  123. Set the PciPolicy as EFI_RESERVE_ISA_IO_NO_ALIAS | EFI_RESERVE_VGA_IO_NO_ALIAS.
  124. @param This - The pointer to the Protocol itself.
  125. PciPolicy - the returned Policy.
  126. @retval EFI_UNSUPPORTED - Function not supported.
  127. @retval EFI_INVALID_PARAMETER - Invalid PciPolicy value.
  128. **/
  129. EFI_STATUS
  130. EFIAPI
  131. GetPlatformPolicy (
  132. IN CONST EFI_PCI_PLATFORM_PROTOCOL *This,
  133. OUT EFI_PCI_PLATFORM_POLICY *PciPolicy
  134. )
  135. ;
  136. /**
  137. Return a PCI ROM image for the onboard device represented by PciHandle.
  138. @param This - Protocol instance pointer.
  139. PciHandle - PCI device to return the ROM image for.
  140. RomImage - PCI Rom Image for onboard device.
  141. RomSize - Size of RomImage in bytes.
  142. @retval EFI_SUCCESS - RomImage is valid.
  143. @retval EFI_NOT_FOUND - No RomImage.
  144. **/
  145. EFI_STATUS
  146. EFIAPI
  147. GetPciRom (
  148. IN CONST EFI_PCI_PLATFORM_PROTOCOL *This,
  149. IN EFI_HANDLE PciHandle,
  150. OUT VOID **RomImage,
  151. OUT UINTN *RomSize
  152. )
  153. ;
  154. /**
  155. Register a callback during PCI bus enumeration
  156. @param This - Protocol instance pointer.
  157. @param Function - Callback function pointer.
  158. @param Phase - PCI enumeration phase.
  159. @retval EFI_SUCCESS - Function has registed successfully
  160. @retval EFI_UNSUPPORTED - The function has been regisered
  161. @retval EFI_InVALID_PARAMETER - The parameter is incorrect
  162. **/
  163. EFI_STATUS
  164. EFIAPI
  165. RegisterPciCallback (
  166. IN EFI_PCI_CALLBACK_PROTOCOL *This,
  167. IN EFI_PCI_CALLBACK_FUNC Function,
  168. IN EFI_PCI_ENUMERATION_PHASE Phase
  169. )
  170. ;
  171. #endif