]>
Commit | Line | Data |
---|---|---|
c69dd9df | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | \r | |
13 | Module Name:\r | |
14 | \r | |
15 | PcatIsaAcpi.c\r | |
16 | \r | |
17 | Abstract:\r | |
18 | \r | |
19 | EFI PCAT ISA ACPI Driver for a Generic PC Platform\r | |
20 | \r | |
21 | Revision History\r | |
22 | \r | |
23 | --*/\r | |
24 | \r | |
25 | #include "PcatIsaAcpi.h"\r | |
26 | \r | |
27 | //\r | |
28 | // PcatIsaAcpi Driver Binding Protocol\r | |
29 | //\r | |
30 | EFI_DRIVER_BINDING_PROTOCOL gPcatIsaAcpiDriverBinding = {\r | |
31 | PcatIsaAcpiDriverBindingSupported,\r | |
32 | PcatIsaAcpiDriverBindingStart,\r | |
33 | PcatIsaAcpiDriverBindingStop,\r | |
34 | 0xa,\r | |
35 | NULL,\r | |
36 | NULL\r | |
37 | };\r | |
38 | \r | |
39 | EFI_STATUS\r | |
40 | EFIAPI\r | |
41 | PcatIsaAcpiDriverEntryPoint (\r | |
42 | IN EFI_HANDLE ImageHandle,\r | |
43 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
44 | )\r | |
45 | /*++\r | |
46 | \r | |
47 | Routine Description:\r | |
48 | the entry point of the PcatIsaAcpi driver\r | |
49 | \r | |
50 | Arguments:\r | |
51 | \r | |
52 | Returns:\r | |
53 | \r | |
54 | --*/ \r | |
55 | {\r | |
56 | return EfiLibInstallDriverBindingComponentName2 (\r | |
57 | ImageHandle, \r | |
58 | SystemTable, \r | |
59 | &gPcatIsaAcpiDriverBinding,\r | |
60 | ImageHandle,\r | |
61 | &gPcatIsaAcpiComponentName,\r | |
62 | &gPcatIsaAcpiComponentName2\r | |
63 | );\r | |
64 | }\r | |
65 | \r | |
66 | EFI_STATUS\r | |
67 | EFIAPI\r | |
68 | PcatIsaAcpiDriverBindingSupported (\r | |
69 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
70 | IN EFI_HANDLE Controller,\r | |
71 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
72 | )\r | |
73 | /*++\r | |
74 | \r | |
75 | Routine Description:\r | |
76 | \r | |
77 | ControllerDriver Protocol Method\r | |
78 | \r | |
79 | Arguments:\r | |
80 | \r | |
81 | Returns:\r | |
82 | \r | |
83 | --*/\r | |
84 | {\r | |
85 | EFI_STATUS Status;\r | |
86 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
87 | PCI_TYPE00 Pci;\r | |
88 | \r | |
89 | //\r | |
90 | // Get PciIo protocol instance\r | |
91 | // \r | |
92 | Status = gBS->OpenProtocol (\r | |
93 | Controller, \r | |
94 | &gEfiPciIoProtocolGuid, \r | |
95 | &PciIo,\r | |
96 | This->DriverBindingHandle,\r | |
97 | Controller,\r | |
98 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
99 | );\r | |
100 | if (EFI_ERROR(Status)) {\r | |
101 | return Status;\r | |
102 | }\r | |
103 | \r | |
104 | Status = PciIo->Pci.Read (\r | |
105 | PciIo,\r | |
106 | EfiPciIoWidthUint32,\r | |
107 | 0,\r | |
108 | sizeof(Pci) / sizeof(UINT32), \r | |
109 | &Pci);\r | |
110 | \r | |
111 | if (!EFI_ERROR (Status)) {\r | |
112 | Status = EFI_UNSUPPORTED;\r | |
113 | if ((Pci.Hdr.Command & 0x03) == 0x03) {\r | |
114 | if (Pci.Hdr.ClassCode[2] == PCI_CLASS_BRIDGE) {\r | |
115 | //\r | |
116 | // See if this is a standard PCI to ISA Bridge from the Base Code and Class Code\r | |
117 | //\r | |
118 | if (Pci.Hdr.ClassCode[1] == PCI_CLASS_ISA) {\r | |
119 | Status = EFI_SUCCESS;\r | |
120 | } \r | |
121 | \r | |
122 | //\r | |
123 | // See if this is an Intel PCI to ISA bridge in Positive Decode Mode\r | |
124 | //\r | |
125 | if (Pci.Hdr.ClassCode[1] == PCI_CLASS_ISA_POSITIVE_DECODE &&\r | |
126 | Pci.Hdr.VendorId == 0x8086 && \r | |
127 | Pci.Hdr.DeviceId == 0x7110) {\r | |
128 | Status = EFI_SUCCESS;\r | |
129 | }\r | |
130 | } \r | |
131 | }\r | |
132 | }\r | |
133 | \r | |
134 | gBS->CloseProtocol (\r | |
135 | Controller, \r | |
136 | &gEfiPciIoProtocolGuid, \r | |
137 | This->DriverBindingHandle, \r | |
138 | Controller \r | |
139 | );\r | |
140 | \r | |
141 | return Status;\r | |
142 | }\r | |
143 | \r | |
144 | EFI_STATUS\r | |
145 | EFIAPI\r | |
146 | PcatIsaAcpiDriverBindingStart (\r | |
147 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
148 | IN EFI_HANDLE Controller,\r | |
149 | IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r | |
150 | )\r | |
151 | /*++\r | |
152 | \r | |
153 | Routine Description:\r | |
154 | Install EFI_ISA_ACPI_PROTOCOL\r | |
155 | \r | |
156 | Arguments:\r | |
157 | \r | |
158 | Returns:\r | |
159 | \r | |
160 | --*/\r | |
161 | {\r | |
162 | EFI_STATUS Status;\r | |
163 | EFI_PCI_IO_PROTOCOL *PciIo;\r | |
164 | PCAT_ISA_ACPI_DEV *PcatIsaAcpiDev;\r | |
165 | \r | |
166 | PcatIsaAcpiDev = NULL;\r | |
167 | //\r | |
168 | // Open the PCI I/O Protocol Interface\r | |
169 | //\r | |
170 | PciIo = NULL;\r | |
171 | Status = gBS->OpenProtocol (\r | |
172 | Controller, \r | |
173 | &gEfiPciIoProtocolGuid, \r | |
174 | &PciIo,\r | |
175 | This->DriverBindingHandle, \r | |
176 | Controller, \r | |
177 | EFI_OPEN_PROTOCOL_BY_DRIVER \r | |
178 | );\r | |
179 | if (EFI_ERROR (Status)) {\r | |
180 | goto Done;\r | |
181 | }\r | |
182 | \r | |
183 | Status = PciIo->Attributes (\r | |
184 | PciIo, \r | |
185 | EfiPciIoAttributeOperationEnable, \r | |
186 | EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO, \r | |
187 | NULL \r | |
188 | );\r | |
189 | if (EFI_ERROR (Status)) {\r | |
190 | goto Done;\r | |
191 | }\r | |
192 | \r | |
193 | //\r | |
194 | // Allocate memory for the PCAT ISA ACPI Device structure\r | |
195 | //\r | |
196 | PcatIsaAcpiDev = NULL;\r | |
197 | Status = gBS->AllocatePool (\r | |
198 | EfiBootServicesData,\r | |
199 | sizeof(PCAT_ISA_ACPI_DEV),\r | |
200 | &PcatIsaAcpiDev\r | |
201 | );\r | |
202 | if (EFI_ERROR (Status)) {\r | |
203 | goto Done;\r | |
204 | }\r | |
205 | \r | |
206 | //\r | |
207 | // Initialize the PCAT ISA ACPI Device structure\r | |
208 | //\r | |
209 | PcatIsaAcpiDev->Signature = PCAT_ISA_ACPI_DEV_SIGNATURE;\r | |
210 | PcatIsaAcpiDev->Handle = Controller;\r | |
211 | PcatIsaAcpiDev->PciIo = PciIo;\r | |
212 | \r | |
213 | //\r | |
214 | // IsaAcpi interface\r | |
215 | //\r | |
216 | (PcatIsaAcpiDev->IsaAcpi).DeviceEnumerate = IsaDeviceEnumerate;\r | |
217 | (PcatIsaAcpiDev->IsaAcpi).SetPower = IsaDeviceSetPower;\r | |
218 | (PcatIsaAcpiDev->IsaAcpi).GetCurResource = IsaGetCurrentResource;\r | |
219 | (PcatIsaAcpiDev->IsaAcpi).GetPosResource = IsaGetPossibleResource;\r | |
220 | (PcatIsaAcpiDev->IsaAcpi).SetResource = IsaSetResource;\r | |
221 | (PcatIsaAcpiDev->IsaAcpi).EnableDevice = IsaEnableDevice;\r | |
222 | (PcatIsaAcpiDev->IsaAcpi).InitDevice = IsaInitDevice;\r | |
223 | (PcatIsaAcpiDev->IsaAcpi).InterfaceInit = IsaInterfaceInit;\r | |
224 | \r | |
225 | //\r | |
226 | // Install the ISA ACPI Protocol interface\r | |
227 | //\r | |
228 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
229 | &Controller,\r | |
230 | &gEfiIsaAcpiProtocolGuid, &PcatIsaAcpiDev->IsaAcpi,\r | |
231 | NULL\r | |
232 | );\r | |
233 | \r | |
234 | Done:\r | |
235 | if (EFI_ERROR (Status)) {\r | |
236 | if (PciIo) {\r | |
237 | PciIo->Attributes (\r | |
238 | PciIo, \r | |
239 | EfiPciIoAttributeOperationDisable, \r | |
240 | EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,\r | |
241 | NULL \r | |
242 | );\r | |
243 | }\r | |
244 | gBS->CloseProtocol (\r | |
245 | Controller, \r | |
246 | &gEfiPciIoProtocolGuid, \r | |
247 | This->DriverBindingHandle, \r | |
248 | Controller\r | |
249 | );\r | |
250 | if (PcatIsaAcpiDev != NULL) {\r | |
251 | gBS->FreePool (PcatIsaAcpiDev);\r | |
252 | }\r | |
253 | return Status;\r | |
254 | }\r | |
255 | \r | |
256 | return EFI_SUCCESS;\r | |
257 | }\r | |
258 | \r | |
259 | EFI_STATUS\r | |
260 | EFIAPI\r | |
261 | PcatIsaAcpiDriverBindingStop (\r | |
262 | IN EFI_DRIVER_BINDING_PROTOCOL *This,\r | |
263 | IN EFI_HANDLE Controller,\r | |
264 | IN UINTN NumberOfChildren,\r | |
265 | IN EFI_HANDLE *ChildHandleBuffer\r | |
266 | )\r | |
267 | /*++\r | |
268 | \r | |
269 | Routine Description:\r | |
270 | \r | |
271 | Arguments:\r | |
272 | \r | |
273 | Returns:\r | |
274 | \r | |
275 | --*/\r | |
276 | {\r | |
277 | EFI_STATUS Status;\r | |
278 | EFI_ISA_ACPI_PROTOCOL *IsaAcpi;\r | |
279 | PCAT_ISA_ACPI_DEV *PcatIsaAcpiDev;\r | |
280 | \r | |
281 | //\r | |
282 | // Get the ISA ACPI Protocol Interface\r | |
283 | // \r | |
284 | Status = gBS->OpenProtocol (\r | |
285 | Controller, \r | |
286 | &gEfiIsaAcpiProtocolGuid, \r | |
287 | &IsaAcpi,\r | |
288 | This->DriverBindingHandle, \r | |
289 | Controller, \r | |
290 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
291 | );\r | |
292 | if (EFI_ERROR (Status)) {\r | |
293 | return Status;\r | |
294 | }\r | |
295 | \r | |
296 | //\r | |
297 | // Get the PCAT ISA ACPI Device structure from the ISA ACPI Protocol\r | |
298 | //\r | |
299 | PcatIsaAcpiDev = PCAT_ISA_ACPI_DEV_FROM_THIS (IsaAcpi);\r | |
300 | \r | |
301 | PcatIsaAcpiDev->PciIo->Attributes (\r | |
302 | PcatIsaAcpiDev->PciIo, \r | |
303 | EfiPciIoAttributeOperationDisable, \r | |
304 | EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_ISA_IO | EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO,\r | |
305 | NULL \r | |
306 | );\r | |
307 | \r | |
308 | //\r | |
309 | // Uninstall protocol interface: EFI_ISA_ACPI_PROTOCOL\r | |
310 | //\r | |
311 | Status = gBS->UninstallProtocolInterface (\r | |
312 | Controller,\r | |
313 | &gEfiIsaAcpiProtocolGuid, &PcatIsaAcpiDev->IsaAcpi\r | |
314 | );\r | |
315 | if (EFI_ERROR (Status)) {\r | |
316 | return Status;\r | |
317 | }\r | |
318 | \r | |
319 | gBS->CloseProtocol (\r | |
320 | Controller, \r | |
321 | &gEfiPciIoProtocolGuid, \r | |
322 | This->DriverBindingHandle, \r | |
323 | Controller\r | |
324 | );\r | |
325 | \r | |
326 | gBS->FreePool (PcatIsaAcpiDev);\r | |
327 | \r | |
328 | return EFI_SUCCESS;\r | |
329 | }\r |