xref: /netbsd-src/sys/external/bsd/acpica/dist/debugger/dbcmds.c (revision daf6c4152fcddc27c445489775ed1f66ab4ea9a9)
1 /*******************************************************************************
2  *
3  * Module Name: dbcmds - Miscellaneous debug commands and output routines
4  *
5  ******************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2011, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43 
44 
45 #include "acpi.h"
46 #include "accommon.h"
47 #include "acevents.h"
48 #include "acdebug.h"
49 #include "acresrc.h"
50 #include "actables.h"
51 
52 #ifdef ACPI_DEBUGGER
53 
54 #define _COMPONENT          ACPI_CA_DEBUGGER
55         ACPI_MODULE_NAME    ("dbcmds")
56 
57 
58 /* Local prototypes */
59 
60 static void
61 AcpiDmCompareAmlResources (
62     UINT8                   *Aml1Buffer,
63     ACPI_RSDESC_SIZE        Aml1BufferLength,
64     UINT8                   *Aml2Buffer,
65     ACPI_RSDESC_SIZE        Aml2BufferLength);
66 
67 static ACPI_STATUS
68 AcpiDmTestResourceConversion (
69     ACPI_NAMESPACE_NODE     *Node,
70     char                    *Name);
71 
72 
73 /*******************************************************************************
74  *
75  * FUNCTION:    AcpiDbConvertToNode
76  *
77  * PARAMETERS:  InString        - String to convert
78  *
79  * RETURN:      Pointer to a NS node
80  *
81  * DESCRIPTION: Convert a string to a valid NS pointer.  Handles numeric or
82  *              alpha strings.
83  *
84  ******************************************************************************/
85 
86 ACPI_NAMESPACE_NODE *
87 AcpiDbConvertToNode (
88     char                    *InString)
89 {
90     ACPI_NAMESPACE_NODE     *Node;
91 
92 
93     if ((*InString >= 0x30) && (*InString <= 0x39))
94     {
95         /* Numeric argument, convert */
96 
97         Node = ACPI_TO_POINTER (ACPI_STRTOUL (InString, NULL, 16));
98         if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
99         {
100             AcpiOsPrintf ("Address %p is invalid in this address space\n",
101                 Node);
102             return (NULL);
103         }
104 
105         /* Make sure pointer is valid NS node */
106 
107         if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
108         {
109             AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n",
110                     Node, AcpiUtGetDescriptorName (Node));
111             return (NULL);
112         }
113     }
114     else
115     {
116         /* Alpha argument */
117         /* The parameter is a name string that must be resolved to a
118          * Named obj
119          */
120         Node = AcpiDbLocalNsLookup (InString);
121         if (!Node)
122         {
123             Node = AcpiGbl_RootNode;
124         }
125     }
126 
127     return (Node);
128 }
129 
130 
131 /*******************************************************************************
132  *
133  * FUNCTION:    AcpiDbSleep
134  *
135  * PARAMETERS:  ObjectArg       - Desired sleep state (0-5)
136  *
137  * RETURN:      Status
138  *
139  * DESCRIPTION: Simulate a sleep/wake sequence
140  *
141  ******************************************************************************/
142 
143 ACPI_STATUS
144 AcpiDbSleep (
145     char                    *ObjectArg)
146 {
147     ACPI_STATUS             Status;
148     UINT8                   SleepState;
149 
150 
151     SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
152 
153     AcpiOsPrintf ("**** Prepare to sleep ****\n");
154     Status = AcpiEnterSleepStatePrep (SleepState);
155     if (ACPI_FAILURE (Status))
156     {
157         return (Status);
158     }
159 
160     AcpiOsPrintf ("**** Going to sleep ****\n");
161     Status = AcpiEnterSleepState (SleepState);
162     if (ACPI_FAILURE (Status))
163     {
164         return (Status);
165     }
166 
167     AcpiOsPrintf ("**** returning from sleep ****\n");
168     Status = AcpiLeaveSleepState (SleepState);
169 
170     return (Status);
171 }
172 
173 /*******************************************************************************
174  *
175  * FUNCTION:    AcpiDbDisplayLocks
176  *
177  * PARAMETERS:  None
178  *
179  * RETURN:      None
180  *
181  * DESCRIPTION: Display information about internal mutexes.
182  *
183  ******************************************************************************/
184 
185 void
186 AcpiDbDisplayLocks (
187     void)
188 {
189     UINT32                  i;
190 
191 
192     for (i = 0; i < ACPI_MAX_MUTEX; i++)
193     {
194         AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
195             AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
196                 ? "Locked" : "Unlocked");
197     }
198 }
199 
200 
201 /*******************************************************************************
202  *
203  * FUNCTION:    AcpiDbDisplayTableInfo
204  *
205  * PARAMETERS:  TableArg        - String with name of table to be displayed
206  *
207  * RETURN:      None
208  *
209  * DESCRIPTION: Display information about loaded tables.  Current
210  *              implementation displays all loaded tables.
211  *
212  ******************************************************************************/
213 
214 void
215 AcpiDbDisplayTableInfo (
216     char                    *TableArg)
217 {
218     UINT32                  i;
219     ACPI_TABLE_DESC         *TableDesc;
220     ACPI_STATUS             Status;
221 
222 
223     /* Walk the entire root table list */
224 
225     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
226     {
227         TableDesc = &AcpiGbl_RootTableList.Tables[i];
228         AcpiOsPrintf ("%u ", i);
229 
230         /* Make sure that the table is mapped */
231 
232         Status = AcpiTbVerifyTable (TableDesc);
233         if (ACPI_FAILURE (Status))
234         {
235             return;
236         }
237 
238         /* Dump the table header */
239 
240         if (TableDesc->Pointer)
241         {
242             AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
243         }
244         else
245         {
246             /* If the pointer is null, the table has been unloaded */
247 
248             ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded",
249                 TableDesc->Signature.Ascii));
250         }
251     }
252 }
253 
254 
255 /*******************************************************************************
256  *
257  * FUNCTION:    AcpiDbUnloadAcpiTable
258  *
259  * PARAMETERS:  TableArg        - Name of the table to be unloaded
260  *              InstanceArg     - Which instance of the table to unload (if
261  *                                there are multiple tables of the same type)
262  *
263  * RETURN:      Nonde
264  *
265  * DESCRIPTION: Unload an ACPI table.
266  *              Instance is not implemented
267  *
268  ******************************************************************************/
269 
270 void
271 AcpiDbUnloadAcpiTable (
272     char                    *TableArg,
273     char                    *InstanceArg)
274 {
275 /* TBD: Need to reimplement for new data structures */
276 
277 #if 0
278     UINT32                  i;
279     ACPI_STATUS             Status;
280 
281 
282     /* Search all tables for the target type */
283 
284     for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++)
285     {
286         if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature,
287                 AcpiGbl_TableData[i].SigLength))
288         {
289             /* Found the table, unload it */
290 
291             Status = AcpiUnloadTable (i);
292             if (ACPI_SUCCESS (Status))
293             {
294                 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
295             }
296             else
297             {
298                 AcpiOsPrintf ("%s, while unloading [%s]\n",
299                     AcpiFormatException (Status), TableArg);
300             }
301 
302             return;
303         }
304     }
305 
306     AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
307 #endif
308 }
309 
310 
311 /*******************************************************************************
312  *
313  * FUNCTION:    AcpiDbSendNotify
314  *
315  * PARAMETERS:  Name            - Name of ACPI object to send the notify to
316  *              Value           - Value of the notify to send.
317  *
318  * RETURN:      None
319  *
320  * DESCRIPTION: Send an ACPI notification.  The value specified is sent to the
321  *              named object as an ACPI notify.
322  *
323  ******************************************************************************/
324 
325 void
326 AcpiDbSendNotify (
327     char                    *Name,
328     UINT32                  Value)
329 {
330     ACPI_NAMESPACE_NODE     *Node;
331     ACPI_STATUS             Status;
332 
333 
334     /* Translate name to an Named object */
335 
336     Node = AcpiDbConvertToNode (Name);
337     if (!Node)
338     {
339         return;
340     }
341 
342     /* Decode Named object type */
343 
344     switch (Node->Type)
345     {
346     case ACPI_TYPE_DEVICE:
347     case ACPI_TYPE_THERMAL:
348 
349          /* Send the notify */
350 
351         Status = AcpiEvQueueNotifyRequest (Node, Value);
352         if (ACPI_FAILURE (Status))
353         {
354             AcpiOsPrintf ("Could not queue notify\n");
355         }
356         break;
357 
358     default:
359         AcpiOsPrintf ("Named object is not a device or a thermal object\n");
360         break;
361     }
362 }
363 
364 
365 /*******************************************************************************
366  *
367  * FUNCTION:    AcpiDbDisplayInterfaces
368  *
369  * PARAMETERS:  ActionArg           - Null, "install", or "remove"
370  *              InterfaceNameArg    - Name for install/remove options
371  *
372  * RETURN:      None
373  *
374  * DESCRIPTION: Display or modify the global _OSI interface list
375  *
376  ******************************************************************************/
377 
378 void
379 AcpiDbDisplayInterfaces (
380     char                    *ActionArg,
381     char                    *InterfaceNameArg)
382 {
383     ACPI_INTERFACE_INFO     *NextInterface;
384     char                    *SubString;
385     ACPI_STATUS             Status;
386 
387 
388     /* If no arguments, just display current interface list */
389 
390     if (!ActionArg)
391     {
392         (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex,
393                     ACPI_WAIT_FOREVER);
394 
395         NextInterface = AcpiGbl_SupportedInterfaces;
396 
397         while (NextInterface)
398         {
399             if (!(NextInterface->Flags & ACPI_OSI_INVALID))
400             {
401                 AcpiOsPrintf ("%s\n", NextInterface->Name);
402             }
403             NextInterface = NextInterface->Next;
404         }
405 
406         AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
407         return;
408     }
409 
410     /* If ActionArg exists, so must InterfaceNameArg */
411 
412     if (!InterfaceNameArg)
413     {
414         AcpiOsPrintf ("Missing Interface Name argument\n");
415         return;
416     }
417 
418     /* Uppercase the action for match below */
419 
420     AcpiUtStrupr (ActionArg);
421 
422     /* Install - install an interface */
423 
424     SubString = ACPI_STRSTR ("INSTALL", ActionArg);
425     if (SubString)
426     {
427         Status = AcpiInstallInterface (InterfaceNameArg);
428         if (ACPI_FAILURE (Status))
429         {
430             AcpiOsPrintf ("%s, while installing \"%s\"\n",
431                 AcpiFormatException (Status), InterfaceNameArg);
432         }
433         return;
434     }
435 
436     /* Remove - remove an interface */
437 
438     SubString = ACPI_STRSTR ("REMOVE", ActionArg);
439     if (SubString)
440     {
441         Status = AcpiRemoveInterface (InterfaceNameArg);
442         if (ACPI_FAILURE (Status))
443         {
444             AcpiOsPrintf ("%s, while removing \"%s\"\n",
445                 AcpiFormatException (Status), InterfaceNameArg);
446         }
447         return;
448     }
449 
450     /* Invalid ActionArg */
451 
452     AcpiOsPrintf ("Invalid action argument: %s\n", ActionArg);
453     return;
454 }
455 
456 
457 /*******************************************************************************
458  *
459  * FUNCTION:    AcpiDmCompareAmlResources
460  *
461  * PARAMETERS:  Aml1Buffer          - Contains first resource list
462  *              Aml1BufferLength    - Length of first resource list
463  *              Aml2Buffer          - Contains second resource list
464  *              Aml2BufferLength    - Length of second resource list
465  *
466  * RETURN:      None
467  *
468  * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
469  *              order to isolate a miscompare to an individual resource)
470  *
471  ******************************************************************************/
472 
473 static void
474 AcpiDmCompareAmlResources (
475     UINT8                   *Aml1Buffer,
476     ACPI_RSDESC_SIZE        Aml1BufferLength,
477     UINT8                   *Aml2Buffer,
478     ACPI_RSDESC_SIZE        Aml2BufferLength)
479 {
480     UINT8                   *Aml1;
481     UINT8                   *Aml2;
482     ACPI_RSDESC_SIZE        Aml1Length;
483     ACPI_RSDESC_SIZE        Aml2Length;
484     ACPI_RSDESC_SIZE        Offset = 0;
485     UINT8                   ResourceType;
486     UINT32                  Count = 0;
487 
488 
489     /* Compare overall buffer sizes (may be different due to size rounding) */
490 
491     if (Aml1BufferLength != Aml2BufferLength)
492     {
493         AcpiOsPrintf (
494             "**** Buffer length mismatch in converted AML: original %X new %X ****\n",
495             Aml1BufferLength, Aml2BufferLength);
496     }
497 
498     Aml1 = Aml1Buffer;
499     Aml2 = Aml2Buffer;
500 
501     /* Walk the descriptor lists, comparing each descriptor */
502 
503     while (Aml1 < (Aml1Buffer + Aml1BufferLength))
504     {
505         /* Get the lengths of each descriptor */
506 
507         Aml1Length = AcpiUtGetDescriptorLength (Aml1);
508         Aml2Length = AcpiUtGetDescriptorLength (Aml2);
509         ResourceType = AcpiUtGetResourceType (Aml1);
510 
511         /* Check for descriptor length match */
512 
513         if (Aml1Length != Aml2Length)
514         {
515             AcpiOsPrintf (
516                 "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X L1 %X L2 %X ****\n",
517                 Count, ResourceType, Offset, Aml1Length, Aml2Length);
518         }
519 
520         /* Check for descriptor byte match */
521 
522         else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length))
523         {
524             AcpiOsPrintf (
525                 "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n",
526                 Count, ResourceType, Offset);
527         }
528 
529         /* Exit on EndTag descriptor */
530 
531         if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
532         {
533             return;
534         }
535 
536         /* Point to next descriptor in each buffer */
537 
538         Count++;
539         Offset += Aml1Length;
540         Aml1 += Aml1Length;
541         Aml2 += Aml2Length;
542     }
543 }
544 
545 
546 /*******************************************************************************
547  *
548  * FUNCTION:    AcpiDmTestResourceConversion
549  *
550  * PARAMETERS:  Node            - Parent device node
551  *              Name            - resource method name (_CRS)
552  *
553  * RETURN:      Status
554  *
555  * DESCRIPTION: Compare the original AML with a conversion of the AML to
556  *              internal resource list, then back to AML.
557  *
558  ******************************************************************************/
559 
560 static ACPI_STATUS
561 AcpiDmTestResourceConversion (
562     ACPI_NAMESPACE_NODE     *Node,
563     char                    *Name)
564 {
565     ACPI_STATUS             Status;
566     ACPI_BUFFER             ReturnObj;
567     ACPI_BUFFER             ResourceObj;
568     ACPI_BUFFER             NewAml;
569     ACPI_OBJECT             *OriginalAml;
570 
571 
572     AcpiOsPrintf ("Resource Conversion Comparison:\n");
573 
574     NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
575     ReturnObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
576     ResourceObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
577 
578     /* Get the original _CRS AML resource template */
579 
580     Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnObj);
581     if (ACPI_FAILURE (Status))
582     {
583         AcpiOsPrintf ("Could not obtain %s: %s\n",
584             Name, AcpiFormatException (Status));
585         return (Status);
586     }
587 
588     /* Get the AML resource template, converted to internal resource structs */
589 
590     Status = AcpiGetCurrentResources (Node, &ResourceObj);
591     if (ACPI_FAILURE (Status))
592     {
593         AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
594             AcpiFormatException (Status));
595         goto Exit1;
596     }
597 
598     /* Convert internal resource list to external AML resource template */
599 
600     Status = AcpiRsCreateAmlResources (ResourceObj.Pointer, &NewAml);
601     if (ACPI_FAILURE (Status))
602     {
603         AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
604             AcpiFormatException (Status));
605         goto Exit2;
606     }
607 
608     /* Compare original AML to the newly created AML resource list */
609 
610     OriginalAml = ReturnObj.Pointer;
611 
612     AcpiDmCompareAmlResources (
613         OriginalAml->Buffer.Pointer, (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length,
614         NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length);
615 
616     /* Cleanup and exit */
617 
618     ACPI_FREE (NewAml.Pointer);
619 Exit2:
620     ACPI_FREE (ResourceObj.Pointer);
621 Exit1:
622     ACPI_FREE (ReturnObj.Pointer);
623     return (Status);
624 }
625 
626 
627 /*******************************************************************************
628  *
629  * FUNCTION:    AcpiDbDisplayResources
630  *
631  * PARAMETERS:  ObjectArg       - String with hex value of the object
632  *
633  * RETURN:      None
634  *
635  * DESCRIPTION: Display the resource objects associated with a device.
636  *
637  ******************************************************************************/
638 
639 void
640 AcpiDbDisplayResources (
641     char                    *ObjectArg)
642 {
643     ACPI_NAMESPACE_NODE     *Node;
644     ACPI_STATUS             Status;
645     ACPI_BUFFER             ReturnObj;
646 
647 
648     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
649     AcpiDbgLevel |= ACPI_LV_RESOURCES;
650 
651     /* Convert string to object pointer */
652 
653     Node = AcpiDbConvertToNode (ObjectArg);
654     if (!Node)
655     {
656         return;
657     }
658 
659     /* Prepare for a return object of arbitrary size */
660 
661     ReturnObj.Pointer = AcpiGbl_DbBuffer;
662     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
663 
664     /* _PRT */
665 
666     AcpiOsPrintf ("Evaluating _PRT\n");
667 
668     /* Check if _PRT exists */
669 
670     Status = AcpiEvaluateObject (Node, METHOD_NAME__PRT, NULL, &ReturnObj);
671     if (ACPI_FAILURE (Status))
672     {
673         AcpiOsPrintf ("Could not obtain _PRT: %s\n",
674             AcpiFormatException (Status));
675         goto GetCrs;
676     }
677 
678     ReturnObj.Pointer = AcpiGbl_DbBuffer;
679     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
680 
681     Status = AcpiGetIrqRoutingTable (Node, &ReturnObj);
682     if (ACPI_FAILURE (Status))
683     {
684         AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
685             AcpiFormatException (Status));
686         goto GetCrs;
687     }
688 
689     AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
690 
691 
692     /* _CRS */
693 
694 GetCrs:
695     AcpiOsPrintf ("Evaluating _CRS\n");
696 
697     ReturnObj.Pointer = AcpiGbl_DbBuffer;
698     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
699 
700     /* Check if _CRS exists */
701 
702     Status = AcpiEvaluateObject (Node, METHOD_NAME__CRS, NULL, &ReturnObj);
703     if (ACPI_FAILURE (Status))
704     {
705         AcpiOsPrintf ("Could not obtain _CRS: %s\n",
706             AcpiFormatException (Status));
707         goto GetPrs;
708     }
709 
710     /* Get the _CRS resource list */
711 
712     ReturnObj.Pointer = AcpiGbl_DbBuffer;
713     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
714 
715     Status = AcpiGetCurrentResources (Node, &ReturnObj);
716     if (ACPI_FAILURE (Status))
717     {
718         AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
719             AcpiFormatException (Status));
720         goto GetPrs;
721     }
722 
723     /* Dump the _CRS resource list */
724 
725     AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
726         ReturnObj.Pointer));
727 
728     /*
729      * Perform comparison of original AML to newly created AML. This tests both
730      * the AML->Resource conversion and the Resource->Aml conversion.
731      */
732     Status = AcpiDmTestResourceConversion (Node, __UNCONST(METHOD_NAME__CRS));
733 
734     /* Execute _SRS with the resource list */
735 
736     Status = AcpiSetCurrentResources (Node, &ReturnObj);
737     if (ACPI_FAILURE (Status))
738     {
739         AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
740             AcpiFormatException (Status));
741         goto GetPrs;
742     }
743 
744 
745     /* _PRS */
746 
747 GetPrs:
748     AcpiOsPrintf ("Evaluating _PRS\n");
749 
750     ReturnObj.Pointer = AcpiGbl_DbBuffer;
751     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
752 
753     /* Check if _PRS exists */
754 
755     Status = AcpiEvaluateObject (Node, METHOD_NAME__PRS, NULL, &ReturnObj);
756     if (ACPI_FAILURE (Status))
757     {
758         AcpiOsPrintf ("Could not obtain _PRS: %s\n",
759             AcpiFormatException (Status));
760         goto Cleanup;
761     }
762 
763     ReturnObj.Pointer = AcpiGbl_DbBuffer;
764     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
765 
766     Status = AcpiGetPossibleResources (Node, &ReturnObj);
767     if (ACPI_FAILURE (Status))
768     {
769         AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
770             AcpiFormatException (Status));
771         goto Cleanup;
772     }
773 
774     AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
775 
776 Cleanup:
777 
778     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
779     return;
780 }
781 
782 
783 /*******************************************************************************
784  *
785  * FUNCTION:    AcpiDbGenerateGpe
786  *
787  * PARAMETERS:  GpeArg          - Raw GPE number, ascii string
788  *              BlockArg        - GPE block number, ascii string
789  *                                0 or 1 for FADT GPE blocks
790  *
791  * RETURN:      None
792  *
793  * DESCRIPTION: Generate a GPE
794  *
795  ******************************************************************************/
796 
797 void
798 AcpiDbGenerateGpe (
799     char                    *GpeArg,
800     char                    *BlockArg)
801 {
802     UINT32                  BlockNumber;
803     UINT32                  GpeNumber;
804     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
805 
806 
807     GpeNumber   = ACPI_STRTOUL (GpeArg, NULL, 0);
808     BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0);
809 
810 
811     GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber),
812         GpeNumber);
813     if (!GpeEventInfo)
814     {
815         AcpiOsPrintf ("Invalid GPE\n");
816         return;
817     }
818 
819     (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber);
820 }
821 
822 #endif /* ACPI_DEBUGGER */
823