aehandlers.c revision 1.1.1.11 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.10 christos * Copyright (C) 2000 - 2017, 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 jruoho
422 1.1.1.11 christos AcpiOsPrintf (AE_PREFIX
423 1.1.1.11 christos "Received an attached data deletion (1) on %4.4s\n",
424 1.1.1.4 christos Node->Name.Ascii);
425 1.1.1.4 christos }
426 1.1.1.4 christos
427 1.1.1.4 christos
428 1.1.1.4 christos /******************************************************************************
429 1.1.1.4 christos *
430 1.1.1.4 christos * FUNCTION: AeAttachedDataHandler2
431 1.1.1.4 christos *
432 1.1.1.4 christos * DESCRIPTION: Handler for deletion of nodes with attached data (attached via
433 1.1.1.4 christos * AcpiAttachData)
434 1.1.1.4 christos *
435 1.1.1.4 christos *****************************************************************************/
436 1.1.1.4 christos
437 1.1.1.4 christos static void
438 1.1.1.4 christos AeAttachedDataHandler2 (
439 1.1.1.4 christos ACPI_HANDLE Object,
440 1.1.1.4 christos void *Data)
441 1.1.1.4 christos {
442 1.1.1.4 christos ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Data);
443 1.1.1.4 christos
444 1.1.1.4 christos
445 1.1.1.11 christos AcpiOsPrintf (AE_PREFIX
446 1.1.1.11 christos "Received an attached data deletion (2) on %4.4s\n",
447 1.1 jruoho Node->Name.Ascii);
448 1.1 jruoho }
449 1.1 jruoho
450 1.1 jruoho
451 1.1 jruoho /******************************************************************************
452 1.1 jruoho *
453 1.1.1.2 jruoho * FUNCTION: AeInterfaceHandler
454 1.1.1.2 jruoho *
455 1.1.1.2 jruoho * DESCRIPTION: Handler for _OSI invocations
456 1.1.1.2 jruoho *
457 1.1.1.2 jruoho *****************************************************************************/
458 1.1.1.2 jruoho
459 1.1.1.2 jruoho static UINT32
460 1.1.1.2 jruoho AeInterfaceHandler (
461 1.1.1.2 jruoho ACPI_STRING InterfaceName,
462 1.1.1.2 jruoho UINT32 Supported)
463 1.1.1.2 jruoho {
464 1.1.1.2 jruoho ACPI_FUNCTION_NAME (AeInterfaceHandler);
465 1.1.1.2 jruoho
466 1.1.1.2 jruoho
467 1.1.1.2 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
468 1.1.1.2 jruoho "Received _OSI (\"%s\"), is %ssupported\n",
469 1.1.1.2 jruoho InterfaceName, Supported == 0 ? "not " : ""));
470 1.1.1.2 jruoho
471 1.1.1.2 jruoho return (Supported);
472 1.1.1.2 jruoho }
473 1.1.1.2 jruoho
474 1.1.1.2 jruoho
475 1.1.1.4 christos #if (!ACPI_REDUCED_HARDWARE)
476 1.1.1.2 jruoho /******************************************************************************
477 1.1.1.2 jruoho *
478 1.1.1.4 christos * FUNCTION: AeEventHandler, AeSciHandler
479 1.1.1.2 jruoho *
480 1.1.1.4 christos * DESCRIPTION: Handler for Fixed Events and SCIs
481 1.1.1.2 jruoho *
482 1.1.1.2 jruoho *****************************************************************************/
483 1.1.1.2 jruoho
484 1.1.1.2 jruoho static UINT32
485 1.1.1.2 jruoho AeEventHandler (
486 1.1.1.2 jruoho void *Context)
487 1.1.1.2 jruoho {
488 1.1.1.2 jruoho return (0);
489 1.1.1.2 jruoho }
490 1.1.1.2 jruoho
491 1.1.1.4 christos static UINT32
492 1.1.1.4 christos AeSciHandler (
493 1.1.1.4 christos void *Context)
494 1.1.1.4 christos {
495 1.1.1.4 christos
496 1.1.1.11 christos AcpiOsPrintf (AE_PREFIX
497 1.1.1.11 christos "Received an SCI at handler\n");
498 1.1.1.4 christos return (0);
499 1.1.1.4 christos }
500 1.1.1.4 christos
501 1.1.1.4 christos #endif /* !ACPI_REDUCED_HARDWARE */
502 1.1.1.4 christos
503 1.1.1.2 jruoho
504 1.1.1.4 christos /*******************************************************************************
505 1.1.1.4 christos *
506 1.1.1.4 christos * FUNCTION: AeInstallSciHandler
507 1.1.1.4 christos *
508 1.1.1.4 christos * PARAMETERS: None
509 1.1.1.4 christos *
510 1.1.1.4 christos * RETURN: Status
511 1.1.1.4 christos *
512 1.1.1.4 christos * DESCRIPTION: Install handler for SCIs. Exercise the code by doing an
513 1.1.1.4 christos * install/remove/install.
514 1.1.1.4 christos *
515 1.1.1.4 christos ******************************************************************************/
516 1.1.1.4 christos
517 1.1.1.4 christos static ACPI_STATUS
518 1.1.1.4 christos AeInstallSciHandler (
519 1.1.1.4 christos void)
520 1.1.1.4 christos {
521 1.1.1.4 christos ACPI_STATUS Status;
522 1.1.1.4 christos
523 1.1.1.4 christos
524 1.1.1.4 christos Status = AcpiInstallSciHandler (AeSciHandler, &AeMyContext);
525 1.1.1.4 christos if (ACPI_FAILURE (Status))
526 1.1.1.4 christos {
527 1.1.1.4 christos ACPI_EXCEPTION ((AE_INFO, Status,
528 1.1.1.4 christos "Could not install an SCI handler (1)"));
529 1.1.1.4 christos }
530 1.1.1.4 christos
531 1.1.1.4 christos Status = AcpiRemoveSciHandler (AeSciHandler);
532 1.1.1.4 christos if (ACPI_FAILURE (Status))
533 1.1.1.4 christos {
534 1.1.1.4 christos ACPI_EXCEPTION ((AE_INFO, Status,
535 1.1.1.4 christos "Could not remove an SCI handler"));
536 1.1.1.4 christos }
537 1.1.1.4 christos
538 1.1.1.4 christos Status = AcpiInstallSciHandler (AeSciHandler, &AeMyContext);
539 1.1.1.4 christos if (ACPI_FAILURE (Status))
540 1.1.1.4 christos {
541 1.1.1.4 christos ACPI_EXCEPTION ((AE_INFO, Status,
542 1.1.1.4 christos "Could not install an SCI handler (2)"));
543 1.1.1.4 christos }
544 1.1.1.4 christos
545 1.1.1.4 christos return (Status);
546 1.1.1.4 christos }
547 1.1.1.4 christos
548 1.1.1.4 christos
549 1.1 jruoho /******************************************************************************
550 1.1 jruoho *
551 1.1.1.2 jruoho * FUNCTION: AeInstallLateHandlers
552 1.1 jruoho *
553 1.1 jruoho * PARAMETERS: None
554 1.1 jruoho *
555 1.1 jruoho * RETURN: Status
556 1.1 jruoho *
557 1.1 jruoho * DESCRIPTION: Install handlers for the AcpiExec utility.
558 1.1 jruoho *
559 1.1 jruoho *****************************************************************************/
560 1.1 jruoho
561 1.1.1.2 jruoho ACPI_STATUS
562 1.1.1.2 jruoho AeInstallLateHandlers (
563 1.1.1.2 jruoho void)
564 1.1.1.2 jruoho {
565 1.1.1.2 jruoho ACPI_STATUS Status;
566 1.1.1.8 christos ACPI_HANDLE Handle;
567 1.1.1.8 christos
568 1.1.1.8 christos
569 1.1.1.8 christos Status = AcpiGetHandle (NULL, "\\_TZ.TZ1", &Handle);
570 1.1.1.8 christos if (ACPI_SUCCESS (Status))
571 1.1.1.8 christos {
572 1.1.1.8 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
573 1.1.1.8 christos AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
574 1.1.1.8 christos
575 1.1.1.8 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
576 1.1.1.8 christos AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
577 1.1.1.8 christos
578 1.1.1.8 christos Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
579 1.1.1.8 christos AeNotifyHandler1);
580 1.1.1.8 christos Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
581 1.1.1.8 christos AeNotifyHandler2);
582 1.1.1.2 jruoho
583 1.1.1.8 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
584 1.1.1.8 christos AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
585 1.1.1.8 christos
586 1.1.1.8 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
587 1.1.1.8 christos AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
588 1.1.1.8 christos }
589 1.1.1.8 christos
590 1.1.1.8 christos Status = AcpiGetHandle (NULL, "\\_PR.CPU0", &Handle);
591 1.1.1.8 christos if (ACPI_SUCCESS (Status))
592 1.1.1.8 christos {
593 1.1.1.8 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
594 1.1.1.8 christos AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
595 1.1.1.8 christos
596 1.1.1.8 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
597 1.1.1.8 christos AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
598 1.1.1.8 christos }
599 1.1.1.2 jruoho
600 1.1.1.4 christos #if (!ACPI_REDUCED_HARDWARE)
601 1.1.1.4 christos if (!AcpiGbl_ReducedHardware)
602 1.1.1.4 christos {
603 1.1.1.4 christos /* Install a user SCI handler */
604 1.1.1.4 christos
605 1.1.1.4 christos Status = AeInstallSciHandler ();
606 1.1.1.8 christos ACPI_CHECK_OK (AeInstallSciHandler, Status);
607 1.1.1.4 christos
608 1.1.1.4 christos /* Install some fixed event handlers */
609 1.1.1.2 jruoho
610 1.1.1.8 christos Status = AcpiInstallFixedEventHandler (
611 1.1.1.8 christos ACPI_EVENT_GLOBAL, AeEventHandler, NULL);
612 1.1.1.8 christos ACPI_CHECK_OK (AcpiInstallFixedEventHandler, Status);
613 1.1.1.8 christos
614 1.1.1.8 christos Status = AcpiInstallFixedEventHandler (
615 1.1.1.8 christos ACPI_EVENT_RTC, AeEventHandler, NULL);
616 1.1.1.8 christos ACPI_CHECK_OK (AcpiInstallFixedEventHandler, Status);
617 1.1.1.4 christos }
618 1.1.1.4 christos #endif /* !ACPI_REDUCED_HARDWARE */
619 1.1.1.4 christos
620 1.1.1.4 christos AeMyContext.Connection = NULL;
621 1.1.1.4 christos AeMyContext.AccessLength = 0xA5;
622 1.1.1.4 christos
623 1.1.1.4 christos /*
624 1.1.1.4 christos * We will install a handler for each EC device, directly under the EC
625 1.1.1.4 christos * device definition. This is unlike the other handlers which we install
626 1.1.1.4 christos * at the root node. Also install memory and I/O handlers at any PCI
627 1.1.1.4 christos * devices.
628 1.1.1.4 christos */
629 1.1.1.4 christos AeInstallDeviceHandlers ();
630 1.1.1.2 jruoho
631 1.1.1.2 jruoho /*
632 1.1.1.2 jruoho * Install handlers for some of the "device driver" address spaces
633 1.1.1.4 christos * such as SMBus, etc.
634 1.1.1.2 jruoho */
635 1.1.1.5 christos AeInstallRegionHandlers ();
636 1.1.1.2 jruoho return (AE_OK);
637 1.1.1.2 jruoho }
638 1.1.1.2 jruoho
639 1.1.1.2 jruoho
640 1.1.1.2 jruoho /******************************************************************************
641 1.1.1.2 jruoho *
642 1.1.1.2 jruoho * FUNCTION: AeInstallEarlyHandlers
643 1.1.1.2 jruoho *
644 1.1.1.2 jruoho * PARAMETERS: None
645 1.1.1.2 jruoho *
646 1.1.1.2 jruoho * RETURN: Status
647 1.1.1.2 jruoho *
648 1.1.1.2 jruoho * DESCRIPTION: Install handlers for the AcpiExec utility.
649 1.1.1.2 jruoho *
650 1.1.1.2 jruoho * Notes: Don't install handler for PCI_Config, we want to use the
651 1.1.1.2 jruoho * default handler to exercise that code.
652 1.1.1.2 jruoho *
653 1.1.1.2 jruoho *****************************************************************************/
654 1.1 jruoho
655 1.1 jruoho ACPI_STATUS
656 1.1.1.2 jruoho AeInstallEarlyHandlers (
657 1.1.1.2 jruoho void)
658 1.1 jruoho {
659 1.1 jruoho ACPI_STATUS Status;
660 1.1 jruoho ACPI_HANDLE Handle;
661 1.1 jruoho
662 1.1 jruoho
663 1.1 jruoho ACPI_FUNCTION_ENTRY ();
664 1.1 jruoho
665 1.1 jruoho
666 1.1.1.2 jruoho Status = AcpiInstallInterfaceHandler (AeInterfaceHandler);
667 1.1.1.2 jruoho if (ACPI_FAILURE (Status))
668 1.1.1.2 jruoho {
669 1.1.1.2 jruoho printf ("Could not install interface handler, %s\n",
670 1.1.1.2 jruoho AcpiFormatException (Status));
671 1.1.1.2 jruoho }
672 1.1.1.2 jruoho
673 1.1 jruoho Status = AcpiInstallTableHandler (AeTableHandler, NULL);
674 1.1 jruoho if (ACPI_FAILURE (Status))
675 1.1 jruoho {
676 1.1 jruoho printf ("Could not install table handler, %s\n",
677 1.1 jruoho AcpiFormatException (Status));
678 1.1 jruoho }
679 1.1 jruoho
680 1.1 jruoho Status = AcpiInstallExceptionHandler (AeExceptionHandler);
681 1.1 jruoho if (ACPI_FAILURE (Status))
682 1.1 jruoho {
683 1.1 jruoho printf ("Could not install exception handler, %s\n",
684 1.1 jruoho AcpiFormatException (Status));
685 1.1 jruoho }
686 1.1 jruoho
687 1.1.1.4 christos /* Install global notify handlers */
688 1.1 jruoho
689 1.1.1.11 christos Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT,
690 1.1.1.11 christos ACPI_SYSTEM_NOTIFY, AeSystemNotifyHandler, NULL);
691 1.1 jruoho if (ACPI_FAILURE (Status))
692 1.1 jruoho {
693 1.1.1.4 christos printf ("Could not install a global system notify handler, %s\n",
694 1.1 jruoho AcpiFormatException (Status));
695 1.1 jruoho }
696 1.1 jruoho
697 1.1.1.11 christos Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT,
698 1.1.1.11 christos ACPI_DEVICE_NOTIFY, AeDeviceNotifyHandler, NULL);
699 1.1 jruoho if (ACPI_FAILURE (Status))
700 1.1 jruoho {
701 1.1 jruoho printf ("Could not install a global notify handler, %s\n",
702 1.1 jruoho AcpiFormatException (Status));
703 1.1 jruoho }
704 1.1 jruoho
705 1.1 jruoho Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
706 1.1 jruoho if (ACPI_SUCCESS (Status))
707 1.1 jruoho {
708 1.1 jruoho Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
709 1.1.1.4 christos AeNotifyHandler1, NULL);
710 1.1 jruoho if (ACPI_FAILURE (Status))
711 1.1 jruoho {
712 1.1 jruoho printf ("Could not install a notify handler, %s\n",
713 1.1 jruoho AcpiFormatException (Status));
714 1.1 jruoho }
715 1.1 jruoho
716 1.1 jruoho Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
717 1.1.1.4 christos AeNotifyHandler1);
718 1.1 jruoho if (ACPI_FAILURE (Status))
719 1.1 jruoho {
720 1.1 jruoho printf ("Could not remove a notify handler, %s\n",
721 1.1 jruoho AcpiFormatException (Status));
722 1.1 jruoho }
723 1.1 jruoho
724 1.1 jruoho Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
725 1.1.1.4 christos AeNotifyHandler1, NULL);
726 1.1.1.8 christos ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status);
727 1.1.1.2 jruoho
728 1.1 jruoho Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
729 1.1.1.4 christos AeNotifyHandler1);
730 1.1.1.8 christos ACPI_CHECK_OK (AcpiRemoveNotifyHandler, Status);
731 1.1.1.2 jruoho
732 1.1.1.4 christos #if 0
733 1.1 jruoho Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
734 1.1.1.4 christos AeNotifyHandler1, NULL);
735 1.1 jruoho if (ACPI_FAILURE (Status))
736 1.1 jruoho {
737 1.1 jruoho printf ("Could not install a notify handler, %s\n",
738 1.1 jruoho AcpiFormatException (Status));
739 1.1 jruoho }
740 1.1.1.4 christos #endif
741 1.1.1.4 christos
742 1.1.1.4 christos /* Install two handlers for _SB_ */
743 1.1.1.4 christos
744 1.1.1.4 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
745 1.1.1.4 christos AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
746 1.1.1.4 christos
747 1.1.1.4 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
748 1.1.1.4 christos AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
749 1.1.1.4 christos
750 1.1.1.4 christos /* Attempt duplicate handler installation, should fail */
751 1.1.1.4 christos
752 1.1.1.4 christos Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
753 1.1.1.4 christos AeNotifyHandler1, ACPI_CAST_PTR (void, 0x77777777));
754 1.1 jruoho
755 1.1 jruoho Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
756 1.1.1.8 christos ACPI_CHECK_OK (AcpiAttachData, Status);
757 1.1.1.2 jruoho
758 1.1 jruoho Status = AcpiDetachData (Handle, AeAttachedDataHandler);
759 1.1.1.8 christos ACPI_CHECK_OK (AcpiDetachData, Status);
760 1.1.1.2 jruoho
761 1.1.1.5 christos /* Test attach data at the root object */
762 1.1.1.5 christos
763 1.1.1.5 christos Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler,
764 1.1.1.5 christos AcpiGbl_RootNode);
765 1.1.1.8 christos ACPI_CHECK_OK (AcpiAttachData, Status);
766 1.1.1.5 christos
767 1.1.1.5 christos Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler2,
768 1.1.1.5 christos AcpiGbl_RootNode);
769 1.1.1.8 christos ACPI_CHECK_OK (AcpiAttachData, Status);
770 1.1.1.4 christos
771 1.1.1.4 christos /* Test support for multiple attaches */
772 1.1.1.4 christos
773 1.1.1.5 christos Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
774 1.1.1.8 christos ACPI_CHECK_OK (AcpiAttachData, Status);
775 1.1.1.5 christos
776 1.1.1.4 christos Status = AcpiAttachData (Handle, AeAttachedDataHandler2, Handle);
777 1.1.1.8 christos ACPI_CHECK_OK (AcpiAttachData, Status);
778 1.1 jruoho }
779 1.1 jruoho else
780 1.1 jruoho {
781 1.1 jruoho printf ("No _SB_ found, %s\n", AcpiFormatException (Status));
782 1.1 jruoho }
783 1.1 jruoho
784 1.1.1.2 jruoho /*
785 1.1.1.2 jruoho * Install handlers that will override the default handlers for some of
786 1.1.1.2 jruoho * the space IDs.
787 1.1.1.2 jruoho */
788 1.1.1.5 christos AeOverrideRegionHandlers ();
789 1.1 jruoho
790 1.1 jruoho /*
791 1.1 jruoho * Initialize the global Region Handler space
792 1.1 jruoho * MCW 3/23/00
793 1.1 jruoho */
794 1.1 jruoho AeRegions.NumberOfRegions = 0;
795 1.1 jruoho AeRegions.RegionList = NULL;
796 1.1.1.4 christos return (AE_OK);
797 1.1.1.4 christos }
798