]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.h
MdeModulePkg: Add generic PciHostBridgeDxe driver.
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciHostBridgeDxe / PciHostBridge.h
diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.h b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.h
new file mode 100644 (file)
index 0000000..288823c
--- /dev/null
@@ -0,0 +1,252 @@
+/** @file\r
+\r
+  The Header file of the Pci Host Bridge Driver.\r
+\r
+Copyright (c) 1999 - 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _PCI_HOST_BRIDGE_H_\r
+#define _PCI_HOST_BRIDGE_H_\r
+\r
+\r
+#include <PiDxe.h>\r
+#include <IndustryStandard/Acpi.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PciHostBridgeLib.h>\r
+#include <Protocol/PciHostBridgeResourceAllocation.h>\r
+\r
+#include "PciRootBridge.h"\r
+\r
+#define PCI_HOST_BRIDGE_SIGNATURE SIGNATURE_32 ('p', 'h', 'b', 'g')\r
+typedef struct {\r
+  UINTN                                             Signature;\r
+  EFI_HANDLE                                        Handle;\r
+  LIST_ENTRY                                        RootBridges;\r
+  BOOLEAN                                           CanRestarted;\r
+  EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL  ResAlloc;\r
+} PCI_HOST_BRIDGE_INSTANCE;\r
+\r
+#define PCI_HOST_BRIDGE_FROM_THIS(a) CR (a, PCI_HOST_BRIDGE_INSTANCE, ResAlloc, PCI_HOST_BRIDGE_SIGNATURE)\r
+\r
+//\r
+// Driver Entry Point\r
+//\r
+/**\r
+\r
+  Entry point of this driver.\r
+\r
+  @param ImageHandle  -  Image handle of this driver.\r
+  @param SystemTable  -  Pointer to standard EFI system table.\r
+\r
+  @retval EFI_SUCCESS       -  Succeed.\r
+  @retval EFI_DEVICE_ERROR  -  Fail to install PCI_ROOT_BRIDGE_IO protocol.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializePciHostBridge (\r
+  IN EFI_HANDLE         ImageHandle,\r
+  IN EFI_SYSTEM_TABLE   *SystemTable\r
+  );\r
+\r
+//\r
+//  HostBridge Resource Allocation interface\r
+//\r
+/**\r
+\r
+  Enter a certain phase of the PCI enumeration process.\r
+\r
+  @param This   -  The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance.\r
+  @param Phase  -  The phase during enumeration.\r
+\r
+  @retval EFI_SUCCESS            -  Succeed.\r
+  @retval EFI_INVALID_PARAMETER  -  Wrong phase parameter passed in.\r
+  @retval EFI_NOT_READY          -  Resources have not been submitted yet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+NotifyPhase (\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL   *This,\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE      Phase\r
+  );\r
+\r
+/**\r
+\r
+  Return the device handle of the next PCI root bridge that is associated with\r
+  this Host Bridge.\r
+\r
+  @param This              - The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.\r
+  RootBridgeHandle  -  Returns the device handle of the next PCI Root Bridge.\r
+                       On input, it holds the RootBridgeHandle returned by the most\r
+                       recent call to GetNextRootBridge().The handle for the first\r
+                       PCI Root Bridge is returned if RootBridgeHandle is NULL on input.\r
+\r
+  @retval EFI_SUCCESS            -  Succeed.\r
+  @retval EFI_NOT_FOUND          -  Next PCI root bridge not found.\r
+  @retval EFI_INVALID_PARAMETER  -  Wrong parameter passed in.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetNextRootBridge (\r
+  IN     EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
+  IN OUT EFI_HANDLE                                       *RootBridgeHandle\r
+  );\r
+\r
+/**\r
+\r
+  Returns the attributes of a PCI Root Bridge.\r
+\r
+  @param This              -  The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance\r
+  @param RootBridgeHandle  -  The device handle of the PCI Root Bridge\r
+                              that the caller is interested in\r
+  @param Attributes        -  The pointer to attributes of the PCI Root Bridge\r
+\r
+  @retval EFI_SUCCESS            -  Succeed.\r
+  @retval EFI_INVALID_PARAMETER  -  Attributes parameter passed in is NULL or\r
+                            @retval RootBridgeHandle is not an EFI_HANDLE\r
+                            @retval that was returned on a previous call to\r
+                            @retval GetNextRootBridge().\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetAttributes (\r
+  IN  EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
+  IN  EFI_HANDLE                                       RootBridgeHandle,\r
+  OUT UINT64                                           *Attributes\r
+  );\r
+\r
+/**\r
+\r
+  This is the request from the PCI enumerator to set up\r
+  the specified PCI Root Bridge for bus enumeration process.\r
+\r
+  @param This              -  The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.\r
+  @param RootBridgeHandle  -  The PCI Root Bridge to be set up.\r
+  @param Configuration     -  Pointer to the pointer to the PCI bus resource descriptor.\r
+\r
+  @retval EFI_SUCCESS            -  Succeed.\r
+  @retval EFI_OUT_OF_RESOURCES   -  Not enough pool to be allocated.\r
+  @retval EFI_INVALID_PARAMETER  -  RootBridgeHandle is not a valid handle.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+StartBusEnumeration (\r
+  IN  EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
+  IN  EFI_HANDLE                                       RootBridgeHandle,\r
+  OUT VOID                                             **Configuration\r
+  );\r
+\r
+/**\r
+\r
+  This function programs the PCI Root Bridge hardware so that\r
+  it decodes the specified PCI bus range.\r
+\r
+  @param This              -  The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.\r
+  @param RootBridgeHandle  -  The PCI Root Bridge whose bus range is to be programmed.\r
+  @param Configuration     -  The pointer to the PCI bus resource descriptor.\r
+\r
+  @retval EFI_SUCCESS            -  Succeed.\r
+  @retval EFI_INVALID_PARAMETER  -  Wrong parameters passed in.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SetBusNumbers (\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
+  IN EFI_HANDLE                                       RootBridgeHandle,\r
+  IN VOID                                             *Configuration\r
+  );\r
+\r
+/**\r
+\r
+  Submits the I/O and memory resource requirements for the specified PCI Root Bridge.\r
+\r
+  @param This              -  The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance\r
+  @param RootBridgeHandle  -  The PCI Root Bridge whose I/O and memory resource requirements\r
+                              are being submitted\r
+  @param Configuration     -  The pointer to the PCI I/O and PCI memory resource descriptor\r
+\r
+  @retval EFI_SUCCESS            -  Succeed.\r
+  @retval EFI_INVALID_PARAMETER  -  Wrong parameters passed in.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SubmitResources (\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
+  IN EFI_HANDLE                                       RootBridgeHandle,\r
+  IN VOID                                             *Configuration\r
+  );\r
+\r
+/**\r
+\r
+  This function returns the proposed resource settings for the specified\r
+  PCI Root Bridge.\r
+\r
+  @param This              -  The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.\r
+  @param RootBridgeHandle  -  The PCI Root Bridge handle.\r
+  @param Configuration     -  The pointer to the pointer to the PCI I/O\r
+                              and memory resource descriptor.\r
+\r
+  @retval EFI_SUCCESS            -  Succeed.\r
+  @retval EFI_OUT_OF_RESOURCES   -  Not enough pool to be allocated.\r
+  @retval EFI_INVALID_PARAMETER  -  RootBridgeHandle is not a valid handle.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetProposedResources (\r
+  IN  EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,\r
+  IN  EFI_HANDLE                                       RootBridgeHandle,\r
+  OUT VOID                                             **Configuration\r
+  );\r
+\r
+/**\r
+\r
+  This function is called for all the PCI controllers that the PCI\r
+  bus driver finds. Can be used to Preprogram the controller.\r
+\r
+  @param This              -  The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance.\r
+  @param RootBridgeHandle  -  The PCI Root Bridge handle.\r
+  @param PciAddress        -  Address of the controller on the PCI bus.\r
+  @param Phase             -  The Phase during resource allocation.\r
+\r
+  @retval EFI_SUCCESS            -  Succeed.\r
+  @retval EFI_INVALID_PARAMETER  -  RootBridgeHandle is not a valid handle.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PreprocessController (\r
+  IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL          *This,\r
+  IN EFI_HANDLE                                                RootBridgeHandle,\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS               PciAddress,\r
+  IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE              Phase\r
+  );\r
+\r
+/**\r
+  This routine constructs the resource descriptors for all root bridges and call PciHostBridgeResourceConflict().\r
+\r
+  @param HostBridge The Host Bridge Instance where the resource adjustment happens.\r
+**/\r
+VOID\r
+ResourceConflict (\r
+  IN  PCI_HOST_BRIDGE_INSTANCE *HostBridge\r
+  );\r
+\r
+extern EFI_METRONOME_ARCH_PROTOCOL *mMetronome;\r
+extern EFI_CPU_IO2_PROTOCOL        *mCpuIo;\r
+#endif\r