PciHotPlug.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /** @file
  2. Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #ifndef _PCI_HOT_PLUG_H_
  6. #define _PCI_HOT_PLUG_H_
  7. //
  8. // External include files do NOT need to be explicitly specified in real EDKII
  9. // environment
  10. //
  11. #include <Base.h>
  12. #include <Library/UefiBootServicesTableLib.h>
  13. #include <Library/UefiRuntimeServicesTableLib.h>
  14. #include <Library/DebugLib.h>
  15. #include <Library/BaseMemoryLib.h>
  16. #include <Library/MemoryAllocationLib.h>
  17. #include <IndustryStandard/Acpi10.h>
  18. #include <Protocol/PciHotPlugInit.h>
  19. #include <Protocol/PciRootBridgeIo.h>
  20. #include <Library/DevicePathLib.h>
  21. #include <Library/UefiLib.h>
  22. #include <Guid/HobList.h>
  23. #include <Library/HobLib.h>
  24. #include <Protocol/SaPolicy.h>
  25. #define PCI_HOT_PLUG_DRIVER_PRIVATE_SIGNATURE SIGNATURE_32 ('G', 'U', 'L', 'P')
  26. #define ACPI \
  27. { \
  28. { ACPI_DEVICE_PATH, ACPI_DP, { (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), (UINT8) \
  29. ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) } }, EISA_PNP_ID (0x0A03), 0 \
  30. }
  31. #define PCI(device, function) \
  32. { \
  33. { HARDWARE_DEVICE_PATH, HW_PCI_DP, { (UINT8) (sizeof (PCI_DEVICE_PATH)), (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) } }, \
  34. (UINTN) function, (UINTN) device \
  35. }
  36. #define END \
  37. { \
  38. END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, { END_DEVICE_PATH_LENGTH, 0 } \
  39. }
  40. #define LPC(eisaid, function) \
  41. { \
  42. { ACPI_DEVICE_PATH, ACPI_DP, { (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), (UINT8) \
  43. ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) } }, EISA_PNP_ID (eisaid), function \
  44. }
  45. typedef struct PCIE_HOT_PLUG_DEVICE_PATH {
  46. ACPI_HID_DEVICE_PATH PciRootBridgeNode;
  47. PCI_DEVICE_PATH PciRootPortNode;
  48. EFI_DEVICE_PATH_PROTOCOL EndDeviceNode;
  49. } PCIE_HOT_PLUG_DEVICE_PATH;
  50. typedef struct {
  51. UINTN Signature;
  52. EFI_HANDLE Handle; // Handle for protocol this driver installs on
  53. EFI_PCI_HOT_PLUG_INIT_PROTOCOL HotPlugInitProtocol;
  54. } PCI_HOT_PLUG_INSTANCE;
  55. /**
  56. This procedure returns a list of Root Hot Plug controllers that require
  57. initialization during boot process
  58. @param[in] This The pointer to the instance of the EFI_PCI_HOT_PLUG_INIT protocol.
  59. @param[out] HpcCount The number of Root HPCs returned.
  60. @param[out] HpcList The list of Root HPCs. HpcCount defines the number of elements in this list.
  61. @retval EFI_SUCCESS.
  62. **/
  63. EFI_STATUS
  64. EFIAPI
  65. GetRootHpcList (
  66. IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This,
  67. OUT UINTN *PhpcCount,
  68. OUT EFI_HPC_LOCATION **PhpcList
  69. );
  70. /**
  71. This procedure Initializes one Root Hot Plug Controller
  72. This process may casue initialization of its subordinate buses
  73. @param[in] This The pointer to the instance of the EFI_PCI_HOT_PLUG_INIT protocol.
  74. @param[in] HpcDevicePath The Device Path to the HPC that is being initialized.
  75. @param[in] HpcPciAddress The address of the Hot Plug Controller function on the PCI bus.
  76. @param[in] Event The event that should be signaled when the Hot Plug Controller initialization is complete. Set to NULL if the caller wants to wait until the entire initialization process is complete. The event must be of the type EFI_EVT_SIGNAL.
  77. @param[out] HpcState The state of the Hot Plug Controller hardware. The type EFI_Hpc_STATE is defined in section 3.1.
  78. @retval EFI_SUCCESS.
  79. **/
  80. EFI_STATUS
  81. EFIAPI
  82. InitializeRootHpc (
  83. IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This,
  84. IN EFI_DEVICE_PATH_PROTOCOL *PhpcDevicePath,
  85. IN UINT64 PhpcPciAddress,
  86. IN EFI_EVENT Event, OPTIONAL
  87. OUT EFI_HPC_STATE *PhpcState
  88. );
  89. /**
  90. Returns the resource padding required by the PCI bus that is controlled by the specified Hot Plug Controller.
  91. @param[in] This The pointer to the instance of the EFI_PCI_HOT_PLUG_INIT protocol. initialized.
  92. @param[in] HpcDevicePath The Device Path to the Hot Plug Controller.
  93. @param[in] HpcPciAddress The address of the Hot Plug Controller function on the PCI bus.
  94. @param[out] HpcState The state of the Hot Plug Controller hardware. The type EFI_HPC_STATE is defined in section 3.1.
  95. @param[out] Padding This is the amount of resource padding required by the PCI bus under the control of the specified Hpc. Since the caller does not know the size of this buffer, this buffer is allocated by the callee and freed by the caller.
  96. @param[out] Attribute Describes how padding is accounted for.
  97. @retval EFI_SUCCESS.
  98. **/
  99. EFI_STATUS
  100. EFIAPI
  101. GetResourcePadding (
  102. IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This,
  103. IN EFI_DEVICE_PATH_PROTOCOL *PhpcDevicePath,
  104. IN UINT64 PhpcPciAddress,
  105. OUT EFI_HPC_STATE *PhpcState,
  106. OUT VOID **Padding,
  107. OUT EFI_HPC_PADDING_ATTRIBUTES *Attributes
  108. );
  109. #endif