1 /******************************************************************************
3 * Module Name: ahasl - ASL operator decoding for acpihelp utility
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, 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 */
50 AhDisplayAslOperator (
51 const AH_ASL_OPERATOR
*Op
);
54 AhDisplayOperatorKeywords (
55 const AH_ASL_OPERATOR
*Op
);
59 const AH_ASL_KEYWORD
*Op
);
62 /*******************************************************************************
64 * FUNCTION: AhFindAslKeywords (entry point for ASL keyword search)
66 * PARAMETERS: Name - Name or prefix for an ASL keyword.
67 * NULL means "find all"
71 * DESCRIPTION: Find all ASL keywords that match the input Name or name
74 ******************************************************************************/
80 const AH_ASL_KEYWORD
*Keyword
;
81 BOOLEAN Found
= FALSE
;
86 for (Keyword
= Gbl_AslKeywordInfo
; Keyword
->Name
; Keyword
++)
88 if (!Name
|| (Name
[0] == '*'))
90 AhDisplayAslKeyword (Keyword
);
95 /* Upper case the operator name before substring compare */
97 strcpy (Gbl_Buffer
, Keyword
->Name
);
98 AcpiUtStrupr (Gbl_Buffer
);
100 if (strstr (Gbl_Buffer
, Name
) == Gbl_Buffer
)
102 AhDisplayAslKeyword (Keyword
);
109 printf ("%s, no matching ASL keywords\n", Name
);
114 /*******************************************************************************
116 * FUNCTION: AhDisplayAslKeyword
118 * PARAMETERS: Op - Pointer to ASL keyword with syntax info
122 * DESCRIPTION: Format and display syntax info for an ASL keyword. Splits
123 * long lines appropriately for reading.
125 ******************************************************************************/
128 AhDisplayAslKeyword (
129 const AH_ASL_KEYWORD
*Op
)
132 /* ASL keyword name and description */
134 printf ("%22s: %s\n", Op
->Name
, Op
->Description
);
135 if (!Op
->KeywordList
)
140 /* List of actual keywords */
142 AhPrintOneField (24, 0, AH_MAX_ASL_LINE_LENGTH
, Op
->KeywordList
);
147 /*******************************************************************************
149 * FUNCTION: AhFindAslAndAmlOperators
151 * PARAMETERS: Name - Name or prefix for an ASL operator.
152 * NULL means "find all"
156 * DESCRIPTION: Find all ASL operators that match the input Name or name
157 * prefix. Also displays the AML information if only one entry
160 ******************************************************************************/
163 AhFindAslAndAmlOperators (
169 MatchCount
= AhFindAslOperators (Name
);
172 AhFindAmlOpcode (Name
);
177 /*******************************************************************************
179 * FUNCTION: AhFindAslOperators (entry point for ASL operator search)
181 * PARAMETERS: Name - Name or prefix for an ASL operator.
182 * NULL means "find all"
184 * RETURN: Number of operators that matched the name prefix.
186 * DESCRIPTION: Find all ASL operators that match the input Name or name
189 ******************************************************************************/
195 const AH_ASL_OPERATOR
*Operator
;
196 BOOLEAN MatchCount
= 0;
201 /* Find/display all names that match the input name prefix */
203 for (Operator
= Gbl_AslOperatorInfo
; Operator
->Name
; Operator
++)
205 if (!Name
|| (Name
[0] == '*'))
207 AhDisplayAslOperator (Operator
);
212 /* Upper case the operator name before substring compare */
214 strcpy (Gbl_Buffer
, Operator
->Name
);
215 AcpiUtStrupr (Gbl_Buffer
);
217 if (strstr (Gbl_Buffer
, Name
) == Gbl_Buffer
)
219 AhDisplayAslOperator (Operator
);
226 printf ("%s, no matching ASL operators\n", Name
);
233 /*******************************************************************************
235 * FUNCTION: AhDisplayAslOperator
237 * PARAMETERS: Op - Pointer to ASL operator with syntax info
241 * DESCRIPTION: Format and display syntax info for an ASL operator. Splits
242 * long lines appropriately for reading.
244 ******************************************************************************/
247 AhDisplayAslOperator (
248 const AH_ASL_OPERATOR
*Op
)
251 /* ASL operator name and description */
253 printf ("%16s: %s\n", Op
->Name
, Op
->Description
);
259 /* Syntax for the operator */
261 AhPrintOneField (18, 0, AH_MAX_ASL_LINE_LENGTH
, Op
->Syntax
);
264 AhDisplayOperatorKeywords (Op
);
269 /*******************************************************************************
271 * FUNCTION: AhDisplayOperatorKeywords
273 * PARAMETERS: Op - Pointer to ASL keyword with syntax info
277 * DESCRIPTION: Display any/all keywords that are associated with the ASL
280 ******************************************************************************/
283 AhDisplayOperatorKeywords (
284 const AH_ASL_OPERATOR
*Op
)
287 char *Separators
= "(){}, ";
288 BOOLEAN FirstKeyword
= TRUE
;
291 if (!Op
|| !Op
->Syntax
)
297 * Find all parameters that have the word "keyword" within, and then
298 * display the info about that keyword
300 strcpy (Gbl_LineBuffer
, Op
->Syntax
);
301 Token
= strtok (Gbl_LineBuffer
, Separators
);
304 if (strstr (Token
, "Keyword"))
309 FirstKeyword
= FALSE
;
312 /* Found a keyword, display keyword information */
314 AhFindAslKeywords (Token
);
317 Token
= strtok (NULL
, Separators
);