1 /****************************************************************************** 2 * 3 * Module Name: ahdecode - Operator/Opcode decoding for acpihelp utility 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2015, 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 #define ACPI_CREATE_PREDEFINED_TABLE 45 #define ACPI_CREATE_RESOURCE_TABLE 46 47 #include "acpihelp.h" 48 #include "acpredef.h" 49 50 51 #define AH_DISPLAY_EXCEPTION(Status, Name) \ 52 printf ("%.4X: %s\n", Status, Name) 53 54 #define AH_DISPLAY_EXCEPTION_TEXT(Status, Exception) \ 55 printf ("%.4X: %-28s (%s)\n", Status, Exception->Name, Exception->Description) 56 57 #define BUFFER_LENGTH 128 58 #define LINE_BUFFER_LENGTH 512 59 60 static char Gbl_Buffer[BUFFER_LENGTH]; 61 static char Gbl_LineBuffer[LINE_BUFFER_LENGTH]; 62 63 64 /* Local prototypes */ 65 66 static BOOLEAN 67 AhDisplayPredefinedName ( 68 char *Name, 69 UINT32 Length); 70 71 static void 72 AhDisplayPredefinedInfo ( 73 char *Name); 74 75 static void 76 AhDisplayResourceName ( 77 const ACPI_PREDEFINED_INFO *ThisName); 78 79 static void 80 AhDisplayAmlOpcode ( 81 const AH_AML_OPCODE *Op); 82 83 static void 84 AhDisplayAslOperator ( 85 const AH_ASL_OPERATOR *Op); 86 87 static void 88 AhDisplayOperatorKeywords ( 89 const AH_ASL_OPERATOR *Op); 90 91 static void 92 AhDisplayAslKeyword ( 93 const AH_ASL_KEYWORD *Op); 94 95 static void 96 AhPrintOneField ( 97 UINT32 Indent, 98 UINT32 CurrentPosition, 99 UINT32 MaxPosition, 100 const char *Field); 101 102 103 void 104 AhDisplayDirectives ( 105 void) 106 { 107 const AH_DIRECTIVE_INFO *Info; 108 109 110 printf ("iASL Preprocessor directives:\n\n"); 111 112 for (Info = PreprocessorDirectives; Info->Name; Info++) 113 { 114 printf ("%16s : %s\n", Info->Name, Info->Operands); 115 } 116 } 117 118 119 /******************************************************************************* 120 * 121 * FUNCTION: AhFindPredefinedNames (entry point for predefined name search) 122 * 123 * PARAMETERS: NamePrefix - Name or prefix to find. Must start with 124 * an underscore. NULL means "find all" 125 * 126 * RETURN: None 127 * 128 * DESCRIPTION: Find and display all ACPI predefined names that match the 129 * input name or prefix. Includes the required number of arguments 130 * and the expected return type, if any. 131 * 132 ******************************************************************************/ 133 134 void 135 AhFindPredefinedNames ( 136 char *NamePrefix) 137 { 138 UINT32 Length; 139 BOOLEAN Found; 140 char Name[9]; 141 142 143 if (!NamePrefix) 144 { 145 Found = AhDisplayPredefinedName (NULL, 0); 146 return; 147 } 148 149 /* Contruct a local name or name prefix */ 150 151 AhStrupr (NamePrefix); 152 if (*NamePrefix == '_') 153 { 154 NamePrefix++; 155 } 156 157 Name[0] = '_'; 158 strncpy (&Name[1], NamePrefix, 7); 159 160 Length = strlen (Name); 161 if (Length > 4) 162 { 163 printf ("%.8s: Predefined name must be 4 characters maximum\n", Name); 164 return; 165 } 166 167 Found = AhDisplayPredefinedName (Name, Length); 168 if (!Found) 169 { 170 printf ("%s, no matching predefined names\n", Name); 171 } 172 } 173 174 175 /******************************************************************************* 176 * 177 * FUNCTION: AhDisplayPredefinedName 178 * 179 * PARAMETERS: Name - Name or name prefix 180 * 181 * RETURN: TRUE if any names matched, FALSE otherwise 182 * 183 * DESCRIPTION: Display information about ACPI predefined names that match 184 * the input name or name prefix. 185 * 186 ******************************************************************************/ 187 188 static BOOLEAN 189 AhDisplayPredefinedName ( 190 char *Name, 191 UINT32 Length) 192 { 193 const AH_PREDEFINED_NAME *Info; 194 BOOLEAN Found = FALSE; 195 BOOLEAN Matched; 196 UINT32 i = 0; 197 198 199 /* Find/display all names that match the input name prefix */ 200 201 for (Info = AslPredefinedInfo; Info->Name; Info++) 202 { 203 if (!Name) 204 { 205 Found = TRUE; 206 printf ("%s: <%s>\n", Info->Name, Info->Description); 207 printf ("%*s%s\n", 6, " ", Info->Action); 208 209 AhDisplayPredefinedInfo (Info->Name); 210 i++; 211 continue; 212 } 213 214 Matched = TRUE; 215 for (i = 0; i < Length; i++) 216 { 217 if (Info->Name[i] != Name[i]) 218 { 219 Matched = FALSE; 220 break; 221 } 222 } 223 224 if (Matched) 225 { 226 Found = TRUE; 227 printf ("%s: <%s>\n", Info->Name, Info->Description); 228 printf ("%*s%s\n", 6, " ", Info->Action); 229 230 AhDisplayPredefinedInfo (Info->Name); 231 } 232 } 233 234 if (!Name) 235 { 236 printf ("\nFound %d Predefined ACPI Names\n", i); 237 } 238 return (Found); 239 } 240 241 242 /******************************************************************************* 243 * 244 * FUNCTION: AhDisplayPredefinedInfo 245 * 246 * PARAMETERS: Name - Exact 4-character ACPI name. 247 * 248 * RETURN: None 249 * 250 * DESCRIPTION: Find the name in the main ACPICA predefined info table and 251 * display the # of arguments and the return value type. 252 * 253 * Note: Resource Descriptor field names do not appear in this 254 * table -- thus, nothing will be displayed for them. 255 * 256 ******************************************************************************/ 257 258 static void 259 AhDisplayPredefinedInfo ( 260 char *Name) 261 { 262 const ACPI_PREDEFINED_INFO *ThisName; 263 264 265 /* NOTE: we check both tables always because there are some dupes */ 266 267 /* Check against the predefine methods first */ 268 269 ThisName = AcpiUtMatchPredefinedMethod (Name); 270 if (ThisName) 271 { 272 AcpiUtDisplayPredefinedMethod (Gbl_Buffer, ThisName, TRUE); 273 } 274 275 /* Check against the predefined resource descriptor names */ 276 277 ThisName = AcpiUtMatchResourceName (Name); 278 if (ThisName) 279 { 280 AhDisplayResourceName (ThisName); 281 } 282 } 283 284 285 /******************************************************************************* 286 * 287 * FUNCTION: AhDisplayResourceName 288 * 289 * PARAMETERS: ThisName - Entry in the predefined method/name table 290 * 291 * RETURN: None 292 * 293 * DESCRIPTION: Display information about a resource descriptor name. 294 * 295 ******************************************************************************/ 296 297 static void 298 AhDisplayResourceName ( 299 const ACPI_PREDEFINED_INFO *ThisName) 300 { 301 UINT32 NumTypes; 302 303 304 NumTypes = AcpiUtGetResourceBitWidth (Gbl_Buffer, 305 ThisName->Info.ArgumentList); 306 307 printf (" %4.4s resource descriptor field is %s bits wide%s\n", 308 ThisName->Info.Name, 309 Gbl_Buffer, 310 (NumTypes > 1) ? " (depending on descriptor type)" : ""); 311 } 312 313 314 /******************************************************************************* 315 * 316 * FUNCTION: AhFindAmlOpcode (entry point for AML opcode name search) 317 * 318 * PARAMETERS: Name - Name or prefix for an AML opcode. 319 * NULL means "find all" 320 * 321 * RETURN: None 322 * 323 * DESCRIPTION: Find all AML opcodes that match the input Name or name 324 * prefix. 325 * 326 ******************************************************************************/ 327 328 void 329 AhFindAmlOpcode ( 330 char *Name) 331 { 332 const AH_AML_OPCODE *Op; 333 BOOLEAN Found = FALSE; 334 335 336 AhStrupr (Name); 337 338 /* Find/display all opcode names that match the input name prefix */ 339 340 for (Op = AmlOpcodeInfo; Op->OpcodeString; Op++) 341 { 342 if (!Op->OpcodeName) /* Unused opcodes */ 343 { 344 continue; 345 } 346 347 if (!Name) 348 { 349 AhDisplayAmlOpcode (Op); 350 Found = TRUE; 351 continue; 352 } 353 354 /* Upper case the opcode name before substring compare */ 355 356 strcpy (Gbl_Buffer, Op->OpcodeName); 357 AhStrupr (Gbl_Buffer); 358 359 if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) 360 { 361 AhDisplayAmlOpcode (Op); 362 Found = TRUE; 363 } 364 } 365 366 if (!Found) 367 { 368 printf ("%s, no matching AML operators\n", Name); 369 } 370 } 371 372 373 /******************************************************************************* 374 * 375 * FUNCTION: AhDecodeAmlOpcode (entry point for AML opcode search) 376 * 377 * PARAMETERS: OpcodeString - String version of AML opcode 378 * 379 * RETURN: None 380 * 381 * DESCRIPTION: Display information about the input AML opcode 382 * 383 ******************************************************************************/ 384 385 void 386 AhDecodeAmlOpcode ( 387 char *OpcodeString) 388 { 389 const AH_AML_OPCODE *Op; 390 UINT32 Opcode; 391 UINT8 Prefix; 392 393 394 if (!OpcodeString) 395 { 396 AhFindAmlOpcode (NULL); 397 return; 398 } 399 400 Opcode = ACPI_STRTOUL (OpcodeString, NULL, 16); 401 if (Opcode > ACPI_UINT16_MAX) 402 { 403 printf ("Invalid opcode (more than 16 bits)\n"); 404 return; 405 } 406 407 /* Only valid opcode extension is 0x5B */ 408 409 Prefix = (Opcode & 0x0000FF00) >> 8; 410 if (Prefix && (Prefix != 0x5B)) 411 { 412 printf ("Invalid opcode (invalid extension prefix 0x%X)\n", 413 Prefix); 414 return; 415 } 416 417 /* Find/Display the opcode. May fall within an opcode range */ 418 419 for (Op = AmlOpcodeInfo; Op->OpcodeString; Op++) 420 { 421 if ((Opcode >= Op->OpcodeRangeStart) && 422 (Opcode <= Op->OpcodeRangeEnd)) 423 { 424 AhDisplayAmlOpcode (Op); 425 } 426 } 427 } 428 429 430 /******************************************************************************* 431 * 432 * FUNCTION: AhDisplayAmlOpcode 433 * 434 * PARAMETERS: Op - An opcode info struct 435 * 436 * RETURN: None 437 * 438 * DESCRIPTION: Display the contents of an AML opcode information struct 439 * 440 ******************************************************************************/ 441 442 static void 443 AhDisplayAmlOpcode ( 444 const AH_AML_OPCODE *Op) 445 { 446 447 if (!Op->OpcodeName) 448 { 449 printf ("%18s: Opcode=%-9s\n", "Reserved opcode", Op->OpcodeString); 450 return; 451 } 452 453 /* Opcode name and value(s) */ 454 455 printf ("%18s: Opcode=%-9s Type (%s)", 456 Op->OpcodeName, Op->OpcodeString, Op->Type); 457 458 /* Optional fixed/static arguments */ 459 460 if (Op->FixedArguments) 461 { 462 printf (" FixedArgs ("); 463 AhPrintOneField (37, 36 + 7 + strlen (Op->Type) + 12, 464 AH_MAX_AML_LINE_LENGTH, Op->FixedArguments); 465 printf (")"); 466 } 467 468 /* Optional variable-length argument list */ 469 470 if (Op->VariableArguments) 471 { 472 if (Op->FixedArguments) 473 { 474 printf ("\n%*s", 36, " "); 475 } 476 printf (" VariableArgs ("); 477 AhPrintOneField (37, 15, AH_MAX_AML_LINE_LENGTH, Op->VariableArguments); 478 printf (")"); 479 } 480 printf ("\n"); 481 482 /* Grammar specification */ 483 484 if (Op->Grammar) 485 { 486 AhPrintOneField (37, 0, AH_MAX_AML_LINE_LENGTH, Op->Grammar); 487 printf ("\n"); 488 } 489 } 490 491 492 /******************************************************************************* 493 * 494 * FUNCTION: AhFindAslKeywords (entry point for ASL keyword search) 495 * 496 * PARAMETERS: Name - Name or prefix for an ASL keyword. 497 * NULL means "find all" 498 * 499 * RETURN: None 500 * 501 * DESCRIPTION: Find all ASL keywords that match the input Name or name 502 * prefix. 503 * 504 ******************************************************************************/ 505 506 void 507 AhFindAslKeywords ( 508 char *Name) 509 { 510 const AH_ASL_KEYWORD *Keyword; 511 BOOLEAN Found = FALSE; 512 513 514 AhStrupr (Name); 515 516 for (Keyword = AslKeywordInfo; Keyword->Name; Keyword++) 517 { 518 if (!Name) 519 { 520 AhDisplayAslKeyword (Keyword); 521 Found = TRUE; 522 continue; 523 } 524 525 /* Upper case the operator name before substring compare */ 526 527 strcpy (Gbl_Buffer, Keyword->Name); 528 AhStrupr (Gbl_Buffer); 529 530 if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) 531 { 532 AhDisplayAslKeyword (Keyword); 533 Found = TRUE; 534 } 535 } 536 537 if (!Found) 538 { 539 printf ("%s, no matching ASL keywords\n", Name); 540 } 541 } 542 543 544 /******************************************************************************* 545 * 546 * FUNCTION: AhDisplayAslKeyword 547 * 548 * PARAMETERS: Op - Pointer to ASL keyword with syntax info 549 * 550 * RETURN: None 551 * 552 * DESCRIPTION: Format and display syntax info for an ASL keyword. Splits 553 * long lines appropriately for reading. 554 * 555 ******************************************************************************/ 556 557 static void 558 AhDisplayAslKeyword ( 559 const AH_ASL_KEYWORD *Op) 560 { 561 562 /* ASL keyword name and description */ 563 564 printf ("%22s: %s\n", Op->Name, Op->Description); 565 if (!Op->KeywordList) 566 { 567 return; 568 } 569 570 /* List of actual keywords */ 571 572 AhPrintOneField (24, 0, AH_MAX_ASL_LINE_LENGTH, Op->KeywordList); 573 printf ("\n"); 574 } 575 576 577 /******************************************************************************* 578 * 579 * FUNCTION: AhFindAslAndAmlOperators 580 * 581 * PARAMETERS: Name - Name or prefix for an ASL operator. 582 * NULL means "find all" 583 * 584 * RETURN: None 585 * 586 * DESCRIPTION: Find all ASL operators that match the input Name or name 587 * prefix. Also displays the AML information if only one entry 588 * matches. 589 * 590 ******************************************************************************/ 591 592 void 593 AhFindAslAndAmlOperators ( 594 char *Name) 595 { 596 UINT32 MatchCount; 597 598 599 MatchCount = AhFindAslOperators (Name); 600 if (MatchCount == 1) 601 { 602 AhFindAmlOpcode (Name); 603 } 604 } 605 606 607 /******************************************************************************* 608 * 609 * FUNCTION: AhFindAslOperators (entry point for ASL operator search) 610 * 611 * PARAMETERS: Name - Name or prefix for an ASL operator. 612 * NULL means "find all" 613 * 614 * RETURN: Number of operators that matched the name prefix. 615 * 616 * DESCRIPTION: Find all ASL operators that match the input Name or name 617 * prefix. 618 * 619 ******************************************************************************/ 620 621 UINT32 622 AhFindAslOperators ( 623 char *Name) 624 { 625 const AH_ASL_OPERATOR *Operator; 626 BOOLEAN MatchCount = 0; 627 628 629 AhStrupr (Name); 630 631 /* Find/display all names that match the input name prefix */ 632 633 for (Operator = AslOperatorInfo; Operator->Name; Operator++) 634 { 635 if (!Name) 636 { 637 AhDisplayAslOperator (Operator); 638 MatchCount++; 639 continue; 640 } 641 642 /* Upper case the operator name before substring compare */ 643 644 strcpy (Gbl_Buffer, Operator->Name); 645 AhStrupr (Gbl_Buffer); 646 647 if (strstr (Gbl_Buffer, Name) == Gbl_Buffer) 648 { 649 AhDisplayAslOperator (Operator); 650 MatchCount++; 651 } 652 } 653 654 if (!MatchCount) 655 { 656 printf ("%s, no matching ASL operators\n", Name); 657 } 658 659 return (MatchCount); 660 } 661 662 663 /******************************************************************************* 664 * 665 * FUNCTION: AhDisplayAslOperator 666 * 667 * PARAMETERS: Op - Pointer to ASL operator with syntax info 668 * 669 * RETURN: None 670 * 671 * DESCRIPTION: Format and display syntax info for an ASL operator. Splits 672 * long lines appropriately for reading. 673 * 674 ******************************************************************************/ 675 676 static void 677 AhDisplayAslOperator ( 678 const AH_ASL_OPERATOR *Op) 679 { 680 681 /* ASL operator name and description */ 682 683 printf ("%16s: %s\n", Op->Name, Op->Description); 684 if (!Op->Syntax) 685 { 686 return; 687 } 688 689 /* Syntax for the operator */ 690 691 AhPrintOneField (18, 0, AH_MAX_ASL_LINE_LENGTH, Op->Syntax); 692 printf ("\n"); 693 694 AhDisplayOperatorKeywords (Op); 695 printf ("\n"); 696 } 697 698 699 /******************************************************************************* 700 * 701 * FUNCTION: AhDisplayOperatorKeywords 702 * 703 * PARAMETERS: Op - Pointer to ASL keyword with syntax info 704 * 705 * RETURN: None 706 * 707 * DESCRIPTION: Display any/all keywords that are associated with the ASL 708 * operator. 709 * 710 ******************************************************************************/ 711 712 static void 713 AhDisplayOperatorKeywords ( 714 const AH_ASL_OPERATOR *Op) 715 { 716 char *Token; 717 char *Separators = "(){}, "; 718 BOOLEAN FirstKeyword = TRUE; 719 720 721 if (!Op || !Op->Syntax) 722 { 723 return; 724 } 725 726 /* 727 * Find all parameters that have the word "keyword" within, and then 728 * display the info about that keyword 729 */ 730 strcpy (Gbl_LineBuffer, Op->Syntax); 731 Token = strtok (Gbl_LineBuffer, Separators); 732 while (Token) 733 { 734 if (strstr (Token, "Keyword")) 735 { 736 if (FirstKeyword) 737 { 738 printf ("\n"); 739 FirstKeyword = FALSE; 740 } 741 742 /* Found a keyword, display keyword information */ 743 744 AhFindAslKeywords (Token); 745 } 746 747 Token = strtok (NULL, Separators); 748 } 749 } 750 751 752 /******************************************************************************* 753 * 754 * FUNCTION: AhPrintOneField 755 * 756 * PARAMETERS: Indent - Indent length for new line(s) 757 * CurrentPosition - Position on current line 758 * MaxPosition - Max allowed line length 759 * Field - Data to output 760 * 761 * RETURN: Line position after field is written 762 * 763 * DESCRIPTION: Split long lines appropriately for ease of reading. 764 * 765 ******************************************************************************/ 766 767 static void 768 AhPrintOneField ( 769 UINT32 Indent, 770 UINT32 CurrentPosition, 771 UINT32 MaxPosition, 772 const char *Field) 773 { 774 UINT32 Position; 775 UINT32 TokenLength; 776 const char *This; 777 const char *Next; 778 const char *Last; 779 780 781 This = Field; 782 Position = CurrentPosition; 783 784 if (Position == 0) 785 { 786 printf ("%*s", (int) Indent, " "); 787 Position = Indent; 788 } 789 790 Last = This + strlen (This); 791 while ((Next = strpbrk (This, " "))) 792 { 793 TokenLength = Next - This; 794 Position += TokenLength; 795 796 /* Split long lines */ 797 798 if (Position > MaxPosition) 799 { 800 printf ("\n%*s", (int) Indent, " "); 801 Position = TokenLength; 802 } 803 804 printf ("%.*s ", (int) TokenLength, This); 805 This = Next + 1; 806 } 807 808 /* Handle last token on the input line */ 809 810 TokenLength = Last - This; 811 if (TokenLength > 0) 812 { 813 Position += TokenLength; 814 if (Position > MaxPosition) 815 { 816 printf ("\n%*s", (int) Indent, " "); 817 } 818 printf ("%s", This); 819 } 820 } 821 822 823 /******************************************************************************* 824 * 825 * FUNCTION: AhDisplayDeviceIds 826 * 827 * PARAMETERS: Name - Device Hardware ID string. 828 * NULL means "find all" 829 * 830 * RETURN: None 831 * 832 * DESCRIPTION: Display PNP* and ACPI* device IDs. 833 * 834 ******************************************************************************/ 835 836 void 837 AhDisplayDeviceIds ( 838 char *Name) 839 { 840 const AH_DEVICE_ID *Info; 841 UINT32 Length; 842 BOOLEAN Matched; 843 UINT32 i; 844 BOOLEAN Found = FALSE; 845 846 847 /* Null input name indicates "display all" */ 848 849 if (!Name) 850 { 851 printf ("ACPI and PNP Device/Hardware IDs:\n\n"); 852 for (Info = AslDeviceIds; Info->Name; Info++) 853 { 854 printf ("%8s %s\n", Info->Name, Info->Description); 855 } 856 857 return; 858 } 859 860 Length = strlen (Name); 861 if (Length > 8) 862 { 863 printf ("%.8s: Hardware ID must be 8 characters maximum\n", Name); 864 return; 865 } 866 867 /* Find/display all names that match the input name prefix */ 868 869 AhStrupr (Name); 870 for (Info = AslDeviceIds; Info->Name; Info++) 871 { 872 Matched = TRUE; 873 for (i = 0; i < Length; i++) 874 { 875 if (Info->Name[i] != Name[i]) 876 { 877 Matched = FALSE; 878 break; 879 } 880 } 881 882 if (Matched) 883 { 884 Found = TRUE; 885 printf ("%8s %s\n", Info->Name, Info->Description); 886 } 887 } 888 889 if (!Found) 890 { 891 printf ("%s, Hardware ID not found\n", Name); 892 } 893 } 894 895 896 /******************************************************************************* 897 * 898 * FUNCTION: AhDisplayUuids 899 * 900 * PARAMETERS: None 901 * 902 * RETURN: None 903 * 904 * DESCRIPTION: Display all known UUIDs. 905 * 906 ******************************************************************************/ 907 908 void 909 AhDisplayUuids ( 910 void) 911 { 912 const AH_UUID *Info; 913 914 915 printf ("ACPI-related UUIDs:\n\n"); 916 917 for (Info = AcpiUuids; Info->Description; Info++) 918 { 919 printf ("%32s : %s\n", Info->Description, Info->String); 920 } 921 } 922 923 924 /******************************************************************************* 925 * 926 * FUNCTION: AhDisplayTables 927 * 928 * PARAMETERS: None 929 * 930 * RETURN: None 931 * 932 * DESCRIPTION: Display all known ACPI tables 933 * 934 ******************************************************************************/ 935 936 void 937 AhDisplayTables ( 938 void) 939 { 940 const AH_TABLE *Info; 941 UINT32 i = 0; 942 943 944 printf ("Known ACPI tables:\n"); 945 946 for (Info = AcpiSupportedTables; Info->Signature; Info++) 947 { 948 printf ("%8s : %s\n", Info->Signature, Info->Description); 949 i++; 950 } 951 952 printf ("\nTotal %u ACPI tables\n\n", i); 953 } 954 955 956 /******************************************************************************* 957 * 958 * FUNCTION: AhDecodeException 959 * 960 * PARAMETERS: HexString - ACPI status string from command line, in 961 * hex. If null, display all exceptions. 962 * 963 * RETURN: None 964 * 965 * DESCRIPTION: Decode and display an ACPI_STATUS exception code. 966 * 967 ******************************************************************************/ 968 969 void 970 AhDecodeException ( 971 char *HexString) 972 { 973 const ACPI_EXCEPTION_INFO *ExceptionInfo; 974 UINT32 Status; 975 UINT32 i; 976 977 978 /* 979 * A null input string means to decode and display all known 980 * exception codes. 981 */ 982 if (!HexString) 983 { 984 printf ("All defined ACPICA exception codes:\n\n"); 985 AH_DISPLAY_EXCEPTION (0, "AE_OK (No error occurred)"); 986 987 /* Display codes in each block of exception types */ 988 989 for (i = 1; (i & AE_CODE_MASK) <= AE_CODE_MAX; i += 0x1000) 990 { 991 Status = i; 992 do 993 { 994 ExceptionInfo = AcpiUtValidateException ((ACPI_STATUS) Status); 995 if (ExceptionInfo) 996 { 997 AH_DISPLAY_EXCEPTION_TEXT (Status, ExceptionInfo); 998 } 999 Status++; 1000 1001 } while (ExceptionInfo); 1002 } 1003 return; 1004 } 1005 1006 /* Decode a single user-supplied exception code */ 1007 1008 Status = ACPI_STRTOUL (HexString, NULL, 16); 1009 if (!Status) 1010 { 1011 printf ("%s: Invalid hexadecimal exception code value\n", HexString); 1012 return; 1013 } 1014 1015 if (Status > ACPI_UINT16_MAX) 1016 { 1017 AH_DISPLAY_EXCEPTION (Status, "Invalid exception code (more than 16 bits)"); 1018 return; 1019 } 1020 1021 ExceptionInfo = AcpiUtValidateException ((ACPI_STATUS) Status); 1022 if (!ExceptionInfo) 1023 { 1024 AH_DISPLAY_EXCEPTION (Status, "Unknown exception code"); 1025 return; 1026 } 1027 1028 AH_DISPLAY_EXCEPTION_TEXT (Status, ExceptionInfo); 1029 } 1030