dbcmds.c revision 1.18 1 1.1 jruoho /*******************************************************************************
2 1.1 jruoho *
3 1.3 jruoho * Module Name: dbcmds - Miscellaneous debug commands and output routines
4 1.1 jruoho *
5 1.1 jruoho ******************************************************************************/
6 1.1 jruoho
7 1.3 jruoho /*
8 1.17 christos * Copyright (C) 2000 - 2023, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.3 jruoho * Redistribution and use in source and binary forms, with or without
12 1.3 jruoho * modification, are permitted provided that the following conditions
13 1.3 jruoho * are met:
14 1.3 jruoho * 1. Redistributions of source code must retain the above copyright
15 1.3 jruoho * notice, this list of conditions, and the following disclaimer,
16 1.3 jruoho * without modification.
17 1.3 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.3 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
19 1.3 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
20 1.3 jruoho * including a substantially similar Disclaimer requirement for further
21 1.3 jruoho * binary redistribution.
22 1.3 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
23 1.3 jruoho * of any contributors may be used to endorse or promote products derived
24 1.3 jruoho * from this software without specific prior written permission.
25 1.3 jruoho *
26 1.3 jruoho * Alternatively, this software may be distributed under the terms of the
27 1.3 jruoho * GNU General Public License ("GPL") version 2 as published by the Free
28 1.3 jruoho * Software Foundation.
29 1.3 jruoho *
30 1.3 jruoho * NO WARRANTY
31 1.3 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.3 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.15 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 1.3 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.3 jruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.3 jruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.3 jruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.3 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.3 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.3 jruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.3 jruoho * POSSIBILITY OF SUCH DAMAGES.
42 1.3 jruoho */
43 1.1 jruoho
44 1.1 jruoho #include "acpi.h"
45 1.1 jruoho #include "accommon.h"
46 1.1 jruoho #include "acevents.h"
47 1.1 jruoho #include "acdebug.h"
48 1.4 christos #include "acnamesp.h"
49 1.1 jruoho #include "acresrc.h"
50 1.1 jruoho #include "actables.h"
51 1.18 christos #ifndef _KERNEL
52 1.17 christos #include "limits.h"
53 1.18 christos #endif
54 1.1 jruoho
55 1.1 jruoho #define _COMPONENT ACPI_CA_DEBUGGER
56 1.1 jruoho ACPI_MODULE_NAME ("dbcmds")
57 1.1 jruoho
58 1.1 jruoho
59 1.1 jruoho /* Local prototypes */
60 1.1 jruoho
61 1.1 jruoho static void
62 1.1 jruoho AcpiDmCompareAmlResources (
63 1.1 jruoho UINT8 *Aml1Buffer,
64 1.1 jruoho ACPI_RSDESC_SIZE Aml1BufferLength,
65 1.1 jruoho UINT8 *Aml2Buffer,
66 1.1 jruoho ACPI_RSDESC_SIZE Aml2BufferLength);
67 1.1 jruoho
68 1.1 jruoho static ACPI_STATUS
69 1.1 jruoho AcpiDmTestResourceConversion (
70 1.1 jruoho ACPI_NAMESPACE_NODE *Node,
71 1.1 jruoho char *Name);
72 1.1 jruoho
73 1.4 christos static ACPI_STATUS
74 1.4 christos AcpiDbResourceCallback (
75 1.4 christos ACPI_RESOURCE *Resource,
76 1.4 christos void *Context);
77 1.4 christos
78 1.4 christos static ACPI_STATUS
79 1.4 christos AcpiDbDeviceResources (
80 1.4 christos ACPI_HANDLE ObjHandle,
81 1.4 christos UINT32 NestingLevel,
82 1.4 christos void *Context,
83 1.4 christos void **ReturnValue);
84 1.4 christos
85 1.4 christos static void
86 1.4 christos AcpiDbDoOneSleepState (
87 1.4 christos UINT8 SleepState);
88 1.4 christos
89 1.1 jruoho
90 1.8 christos static char *AcpiDbTraceMethodName = NULL;
91 1.8 christos
92 1.9 christos
93 1.1 jruoho /*******************************************************************************
94 1.1 jruoho *
95 1.1 jruoho * FUNCTION: AcpiDbConvertToNode
96 1.1 jruoho *
97 1.4 christos * PARAMETERS: InString - String to convert
98 1.1 jruoho *
99 1.1 jruoho * RETURN: Pointer to a NS node
100 1.1 jruoho *
101 1.4 christos * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or
102 1.4 christos * alphanumeric strings.
103 1.1 jruoho *
104 1.1 jruoho ******************************************************************************/
105 1.1 jruoho
106 1.3 jruoho ACPI_NAMESPACE_NODE *
107 1.1 jruoho AcpiDbConvertToNode (
108 1.1 jruoho char *InString)
109 1.1 jruoho {
110 1.1 jruoho ACPI_NAMESPACE_NODE *Node;
111 1.4 christos ACPI_SIZE Address;
112 1.1 jruoho
113 1.1 jruoho
114 1.1 jruoho if ((*InString >= 0x30) && (*InString <= 0x39))
115 1.1 jruoho {
116 1.1 jruoho /* Numeric argument, convert */
117 1.1 jruoho
118 1.8 christos Address = strtoul (InString, NULL, 16);
119 1.4 christos Node = ACPI_TO_POINTER (Address);
120 1.1 jruoho if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
121 1.1 jruoho {
122 1.9 christos AcpiOsPrintf ("Address %p is invalid", Node);
123 1.1 jruoho return (NULL);
124 1.1 jruoho }
125 1.1 jruoho
126 1.1 jruoho /* Make sure pointer is valid NS node */
127 1.1 jruoho
128 1.1 jruoho if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
129 1.1 jruoho {
130 1.6 christos AcpiOsPrintf ("Address %p is not a valid namespace node [%s]\n",
131 1.9 christos Node, AcpiUtGetDescriptorName (Node));
132 1.1 jruoho return (NULL);
133 1.1 jruoho }
134 1.1 jruoho }
135 1.1 jruoho else
136 1.1 jruoho {
137 1.4 christos /*
138 1.4 christos * Alpha argument: The parameter is a name string that must be
139 1.4 christos * resolved to a Namespace object.
140 1.1 jruoho */
141 1.1 jruoho Node = AcpiDbLocalNsLookup (InString);
142 1.1 jruoho if (!Node)
143 1.1 jruoho {
144 1.9 christos AcpiOsPrintf (
145 1.9 christos "Could not find [%s] in namespace, defaulting to root node\n",
146 1.6 christos InString);
147 1.1 jruoho Node = AcpiGbl_RootNode;
148 1.1 jruoho }
149 1.1 jruoho }
150 1.1 jruoho
151 1.1 jruoho return (Node);
152 1.1 jruoho }
153 1.1 jruoho
154 1.1 jruoho
155 1.1 jruoho /*******************************************************************************
156 1.1 jruoho *
157 1.1 jruoho * FUNCTION: AcpiDbSleep
158 1.1 jruoho *
159 1.4 christos * PARAMETERS: ObjectArg - Desired sleep state (0-5). NULL means
160 1.4 christos * invoke all possible sleep states.
161 1.1 jruoho *
162 1.1 jruoho * RETURN: Status
163 1.1 jruoho *
164 1.4 christos * DESCRIPTION: Simulate sleep/wake sequences
165 1.1 jruoho *
166 1.1 jruoho ******************************************************************************/
167 1.1 jruoho
168 1.1 jruoho ACPI_STATUS
169 1.1 jruoho AcpiDbSleep (
170 1.1 jruoho char *ObjectArg)
171 1.1 jruoho {
172 1.1 jruoho UINT8 SleepState;
173 1.4 christos UINT32 i;
174 1.4 christos
175 1.4 christos
176 1.4 christos ACPI_FUNCTION_TRACE (AcpiDbSleep);
177 1.4 christos
178 1.4 christos
179 1.4 christos /* Null input (no arguments) means to invoke all sleep states */
180 1.4 christos
181 1.4 christos if (!ObjectArg)
182 1.4 christos {
183 1.4 christos AcpiOsPrintf ("Invoking all possible sleep states, 0-%d\n",
184 1.4 christos ACPI_S_STATES_MAX);
185 1.4 christos
186 1.4 christos for (i = 0; i <= ACPI_S_STATES_MAX; i++)
187 1.4 christos {
188 1.4 christos AcpiDbDoOneSleepState ((UINT8) i);
189 1.4 christos }
190 1.4 christos
191 1.4 christos return_ACPI_STATUS (AE_OK);
192 1.4 christos }
193 1.1 jruoho
194 1.4 christos /* Convert argument to binary and invoke the sleep state */
195 1.1 jruoho
196 1.8 christos SleepState = (UINT8) strtoul (ObjectArg, NULL, 0);
197 1.4 christos AcpiDbDoOneSleepState (SleepState);
198 1.4 christos return_ACPI_STATUS (AE_OK);
199 1.4 christos }
200 1.4 christos
201 1.4 christos
202 1.4 christos /*******************************************************************************
203 1.4 christos *
204 1.4 christos * FUNCTION: AcpiDbDoOneSleepState
205 1.4 christos *
206 1.4 christos * PARAMETERS: SleepState - Desired sleep state (0-5)
207 1.4 christos *
208 1.9 christos * RETURN: None
209 1.4 christos *
210 1.4 christos * DESCRIPTION: Simulate a sleep/wake sequence
211 1.4 christos *
212 1.4 christos ******************************************************************************/
213 1.4 christos
214 1.4 christos static void
215 1.4 christos AcpiDbDoOneSleepState (
216 1.4 christos UINT8 SleepState)
217 1.4 christos {
218 1.4 christos ACPI_STATUS Status;
219 1.4 christos UINT8 SleepTypeA;
220 1.4 christos UINT8 SleepTypeB;
221 1.4 christos
222 1.4 christos
223 1.4 christos /* Validate parameter */
224 1.4 christos
225 1.4 christos if (SleepState > ACPI_S_STATES_MAX)
226 1.4 christos {
227 1.4 christos AcpiOsPrintf ("Sleep state %d out of range (%d max)\n",
228 1.4 christos SleepState, ACPI_S_STATES_MAX);
229 1.4 christos return;
230 1.4 christos }
231 1.4 christos
232 1.4 christos AcpiOsPrintf ("\n---- Invoking sleep state S%d (%s):\n",
233 1.4 christos SleepState, AcpiGbl_SleepStateNames[SleepState]);
234 1.4 christos
235 1.4 christos /* Get the values for the sleep type registers (for display only) */
236 1.4 christos
237 1.4 christos Status = AcpiGetSleepTypeData (SleepState, &SleepTypeA, &SleepTypeB);
238 1.4 christos if (ACPI_FAILURE (Status))
239 1.4 christos {
240 1.4 christos AcpiOsPrintf ("Could not evaluate [%s] method, %s\n",
241 1.4 christos AcpiGbl_SleepStateNames[SleepState],
242 1.4 christos AcpiFormatException (Status));
243 1.4 christos return;
244 1.4 christos }
245 1.1 jruoho
246 1.4 christos AcpiOsPrintf (
247 1.4 christos "Register values for sleep state S%d: Sleep-A: %.2X, Sleep-B: %.2X\n",
248 1.4 christos SleepState, SleepTypeA, SleepTypeB);
249 1.4 christos
250 1.4 christos /* Invoke the various sleep/wake interfaces */
251 1.4 christos
252 1.4 christos AcpiOsPrintf ("**** Sleep: Prepare to sleep (S%d) ****\n",
253 1.4 christos SleepState);
254 1.1 jruoho Status = AcpiEnterSleepStatePrep (SleepState);
255 1.1 jruoho if (ACPI_FAILURE (Status))
256 1.1 jruoho {
257 1.4 christos goto ErrorExit;
258 1.1 jruoho }
259 1.1 jruoho
260 1.4 christos AcpiOsPrintf ("**** Sleep: Going to sleep (S%d) ****\n",
261 1.4 christos SleepState);
262 1.1 jruoho Status = AcpiEnterSleepState (SleepState);
263 1.1 jruoho if (ACPI_FAILURE (Status))
264 1.1 jruoho {
265 1.4 christos goto ErrorExit;
266 1.4 christos }
267 1.4 christos
268 1.4 christos AcpiOsPrintf ("**** Wake: Prepare to return from sleep (S%d) ****\n",
269 1.4 christos SleepState);
270 1.4 christos Status = AcpiLeaveSleepStatePrep (SleepState);
271 1.4 christos if (ACPI_FAILURE (Status))
272 1.4 christos {
273 1.4 christos goto ErrorExit;
274 1.1 jruoho }
275 1.1 jruoho
276 1.4 christos AcpiOsPrintf ("**** Wake: Return from sleep (S%d) ****\n",
277 1.4 christos SleepState);
278 1.1 jruoho Status = AcpiLeaveSleepState (SleepState);
279 1.4 christos if (ACPI_FAILURE (Status))
280 1.4 christos {
281 1.4 christos goto ErrorExit;
282 1.4 christos }
283 1.4 christos
284 1.4 christos return;
285 1.1 jruoho
286 1.4 christos
287 1.4 christos ErrorExit:
288 1.4 christos ACPI_EXCEPTION ((AE_INFO, Status, "During invocation of sleep state S%d",
289 1.4 christos SleepState));
290 1.1 jruoho }
291 1.1 jruoho
292 1.4 christos
293 1.1 jruoho /*******************************************************************************
294 1.1 jruoho *
295 1.1 jruoho * FUNCTION: AcpiDbDisplayLocks
296 1.1 jruoho *
297 1.1 jruoho * PARAMETERS: None
298 1.1 jruoho *
299 1.1 jruoho * RETURN: None
300 1.1 jruoho *
301 1.1 jruoho * DESCRIPTION: Display information about internal mutexes.
302 1.1 jruoho *
303 1.1 jruoho ******************************************************************************/
304 1.1 jruoho
305 1.1 jruoho void
306 1.1 jruoho AcpiDbDisplayLocks (
307 1.1 jruoho void)
308 1.1 jruoho {
309 1.1 jruoho UINT32 i;
310 1.1 jruoho
311 1.1 jruoho
312 1.1 jruoho for (i = 0; i < ACPI_MAX_MUTEX; i++)
313 1.1 jruoho {
314 1.1 jruoho AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
315 1.1 jruoho AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
316 1.1 jruoho ? "Locked" : "Unlocked");
317 1.1 jruoho }
318 1.1 jruoho }
319 1.1 jruoho
320 1.1 jruoho
321 1.1 jruoho /*******************************************************************************
322 1.1 jruoho *
323 1.1 jruoho * FUNCTION: AcpiDbDisplayTableInfo
324 1.1 jruoho *
325 1.4 christos * PARAMETERS: TableArg - Name of table to be displayed
326 1.1 jruoho *
327 1.1 jruoho * RETURN: None
328 1.1 jruoho *
329 1.4 christos * DESCRIPTION: Display information about loaded tables. Current
330 1.1 jruoho * implementation displays all loaded tables.
331 1.1 jruoho *
332 1.1 jruoho ******************************************************************************/
333 1.1 jruoho
334 1.1 jruoho void
335 1.1 jruoho AcpiDbDisplayTableInfo (
336 1.1 jruoho char *TableArg)
337 1.1 jruoho {
338 1.1 jruoho UINT32 i;
339 1.1 jruoho ACPI_TABLE_DESC *TableDesc;
340 1.1 jruoho ACPI_STATUS Status;
341 1.1 jruoho
342 1.1 jruoho
343 1.4 christos /* Header */
344 1.4 christos
345 1.9 christos AcpiOsPrintf ("Idx ID Status Type "
346 1.9 christos "TableHeader (Sig, Address, Length, Misc)\n");
347 1.4 christos
348 1.1 jruoho /* Walk the entire root table list */
349 1.1 jruoho
350 1.1 jruoho for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
351 1.1 jruoho {
352 1.1 jruoho TableDesc = &AcpiGbl_RootTableList.Tables[i];
353 1.4 christos
354 1.4 christos /* Index and Table ID */
355 1.4 christos
356 1.4 christos AcpiOsPrintf ("%3u %.2u ", i, TableDesc->OwnerId);
357 1.4 christos
358 1.4 christos /* Decode the table flags */
359 1.4 christos
360 1.4 christos if (!(TableDesc->Flags & ACPI_TABLE_IS_LOADED))
361 1.4 christos {
362 1.4 christos AcpiOsPrintf ("NotLoaded ");
363 1.4 christos }
364 1.4 christos else
365 1.4 christos {
366 1.4 christos AcpiOsPrintf (" Loaded ");
367 1.4 christos }
368 1.4 christos
369 1.4 christos switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
370 1.4 christos {
371 1.6 christos case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
372 1.4 christos
373 1.6 christos AcpiOsPrintf ("External/virtual ");
374 1.4 christos break;
375 1.4 christos
376 1.6 christos case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
377 1.4 christos
378 1.6 christos AcpiOsPrintf ("Internal/physical ");
379 1.4 christos break;
380 1.4 christos
381 1.6 christos case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
382 1.4 christos
383 1.6 christos AcpiOsPrintf ("Internal/virtual ");
384 1.4 christos break;
385 1.4 christos
386 1.4 christos default:
387 1.4 christos
388 1.6 christos AcpiOsPrintf ("INVALID TYPE ");
389 1.4 christos break;
390 1.4 christos }
391 1.1 jruoho
392 1.1 jruoho /* Make sure that the table is mapped */
393 1.1 jruoho
394 1.6 christos Status = AcpiTbValidateTable (TableDesc);
395 1.1 jruoho if (ACPI_FAILURE (Status))
396 1.1 jruoho {
397 1.1 jruoho return;
398 1.1 jruoho }
399 1.1 jruoho
400 1.1 jruoho /* Dump the table header */
401 1.1 jruoho
402 1.1 jruoho if (TableDesc->Pointer)
403 1.1 jruoho {
404 1.1 jruoho AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
405 1.1 jruoho }
406 1.1 jruoho else
407 1.1 jruoho {
408 1.1 jruoho /* If the pointer is null, the table has been unloaded */
409 1.1 jruoho
410 1.10 christos ACPI_INFO (("%4.4s - Table has been unloaded",
411 1.1 jruoho TableDesc->Signature.Ascii));
412 1.1 jruoho }
413 1.1 jruoho }
414 1.1 jruoho }
415 1.1 jruoho
416 1.1 jruoho
417 1.1 jruoho /*******************************************************************************
418 1.1 jruoho *
419 1.3 jruoho * FUNCTION: AcpiDbUnloadAcpiTable
420 1.1 jruoho *
421 1.4 christos * PARAMETERS: ObjectName - Namespace pathname for an object that
422 1.4 christos * is owned by the table to be unloaded
423 1.1 jruoho *
424 1.4 christos * RETURN: None
425 1.1 jruoho *
426 1.4 christos * DESCRIPTION: Unload an ACPI table, via any namespace node that is owned
427 1.4 christos * by the table.
428 1.1 jruoho *
429 1.1 jruoho ******************************************************************************/
430 1.1 jruoho
431 1.3 jruoho void
432 1.3 jruoho AcpiDbUnloadAcpiTable (
433 1.4 christos char *ObjectName)
434 1.1 jruoho {
435 1.4 christos ACPI_NAMESPACE_NODE *Node;
436 1.1 jruoho ACPI_STATUS Status;
437 1.1 jruoho
438 1.1 jruoho
439 1.4 christos /* Translate name to an Named object */
440 1.1 jruoho
441 1.4 christos Node = AcpiDbConvertToNode (ObjectName);
442 1.4 christos if (!Node)
443 1.1 jruoho {
444 1.4 christos return;
445 1.4 christos }
446 1.1 jruoho
447 1.4 christos Status = AcpiUnloadParentTable (ACPI_CAST_PTR (ACPI_HANDLE, Node));
448 1.4 christos if (ACPI_SUCCESS (Status))
449 1.4 christos {
450 1.4 christos AcpiOsPrintf ("Parent of [%s] (%p) unloaded and uninstalled\n",
451 1.4 christos ObjectName, Node);
452 1.4 christos }
453 1.4 christos else
454 1.4 christos {
455 1.4 christos AcpiOsPrintf ("%s, while unloading parent table of [%s]\n",
456 1.4 christos AcpiFormatException (Status), ObjectName);
457 1.1 jruoho }
458 1.1 jruoho }
459 1.1 jruoho
460 1.1 jruoho
461 1.1 jruoho /*******************************************************************************
462 1.1 jruoho *
463 1.3 jruoho * FUNCTION: AcpiDbSendNotify
464 1.1 jruoho *
465 1.4 christos * PARAMETERS: Name - Name of ACPI object where to send notify
466 1.4 christos * Value - Value of the notify to send.
467 1.1 jruoho *
468 1.1 jruoho * RETURN: None
469 1.1 jruoho *
470 1.4 christos * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
471 1.3 jruoho * named object as an ACPI notify.
472 1.1 jruoho *
473 1.1 jruoho ******************************************************************************/
474 1.1 jruoho
475 1.3 jruoho void
476 1.3 jruoho AcpiDbSendNotify (
477 1.3 jruoho char *Name,
478 1.3 jruoho UINT32 Value)
479 1.1 jruoho {
480 1.3 jruoho ACPI_NAMESPACE_NODE *Node;
481 1.3 jruoho ACPI_STATUS Status;
482 1.3 jruoho
483 1.1 jruoho
484 1.3 jruoho /* Translate name to an Named object */
485 1.1 jruoho
486 1.3 jruoho Node = AcpiDbConvertToNode (Name);
487 1.3 jruoho if (!Node)
488 1.1 jruoho {
489 1.3 jruoho return;
490 1.1 jruoho }
491 1.1 jruoho
492 1.4 christos /* Dispatch the notify if legal */
493 1.1 jruoho
494 1.4 christos if (AcpiEvIsNotifyObject (Node))
495 1.1 jruoho {
496 1.3 jruoho Status = AcpiEvQueueNotifyRequest (Node, Value);
497 1.3 jruoho if (ACPI_FAILURE (Status))
498 1.3 jruoho {
499 1.3 jruoho AcpiOsPrintf ("Could not queue notify\n");
500 1.3 jruoho }
501 1.4 christos }
502 1.4 christos else
503 1.4 christos {
504 1.4 christos AcpiOsPrintf (
505 1.9 christos "Named object [%4.4s] Type %s, "
506 1.9 christos "must be Device/Thermal/Processor type\n",
507 1.4 christos AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type));
508 1.3 jruoho }
509 1.1 jruoho }
510 1.1 jruoho
511 1.1 jruoho
512 1.1 jruoho /*******************************************************************************
513 1.1 jruoho *
514 1.3 jruoho * FUNCTION: AcpiDbDisplayInterfaces
515 1.1 jruoho *
516 1.3 jruoho * PARAMETERS: ActionArg - Null, "install", or "remove"
517 1.3 jruoho * InterfaceNameArg - Name for install/remove options
518 1.1 jruoho *
519 1.3 jruoho * RETURN: None
520 1.1 jruoho *
521 1.3 jruoho * DESCRIPTION: Display or modify the global _OSI interface list
522 1.1 jruoho *
523 1.1 jruoho ******************************************************************************/
524 1.1 jruoho
525 1.1 jruoho void
526 1.3 jruoho AcpiDbDisplayInterfaces (
527 1.3 jruoho char *ActionArg,
528 1.3 jruoho char *InterfaceNameArg)
529 1.1 jruoho {
530 1.3 jruoho ACPI_INTERFACE_INFO *NextInterface;
531 1.3 jruoho char *SubString;
532 1.1 jruoho ACPI_STATUS Status;
533 1.1 jruoho
534 1.1 jruoho
535 1.3 jruoho /* If no arguments, just display current interface list */
536 1.3 jruoho
537 1.3 jruoho if (!ActionArg)
538 1.1 jruoho {
539 1.9 christos (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
540 1.3 jruoho
541 1.3 jruoho NextInterface = AcpiGbl_SupportedInterfaces;
542 1.3 jruoho while (NextInterface)
543 1.3 jruoho {
544 1.3 jruoho if (!(NextInterface->Flags & ACPI_OSI_INVALID))
545 1.3 jruoho {
546 1.3 jruoho AcpiOsPrintf ("%s\n", NextInterface->Name);
547 1.3 jruoho }
548 1.9 christos
549 1.3 jruoho NextInterface = NextInterface->Next;
550 1.3 jruoho }
551 1.3 jruoho
552 1.3 jruoho AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
553 1.1 jruoho return;
554 1.1 jruoho }
555 1.1 jruoho
556 1.3 jruoho /* If ActionArg exists, so must InterfaceNameArg */
557 1.1 jruoho
558 1.3 jruoho if (!InterfaceNameArg)
559 1.1 jruoho {
560 1.3 jruoho AcpiOsPrintf ("Missing Interface Name argument\n");
561 1.3 jruoho return;
562 1.3 jruoho }
563 1.3 jruoho
564 1.3 jruoho /* Uppercase the action for match below */
565 1.1 jruoho
566 1.3 jruoho AcpiUtStrupr (ActionArg);
567 1.3 jruoho
568 1.3 jruoho /* Install - install an interface */
569 1.3 jruoho
570 1.8 christos SubString = strstr ("INSTALL", ActionArg);
571 1.3 jruoho if (SubString)
572 1.3 jruoho {
573 1.3 jruoho Status = AcpiInstallInterface (InterfaceNameArg);
574 1.1 jruoho if (ACPI_FAILURE (Status))
575 1.1 jruoho {
576 1.3 jruoho AcpiOsPrintf ("%s, while installing \"%s\"\n",
577 1.3 jruoho AcpiFormatException (Status), InterfaceNameArg);
578 1.1 jruoho }
579 1.3 jruoho return;
580 1.3 jruoho }
581 1.3 jruoho
582 1.3 jruoho /* Remove - remove an interface */
583 1.1 jruoho
584 1.8 christos SubString = strstr ("REMOVE", ActionArg);
585 1.3 jruoho if (SubString)
586 1.1 jruoho {
587 1.3 jruoho Status = AcpiRemoveInterface (InterfaceNameArg);
588 1.1 jruoho if (ACPI_FAILURE (Status))
589 1.1 jruoho {
590 1.3 jruoho AcpiOsPrintf ("%s, while removing \"%s\"\n",
591 1.3 jruoho AcpiFormatException (Status), InterfaceNameArg);
592 1.1 jruoho }
593 1.3 jruoho return;
594 1.3 jruoho }
595 1.1 jruoho
596 1.3 jruoho /* Invalid ActionArg */
597 1.1 jruoho
598 1.3 jruoho AcpiOsPrintf ("Invalid action argument: %s\n", ActionArg);
599 1.1 jruoho return;
600 1.1 jruoho }
601 1.1 jruoho
602 1.1 jruoho
603 1.1 jruoho /*******************************************************************************
604 1.1 jruoho *
605 1.4 christos * FUNCTION: AcpiDbDisplayTemplate
606 1.4 christos *
607 1.4 christos * PARAMETERS: BufferArg - Buffer name or address
608 1.4 christos *
609 1.4 christos * RETURN: None
610 1.4 christos *
611 1.4 christos * DESCRIPTION: Dump a buffer that contains a resource template
612 1.4 christos *
613 1.4 christos ******************************************************************************/
614 1.4 christos
615 1.4 christos void
616 1.4 christos AcpiDbDisplayTemplate (
617 1.4 christos char *BufferArg)
618 1.4 christos {
619 1.4 christos ACPI_NAMESPACE_NODE *Node;
620 1.4 christos ACPI_STATUS Status;
621 1.4 christos ACPI_BUFFER ReturnBuffer;
622 1.4 christos
623 1.4 christos
624 1.4 christos /* Translate BufferArg to an Named object */
625 1.4 christos
626 1.4 christos Node = AcpiDbConvertToNode (BufferArg);
627 1.4 christos if (!Node || (Node == AcpiGbl_RootNode))
628 1.4 christos {
629 1.4 christos AcpiOsPrintf ("Invalid argument: %s\n", BufferArg);
630 1.4 christos return;
631 1.4 christos }
632 1.4 christos
633 1.4 christos /* We must have a buffer object */
634 1.4 christos
635 1.4 christos if (Node->Type != ACPI_TYPE_BUFFER)
636 1.4 christos {
637 1.4 christos AcpiOsPrintf ("Not a Buffer object, cannot be a template: %s\n",
638 1.4 christos BufferArg);
639 1.4 christos return;
640 1.4 christos }
641 1.4 christos
642 1.4 christos ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
643 1.4 christos ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
644 1.4 christos
645 1.4 christos /* Attempt to convert the raw buffer to a resource list */
646 1.4 christos
647 1.4 christos Status = AcpiRsCreateResourceList (Node->Object, &ReturnBuffer);
648 1.4 christos
649 1.4 christos AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
650 1.4 christos AcpiDbgLevel |= ACPI_LV_RESOURCES;
651 1.4 christos
652 1.4 christos if (ACPI_FAILURE (Status))
653 1.4 christos {
654 1.9 christos AcpiOsPrintf (
655 1.9 christos "Could not convert Buffer to a resource list: %s, %s\n",
656 1.4 christos BufferArg, AcpiFormatException (Status));
657 1.4 christos goto DumpBuffer;
658 1.4 christos }
659 1.4 christos
660 1.4 christos /* Now we can dump the resource list */
661 1.4 christos
662 1.4 christos AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
663 1.4 christos ReturnBuffer.Pointer));
664 1.4 christos
665 1.4 christos DumpBuffer:
666 1.4 christos AcpiOsPrintf ("\nRaw data buffer:\n");
667 1.4 christos AcpiUtDebugDumpBuffer ((UINT8 *) Node->Object->Buffer.Pointer,
668 1.4 christos Node->Object->Buffer.Length,
669 1.4 christos DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
670 1.4 christos
671 1.4 christos AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
672 1.4 christos return;
673 1.4 christos }
674 1.4 christos
675 1.4 christos
676 1.4 christos /*******************************************************************************
677 1.4 christos *
678 1.1 jruoho * FUNCTION: AcpiDmCompareAmlResources
679 1.1 jruoho *
680 1.1 jruoho * PARAMETERS: Aml1Buffer - Contains first resource list
681 1.1 jruoho * Aml1BufferLength - Length of first resource list
682 1.1 jruoho * Aml2Buffer - Contains second resource list
683 1.1 jruoho * Aml2BufferLength - Length of second resource list
684 1.1 jruoho *
685 1.1 jruoho * RETURN: None
686 1.1 jruoho *
687 1.1 jruoho * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
688 1.1 jruoho * order to isolate a miscompare to an individual resource)
689 1.1 jruoho *
690 1.1 jruoho ******************************************************************************/
691 1.1 jruoho
692 1.1 jruoho static void
693 1.1 jruoho AcpiDmCompareAmlResources (
694 1.1 jruoho UINT8 *Aml1Buffer,
695 1.1 jruoho ACPI_RSDESC_SIZE Aml1BufferLength,
696 1.1 jruoho UINT8 *Aml2Buffer,
697 1.1 jruoho ACPI_RSDESC_SIZE Aml2BufferLength)
698 1.1 jruoho {
699 1.1 jruoho UINT8 *Aml1;
700 1.1 jruoho UINT8 *Aml2;
701 1.4 christos UINT8 *Aml1End;
702 1.4 christos UINT8 *Aml2End;
703 1.1 jruoho ACPI_RSDESC_SIZE Aml1Length;
704 1.1 jruoho ACPI_RSDESC_SIZE Aml2Length;
705 1.1 jruoho ACPI_RSDESC_SIZE Offset = 0;
706 1.1 jruoho UINT8 ResourceType;
707 1.1 jruoho UINT32 Count = 0;
708 1.4 christos UINT32 i;
709 1.1 jruoho
710 1.1 jruoho
711 1.1 jruoho /* Compare overall buffer sizes (may be different due to size rounding) */
712 1.1 jruoho
713 1.1 jruoho if (Aml1BufferLength != Aml2BufferLength)
714 1.1 jruoho {
715 1.1 jruoho AcpiOsPrintf (
716 1.9 christos "**** Buffer length mismatch in converted "
717 1.9 christos "AML: Original %X, New %X ****\n",
718 1.1 jruoho Aml1BufferLength, Aml2BufferLength);
719 1.1 jruoho }
720 1.1 jruoho
721 1.1 jruoho Aml1 = Aml1Buffer;
722 1.1 jruoho Aml2 = Aml2Buffer;
723 1.4 christos Aml1End = Aml1Buffer + Aml1BufferLength;
724 1.4 christos Aml2End = Aml2Buffer + Aml2BufferLength;
725 1.1 jruoho
726 1.1 jruoho /* Walk the descriptor lists, comparing each descriptor */
727 1.1 jruoho
728 1.4 christos while ((Aml1 < Aml1End) && (Aml2 < Aml2End))
729 1.1 jruoho {
730 1.1 jruoho /* Get the lengths of each descriptor */
731 1.1 jruoho
732 1.1 jruoho Aml1Length = AcpiUtGetDescriptorLength (Aml1);
733 1.1 jruoho Aml2Length = AcpiUtGetDescriptorLength (Aml2);
734 1.1 jruoho ResourceType = AcpiUtGetResourceType (Aml1);
735 1.1 jruoho
736 1.1 jruoho /* Check for descriptor length match */
737 1.1 jruoho
738 1.1 jruoho if (Aml1Length != Aml2Length)
739 1.1 jruoho {
740 1.1 jruoho AcpiOsPrintf (
741 1.9 christos "**** Length mismatch in descriptor [%.2X] type %2.2X, "
742 1.9 christos "Offset %8.8X Len1 %X, Len2 %X ****\n",
743 1.1 jruoho Count, ResourceType, Offset, Aml1Length, Aml2Length);
744 1.1 jruoho }
745 1.1 jruoho
746 1.1 jruoho /* Check for descriptor byte match */
747 1.1 jruoho
748 1.8 christos else if (memcmp (Aml1, Aml2, Aml1Length))
749 1.1 jruoho {
750 1.1 jruoho AcpiOsPrintf (
751 1.9 christos "**** Data mismatch in descriptor [%.2X] type %2.2X, "
752 1.9 christos "Offset %8.8X ****\n",
753 1.1 jruoho Count, ResourceType, Offset);
754 1.4 christos
755 1.4 christos for (i = 0; i < Aml1Length; i++)
756 1.4 christos {
757 1.4 christos if (Aml1[i] != Aml2[i])
758 1.4 christos {
759 1.4 christos AcpiOsPrintf (
760 1.9 christos "Mismatch at byte offset %.2X: is %2.2X, "
761 1.9 christos "should be %2.2X\n",
762 1.4 christos i, Aml2[i], Aml1[i]);
763 1.4 christos }
764 1.4 christos }
765 1.1 jruoho }
766 1.1 jruoho
767 1.1 jruoho /* Exit on EndTag descriptor */
768 1.1 jruoho
769 1.1 jruoho if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
770 1.1 jruoho {
771 1.1 jruoho return;
772 1.1 jruoho }
773 1.1 jruoho
774 1.1 jruoho /* Point to next descriptor in each buffer */
775 1.1 jruoho
776 1.1 jruoho Count++;
777 1.1 jruoho Offset += Aml1Length;
778 1.1 jruoho Aml1 += Aml1Length;
779 1.1 jruoho Aml2 += Aml2Length;
780 1.1 jruoho }
781 1.1 jruoho }
782 1.1 jruoho
783 1.1 jruoho
784 1.1 jruoho /*******************************************************************************
785 1.1 jruoho *
786 1.1 jruoho * FUNCTION: AcpiDmTestResourceConversion
787 1.1 jruoho *
788 1.4 christos * PARAMETERS: Node - Parent device node
789 1.4 christos * Name - resource method name (_CRS)
790 1.1 jruoho *
791 1.1 jruoho * RETURN: Status
792 1.1 jruoho *
793 1.1 jruoho * DESCRIPTION: Compare the original AML with a conversion of the AML to
794 1.1 jruoho * internal resource list, then back to AML.
795 1.1 jruoho *
796 1.1 jruoho ******************************************************************************/
797 1.1 jruoho
798 1.1 jruoho static ACPI_STATUS
799 1.1 jruoho AcpiDmTestResourceConversion (
800 1.1 jruoho ACPI_NAMESPACE_NODE *Node,
801 1.1 jruoho char *Name)
802 1.1 jruoho {
803 1.1 jruoho ACPI_STATUS Status;
804 1.4 christos ACPI_BUFFER ReturnBuffer;
805 1.4 christos ACPI_BUFFER ResourceBuffer;
806 1.1 jruoho ACPI_BUFFER NewAml;
807 1.1 jruoho ACPI_OBJECT *OriginalAml;
808 1.1 jruoho
809 1.1 jruoho
810 1.1 jruoho AcpiOsPrintf ("Resource Conversion Comparison:\n");
811 1.1 jruoho
812 1.1 jruoho NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
813 1.4 christos ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
814 1.4 christos ResourceBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
815 1.1 jruoho
816 1.1 jruoho /* Get the original _CRS AML resource template */
817 1.1 jruoho
818 1.4 christos Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnBuffer);
819 1.1 jruoho if (ACPI_FAILURE (Status))
820 1.1 jruoho {
821 1.1 jruoho AcpiOsPrintf ("Could not obtain %s: %s\n",
822 1.1 jruoho Name, AcpiFormatException (Status));
823 1.1 jruoho return (Status);
824 1.1 jruoho }
825 1.1 jruoho
826 1.1 jruoho /* Get the AML resource template, converted to internal resource structs */
827 1.1 jruoho
828 1.4 christos Status = AcpiGetCurrentResources (Node, &ResourceBuffer);
829 1.1 jruoho if (ACPI_FAILURE (Status))
830 1.1 jruoho {
831 1.1 jruoho AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
832 1.1 jruoho AcpiFormatException (Status));
833 1.1 jruoho goto Exit1;
834 1.1 jruoho }
835 1.1 jruoho
836 1.1 jruoho /* Convert internal resource list to external AML resource template */
837 1.1 jruoho
838 1.4 christos Status = AcpiRsCreateAmlResources (&ResourceBuffer, &NewAml);
839 1.1 jruoho if (ACPI_FAILURE (Status))
840 1.1 jruoho {
841 1.1 jruoho AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
842 1.1 jruoho AcpiFormatException (Status));
843 1.1 jruoho goto Exit2;
844 1.1 jruoho }
845 1.1 jruoho
846 1.1 jruoho /* Compare original AML to the newly created AML resource list */
847 1.1 jruoho
848 1.4 christos OriginalAml = ReturnBuffer.Pointer;
849 1.1 jruoho
850 1.4 christos AcpiDmCompareAmlResources (OriginalAml->Buffer.Pointer,
851 1.4 christos (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length,
852 1.1 jruoho NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length);
853 1.1 jruoho
854 1.1 jruoho /* Cleanup and exit */
855 1.1 jruoho
856 1.1 jruoho ACPI_FREE (NewAml.Pointer);
857 1.1 jruoho Exit2:
858 1.4 christos ACPI_FREE (ResourceBuffer.Pointer);
859 1.1 jruoho Exit1:
860 1.4 christos ACPI_FREE (ReturnBuffer.Pointer);
861 1.1 jruoho return (Status);
862 1.1 jruoho }
863 1.1 jruoho
864 1.1 jruoho
865 1.1 jruoho /*******************************************************************************
866 1.1 jruoho *
867 1.4 christos * FUNCTION: AcpiDbResourceCallback
868 1.4 christos *
869 1.4 christos * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
870 1.4 christos *
871 1.4 christos * RETURN: Status
872 1.4 christos *
873 1.4 christos * DESCRIPTION: Simple callback to exercise AcpiWalkResources and
874 1.4 christos * AcpiWalkResourceBuffer.
875 1.4 christos *
876 1.4 christos ******************************************************************************/
877 1.4 christos
878 1.4 christos static ACPI_STATUS
879 1.4 christos AcpiDbResourceCallback (
880 1.4 christos ACPI_RESOURCE *Resource,
881 1.4 christos void *Context)
882 1.4 christos {
883 1.4 christos
884 1.4 christos return (AE_OK);
885 1.4 christos }
886 1.4 christos
887 1.4 christos
888 1.4 christos /*******************************************************************************
889 1.4 christos *
890 1.4 christos * FUNCTION: AcpiDbDeviceResources
891 1.1 jruoho *
892 1.4 christos * PARAMETERS: ACPI_WALK_CALLBACK
893 1.1 jruoho *
894 1.4 christos * RETURN: Status
895 1.1 jruoho *
896 1.4 christos * DESCRIPTION: Display the _PRT/_CRS/_PRS resources for a device object.
897 1.1 jruoho *
898 1.1 jruoho ******************************************************************************/
899 1.1 jruoho
900 1.4 christos static ACPI_STATUS
901 1.4 christos AcpiDbDeviceResources (
902 1.4 christos ACPI_HANDLE ObjHandle,
903 1.4 christos UINT32 NestingLevel,
904 1.4 christos void *Context,
905 1.4 christos void **ReturnValue)
906 1.1 jruoho {
907 1.1 jruoho ACPI_NAMESPACE_NODE *Node;
908 1.4 christos ACPI_NAMESPACE_NODE *PrtNode = NULL;
909 1.4 christos ACPI_NAMESPACE_NODE *CrsNode = NULL;
910 1.4 christos ACPI_NAMESPACE_NODE *PrsNode = NULL;
911 1.4 christos ACPI_NAMESPACE_NODE *AeiNode = NULL;
912 1.4 christos char *ParentPath;
913 1.4 christos ACPI_BUFFER ReturnBuffer;
914 1.1 jruoho ACPI_STATUS Status;
915 1.1 jruoho
916 1.1 jruoho
917 1.4 christos Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
918 1.9 christos ParentPath = AcpiNsGetNormalizedPathname (Node, TRUE);
919 1.4 christos if (!ParentPath)
920 1.4 christos {
921 1.4 christos return (AE_NO_MEMORY);
922 1.4 christos }
923 1.1 jruoho
924 1.4 christos /* Get handles to the resource methods for this device */
925 1.1 jruoho
926 1.9 christos (void) AcpiGetHandle (Node, METHOD_NAME__PRT,
927 1.9 christos ACPI_CAST_PTR (ACPI_HANDLE, &PrtNode));
928 1.9 christos (void) AcpiGetHandle (Node, METHOD_NAME__CRS,
929 1.9 christos ACPI_CAST_PTR (ACPI_HANDLE, &CrsNode));
930 1.9 christos (void) AcpiGetHandle (Node, METHOD_NAME__PRS,
931 1.9 christos ACPI_CAST_PTR (ACPI_HANDLE, &PrsNode));
932 1.9 christos (void) AcpiGetHandle (Node, METHOD_NAME__AEI,
933 1.9 christos ACPI_CAST_PTR (ACPI_HANDLE, &AeiNode));
934 1.9 christos
935 1.4 christos if (!PrtNode && !CrsNode && !PrsNode && !AeiNode)
936 1.1 jruoho {
937 1.4 christos goto Cleanup; /* Nothing to do */
938 1.1 jruoho }
939 1.1 jruoho
940 1.4 christos AcpiOsPrintf ("\nDevice: %s\n", ParentPath);
941 1.4 christos
942 1.1 jruoho /* Prepare for a return object of arbitrary size */
943 1.1 jruoho
944 1.4 christos ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
945 1.4 christos ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
946 1.4 christos
947 1.1 jruoho
948 1.1 jruoho /* _PRT */
949 1.1 jruoho
950 1.4 christos if (PrtNode)
951 1.4 christos {
952 1.4 christos AcpiOsPrintf ("Evaluating _PRT\n");
953 1.4 christos
954 1.4 christos Status = AcpiEvaluateObject (PrtNode, NULL, NULL, &ReturnBuffer);
955 1.4 christos if (ACPI_FAILURE (Status))
956 1.4 christos {
957 1.4 christos AcpiOsPrintf ("Could not evaluate _PRT: %s\n",
958 1.4 christos AcpiFormatException (Status));
959 1.4 christos goto GetCrs;
960 1.4 christos }
961 1.1 jruoho
962 1.4 christos ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
963 1.4 christos ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
964 1.4 christos
965 1.4 christos Status = AcpiGetIrqRoutingTable (Node, &ReturnBuffer);
966 1.4 christos if (ACPI_FAILURE (Status))
967 1.4 christos {
968 1.4 christos AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
969 1.4 christos AcpiFormatException (Status));
970 1.4 christos goto GetCrs;
971 1.4 christos }
972 1.1 jruoho
973 1.4 christos AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
974 1.1 jruoho }
975 1.1 jruoho
976 1.1 jruoho
977 1.4 christos /* _CRS */
978 1.4 christos
979 1.4 christos GetCrs:
980 1.4 christos if (CrsNode)
981 1.1 jruoho {
982 1.4 christos AcpiOsPrintf ("Evaluating _CRS\n");
983 1.1 jruoho
984 1.4 christos ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
985 1.4 christos ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
986 1.1 jruoho
987 1.4 christos Status = AcpiEvaluateObject (CrsNode, NULL, NULL, &ReturnBuffer);
988 1.4 christos if (ACPI_FAILURE (Status))
989 1.4 christos {
990 1.4 christos AcpiOsPrintf ("Could not evaluate _CRS: %s\n",
991 1.4 christos AcpiFormatException (Status));
992 1.4 christos goto GetPrs;
993 1.4 christos }
994 1.1 jruoho
995 1.4 christos /* This code exercises the AcpiWalkResources interface */
996 1.1 jruoho
997 1.4 christos Status = AcpiWalkResources (Node, METHOD_NAME__CRS,
998 1.4 christos AcpiDbResourceCallback, NULL);
999 1.4 christos if (ACPI_FAILURE (Status))
1000 1.4 christos {
1001 1.4 christos AcpiOsPrintf ("AcpiWalkResources failed: %s\n",
1002 1.4 christos AcpiFormatException (Status));
1003 1.4 christos goto GetPrs;
1004 1.4 christos }
1005 1.1 jruoho
1006 1.4 christos /* Get the _CRS resource list (test ALLOCATE buffer) */
1007 1.1 jruoho
1008 1.4 christos ReturnBuffer.Pointer = NULL;
1009 1.9 christos ReturnBuffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1010 1.1 jruoho
1011 1.4 christos Status = AcpiGetCurrentResources (Node, &ReturnBuffer);
1012 1.4 christos if (ACPI_FAILURE (Status))
1013 1.4 christos {
1014 1.4 christos AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1015 1.4 christos AcpiFormatException (Status));
1016 1.4 christos goto GetPrs;
1017 1.4 christos }
1018 1.1 jruoho
1019 1.4 christos /* This code exercises the AcpiWalkResourceBuffer interface */
1020 1.1 jruoho
1021 1.4 christos Status = AcpiWalkResourceBuffer (&ReturnBuffer,
1022 1.4 christos AcpiDbResourceCallback, NULL);
1023 1.4 christos if (ACPI_FAILURE (Status))
1024 1.4 christos {
1025 1.4 christos AcpiOsPrintf ("AcpiWalkResourceBuffer failed: %s\n",
1026 1.4 christos AcpiFormatException (Status));
1027 1.4 christos goto EndCrs;
1028 1.4 christos }
1029 1.1 jruoho
1030 1.4 christos /* Dump the _CRS resource list */
1031 1.1 jruoho
1032 1.4 christos AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
1033 1.4 christos ReturnBuffer.Pointer));
1034 1.1 jruoho
1035 1.4 christos /*
1036 1.4 christos * Perform comparison of original AML to newly created AML. This
1037 1.4 christos * tests both the AML->Resource conversion and the Resource->AML
1038 1.4 christos * conversion.
1039 1.4 christos */
1040 1.5 christos (void) AcpiDmTestResourceConversion (Node, __UNCONST(METHOD_NAME__CRS));
1041 1.4 christos
1042 1.4 christos /* Execute _SRS with the resource list */
1043 1.1 jruoho
1044 1.4 christos AcpiOsPrintf ("Evaluating _SRS\n");
1045 1.1 jruoho
1046 1.4 christos Status = AcpiSetCurrentResources (Node, &ReturnBuffer);
1047 1.4 christos if (ACPI_FAILURE (Status))
1048 1.4 christos {
1049 1.4 christos AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
1050 1.4 christos AcpiFormatException (Status));
1051 1.4 christos goto EndCrs;
1052 1.4 christos }
1053 1.1 jruoho
1054 1.4 christos EndCrs:
1055 1.4 christos ACPI_FREE (ReturnBuffer.Pointer);
1056 1.1 jruoho }
1057 1.1 jruoho
1058 1.1 jruoho
1059 1.1 jruoho /* _PRS */
1060 1.1 jruoho
1061 1.1 jruoho GetPrs:
1062 1.4 christos if (PrsNode)
1063 1.4 christos {
1064 1.4 christos AcpiOsPrintf ("Evaluating _PRS\n");
1065 1.4 christos
1066 1.4 christos ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1067 1.4 christos ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1068 1.1 jruoho
1069 1.4 christos Status = AcpiEvaluateObject (PrsNode, NULL, NULL, &ReturnBuffer);
1070 1.4 christos if (ACPI_FAILURE (Status))
1071 1.4 christos {
1072 1.4 christos AcpiOsPrintf ("Could not evaluate _PRS: %s\n",
1073 1.4 christos AcpiFormatException (Status));
1074 1.4 christos goto GetAei;
1075 1.4 christos }
1076 1.1 jruoho
1077 1.4 christos ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1078 1.9 christos ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1079 1.4 christos
1080 1.4 christos Status = AcpiGetPossibleResources (Node, &ReturnBuffer);
1081 1.4 christos if (ACPI_FAILURE (Status))
1082 1.4 christos {
1083 1.4 christos AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
1084 1.4 christos AcpiFormatException (Status));
1085 1.4 christos goto GetAei;
1086 1.4 christos }
1087 1.1 jruoho
1088 1.9 christos AcpiRsDumpResourceList (ACPI_CAST_PTR (
1089 1.9 christos ACPI_RESOURCE, AcpiGbl_DbBuffer));
1090 1.1 jruoho }
1091 1.1 jruoho
1092 1.1 jruoho
1093 1.4 christos /* _AEI */
1094 1.4 christos
1095 1.4 christos GetAei:
1096 1.4 christos if (AeiNode)
1097 1.1 jruoho {
1098 1.4 christos AcpiOsPrintf ("Evaluating _AEI\n");
1099 1.4 christos
1100 1.4 christos ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1101 1.9 christos ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1102 1.4 christos
1103 1.4 christos Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnBuffer);
1104 1.4 christos if (ACPI_FAILURE (Status))
1105 1.4 christos {
1106 1.4 christos AcpiOsPrintf ("Could not evaluate _AEI: %s\n",
1107 1.4 christos AcpiFormatException (Status));
1108 1.4 christos goto Cleanup;
1109 1.4 christos }
1110 1.4 christos
1111 1.4 christos ReturnBuffer.Pointer = AcpiGbl_DbBuffer;
1112 1.9 christos ReturnBuffer.Length = ACPI_DEBUG_BUFFER_SIZE;
1113 1.4 christos
1114 1.4 christos Status = AcpiGetEventResources (Node, &ReturnBuffer);
1115 1.4 christos if (ACPI_FAILURE (Status))
1116 1.4 christos {
1117 1.4 christos AcpiOsPrintf ("AcpiGetEventResources failed: %s\n",
1118 1.4 christos AcpiFormatException (Status));
1119 1.4 christos goto Cleanup;
1120 1.4 christos }
1121 1.4 christos
1122 1.9 christos AcpiRsDumpResourceList (ACPI_CAST_PTR (
1123 1.9 christos ACPI_RESOURCE, AcpiGbl_DbBuffer));
1124 1.1 jruoho }
1125 1.1 jruoho
1126 1.1 jruoho
1127 1.1 jruoho Cleanup:
1128 1.4 christos ACPI_FREE (ParentPath);
1129 1.4 christos return (AE_OK);
1130 1.4 christos }
1131 1.4 christos
1132 1.4 christos
1133 1.4 christos /*******************************************************************************
1134 1.4 christos *
1135 1.4 christos * FUNCTION: AcpiDbDisplayResources
1136 1.4 christos *
1137 1.4 christos * PARAMETERS: ObjectArg - String object name or object pointer.
1138 1.4 christos * NULL or "*" means "display resources for
1139 1.4 christos * all devices"
1140 1.4 christos *
1141 1.4 christos * RETURN: None
1142 1.4 christos *
1143 1.4 christos * DESCRIPTION: Display the resource objects associated with a device.
1144 1.4 christos *
1145 1.4 christos ******************************************************************************/
1146 1.4 christos
1147 1.4 christos void
1148 1.4 christos AcpiDbDisplayResources (
1149 1.4 christos char *ObjectArg)
1150 1.4 christos {
1151 1.4 christos ACPI_NAMESPACE_NODE *Node;
1152 1.4 christos
1153 1.4 christos
1154 1.4 christos AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1155 1.4 christos AcpiDbgLevel |= ACPI_LV_RESOURCES;
1156 1.4 christos
1157 1.4 christos /* Asterisk means "display resources for all devices" */
1158 1.4 christos
1159 1.8 christos if (!ObjectArg || (!strcmp (ObjectArg, "*")))
1160 1.4 christos {
1161 1.4 christos (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
1162 1.9 christos ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL);
1163 1.4 christos }
1164 1.4 christos else
1165 1.4 christos {
1166 1.4 christos /* Convert string to object pointer */
1167 1.4 christos
1168 1.4 christos Node = AcpiDbConvertToNode (ObjectArg);
1169 1.4 christos if (Node)
1170 1.4 christos {
1171 1.4 christos if (Node->Type != ACPI_TYPE_DEVICE)
1172 1.4 christos {
1173 1.9 christos AcpiOsPrintf (
1174 1.9 christos "%4.4s: Name is not a device object (%s)\n",
1175 1.4 christos Node->Name.Ascii, AcpiUtGetTypeName (Node->Type));
1176 1.4 christos }
1177 1.4 christos else
1178 1.4 christos {
1179 1.4 christos (void) AcpiDbDeviceResources (Node, 0, NULL, NULL);
1180 1.4 christos }
1181 1.4 christos }
1182 1.4 christos }
1183 1.1 jruoho
1184 1.1 jruoho AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1185 1.1 jruoho }
1186 1.1 jruoho
1187 1.1 jruoho
1188 1.17 christos /*******************************************************************************
1189 1.17 christos *
1190 1.17 christos * FUNCTION: AcpiDbGenerateGed
1191 1.17 christos *
1192 1.17 christos * PARAMETERS: GedArg - Raw GED number, ascii string
1193 1.17 christos *
1194 1.17 christos * RETURN: None
1195 1.17 christos *
1196 1.17 christos * DESCRIPTION: Simulate firing of a GED
1197 1.17 christos *
1198 1.17 christos ******************************************************************************/
1199 1.17 christos
1200 1.17 christos void
1201 1.17 christos AcpiDbGenerateInterrupt (
1202 1.17 christos char *GsivArg)
1203 1.17 christos {
1204 1.17 christos UINT32 GsivNumber;
1205 1.17 christos ACPI_GED_HANDLER_INFO *GedInfo = AcpiGbl_GedHandlerList;
1206 1.17 christos
1207 1.17 christos if (!GedInfo) {
1208 1.17 christos AcpiOsPrintf ("No GED handling present\n");
1209 1.17 christos }
1210 1.17 christos
1211 1.17 christos GsivNumber = strtoul (GsivArg, NULL, 0);
1212 1.17 christos
1213 1.17 christos while (GedInfo) {
1214 1.17 christos
1215 1.17 christos if (GedInfo->IntId == GsivNumber) {
1216 1.17 christos ACPI_OBJECT_LIST ArgList;
1217 1.17 christos ACPI_OBJECT Arg0;
1218 1.17 christos ACPI_HANDLE EvtHandle = GedInfo->EvtMethod;
1219 1.17 christos ACPI_STATUS Status;
1220 1.17 christos
1221 1.17 christos AcpiOsPrintf ("Evaluate GED _EVT (GSIV=%d)\n", GsivNumber);
1222 1.17 christos
1223 1.17 christos if (!EvtHandle) {
1224 1.17 christos AcpiOsPrintf ("Undefined _EVT method\n");
1225 1.17 christos return;
1226 1.17 christos }
1227 1.17 christos
1228 1.17 christos Arg0.Integer.Type = ACPI_TYPE_INTEGER;
1229 1.17 christos Arg0.Integer.Value = GsivNumber;
1230 1.17 christos
1231 1.17 christos ArgList.Count = 1;
1232 1.17 christos ArgList.Pointer = &Arg0;
1233 1.17 christos
1234 1.17 christos Status = AcpiEvaluateObject (EvtHandle, NULL, &ArgList, NULL);
1235 1.17 christos if (ACPI_FAILURE (Status))
1236 1.17 christos {
1237 1.17 christos AcpiOsPrintf ("Could not evaluate _EVT\n");
1238 1.17 christos return;
1239 1.17 christos }
1240 1.17 christos
1241 1.17 christos }
1242 1.17 christos GedInfo = GedInfo->Next;
1243 1.17 christos }
1244 1.17 christos }
1245 1.17 christos
1246 1.4 christos #if (!ACPI_REDUCED_HARDWARE)
1247 1.1 jruoho /*******************************************************************************
1248 1.1 jruoho *
1249 1.1 jruoho * FUNCTION: AcpiDbGenerateGpe
1250 1.1 jruoho *
1251 1.4 christos * PARAMETERS: GpeArg - Raw GPE number, ascii string
1252 1.4 christos * BlockArg - GPE block number, ascii string
1253 1.4 christos * 0 or 1 for FADT GPE blocks
1254 1.1 jruoho *
1255 1.1 jruoho * RETURN: None
1256 1.1 jruoho *
1257 1.4 christos * DESCRIPTION: Simulate firing of a GPE
1258 1.1 jruoho *
1259 1.1 jruoho ******************************************************************************/
1260 1.1 jruoho
1261 1.1 jruoho void
1262 1.1 jruoho AcpiDbGenerateGpe (
1263 1.1 jruoho char *GpeArg,
1264 1.1 jruoho char *BlockArg)
1265 1.1 jruoho {
1266 1.6 christos UINT32 BlockNumber = 0;
1267 1.1 jruoho UINT32 GpeNumber;
1268 1.1 jruoho ACPI_GPE_EVENT_INFO *GpeEventInfo;
1269 1.1 jruoho
1270 1.1 jruoho
1271 1.8 christos GpeNumber = strtoul (GpeArg, NULL, 0);
1272 1.1 jruoho
1273 1.6 christos /*
1274 1.6 christos * If no block arg, or block arg == 0 or 1, use the FADT-defined
1275 1.6 christos * GPE blocks.
1276 1.6 christos */
1277 1.6 christos if (BlockArg)
1278 1.6 christos {
1279 1.8 christos BlockNumber = strtoul (BlockArg, NULL, 0);
1280 1.6 christos if (BlockNumber == 1)
1281 1.6 christos {
1282 1.6 christos BlockNumber = 0;
1283 1.6 christos }
1284 1.6 christos }
1285 1.1 jruoho
1286 1.9 christos GpeEventInfo = AcpiEvGetGpeEventInfo (
1287 1.9 christos ACPI_TO_POINTER (BlockNumber), GpeNumber);
1288 1.1 jruoho if (!GpeEventInfo)
1289 1.1 jruoho {
1290 1.1 jruoho AcpiOsPrintf ("Invalid GPE\n");
1291 1.1 jruoho return;
1292 1.1 jruoho }
1293 1.1 jruoho
1294 1.3 jruoho (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber);
1295 1.1 jruoho }
1296 1.1 jruoho
1297 1.9 christos
1298 1.9 christos /*******************************************************************************
1299 1.9 christos *
1300 1.9 christos * FUNCTION: AcpiDbGenerateSci
1301 1.9 christos *
1302 1.9 christos * PARAMETERS: None
1303 1.9 christos *
1304 1.9 christos * RETURN: None
1305 1.9 christos *
1306 1.9 christos * DESCRIPTION: Simulate an SCI -- just call the SCI dispatch.
1307 1.9 christos *
1308 1.9 christos ******************************************************************************/
1309 1.9 christos
1310 1.4 christos void
1311 1.4 christos AcpiDbGenerateSci (
1312 1.4 christos void)
1313 1.4 christos {
1314 1.4 christos AcpiEvSciDispatch ();
1315 1.4 christos }
1316 1.4 christos
1317 1.4 christos #endif /* !ACPI_REDUCED_HARDWARE */
1318 1.4 christos
1319 1.8 christos
1320 1.8 christos /*******************************************************************************
1321 1.8 christos *
1322 1.8 christos * FUNCTION: AcpiDbTrace
1323 1.8 christos *
1324 1.8 christos * PARAMETERS: EnableArg - ENABLE/AML to enable tracer
1325 1.8 christos * DISABLE to disable tracer
1326 1.8 christos * MethodArg - Method to trace
1327 1.8 christos * OnceArg - Whether trace once
1328 1.8 christos *
1329 1.8 christos * RETURN: None
1330 1.8 christos *
1331 1.8 christos * DESCRIPTION: Control method tracing facility
1332 1.8 christos *
1333 1.8 christos ******************************************************************************/
1334 1.8 christos
1335 1.8 christos void
1336 1.8 christos AcpiDbTrace (
1337 1.8 christos char *EnableArg,
1338 1.8 christos char *MethodArg,
1339 1.8 christos char *OnceArg)
1340 1.8 christos {
1341 1.8 christos UINT32 DebugLevel = 0;
1342 1.8 christos UINT32 DebugLayer = 0;
1343 1.8 christos UINT32 Flags = 0;
1344 1.8 christos
1345 1.8 christos
1346 1.9 christos AcpiUtStrupr (EnableArg);
1347 1.9 christos AcpiUtStrupr (OnceArg);
1348 1.9 christos
1349 1.8 christos if (MethodArg)
1350 1.8 christos {
1351 1.8 christos if (AcpiDbTraceMethodName)
1352 1.8 christos {
1353 1.8 christos ACPI_FREE (AcpiDbTraceMethodName);
1354 1.8 christos AcpiDbTraceMethodName = NULL;
1355 1.8 christos }
1356 1.9 christos
1357 1.8 christos AcpiDbTraceMethodName = ACPI_ALLOCATE (strlen (MethodArg) + 1);
1358 1.8 christos if (!AcpiDbTraceMethodName)
1359 1.8 christos {
1360 1.9 christos AcpiOsPrintf ("Failed to allocate method name (%s)\n",
1361 1.9 christos MethodArg);
1362 1.8 christos return;
1363 1.8 christos }
1364 1.9 christos
1365 1.8 christos strcpy (AcpiDbTraceMethodName, MethodArg);
1366 1.8 christos }
1367 1.9 christos
1368 1.8 christos if (!strcmp (EnableArg, "ENABLE") ||
1369 1.8 christos !strcmp (EnableArg, "METHOD") ||
1370 1.8 christos !strcmp (EnableArg, "OPCODE"))
1371 1.8 christos {
1372 1.8 christos if (!strcmp (EnableArg, "ENABLE"))
1373 1.8 christos {
1374 1.8 christos /* Inherit current console settings */
1375 1.8 christos
1376 1.8 christos DebugLevel = AcpiGbl_DbConsoleDebugLevel;
1377 1.8 christos DebugLayer = AcpiDbgLayer;
1378 1.8 christos }
1379 1.8 christos else
1380 1.8 christos {
1381 1.8 christos /* Restrict console output to trace points only */
1382 1.8 christos
1383 1.8 christos DebugLevel = ACPI_LV_TRACE_POINT;
1384 1.8 christos DebugLayer = ACPI_EXECUTER;
1385 1.8 christos }
1386 1.8 christos
1387 1.8 christos Flags = ACPI_TRACE_ENABLED;
1388 1.9 christos
1389 1.8 christos if (!strcmp (EnableArg, "OPCODE"))
1390 1.8 christos {
1391 1.8 christos Flags |= ACPI_TRACE_OPCODE;
1392 1.8 christos }
1393 1.9 christos
1394 1.8 christos if (OnceArg && !strcmp (OnceArg, "ONCE"))
1395 1.8 christos {
1396 1.8 christos Flags |= ACPI_TRACE_ONESHOT;
1397 1.8 christos }
1398 1.8 christos }
1399 1.8 christos
1400 1.8 christos (void) AcpiDebugTrace (AcpiDbTraceMethodName,
1401 1.9 christos DebugLevel, DebugLayer, Flags);
1402 1.8 christos }
1403