3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 EFI PCAT ISA ACPI Driver for a Generic PC Platform
25 #include "PcatIsaAcpi.h"
28 // PcatIsaAcpi Driver Binding Protocol
30 EFI_DRIVER_BINDING_PROTOCOL gPcatIsaAcpiDriverBinding
= {
31 PcatIsaAcpiDriverBindingSupported
,
32 PcatIsaAcpiDriverBindingStart
,
33 PcatIsaAcpiDriverBindingStop
,
41 PcatIsaAcpiDriverEntryPoint (
42 IN EFI_HANDLE ImageHandle
,
43 IN EFI_SYSTEM_TABLE
*SystemTable
48 the entry point of the PcatIsaAcpi driver
56 return EfiLibInstallDriverBindingComponentName2 (
59 &gPcatIsaAcpiDriverBinding
,
61 &gPcatIsaAcpiComponentName
,
62 &gPcatIsaAcpiComponentName2
68 PcatIsaAcpiDriverBindingSupported (
69 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
70 IN EFI_HANDLE Controller
,
71 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
77 ControllerDriver Protocol Method
86 EFI_PCI_IO_PROTOCOL
*PciIo
;
90 // Get PciIo protocol instance
92 Status
= gBS
->OpenProtocol (
94 &gEfiPciIoProtocolGuid
,
96 This
->DriverBindingHandle
,
98 EFI_OPEN_PROTOCOL_BY_DRIVER
100 if (EFI_ERROR(Status
)) {
104 Status
= PciIo
->Pci
.Read (
108 sizeof(Pci
) / sizeof(UINT32
),
111 if (!EFI_ERROR (Status
)) {
112 Status
= EFI_UNSUPPORTED
;
113 if ((Pci
.Hdr
.Command
& 0x03) == 0x03) {
114 if (Pci
.Hdr
.ClassCode
[2] == PCI_CLASS_BRIDGE
) {
116 // See if this is a standard PCI to ISA Bridge from the Base Code and Class Code
118 if (Pci
.Hdr
.ClassCode
[1] == PCI_CLASS_BRIDGE_ISA
) {
119 Status
= EFI_SUCCESS
;
123 // See if this is an Intel PCI to ISA bridge in Positive Decode Mode
125 if (Pci
.Hdr
.ClassCode
[1] == PCI_CLASS_BRIDGE_ISA_PDECODE
&&
126 Pci
.Hdr
.VendorId
== 0x8086 &&
127 Pci
.Hdr
.DeviceId
== 0x7110) {
128 Status
= EFI_SUCCESS
;
136 &gEfiPciIoProtocolGuid
,
137 This
->DriverBindingHandle
,
146 PcatIsaAcpiDriverBindingStart (
147 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
148 IN EFI_HANDLE Controller
,
149 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
154 Install EFI_ISA_ACPI_PROTOCOL
163 EFI_PCI_IO_PROTOCOL
*PciIo
;
164 PCAT_ISA_ACPI_DEV
*PcatIsaAcpiDev
;
166 PcatIsaAcpiDev
= NULL
;
168 // Open the PCI I/O Protocol Interface
171 Status
= gBS
->OpenProtocol (
173 &gEfiPciIoProtocolGuid
,
175 This
->DriverBindingHandle
,
177 EFI_OPEN_PROTOCOL_BY_DRIVER
179 if (EFI_ERROR (Status
)) {
183 Status
= PciIo
->Attributes (
185 EfiPciIoAttributeOperationEnable
,
186 EFI_PCI_DEVICE_ENABLE
| EFI_PCI_IO_ATTRIBUTE_ISA_IO
| EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO
,
189 if (EFI_ERROR (Status
)) {
194 // Allocate memory for the PCAT ISA ACPI Device structure
196 PcatIsaAcpiDev
= NULL
;
197 Status
= gBS
->AllocatePool (
199 sizeof(PCAT_ISA_ACPI_DEV
),
200 (VOID
**)&PcatIsaAcpiDev
202 if (EFI_ERROR (Status
)) {
207 // Initialize the PCAT ISA ACPI Device structure
209 PcatIsaAcpiDev
->Signature
= PCAT_ISA_ACPI_DEV_SIGNATURE
;
210 PcatIsaAcpiDev
->Handle
= Controller
;
211 PcatIsaAcpiDev
->PciIo
= PciIo
;
216 (PcatIsaAcpiDev
->IsaAcpi
).DeviceEnumerate
= IsaDeviceEnumerate
;
217 (PcatIsaAcpiDev
->IsaAcpi
).SetPower
= IsaDeviceSetPower
;
218 (PcatIsaAcpiDev
->IsaAcpi
).GetCurResource
= IsaGetCurrentResource
;
219 (PcatIsaAcpiDev
->IsaAcpi
).GetPosResource
= IsaGetPossibleResource
;
220 (PcatIsaAcpiDev
->IsaAcpi
).SetResource
= IsaSetResource
;
221 (PcatIsaAcpiDev
->IsaAcpi
).EnableDevice
= IsaEnableDevice
;
222 (PcatIsaAcpiDev
->IsaAcpi
).InitDevice
= IsaInitDevice
;
223 (PcatIsaAcpiDev
->IsaAcpi
).InterfaceInit
= IsaInterfaceInit
;
226 // Install the ISA ACPI Protocol interface
228 Status
= gBS
->InstallMultipleProtocolInterfaces (
230 &gEfiIsaAcpiProtocolGuid
, &PcatIsaAcpiDev
->IsaAcpi
,
235 if (EFI_ERROR (Status
)) {
239 EfiPciIoAttributeOperationDisable
,
240 EFI_PCI_DEVICE_ENABLE
| EFI_PCI_IO_ATTRIBUTE_ISA_IO
| EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO
,
246 &gEfiPciIoProtocolGuid
,
247 This
->DriverBindingHandle
,
250 if (PcatIsaAcpiDev
!= NULL
) {
251 gBS
->FreePool (PcatIsaAcpiDev
);
261 PcatIsaAcpiDriverBindingStop (
262 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
263 IN EFI_HANDLE Controller
,
264 IN UINTN NumberOfChildren
,
265 IN EFI_HANDLE
*ChildHandleBuffer
278 EFI_ISA_ACPI_PROTOCOL
*IsaAcpi
;
279 PCAT_ISA_ACPI_DEV
*PcatIsaAcpiDev
;
282 // Get the ISA ACPI Protocol Interface
284 Status
= gBS
->OpenProtocol (
286 &gEfiIsaAcpiProtocolGuid
,
288 This
->DriverBindingHandle
,
290 EFI_OPEN_PROTOCOL_GET_PROTOCOL
292 if (EFI_ERROR (Status
)) {
297 // Get the PCAT ISA ACPI Device structure from the ISA ACPI Protocol
299 PcatIsaAcpiDev
= PCAT_ISA_ACPI_DEV_FROM_THIS (IsaAcpi
);
301 PcatIsaAcpiDev
->PciIo
->Attributes (
302 PcatIsaAcpiDev
->PciIo
,
303 EfiPciIoAttributeOperationDisable
,
304 EFI_PCI_DEVICE_ENABLE
| EFI_PCI_IO_ATTRIBUTE_ISA_IO
| EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO
,
309 // Uninstall protocol interface: EFI_ISA_ACPI_PROTOCOL
311 Status
= gBS
->UninstallProtocolInterface (
313 &gEfiIsaAcpiProtocolGuid
, &PcatIsaAcpiDev
->IsaAcpi
315 if (EFI_ERROR (Status
)) {
321 &gEfiPciIoProtocolGuid
,
322 This
->DriverBindingHandle
,
326 gBS
->FreePool (PcatIsaAcpiDev
);