ahdecode.c revision 1.1.1.18.6.1 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1.1.8 christos * Module Name: ahdecode - Miscellaneous decoding for acpihelp utility
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.1.1.18.6.1 perseant /******************************************************************************
8 1.1.1.18.6.1 perseant *
9 1.1.1.18.6.1 perseant * 1. Copyright Notice
10 1.1.1.18.6.1 perseant *
11 1.1.1.18.6.1 perseant * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
12 1.1 jruoho * All rights reserved.
13 1.1 jruoho *
14 1.1.1.18.6.1 perseant * 2. License
15 1.1.1.18.6.1 perseant *
16 1.1.1.18.6.1 perseant * 2.1. This is your license from Intel Corp. under its intellectual property
17 1.1.1.18.6.1 perseant * rights. You may have additional license terms from the party that provided
18 1.1.1.18.6.1 perseant * you this software, covering your right to use that party's intellectual
19 1.1.1.18.6.1 perseant * property rights.
20 1.1.1.18.6.1 perseant *
21 1.1.1.18.6.1 perseant * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 1.1.1.18.6.1 perseant * copy of the source code appearing in this file ("Covered Code") an
23 1.1.1.18.6.1 perseant * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 1.1.1.18.6.1 perseant * base code distributed originally by Intel ("Original Intel Code") to copy,
25 1.1.1.18.6.1 perseant * make derivatives, distribute, use and display any portion of the Covered
26 1.1.1.18.6.1 perseant * Code in any form, with the right to sublicense such rights; and
27 1.1.1.18.6.1 perseant *
28 1.1.1.18.6.1 perseant * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 1.1.1.18.6.1 perseant * license (with the right to sublicense), under only those claims of Intel
30 1.1.1.18.6.1 perseant * patents that are infringed by the Original Intel Code, to make, use, sell,
31 1.1.1.18.6.1 perseant * offer to sell, and import the Covered Code and derivative works thereof
32 1.1.1.18.6.1 perseant * solely to the minimum extent necessary to exercise the above copyright
33 1.1.1.18.6.1 perseant * license, and in no event shall the patent license extend to any additions
34 1.1.1.18.6.1 perseant * to or modifications of the Original Intel Code. No other license or right
35 1.1.1.18.6.1 perseant * is granted directly or by implication, estoppel or otherwise;
36 1.1.1.18.6.1 perseant *
37 1.1.1.18.6.1 perseant * The above copyright and patent license is granted only if the following
38 1.1.1.18.6.1 perseant * conditions are met:
39 1.1.1.18.6.1 perseant *
40 1.1.1.18.6.1 perseant * 3. Conditions
41 1.1.1.18.6.1 perseant *
42 1.1.1.18.6.1 perseant * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 1.1.1.18.6.1 perseant * Redistribution of source code of any substantial portion of the Covered
44 1.1.1.18.6.1 perseant * Code or modification with rights to further distribute source must include
45 1.1.1.18.6.1 perseant * the above Copyright Notice, the above License, this list of Conditions,
46 1.1.1.18.6.1 perseant * and the following Disclaimer and Export Compliance provision. In addition,
47 1.1.1.18.6.1 perseant * Licensee must cause all Covered Code to which Licensee contributes to
48 1.1.1.18.6.1 perseant * contain a file documenting the changes Licensee made to create that Covered
49 1.1.1.18.6.1 perseant * Code and the date of any change. Licensee must include in that file the
50 1.1.1.18.6.1 perseant * documentation of any changes made by any predecessor Licensee. Licensee
51 1.1.1.18.6.1 perseant * must include a prominent statement that the modification is derived,
52 1.1.1.18.6.1 perseant * directly or indirectly, from Original Intel Code.
53 1.1.1.18.6.1 perseant *
54 1.1.1.18.6.1 perseant * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 1.1.1.18.6.1 perseant * Redistribution of source code of any substantial portion of the Covered
56 1.1.1.18.6.1 perseant * Code or modification without rights to further distribute source must
57 1.1.1.18.6.1 perseant * include the following Disclaimer and Export Compliance provision in the
58 1.1.1.18.6.1 perseant * documentation and/or other materials provided with distribution. In
59 1.1.1.18.6.1 perseant * addition, Licensee may not authorize further sublicense of source of any
60 1.1.1.18.6.1 perseant * portion of the Covered Code, and must include terms to the effect that the
61 1.1.1.18.6.1 perseant * license from Licensee to its licensee is limited to the intellectual
62 1.1.1.18.6.1 perseant * property embodied in the software Licensee provides to its licensee, and
63 1.1.1.18.6.1 perseant * not to intellectual property embodied in modifications its licensee may
64 1.1.1.18.6.1 perseant * make.
65 1.1.1.18.6.1 perseant *
66 1.1.1.18.6.1 perseant * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 1.1.1.18.6.1 perseant * substantial portion of the Covered Code or modification must reproduce the
68 1.1.1.18.6.1 perseant * above Copyright Notice, and the following Disclaimer and Export Compliance
69 1.1.1.18.6.1 perseant * provision in the documentation and/or other materials provided with the
70 1.1.1.18.6.1 perseant * distribution.
71 1.1.1.18.6.1 perseant *
72 1.1.1.18.6.1 perseant * 3.4. Intel retains all right, title, and interest in and to the Original
73 1.1.1.18.6.1 perseant * Intel Code.
74 1.1.1.18.6.1 perseant *
75 1.1.1.18.6.1 perseant * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 1.1.1.18.6.1 perseant * Intel shall be used in advertising or otherwise to promote the sale, use or
77 1.1.1.18.6.1 perseant * other dealings in products derived from or relating to the Covered Code
78 1.1.1.18.6.1 perseant * without prior written authorization from Intel.
79 1.1.1.18.6.1 perseant *
80 1.1.1.18.6.1 perseant * 4. Disclaimer and Export Compliance
81 1.1.1.18.6.1 perseant *
82 1.1.1.18.6.1 perseant * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 1.1.1.18.6.1 perseant * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 1.1.1.18.6.1 perseant * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 1.1.1.18.6.1 perseant * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 1.1.1.18.6.1 perseant * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 1.1.1.18.6.1 perseant * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 1.1.1.18.6.1 perseant * PARTICULAR PURPOSE.
89 1.1.1.18.6.1 perseant *
90 1.1.1.18.6.1 perseant * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 1.1.1.18.6.1 perseant * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 1.1.1.18.6.1 perseant * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 1.1.1.18.6.1 perseant * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 1.1.1.18.6.1 perseant * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 1.1.1.18.6.1 perseant * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 1.1.1.18.6.1 perseant * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 1.1.1.18.6.1 perseant * LIMITED REMEDY.
98 1.1.1.18.6.1 perseant *
99 1.1.1.18.6.1 perseant * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 1.1.1.18.6.1 perseant * software or system incorporating such software without first obtaining any
101 1.1.1.18.6.1 perseant * required license or other approval from the U. S. Department of Commerce or
102 1.1.1.18.6.1 perseant * any other agency or department of the United States Government. In the
103 1.1.1.18.6.1 perseant * event Licensee exports any such software from the United States or
104 1.1.1.18.6.1 perseant * re-exports any such software from a foreign destination, Licensee shall
105 1.1.1.18.6.1 perseant * ensure that the distribution and export/re-export of the software is in
106 1.1.1.18.6.1 perseant * compliance with all laws, regulations, orders, or other restrictions of the
107 1.1.1.18.6.1 perseant * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 1.1.1.18.6.1 perseant * any of its subsidiaries will export/re-export any technical data, process,
109 1.1.1.18.6.1 perseant * software, or service, directly or indirectly, to any country for which the
110 1.1.1.18.6.1 perseant * United States government or any agency thereof requires an export license,
111 1.1.1.18.6.1 perseant * other governmental approval, or letter of assurance, without first obtaining
112 1.1.1.18.6.1 perseant * such license, approval or letter.
113 1.1.1.18.6.1 perseant *
114 1.1.1.18.6.1 perseant *****************************************************************************
115 1.1.1.18.6.1 perseant *
116 1.1.1.18.6.1 perseant * Alternatively, you may choose to be licensed under the terms of the
117 1.1.1.18.6.1 perseant * following license:
118 1.1.1.18.6.1 perseant *
119 1.1 jruoho * Redistribution and use in source and binary forms, with or without
120 1.1 jruoho * modification, are permitted provided that the following conditions
121 1.1 jruoho * are met:
122 1.1 jruoho * 1. Redistributions of source code must retain the above copyright
123 1.1 jruoho * notice, this list of conditions, and the following disclaimer,
124 1.1 jruoho * without modification.
125 1.1 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 1.1 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
127 1.1 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
128 1.1 jruoho * including a substantially similar Disclaimer requirement for further
129 1.1 jruoho * binary redistribution.
130 1.1 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
131 1.1 jruoho * of any contributors may be used to endorse or promote products derived
132 1.1 jruoho * from this software without specific prior written permission.
133 1.1 jruoho *
134 1.1 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 1.1 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 1.1.1.15 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 1.1 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 1.1.1.18.6.1 perseant * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 1.1.1.18.6.1 perseant * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 1.1.1.18.6.1 perseant * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 1.1.1.18.6.1 perseant * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 1.1.1.18.6.1 perseant * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 1.1.1.18.6.1 perseant * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 1.1.1.18.6.1 perseant * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 1.1.1.18.6.1 perseant *
146 1.1.1.18.6.1 perseant * Alternatively, you may choose to be licensed under the terms of the
147 1.1.1.18.6.1 perseant * GNU General Public License ("GPL") version 2 as published by the Free
148 1.1.1.18.6.1 perseant * Software Foundation.
149 1.1.1.18.6.1 perseant *
150 1.1.1.18.6.1 perseant *****************************************************************************/
151 1.1 jruoho
152 1.1 jruoho #define ACPI_CREATE_PREDEFINED_TABLE
153 1.1.1.2 christos #define ACPI_CREATE_RESOURCE_TABLE
154 1.1.1.2 christos
155 1.1.1.2 christos #include "acpihelp.h"
156 1.1 jruoho #include "acpredef.h"
157 1.1 jruoho
158 1.1.1.14 christos BOOLEAN AslGbl_VerboseErrors = TRUE;
159 1.1.1.2 christos
160 1.1 jruoho /* Local prototypes */
161 1.1 jruoho
162 1.1 jruoho static BOOLEAN
163 1.1 jruoho AhDisplayPredefinedName (
164 1.1 jruoho char *Name,
165 1.1 jruoho UINT32 Length);
166 1.1 jruoho
167 1.1 jruoho static void
168 1.1 jruoho AhDisplayPredefinedInfo (
169 1.1 jruoho char *Name);
170 1.1 jruoho
171 1.1 jruoho static void
172 1.1.1.10 christos AhDoSpecialNames (
173 1.1.1.10 christos char *Name);
174 1.1.1.10 christos
175 1.1.1.10 christos static void
176 1.1.1.2 christos AhDisplayResourceName (
177 1.1.1.2 christos const ACPI_PREDEFINED_INFO *ThisName);
178 1.1 jruoho
179 1.1.1.2 christos
180 1.1.1.8 christos /*******************************************************************************
181 1.1.1.8 christos *
182 1.1.1.8 christos * FUNCTION: AhPrintOneField
183 1.1.1.8 christos *
184 1.1.1.8 christos * PARAMETERS: Indent - Indent length for new line(s)
185 1.1.1.8 christos * CurrentPosition - Position on current line
186 1.1.1.8 christos * MaxPosition - Max allowed line length
187 1.1.1.8 christos * Field - Data to output
188 1.1.1.8 christos *
189 1.1.1.8 christos * RETURN: Line position after field is written
190 1.1.1.8 christos *
191 1.1.1.8 christos * DESCRIPTION: Split long lines appropriately for ease of reading.
192 1.1.1.8 christos *
193 1.1.1.8 christos ******************************************************************************/
194 1.1 jruoho
195 1.1.1.8 christos void
196 1.1 jruoho AhPrintOneField (
197 1.1 jruoho UINT32 Indent,
198 1.1 jruoho UINT32 CurrentPosition,
199 1.1 jruoho UINT32 MaxPosition,
200 1.1.1.8 christos const char *Field)
201 1.1.1.8 christos {
202 1.1.1.8 christos UINT32 Position;
203 1.1.1.8 christos UINT32 TokenLength;
204 1.1.1.8 christos const char *This;
205 1.1.1.8 christos const char *Next;
206 1.1.1.8 christos const char *Last;
207 1.1.1.8 christos
208 1.1.1.8 christos
209 1.1.1.8 christos This = Field;
210 1.1.1.8 christos Position = CurrentPosition;
211 1.1.1.8 christos
212 1.1.1.8 christos if (Position == 0)
213 1.1.1.8 christos {
214 1.1.1.8 christos printf ("%*s", (int) Indent, " ");
215 1.1.1.8 christos Position = Indent;
216 1.1.1.8 christos }
217 1.1.1.8 christos
218 1.1.1.8 christos Last = This + strlen (This);
219 1.1.1.8 christos while ((Next = strpbrk (This, " ")))
220 1.1.1.8 christos {
221 1.1.1.8 christos TokenLength = Next - This;
222 1.1.1.8 christos Position += TokenLength;
223 1.1.1.8 christos
224 1.1.1.8 christos /* Split long lines */
225 1.1.1.8 christos
226 1.1.1.8 christos if (Position > MaxPosition)
227 1.1.1.8 christos {
228 1.1.1.8 christos printf ("\n%*s", (int) Indent, " ");
229 1.1.1.8 christos Position = TokenLength;
230 1.1.1.8 christos }
231 1.1.1.8 christos
232 1.1.1.8 christos printf ("%.*s ", (int) TokenLength, This);
233 1.1.1.8 christos This = Next + 1;
234 1.1.1.8 christos }
235 1.1.1.8 christos
236 1.1.1.8 christos /* Handle last token on the input line */
237 1.1.1.8 christos
238 1.1.1.8 christos TokenLength = Last - This;
239 1.1.1.8 christos if (TokenLength > 0)
240 1.1.1.8 christos {
241 1.1.1.8 christos Position += TokenLength;
242 1.1.1.8 christos if (Position > MaxPosition)
243 1.1.1.8 christos {
244 1.1.1.8 christos printf ("\n%*s", (int) Indent, " ");
245 1.1.1.8 christos }
246 1.1.1.8 christos
247 1.1.1.8 christos printf ("%s", This);
248 1.1.1.8 christos }
249 1.1.1.8 christos }
250 1.1 jruoho
251 1.1 jruoho
252 1.1 jruoho /*******************************************************************************
253 1.1 jruoho *
254 1.1.1.5 christos * FUNCTION: AhDisplayDirectives
255 1.1.1.5 christos *
256 1.1.1.5 christos * PARAMETERS: None
257 1.1.1.5 christos *
258 1.1.1.5 christos * RETURN: None
259 1.1.1.5 christos *
260 1.1.1.5 christos * DESCRIPTION: Display all iASL preprocessor directives.
261 1.1.1.5 christos *
262 1.1.1.5 christos ******************************************************************************/
263 1.1.1.5 christos
264 1.1.1.5 christos void
265 1.1.1.5 christos AhDisplayDirectives (
266 1.1.1.5 christos void)
267 1.1.1.5 christos {
268 1.1.1.5 christos const AH_DIRECTIVE_INFO *Info;
269 1.1.1.5 christos
270 1.1.1.5 christos
271 1.1.1.5 christos printf ("iASL Preprocessor Directives\n\n");
272 1.1.1.5 christos
273 1.1.1.8 christos for (Info = Gbl_PreprocessorDirectives; Info->Name; Info++)
274 1.1.1.5 christos {
275 1.1.1.5 christos printf (" %-36s : %s\n", Info->Name, Info->Description);
276 1.1.1.5 christos }
277 1.1.1.5 christos }
278 1.1.1.5 christos
279 1.1.1.5 christos
280 1.1.1.5 christos /*******************************************************************************
281 1.1.1.5 christos *
282 1.1 jruoho * FUNCTION: AhFindPredefinedNames (entry point for predefined name search)
283 1.1 jruoho *
284 1.1 jruoho * PARAMETERS: NamePrefix - Name or prefix to find. Must start with
285 1.1 jruoho * an underscore. NULL means "find all"
286 1.1 jruoho *
287 1.1 jruoho * RETURN: None
288 1.1 jruoho *
289 1.1 jruoho * DESCRIPTION: Find and display all ACPI predefined names that match the
290 1.1 jruoho * input name or prefix. Includes the required number of arguments
291 1.1 jruoho * and the expected return type, if any.
292 1.1 jruoho *
293 1.1 jruoho ******************************************************************************/
294 1.1 jruoho
295 1.1 jruoho void
296 1.1 jruoho AhFindPredefinedNames (
297 1.1 jruoho char *NamePrefix)
298 1.1 jruoho {
299 1.1 jruoho UINT32 Length;
300 1.1 jruoho BOOLEAN Found;
301 1.1.1.11 christos char Name[ACPI_NAMESEG_SIZE + 1];
302 1.1 jruoho
303 1.1 jruoho
304 1.1.1.10 christos if (!NamePrefix || (*NamePrefix == '*'))
305 1.1 jruoho {
306 1.1.1.12 christos (void) AhDisplayPredefinedName (NULL, 0);
307 1.1 jruoho return;
308 1.1 jruoho }
309 1.1 jruoho
310 1.1.1.10 christos Length = strlen (NamePrefix);
311 1.1.1.11 christos if (Length > ACPI_NAMESEG_SIZE)
312 1.1.1.10 christos {
313 1.1.1.10 christos printf ("%.8s: Predefined name must be 4 characters maximum\n",
314 1.1.1.10 christos NamePrefix);
315 1.1.1.10 christos return;
316 1.1.1.10 christos }
317 1.1.1.10 christos
318 1.1.1.11 christos /* Construct a local name or name prefix */
319 1.1 jruoho
320 1.1.1.5 christos AcpiUtStrupr (NamePrefix);
321 1.1 jruoho if (*NamePrefix == '_')
322 1.1 jruoho {
323 1.1 jruoho NamePrefix++;
324 1.1 jruoho }
325 1.1 jruoho
326 1.1 jruoho Name[0] = '_';
327 1.1.1.10 christos AcpiUtSafeStrncpy (&Name[1], NamePrefix, 4);
328 1.1 jruoho
329 1.1.1.10 christos /* Check for special names such as _Exx, _ACx, etc. */
330 1.1.1.10 christos
331 1.1.1.10 christos AhDoSpecialNames (Name);
332 1.1.1.10 christos
333 1.1.1.10 christos /* Lookup and display the name(s) */
334 1.1 jruoho
335 1.1 jruoho Found = AhDisplayPredefinedName (Name, Length);
336 1.1 jruoho if (!Found)
337 1.1 jruoho {
338 1.1 jruoho printf ("%s, no matching predefined names\n", Name);
339 1.1 jruoho }
340 1.1 jruoho }
341 1.1 jruoho
342 1.1 jruoho
343 1.1 jruoho /*******************************************************************************
344 1.1 jruoho *
345 1.1.1.10 christos * FUNCTION: AhDoSpecialNames
346 1.1.1.10 christos *
347 1.1.1.10 christos * PARAMETERS: Name - Name or prefix to find
348 1.1.1.10 christos *
349 1.1.1.10 christos * RETURN: None
350 1.1.1.10 christos *
351 1.1.1.10 christos * DESCRIPTION: Detect and handle the "special" names such as _Exx, _ACx, etc.
352 1.1.1.10 christos *
353 1.1.1.10 christos * Current support:
354 1.1.1.10 christos * _EJx
355 1.1.1.10 christos * _Exx
356 1.1.1.10 christos * _Lxx
357 1.1.1.10 christos * _Qxx
358 1.1.1.10 christos * _Wxx
359 1.1.1.10 christos * _ACx
360 1.1.1.10 christos * _ALx
361 1.1.1.10 christos * _T_x
362 1.1.1.10 christos *
363 1.1.1.10 christos ******************************************************************************/
364 1.1.1.10 christos
365 1.1.1.10 christos static void
366 1.1.1.10 christos AhDoSpecialNames (
367 1.1.1.10 christos char *Name)
368 1.1.1.10 christos {
369 1.1.1.10 christos
370 1.1.1.10 christos /*
371 1.1.1.10 christos * Check for the special names that have one or more numeric
372 1.1.1.10 christos * suffixes. For example, _Lxx can have 256 different flavors,
373 1.1.1.10 christos * from _L00 to _LFF.
374 1.1.1.10 christos */
375 1.1.1.10 christos switch (Name[1])
376 1.1.1.10 christos {
377 1.1.1.10 christos case 'E':
378 1.1.1.10 christos if (Name[2] == 'J')
379 1.1.1.10 christos {
380 1.1.1.15 christos if (isdigit ((int) Name[3]) || (Name[3] == 'X'))
381 1.1.1.10 christos {
382 1.1.1.10 christos /* _EJx */
383 1.1.1.10 christos
384 1.1.1.10 christos Name[3] = 'x';
385 1.1.1.10 christos break;
386 1.1.1.10 christos }
387 1.1.1.10 christos }
388 1.1.1.10 christos
389 1.1.1.15 christos ACPI_FALLTHROUGH;
390 1.1.1.10 christos
391 1.1.1.10 christos case 'L':
392 1.1.1.10 christos case 'Q':
393 1.1.1.10 christos case 'W':
394 1.1.1.15 christos if ((isxdigit ((int) Name[2]) && isxdigit ((int) Name[3]))
395 1.1.1.10 christos ||
396 1.1.1.10 christos ((Name[2] == 'X') && (Name[3] == 'X')))
397 1.1.1.10 christos {
398 1.1.1.10 christos /* _Exx, _Lxx, _Qxx, or _Wxx */
399 1.1.1.10 christos
400 1.1.1.10 christos Name[2] = 'x';
401 1.1.1.10 christos Name[3] = 'x';
402 1.1.1.10 christos }
403 1.1.1.10 christos break;
404 1.1.1.10 christos
405 1.1.1.10 christos case 'A':
406 1.1.1.10 christos if ((Name[2] == 'C') || (Name[2] == 'L'))
407 1.1.1.10 christos {
408 1.1.1.15 christos if (isdigit ((int) Name[3]) || (Name[3] == 'X'))
409 1.1.1.10 christos {
410 1.1.1.10 christos /* _ACx or _ALx */
411 1.1.1.10 christos
412 1.1.1.10 christos Name[3] = 'x';
413 1.1.1.10 christos }
414 1.1.1.10 christos }
415 1.1.1.10 christos break;
416 1.1.1.10 christos
417 1.1.1.10 christos case 'T':
418 1.1.1.10 christos if (Name[2] == '_')
419 1.1.1.10 christos {
420 1.1.1.10 christos /* _T_x (Reserved for iASL compiler */
421 1.1.1.10 christos
422 1.1.1.10 christos Name[3] = 'x';
423 1.1.1.10 christos }
424 1.1.1.10 christos break;
425 1.1.1.10 christos
426 1.1.1.10 christos default:
427 1.1.1.10 christos break;
428 1.1.1.10 christos }
429 1.1.1.10 christos }
430 1.1.1.10 christos
431 1.1.1.10 christos
432 1.1.1.10 christos /*******************************************************************************
433 1.1.1.10 christos *
434 1.1 jruoho * FUNCTION: AhDisplayPredefinedName
435 1.1 jruoho *
436 1.1 jruoho * PARAMETERS: Name - Name or name prefix
437 1.1 jruoho *
438 1.1 jruoho * RETURN: TRUE if any names matched, FALSE otherwise
439 1.1 jruoho *
440 1.1 jruoho * DESCRIPTION: Display information about ACPI predefined names that match
441 1.1 jruoho * the input name or name prefix.
442 1.1 jruoho *
443 1.1 jruoho ******************************************************************************/
444 1.1 jruoho
445 1.1 jruoho static BOOLEAN
446 1.1 jruoho AhDisplayPredefinedName (
447 1.1 jruoho char *Name,
448 1.1 jruoho UINT32 Length)
449 1.1 jruoho {
450 1.1 jruoho const AH_PREDEFINED_NAME *Info;
451 1.1 jruoho BOOLEAN Found = FALSE;
452 1.1 jruoho BOOLEAN Matched;
453 1.1.1.5 christos UINT32 i = 0;
454 1.1 jruoho
455 1.1 jruoho
456 1.1 jruoho /* Find/display all names that match the input name prefix */
457 1.1 jruoho
458 1.1 jruoho for (Info = AslPredefinedInfo; Info->Name; Info++)
459 1.1 jruoho {
460 1.1 jruoho if (!Name)
461 1.1 jruoho {
462 1.1 jruoho Found = TRUE;
463 1.1 jruoho printf ("%s: <%s>\n", Info->Name, Info->Description);
464 1.1 jruoho printf ("%*s%s\n", 6, " ", Info->Action);
465 1.1 jruoho
466 1.1 jruoho AhDisplayPredefinedInfo (Info->Name);
467 1.1.1.5 christos i++;
468 1.1 jruoho continue;
469 1.1 jruoho }
470 1.1 jruoho
471 1.1 jruoho Matched = TRUE;
472 1.1 jruoho for (i = 0; i < Length; i++)
473 1.1 jruoho {
474 1.1 jruoho if (Info->Name[i] != Name[i])
475 1.1 jruoho {
476 1.1 jruoho Matched = FALSE;
477 1.1 jruoho break;
478 1.1 jruoho }
479 1.1 jruoho }
480 1.1 jruoho
481 1.1 jruoho if (Matched)
482 1.1 jruoho {
483 1.1 jruoho Found = TRUE;
484 1.1 jruoho printf ("%s: <%s>\n", Info->Name, Info->Description);
485 1.1 jruoho printf ("%*s%s\n", 6, " ", Info->Action);
486 1.1 jruoho
487 1.1 jruoho AhDisplayPredefinedInfo (Info->Name);
488 1.1 jruoho }
489 1.1 jruoho }
490 1.1 jruoho
491 1.1.1.5 christos if (!Name)
492 1.1.1.5 christos {
493 1.1.1.5 christos printf ("\nFound %d Predefined ACPI Names\n", i);
494 1.1.1.5 christos }
495 1.1 jruoho return (Found);
496 1.1 jruoho }
497 1.1 jruoho
498 1.1 jruoho
499 1.1 jruoho /*******************************************************************************
500 1.1 jruoho *
501 1.1 jruoho * FUNCTION: AhDisplayPredefinedInfo
502 1.1 jruoho *
503 1.1 jruoho * PARAMETERS: Name - Exact 4-character ACPI name.
504 1.1 jruoho *
505 1.1 jruoho * RETURN: None
506 1.1 jruoho *
507 1.1 jruoho * DESCRIPTION: Find the name in the main ACPICA predefined info table and
508 1.1 jruoho * display the # of arguments and the return value type.
509 1.1 jruoho *
510 1.1 jruoho * Note: Resource Descriptor field names do not appear in this
511 1.1 jruoho * table -- thus, nothing will be displayed for them.
512 1.1 jruoho *
513 1.1 jruoho ******************************************************************************/
514 1.1 jruoho
515 1.1 jruoho static void
516 1.1 jruoho AhDisplayPredefinedInfo (
517 1.1.1.2 christos char *Name)
518 1.1 jruoho {
519 1.1 jruoho const ACPI_PREDEFINED_INFO *ThisName;
520 1.1 jruoho
521 1.1 jruoho
522 1.1.1.2 christos /* NOTE: we check both tables always because there are some dupes */
523 1.1 jruoho
524 1.1.1.10 christos /* Check against the predefined methods first */
525 1.1 jruoho
526 1.1.1.2 christos ThisName = AcpiUtMatchPredefinedMethod (Name);
527 1.1.1.2 christos if (ThisName)
528 1.1.1.2 christos {
529 1.1.1.2 christos AcpiUtDisplayPredefinedMethod (Gbl_Buffer, ThisName, TRUE);
530 1.1.1.2 christos }
531 1.1 jruoho
532 1.1.1.2 christos /* Check against the predefined resource descriptor names */
533 1.1 jruoho
534 1.1.1.2 christos ThisName = AcpiUtMatchResourceName (Name);
535 1.1.1.2 christos if (ThisName)
536 1.1.1.2 christos {
537 1.1.1.2 christos AhDisplayResourceName (ThisName);
538 1.1 jruoho }
539 1.1 jruoho }
540 1.1 jruoho
541 1.1 jruoho
542 1.1 jruoho /*******************************************************************************
543 1.1 jruoho *
544 1.1.1.2 christos * FUNCTION: AhDisplayResourceName
545 1.1 jruoho *
546 1.1.1.2 christos * PARAMETERS: ThisName - Entry in the predefined method/name table
547 1.1 jruoho *
548 1.1.1.2 christos * RETURN: None
549 1.1 jruoho *
550 1.1.1.2 christos * DESCRIPTION: Display information about a resource descriptor name.
551 1.1 jruoho *
552 1.1 jruoho ******************************************************************************/
553 1.1 jruoho
554 1.1 jruoho static void
555 1.1.1.2 christos AhDisplayResourceName (
556 1.1.1.2 christos const ACPI_PREDEFINED_INFO *ThisName)
557 1.1 jruoho {
558 1.1.1.2 christos UINT32 NumTypes;
559 1.1 jruoho
560 1.1 jruoho
561 1.1.1.2 christos NumTypes = AcpiUtGetResourceBitWidth (Gbl_Buffer,
562 1.1.1.2 christos ThisName->Info.ArgumentList);
563 1.1 jruoho
564 1.1.1.2 christos printf (" %4.4s resource descriptor field is %s bits wide%s\n",
565 1.1.1.2 christos ThisName->Info.Name,
566 1.1.1.2 christos Gbl_Buffer,
567 1.1.1.2 christos (NumTypes > 1) ? " (depending on descriptor type)" : "");
568 1.1 jruoho }
569 1.1 jruoho
570 1.1 jruoho
571 1.1 jruoho /*******************************************************************************
572 1.1 jruoho *
573 1.1.1.2 christos * FUNCTION: AhDisplayDeviceIds
574 1.1.1.2 christos *
575 1.1.1.3 christos * PARAMETERS: Name - Device Hardware ID string.
576 1.1.1.3 christos * NULL means "find all"
577 1.1.1.2 christos *
578 1.1.1.2 christos * RETURN: None
579 1.1.1.2 christos *
580 1.1.1.3 christos * DESCRIPTION: Display PNP* and ACPI* device IDs.
581 1.1.1.2 christos *
582 1.1.1.2 christos ******************************************************************************/
583 1.1.1.2 christos
584 1.1.1.2 christos void
585 1.1.1.2 christos AhDisplayDeviceIds (
586 1.1.1.3 christos char *Name)
587 1.1.1.3 christos {
588 1.1.1.3 christos const AH_DEVICE_ID *Info;
589 1.1.1.3 christos UINT32 Length;
590 1.1.1.3 christos BOOLEAN Matched;
591 1.1.1.3 christos UINT32 i;
592 1.1.1.3 christos BOOLEAN Found = FALSE;
593 1.1.1.3 christos
594 1.1.1.3 christos
595 1.1.1.3 christos /* Null input name indicates "display all" */
596 1.1.1.3 christos
597 1.1.1.7 christos if (!Name || (Name[0] == '*'))
598 1.1.1.3 christos {
599 1.1.1.3 christos printf ("ACPI and PNP Device/Hardware IDs:\n\n");
600 1.1.1.3 christos for (Info = AslDeviceIds; Info->Name; Info++)
601 1.1.1.3 christos {
602 1.1.1.3 christos printf ("%8s %s\n", Info->Name, Info->Description);
603 1.1.1.3 christos }
604 1.1.1.3 christos
605 1.1.1.3 christos return;
606 1.1.1.3 christos }
607 1.1.1.3 christos
608 1.1.1.3 christos Length = strlen (Name);
609 1.1.1.3 christos if (Length > 8)
610 1.1.1.3 christos {
611 1.1.1.3 christos printf ("%.8s: Hardware ID must be 8 characters maximum\n", Name);
612 1.1.1.3 christos return;
613 1.1.1.3 christos }
614 1.1.1.3 christos
615 1.1.1.3 christos /* Find/display all names that match the input name prefix */
616 1.1.1.3 christos
617 1.1.1.5 christos AcpiUtStrupr (Name);
618 1.1.1.3 christos for (Info = AslDeviceIds; Info->Name; Info++)
619 1.1.1.3 christos {
620 1.1.1.3 christos Matched = TRUE;
621 1.1.1.3 christos for (i = 0; i < Length; i++)
622 1.1.1.3 christos {
623 1.1.1.3 christos if (Info->Name[i] != Name[i])
624 1.1.1.3 christos {
625 1.1.1.3 christos Matched = FALSE;
626 1.1.1.3 christos break;
627 1.1.1.3 christos }
628 1.1.1.3 christos }
629 1.1.1.3 christos
630 1.1.1.3 christos if (Matched)
631 1.1.1.3 christos {
632 1.1.1.3 christos Found = TRUE;
633 1.1.1.3 christos printf ("%8s %s\n", Info->Name, Info->Description);
634 1.1.1.3 christos }
635 1.1.1.3 christos }
636 1.1.1.3 christos
637 1.1.1.3 christos if (!Found)
638 1.1.1.3 christos {
639 1.1.1.3 christos printf ("%s, Hardware ID not found\n", Name);
640 1.1.1.3 christos }
641 1.1.1.3 christos }
642 1.1.1.3 christos
643 1.1.1.3 christos
644 1.1.1.3 christos /*******************************************************************************
645 1.1.1.3 christos *
646 1.1.1.3 christos * FUNCTION: AhDisplayUuids
647 1.1.1.3 christos *
648 1.1.1.3 christos * PARAMETERS: None
649 1.1.1.3 christos *
650 1.1.1.3 christos * RETURN: None
651 1.1.1.3 christos *
652 1.1.1.3 christos * DESCRIPTION: Display all known UUIDs.
653 1.1.1.3 christos *
654 1.1.1.3 christos ******************************************************************************/
655 1.1.1.3 christos
656 1.1.1.3 christos void
657 1.1.1.3 christos AhDisplayUuids (
658 1.1.1.2 christos void)
659 1.1.1.2 christos {
660 1.1.1.3 christos const AH_UUID *Info;
661 1.1.1.3 christos
662 1.1.1.2 christos
663 1.1.1.5 christos printf ("ACPI-related UUIDs/GUIDs:\n");
664 1.1.1.5 christos
665 1.1.1.5 christos /* Display entire table of known ACPI-related UUIDs/GUIDs */
666 1.1.1.2 christos
667 1.1.1.8 christos for (Info = Gbl_AcpiUuids; Info->Description; Info++)
668 1.1.1.2 christos {
669 1.1.1.5 christos if (!Info->String) /* Null UUID string means group description */
670 1.1.1.5 christos {
671 1.1.1.5 christos printf ("\n%36s\n", Info->Description);
672 1.1.1.5 christos }
673 1.1.1.5 christos else
674 1.1.1.5 christos {
675 1.1.1.5 christos printf ("%32s : %s\n", Info->Description, Info->String);
676 1.1.1.5 christos }
677 1.1.1.5 christos }
678 1.1.1.5 christos
679 1.1.1.5 christos /* Help info on how UUIDs/GUIDs strings are encoded */
680 1.1.1.5 christos
681 1.1.1.5 christos printf ("\n\nByte encoding of UUID/GUID strings"
682 1.1.1.5 christos " into ACPI Buffer objects (use ToUUID from ASL):\n\n");
683 1.1.1.5 christos
684 1.1.1.5 christos printf ("%32s : %s\n", "Input UUID/GUID String format",
685 1.1.1.5 christos "aabbccdd-eeff-gghh-iijj-kkllmmnnoopp");
686 1.1.1.5 christos
687 1.1.1.5 christos printf ("%32s : %s\n", "Expected output ACPI buffer",
688 1.1.1.5 christos "dd,cc,bb,aa, ff,ee, hh,gg, ii,jj, kk,ll,mm,nn,oo,pp");
689 1.1.1.5 christos }
690 1.1.1.5 christos
691 1.1.1.5 christos
692 1.1.1.5 christos /*******************************************************************************
693 1.1.1.5 christos *
694 1.1.1.5 christos * FUNCTION: AhDisplayTables
695 1.1.1.5 christos *
696 1.1.1.5 christos * PARAMETERS: None
697 1.1.1.5 christos *
698 1.1.1.5 christos * RETURN: None
699 1.1.1.5 christos *
700 1.1.1.5 christos * DESCRIPTION: Display all known ACPI tables
701 1.1.1.5 christos *
702 1.1.1.5 christos ******************************************************************************/
703 1.1.1.5 christos
704 1.1.1.5 christos void
705 1.1.1.5 christos AhDisplayTables (
706 1.1.1.5 christos void)
707 1.1.1.5 christos {
708 1.1.1.5 christos const AH_TABLE *Info;
709 1.1.1.5 christos UINT32 i = 0;
710 1.1.1.5 christos
711 1.1.1.5 christos
712 1.1.1.16 christos printf ("Known/Supported ACPI tables:\n");
713 1.1.1.5 christos
714 1.1.1.10 christos for (Info = AcpiGbl_SupportedTables; Info->Signature; Info++)
715 1.1.1.5 christos {
716 1.1.1.16 christos printf ("%8u) %s : %s\n", i + 1, Info->Signature, Info->Description);
717 1.1.1.5 christos i++;
718 1.1.1.2 christos }
719 1.1.1.5 christos
720 1.1.1.5 christos printf ("\nTotal %u ACPI tables\n\n", i);
721 1.1.1.2 christos }
722 1.1.1.2 christos
723 1.1.1.2 christos
724 1.1.1.2 christos /*******************************************************************************
725 1.1.1.2 christos *
726 1.1.1.2 christos * FUNCTION: AhDecodeException
727 1.1.1.2 christos *
728 1.1.1.2 christos * PARAMETERS: HexString - ACPI status string from command line, in
729 1.1.1.2 christos * hex. If null, display all exceptions.
730 1.1.1.2 christos *
731 1.1.1.2 christos * RETURN: None
732 1.1.1.2 christos *
733 1.1.1.2 christos * DESCRIPTION: Decode and display an ACPI_STATUS exception code.
734 1.1.1.2 christos *
735 1.1.1.2 christos ******************************************************************************/
736 1.1.1.2 christos
737 1.1.1.2 christos void
738 1.1.1.2 christos AhDecodeException (
739 1.1.1.2 christos char *HexString)
740 1.1.1.2 christos {
741 1.1.1.2 christos const ACPI_EXCEPTION_INFO *ExceptionInfo;
742 1.1.1.2 christos UINT32 Status;
743 1.1.1.2 christos UINT32 i;
744 1.1.1.2 christos
745 1.1.1.2 christos
746 1.1.1.2 christos /*
747 1.1.1.2 christos * A null input string means to decode and display all known
748 1.1.1.2 christos * exception codes.
749 1.1.1.2 christos */
750 1.1.1.2 christos if (!HexString)
751 1.1.1.2 christos {
752 1.1.1.2 christos printf ("All defined ACPICA exception codes:\n\n");
753 1.1.1.6 christos AH_DISPLAY_EXCEPTION (0,
754 1.1.1.6 christos "AE_OK (No error occurred)");
755 1.1.1.2 christos
756 1.1.1.2 christos /* Display codes in each block of exception types */
757 1.1.1.2 christos
758 1.1.1.2 christos for (i = 1; (i & AE_CODE_MASK) <= AE_CODE_MAX; i += 0x1000)
759 1.1.1.2 christos {
760 1.1.1.2 christos Status = i;
761 1.1.1.2 christos do
762 1.1.1.2 christos {
763 1.1.1.2 christos ExceptionInfo = AcpiUtValidateException ((ACPI_STATUS) Status);
764 1.1.1.2 christos if (ExceptionInfo)
765 1.1.1.2 christos {
766 1.1.1.2 christos AH_DISPLAY_EXCEPTION_TEXT (Status, ExceptionInfo);
767 1.1.1.2 christos }
768 1.1.1.6 christos
769 1.1.1.2 christos Status++;
770 1.1.1.2 christos
771 1.1.1.2 christos } while (ExceptionInfo);
772 1.1.1.2 christos }
773 1.1.1.2 christos return;
774 1.1.1.2 christos }
775 1.1.1.2 christos
776 1.1.1.2 christos /* Decode a single user-supplied exception code */
777 1.1.1.2 christos
778 1.1.1.5 christos Status = strtoul (HexString, NULL, 16);
779 1.1.1.2 christos if (!Status)
780 1.1.1.2 christos {
781 1.1.1.2 christos printf ("%s: Invalid hexadecimal exception code value\n", HexString);
782 1.1.1.2 christos return;
783 1.1.1.2 christos }
784 1.1.1.2 christos
785 1.1.1.2 christos if (Status > ACPI_UINT16_MAX)
786 1.1.1.2 christos {
787 1.1.1.2 christos AH_DISPLAY_EXCEPTION (Status, "Invalid exception code (more than 16 bits)");
788 1.1.1.2 christos return;
789 1.1.1.2 christos }
790 1.1.1.2 christos
791 1.1.1.2 christos ExceptionInfo = AcpiUtValidateException ((ACPI_STATUS) Status);
792 1.1.1.2 christos if (!ExceptionInfo)
793 1.1.1.2 christos {
794 1.1.1.2 christos AH_DISPLAY_EXCEPTION (Status, "Unknown exception code");
795 1.1.1.2 christos return;
796 1.1.1.2 christos }
797 1.1.1.2 christos
798 1.1.1.2 christos AH_DISPLAY_EXCEPTION_TEXT (Status, ExceptionInfo);
799 1.1.1.2 christos }
800