aeinstall.c revision 1.1.1.6 1 1.1 christos /******************************************************************************
2 1.1 christos *
3 1.1 christos * Module Name: aeinstall - Installation of operation region handlers
4 1.1 christos *
5 1.1 christos *****************************************************************************/
6 1.1 christos
7 1.1 christos /*
8 1.1.1.5 christos * Copyright (C) 2000 - 2021, Intel Corp.
9 1.1 christos * All rights reserved.
10 1.1 christos *
11 1.1 christos * Redistribution and use in source and binary forms, with or without
12 1.1 christos * modification, are permitted provided that the following conditions
13 1.1 christos * are met:
14 1.1 christos * 1. Redistributions of source code must retain the above copyright
15 1.1 christos * notice, this list of conditions, and the following disclaimer,
16 1.1 christos * without modification.
17 1.1 christos * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1 christos * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1 christos * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1 christos * including a substantially similar Disclaimer requirement for further
21 1.1 christos * binary redistribution.
22 1.1 christos * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1 christos * of any contributors may be used to endorse or promote products derived
24 1.1 christos * from this software without specific prior written permission.
25 1.1 christos *
26 1.1 christos * Alternatively, this software may be distributed under the terms of the
27 1.1 christos * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1 christos * Software Foundation.
29 1.1 christos *
30 1.1 christos * NO WARRANTY
31 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1 christos * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.5 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 1.1 christos * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1 christos * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1 christos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1 christos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1 christos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1 christos * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1 christos * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1 christos * POSSIBILITY OF SUCH DAMAGES.
42 1.1 christos */
43 1.1 christos
44 1.1 christos #include "aecommon.h"
45 1.1 christos
46 1.1 christos #define _COMPONENT ACPI_TOOLS
47 1.1 christos ACPI_MODULE_NAME ("aeinstall")
48 1.1 christos
49 1.1 christos
50 1.1 christos static ACPI_STATUS
51 1.1 christos AeRegionInit (
52 1.1 christos ACPI_HANDLE RegionHandle,
53 1.1 christos UINT32 Function,
54 1.1 christos void *HandlerContext,
55 1.1 christos void **RegionContext);
56 1.1 christos
57 1.1 christos static ACPI_STATUS
58 1.1 christos AeInstallEcHandler (
59 1.1 christos ACPI_HANDLE ObjHandle,
60 1.1 christos UINT32 Level,
61 1.1 christos void *Context,
62 1.1 christos void **ReturnValue);
63 1.1 christos
64 1.1 christos static ACPI_STATUS
65 1.1 christos AeInstallPciHandler (
66 1.1 christos ACPI_HANDLE ObjHandle,
67 1.1 christos UINT32 Level,
68 1.1 christos void *Context,
69 1.1 christos void **ReturnValue);
70 1.1 christos
71 1.1 christos
72 1.1 christos BOOLEAN AcpiGbl_DisplayRegionAccess = FALSE;
73 1.1 christos ACPI_CONNECTION_INFO AeMyContext;
74 1.1 christos
75 1.1 christos
76 1.1 christos /*
77 1.1 christos * We will override some of the default region handlers, especially
78 1.1 christos * the SystemMemory handler, which must be implemented locally.
79 1.1 christos * These handlers are installed "early" - before any _REG methods
80 1.1 christos * are executed - since they are special in the sense that the ACPI spec
81 1.1 christos * declares that they must "always be available". Cannot override the
82 1.1 christos * DataTable region handler either -- needed for test execution.
83 1.1 christos *
84 1.1 christos * NOTE: The local region handler will simulate access to these address
85 1.1 christos * spaces by creating a memory buffer behind each operation region.
86 1.1 christos */
87 1.1 christos static ACPI_ADR_SPACE_TYPE DefaultSpaceIdList[] =
88 1.1 christos {
89 1.1 christos ACPI_ADR_SPACE_SYSTEM_MEMORY,
90 1.1 christos ACPI_ADR_SPACE_SYSTEM_IO,
91 1.1 christos ACPI_ADR_SPACE_PCI_CONFIG,
92 1.1 christos ACPI_ADR_SPACE_EC
93 1.1 christos };
94 1.1 christos
95 1.1 christos /*
96 1.1 christos * We will install handlers for some of the various address space IDs.
97 1.1 christos * Test one user-defined address space (used by aslts).
98 1.1 christos */
99 1.1 christos #define ACPI_ADR_SPACE_USER_DEFINED1 0x80
100 1.1 christos #define ACPI_ADR_SPACE_USER_DEFINED2 0xE4
101 1.1 christos
102 1.1 christos static ACPI_ADR_SPACE_TYPE SpaceIdList[] =
103 1.1 christos {
104 1.1 christos ACPI_ADR_SPACE_SMBUS,
105 1.1 christos ACPI_ADR_SPACE_CMOS,
106 1.1 christos ACPI_ADR_SPACE_PCI_BAR_TARGET,
107 1.1 christos ACPI_ADR_SPACE_IPMI,
108 1.1 christos ACPI_ADR_SPACE_GPIO,
109 1.1 christos ACPI_ADR_SPACE_GSBUS,
110 1.1.1.3 christos ACPI_ADR_SPACE_PLATFORM_COMM,
111 1.1.1.6 christos ACPI_ADR_SPACE_PLATFORM_RT,
112 1.1 christos ACPI_ADR_SPACE_FIXED_HARDWARE,
113 1.1 christos ACPI_ADR_SPACE_USER_DEFINED1,
114 1.1 christos ACPI_ADR_SPACE_USER_DEFINED2
115 1.1 christos };
116 1.1 christos
117 1.1 christos
118 1.1 christos /******************************************************************************
119 1.1 christos *
120 1.1 christos * FUNCTION: AeRegionInit
121 1.1 christos *
122 1.1 christos * PARAMETERS: Region init handler
123 1.1 christos *
124 1.1 christos * RETURN: Status
125 1.1 christos *
126 1.1 christos * DESCRIPTION: Opregion init function.
127 1.1 christos *
128 1.1 christos *****************************************************************************/
129 1.1 christos
130 1.1 christos static ACPI_STATUS
131 1.1 christos AeRegionInit (
132 1.1 christos ACPI_HANDLE RegionHandle,
133 1.1 christos UINT32 Function,
134 1.1 christos void *HandlerContext,
135 1.1 christos void **RegionContext)
136 1.1 christos {
137 1.1 christos
138 1.1 christos if (Function == ACPI_REGION_DEACTIVATE)
139 1.1 christos {
140 1.1 christos *RegionContext = NULL;
141 1.1 christos }
142 1.1 christos else
143 1.1 christos {
144 1.1 christos *RegionContext = RegionHandle;
145 1.1 christos }
146 1.1 christos
147 1.1 christos return (AE_OK);
148 1.1 christos }
149 1.1 christos
150 1.1 christos
151 1.1 christos /******************************************************************************
152 1.1 christos *
153 1.1 christos * FUNCTION: AeOverrideRegionHandlers
154 1.1 christos *
155 1.1 christos * PARAMETERS: None
156 1.1 christos *
157 1.1 christos * RETURN: None
158 1.1 christos *
159 1.1 christos * DESCRIPTION: Override the default region handlers for memory, i/o, and
160 1.1 christos * pci_config. Also install a handler for EC. This is part of
161 1.1 christos * the "install early handlers" functionality.
162 1.1 christos *
163 1.1 christos *****************************************************************************/
164 1.1 christos
165 1.1 christos void
166 1.1 christos AeOverrideRegionHandlers (
167 1.1 christos void)
168 1.1 christos {
169 1.1 christos UINT32 i;
170 1.1 christos ACPI_STATUS Status;
171 1.1 christos
172 1.1 christos /*
173 1.1 christos * Install handlers that will override the default handlers for some of
174 1.1 christos * the space IDs.
175 1.1 christos */
176 1.1 christos for (i = 0; i < ACPI_ARRAY_LENGTH (DefaultSpaceIdList); i++)
177 1.1 christos {
178 1.1 christos /* Install handler at the root object */
179 1.1 christos
180 1.1 christos Status = AcpiInstallAddressSpaceHandler (ACPI_ROOT_OBJECT,
181 1.1 christos DefaultSpaceIdList[i], AeRegionHandler, AeRegionInit,
182 1.1 christos &AeMyContext);
183 1.1 christos
184 1.1 christos if (ACPI_FAILURE (Status))
185 1.1 christos {
186 1.1 christos ACPI_EXCEPTION ((AE_INFO, Status,
187 1.1 christos "Could not install an OpRegion handler for %s space(%u)",
188 1.1 christos AcpiUtGetRegionName ((UINT8) DefaultSpaceIdList[i]),
189 1.1 christos DefaultSpaceIdList[i]));
190 1.1 christos }
191 1.1 christos }
192 1.1 christos }
193 1.1 christos
194 1.1 christos
195 1.1 christos /******************************************************************************
196 1.1 christos *
197 1.1 christos * FUNCTION: AeInstallRegionHandlers
198 1.1 christos *
199 1.1 christos * PARAMETERS: None
200 1.1 christos *
201 1.1 christos * RETURN: None
202 1.1 christos *
203 1.1 christos * DESCRIPTION: Install handlers for the address spaces other than
204 1.1 christos * SystemMemory, SystemIO, and PCI_CONFIG.
205 1.1 christos *
206 1.1 christos *****************************************************************************/
207 1.1 christos
208 1.1 christos void
209 1.1 christos AeInstallRegionHandlers (
210 1.1 christos void)
211 1.1 christos {
212 1.1 christos UINT32 i;
213 1.1 christos ACPI_STATUS Status;
214 1.1 christos
215 1.1 christos
216 1.1 christos /*
217 1.1 christos * Install handlers for some of the "device driver" address spaces
218 1.1 christos * such as SMBus, etc.
219 1.1 christos */
220 1.1 christos for (i = 0; i < ACPI_ARRAY_LENGTH (SpaceIdList); i++)
221 1.1 christos {
222 1.1 christos /* Install handler at the root object */
223 1.1 christos
224 1.1 christos Status = AcpiInstallAddressSpaceHandler (ACPI_ROOT_OBJECT,
225 1.1 christos SpaceIdList[i], AeRegionHandler, AeRegionInit,
226 1.1 christos &AeMyContext);
227 1.1 christos
228 1.1 christos if (ACPI_FAILURE (Status))
229 1.1 christos {
230 1.1 christos ACPI_EXCEPTION ((AE_INFO, Status,
231 1.1 christos "Could not install an OpRegion handler for %s space(%u)",
232 1.1 christos AcpiUtGetRegionName((UINT8) SpaceIdList[i]), SpaceIdList[i]));
233 1.1 christos return;
234 1.1 christos }
235 1.1 christos }
236 1.1 christos }
237 1.1 christos
238 1.1 christos
239 1.1 christos /*******************************************************************************
240 1.1 christos *
241 1.1 christos * FUNCTION: AeInstallDeviceHandlers
242 1.1 christos *
243 1.1 christos * PARAMETERS: None
244 1.1 christos *
245 1.1 christos * RETURN: Status
246 1.1 christos *
247 1.1 christos * DESCRIPTION: Install handlers for all EC and PCI devices in the namespace
248 1.1 christos *
249 1.1 christos ******************************************************************************/
250 1.1 christos
251 1.1 christos ACPI_STATUS
252 1.1 christos AeInstallDeviceHandlers (
253 1.1 christos void)
254 1.1 christos {
255 1.1 christos
256 1.1 christos /* Find all Embedded Controller devices */
257 1.1 christos
258 1.1 christos AcpiGetDevices ("PNP0C09", AeInstallEcHandler, NULL, NULL);
259 1.1 christos
260 1.1 christos /* Install a PCI handler */
261 1.1 christos
262 1.1 christos AcpiGetDevices ("PNP0A08", AeInstallPciHandler, NULL, NULL);
263 1.1 christos return (AE_OK);
264 1.1 christos }
265 1.1 christos
266 1.1 christos
267 1.1 christos /*******************************************************************************
268 1.1 christos *
269 1.1 christos * FUNCTION: AeInstallEcHandler
270 1.1 christos *
271 1.1 christos * PARAMETERS: ACPI_WALK_NAMESPACE callback
272 1.1 christos *
273 1.1 christos * RETURN: Status
274 1.1 christos *
275 1.1 christos * DESCRIPTION: Walk entire namespace, install a handler for every EC
276 1.1 christos * device found.
277 1.1 christos *
278 1.1 christos ******************************************************************************/
279 1.1 christos
280 1.1 christos static ACPI_STATUS
281 1.1 christos AeInstallEcHandler (
282 1.1 christos ACPI_HANDLE ObjHandle,
283 1.1 christos UINT32 Level,
284 1.1 christos void *Context,
285 1.1 christos void **ReturnValue)
286 1.1 christos {
287 1.1 christos ACPI_STATUS Status;
288 1.1 christos
289 1.1 christos
290 1.1 christos /* Install the handler for this EC device */
291 1.1 christos
292 1.1 christos Status = AcpiInstallAddressSpaceHandler (ObjHandle,
293 1.1 christos ACPI_ADR_SPACE_EC, AeRegionHandler, AeRegionInit, &AeMyContext);
294 1.1 christos if (ACPI_FAILURE (Status))
295 1.1 christos {
296 1.1 christos ACPI_EXCEPTION ((AE_INFO, Status,
297 1.1 christos "Could not install an OpRegion handler for EC device (%p)",
298 1.1 christos ObjHandle));
299 1.1 christos }
300 1.1 christos
301 1.1 christos return (Status);
302 1.1 christos }
303 1.1 christos
304 1.1 christos
305 1.1 christos /*******************************************************************************
306 1.1 christos *
307 1.1 christos * FUNCTION: AeInstallPciHandler
308 1.1 christos *
309 1.1 christos * PARAMETERS: ACPI_WALK_NAMESPACE callback
310 1.1 christos *
311 1.1 christos * RETURN: Status
312 1.1 christos *
313 1.1 christos * DESCRIPTION: Walk entire namespace, install a handler for every PCI
314 1.1 christos * device found.
315 1.1 christos *
316 1.1 christos ******************************************************************************/
317 1.1 christos
318 1.1 christos static ACPI_STATUS
319 1.1 christos AeInstallPciHandler (
320 1.1 christos ACPI_HANDLE ObjHandle,
321 1.1 christos UINT32 Level,
322 1.1 christos void *Context,
323 1.1 christos void **ReturnValue)
324 1.1 christos {
325 1.1 christos ACPI_STATUS Status;
326 1.1 christos
327 1.1 christos
328 1.1 christos /* Install memory and I/O handlers for the PCI device */
329 1.1 christos
330 1.1 christos Status = AcpiInstallAddressSpaceHandler (ObjHandle,
331 1.1 christos ACPI_ADR_SPACE_SYSTEM_IO, AeRegionHandler, AeRegionInit,
332 1.1 christos &AeMyContext);
333 1.1 christos if (ACPI_FAILURE (Status))
334 1.1 christos {
335 1.1 christos ACPI_EXCEPTION ((AE_INFO, Status,
336 1.1 christos "Could not install an OpRegion handler for PCI device (%p)",
337 1.1 christos ObjHandle));
338 1.1 christos }
339 1.1 christos
340 1.1 christos Status = AcpiInstallAddressSpaceHandler (ObjHandle,
341 1.1 christos ACPI_ADR_SPACE_SYSTEM_MEMORY, AeRegionHandler, AeRegionInit,
342 1.1 christos &AeMyContext);
343 1.1 christos if (ACPI_FAILURE (Status))
344 1.1 christos {
345 1.1 christos ACPI_EXCEPTION ((AE_INFO, Status,
346 1.1 christos "Could not install an OpRegion handler for PCI device (%p)",
347 1.1 christos ObjHandle));
348 1.1 christos }
349 1.1 christos
350 1.1 christos return (AE_CTRL_TERMINATE);
351 1.1 christos }
352