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