2 EFI PCAT ISA ACPI Driver for a Generic PC Platform
4 Copyright (c) 2006, 2009, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "PcatIsaAcpi.h"
18 // PcatIsaAcpi Driver Binding Protocol
20 EFI_DRIVER_BINDING_PROTOCOL gPcatIsaAcpiDriverBinding
= {
21 PcatIsaAcpiDriverBindingSupported
,
22 PcatIsaAcpiDriverBindingStart
,
23 PcatIsaAcpiDriverBindingStop
,
31 PcatIsaAcpiDriverEntryPoint (
32 IN EFI_HANDLE ImageHandle
,
33 IN EFI_SYSTEM_TABLE
*SystemTable
38 the entry point of the PcatIsaAcpi driver
46 return EfiLibInstallDriverBindingComponentName2 (
49 &gPcatIsaAcpiDriverBinding
,
51 &gPcatIsaAcpiComponentName
,
52 &gPcatIsaAcpiComponentName2
58 PcatIsaAcpiDriverBindingSupported (
59 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
60 IN EFI_HANDLE Controller
,
61 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
67 ControllerDriver Protocol Method
76 EFI_PCI_IO_PROTOCOL
*PciIo
;
80 // Get PciIo protocol instance
82 Status
= gBS
->OpenProtocol (
84 &gEfiPciIoProtocolGuid
,
86 This
->DriverBindingHandle
,
88 EFI_OPEN_PROTOCOL_BY_DRIVER
90 if (EFI_ERROR(Status
)) {
94 Status
= PciIo
->Pci
.Read (
98 sizeof(Pci
) / sizeof(UINT32
),
101 if (!EFI_ERROR (Status
)) {
102 Status
= EFI_UNSUPPORTED
;
103 if ((Pci
.Hdr
.Command
& 0x03) == 0x03) {
104 if (Pci
.Hdr
.ClassCode
[2] == PCI_CLASS_BRIDGE
) {
106 // See if this is a standard PCI to ISA Bridge from the Base Code and Class Code
108 if (Pci
.Hdr
.ClassCode
[1] == PCI_CLASS_BRIDGE_ISA
) {
109 Status
= EFI_SUCCESS
;
113 // See if this is an Intel PCI to ISA bridge in Positive Decode Mode
115 if (Pci
.Hdr
.ClassCode
[1] == PCI_CLASS_BRIDGE_ISA_PDECODE
&&
116 Pci
.Hdr
.VendorId
== 0x8086 &&
117 (Pci
.Hdr
.DeviceId
& 0xF000) == 0x7000) {
118 Status
= EFI_SUCCESS
;
126 &gEfiPciIoProtocolGuid
,
127 This
->DriverBindingHandle
,
136 PcatIsaAcpiDriverBindingStart (
137 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
138 IN EFI_HANDLE Controller
,
139 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
144 Install EFI_ISA_ACPI_PROTOCOL
153 EFI_PCI_IO_PROTOCOL
*PciIo
;
154 PCAT_ISA_ACPI_DEV
*PcatIsaAcpiDev
;
156 PcatIsaAcpiDev
= NULL
;
158 // Open the PCI I/O Protocol Interface
161 Status
= gBS
->OpenProtocol (
163 &gEfiPciIoProtocolGuid
,
165 This
->DriverBindingHandle
,
167 EFI_OPEN_PROTOCOL_BY_DRIVER
169 if (EFI_ERROR (Status
)) {
173 Status
= PciIo
->Attributes (
175 EfiPciIoAttributeOperationEnable
,
176 EFI_PCI_DEVICE_ENABLE
| EFI_PCI_IO_ATTRIBUTE_ISA_IO
| EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO
,
179 if (EFI_ERROR (Status
)) {
184 // Allocate memory for the PCAT ISA ACPI Device structure
186 PcatIsaAcpiDev
= NULL
;
187 Status
= gBS
->AllocatePool (
189 sizeof(PCAT_ISA_ACPI_DEV
),
190 (VOID
**)&PcatIsaAcpiDev
192 if (EFI_ERROR (Status
)) {
197 // Initialize the PCAT ISA ACPI Device structure
199 PcatIsaAcpiDev
->Signature
= PCAT_ISA_ACPI_DEV_SIGNATURE
;
200 PcatIsaAcpiDev
->Handle
= Controller
;
201 PcatIsaAcpiDev
->PciIo
= PciIo
;
206 (PcatIsaAcpiDev
->IsaAcpi
).DeviceEnumerate
= IsaDeviceEnumerate
;
207 (PcatIsaAcpiDev
->IsaAcpi
).SetPower
= IsaDeviceSetPower
;
208 (PcatIsaAcpiDev
->IsaAcpi
).GetCurResource
= IsaGetCurrentResource
;
209 (PcatIsaAcpiDev
->IsaAcpi
).GetPosResource
= IsaGetPossibleResource
;
210 (PcatIsaAcpiDev
->IsaAcpi
).SetResource
= IsaSetResource
;
211 (PcatIsaAcpiDev
->IsaAcpi
).EnableDevice
= IsaEnableDevice
;
212 (PcatIsaAcpiDev
->IsaAcpi
).InitDevice
= IsaInitDevice
;
213 (PcatIsaAcpiDev
->IsaAcpi
).InterfaceInit
= IsaInterfaceInit
;
216 // Install the ISA ACPI Protocol interface
218 Status
= gBS
->InstallMultipleProtocolInterfaces (
220 &gEfiIsaAcpiProtocolGuid
, &PcatIsaAcpiDev
->IsaAcpi
,
225 if (EFI_ERROR (Status
)) {
229 EfiPciIoAttributeOperationDisable
,
230 EFI_PCI_DEVICE_ENABLE
| EFI_PCI_IO_ATTRIBUTE_ISA_IO
| EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO
,
236 &gEfiPciIoProtocolGuid
,
237 This
->DriverBindingHandle
,
240 if (PcatIsaAcpiDev
!= NULL
) {
241 gBS
->FreePool (PcatIsaAcpiDev
);
251 PcatIsaAcpiDriverBindingStop (
252 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
253 IN EFI_HANDLE Controller
,
254 IN UINTN NumberOfChildren
,
255 IN EFI_HANDLE
*ChildHandleBuffer
268 EFI_ISA_ACPI_PROTOCOL
*IsaAcpi
;
269 PCAT_ISA_ACPI_DEV
*PcatIsaAcpiDev
;
272 // Get the ISA ACPI Protocol Interface
274 Status
= gBS
->OpenProtocol (
276 &gEfiIsaAcpiProtocolGuid
,
278 This
->DriverBindingHandle
,
280 EFI_OPEN_PROTOCOL_GET_PROTOCOL
282 if (EFI_ERROR (Status
)) {
287 // Get the PCAT ISA ACPI Device structure from the ISA ACPI Protocol
289 PcatIsaAcpiDev
= PCAT_ISA_ACPI_DEV_FROM_THIS (IsaAcpi
);
291 PcatIsaAcpiDev
->PciIo
->Attributes (
292 PcatIsaAcpiDev
->PciIo
,
293 EfiPciIoAttributeOperationDisable
,
294 EFI_PCI_DEVICE_ENABLE
| EFI_PCI_IO_ATTRIBUTE_ISA_IO
| EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO
,
299 // Uninstall protocol interface: EFI_ISA_ACPI_PROTOCOL
301 Status
= gBS
->UninstallProtocolInterface (
303 &gEfiIsaAcpiProtocolGuid
, &PcatIsaAcpiDev
->IsaAcpi
305 if (EFI_ERROR (Status
)) {
311 &gEfiPciIoProtocolGuid
,
312 This
->DriverBindingHandle
,
316 gBS
->FreePool (PcatIsaAcpiDev
);