blob: 7b1ab1c8d5c55a649786399b0983f4a88ea634d7 [file] [log] [blame]
klu218c97f52010-04-12 04:38:44 +00001/** @file
2 ISA ACPI Protocol Implementation
klu2c69dd9d2008-04-17 05:48:13 +00003
lzeng14ce68d3b2012-10-11 02:15:23 +00004Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
klu218c97f52010-04-12 04:38:44 +00005This program and the accompanying materials
klu2c69dd9d2008-04-17 05:48:13 +00006are licensed and made available under the terms and conditions of the BSD License
7which accompanies this distribution. The full text of the license may be found at
8http://opensource.org/licenses/bsd-license.php
9
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
klu218c97f52010-04-12 04:38:44 +000012**/
klu2c69dd9d2008-04-17 05:48:13 +000013
14#include "PcatIsaAcpi.h"
15
16//
17// Platform specific data for the ISA devices that are present.in the platform
18//
19
20//
21// COM 1 UART Controller
22//
niruiyue8bce4b2011-03-10 07:33:42 +000023GLOBAL_REMOVE_IF_UNREFERENCED
jji4e56dd2c2008-10-30 06:17:19 +000024EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiCom1DeviceResources[] = {
klu2c69dd9d2008-04-17 05:48:13 +000025 {EfiIsaAcpiResourceIo, 0, 0x3f8, 0x3ff},
26 {EfiIsaAcpiResourceInterrupt, 0, 4, 0},
27 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
28};
29
30//
31// COM 2 UART Controller
32//
niruiyue8bce4b2011-03-10 07:33:42 +000033GLOBAL_REMOVE_IF_UNREFERENCED
jji4e56dd2c2008-10-30 06:17:19 +000034EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiCom2DeviceResources[] = {
klu2c69dd9d2008-04-17 05:48:13 +000035 {EfiIsaAcpiResourceIo, 0, 0x2f8, 0x2ff},
36 {EfiIsaAcpiResourceInterrupt, 0, 3, 0},
37 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
38};
39
40//
41// PS/2 Keyboard Controller
42//
niruiyue8bce4b2011-03-10 07:33:42 +000043GLOBAL_REMOVE_IF_UNREFERENCED
jji4e56dd2c2008-10-30 06:17:19 +000044EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiPs2KeyboardDeviceResources[] = {
klu2c69dd9d2008-04-17 05:48:13 +000045 {EfiIsaAcpiResourceIo, 0, 0x60, 0x64},
46 {EfiIsaAcpiResourceInterrupt, 0, 1, 0},
47 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
48};
49
50//
51// PS/2 Mouse Controller
52//
niruiyue8bce4b2011-03-10 07:33:42 +000053GLOBAL_REMOVE_IF_UNREFERENCED
jji4e56dd2c2008-10-30 06:17:19 +000054EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiPs2MouseDeviceResources[] = {
klu2c69dd9d2008-04-17 05:48:13 +000055 {EfiIsaAcpiResourceIo, 0, 0x60, 0x64},
56 {EfiIsaAcpiResourceInterrupt, 0, 12, 0},
57 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
58};
59
60//
61// Floppy Disk Controller
62//
niruiyue8bce4b2011-03-10 07:33:42 +000063GLOBAL_REMOVE_IF_UNREFERENCED
jji4e56dd2c2008-10-30 06:17:19 +000064EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiFloppyResources[] = {
klu2c69dd9d2008-04-17 05:48:13 +000065 {EfiIsaAcpiResourceIo, 0, 0x3f0, 0x3f7},
66 {EfiIsaAcpiResourceInterrupt, 0, 6, 0},
67 {EfiIsaAcpiResourceDma, EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE | EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8 | EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE, 2, 0},
68 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
69};
70
niruiyue8bce4b2011-03-10 07:33:42 +000071GLOBAL_REMOVE_IF_UNREFERENCED
72EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiCom1Device = {
73 {EISA_PNP_ID(0x501), 0}, mPcatIsaAcpiCom1DeviceResources
74}; // COM 1 UART Controller
75
76GLOBAL_REMOVE_IF_UNREFERENCED
77EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiCom2Device = {
78 {EISA_PNP_ID(0x501), 1}, mPcatIsaAcpiCom2DeviceResources
79}; // COM 2 UART Controller
80
81GLOBAL_REMOVE_IF_UNREFERENCED
82EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiPs2KeyboardDevice = {
83 {EISA_PNP_ID(0x303), 0}, mPcatIsaAcpiPs2KeyboardDeviceResources
84}; // PS/2 Keyboard Controller
85
86GLOBAL_REMOVE_IF_UNREFERENCED
87EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiPs2MouseDevice = {
88 {EISA_PNP_ID(0x303), 1}, mPcatIsaAcpiPs2MouseDeviceResources
89}; // PS/2 Mouse Controller
90
91GLOBAL_REMOVE_IF_UNREFERENCED
92EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiFloppyADevice = {
93 {EISA_PNP_ID(0x604), 0}, mPcatIsaAcpiFloppyResources
94}; // Floppy Disk Controller A:
95
96GLOBAL_REMOVE_IF_UNREFERENCED
97EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiFloppyBDevice = {
98 {EISA_PNP_ID(0x604), 1}, mPcatIsaAcpiFloppyResources
99}; // Floppy Disk Controller B:
100
klu2c69dd9d2008-04-17 05:48:13 +0000101//
102// Table of ISA Controllers
103//
lzeng14ce68d3b2012-10-11 02:15:23 +0000104EFI_ISA_ACPI_RESOURCE_LIST gPcatIsaAcpiDeviceList[7] = {{{0, 0}, NULL}};
niruiyue8bce4b2011-03-10 07:33:42 +0000105
106/**
107 Initialize gPcatIsaAcpiDeviceList.
108**/
109VOID
110InitializePcatIsaAcpiDeviceList (
111 VOID
112 )
113{
114 UINTN Index;
115
116 Index = 0;
117 if (PcdGetBool (PcdIsaAcpiCom1Enable)) {
118 CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiCom1Device, sizeof(mPcatIsaAcpiCom1Device));
119 Index++;
120 }
121 if (PcdGetBool (PcdIsaAcpiCom2Enable)) {
122 CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiCom2Device, sizeof(mPcatIsaAcpiCom2Device));
123 Index++;
124 }
125 if (PcdGetBool (PcdIsaAcpiPs2KeyboardEnable)) {
126 CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiPs2KeyboardDevice, sizeof(mPcatIsaAcpiPs2KeyboardDevice));
127 Index++;
128 }
129 if (PcdGetBool (PcdIsaAcpiPs2MouseEnable)) {
130 CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiPs2MouseDevice, sizeof(mPcatIsaAcpiPs2MouseDevice));
131 Index++;
132 }
133 if (PcdGetBool (PcdIsaAcpiFloppyAEnable)) {
134 CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiFloppyADevice, sizeof(mPcatIsaAcpiFloppyADevice));
135 Index++;
136 }
137 if (PcdGetBool (PcdIsaAcpiFloppyBEnable)) {
138 CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiFloppyBDevice, sizeof(mPcatIsaAcpiFloppyBDevice));
139 Index++;
140 }
141}
klu2c69dd9d2008-04-17 05:48:13 +0000142
143//
144// ISA ACPI Protocol Functions
145//
klu218c97f52010-04-12 04:38:44 +0000146/**
147 Enumerate the ISA devices on the ISA bus.
148
149 @param Device Point to device ID instance
150 @param IsaAcpiDevice On return, point to resource data for Isa device
151 @param NextIsaAcpiDevice On return, point to resource data for next Isa device
152**/
klu2c69dd9d2008-04-17 05:48:13 +0000153VOID
154IsaDeviceLookup (
155 IN EFI_ISA_ACPI_DEVICE_ID *Device,
156 OUT EFI_ISA_ACPI_RESOURCE_LIST **IsaAcpiDevice,
157 OUT EFI_ISA_ACPI_RESOURCE_LIST **NextIsaAcpiDevice
158 )
klu2c69dd9d2008-04-17 05:48:13 +0000159{
160 UINTN Index;
161
162 *IsaAcpiDevice = NULL;
163 if (NextIsaAcpiDevice != NULL) {
164 *NextIsaAcpiDevice = NULL;
165 }
166 if (Device == NULL) {
167 Index = 0;
168 } else {
169 for(Index = 0; gPcatIsaAcpiDeviceList[Index].ResourceItem != NULL; Index++) {
170 if (Device->HID == gPcatIsaAcpiDeviceList[Index].Device.HID &&
171 Device->UID == gPcatIsaAcpiDeviceList[Index].Device.UID ) {
172 break;
173 }
174 }
175 if (gPcatIsaAcpiDeviceList[Index].ResourceItem == NULL) {
176 return;
177 }
178 *IsaAcpiDevice = &(gPcatIsaAcpiDeviceList[Index]);
179 Index++;
180 }
181 if (gPcatIsaAcpiDeviceList[Index].ResourceItem != NULL && NextIsaAcpiDevice != NULL) {
182 *NextIsaAcpiDevice = &(gPcatIsaAcpiDeviceList[Index]);
183 }
184}
185
klu218c97f52010-04-12 04:38:44 +0000186/**
187 Enumerate the ISA devices on the ISA bus
188
189
190 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
191 @param Device Point to device ID instance
192
193 @retval EFI_NOT_FOUND Can not found the next Isa device.
194 @retval EFI_SUCESS Success retrieve the next Isa device for enumration.
195
196**/
klu2c69dd9d2008-04-17 05:48:13 +0000197EFI_STATUS
198EFIAPI
199IsaDeviceEnumerate (
200 IN EFI_ISA_ACPI_PROTOCOL *This,
201 OUT EFI_ISA_ACPI_DEVICE_ID **Device
202 )
klu2c69dd9d2008-04-17 05:48:13 +0000203{
204 EFI_ISA_ACPI_RESOURCE_LIST *IsaAcpiDevice;
205 EFI_ISA_ACPI_RESOURCE_LIST *NextIsaAcpiDevice;
206
207 IsaDeviceLookup (*Device, &IsaAcpiDevice, &NextIsaAcpiDevice);
208 if (NextIsaAcpiDevice == NULL) {
209 return EFI_NOT_FOUND;
210 }
211 *Device = &(NextIsaAcpiDevice->Device);
212 return EFI_SUCCESS;
213}
214
klu218c97f52010-04-12 04:38:44 +0000215/**
216 Set ISA device power
217
218
219 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
220 @param Device Point to device ID instance
221 @param OnOff TRUE for setting isa device power on,
222 FALSE for setting isa device power off
223
224 @return EFI_SUCCESS Sucess to change power status for isa device.
225**/
klu2c69dd9d2008-04-17 05:48:13 +0000226EFI_STATUS
227EFIAPI
228IsaDeviceSetPower (
229 IN EFI_ISA_ACPI_PROTOCOL *This,
230 IN EFI_ISA_ACPI_DEVICE_ID *Device,
231 IN BOOLEAN OnOff
232 )
klu2c69dd9d2008-04-17 05:48:13 +0000233{
234 return EFI_SUCCESS;
235}
236
klu218c97f52010-04-12 04:38:44 +0000237/**
238 Get current resource for the specific ISA device.
239
240 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
241 @param Device Point to device ID instance
242 @param ResourceList On return, point to resources instances for given isa device
243
244 @retval EFI_NOT_FOUND Can not found the resource instance for given isa device
245 @retval EFI_SUCCESS Success to get resource instance for given isa device.
246**/
klu2c69dd9d2008-04-17 05:48:13 +0000247EFI_STATUS
248EFIAPI
249IsaGetCurrentResource (
250 IN EFI_ISA_ACPI_PROTOCOL *This,
251 IN EFI_ISA_ACPI_DEVICE_ID *Device,
252 OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList
253 )
klu2c69dd9d2008-04-17 05:48:13 +0000254{
255 IsaDeviceLookup (Device, ResourceList, NULL);
256 if (*ResourceList == NULL) {
257 return EFI_NOT_FOUND;
258 }
259 return EFI_SUCCESS;
260}
261
klu218c97f52010-04-12 04:38:44 +0000262/**
263 Get possible resource for the specific ISA device.
264
265 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
266 @param Device Point to device ID instance
267 @param ResourceList On return, point to resources instances for given isa device
268
269 @retval EFI_SUCCESS Success to get resource instance for given isa device.
270**/
klu2c69dd9d2008-04-17 05:48:13 +0000271EFI_STATUS
272EFIAPI
273IsaGetPossibleResource (
274 IN EFI_ISA_ACPI_PROTOCOL *This,
275 IN EFI_ISA_ACPI_DEVICE_ID *Device,
276 OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList
277 )
klu2c69dd9d2008-04-17 05:48:13 +0000278{
279 return EFI_SUCCESS;
280}
281
klu218c97f52010-04-12 04:38:44 +0000282/**
283 Set resource for the specific ISA device.
284
285 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
286 @param Device Point to device ID instance
287 @param ResourceList Point to resources instances for given isa device
288
289 @return EFI_SUCESS Success to set resource.
290
291**/
klu2c69dd9d2008-04-17 05:48:13 +0000292EFI_STATUS
293EFIAPI
294IsaSetResource (
295 IN EFI_ISA_ACPI_PROTOCOL *This,
296 IN EFI_ISA_ACPI_DEVICE_ID *Device,
297 IN EFI_ISA_ACPI_RESOURCE_LIST *ResourceList
298 )
klu2c69dd9d2008-04-17 05:48:13 +0000299{
300 return EFI_SUCCESS;
301}
302
klu218c97f52010-04-12 04:38:44 +0000303/**
304 Enable/Disable the specific ISA device.
305
306 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
307 @param Device Point to device ID instance
308 @param Enable Enable/Disable
309
310 @return EFI_SUCESS Success to enable/disable.
311
312**/
klu2c69dd9d2008-04-17 05:48:13 +0000313EFI_STATUS
314EFIAPI
315IsaEnableDevice (
316 IN EFI_ISA_ACPI_PROTOCOL *This,
317 IN EFI_ISA_ACPI_DEVICE_ID *Device,
318 IN BOOLEAN Enable
319 )
klu2c69dd9d2008-04-17 05:48:13 +0000320{
321 return EFI_SUCCESS;
322}
323
klu218c97f52010-04-12 04:38:44 +0000324/**
325 Initialize the specific ISA device.
326
327 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
328 @param Device Point to device ID instance
329
330 @return EFI_SUCESS Success to initialize.
331
332**/
klu2c69dd9d2008-04-17 05:48:13 +0000333EFI_STATUS
334EFIAPI
335IsaInitDevice (
336 IN EFI_ISA_ACPI_PROTOCOL *This,
337 IN EFI_ISA_ACPI_DEVICE_ID *Device
338 )
klu2c69dd9d2008-04-17 05:48:13 +0000339{
340 return EFI_SUCCESS;
341}
342
343
klu218c97f52010-04-12 04:38:44 +0000344/**
345 Initialize the ISA interface.
346
347 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
348
349 @return EFI_SUCESS Success to initialize ISA interface.
350
351**/
klu2c69dd9d2008-04-17 05:48:13 +0000352EFI_STATUS
353EFIAPI
354IsaInterfaceInit (
355 IN EFI_ISA_ACPI_PROTOCOL *This
356)
klu2c69dd9d2008-04-17 05:48:13 +0000357{
358 return EFI_SUCCESS;
359}