1 /******************************************************************************
3 * Module Name: ahmain - Main module for the acpi help utility
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2015, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
47 /* Local prototypes */
53 #define AH_UTILITY_NAME "ACPI Help Utility"
54 #define AH_SUPPORTED_OPTIONS "adehikmopstuv"
57 /******************************************************************************
59 * FUNCTION: AhDisplayUsage
61 * DESCRIPTION: Usage message
63 ******************************************************************************/
70 ACPI_USAGE_HEADER ("acpihelp <options> [Name/Prefix | HexValue]");
71 ACPI_OPTION ("-h", "Display help");
72 ACPI_OPTION ("-v", "Display version information");
74 ACPI_USAGE_TEXT ("\nAML (ACPI Machine Language) Names and Encodings:\n");
75 ACPI_OPTION ("-a [Name/Prefix]", "Find/Display both ASL operator and AML opcode name(s)");
76 ACPI_OPTION ("-m [Name/Prefix]", "Find/Display AML opcode name(s)");
78 ACPI_USAGE_TEXT ("\nACPI Values:\n");
79 ACPI_OPTION ("-e [HexValue]", "Decode ACPICA exception code");
80 ACPI_OPTION ("-o [HexValue]", "Decode hex AML opcode");
82 ACPI_USAGE_TEXT ("\nASL (ACPI Source Language) Names and Symbols:\n");
83 ACPI_OPTION ("-k [Name/Prefix]", "Find/Display ASL non-operator keyword(s)");
84 ACPI_OPTION ("-p [Name/Prefix]", "Find/Display ASL predefined method name(s)");
85 ACPI_OPTION ("-s [Name/Prefix]", "Find/Display ASL operator name(s)");
87 ACPI_USAGE_TEXT ("\nOther ACPI Names:\n");
88 ACPI_OPTION ("-i [Name/Prefix]", "Find/Display ACPI/PNP Hardware ID(s)");
89 ACPI_OPTION ("-d", "Display iASL Preprocessor directives");
90 ACPI_OPTION ("-t", "Display supported ACPI tables");
91 ACPI_OPTION ("-u", "Display ACPI-related UUIDs");
93 ACPI_USAGE_TEXT ("\nName/Prefix or HexValue not specified means \"Display All\"\n");
94 ACPI_USAGE_TEXT ("\nDefault search with valid Name/Prefix and no options:\n");
95 ACPI_USAGE_TEXT (" Find ASL/AML operator names - if NamePrefix does not start with underscore\n");
96 ACPI_USAGE_TEXT (" Find ASL predefined method names - if NamePrefix starts with underscore\n");
100 /******************************************************************************
104 * DESCRIPTION: C main function for AcpiHelp utility.
106 ******************************************************************************/
108 int ACPI_SYSTEM_XFACE
119 ACPI_DEBUG_INITIALIZE (); /* For debug version only */
120 printf (ACPI_COMMON_SIGNON (AH_UTILITY_NAME));
121 DecodeType = AH_DECODE_DEFAULT;
129 /* Command line options */
131 while ((j = AcpiGetopt (argc, argv, AH_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j)
135 DecodeType = AH_DECODE_ASL_AML;
140 DecodeType = AH_DISPLAY_DIRECTIVES;
145 DecodeType = AH_DECODE_EXCEPTION;
150 DecodeType = AH_DISPLAY_DEVICE_IDS;
155 DecodeType = AH_DECODE_ASL_KEYWORD;
160 DecodeType = AH_DECODE_AML;
165 DecodeType = AH_DECODE_AML_OPCODE;
170 DecodeType = AH_DECODE_PREDEFINED_NAME;
175 DecodeType = AH_DECODE_ASL;
180 DecodeType = AH_DISPLAY_TABLES;
185 DecodeType = AH_DISPLAY_UUIDS;
188 case 'v': /* -v: (Version): signon already emitted, just exit */
199 /* Missing (null) name means "display all" */
201 Name = argv[AcpiGbl_Optind];
205 case AH_DECODE_ASL_AML:
207 AhFindAslAndAmlOperators (Name);
212 AhFindAmlOpcode (Name);
215 case AH_DECODE_AML_OPCODE:
217 AhDecodeAmlOpcode (Name);
220 case AH_DECODE_PREDEFINED_NAME:
222 AhFindPredefinedNames (Name);
227 AhFindAslOperators (Name);
230 case AH_DECODE_ASL_KEYWORD:
232 AhFindAslKeywords (Name);
235 case AH_DISPLAY_DEVICE_IDS:
237 AhDisplayDeviceIds (Name);
240 case AH_DECODE_EXCEPTION:
242 AhDecodeException (Name);
245 case AH_DISPLAY_UUIDS:
250 case AH_DISPLAY_TABLES:
255 case AH_DISPLAY_DIRECTIVES:
257 AhDisplayDirectives ();
264 AhFindAslOperators (Name);
270 AhFindPredefinedNames (Name);
274 AhFindAslAndAmlOperators (Name);
283 /*******************************************************************************
285 * FUNCTION: AhStrupr (strupr)
287 * PARAMETERS: SrcString - The source string to convert
291 * DESCRIPTION: Convert string to uppercase
293 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
295 ******************************************************************************/
309 /* Walk entire string, uppercasing the letters */
311 for (String = SrcString; *String; String++)
313 *String = (char) toupper ((int) *String);