aehandlers.c revision 1.1.1.13 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: aehandlers - Various handlers for acpiexec
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.1.1.2 jruoho /*
8 1.1.1.13 christos * Copyright (C) 2000 - 2019, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without
12 1.1.1.2 jruoho * modification, are permitted provided that the following conditions
13 1.1.1.2 jruoho * are met:
14 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2 jruoho * without modification.
17 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further
21 1.1.1.2 jruoho * binary redistribution.
22 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived
24 1.1.1.2 jruoho * from this software without specific prior written permission.
25 1.1.1.2 jruoho *
26 1.1.1.2 jruoho * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2 jruoho * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2 jruoho * Software Foundation.
29 1.1.1.2 jruoho *
30 1.1.1.2 jruoho * NO WARRANTY
31 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2 jruoho * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2 jruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2 jruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2 jruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2 jruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2 jruoho * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2 jruoho */
43 1.1 jruoho
44 1.1 jruoho #include "aecommon.h"
45 1.1 jruoho
46 1.1 jruoho #define _COMPONENT ACPI_TOOLS
47 1.1 jruoho ACPI_MODULE_NAME ("aehandlers")
48 1.1 jruoho
49 1.1.1.5 christos
50 1.1 jruoho /* Local prototypes */
51 1.1 jruoho
52 1.1.1.2 jruoho static void
53 1.1.1.4 christos AeNotifyHandler1 (
54 1.1 jruoho ACPI_HANDLE Device,
55 1.1 jruoho UINT32 Value,
56 1.1 jruoho void *Context);
57 1.1 jruoho
58 1.1.1.2 jruoho static void
59 1.1.1.4 christos AeNotifyHandler2 (
60 1.1.1.4 christos ACPI_HANDLE Device,
61 1.1.1.4 christos UINT32 Value,
62 1.1.1.4 christos void *Context);
63 1.1.1.4 christos
64 1.1.1.4 christos static void
65 1.1.1.4 christos AeCommonNotifyHandler (
66 1.1.1.4 christos ACPI_HANDLE Device,
67 1.1.1.4 christos UINT32 Value,
68 1.1.1.4 christos UINT32 HandlerId);
69 1.1.1.4 christos
70 1.1.1.4 christos static void
71 1.1 jruoho AeDeviceNotifyHandler (
72 1.1 jruoho ACPI_HANDLE Device,
73 1.1 jruoho UINT32 Value,
74 1.1 jruoho void *Context);
75 1.1 jruoho
76 1.1.1.2 jruoho static ACPI_STATUS
77 1.1 jruoho AeTableHandler (
78 1.1 jruoho UINT32 Event,
79 1.1 jruoho void *Table,
80 1.1 jruoho void *Context);
81 1.1 jruoho
82 1.1.1.2 jruoho static void
83 1.1 jruoho AeAttachedDataHandler (
84 1.1 jruoho ACPI_HANDLE Object,
85 1.1 jruoho void *Data);
86 1.1 jruoho
87 1.1.1.4 christos static void
88 1.1.1.4 christos AeAttachedDataHandler2 (
89 1.1.1.4 christos ACPI_HANDLE Object,
90 1.1.1.4 christos void *Data);
91 1.1.1.4 christos
92 1.1.1.2 jruoho static UINT32
93 1.1.1.2 jruoho AeInterfaceHandler (
94 1.1.1.2 jruoho ACPI_STRING InterfaceName,
95 1.1.1.2 jruoho UINT32 Supported);
96 1.1.1.2 jruoho
97 1.1.1.4 christos #if (!ACPI_REDUCED_HARDWARE)
98 1.1.1.2 jruoho static UINT32
99 1.1.1.2 jruoho AeEventHandler (
100 1.1.1.2 jruoho void *Context);
101 1.1.1.2 jruoho
102 1.1.1.4 christos static UINT32
103 1.1.1.4 christos AeSciHandler (
104 1.1.1.4 christos void *Context);
105 1.1.1.4 christos
106 1.1.1.4 christos static char *TableEvents[] =
107 1.1.1.4 christos {
108 1.1.1.4 christos "LOAD",
109 1.1.1.4 christos "UNLOAD",
110 1.1.1.9 christos "INSTALL",
111 1.1.1.9 christos "UNINSTALL",
112 1.1.1.4 christos "UNKNOWN"
113 1.1.1.4 christos };
114 1.1.1.4 christos #endif /* !ACPI_REDUCED_HARDWARE */
115 1.1.1.4 christos
116 1.1.1.4 christos
117 1.1.1.2 jruoho static AE_DEBUG_REGIONS AeRegions;
118 1.1.1.4 christos
119 1.1 jruoho
120 1.1 jruoho /******************************************************************************
121 1.1 jruoho *
122 1.1.1.4 christos * FUNCTION: AeNotifyHandler(s)
123 1.1 jruoho *
124 1.1 jruoho * PARAMETERS: Standard notify handler parameters
125 1.1 jruoho *
126 1.1 jruoho * RETURN: Status
127 1.1 jruoho *
128 1.1.1.4 christos * DESCRIPTION: Notify handlers for AcpiExec utility. Used by the ASL
129 1.1 jruoho * test suite(s) to communicate errors and other information to
130 1.1.1.4 christos * this utility via the Notify() operator. Tests notify handling
131 1.1.1.4 christos * and multiple notify handler support.
132 1.1 jruoho *
133 1.1 jruoho *****************************************************************************/
134 1.1 jruoho
135 1.1.1.2 jruoho static void
136 1.1.1.4 christos AeNotifyHandler1 (
137 1.1.1.4 christos ACPI_HANDLE Device,
138 1.1.1.4 christos UINT32 Value,
139 1.1.1.4 christos void *Context)
140 1.1.1.4 christos {
141 1.1.1.4 christos AeCommonNotifyHandler (Device, Value, 1);
142 1.1.1.4 christos }
143 1.1.1.4 christos
144 1.1.1.4 christos static void
145 1.1.1.4 christos AeNotifyHandler2 (
146 1.1.1.4 christos ACPI_HANDLE Device,
147 1.1.1.4 christos UINT32 Value,
148 1.1.1.4 christos void *Context)
149 1.1.1.4 christos {
150 1.1.1.4 christos AeCommonNotifyHandler (Device, Value, 2);
151 1.1.1.4 christos }
152 1.1.1.4 christos
153 1.1.1.4 christos static void
154 1.1.1.4 christos AeCommonNotifyHandler (
155 1.1.1.4 christos ACPI_HANDLE Device,
156 1.1.1.4 christos UINT32 Value,
157 1.1.1.4 christos UINT32 HandlerId)
158 1.1 jruoho {
159 1.1.1.4 christos char *Type;
160 1.1.1.4 christos
161 1.1.1.4 christos
162 1.1.1.4 christos Type = "Device";
163 1.1.1.4 christos if (Value <= ACPI_MAX_SYS_NOTIFY)
164 1.1.1.4 christos {
165 1.1.1.4 christos Type = "System";
166 1.1.1.4 christos }
167 1.1 jruoho
168 1.1 jruoho switch (Value)
169 1.1 jruoho {
170 1.1 jruoho #if 0
171 1.1 jruoho case 0:
172 1.1.1.4 christos
173 1.1.1.11 christos printf (AE_PREFIX
174 1.1.1.11 christos "Method Error 0x%X: Results not equal\n", Value);
175 1.1 jruoho if (AcpiGbl_DebugFile)
176 1.1 jruoho {
177 1.1.1.11 christos AcpiOsPrintf (AE_PREFIX
178 1.1.1.11 christos "Method Error: Results not equal\n");
179 1.1 jruoho }
180 1.1 jruoho break;
181 1.1 jruoho
182 1.1 jruoho case 1:
183 1.1.1.4 christos
184 1.1.1.11 christos printf (AE_PREFIX
185 1.1.1.11 christos "Method Error: Incorrect numeric result\n");
186 1.1 jruoho if (AcpiGbl_DebugFile)
187 1.1 jruoho {
188 1.1.1.11 christos AcpiOsPrintf (AE_PREFIX
189 1.1.1.11 christos "Method Error: Incorrect numeric result\n");
190 1.1 jruoho }
191 1.1 jruoho break;
192 1.1 jruoho
193 1.1 jruoho case 2:
194 1.1.1.4 christos
195 1.1.1.11 christos printf (AE_PREFIX
196 1.1.1.11 christos "Method Error: An operand was overwritten\n");
197 1.1 jruoho if (AcpiGbl_DebugFile)
198 1.1 jruoho {
199 1.1.1.11 christos AcpiOsPrintf (AE_PREFIX
200 1.1.1.11 christos "Method Error: An operand was overwritten\n");
201 1.1 jruoho }
202 1.1 jruoho break;
203 1.1 jruoho
204 1.1 jruoho #endif
205 1.1 jruoho
206 1.1 jruoho default:
207 1.1.1.4 christos
208 1.1.1.11 christos printf (AE_PREFIX
209 1.1.1.11 christos "Handler %u: Received a %s Notify on [%4.4s] %p Value 0x%2.2X (%s)\n",
210 1.1.1.4 christos HandlerId, Type, AcpiUtGetNodeName (Device), Device, Value,
211 1.1.1.5 christos AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY));
212 1.1 jruoho if (AcpiGbl_DebugFile)
213 1.1 jruoho {
214 1.1.1.11 christos AcpiOsPrintf (AE_PREFIX
215 1.1.1.11 christos "Handler %u: Received a %s notify, Value 0x%2.2X\n",
216 1.1.1.4 christos HandlerId, Type, Value);
217 1.1 jruoho }
218 1.1 jruoho
219 1.1 jruoho (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL);
220 1.1 jruoho break;
221 1.1 jruoho }
222 1.1 jruoho }
223 1.1 jruoho
224 1.1 jruoho
225 1.1 jruoho /******************************************************************************
226 1.1 jruoho *
227 1.1.1.4 christos * FUNCTION: AeSystemNotifyHandler
228 1.1.1.4 christos *
229 1.1.1.4 christos * PARAMETERS: Standard notify handler parameters
230 1.1.1.4 christos *
231 1.1.1.4 christos * RETURN: Status
232 1.1.1.4 christos *
233 1.1.1.4 christos * DESCRIPTION: System notify handler for AcpiExec utility. Used by the ASL
234 1.1.1.4 christos * test suite(s) to communicate errors and other information to
235 1.1.1.4 christos * this utility via the Notify() operator.
236 1.1.1.4 christos *
237 1.1.1.4 christos *****************************************************************************/
238 1.1.1.4 christos
239 1.1.1.4 christos static void
240 1.1.1.4 christos AeSystemNotifyHandler (
241 1.1.1.4 christos ACPI_HANDLE Device,
242 1.1.1.4 christos UINT32 Value,
243 1.1.1.4 christos void *Context)
244 1.1.1.4 christos {
245 1.1.1.4 christos
246 1.1.1.11 christos printf (AE_PREFIX
247 1.1.1.11 christos "Global: Received a System Notify on [%4.4s] %p Value 0x%2.2X (%s)\n",
248 1.1.1.4 christos AcpiUtGetNodeName (Device), Device, Value,
249 1.1.1.5 christos AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY));
250 1.1.1.4 christos if (AcpiGbl_DebugFile)
251 1.1.1.4 christos {
252 1.1.1.11 christos AcpiOsPrintf (AE_PREFIX
253 1.1.1.11 christos "Global: Received a System Notify, Value 0x%2.2X\n", Value);
254 1.1.1.4 christos }
255 1.1.1.4 christos
256 1.1.1.4 christos (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL);
257 1.1.1.4 christos }
258 1.1.1.4 christos
259 1.1.1.4 christos
260 1.1.1.4 christos /******************************************************************************
261 1.1.1.4 christos *
262 1.1 jruoho * FUNCTION: AeDeviceNotifyHandler
263 1.1 jruoho *
264 1.1 jruoho * PARAMETERS: Standard notify handler parameters
265 1.1 jruoho *
266 1.1 jruoho * RETURN: Status
267 1.1 jruoho *
268 1.1.1.4 christos * DESCRIPTION: Device notify handler for AcpiExec utility. Used by the ASL
269 1.1 jruoho * test suite(s) to communicate errors and other information to
270 1.1 jruoho * this utility via the Notify() operator.
271 1.1 jruoho *
272 1.1 jruoho *****************************************************************************/
273 1.1 jruoho
274 1.1.1.2 jruoho static void
275 1.1 jruoho AeDeviceNotifyHandler (
276 1.1 jruoho ACPI_HANDLE Device,
277 1.1 jruoho UINT32 Value,
278 1.1 jruoho void *Context)
279 1.1 jruoho {
280 1.1 jruoho
281 1.1.1.11 christos printf (AE_PREFIX
282 1.1.1.11 christos "Global: Received a Device Notify on [%4.4s] %p Value 0x%2.2X (%s)\n",
283 1.1 jruoho AcpiUtGetNodeName (Device), Device, Value,
284 1.1.1.5 christos AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY));
285 1.1 jruoho if (AcpiGbl_DebugFile)
286 1.1 jruoho {
287 1.1.1.11 christos AcpiOsPrintf (AE_PREFIX
288 1.1.1.11 christos "Global: Received a Device Notify, Value 0x%2.2X\n", Value);
289 1.1 jruoho }
290 1.1 jruoho
291 1.1 jruoho (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL);
292 1.1 jruoho }
293 1.1 jruoho
294 1.1 jruoho
295 1.1 jruoho /******************************************************************************
296 1.1 jruoho *
297 1.1 jruoho * FUNCTION: AeTableHandler
298 1.1 jruoho *
299 1.1 jruoho * PARAMETERS: Table handler
300 1.1 jruoho *
301 1.1 jruoho * RETURN: Status
302 1.1 jruoho *
303 1.1 jruoho * DESCRIPTION: System table handler for AcpiExec utility.
304 1.1 jruoho *
305 1.1 jruoho *****************************************************************************/
306 1.1 jruoho
307 1.1.1.2 jruoho static ACPI_STATUS
308 1.1 jruoho AeTableHandler (
309 1.1 jruoho UINT32 Event,
310 1.1 jruoho void *Table,
311 1.1 jruoho void *Context)
312 1.1 jruoho {
313 1.1.1.4 christos #if (!ACPI_REDUCED_HARDWARE)
314 1.1.1.2 jruoho ACPI_STATUS Status;
315 1.1.1.4 christos #endif /* !ACPI_REDUCED_HARDWARE */
316 1.1.1.2 jruoho
317 1.1 jruoho
318 1.1 jruoho if (Event > ACPI_NUM_TABLE_EVENTS)
319 1.1 jruoho {
320 1.1 jruoho Event = ACPI_NUM_TABLE_EVENTS;
321 1.1 jruoho }
322 1.1 jruoho
323 1.1.1.4 christos #if (!ACPI_REDUCED_HARDWARE)
324 1.1.1.2 jruoho /* Enable any GPEs associated with newly-loaded GPE methods */
325 1.1.1.2 jruoho
326 1.1.1.2 jruoho Status = AcpiUpdateAllGpes ();
327 1.1.1.8 christos ACPI_CHECK_OK (AcpiUpdateAllGpes, Status);
328 1.1 jruoho
329 1.1.1.11 christos printf (AE_PREFIX "Table Event %s, [%4.4s] %p\n",
330 1.1.1.11 christos TableEvents[Event],
331 1.1.1.11 christos ((ACPI_TABLE_HEADER *) Table)->Signature, Table);
332 1.1.1.4 christos #endif /* !ACPI_REDUCED_HARDWARE */
333 1.1.1.4 christos
334 1.1 jruoho return (AE_OK);
335 1.1 jruoho }
336 1.1 jruoho
337 1.1 jruoho
338 1.1 jruoho /******************************************************************************
339 1.1 jruoho *
340 1.1 jruoho * FUNCTION: AeGpeHandler
341 1.1 jruoho *
342 1.1.1.2 jruoho * DESCRIPTION: Common GPE handler for acpiexec
343 1.1 jruoho *
344 1.1 jruoho *****************************************************************************/
345 1.1 jruoho
346 1.1 jruoho UINT32
347 1.1 jruoho AeGpeHandler (
348 1.1.1.2 jruoho ACPI_HANDLE GpeDevice,
349 1.1.1.2 jruoho UINT32 GpeNumber,
350 1.1 jruoho void *Context)
351 1.1 jruoho {
352 1.1.1.2 jruoho ACPI_NAMESPACE_NODE *DeviceNode = (ACPI_NAMESPACE_NODE *) GpeDevice;
353 1.1.1.2 jruoho
354 1.1.1.2 jruoho
355 1.1.1.11 christos AcpiOsPrintf (AE_PREFIX
356 1.1.1.11 christos "GPE Handler received GPE %02X (GPE block %4.4s)\n",
357 1.1.1.2 jruoho GpeNumber, GpeDevice ? DeviceNode->Name.Ascii : "FADT");
358 1.1.1.2 jruoho
359 1.1.1.2 jruoho return (ACPI_REENABLE_GPE);
360 1.1.1.2 jruoho }
361 1.1.1.2 jruoho
362 1.1.1.2 jruoho
363 1.1.1.2 jruoho /******************************************************************************
364 1.1.1.2 jruoho *
365 1.1.1.2 jruoho * FUNCTION: AeGlobalEventHandler
366 1.1.1.2 jruoho *
367 1.1.1.2 jruoho * DESCRIPTION: Global GPE/Fixed event handler
368 1.1.1.2 jruoho *
369 1.1.1.2 jruoho *****************************************************************************/
370 1.1.1.2 jruoho
371 1.1.1.2 jruoho void
372 1.1.1.2 jruoho AeGlobalEventHandler (
373 1.1.1.2 jruoho UINT32 Type,
374 1.1.1.2 jruoho ACPI_HANDLE Device,
375 1.1.1.2 jruoho UINT32 EventNumber,
376 1.1.1.2 jruoho void *Context)
377 1.1.1.2 jruoho {
378 1.1.1.2 jruoho char *TypeName;
379 1.1.1.2 jruoho
380 1.1.1.2 jruoho
381 1.1.1.2 jruoho switch (Type)
382 1.1.1.2 jruoho {
383 1.1.1.2 jruoho case ACPI_EVENT_TYPE_GPE:
384 1.1.1.4 christos
385 1.1.1.2 jruoho TypeName = "GPE";
386 1.1.1.2 jruoho break;
387 1.1.1.2 jruoho
388 1.1.1.2 jruoho case ACPI_EVENT_TYPE_FIXED:
389 1.1.1.4 christos
390 1.1.1.2 jruoho TypeName = "FixedEvent";
391 1.1.1.2 jruoho break;
392 1.1.1.2 jruoho
393 1.1.1.2 jruoho default:
394 1.1.1.4 christos
395 1.1.1.2 jruoho TypeName = "UNKNOWN";
396 1.1.1.2 jruoho break;
397 1.1.1.2 jruoho }
398 1.1.1.2 jruoho
399 1.1.1.11 christos AcpiOsPrintf (AE_PREFIX
400 1.1.1.11 christos "Global Event Handler received: Type %s Number %.2X Dev %p\n",
401 1.1.1.2 jruoho TypeName, EventNumber, Device);
402 1.1 jruoho }
403 1.1 jruoho
404 1.1 jruoho
405 1.1 jruoho /******************************************************************************
406 1.1 jruoho *
407 1.1 jruoho * FUNCTION: AeAttachedDataHandler
408 1.1 jruoho *
409 1.1 jruoho * DESCRIPTION: Handler for deletion of nodes with attached data (attached via
410 1.1 jruoho * AcpiAttachData)
411 1.1 jruoho *
412 1.1 jruoho *****************************************************************************/
413 1.1 jruoho
414 1.1.1.2 jruoho static void
415 1.1 jruoho AeAttachedDataHandler (
416 1.1 jruoho ACPI_HANDLE Object,
417 1.1 jruoho void *Data)
418 1.1 jruoho {
419 1.1 jruoho ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Data);
420 1.1 jruoho
421 1.1.1.12 christos ACPI_FUNCTION_NAME (AeAttachedDataHandler1);
422 1.1 jruoho
423 1.1.1.12 christos
424 1.1.1.12 christos ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
425 1.1.1.12 christos "Received an attached data deletion at handler 1 on %4.4s\n",
426 1.1.1.12 christos Node->Name.Ascii));
427 1.1.1.4 christos }
428 1.1.1.4 christos
429 1.1.1.4 christos
430 1.1.1.4 christos /******************************************************************************
431 1.1.1.4 christos *
432 1.1.1.4 christos * FUNCTION: AeAttachedDataHandler2
433 1.1.1.4 christos *
434 1.1.1.4 christos * DESCRIPTION: Handler for deletion of nodes with attached data (attached via
435 1.1.1.4 christos * AcpiAttachData)
436 1.1.1.4 christos *
437 1.1.1.4 christos *****************************************************************************/
438 1.1.1.4 christos
439 1.1.1.4 christos static void
440 1.1.1.4 christos AeAttachedDataHandler2 (
441 1.1.1.4 christos ACPI_HANDLE Object,
442 1.1.1.4 christos void *Data)
443 1.1.1.4 christos {
444 1.1.1.4 christos ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Data);
445 1.1.1.4 christos
446 1.1.1.12 christos ACPI_FUNCTION_NAME (AeAttachedDataHandler2);
447 1.1.1.4 christos
448 1.1.1.12 christos
449 1.1.1.12 christos ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
450 1.1.1.12 christos "Received an attached data deletion at handler 2 on %4.4s\n",
451 1.1.1.12 christos Node->Name.Ascii));
452 1.1 jruoho }
453 1.1 jruoho
454 1.1 jruoho
455 1.1 jruoho /******************************************************************************
456 1.1 jruoho *
457 1.1.1.2 jruoho * FUNCTION: AeInterfaceHandler
458 1.1.1.2 jruoho *
459 1.1.1.2 jruoho * DESCRIPTION: Handler for _OSI invocations
460 1.1.1.2 jruoho *
461 1.1.1.2 jruoho *****************************************************************************/
462 1.1.1.2 jruoho
463 1.1.1.2 jruoho static UINT32
464 1.1.1.2 jruoho AeInterfaceHandler (
465 1.1.1.2 jruoho ACPI_STRING InterfaceName,
466 1.1.1.2 jruoho UINT32 Supported)
467 1.1.1.2 jruoho {
468 1.1.1.2 jruoho ACPI_FUNCTION_NAME (AeInterfaceHandler);
469 1.1.1.2 jruoho
470 1.1.1.2 jruoho
471 1.1.1.2 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
472 1.1.1.2 jruoho "Received _OSI (\"%s\"), is %ssupported\n",
473 1.1.1.2 jruoho InterfaceName, Supported == 0 ? "not " : ""));
474 1.1.1.2 jruoho
475 1.1.1.2 jruoho return (Supported);
476 1.1.1.2 jruoho }
477 1.1.1.2 jruoho
478 1.1.1.2 jruoho
479 1.1.1.4 christos #if (!ACPI_REDUCED_HARDWARE)
480 1.1.1.2 jruoho /******************************************************************************
481 1.1.1.2 jruoho *
482 1.1.1.4 christos * FUNCTION: AeEventHandler, AeSciHandler
483 1.1.1.2 jruoho *
484 1.1.1.4 christos * DESCRIPTION: Handler for Fixed Events and SCIs
485 1.1.1.2 jruoho *
486 1.1.1.2 jruoho *****************************************************************************/
487 1.1.1.2 jruoho
488 1.1.1.2 jruoho static UINT32
489 1.1.1.2 jruoho AeEventHandler (
490 1.1.1.2 jruoho void *Context)
491 1.1.1.2 jruoho {
492 1.1.1.2 jruoho return (0);
493 1.1.1.2 jruoho }
494 1.1.1.2 jruoho
495 1.1.1.4 christos static UINT32
496 1.1.1.4 christos AeSciHandler (
497 1.1.1.4 christos void *Context)
498 1.1.1.4 christos {
499 1.1.1.4 christos
500 1.1.1.11 christos AcpiOsPrintf (AE_PREFIX
501 1.1.1.11 christos "Received an SCI at handler\n");
502 1.1.1.4 christos return (0);
503 1.1.1.4 christos }
504 1.1.1.4 christos
505 1.1.1.4 christos #endif /* !ACPI_REDUCED_HARDWARE */
506 1.1.1.4 christos
507 1.1.1.2 jruoho
508 1.1.1.4 christos /*******************************************************************************
509 1.1.1.4 christos *
510 1.1.1.4 christos * FUNCTION: AeInstallSciHandler
511 1.1.1.4 christos *
512 1.1.1.4 christos * PARAMETERS: None
513 1.1.1.4 christos *
514 1.1.1.4 christos * RETURN: Status
515 1.1.1.4 christos *
516 1.1.1.4 christos * DESCRIPTION: Install handler for SCIs. Exercise the code by doing an
517 1.1.1.4 christos * install/remove/install.
518 1.1.1.4 christos *
519 1.1.1.4 christos ******************************************************************************/
520 1.1.1.4 christos
521 1.1.1.4 christos static ACPI_STATUS
522 1.1.1.4 christos AeInstallSciHandler (
523 1.1.1.4 christos void)
524 1.1.1.4 christos {
525 1.1.1.4 christos ACPI_STATUS Status;
526 1.1.1.4 christos
527 1.1.1.4 christos
528 1.1.1.4 christos Status = AcpiInstallSciHandler (AeSciHandler, &AeMyContext);
529 1.1.1.4 christos if (ACPI_FAILURE (Status))
530 1.1.1.4 christos {
531 1.1.1.4 christos ACPI_EXCEPTION ((AE_INFO, Status,
532 1.1.1.4 christos "Could not install an SCI handler (1)"));
533 1.1.1.4 christos }
534 1.1.1.4 christos
535 1.1.1.4 christos Status = AcpiRemoveSciHandler (AeSciHandler);
536 1.1.1.4 christos if (ACPI_FAILURE (Status))
537 1.1.1.4 christos {
538 1.1.1.4 christos ACPI_EXCEPTION ((AE_INFO, Status,
539 1.1.1.4 christos "Could not remove an SCI handler"));
540 1.1.1.4 christos }
541 1.1.1.4 christos
542 1.1.1.4 christos Status = AcpiInstallSciHandler (AeSciHandler, &AeMyContext);
543 1.1.1.4 christos if (ACPI_FAILURE (Status))
544 1.1.1.4 christos {
545 1.1.1.4 christos ACPI_EXCEPTION ((AE_INFO, Status,
546 1.1.1.4 christos "Could not install an SCI handler (2)"));
547 1.1.1.4 christos }
548 1.1.1.4 christos
549 1.1.1.4 christos return (Status);
550 1.1.1.4 christos }
551 1.1.1.4 christos
552 1.1.1.4 christos
553 1.1 jruoho /******************************************************************************
554 1.1 jruoho *
555 1.1.1.2 jruoho * FUNCTION: AeInstallLateHandlers
556 1.1 jruoho *
557 1.1 jruoho * PARAMETERS: None
558 1.1 jruoho *
559 1.1 jruoho * RETURN: Status
560 1.1 jruoho *
561 1.1 jruoho * DESCRIPTION: Install handlers for the AcpiExec utility.
562 1.1 jruoho *
563 1.1 jruoho *****************************************************************************/
564 1.1 jruoho
565 1.1.1.2 jruoho ACPI_STATUS
566 1.1.1.2 jruoho AeInstallLateHandlers (
567 1.1.1.2 jruoho void)
568 1.1.1.2 jruoho {
569 1.1.1.2 jruoho ACPI_STATUS Status;
570 1.1.1.8 christos ACPI_HANDLE Handle;
571 1.1.1.8 christos
572 1.1.1.8 christos
573 1.1.1.8 christos Status = AcpiGetHandle (NULL, "\\_TZ.TZ1", &Handle);
574 1.1.1.8 christos if (ACPI_SUCCESS (Status))
575 1.1.1.8 christos {
576 1.1.1.8 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
577 1.1.1.8 christos AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
578 1.1.1.8 christos
579 1.1.1.8 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
580 1.1.1.8 christos AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
581 1.1.1.8 christos
582 1.1.1.8 christos Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
583 1.1.1.8 christos AeNotifyHandler1);
584 1.1.1.8 christos Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
585 1.1.1.8 christos AeNotifyHandler2);
586 1.1.1.2 jruoho
587 1.1.1.8 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
588 1.1.1.8 christos AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
589 1.1.1.8 christos
590 1.1.1.8 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
591 1.1.1.8 christos AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
592 1.1.1.8 christos }
593 1.1.1.8 christos
594 1.1.1.8 christos Status = AcpiGetHandle (NULL, "\\_PR.CPU0", &Handle);
595 1.1.1.8 christos if (ACPI_SUCCESS (Status))
596 1.1.1.8 christos {
597 1.1.1.8 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
598 1.1.1.8 christos AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
599 1.1.1.8 christos
600 1.1.1.8 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
601 1.1.1.8 christos AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
602 1.1.1.8 christos }
603 1.1.1.2 jruoho
604 1.1.1.4 christos #if (!ACPI_REDUCED_HARDWARE)
605 1.1.1.4 christos if (!AcpiGbl_ReducedHardware)
606 1.1.1.4 christos {
607 1.1.1.4 christos /* Install a user SCI handler */
608 1.1.1.4 christos
609 1.1.1.4 christos Status = AeInstallSciHandler ();
610 1.1.1.8 christos ACPI_CHECK_OK (AeInstallSciHandler, Status);
611 1.1.1.4 christos
612 1.1.1.4 christos /* Install some fixed event handlers */
613 1.1.1.2 jruoho
614 1.1.1.8 christos Status = AcpiInstallFixedEventHandler (
615 1.1.1.8 christos ACPI_EVENT_GLOBAL, AeEventHandler, NULL);
616 1.1.1.8 christos ACPI_CHECK_OK (AcpiInstallFixedEventHandler, Status);
617 1.1.1.8 christos
618 1.1.1.8 christos Status = AcpiInstallFixedEventHandler (
619 1.1.1.8 christos ACPI_EVENT_RTC, AeEventHandler, NULL);
620 1.1.1.8 christos ACPI_CHECK_OK (AcpiInstallFixedEventHandler, Status);
621 1.1.1.4 christos }
622 1.1.1.4 christos #endif /* !ACPI_REDUCED_HARDWARE */
623 1.1.1.4 christos
624 1.1.1.4 christos AeMyContext.Connection = NULL;
625 1.1.1.4 christos AeMyContext.AccessLength = 0xA5;
626 1.1.1.4 christos
627 1.1.1.4 christos /*
628 1.1.1.4 christos * We will install a handler for each EC device, directly under the EC
629 1.1.1.4 christos * device definition. This is unlike the other handlers which we install
630 1.1.1.4 christos * at the root node. Also install memory and I/O handlers at any PCI
631 1.1.1.4 christos * devices.
632 1.1.1.4 christos */
633 1.1.1.4 christos AeInstallDeviceHandlers ();
634 1.1.1.2 jruoho
635 1.1.1.2 jruoho /*
636 1.1.1.2 jruoho * Install handlers for some of the "device driver" address spaces
637 1.1.1.4 christos * such as SMBus, etc.
638 1.1.1.2 jruoho */
639 1.1.1.5 christos AeInstallRegionHandlers ();
640 1.1.1.2 jruoho return (AE_OK);
641 1.1.1.2 jruoho }
642 1.1.1.2 jruoho
643 1.1.1.2 jruoho
644 1.1.1.2 jruoho /******************************************************************************
645 1.1.1.2 jruoho *
646 1.1.1.2 jruoho * FUNCTION: AeInstallEarlyHandlers
647 1.1.1.2 jruoho *
648 1.1.1.2 jruoho * PARAMETERS: None
649 1.1.1.2 jruoho *
650 1.1.1.2 jruoho * RETURN: Status
651 1.1.1.2 jruoho *
652 1.1.1.2 jruoho * DESCRIPTION: Install handlers for the AcpiExec utility.
653 1.1.1.2 jruoho *
654 1.1.1.2 jruoho * Notes: Don't install handler for PCI_Config, we want to use the
655 1.1.1.2 jruoho * default handler to exercise that code.
656 1.1.1.2 jruoho *
657 1.1.1.2 jruoho *****************************************************************************/
658 1.1 jruoho
659 1.1 jruoho ACPI_STATUS
660 1.1.1.2 jruoho AeInstallEarlyHandlers (
661 1.1.1.2 jruoho void)
662 1.1 jruoho {
663 1.1 jruoho ACPI_STATUS Status;
664 1.1 jruoho ACPI_HANDLE Handle;
665 1.1 jruoho
666 1.1 jruoho
667 1.1 jruoho ACPI_FUNCTION_ENTRY ();
668 1.1 jruoho
669 1.1 jruoho
670 1.1.1.2 jruoho Status = AcpiInstallInterfaceHandler (AeInterfaceHandler);
671 1.1.1.2 jruoho if (ACPI_FAILURE (Status))
672 1.1.1.2 jruoho {
673 1.1.1.2 jruoho printf ("Could not install interface handler, %s\n",
674 1.1.1.2 jruoho AcpiFormatException (Status));
675 1.1.1.2 jruoho }
676 1.1.1.2 jruoho
677 1.1 jruoho Status = AcpiInstallTableHandler (AeTableHandler, NULL);
678 1.1 jruoho if (ACPI_FAILURE (Status))
679 1.1 jruoho {
680 1.1 jruoho printf ("Could not install table handler, %s\n",
681 1.1 jruoho AcpiFormatException (Status));
682 1.1 jruoho }
683 1.1 jruoho
684 1.1 jruoho Status = AcpiInstallExceptionHandler (AeExceptionHandler);
685 1.1 jruoho if (ACPI_FAILURE (Status))
686 1.1 jruoho {
687 1.1 jruoho printf ("Could not install exception handler, %s\n",
688 1.1 jruoho AcpiFormatException (Status));
689 1.1 jruoho }
690 1.1 jruoho
691 1.1.1.4 christos /* Install global notify handlers */
692 1.1 jruoho
693 1.1.1.11 christos Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT,
694 1.1.1.11 christos ACPI_SYSTEM_NOTIFY, AeSystemNotifyHandler, NULL);
695 1.1 jruoho if (ACPI_FAILURE (Status))
696 1.1 jruoho {
697 1.1.1.4 christos printf ("Could not install a global system notify handler, %s\n",
698 1.1 jruoho AcpiFormatException (Status));
699 1.1 jruoho }
700 1.1 jruoho
701 1.1.1.11 christos Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT,
702 1.1.1.11 christos ACPI_DEVICE_NOTIFY, AeDeviceNotifyHandler, NULL);
703 1.1 jruoho if (ACPI_FAILURE (Status))
704 1.1 jruoho {
705 1.1 jruoho printf ("Could not install a global notify handler, %s\n",
706 1.1 jruoho AcpiFormatException (Status));
707 1.1 jruoho }
708 1.1 jruoho
709 1.1 jruoho Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
710 1.1 jruoho if (ACPI_SUCCESS (Status))
711 1.1 jruoho {
712 1.1 jruoho Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
713 1.1.1.4 christos AeNotifyHandler1, NULL);
714 1.1 jruoho if (ACPI_FAILURE (Status))
715 1.1 jruoho {
716 1.1 jruoho printf ("Could not install a notify handler, %s\n",
717 1.1 jruoho AcpiFormatException (Status));
718 1.1 jruoho }
719 1.1 jruoho
720 1.1 jruoho Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
721 1.1.1.4 christos AeNotifyHandler1);
722 1.1 jruoho if (ACPI_FAILURE (Status))
723 1.1 jruoho {
724 1.1 jruoho printf ("Could not remove a notify handler, %s\n",
725 1.1 jruoho AcpiFormatException (Status));
726 1.1 jruoho }
727 1.1 jruoho
728 1.1 jruoho Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
729 1.1.1.4 christos AeNotifyHandler1, NULL);
730 1.1.1.8 christos ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status);
731 1.1.1.2 jruoho
732 1.1 jruoho Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
733 1.1.1.4 christos AeNotifyHandler1);
734 1.1.1.8 christos ACPI_CHECK_OK (AcpiRemoveNotifyHandler, Status);
735 1.1.1.2 jruoho
736 1.1.1.4 christos #if 0
737 1.1 jruoho Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
738 1.1.1.4 christos AeNotifyHandler1, NULL);
739 1.1 jruoho if (ACPI_FAILURE (Status))
740 1.1 jruoho {
741 1.1 jruoho printf ("Could not install a notify handler, %s\n",
742 1.1 jruoho AcpiFormatException (Status));
743 1.1 jruoho }
744 1.1.1.4 christos #endif
745 1.1.1.4 christos
746 1.1.1.4 christos /* Install two handlers for _SB_ */
747 1.1.1.4 christos
748 1.1.1.4 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
749 1.1.1.4 christos AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
750 1.1.1.4 christos
751 1.1.1.4 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
752 1.1.1.4 christos AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
753 1.1.1.4 christos
754 1.1.1.4 christos /* Attempt duplicate handler installation, should fail */
755 1.1.1.4 christos
756 1.1.1.4 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
757 1.1.1.4 christos AeNotifyHandler1, ACPI_CAST_PTR (void, 0x77777777));
758 1.1 jruoho
759 1.1 jruoho Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
760 1.1.1.8 christos ACPI_CHECK_OK (AcpiAttachData, Status);
761 1.1.1.2 jruoho
762 1.1 jruoho Status = AcpiDetachData (Handle, AeAttachedDataHandler);
763 1.1.1.8 christos ACPI_CHECK_OK (AcpiDetachData, Status);
764 1.1.1.2 jruoho
765 1.1.1.5 christos /* Test attach data at the root object */
766 1.1.1.5 christos
767 1.1.1.5 christos Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler,
768 1.1.1.5 christos AcpiGbl_RootNode);
769 1.1.1.8 christos ACPI_CHECK_OK (AcpiAttachData, Status);
770 1.1.1.5 christos
771 1.1.1.5 christos Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler2,
772 1.1.1.5 christos AcpiGbl_RootNode);
773 1.1.1.8 christos ACPI_CHECK_OK (AcpiAttachData, Status);
774 1.1.1.4 christos
775 1.1.1.4 christos /* Test support for multiple attaches */
776 1.1.1.4 christos
777 1.1.1.5 christos Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
778 1.1.1.8 christos ACPI_CHECK_OK (AcpiAttachData, Status);
779 1.1.1.5 christos
780 1.1.1.4 christos Status = AcpiAttachData (Handle, AeAttachedDataHandler2, Handle);
781 1.1.1.8 christos ACPI_CHECK_OK (AcpiAttachData, Status);
782 1.1 jruoho }
783 1.1 jruoho else
784 1.1 jruoho {
785 1.1 jruoho printf ("No _SB_ found, %s\n", AcpiFormatException (Status));
786 1.1 jruoho }
787 1.1 jruoho
788 1.1.1.2 jruoho /*
789 1.1.1.2 jruoho * Install handlers that will override the default handlers for some of
790 1.1.1.2 jruoho * the space IDs.
791 1.1.1.2 jruoho */
792 1.1.1.5 christos AeOverrideRegionHandlers ();
793 1.1 jruoho
794 1.1 jruoho /*
795 1.1 jruoho * Initialize the global Region Handler space
796 1.1 jruoho * MCW 3/23/00
797 1.1 jruoho */
798 1.1 jruoho AeRegions.NumberOfRegions = 0;
799 1.1 jruoho AeRegions.RegionList = NULL;
800 1.1.1.4 christos return (AE_OK);
801 1.1.1.4 christos }
802