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