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