]>
Commit | Line | Data |
---|---|---|
b303605e MK |
1 | /** @file\r |
2 | Registers onboard PCI ROMs with PCI.IO\r | |
3 | \r | |
4 | Copyright (c) 2013-2015 Intel Corporation.\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #include "CommonHeader.h"\r | |
18 | \r | |
19 | #include "PciPlatform.h"\r | |
20 | \r | |
21 | \r | |
22 | PCI_OPTION_ROM_TABLE mPciOptionRomTable[] = {\r | |
23 | { NULL_ROM_FILE_GUID, 0, 0, 0, 0, 0xffff, 0xffff }\r | |
24 | };\r | |
25 | EFI_PCI_PLATFORM_PROTOCOL mPciPlatform = {\r | |
26 | PhaseNotify,\r | |
27 | PlatformPrepController,\r | |
28 | GetPlatformPolicy,\r | |
29 | GetPciRom\r | |
30 | };\r | |
31 | \r | |
32 | EFI_HANDLE mPciPlatformHandle = NULL;\r | |
33 | EFI_HANDLE mImageHandle = NULL;\r | |
34 | \r | |
35 | \r | |
36 | EFI_STATUS\r | |
37 | PhaseNotify (\r | |
38 | IN EFI_PCI_PLATFORM_PROTOCOL *This,\r | |
39 | IN EFI_HANDLE HostBridge,\r | |
40 | IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase,\r | |
41 | IN EFI_PCI_CHIPSET_EXECUTION_PHASE ChipsetPhase\r | |
42 | )\r | |
43 | {\r | |
44 | UINT8 UsbHostBusNumber = IOH_BUS;\r | |
45 | if (Phase == EfiPciHostBridgeEndResourceAllocation) {\r | |
46 | // Required for QuarkSouthCluster.\r | |
47 | // Enable USB controller memory, io and bus master before Ehci driver.\r | |
48 | EnableUsbMemIoBusMaster (UsbHostBusNumber);\r | |
49 | return EFI_SUCCESS;\r | |
50 | }\r | |
51 | return EFI_UNSUPPORTED;\r | |
52 | }\r | |
53 | \r | |
54 | \r | |
55 | EFI_STATUS\r | |
56 | PlatformPrepController (\r | |
57 | IN EFI_PCI_PLATFORM_PROTOCOL *This,\r | |
58 | IN EFI_HANDLE HostBridge,\r | |
59 | IN EFI_HANDLE RootBridge,\r | |
60 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,\r | |
61 | IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase,\r | |
62 | IN EFI_PCI_CHIPSET_EXECUTION_PHASE ChipsetPhase\r | |
63 | )\r | |
64 | {\r | |
65 | return EFI_UNSUPPORTED;\r | |
66 | }\r | |
67 | \r | |
68 | EFI_STATUS\r | |
69 | GetPlatformPolicy (\r | |
70 | IN CONST EFI_PCI_PLATFORM_PROTOCOL *This,\r | |
71 | OUT EFI_PCI_PLATFORM_POLICY *PciPolicy\r | |
72 | )\r | |
73 | {\r | |
74 | if (PciPolicy == NULL) {\r | |
75 | return EFI_INVALID_PARAMETER;\r | |
76 | }\r | |
77 | \r | |
78 | return EFI_UNSUPPORTED;\r | |
79 | }\r | |
80 | \r | |
81 | EFI_STATUS\r | |
82 | GetPciRom (\r | |
83 | IN CONST EFI_PCI_PLATFORM_PROTOCOL *This,\r | |
84 | IN EFI_HANDLE PciHandle,\r | |
85 | OUT VOID **RomImage,\r | |
86 | OUT UINTN *RomSize\r | |
87 | )\r | |
88 | /*++\r | |
89 | \r | |
90 | Routine Description:\r | |
91 | Return a PCI ROM image for the onboard device represented by PciHandle\r | |
92 | \r | |
93 | Arguments:\r | |
94 | This - Protocol instance pointer.\r | |
95 | PciHandle - PCI device to return the ROM image for.\r | |
96 | RomImage - PCI Rom Image for onboard device\r | |
97 | RomSize - Size of RomImage in bytes\r | |
98 | \r | |
99 | Returns:\r | |
100 | EFI_SUCCESS - RomImage is valid\r | |
101 | EFI_NOT_FOUND - No RomImage\r | |
102 | \r | |
103 | --*/\r | |
104 | {\r | |
105 | EFI_STATUS Status;\r | |
106 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
107 | UINTN Segment;\r | |
108 | UINTN Bus;\r | |
109 | UINTN Device;\r | |
110 | UINTN Function;\r | |
111 | UINT16 VendorId;\r | |
112 | UINT16 DeviceId;\r | |
113 | UINT16 DeviceClass;\r | |
114 | UINTN TableIndex;\r | |
115 | \r | |
116 | Status = gBS->HandleProtocol (\r | |
117 | PciHandle,\r | |
118 | &gEfiPciIoProtocolGuid,\r | |
119 | (VOID **) &PciIo\r | |
120 | );\r | |
121 | if (EFI_ERROR (Status)) {\r | |
122 | return EFI_NOT_FOUND;\r | |
123 | }\r | |
124 | \r | |
125 | PciIo->GetLocation (PciIo, &Segment, &Bus, &Device, &Function);\r | |
126 | \r | |
127 | PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, 0x0A, 1, &DeviceClass);\r | |
128 | \r | |
129 | PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, 0, 1, &VendorId);\r | |
130 | \r | |
131 | PciIo->Pci.Read (PciIo, EfiPciIoWidthUint16, 2, 1, &DeviceId);\r | |
132 | \r | |
133 | //\r | |
134 | // Loop through table of video option rom descriptions\r | |
135 | //\r | |
136 | for (TableIndex = 0; mPciOptionRomTable[TableIndex].VendorId != 0xffff; TableIndex++) {\r | |
137 | \r | |
138 | //\r | |
139 | // See if the PCI device specified by PciHandle matches at device in mPciOptionRomTable\r | |
140 | //\r | |
141 | if (VendorId != mPciOptionRomTable[TableIndex].VendorId ||\r | |
142 | DeviceId != mPciOptionRomTable[TableIndex].DeviceId ||\r | |
143 | Segment != mPciOptionRomTable[TableIndex].Segment ||\r | |
144 | Bus != mPciOptionRomTable[TableIndex].Bus ||\r | |
145 | Device != mPciOptionRomTable[TableIndex].Device ||\r | |
146 | Function != mPciOptionRomTable[TableIndex].Function) {\r | |
147 | continue;\r | |
148 | }\r | |
149 | \r | |
150 | Status = GetSectionFromFv (\r | |
151 | &mPciOptionRomTable[TableIndex].FileName,\r | |
152 | EFI_SECTION_RAW,\r | |
153 | 0,\r | |
154 | RomImage,\r | |
155 | RomSize\r | |
156 | );\r | |
157 | \r | |
158 | if (EFI_ERROR (Status)) {\r | |
159 | continue;\r | |
160 | }\r | |
161 | \r | |
162 | return EFI_SUCCESS;\r | |
163 | }\r | |
164 | \r | |
165 | return EFI_NOT_FOUND;\r | |
166 | }\r | |
167 | \r | |
168 | EFI_STATUS\r | |
169 | PciPlatformDriverEntry (\r | |
170 | IN EFI_HANDLE ImageHandle,\r | |
171 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
172 | )\r | |
173 | /*++\r | |
174 | \r | |
175 | Routine Description:\r | |
176 | \r | |
177 | Arguments:\r | |
178 | (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)\r | |
179 | \r | |
180 | Returns:\r | |
181 | EFI_STATUS\r | |
182 | \r | |
183 | --*/\r | |
184 | {\r | |
185 | EFI_STATUS Status;\r | |
186 | \r | |
187 | mImageHandle = ImageHandle;\r | |
188 | \r | |
189 | //\r | |
190 | // Install on a new handle\r | |
191 | //\r | |
192 | Status = gBS->InstallProtocolInterface (\r | |
193 | &mPciPlatformHandle,\r | |
194 | &gEfiPciPlatformProtocolGuid,\r | |
195 | EFI_NATIVE_INTERFACE,\r | |
196 | &mPciPlatform\r | |
197 | );\r | |
198 | \r | |
199 | return Status;\r | |
200 | }\r |