3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 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.
21 EFI Lpc Driver for a Generic PC Platform
27 #include "LpcDriver.h"
28 #include "IndustryStandard/Pci22.h"
31 // This driver is for ACPI(PNP0A03,0)/PCI(0x1f,0)
35 // Lpc Driver Global Variables
38 EFI_DRIVER_BINDING_PROTOCOL gLpcDriver
= {
53 IsaGetCurrentResource
,
54 IsaGetPossibleResource
,
63 BOOLEAN InitExecuted
= FALSE
;
66 the entry point of the Lpc driver
72 IN EFI_HANDLE ImageHandle
,
73 IN EFI_SYSTEM_TABLE
*SystemTable
78 return EfiLibInstallDriverBinding (ImageHandle
, SystemTable
, &gLpcDriver
, ImageHandle
);
83 ControllerDriver Protocol Method
89 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
90 IN EFI_HANDLE Controller
,
91 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
95 EFI_PCI_IO_PROTOCOL
*PciIo
;
96 EFI_DEVICE_PATH_PROTOCOL
*IsaBridgeDevicePath
;
98 ACPI_HID_DEVICE_PATH
*AcpiNode
;
99 PCI_DEVICE_PATH
*PciNode
;
103 // Get the ISA bridge's Device Path and test it
104 // the following code is specific
106 Status
= gBS
->OpenProtocol (
108 &gEfiDevicePathProtocolGuid
,
109 (VOID
**)&IsaBridgeDevicePath
,
110 This
->DriverBindingHandle
,
112 EFI_OPEN_PROTOCOL_BY_DRIVER
115 if (EFI_ERROR (Status
)) {
119 Status
= EFI_SUCCESS
;
120 AcpiNode
= (ACPI_HID_DEVICE_PATH
*)IsaBridgeDevicePath
;
121 if (AcpiNode
->Header
.Type
!= ACPI_DEVICE_PATH
||
122 AcpiNode
->Header
.SubType
!= ACPI_DP
||
123 DevicePathNodeLength (&AcpiNode
->Header
) != sizeof(ACPI_HID_DEVICE_PATH
) ||
124 AcpiNode
-> HID
!= EISA_PNP_ID(0x0A03) ||
125 AcpiNode
-> UID
!= 0 ) {
126 Status
= EFI_UNSUPPORTED
;
131 IsaBridgeDevicePath
= NextDevicePathNode (IsaBridgeDevicePath
);
132 PciNode
= (PCI_DEVICE_PATH
*)IsaBridgeDevicePath
;
133 if (PciNode
->Header
.Type
!= HARDWARE_DEVICE_PATH
||
134 PciNode
->Header
.SubType
!= HW_PCI_DP
||
135 DevicePathNodeLength (&PciNode
->Header
) != sizeof (PCI_DEVICE_PATH
) ||
136 PciNode
-> Function
!= 0x00 ||
137 PciNode
-> Device
!= 0x1f ) {
138 Status
= EFI_UNSUPPORTED
;
144 &gEfiDevicePathProtocolGuid
,
145 This
->DriverBindingHandle
,
149 if (EFI_ERROR (Status
)) {
150 return EFI_UNSUPPORTED
;
154 // Get PciIo protocol instance
156 Status
= gBS
->OpenProtocol (
158 &gEfiPciIoProtocolGuid
,
160 This
->DriverBindingHandle
,
162 EFI_OPEN_PROTOCOL_BY_DRIVER
165 if (EFI_ERROR(Status
)) {
169 Status
= PciIo
->Pci
.Read (
173 sizeof(Pci
) / sizeof(UINT32
),
177 if (!EFI_ERROR (Status
)) {
178 Status
= EFI_SUCCESS
; //TODO: force return success as temp solution EFI_UNSUPPORTED;
179 if ((Pci
.Hdr
.Command
& 0x03) == 0x03) {
180 if (Pci
.Hdr
.ClassCode
[2] == PCI_CLASS_BRIDGE
) {
182 // See if this is a standard PCI to ISA Bridge from the Base Code
185 if (Pci
.Hdr
.ClassCode
[1] == PCI_CLASS_BRIDGE_ISA
) {
186 Status
= EFI_SUCCESS
;
191 // See if this is an Intel PCI to ISA bridge in Positive Decode Mode
193 if (Pci
.Hdr
.ClassCode
[1] == PCI_CLASS_BRIDGE_ISA_PDECODE
&&
194 Pci
.Hdr
.VendorId
== 0x8086 &&
195 Pci
.Hdr
.DeviceId
== 0x7110) {
196 Status
= EFI_SUCCESS
;
208 &gEfiPciIoProtocolGuid
,
209 This
->DriverBindingHandle
,
217 Install EFI_ISA_ACPI_PROTOCOL
223 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
224 IN EFI_HANDLE Controller
,
225 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
229 EFI_PCI_IO_PROTOCOL
*PciIo
;
234 Status
= gBS
->OpenProtocol (
236 &gEfiPciIoProtocolGuid
,
238 This
->DriverBindingHandle
,
240 EFI_OPEN_PROTOCOL_BY_DRIVER
243 if (EFI_ERROR (Status
) && Status
!= EFI_ALREADY_STARTED
) {
250 // Install IsaAcpi interface, the Sio interface is not installed!
252 Status
= gBS
->InstallMultipleProtocolInterfaces (
254 &gEfiIsaAcpiProtocolGuid
,
265 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
266 IN EFI_HANDLE Controller
,
267 IN UINTN NumberOfChildren
,
268 IN EFI_HANDLE
*ChildHandleBuffer
272 EFI_ISA_ACPI_PROTOCOL
*IsaAcpi
;
276 // Get EFI_ISA_ACPI_PROTOCOL interface
278 Status
= gBS
->OpenProtocol (
280 &gEfiIsaAcpiProtocolGuid
,
282 This
->DriverBindingHandle
,
284 EFI_OPEN_PROTOCOL_GET_PROTOCOL
286 if (EFI_ERROR (Status
)) {
290 LpcDev
= LPC_ISA_ACPI_FROM_THIS (IsaAcpi
);
293 // Uninstall protocol interface: EFI_ISA_ACPI_PROTOCOL
295 Status
= gBS
->UninstallProtocolInterface (
297 &gEfiIsaAcpiProtocolGuid
,
300 if (EFI_ERROR (Status
)) {
306 &gEfiPciIoProtocolGuid
,
307 This
->DriverBindingHandle
,
323 EFI_PCI_IO_PASS_THROUGH_BAR
,
336 mLpc
.PciIo
->Io
.Write(
339 EFI_PCI_IO_PASS_THROUGH_BAR
,