2 EFI PCAT ISA ACPI Driver for a Generic PC Platform
4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
5 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
,
30 the entry point of the PcatIsaAcpi driver.
32 @param ImageHandle Handle for driver image
33 @param SystemTable Point to EFI_SYSTEM_TABLE
35 @return Sucess or not for installing driver binding protocol
39 PcatIsaAcpiDriverEntryPoint (
40 IN EFI_HANDLE ImageHandle
,
41 IN EFI_SYSTEM_TABLE
*SystemTable
44 return EfiLibInstallDriverBindingComponentName2 (
47 &gPcatIsaAcpiDriverBinding
,
49 &gPcatIsaAcpiComponentName
,
50 &gPcatIsaAcpiComponentName2
55 ControllerDriver Protocol Method
57 @param This Driver Binding protocol instance pointer.
58 @param Controller Handle of device to test.
59 @param RemainingDevicePath Optional parameter use to pick a specific child
61 @retval EFI_SUCCESS This driver supports this device.
62 @retval other This driver does not support this device.
67 PcatIsaAcpiDriverBindingSupported (
68 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
69 IN EFI_HANDLE Controller
,
70 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
74 EFI_PCI_IO_PROTOCOL
*PciIo
;
78 // Get PciIo protocol instance
80 Status
= gBS
->OpenProtocol (
82 &gEfiPciIoProtocolGuid
,
84 This
->DriverBindingHandle
,
86 EFI_OPEN_PROTOCOL_BY_DRIVER
88 if (EFI_ERROR(Status
)) {
92 Status
= PciIo
->Pci
.Read (
96 sizeof(Pci
) / sizeof(UINT32
),
99 if (!EFI_ERROR (Status
)) {
100 Status
= EFI_UNSUPPORTED
;
101 if ((Pci
.Hdr
.Command
& 0x03) == 0x03) {
102 if (Pci
.Hdr
.ClassCode
[2] == PCI_CLASS_BRIDGE
) {
104 // See if this is a standard PCI to ISA Bridge from the Base Code and Class Code
106 if (Pci
.Hdr
.ClassCode
[1] == PCI_CLASS_BRIDGE_ISA
) {
107 Status
= EFI_SUCCESS
;
111 // See if this is an Intel PCI to ISA bridge in Positive Decode Mode
113 if (Pci
.Hdr
.ClassCode
[1] == PCI_CLASS_BRIDGE_ISA_PDECODE
&&
114 Pci
.Hdr
.VendorId
== 0x8086 &&
115 (Pci
.Hdr
.DeviceId
& 0xF000) == 0x7000) {
116 Status
= EFI_SUCCESS
;
124 &gEfiPciIoProtocolGuid
,
125 This
->DriverBindingHandle
,
133 Install EFI_ISA_ACPI_PROTOCOL.
135 @param This Driver Binding protocol instance pointer.
136 @param ControllerHandle Handle of device to bind driver to.
137 @param RemainingDevicePath Optional parameter use to pick a specific child
140 @retval EFI_SUCCESS This driver is added to ControllerHandle
141 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
142 @retval other This driver does not support this device
146 PcatIsaAcpiDriverBindingStart (
147 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
148 IN EFI_HANDLE Controller
,
149 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
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 Stop this driver on ControllerHandle. Support stopping any child handles
252 created by this driver.
254 @param This Protocol instance pointer.
255 @param ControllerHandle Handle of device to stop driver on
256 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
257 children is zero stop the entire bus driver.
258 @param ChildHandleBuffer List of Child Handles to Stop.
260 @retval EFI_SUCCESS This driver is removed ControllerHandle
261 @retval other This driver was not removed from this device
266 PcatIsaAcpiDriverBindingStop (
267 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
268 IN EFI_HANDLE Controller
,
269 IN UINTN NumberOfChildren
,
270 IN EFI_HANDLE
*ChildHandleBuffer
274 EFI_ISA_ACPI_PROTOCOL
*IsaAcpi
;
275 PCAT_ISA_ACPI_DEV
*PcatIsaAcpiDev
;
278 // Get the ISA ACPI Protocol Interface
280 Status
= gBS
->OpenProtocol (
282 &gEfiIsaAcpiProtocolGuid
,
284 This
->DriverBindingHandle
,
286 EFI_OPEN_PROTOCOL_GET_PROTOCOL
288 if (EFI_ERROR (Status
)) {
293 // Get the PCAT ISA ACPI Device structure from the ISA ACPI Protocol
295 PcatIsaAcpiDev
= PCAT_ISA_ACPI_DEV_FROM_THIS (IsaAcpi
);
297 PcatIsaAcpiDev
->PciIo
->Attributes (
298 PcatIsaAcpiDev
->PciIo
,
299 EfiPciIoAttributeOperationDisable
,
300 EFI_PCI_DEVICE_ENABLE
| EFI_PCI_IO_ATTRIBUTE_ISA_IO
| EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO
,
305 // Uninstall protocol interface: EFI_ISA_ACPI_PROTOCOL
307 Status
= gBS
->UninstallProtocolInterface (
309 &gEfiIsaAcpiProtocolGuid
, &PcatIsaAcpiDev
->IsaAcpi
311 if (EFI_ERROR (Status
)) {
317 &gEfiPciIoProtocolGuid
,
318 This
->DriverBindingHandle
,
322 gBS
->FreePool (PcatIsaAcpiDev
);