1 /****************************************************************************** 2 * 3 * Module Name: ahmain - Main module for the acpi help utility 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2014, 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 #include "acpihelp.h" 45 46 47 /* Local prototypes */ 48 49 static void 50 AhDisplayUsage ( 51 void); 52 53 #define AH_UTILITY_NAME "ACPI Help Utility" 54 #define AH_SUPPORTED_OPTIONS "ehikmopsv" 55 56 57 /****************************************************************************** 58 * 59 * FUNCTION: AhDisplayUsage 60 * 61 * DESCRIPTION: Usage message 62 * 63 ******************************************************************************/ 64 65 static void 66 AhDisplayUsage ( 67 void) 68 { 69 70 ACPI_USAGE_HEADER ("acpihelp <options> [NamePrefix | HexValue]"); 71 ACPI_OPTION ("-h", "Display help"); 72 ACPI_OPTION ("-v", "Display version information"); 73 74 printf ("\nACPI Names and Symbols:\n"); 75 ACPI_OPTION ("-k [NamePrefix]", "Find/Display ASL non-operator keyword(s)"); 76 ACPI_OPTION ("-m [NamePrefix]", "Find/Display AML opcode name(s)"); 77 ACPI_OPTION ("-p [NamePrefix]", "Find/Display ASL predefined method name(s)"); 78 ACPI_OPTION ("-s [NamePrefix]", "Find/Display ASL operator name(s)"); 79 80 printf ("\nACPI Values:\n"); 81 ACPI_OPTION ("-e [HexValue]", "Decode ACPICA exception code"); 82 ACPI_OPTION ("-i", "Display known ACPI Device IDs (_HID)"); 83 ACPI_OPTION ("-o [HexValue]", "Decode hex AML opcode"); 84 85 printf ("\nNamePrefix/HexValue not specified means \"Display All\"\n"); 86 printf ("\nDefault search with NamePrefix and no options:\n"); 87 printf (" Find ASL operator names - if NamePrefix does not start with underscore\n"); 88 printf (" Find ASL predefined method names - if NamePrefix starts with underscore\n"); 89 } 90 91 92 /****************************************************************************** 93 * 94 * FUNCTION: main 95 * 96 * DESCRIPTION: C main function for AcpiHelp utility. 97 * 98 ******************************************************************************/ 99 100 int ACPI_SYSTEM_XFACE 101 main ( 102 int argc, 103 char *argv[]) 104 { 105 char *Name; 106 UINT32 DecodeType; 107 int j; 108 109 110 ACPI_DEBUG_INITIALIZE (); /* For debug version only */ 111 printf (ACPI_COMMON_SIGNON (AH_UTILITY_NAME)); 112 DecodeType = AH_DECODE_DEFAULT; 113 114 if (argc < 2) 115 { 116 AhDisplayUsage (); 117 return (0); 118 } 119 120 /* Command line options */ 121 122 while ((j = AcpiGetopt (argc, argv, AH_SUPPORTED_OPTIONS)) != EOF) switch (j) 123 { 124 case 'e': 125 126 DecodeType = AH_DECODE_EXCEPTION; 127 break; 128 129 case 'i': 130 131 DecodeType = AH_DISPLAY_DEVICE_IDS; 132 break; 133 134 case 'k': 135 136 DecodeType = AH_DECODE_ASL_KEYWORD; 137 break; 138 139 case 'm': 140 141 DecodeType = AH_DECODE_AML; 142 break; 143 144 case 'o': 145 146 DecodeType = AH_DECODE_AML_OPCODE; 147 break; 148 149 case 'p': 150 151 DecodeType = AH_DECODE_PREDEFINED_NAME; 152 break; 153 154 case 's': 155 156 DecodeType = AH_DECODE_ASL; 157 break; 158 159 case 'v': /* -v: (Version): signon already emitted, just exit */ 160 161 return (0); 162 163 case 'h': 164 default: 165 166 AhDisplayUsage (); 167 return (-1); 168 } 169 170 /* Missing (null) name means "display all" */ 171 172 Name = argv[AcpiGbl_Optind]; 173 174 switch (DecodeType) 175 { 176 case AH_DECODE_AML: 177 178 AhFindAmlOpcode (Name); 179 break; 180 181 case AH_DECODE_AML_OPCODE: 182 183 AhDecodeAmlOpcode (Name); 184 break; 185 186 case AH_DECODE_PREDEFINED_NAME: 187 188 AhFindPredefinedNames (Name); 189 break; 190 191 case AH_DECODE_ASL: 192 193 AhFindAslOperators (Name); 194 break; 195 196 case AH_DECODE_ASL_KEYWORD: 197 198 AhFindAslKeywords (Name); 199 break; 200 201 case AH_DISPLAY_DEVICE_IDS: 202 203 AhDisplayDeviceIds (); 204 break; 205 206 case AH_DECODE_EXCEPTION: 207 208 AhDecodeException (Name); 209 break; 210 211 default: 212 213 if (!Name) 214 { 215 AhFindAslOperators (Name); 216 break; 217 } 218 219 if (*Name == '_') 220 { 221 AhFindPredefinedNames (Name); 222 } 223 else 224 { 225 AhFindAslOperators (Name); 226 } 227 break; 228 } 229 230 return (0); 231 } 232 233 234 /******************************************************************************* 235 * 236 * FUNCTION: AhStrupr (strupr) 237 * 238 * PARAMETERS: SrcString - The source string to convert 239 * 240 * RETURN: None 241 * 242 * DESCRIPTION: Convert string to uppercase 243 * 244 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c 245 * 246 ******************************************************************************/ 247 248 void 249 AhStrupr ( 250 char *SrcString) 251 { 252 char *String; 253 254 255 if (!SrcString) 256 { 257 return; 258 } 259 260 /* Walk entire string, uppercasing the letters */ 261 262 for (String = SrcString; *String; String++) 263 { 264 *String = (char) toupper ((int) *String); 265 } 266 267 return; 268 }