PciPlatform.h 6.4 KB

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