PcAtChipsetPkg: Clean up source files
[mirror_edk2.git] / PcAtChipsetPkg / IsaAcpiDxe / IsaAcpi.c
1 /** @file
2 ISA ACPI Protocol Implementation
3
4 Copyright (c) 2006 - 2018, 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
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 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 }
142
143 //
144 // ISA ACPI Protocol Functions
145 //
146 /**
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 **/
153 VOID
154 IsaDeviceLookup (
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 )
159 {
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
186 /**
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_SUCCESS Success retrieve the next Isa device for enumration.
195
196 **/
197 EFI_STATUS
198 EFIAPI
199 IsaDeviceEnumerate (
200 IN EFI_ISA_ACPI_PROTOCOL *This,
201 OUT EFI_ISA_ACPI_DEVICE_ID **Device
202 )
203 {
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
215 /**
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 Success to change power status for isa device.
225 **/
226 EFI_STATUS
227 EFIAPI
228 IsaDeviceSetPower (
229 IN EFI_ISA_ACPI_PROTOCOL *This,
230 IN EFI_ISA_ACPI_DEVICE_ID *Device,
231 IN BOOLEAN OnOff
232 )
233 {
234 return EFI_SUCCESS;
235 }
236
237 /**
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 **/
247 EFI_STATUS
248 EFIAPI
249 IsaGetCurrentResource (
250 IN EFI_ISA_ACPI_PROTOCOL *This,
251 IN EFI_ISA_ACPI_DEVICE_ID *Device,
252 OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList
253 )
254 {
255 IsaDeviceLookup (Device, ResourceList, NULL);
256 if (*ResourceList == NULL) {
257 return EFI_NOT_FOUND;
258 }
259 return EFI_SUCCESS;
260 }
261
262 /**
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 **/
271 EFI_STATUS
272 EFIAPI
273 IsaGetPossibleResource (
274 IN EFI_ISA_ACPI_PROTOCOL *This,
275 IN EFI_ISA_ACPI_DEVICE_ID *Device,
276 OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList
277 )
278 {
279 return EFI_SUCCESS;
280 }
281
282 /**
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_SUCCESS Success to set resource.
290
291 **/
292 EFI_STATUS
293 EFIAPI
294 IsaSetResource (
295 IN EFI_ISA_ACPI_PROTOCOL *This,
296 IN EFI_ISA_ACPI_DEVICE_ID *Device,
297 IN EFI_ISA_ACPI_RESOURCE_LIST *ResourceList
298 )
299 {
300 return EFI_SUCCESS;
301 }
302
303 /**
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_SUCCESS Success to enable/disable.
311
312 **/
313 EFI_STATUS
314 EFIAPI
315 IsaEnableDevice (
316 IN EFI_ISA_ACPI_PROTOCOL *This,
317 IN EFI_ISA_ACPI_DEVICE_ID *Device,
318 IN BOOLEAN Enable
319 )
320 {
321 return EFI_SUCCESS;
322 }
323
324 /**
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_SUCCESS Success to initialize.
331
332 **/
333 EFI_STATUS
334 EFIAPI
335 IsaInitDevice (
336 IN EFI_ISA_ACPI_PROTOCOL *This,
337 IN EFI_ISA_ACPI_DEVICE_ID *Device
338 )
339 {
340 return EFI_SUCCESS;
341 }
342
343
344 /**
345 Initialize the ISA interface.
346
347 @param This Point to instance of EFI_ISA_ACPI_PROTOCOL
348
349 @return EFI_SUCCESS Success to initialize ISA interface.
350
351 **/
352 EFI_STATUS
353 EFIAPI
354 IsaInterfaceInit (
355 IN EFI_ISA_ACPI_PROTOCOL *This
356 )
357 {
358 return EFI_SUCCESS;
359 }