]>
Commit | Line | Data |
---|---|---|
d85861d7 LE |
1 | /** @file\r |
2 | OVMF's instance of the PCI Host Bridge Library.\r | |
3 | \r | |
4 | Copyright (C) 2016, Red Hat, Inc.\r | |
5 | Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r | |
6 | \r | |
b26f0cf9 | 7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
d85861d7 LE |
8 | \r |
9 | **/\r | |
32fef035 LE |
10 | #include <IndustryStandard/Pci.h> // PCI_MAX_BUS\r |
11 | #include <IndustryStandard/Q35MchIch9.h> // INTEL_Q35_MCH_DEVIC...\r | |
12 | #include <Library/BaseMemoryLib.h> // ZeroMem()\r | |
13 | #include <Library/PcdLib.h> // PcdGet64()\r | |
14 | #include <Library/PciHostBridgeLib.h> // PCI_ROOT_BRIDGE_APE...\r | |
15 | #include <Library/PciHostBridgeUtilityLib.h> // PciHostBridgeUtilit...\r | |
16 | #include <Protocol/PciHostBridgeResourceAllocation.h> // EFI_PCI_HOST_BRIDGE...\r | |
17 | #include <Protocol/PciRootBridgeIo.h> // EFI_PCI_ATTRIBUTE_I...\r | |
46e46eaf | 18 | \r |
c0a2591b | 19 | STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture = { MAX_UINT64, 0 };\r |
1f4e2299 | 20 | \r |
46e46eaf | 21 | \r |
d85861d7 LE |
22 | /**\r |
23 | Return all the root bridge instances in an array.\r | |
24 | \r | |
25 | @param Count Return the count of root bridge instances.\r | |
26 | \r | |
27 | @return All the root bridge instances in an array.\r | |
28 | The array should be passed into PciHostBridgeFreeRootBridges()\r | |
29 | when it's not used.\r | |
30 | **/\r | |
31 | PCI_ROOT_BRIDGE *\r | |
32 | EFIAPI\r | |
33 | PciHostBridgeGetRootBridges (\r | |
34 | UINTN *Count\r | |
35 | )\r | |
36 | {\r | |
c0a2591b RN |
37 | UINT64 Attributes;\r |
38 | UINT64 AllocationAttributes;\r | |
39 | PCI_ROOT_BRIDGE_APERTURE Io;\r | |
40 | PCI_ROOT_BRIDGE_APERTURE Mem;\r | |
41 | PCI_ROOT_BRIDGE_APERTURE MemAbove4G;\r | |
42 | \r | |
e33305ea HG |
43 | ZeroMem (&Io, sizeof (Io));\r |
44 | ZeroMem (&Mem, sizeof (Mem));\r | |
45 | ZeroMem (&MemAbove4G, sizeof (MemAbove4G));\r | |
46 | \r | |
c0a2591b RN |
47 | Attributes = EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO |\r |
48 | EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO |\r | |
49 | EFI_PCI_ATTRIBUTE_ISA_IO_16 |\r | |
50 | EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO |\r | |
51 | EFI_PCI_ATTRIBUTE_VGA_MEMORY |\r | |
52 | EFI_PCI_ATTRIBUTE_VGA_IO_16 |\r | |
53 | EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16;\r | |
54 | \r | |
55 | AllocationAttributes = EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM;\r | |
56 | if (PcdGet64 (PcdPciMmio64Size) > 0) {\r | |
57 | AllocationAttributes |= EFI_PCI_HOST_BRIDGE_MEM64_DECODE;\r | |
58 | MemAbove4G.Base = PcdGet64 (PcdPciMmio64Base);\r | |
59 | MemAbove4G.Limit = PcdGet64 (PcdPciMmio64Base) +\r | |
60 | PcdGet64 (PcdPciMmio64Size) - 1;\r | |
61 | } else {\r | |
62 | CopyMem (&MemAbove4G, &mNonExistAperture, sizeof (mNonExistAperture));\r | |
63 | }\r | |
64 | \r | |
65 | Io.Base = PcdGet64 (PcdPciIoBase);\r | |
66 | Io.Limit = PcdGet64 (PcdPciIoBase) + (PcdGet64 (PcdPciIoSize) - 1);\r | |
67 | Mem.Base = PcdGet64 (PcdPciMmio32Base);\r | |
68 | Mem.Limit = PcdGet64 (PcdPciMmio32Base) + (PcdGet64 (PcdPciMmio32Size) - 1);\r | |
46e46eaf | 69 | \r |
4edba296 JC |
70 | return PciHostBridgeUtilityGetRootBridges (\r |
71 | Count,\r | |
c0a2591b RN |
72 | Attributes,\r |
73 | AllocationAttributes,\r | |
14d4b6be JC |
74 | FALSE,\r |
75 | PcdGet16 (PcdOvmfHostBridgePciDevId) != INTEL_Q35_MCH_DEVICE_ID,\r | |
f4a257a3 JC |
76 | 0,\r |
77 | PCI_MAX_BUS,\r | |
c0a2591b RN |
78 | &Io,\r |
79 | &Mem,\r | |
80 | &MemAbove4G,\r | |
81 | &mNonExistAperture,\r | |
4edba296 | 82 | &mNonExistAperture\r |
c0a2591b | 83 | );\r |
d85861d7 LE |
84 | }\r |
85 | \r | |
46e46eaf | 86 | \r |
d85861d7 LE |
87 | /**\r |
88 | Free the root bridge instances array returned from\r | |
89 | PciHostBridgeGetRootBridges().\r | |
90 | \r | |
91 | @param The root bridge instances array.\r | |
92 | @param The count of the array.\r | |
93 | **/\r | |
94 | VOID\r | |
95 | EFIAPI\r | |
96 | PciHostBridgeFreeRootBridges (\r | |
97 | PCI_ROOT_BRIDGE *Bridges,\r | |
98 | UINTN Count\r | |
99 | )\r | |
100 | {\r | |
4edba296 | 101 | PciHostBridgeUtilityFreeRootBridges (Bridges, Count);\r |
d85861d7 LE |
102 | }\r |
103 | \r | |
46e46eaf | 104 | \r |
d85861d7 LE |
105 | /**\r |
106 | Inform the platform that the resource conflict happens.\r | |
107 | \r | |
108 | @param HostBridgeHandle Handle of the Host Bridge.\r | |
109 | @param Configuration Pointer to PCI I/O and PCI memory resource\r | |
110 | descriptors. The Configuration contains the resources\r | |
111 | for all the root bridges. The resource for each root\r | |
112 | bridge is terminated with END descriptor and an\r | |
113 | additional END is appended indicating the end of the\r | |
114 | entire resources. The resource descriptor field\r | |
115 | values follow the description in\r | |
116 | EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL\r | |
117 | .SubmitResources().\r | |
118 | **/\r | |
119 | VOID\r | |
120 | EFIAPI\r | |
121 | PciHostBridgeResourceConflict (\r | |
122 | EFI_HANDLE HostBridgeHandle,\r | |
123 | VOID *Configuration\r | |
124 | )\r | |
125 | {\r | |
7a6172f8 | 126 | PciHostBridgeUtilityResourceConflict (Configuration);\r |
d85861d7 | 127 | }\r |