Rev 1498 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1498 | serge | 1 | /******************************************************************************* |
2 | * |
||
2216 | Serge | 3 | * Module Name: dbcmds - Miscellaneous debug commands and output routines |
1498 | serge | 4 | * |
5 | ******************************************************************************/ |
||
6 | |||
7 | /****************************************************************************** |
||
8 | * |
||
9 | * 1. Copyright Notice |
||
10 | * |
||
2216 | Serge | 11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
1498 | serge | 12 | * All rights reserved. |
13 | * |
||
14 | * 2. License |
||
15 | * |
||
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
||
17 | * rights. You may have additional license terms from the party that provided |
||
18 | * you this software, covering your right to use that party's intellectual |
||
19 | * property rights. |
||
20 | * |
||
21 | * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
||
22 | * copy of the source code appearing in this file ("Covered Code") an |
||
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
||
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
||
25 | * make derivatives, distribute, use and display any portion of the Covered |
||
26 | * Code in any form, with the right to sublicense such rights; and |
||
27 | * |
||
28 | * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
||
29 | * license (with the right to sublicense), under only those claims of Intel |
||
30 | * patents that are infringed by the Original Intel Code, to make, use, sell, |
||
31 | * offer to sell, and import the Covered Code and derivative works thereof |
||
32 | * solely to the minimum extent necessary to exercise the above copyright |
||
33 | * license, and in no event shall the patent license extend to any additions |
||
34 | * to or modifications of the Original Intel Code. No other license or right |
||
35 | * is granted directly or by implication, estoppel or otherwise; |
||
36 | * |
||
37 | * The above copyright and patent license is granted only if the following |
||
38 | * conditions are met: |
||
39 | * |
||
40 | * 3. Conditions |
||
41 | * |
||
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
||
43 | * Redistribution of source code of any substantial portion of the Covered |
||
44 | * Code or modification with rights to further distribute source must include |
||
45 | * the above Copyright Notice, the above License, this list of Conditions, |
||
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
||
47 | * Licensee must cause all Covered Code to which Licensee contributes to |
||
48 | * contain a file documenting the changes Licensee made to create that Covered |
||
49 | * Code and the date of any change. Licensee must include in that file the |
||
50 | * documentation of any changes made by any predecessor Licensee. Licensee |
||
51 | * must include a prominent statement that the modification is derived, |
||
52 | * directly or indirectly, from Original Intel Code. |
||
53 | * |
||
54 | * 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
||
55 | * Redistribution of source code of any substantial portion of the Covered |
||
56 | * Code or modification without rights to further distribute source must |
||
57 | * include the following Disclaimer and Export Compliance provision in the |
||
58 | * documentation and/or other materials provided with distribution. In |
||
59 | * addition, Licensee may not authorize further sublicense of source of any |
||
60 | * portion of the Covered Code, and must include terms to the effect that the |
||
61 | * license from Licensee to its licensee is limited to the intellectual |
||
62 | * property embodied in the software Licensee provides to its licensee, and |
||
63 | * not to intellectual property embodied in modifications its licensee may |
||
64 | * make. |
||
65 | * |
||
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
||
67 | * substantial portion of the Covered Code or modification must reproduce the |
||
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
||
69 | * provision in the documentation and/or other materials provided with the |
||
70 | * distribution. |
||
71 | * |
||
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
||
73 | * Intel Code. |
||
74 | * |
||
75 | * 3.5. Neither the name Intel nor any other trademark owned or controlled by |
||
76 | * Intel shall be used in advertising or otherwise to promote the sale, use or |
||
77 | * other dealings in products derived from or relating to the Covered Code |
||
78 | * without prior written authorization from Intel. |
||
79 | * |
||
80 | * 4. Disclaimer and Export Compliance |
||
81 | * |
||
82 | * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
||
83 | * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
||
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
||
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
||
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
||
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
||
88 | * PARTICULAR PURPOSE. |
||
89 | * |
||
90 | * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
||
91 | * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
||
92 | * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
||
93 | * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
||
94 | * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
||
95 | * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
||
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
||
97 | * LIMITED REMEDY. |
||
98 | * |
||
99 | * 4.3. Licensee shall not export, either directly or indirectly, any of this |
||
100 | * software or system incorporating such software without first obtaining any |
||
101 | * required license or other approval from the U. S. Department of Commerce or |
||
102 | * any other agency or department of the United States Government. In the |
||
103 | * event Licensee exports any such software from the United States or |
||
104 | * re-exports any such software from a foreign destination, Licensee shall |
||
105 | * ensure that the distribution and export/re-export of the software is in |
||
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
||
107 | * U.S. Export Administration Regulations. Licensee agrees that neither it nor |
||
108 | * any of its subsidiaries will export/re-export any technical data, process, |
||
109 | * software, or service, directly or indirectly, to any country for which the |
||
110 | * United States government or any agency thereof requires an export license, |
||
111 | * other governmental approval, or letter of assurance, without first obtaining |
||
112 | * such license, approval or letter. |
||
113 | * |
||
114 | *****************************************************************************/ |
||
115 | |||
116 | |||
117 | #include "acpi.h" |
||
118 | #include "accommon.h" |
||
119 | #include "acevents.h" |
||
120 | #include "acdebug.h" |
||
121 | #include "acresrc.h" |
||
122 | #include "actables.h" |
||
123 | |||
124 | #ifdef ACPI_DEBUGGER |
||
125 | |||
126 | #define _COMPONENT ACPI_CA_DEBUGGER |
||
127 | ACPI_MODULE_NAME ("dbcmds") |
||
128 | |||
129 | |||
130 | /* Local prototypes */ |
||
131 | |||
132 | static void |
||
133 | AcpiDmCompareAmlResources ( |
||
134 | UINT8 *Aml1Buffer, |
||
135 | ACPI_RSDESC_SIZE Aml1BufferLength, |
||
136 | UINT8 *Aml2Buffer, |
||
137 | ACPI_RSDESC_SIZE Aml2BufferLength); |
||
138 | |||
139 | static ACPI_STATUS |
||
140 | AcpiDmTestResourceConversion ( |
||
141 | ACPI_NAMESPACE_NODE *Node, |
||
142 | char *Name); |
||
143 | |||
144 | |||
145 | /******************************************************************************* |
||
146 | * |
||
147 | * FUNCTION: AcpiDbConvertToNode |
||
148 | * |
||
149 | * PARAMETERS: InString - String to convert |
||
150 | * |
||
151 | * RETURN: Pointer to a NS node |
||
152 | * |
||
153 | * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or |
||
154 | * alpha strings. |
||
155 | * |
||
156 | ******************************************************************************/ |
||
157 | |||
2216 | Serge | 158 | ACPI_NAMESPACE_NODE * |
1498 | serge | 159 | AcpiDbConvertToNode ( |
160 | char *InString) |
||
161 | { |
||
162 | ACPI_NAMESPACE_NODE *Node; |
||
163 | |||
164 | |||
165 | if ((*InString >= 0x30) && (*InString <= 0x39)) |
||
166 | { |
||
167 | /* Numeric argument, convert */ |
||
168 | |||
169 | Node = ACPI_TO_POINTER (ACPI_STRTOUL (InString, NULL, 16)); |
||
170 | if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) |
||
171 | { |
||
172 | AcpiOsPrintf ("Address %p is invalid in this address space\n", |
||
173 | Node); |
||
174 | return (NULL); |
||
175 | } |
||
176 | |||
177 | /* Make sure pointer is valid NS node */ |
||
178 | |||
179 | if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) |
||
180 | { |
||
181 | AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n", |
||
182 | Node, AcpiUtGetDescriptorName (Node)); |
||
183 | return (NULL); |
||
184 | } |
||
185 | } |
||
186 | else |
||
187 | { |
||
188 | /* Alpha argument */ |
||
189 | /* The parameter is a name string that must be resolved to a |
||
190 | * Named obj |
||
191 | */ |
||
192 | Node = AcpiDbLocalNsLookup (InString); |
||
193 | if (!Node) |
||
194 | { |
||
195 | Node = AcpiGbl_RootNode; |
||
196 | } |
||
197 | } |
||
198 | |||
199 | return (Node); |
||
200 | } |
||
201 | |||
202 | |||
203 | /******************************************************************************* |
||
204 | * |
||
205 | * FUNCTION: AcpiDbSleep |
||
206 | * |
||
207 | * PARAMETERS: ObjectArg - Desired sleep state (0-5) |
||
208 | * |
||
209 | * RETURN: Status |
||
210 | * |
||
211 | * DESCRIPTION: Simulate a sleep/wake sequence |
||
212 | * |
||
213 | ******************************************************************************/ |
||
214 | |||
215 | ACPI_STATUS |
||
216 | AcpiDbSleep ( |
||
217 | char *ObjectArg) |
||
218 | { |
||
219 | ACPI_STATUS Status; |
||
220 | UINT8 SleepState; |
||
221 | |||
222 | |||
223 | SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0); |
||
224 | |||
225 | AcpiOsPrintf ("**** Prepare to sleep ****\n"); |
||
226 | Status = AcpiEnterSleepStatePrep (SleepState); |
||
227 | if (ACPI_FAILURE (Status)) |
||
228 | { |
||
229 | return (Status); |
||
230 | } |
||
231 | |||
232 | AcpiOsPrintf ("**** Going to sleep ****\n"); |
||
233 | Status = AcpiEnterSleepState (SleepState); |
||
234 | if (ACPI_FAILURE (Status)) |
||
235 | { |
||
236 | return (Status); |
||
237 | } |
||
238 | |||
239 | AcpiOsPrintf ("**** returning from sleep ****\n"); |
||
240 | Status = AcpiLeaveSleepState (SleepState); |
||
241 | |||
242 | return (Status); |
||
243 | } |
||
244 | |||
245 | /******************************************************************************* |
||
246 | * |
||
247 | * FUNCTION: AcpiDbDisplayLocks |
||
248 | * |
||
249 | * PARAMETERS: None |
||
250 | * |
||
251 | * RETURN: None |
||
252 | * |
||
253 | * DESCRIPTION: Display information about internal mutexes. |
||
254 | * |
||
255 | ******************************************************************************/ |
||
256 | |||
257 | void |
||
258 | AcpiDbDisplayLocks ( |
||
259 | void) |
||
260 | { |
||
261 | UINT32 i; |
||
262 | |||
263 | |||
264 | for (i = 0; i < ACPI_MAX_MUTEX; i++) |
||
265 | { |
||
266 | AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i), |
||
267 | AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED |
||
268 | ? "Locked" : "Unlocked"); |
||
269 | } |
||
270 | } |
||
271 | |||
272 | |||
273 | /******************************************************************************* |
||
274 | * |
||
275 | * FUNCTION: AcpiDbDisplayTableInfo |
||
276 | * |
||
277 | * PARAMETERS: TableArg - String with name of table to be displayed |
||
278 | * |
||
279 | * RETURN: None |
||
280 | * |
||
281 | * DESCRIPTION: Display information about loaded tables. Current |
||
282 | * implementation displays all loaded tables. |
||
283 | * |
||
284 | ******************************************************************************/ |
||
285 | |||
286 | void |
||
287 | AcpiDbDisplayTableInfo ( |
||
288 | char *TableArg) |
||
289 | { |
||
290 | UINT32 i; |
||
291 | ACPI_TABLE_DESC *TableDesc; |
||
292 | ACPI_STATUS Status; |
||
293 | |||
294 | |||
295 | /* Walk the entire root table list */ |
||
296 | |||
297 | for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++) |
||
298 | { |
||
299 | TableDesc = &AcpiGbl_RootTableList.Tables[i]; |
||
300 | AcpiOsPrintf ("%u ", i); |
||
301 | |||
302 | /* Make sure that the table is mapped */ |
||
303 | |||
304 | Status = AcpiTbVerifyTable (TableDesc); |
||
305 | if (ACPI_FAILURE (Status)) |
||
306 | { |
||
307 | return; |
||
308 | } |
||
309 | |||
310 | /* Dump the table header */ |
||
311 | |||
312 | if (TableDesc->Pointer) |
||
313 | { |
||
314 | AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer); |
||
315 | } |
||
316 | else |
||
317 | { |
||
318 | /* If the pointer is null, the table has been unloaded */ |
||
319 | |||
320 | ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded", |
||
321 | TableDesc->Signature.Ascii)); |
||
322 | } |
||
323 | } |
||
324 | } |
||
325 | |||
326 | |||
327 | /******************************************************************************* |
||
328 | * |
||
329 | * FUNCTION: AcpiDbUnloadAcpiTable |
||
330 | * |
||
331 | * PARAMETERS: TableArg - Name of the table to be unloaded |
||
332 | * InstanceArg - Which instance of the table to unload (if |
||
333 | * there are multiple tables of the same type) |
||
334 | * |
||
335 | * RETURN: Nonde |
||
336 | * |
||
337 | * DESCRIPTION: Unload an ACPI table. |
||
338 | * Instance is not implemented |
||
339 | * |
||
340 | ******************************************************************************/ |
||
341 | |||
342 | void |
||
343 | AcpiDbUnloadAcpiTable ( |
||
344 | char *TableArg, |
||
345 | char *InstanceArg) |
||
346 | { |
||
347 | /* TBD: Need to reimplement for new data structures */ |
||
348 | |||
349 | #if 0 |
||
350 | UINT32 i; |
||
351 | ACPI_STATUS Status; |
||
352 | |||
353 | |||
354 | /* Search all tables for the target type */ |
||
355 | |||
356 | for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++) |
||
357 | { |
||
358 | if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature, |
||
359 | AcpiGbl_TableData[i].SigLength)) |
||
360 | { |
||
361 | /* Found the table, unload it */ |
||
362 | |||
363 | Status = AcpiUnloadTable (i); |
||
364 | if (ACPI_SUCCESS (Status)) |
||
365 | { |
||
366 | AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg); |
||
367 | } |
||
368 | else |
||
369 | { |
||
370 | AcpiOsPrintf ("%s, while unloading [%s]\n", |
||
371 | AcpiFormatException (Status), TableArg); |
||
372 | } |
||
373 | |||
374 | return; |
||
375 | } |
||
376 | } |
||
377 | |||
378 | AcpiOsPrintf ("Unknown table type [%s]\n", TableArg); |
||
379 | #endif |
||
380 | } |
||
381 | |||
382 | |||
383 | /******************************************************************************* |
||
384 | * |
||
385 | * FUNCTION: AcpiDbSendNotify |
||
386 | * |
||
387 | * PARAMETERS: Name - Name of ACPI object to send the notify to |
||
388 | * Value - Value of the notify to send. |
||
389 | * |
||
390 | * RETURN: None |
||
391 | * |
||
392 | * DESCRIPTION: Send an ACPI notification. The value specified is sent to the |
||
393 | * named object as an ACPI notify. |
||
394 | * |
||
395 | ******************************************************************************/ |
||
396 | |||
397 | void |
||
398 | AcpiDbSendNotify ( |
||
399 | char *Name, |
||
400 | UINT32 Value) |
||
401 | { |
||
402 | ACPI_NAMESPACE_NODE *Node; |
||
403 | ACPI_STATUS Status; |
||
404 | |||
405 | |||
406 | /* Translate name to an Named object */ |
||
407 | |||
408 | Node = AcpiDbConvertToNode (Name); |
||
409 | if (!Node) |
||
410 | { |
||
411 | return; |
||
412 | } |
||
413 | |||
414 | /* Decode Named object type */ |
||
415 | |||
416 | switch (Node->Type) |
||
417 | { |
||
418 | case ACPI_TYPE_DEVICE: |
||
419 | case ACPI_TYPE_THERMAL: |
||
420 | |||
421 | /* Send the notify */ |
||
422 | |||
423 | Status = AcpiEvQueueNotifyRequest (Node, Value); |
||
424 | if (ACPI_FAILURE (Status)) |
||
425 | { |
||
426 | AcpiOsPrintf ("Could not queue notify\n"); |
||
427 | } |
||
428 | break; |
||
429 | |||
430 | default: |
||
431 | AcpiOsPrintf ("Named object is not a device or a thermal object\n"); |
||
432 | break; |
||
433 | } |
||
434 | } |
||
435 | |||
436 | |||
437 | /******************************************************************************* |
||
438 | * |
||
2216 | Serge | 439 | * FUNCTION: AcpiDbDisplayInterfaces |
1498 | serge | 440 | * |
2216 | Serge | 441 | * PARAMETERS: ActionArg - Null, "install", or "remove" |
442 | * InterfaceNameArg - Name for install/remove options |
||
1498 | serge | 443 | * |
444 | * RETURN: None |
||
445 | * |
||
2216 | Serge | 446 | * DESCRIPTION: Display or modify the global _OSI interface list |
1498 | serge | 447 | * |
448 | ******************************************************************************/ |
||
449 | |||
450 | void |
||
2216 | Serge | 451 | AcpiDbDisplayInterfaces ( |
452 | char *ActionArg, |
||
453 | char *InterfaceNameArg) |
||
1498 | serge | 454 | { |
2216 | Serge | 455 | ACPI_INTERFACE_INFO *NextInterface; |
456 | char *SubString; |
||
1498 | serge | 457 | ACPI_STATUS Status; |
458 | |||
459 | |||
2216 | Serge | 460 | /* If no arguments, just display current interface list */ |
1498 | serge | 461 | |
2216 | Serge | 462 | if (!ActionArg) |
1498 | serge | 463 | { |
2216 | Serge | 464 | (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, |
465 | ACPI_WAIT_FOREVER); |
||
1498 | serge | 466 | |
2216 | Serge | 467 | NextInterface = AcpiGbl_SupportedInterfaces; |
1498 | serge | 468 | |
2216 | Serge | 469 | while (NextInterface) |
1498 | serge | 470 | { |
2216 | Serge | 471 | if (!(NextInterface->Flags & ACPI_OSI_INVALID)) |
472 | { |
||
473 | AcpiOsPrintf ("%s\n", NextInterface->Name); |
||
474 | } |
||
475 | NextInterface = NextInterface->Next; |
||
1498 | serge | 476 | } |
2216 | Serge | 477 | |
478 | AcpiOsReleaseMutex (AcpiGbl_OsiMutex); |
||
1498 | serge | 479 | return; |
480 | } |
||
481 | |||
2216 | Serge | 482 | /* If ActionArg exists, so must InterfaceNameArg */ |
1498 | serge | 483 | |
2216 | Serge | 484 | if (!InterfaceNameArg) |
1498 | serge | 485 | { |
2216 | Serge | 486 | AcpiOsPrintf ("Missing Interface Name argument\n"); |
1498 | serge | 487 | return; |
488 | } |
||
489 | |||
2216 | Serge | 490 | /* Uppercase the action for match below */ |
1498 | serge | 491 | |
2216 | Serge | 492 | AcpiUtStrupr (ActionArg); |
1498 | serge | 493 | |
2216 | Serge | 494 | /* Install - install an interface */ |
1498 | serge | 495 | |
2216 | Serge | 496 | SubString = ACPI_STRSTR ("INSTALL", ActionArg); |
497 | if (SubString) |
||
1498 | serge | 498 | { |
2216 | Serge | 499 | Status = AcpiInstallInterface (InterfaceNameArg); |
1498 | serge | 500 | if (ACPI_FAILURE (Status)) |
501 | { |
||
2216 | Serge | 502 | AcpiOsPrintf ("%s, while installing \"%s\"\n", |
503 | AcpiFormatException (Status), InterfaceNameArg); |
||
1498 | serge | 504 | } |
505 | return; |
||
506 | } |
||
507 | |||
2216 | Serge | 508 | /* Remove - remove an interface */ |
1498 | serge | 509 | |
2216 | Serge | 510 | SubString = ACPI_STRSTR ("REMOVE", ActionArg); |
511 | if (SubString) |
||
1498 | serge | 512 | { |
2216 | Serge | 513 | Status = AcpiRemoveInterface (InterfaceNameArg); |
1498 | serge | 514 | if (ACPI_FAILURE (Status)) |
515 | { |
||
2216 | Serge | 516 | AcpiOsPrintf ("%s, while removing \"%s\"\n", |
517 | AcpiFormatException (Status), InterfaceNameArg); |
||
1498 | serge | 518 | } |
2216 | Serge | 519 | return; |
1498 | serge | 520 | } |
521 | |||
2216 | Serge | 522 | /* Invalid ActionArg */ |
1498 | serge | 523 | |
2216 | Serge | 524 | AcpiOsPrintf ("Invalid action argument: %s\n", ActionArg); |
1498 | serge | 525 | return; |
526 | } |
||
527 | |||
528 | |||
529 | /******************************************************************************* |
||
530 | * |
||
531 | * FUNCTION: AcpiDmCompareAmlResources |
||
532 | * |
||
533 | * PARAMETERS: Aml1Buffer - Contains first resource list |
||
534 | * Aml1BufferLength - Length of first resource list |
||
535 | * Aml2Buffer - Contains second resource list |
||
536 | * Aml2BufferLength - Length of second resource list |
||
537 | * |
||
538 | * RETURN: None |
||
539 | * |
||
540 | * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in |
||
541 | * order to isolate a miscompare to an individual resource) |
||
542 | * |
||
543 | ******************************************************************************/ |
||
544 | |||
545 | static void |
||
546 | AcpiDmCompareAmlResources ( |
||
547 | UINT8 *Aml1Buffer, |
||
548 | ACPI_RSDESC_SIZE Aml1BufferLength, |
||
549 | UINT8 *Aml2Buffer, |
||
550 | ACPI_RSDESC_SIZE Aml2BufferLength) |
||
551 | { |
||
552 | UINT8 *Aml1; |
||
553 | UINT8 *Aml2; |
||
554 | ACPI_RSDESC_SIZE Aml1Length; |
||
555 | ACPI_RSDESC_SIZE Aml2Length; |
||
556 | ACPI_RSDESC_SIZE Offset = 0; |
||
557 | UINT8 ResourceType; |
||
558 | UINT32 Count = 0; |
||
559 | |||
560 | |||
561 | /* Compare overall buffer sizes (may be different due to size rounding) */ |
||
562 | |||
563 | if (Aml1BufferLength != Aml2BufferLength) |
||
564 | { |
||
565 | AcpiOsPrintf ( |
||
566 | "**** Buffer length mismatch in converted AML: original %X new %X ****\n", |
||
567 | Aml1BufferLength, Aml2BufferLength); |
||
568 | } |
||
569 | |||
570 | Aml1 = Aml1Buffer; |
||
571 | Aml2 = Aml2Buffer; |
||
572 | |||
573 | /* Walk the descriptor lists, comparing each descriptor */ |
||
574 | |||
575 | while (Aml1 < (Aml1Buffer + Aml1BufferLength)) |
||
576 | { |
||
577 | /* Get the lengths of each descriptor */ |
||
578 | |||
579 | Aml1Length = AcpiUtGetDescriptorLength (Aml1); |
||
580 | Aml2Length = AcpiUtGetDescriptorLength (Aml2); |
||
581 | ResourceType = AcpiUtGetResourceType (Aml1); |
||
582 | |||
583 | /* Check for descriptor length match */ |
||
584 | |||
585 | if (Aml1Length != Aml2Length) |
||
586 | { |
||
587 | AcpiOsPrintf ( |
||
588 | "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X L1 %X L2 %X ****\n", |
||
589 | Count, ResourceType, Offset, Aml1Length, Aml2Length); |
||
590 | } |
||
591 | |||
592 | /* Check for descriptor byte match */ |
||
593 | |||
594 | else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length)) |
||
595 | { |
||
596 | AcpiOsPrintf ( |
||
597 | "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n", |
||
598 | Count, ResourceType, Offset); |
||
599 | } |
||
600 | |||
601 | /* Exit on EndTag descriptor */ |
||
602 | |||
603 | if (ResourceType == ACPI_RESOURCE_NAME_END_TAG) |
||
604 | { |
||
605 | return; |
||
606 | } |
||
607 | |||
608 | /* Point to next descriptor in each buffer */ |
||
609 | |||
610 | Count++; |
||
611 | Offset += Aml1Length; |
||
612 | Aml1 += Aml1Length; |
||
613 | Aml2 += Aml2Length; |
||
614 | } |
||
615 | } |
||
616 | |||
617 | |||
618 | /******************************************************************************* |
||
619 | * |
||
620 | * FUNCTION: AcpiDmTestResourceConversion |
||
621 | * |
||
622 | * PARAMETERS: Node - Parent device node |
||
623 | * Name - resource method name (_CRS) |
||
624 | * |
||
625 | * RETURN: Status |
||
626 | * |
||
627 | * DESCRIPTION: Compare the original AML with a conversion of the AML to |
||
628 | * internal resource list, then back to AML. |
||
629 | * |
||
630 | ******************************************************************************/ |
||
631 | |||
632 | static ACPI_STATUS |
||
633 | AcpiDmTestResourceConversion ( |
||
634 | ACPI_NAMESPACE_NODE *Node, |
||
635 | char *Name) |
||
636 | { |
||
637 | ACPI_STATUS Status; |
||
638 | ACPI_BUFFER ReturnObj; |
||
639 | ACPI_BUFFER ResourceObj; |
||
640 | ACPI_BUFFER NewAml; |
||
641 | ACPI_OBJECT *OriginalAml; |
||
642 | |||
643 | |||
644 | AcpiOsPrintf ("Resource Conversion Comparison:\n"); |
||
645 | |||
646 | NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER; |
||
647 | ReturnObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER; |
||
648 | ResourceObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER; |
||
649 | |||
650 | /* Get the original _CRS AML resource template */ |
||
651 | |||
652 | Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnObj); |
||
653 | if (ACPI_FAILURE (Status)) |
||
654 | { |
||
655 | AcpiOsPrintf ("Could not obtain %s: %s\n", |
||
656 | Name, AcpiFormatException (Status)); |
||
657 | return (Status); |
||
658 | } |
||
659 | |||
660 | /* Get the AML resource template, converted to internal resource structs */ |
||
661 | |||
662 | Status = AcpiGetCurrentResources (Node, &ResourceObj); |
||
663 | if (ACPI_FAILURE (Status)) |
||
664 | { |
||
665 | AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", |
||
666 | AcpiFormatException (Status)); |
||
667 | goto Exit1; |
||
668 | } |
||
669 | |||
670 | /* Convert internal resource list to external AML resource template */ |
||
671 | |||
672 | Status = AcpiRsCreateAmlResources (ResourceObj.Pointer, &NewAml); |
||
673 | if (ACPI_FAILURE (Status)) |
||
674 | { |
||
675 | AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n", |
||
676 | AcpiFormatException (Status)); |
||
677 | goto Exit2; |
||
678 | } |
||
679 | |||
680 | /* Compare original AML to the newly created AML resource list */ |
||
681 | |||
682 | OriginalAml = ReturnObj.Pointer; |
||
683 | |||
684 | AcpiDmCompareAmlResources ( |
||
685 | OriginalAml->Buffer.Pointer, (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length, |
||
686 | NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length); |
||
687 | |||
688 | /* Cleanup and exit */ |
||
689 | |||
690 | ACPI_FREE (NewAml.Pointer); |
||
691 | Exit2: |
||
692 | ACPI_FREE (ResourceObj.Pointer); |
||
693 | Exit1: |
||
694 | ACPI_FREE (ReturnObj.Pointer); |
||
695 | return (Status); |
||
696 | } |
||
697 | |||
698 | |||
699 | /******************************************************************************* |
||
700 | * |
||
701 | * FUNCTION: AcpiDbDisplayResources |
||
702 | * |
||
703 | * PARAMETERS: ObjectArg - String with hex value of the object |
||
704 | * |
||
705 | * RETURN: None |
||
706 | * |
||
707 | * DESCRIPTION: Display the resource objects associated with a device. |
||
708 | * |
||
709 | ******************************************************************************/ |
||
710 | |||
711 | void |
||
712 | AcpiDbDisplayResources ( |
||
713 | char *ObjectArg) |
||
714 | { |
||
715 | ACPI_NAMESPACE_NODE *Node; |
||
716 | ACPI_STATUS Status; |
||
717 | ACPI_BUFFER ReturnObj; |
||
718 | |||
719 | |||
720 | AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); |
||
721 | AcpiDbgLevel |= ACPI_LV_RESOURCES; |
||
722 | |||
723 | /* Convert string to object pointer */ |
||
724 | |||
725 | Node = AcpiDbConvertToNode (ObjectArg); |
||
726 | if (!Node) |
||
727 | { |
||
728 | return; |
||
729 | } |
||
730 | |||
731 | /* Prepare for a return object of arbitrary size */ |
||
732 | |||
733 | ReturnObj.Pointer = AcpiGbl_DbBuffer; |
||
734 | ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; |
||
735 | |||
736 | /* _PRT */ |
||
737 | |||
738 | AcpiOsPrintf ("Evaluating _PRT\n"); |
||
739 | |||
740 | /* Check if _PRT exists */ |
||
741 | |||
742 | Status = AcpiEvaluateObject (Node, METHOD_NAME__PRT, NULL, &ReturnObj); |
||
743 | if (ACPI_FAILURE (Status)) |
||
744 | { |
||
745 | AcpiOsPrintf ("Could not obtain _PRT: %s\n", |
||
746 | AcpiFormatException (Status)); |
||
747 | goto GetCrs; |
||
748 | } |
||
749 | |||
750 | ReturnObj.Pointer = AcpiGbl_DbBuffer; |
||
751 | ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; |
||
752 | |||
753 | Status = AcpiGetIrqRoutingTable (Node, &ReturnObj); |
||
754 | if (ACPI_FAILURE (Status)) |
||
755 | { |
||
756 | AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", |
||
757 | AcpiFormatException (Status)); |
||
758 | goto GetCrs; |
||
759 | } |
||
760 | |||
761 | AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer)); |
||
762 | |||
763 | |||
764 | /* _CRS */ |
||
765 | |||
766 | GetCrs: |
||
767 | AcpiOsPrintf ("Evaluating _CRS\n"); |
||
768 | |||
769 | ReturnObj.Pointer = AcpiGbl_DbBuffer; |
||
770 | ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; |
||
771 | |||
772 | /* Check if _CRS exists */ |
||
773 | |||
774 | Status = AcpiEvaluateObject (Node, METHOD_NAME__CRS, NULL, &ReturnObj); |
||
775 | if (ACPI_FAILURE (Status)) |
||
776 | { |
||
777 | AcpiOsPrintf ("Could not obtain _CRS: %s\n", |
||
778 | AcpiFormatException (Status)); |
||
779 | goto GetPrs; |
||
780 | } |
||
781 | |||
782 | /* Get the _CRS resource list */ |
||
783 | |||
784 | ReturnObj.Pointer = AcpiGbl_DbBuffer; |
||
785 | ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; |
||
786 | |||
787 | Status = AcpiGetCurrentResources (Node, &ReturnObj); |
||
788 | if (ACPI_FAILURE (Status)) |
||
789 | { |
||
790 | AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", |
||
791 | AcpiFormatException (Status)); |
||
792 | goto GetPrs; |
||
793 | } |
||
794 | |||
795 | /* Dump the _CRS resource list */ |
||
796 | |||
797 | AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, |
||
798 | ReturnObj.Pointer)); |
||
799 | |||
800 | /* |
||
801 | * Perform comparison of original AML to newly created AML. This tests both |
||
802 | * the AML->Resource conversion and the Resource->Aml conversion. |
||
803 | */ |
||
804 | Status = AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS); |
||
805 | |||
806 | /* Execute _SRS with the resource list */ |
||
807 | |||
808 | Status = AcpiSetCurrentResources (Node, &ReturnObj); |
||
809 | if (ACPI_FAILURE (Status)) |
||
810 | { |
||
811 | AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", |
||
812 | AcpiFormatException (Status)); |
||
813 | goto GetPrs; |
||
814 | } |
||
815 | |||
816 | |||
817 | /* _PRS */ |
||
818 | |||
819 | GetPrs: |
||
820 | AcpiOsPrintf ("Evaluating _PRS\n"); |
||
821 | |||
822 | ReturnObj.Pointer = AcpiGbl_DbBuffer; |
||
823 | ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; |
||
824 | |||
825 | /* Check if _PRS exists */ |
||
826 | |||
827 | Status = AcpiEvaluateObject (Node, METHOD_NAME__PRS, NULL, &ReturnObj); |
||
828 | if (ACPI_FAILURE (Status)) |
||
829 | { |
||
830 | AcpiOsPrintf ("Could not obtain _PRS: %s\n", |
||
831 | AcpiFormatException (Status)); |
||
832 | goto Cleanup; |
||
833 | } |
||
834 | |||
835 | ReturnObj.Pointer = AcpiGbl_DbBuffer; |
||
836 | ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; |
||
837 | |||
838 | Status = AcpiGetPossibleResources (Node, &ReturnObj); |
||
839 | if (ACPI_FAILURE (Status)) |
||
840 | { |
||
841 | AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", |
||
842 | AcpiFormatException (Status)); |
||
843 | goto Cleanup; |
||
844 | } |
||
845 | |||
846 | AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); |
||
847 | |||
848 | Cleanup: |
||
849 | |||
850 | AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); |
||
851 | return; |
||
852 | } |
||
853 | |||
854 | |||
855 | /******************************************************************************* |
||
856 | * |
||
857 | * FUNCTION: AcpiDbGenerateGpe |
||
858 | * |
||
859 | * PARAMETERS: GpeArg - Raw GPE number, ascii string |
||
860 | * BlockArg - GPE block number, ascii string |
||
861 | * 0 or 1 for FADT GPE blocks |
||
862 | * |
||
863 | * RETURN: None |
||
864 | * |
||
865 | * DESCRIPTION: Generate a GPE |
||
866 | * |
||
867 | ******************************************************************************/ |
||
868 | |||
869 | void |
||
870 | AcpiDbGenerateGpe ( |
||
871 | char *GpeArg, |
||
872 | char *BlockArg) |
||
873 | { |
||
874 | UINT32 BlockNumber; |
||
875 | UINT32 GpeNumber; |
||
876 | ACPI_GPE_EVENT_INFO *GpeEventInfo; |
||
877 | |||
878 | |||
879 | GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0); |
||
880 | BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0); |
||
881 | |||
882 | |||
883 | GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber), |
||
884 | GpeNumber); |
||
885 | if (!GpeEventInfo) |
||
886 | { |
||
887 | AcpiOsPrintf ("Invalid GPE\n"); |
||
888 | return; |
||
889 | } |
||
890 | |||
2216 | Serge | 891 | (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber); |
1498 | serge | 892 | } |
893 | |||
894 | #endif /* ACPI_DEBUGGER */>>>>=> |