1 /******************************************************************************
3 * Module Name: ahmain - Main module for the acpi help utility
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2012, 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 */
54 /******************************************************************************
56 * FUNCTION: AhDisplayUsage
58 * DESCRIPTION: Usage message
60 ******************************************************************************/
67 ACPI_USAGE_HEADER ("acpihelp <options> [NamePrefix | HexValue]");
68 ACPI_OPTION ("-h", "Display help");
69 ACPI_OPTION ("-i", "Display known ACPI Device IDs (_HID)");
70 ACPI_OPTION ("-k [NamePrefix]", "Find/Display ASL non-operator keyword(s)");
71 ACPI_OPTION ("-m [NamePrefix]", "Find/Display AML opcode name(s)");
72 ACPI_OPTION ("-o [HexValue]", "Decode hex AML opcode");
73 ACPI_OPTION ("-p [NamePrefix]", "Find/Display ASL predefined method name(s)");
74 ACPI_OPTION ("-s [NamePrefix]", "Find/Display ASL operator name(s)");
75 printf ("\nNamePrefix/HexValue not specified means \"Display All\"\n");
76 printf ("\nDefault search with NamePrefix and no options:\n");
77 printf (" Find ASL operator names - if NamePrefix does not start with underscore\n");
78 printf (" Find ASL predefined method names - if NamePrefix starts with underscore\n");
82 /******************************************************************************
86 * DESCRIPTION: C main function for AcpiHelp utility.
88 ******************************************************************************/
100 printf (ACPI_COMMON_SIGNON ("ACPI Help Utility"));
101 DecodeType = AH_DECODE_DEFAULT;
109 /* Command line options */
111 while ((j = AcpiGetopt (argc, argv, "hikmops")) != EOF) switch (j)
114 DecodeType = AH_DISPLAY_DEVICE_IDS;
118 DecodeType = AH_DECODE_ASL_KEYWORD;
122 DecodeType = AH_DECODE_AML;
126 DecodeType = AH_DECODE_AML_OPCODE;
130 DecodeType = AH_DECODE_PREDEFINED_NAME;
134 DecodeType = AH_DECODE_ASL;
143 /* Missing (null) name means "display all" */
145 Name = argv[AcpiGbl_Optind];
150 AhFindAmlOpcode (Name);
153 case AH_DECODE_AML_OPCODE:
154 AhDecodeAmlOpcode (Name);
157 case AH_DECODE_PREDEFINED_NAME:
158 AhFindPredefinedNames (Name);
162 AhFindAslOperators (Name);
165 case AH_DECODE_ASL_KEYWORD:
166 AhFindAslKeywords (Name);
169 case AH_DISPLAY_DEVICE_IDS:
170 AhDisplayDeviceIds ();
176 AhFindAslOperators (Name);
182 AhFindPredefinedNames (Name);
186 AhFindAslOperators (Name);
195 /*******************************************************************************
197 * FUNCTION: AhStrupr (strupr)
199 * PARAMETERS: SrcString - The source string to convert
203 * DESCRIPTION: Convert string to uppercase
205 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
207 ******************************************************************************/
221 /* Walk entire string, uppercasing the letters */
223 for (String = SrcString; *String; String++)
225 *String = (char) toupper ((int) *String);