1 /** @file
2 ISA ACPI Protocol Implementation
3
4 Copyright (c) 2006 - 2012, 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
9
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.
12 **/
13
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 //
23 GLOBAL_REMOVE_IF_UNREFERENCED
24 EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiCom1DeviceResources[] = {
25 {EfiIsaAcpiResourceIo, 0, 0x3f8, 0x3ff},
26 {EfiIsaAcpiResourceInterrupt, 0, 4, 0},
27 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
28 };
29
30 //
31 // COM 2 UART Controller
32 //
33 GLOBAL_REMOVE_IF_UNREFERENCED
34 EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiCom2DeviceResources[] = {
35 {EfiIsaAcpiResourceIo, 0, 0x2f8, 0x2ff},
36 {EfiIsaAcpiResourceInterrupt, 0, 3, 0},
37 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
38 };
39
40 //
41 // PS/2 Keyboard Controller
42 //
43 GLOBAL_REMOVE_IF_UNREFERENCED
44 EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiPs2KeyboardDeviceResources[] = {
45 {EfiIsaAcpiResourceIo, 0, 0x60, 0x64},
46 {EfiIsaAcpiResourceInterrupt, 0, 1, 0},
47 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
48 };
49
50 //
51 // PS/2 Mouse Controller
52 //
53 GLOBAL_REMOVE_IF_UNREFERENCED
54 EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiPs2MouseDeviceResources[] = {
55 {EfiIsaAcpiResourceIo, 0, 0x60, 0x64},
56 {EfiIsaAcpiResourceInterrupt, 0, 12, 0},
57 {EfiIsaAcpiResourceEndOfList, 0, 0, 0}
58 };
59
60 //
61 // Floppy Disk Controller
62 //
63 GLOBAL_REMOVE_IF_UNREFERENCED
64 EFI_ISA_ACPI_RESOURCE mPcatIsaAcpiFloppyResources[] = {
65 {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
71 GLOBAL_REMOVE_IF_UNREFERENCED
72 EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiCom1Device = {
73 {EISA_PNP_ID(0x501), 0}, mPcatIsaAcpiCom1DeviceResources
74 }; // COM 1 UART Controller
75
76 GLOBAL_REMOVE_IF_UNREFERENCED
77 EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiCom2Device = {
78 {EISA_PNP_ID(0x501), 1}, mPcatIsaAcpiCom2DeviceResources
79 }; // COM 2 UART Controller
80
81 GLOBAL_REMOVE_IF_UNREFERENCED
82 EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiPs2KeyboardDevice = {
83 {EISA_PNP_ID(0x303), 0}, mPcatIsaAcpiPs2KeyboardDeviceResources
84 }; // PS/2 Keyboard Controller
85
86 GLOBAL_REMOVE_IF_UNREFERENCED
87 EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiPs2MouseDevice = {
88 {EISA_PNP_ID(0x303), 1}, mPcatIsaAcpiPs2MouseDeviceResources
89 }; // PS/2 Mouse Controller
90
91 GLOBAL_REMOVE_IF_UNREFERENCED
92 EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiFloppyADevice = {
93 {EISA_PNP_ID(0x604), 0}, mPcatIsaAcpiFloppyResources
94 }; // Floppy Disk Controller A:
95
96 GLOBAL_REMOVE_IF_UNREFERENCED
97 EFI_ISA_ACPI_RESOURCE_LIST mPcatIsaAcpiFloppyBDevice = {
98 {EISA_PNP_ID(0x604), 1}, mPcatIsaAcpiFloppyResources
99 }; // Floppy Disk Controller B:
100
101 //
102 // Table of ISA Controllers
103 //
104 EFI_ISA_ACPI_RESOURCE_LIST gPcatIsaAcpiDeviceList[7] = {{{0, 0}, NULL}};
105
106 /**
107 Initialize gPcatIsaAcpiDeviceList.
108 **/
109 VOID
InitializePcatIsaAcpiDeviceList(VOID)110 InitializePcatIsaAcpiDeviceList (
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 #ifdef NOT_BHYVE
134 if (PcdGetBool (PcdIsaAcpiFloppyAEnable)) {
135 CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiFloppyADevice, sizeof(mPcatIsaAcpiFloppyADevice));
136 Index++;
137 }
138 if (PcdGetBool (PcdIsaAcpiFloppyBEnable)) {
139 CopyMem (&gPcatIsaAcpiDeviceList[Index], &mPcatIsaAcpiFloppyBDevice, sizeof(mPcatIsaAcpiFloppyBDevice));
140 Index++;
141 }
142 #endif
143 }
144
145 //
146 // ISA ACPI Protocol Functions
147 //
148 /**
149 Enumerate the ISA devices on the ISA bus.
150
151 @param Device Point to device ID instance
152 @param IsaAcpiDevice On return, point to resource data for Isa device
153 @param NextIsaAcpiDevice On return, point to resource data for next Isa device
154 **/
155 VOID
IsaDeviceLookup(IN EFI_ISA_ACPI_DEVICE_ID * Device,OUT EFI_ISA_ACPI_RESOURCE_LIST ** IsaAcpiDevice,OUT EFI_ISA_ACPI_RESOURCE_LIST ** NextIsaAcpiDevice)156 IsaDeviceLookup (
157 IN EFI_ISA_ACPI_DEVICE_ID *Device,
158 OUT EFI_ISA_ACPI_RESOURCE_LIST **IsaAcpiDevice,
159 OUT EFI_ISA_ACPI_RESOURCE_LIST **NextIsaAcpiDevice
160 )
161 {
162 UINTN Index;
163
164 *IsaAcpiDevice = NULL;
165 if (NextIsaAcpiDevice != NULL) {
166 *NextIsaAcpiDevice = NULL;
167 }
168 if (Device == NULL) {
169 Index = 0;
170 } else {
171 for(Index = 0; gPcatIsaAcpiDeviceList[Index].ResourceItem != NULL; Index++) {
172 if (Device->HID == gPcatIsaAcpiDeviceList[Index].Device.HID &&
173 Device->UID == gPcatIsaAcpiDeviceList[Index].Device.UID ) {
174 break;
175 }
176 }
177 if (gPcatIsaAcpiDeviceList[Index].ResourceItem == NULL) {
178 return;
179 }
180 *IsaAcpiDevice = &(gPcatIsaAcpiDeviceList[Index]);
181 Index++;
182 }
183 if (gPcatIsaAcpiDeviceList[Index].ResourceItem != NULL && NextIsaAcpiDevice != NULL) {
184 *NextIsaAcpiDevice = &(gPcatIsaAcpiDeviceList[Index]);
185 }
186 }
187
188 /**
189 Enumerate the ISA devices on the ISA bus
190
191
192 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
193 @param Device Point to device ID instance
194
195 @retval EFI_NOT_FOUND Can not found the next Isa device.
196 @retval EFI_SUCESS Success retrieve the next Isa device for enumration.
197
198 **/
199 EFI_STATUS
200 EFIAPI
IsaDeviceEnumerate(IN EFI_ISA_ACPI_PROTOCOL * This,OUT EFI_ISA_ACPI_DEVICE_ID ** Device)201 IsaDeviceEnumerate (
202 IN EFI_ISA_ACPI_PROTOCOL *This,
203 OUT EFI_ISA_ACPI_DEVICE_ID **Device
204 )
205 {
206 EFI_ISA_ACPI_RESOURCE_LIST *IsaAcpiDevice;
207 EFI_ISA_ACPI_RESOURCE_LIST *NextIsaAcpiDevice;
208
209 IsaDeviceLookup (*Device, &IsaAcpiDevice, &NextIsaAcpiDevice);
210 if (NextIsaAcpiDevice == NULL) {
211 return EFI_NOT_FOUND;
212 }
213 *Device = &(NextIsaAcpiDevice->Device);
214 return EFI_SUCCESS;
215 }
216
217 /**
218 Set ISA device power
219
220
221 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
222 @param Device Point to device ID instance
223 @param OnOff TRUE for setting isa device power on,
224 FALSE for setting isa device power off
225
226 @return EFI_SUCCESS Sucess to change power status for isa device.
227 **/
228 EFI_STATUS
229 EFIAPI
IsaDeviceSetPower(IN EFI_ISA_ACPI_PROTOCOL * This,IN EFI_ISA_ACPI_DEVICE_ID * Device,IN BOOLEAN OnOff)230 IsaDeviceSetPower (
231 IN EFI_ISA_ACPI_PROTOCOL *This,
232 IN EFI_ISA_ACPI_DEVICE_ID *Device,
233 IN BOOLEAN OnOff
234 )
235 {
236 return EFI_SUCCESS;
237 }
238
239 /**
240 Get current resource for the specific ISA device.
241
242 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
243 @param Device Point to device ID instance
244 @param ResourceList On return, point to resources instances for given isa device
245
246 @retval EFI_NOT_FOUND Can not found the resource instance for given isa device
247 @retval EFI_SUCCESS Success to get resource instance for given isa device.
248 **/
249 EFI_STATUS
250 EFIAPI
IsaGetCurrentResource(IN EFI_ISA_ACPI_PROTOCOL * This,IN EFI_ISA_ACPI_DEVICE_ID * Device,OUT EFI_ISA_ACPI_RESOURCE_LIST ** ResourceList)251 IsaGetCurrentResource (
252 IN EFI_ISA_ACPI_PROTOCOL *This,
253 IN EFI_ISA_ACPI_DEVICE_ID *Device,
254 OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList
255 )
256 {
257 IsaDeviceLookup (Device, ResourceList, NULL);
258 if (*ResourceList == NULL) {
259 return EFI_NOT_FOUND;
260 }
261 return EFI_SUCCESS;
262 }
263
264 /**
265 Get possible resource for the specific ISA device.
266
267 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
268 @param Device Point to device ID instance
269 @param ResourceList On return, point to resources instances for given isa device
270
271 @retval EFI_SUCCESS Success to get resource instance for given isa device.
272 **/
273 EFI_STATUS
274 EFIAPI
IsaGetPossibleResource(IN EFI_ISA_ACPI_PROTOCOL * This,IN EFI_ISA_ACPI_DEVICE_ID * Device,OUT EFI_ISA_ACPI_RESOURCE_LIST ** ResourceList)275 IsaGetPossibleResource (
276 IN EFI_ISA_ACPI_PROTOCOL *This,
277 IN EFI_ISA_ACPI_DEVICE_ID *Device,
278 OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList
279 )
280 {
281 return EFI_SUCCESS;
282 }
283
284 /**
285 Set resource for the specific ISA device.
286
287 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
288 @param Device Point to device ID instance
289 @param ResourceList Point to resources instances for given isa device
290
291 @return EFI_SUCESS Success to set resource.
292
293 **/
294 EFI_STATUS
295 EFIAPI
IsaSetResource(IN EFI_ISA_ACPI_PROTOCOL * This,IN EFI_ISA_ACPI_DEVICE_ID * Device,IN EFI_ISA_ACPI_RESOURCE_LIST * ResourceList)296 IsaSetResource (
297 IN EFI_ISA_ACPI_PROTOCOL *This,
298 IN EFI_ISA_ACPI_DEVICE_ID *Device,
299 IN EFI_ISA_ACPI_RESOURCE_LIST *ResourceList
300 )
301 {
302 return EFI_SUCCESS;
303 }
304
305 /**
306 Enable/Disable the specific ISA device.
307
308 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
309 @param Device Point to device ID instance
310 @param Enable Enable/Disable
311
312 @return EFI_SUCESS Success to enable/disable.
313
314 **/
315 EFI_STATUS
316 EFIAPI
IsaEnableDevice(IN EFI_ISA_ACPI_PROTOCOL * This,IN EFI_ISA_ACPI_DEVICE_ID * Device,IN BOOLEAN Enable)317 IsaEnableDevice (
318 IN EFI_ISA_ACPI_PROTOCOL *This,
319 IN EFI_ISA_ACPI_DEVICE_ID *Device,
320 IN BOOLEAN Enable
321 )
322 {
323 return EFI_SUCCESS;
324 }
325
326 /**
327 Initialize the specific ISA device.
328
329 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
330 @param Device Point to device ID instance
331
332 @return EFI_SUCESS Success to initialize.
333
334 **/
335 EFI_STATUS
336 EFIAPI
IsaInitDevice(IN EFI_ISA_ACPI_PROTOCOL * This,IN EFI_ISA_ACPI_DEVICE_ID * Device)337 IsaInitDevice (
338 IN EFI_ISA_ACPI_PROTOCOL *This,
339 IN EFI_ISA_ACPI_DEVICE_ID *Device
340 )
341 {
342 return EFI_SUCCESS;
343 }
344
345
346 /**
347 Initialize the ISA interface.
348
349 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
350
351 @return EFI_SUCESS Success to initialize ISA interface.
352
353 **/
354 EFI_STATUS
355 EFIAPI
IsaInterfaceInit(IN EFI_ISA_ACPI_PROTOCOL * This)356 IsaInterfaceInit (
357 IN EFI_ISA_ACPI_PROTOCOL *This
358 )
359 {
360 return EFI_SUCCESS;
361 }
362