dmopcode.c revision 1.1.1.10.2.1 1 1.1 jruoho /*******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: dmopcode - AML disassembler, specific AML opcodes
4 1.1 jruoho *
5 1.1 jruoho ******************************************************************************/
6 1.1 jruoho
7 1.1.1.2 jruoho /*
8 1.1.1.10.2.1 bouyer * Copyright (C) 2000 - 2017, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without
12 1.1.1.2 jruoho * modification, are permitted provided that the following conditions
13 1.1.1.2 jruoho * are met:
14 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2 jruoho * without modification.
17 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further
21 1.1.1.2 jruoho * binary redistribution.
22 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived
24 1.1.1.2 jruoho * from this software without specific prior written permission.
25 1.1.1.2 jruoho *
26 1.1.1.2 jruoho * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2 jruoho * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2 jruoho * Software Foundation.
29 1.1.1.2 jruoho *
30 1.1.1.2 jruoho * NO WARRANTY
31 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2 jruoho * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2 jruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2 jruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2 jruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2 jruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2 jruoho * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2 jruoho */
43 1.1 jruoho
44 1.1 jruoho #include "acpi.h"
45 1.1 jruoho #include "accommon.h"
46 1.1 jruoho #include "acparser.h"
47 1.1 jruoho #include "amlcode.h"
48 1.1.1.4 christos #include "acinterp.h"
49 1.1.1.4 christos #include "acnamesp.h"
50 1.1.1.6 christos #include "acdebug.h"
51 1.1 jruoho
52 1.1 jruoho
53 1.1 jruoho #define _COMPONENT ACPI_CA_DEBUGGER
54 1.1 jruoho ACPI_MODULE_NAME ("dmopcode")
55 1.1 jruoho
56 1.1.1.5 christos
57 1.1 jruoho /* Local prototypes */
58 1.1 jruoho
59 1.1 jruoho static void
60 1.1 jruoho AcpiDmMatchKeyword (
61 1.1 jruoho ACPI_PARSE_OBJECT *Op);
62 1.1 jruoho
63 1.1.1.7 christos static void
64 1.1.1.7 christos AcpiDmConvertToElseIf (
65 1.1.1.7 christos ACPI_PARSE_OBJECT *Op);
66 1.1.1.7 christos
67 1.1.1.10 christos static void
68 1.1.1.10 christos AcpiDmPromoteSubtree (
69 1.1.1.10 christos ACPI_PARSE_OBJECT *StartOp);
70 1.1.1.10 christos
71 1.1.1.10.2.1 bouyer static BOOLEAN
72 1.1.1.10.2.1 bouyer AcpiDmIsSwitchBlock (
73 1.1.1.10.2.1 bouyer ACPI_PARSE_OBJECT *Op);
74 1.1.1.10.2.1 bouyer
75 1.1.1.10.2.1 bouyer static BOOLEAN
76 1.1.1.10.2.1 bouyer AcpiDmIsCaseBlock (
77 1.1.1.10.2.1 bouyer ACPI_PARSE_OBJECT *Op);
78 1.1 jruoho
79 1.1 jruoho /*******************************************************************************
80 1.1 jruoho *
81 1.1.1.4 christos * FUNCTION: AcpiDmDisplayTargetPathname
82 1.1.1.4 christos *
83 1.1.1.4 christos * PARAMETERS: Op - Parse object
84 1.1.1.4 christos *
85 1.1.1.4 christos * RETURN: None
86 1.1.1.4 christos *
87 1.1.1.4 christos * DESCRIPTION: For AML opcodes that have a target operand, display the full
88 1.1.1.4 christos * pathname for the target, in a comment field. Handles Return()
89 1.1.1.4 christos * statements also.
90 1.1.1.4 christos *
91 1.1.1.4 christos ******************************************************************************/
92 1.1.1.4 christos
93 1.1.1.4 christos void
94 1.1.1.4 christos AcpiDmDisplayTargetPathname (
95 1.1.1.4 christos ACPI_PARSE_OBJECT *Op)
96 1.1.1.4 christos {
97 1.1.1.4 christos ACPI_PARSE_OBJECT *NextOp;
98 1.1.1.4 christos ACPI_PARSE_OBJECT *PrevOp = NULL;
99 1.1.1.4 christos char *Pathname;
100 1.1.1.4 christos const ACPI_OPCODE_INFO *OpInfo;
101 1.1.1.4 christos
102 1.1.1.4 christos
103 1.1.1.4 christos if (Op->Common.AmlOpcode == AML_RETURN_OP)
104 1.1.1.4 christos {
105 1.1.1.4 christos PrevOp = Op->Asl.Value.Arg;
106 1.1.1.4 christos }
107 1.1.1.4 christos else
108 1.1.1.4 christos {
109 1.1.1.4 christos OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
110 1.1.1.4 christos if (!(OpInfo->Flags & AML_HAS_TARGET))
111 1.1.1.4 christos {
112 1.1.1.4 christos return;
113 1.1.1.4 christos }
114 1.1.1.4 christos
115 1.1.1.4 christos /* Target is the last Op in the arg list */
116 1.1.1.4 christos
117 1.1.1.4 christos NextOp = Op->Asl.Value.Arg;
118 1.1.1.4 christos while (NextOp)
119 1.1.1.4 christos {
120 1.1.1.4 christos PrevOp = NextOp;
121 1.1.1.4 christos NextOp = PrevOp->Asl.Next;
122 1.1.1.4 christos }
123 1.1.1.4 christos }
124 1.1.1.4 christos
125 1.1.1.4 christos if (!PrevOp)
126 1.1.1.4 christos {
127 1.1.1.4 christos return;
128 1.1.1.4 christos }
129 1.1.1.4 christos
130 1.1.1.4 christos /* We must have a namepath AML opcode */
131 1.1.1.4 christos
132 1.1.1.4 christos if (PrevOp->Asl.AmlOpcode != AML_INT_NAMEPATH_OP)
133 1.1.1.4 christos {
134 1.1.1.4 christos return;
135 1.1.1.4 christos }
136 1.1.1.4 christos
137 1.1.1.4 christos /* A null string is the "no target specified" case */
138 1.1.1.4 christos
139 1.1.1.4 christos if (!PrevOp->Asl.Value.String)
140 1.1.1.4 christos {
141 1.1.1.4 christos return;
142 1.1.1.4 christos }
143 1.1.1.4 christos
144 1.1.1.4 christos /* No node means "unresolved external reference" */
145 1.1.1.4 christos
146 1.1.1.4 christos if (!PrevOp->Asl.Node)
147 1.1.1.4 christos {
148 1.1.1.4 christos AcpiOsPrintf (" /* External reference */");
149 1.1.1.4 christos return;
150 1.1.1.4 christos }
151 1.1.1.4 christos
152 1.1.1.4 christos /* Ignore if path is already from the root */
153 1.1.1.4 christos
154 1.1.1.4 christos if (*PrevOp->Asl.Value.String == '\\')
155 1.1.1.4 christos {
156 1.1.1.4 christos return;
157 1.1.1.4 christos }
158 1.1.1.4 christos
159 1.1.1.4 christos /* Now: we can get the full pathname */
160 1.1.1.4 christos
161 1.1.1.4 christos Pathname = AcpiNsGetExternalPathname (PrevOp->Asl.Node);
162 1.1.1.4 christos if (!Pathname)
163 1.1.1.4 christos {
164 1.1.1.4 christos return;
165 1.1.1.4 christos }
166 1.1.1.4 christos
167 1.1.1.4 christos AcpiOsPrintf (" /* %s */", Pathname);
168 1.1.1.4 christos ACPI_FREE (Pathname);
169 1.1.1.4 christos }
170 1.1.1.4 christos
171 1.1.1.4 christos
172 1.1.1.4 christos /*******************************************************************************
173 1.1.1.4 christos *
174 1.1.1.4 christos * FUNCTION: AcpiDmNotifyDescription
175 1.1.1.4 christos *
176 1.1.1.4 christos * PARAMETERS: Op - Name() parse object
177 1.1.1.4 christos *
178 1.1.1.4 christos * RETURN: None
179 1.1.1.4 christos *
180 1.1.1.4 christos * DESCRIPTION: Emit a description comment for the value associated with a
181 1.1.1.4 christos * Notify() operator.
182 1.1.1.4 christos *
183 1.1.1.4 christos ******************************************************************************/
184 1.1.1.4 christos
185 1.1.1.4 christos void
186 1.1.1.4 christos AcpiDmNotifyDescription (
187 1.1.1.4 christos ACPI_PARSE_OBJECT *Op)
188 1.1.1.4 christos {
189 1.1.1.4 christos ACPI_PARSE_OBJECT *NextOp;
190 1.1.1.4 christos ACPI_NAMESPACE_NODE *Node;
191 1.1.1.4 christos UINT8 NotifyValue;
192 1.1.1.4 christos UINT8 Type = ACPI_TYPE_ANY;
193 1.1.1.4 christos
194 1.1.1.4 christos
195 1.1.1.4 christos /* The notify value is the second argument */
196 1.1.1.4 christos
197 1.1.1.4 christos NextOp = Op->Asl.Value.Arg;
198 1.1.1.4 christos NextOp = NextOp->Asl.Next;
199 1.1.1.4 christos
200 1.1.1.4 christos switch (NextOp->Common.AmlOpcode)
201 1.1.1.4 christos {
202 1.1.1.4 christos case AML_ZERO_OP:
203 1.1.1.4 christos case AML_ONE_OP:
204 1.1.1.4 christos
205 1.1.1.4 christos NotifyValue = (UINT8) NextOp->Common.AmlOpcode;
206 1.1.1.4 christos break;
207 1.1.1.4 christos
208 1.1.1.4 christos case AML_BYTE_OP:
209 1.1.1.4 christos
210 1.1.1.4 christos NotifyValue = (UINT8) NextOp->Asl.Value.Integer;
211 1.1.1.4 christos break;
212 1.1.1.4 christos
213 1.1.1.4 christos default:
214 1.1.1.4 christos return;
215 1.1.1.4 christos }
216 1.1.1.4 christos
217 1.1.1.4 christos /*
218 1.1.1.4 christos * Attempt to get the namespace node so we can determine the object type.
219 1.1.1.4 christos * Some notify values are dependent on the object type (Device, Thermal,
220 1.1.1.4 christos * or Processor).
221 1.1.1.4 christos */
222 1.1.1.4 christos Node = Op->Asl.Node;
223 1.1.1.4 christos if (Node)
224 1.1.1.4 christos {
225 1.1.1.4 christos Type = Node->Type;
226 1.1.1.4 christos }
227 1.1.1.4 christos
228 1.1.1.4 christos AcpiOsPrintf (" // %s", AcpiUtGetNotifyName (NotifyValue, Type));
229 1.1.1.4 christos }
230 1.1.1.4 christos
231 1.1.1.4 christos
232 1.1.1.4 christos /*******************************************************************************
233 1.1.1.4 christos *
234 1.1.1.3 christos * FUNCTION: AcpiDmPredefinedDescription
235 1.1.1.3 christos *
236 1.1.1.3 christos * PARAMETERS: Op - Name() parse object
237 1.1.1.3 christos *
238 1.1.1.3 christos * RETURN: None
239 1.1.1.3 christos *
240 1.1.1.3 christos * DESCRIPTION: Emit a description comment for a predefined ACPI name.
241 1.1.1.3 christos * Used for iASL compiler only.
242 1.1.1.3 christos *
243 1.1.1.3 christos ******************************************************************************/
244 1.1.1.3 christos
245 1.1.1.3 christos void
246 1.1.1.3 christos AcpiDmPredefinedDescription (
247 1.1.1.3 christos ACPI_PARSE_OBJECT *Op)
248 1.1.1.3 christos {
249 1.1.1.3 christos #ifdef ACPI_ASL_COMPILER
250 1.1.1.3 christos const AH_PREDEFINED_NAME *Info;
251 1.1.1.3 christos char *NameString;
252 1.1.1.3 christos int LastCharIsDigit;
253 1.1.1.3 christos int LastCharsAreHex;
254 1.1.1.3 christos
255 1.1.1.3 christos
256 1.1.1.3 christos if (!Op)
257 1.1.1.3 christos {
258 1.1.1.3 christos return;
259 1.1.1.3 christos }
260 1.1.1.3 christos
261 1.1.1.3 christos /* Ensure that the comment field is emitted only once */
262 1.1.1.3 christos
263 1.1.1.8 christos if (Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEFINED_CHECKED)
264 1.1.1.3 christos {
265 1.1.1.3 christos return;
266 1.1.1.3 christos }
267 1.1.1.8 christos Op->Common.DisasmFlags |= ACPI_PARSEOP_PREDEFINED_CHECKED;
268 1.1.1.3 christos
269 1.1.1.3 christos /* Predefined name must start with an underscore */
270 1.1.1.3 christos
271 1.1.1.3 christos NameString = ACPI_CAST_PTR (char, &Op->Named.Name);
272 1.1.1.3 christos if (NameString[0] != '_')
273 1.1.1.3 christos {
274 1.1.1.3 christos return;
275 1.1.1.3 christos }
276 1.1.1.3 christos
277 1.1.1.3 christos /*
278 1.1.1.3 christos * Check for the special ACPI names:
279 1.1.1.3 christos * _ACd, _ALd, _EJd, _Exx, _Lxx, _Qxx, _Wxx, _T_a
280 1.1.1.3 christos * (where d=decimal_digit, x=hex_digit, a=anything)
281 1.1.1.3 christos *
282 1.1.1.3 christos * Convert these to the generic name for table lookup.
283 1.1.1.3 christos * Note: NameString is guaranteed to be upper case here.
284 1.1.1.3 christos */
285 1.1.1.3 christos LastCharIsDigit =
286 1.1.1.6 christos (isdigit ((int) NameString[3])); /* d */
287 1.1.1.3 christos LastCharsAreHex =
288 1.1.1.6 christos (isxdigit ((int) NameString[2]) && /* xx */
289 1.1.1.6 christos isxdigit ((int) NameString[3]));
290 1.1.1.3 christos
291 1.1.1.3 christos switch (NameString[1])
292 1.1.1.3 christos {
293 1.1.1.3 christos case 'A':
294 1.1.1.3 christos
295 1.1.1.3 christos if ((NameString[2] == 'C') && (LastCharIsDigit))
296 1.1.1.3 christos {
297 1.1.1.3 christos NameString = "_ACx";
298 1.1.1.3 christos }
299 1.1.1.3 christos else if ((NameString[2] == 'L') && (LastCharIsDigit))
300 1.1.1.3 christos {
301 1.1.1.3 christos NameString = "_ALx";
302 1.1.1.3 christos }
303 1.1.1.3 christos break;
304 1.1.1.3 christos
305 1.1.1.3 christos case 'E':
306 1.1.1.3 christos
307 1.1.1.3 christos if ((NameString[2] == 'J') && (LastCharIsDigit))
308 1.1.1.3 christos {
309 1.1.1.3 christos NameString = "_EJx";
310 1.1.1.3 christos }
311 1.1.1.3 christos else if (LastCharsAreHex)
312 1.1.1.3 christos {
313 1.1.1.3 christos NameString = "_Exx";
314 1.1.1.3 christos }
315 1.1.1.3 christos break;
316 1.1.1.3 christos
317 1.1.1.3 christos case 'L':
318 1.1.1.3 christos
319 1.1.1.3 christos if (LastCharsAreHex)
320 1.1.1.3 christos {
321 1.1.1.3 christos NameString = "_Lxx";
322 1.1.1.3 christos }
323 1.1.1.3 christos break;
324 1.1.1.3 christos
325 1.1.1.3 christos case 'Q':
326 1.1.1.3 christos
327 1.1.1.3 christos if (LastCharsAreHex)
328 1.1.1.3 christos {
329 1.1.1.3 christos NameString = "_Qxx";
330 1.1.1.3 christos }
331 1.1.1.3 christos break;
332 1.1.1.3 christos
333 1.1.1.3 christos case 'T':
334 1.1.1.3 christos
335 1.1.1.3 christos if (NameString[2] == '_')
336 1.1.1.3 christos {
337 1.1.1.3 christos NameString = "_T_x";
338 1.1.1.3 christos }
339 1.1.1.3 christos break;
340 1.1.1.3 christos
341 1.1.1.3 christos case 'W':
342 1.1.1.3 christos
343 1.1.1.3 christos if (LastCharsAreHex)
344 1.1.1.3 christos {
345 1.1.1.3 christos NameString = "_Wxx";
346 1.1.1.3 christos }
347 1.1.1.3 christos break;
348 1.1.1.3 christos
349 1.1.1.3 christos default:
350 1.1.1.3 christos
351 1.1.1.3 christos break;
352 1.1.1.3 christos }
353 1.1.1.3 christos
354 1.1.1.3 christos /* Match the name in the info table */
355 1.1.1.3 christos
356 1.1.1.4 christos Info = AcpiAhMatchPredefinedName (NameString);
357 1.1.1.4 christos if (Info)
358 1.1.1.3 christos {
359 1.1.1.4 christos AcpiOsPrintf (" // %4.4s: %s",
360 1.1.1.4 christos NameString, ACPI_CAST_PTR (char, Info->Description));
361 1.1.1.3 christos }
362 1.1.1.3 christos
363 1.1.1.3 christos #endif
364 1.1.1.3 christos return;
365 1.1.1.3 christos }
366 1.1.1.3 christos
367 1.1.1.3 christos
368 1.1.1.3 christos /*******************************************************************************
369 1.1.1.3 christos *
370 1.1.1.3 christos * FUNCTION: AcpiDmFieldPredefinedDescription
371 1.1.1.3 christos *
372 1.1.1.3 christos * PARAMETERS: Op - Parse object
373 1.1.1.3 christos *
374 1.1.1.3 christos * RETURN: None
375 1.1.1.3 christos *
376 1.1.1.3 christos * DESCRIPTION: Emit a description comment for a resource descriptor tag
377 1.1.1.3 christos * (which is a predefined ACPI name.) Used for iASL compiler only.
378 1.1.1.3 christos *
379 1.1.1.3 christos ******************************************************************************/
380 1.1.1.3 christos
381 1.1.1.3 christos void
382 1.1.1.3 christos AcpiDmFieldPredefinedDescription (
383 1.1.1.3 christos ACPI_PARSE_OBJECT *Op)
384 1.1.1.3 christos {
385 1.1.1.3 christos #ifdef ACPI_ASL_COMPILER
386 1.1.1.3 christos ACPI_PARSE_OBJECT *IndexOp;
387 1.1.1.3 christos char *Tag;
388 1.1.1.3 christos const ACPI_OPCODE_INFO *OpInfo;
389 1.1.1.3 christos const AH_PREDEFINED_NAME *Info;
390 1.1.1.3 christos
391 1.1.1.3 christos
392 1.1.1.3 christos if (!Op)
393 1.1.1.3 christos {
394 1.1.1.3 christos return;
395 1.1.1.3 christos }
396 1.1.1.3 christos
397 1.1.1.3 christos /* Ensure that the comment field is emitted only once */
398 1.1.1.3 christos
399 1.1.1.8 christos if (Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEFINED_CHECKED)
400 1.1.1.3 christos {
401 1.1.1.3 christos return;
402 1.1.1.3 christos }
403 1.1.1.8 christos Op->Common.DisasmFlags |= ACPI_PARSEOP_PREDEFINED_CHECKED;
404 1.1.1.3 christos
405 1.1.1.3 christos /*
406 1.1.1.3 christos * Op must be one of the Create* operators: CreateField, CreateBitField,
407 1.1.1.3 christos * CreateByteField, CreateWordField, CreateDwordField, CreateQwordField
408 1.1.1.3 christos */
409 1.1.1.3 christos OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
410 1.1.1.3 christos if (!(OpInfo->Flags & AML_CREATE))
411 1.1.1.3 christos {
412 1.1.1.3 christos return;
413 1.1.1.3 christos }
414 1.1.1.3 christos
415 1.1.1.3 christos /* Second argument is the Index argument */
416 1.1.1.3 christos
417 1.1.1.3 christos IndexOp = Op->Common.Value.Arg;
418 1.1.1.3 christos IndexOp = IndexOp->Common.Next;
419 1.1.1.3 christos
420 1.1.1.3 christos /* Index argument must be a namepath */
421 1.1.1.3 christos
422 1.1.1.3 christos if (IndexOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP)
423 1.1.1.3 christos {
424 1.1.1.3 christos return;
425 1.1.1.3 christos }
426 1.1.1.3 christos
427 1.1.1.3 christos /* Major cheat: We previously put the Tag ptr in the Node field */
428 1.1.1.3 christos
429 1.1.1.3 christos Tag = ACPI_CAST_PTR (char, IndexOp->Common.Node);
430 1.1.1.3 christos if (!Tag)
431 1.1.1.3 christos {
432 1.1.1.3 christos return;
433 1.1.1.3 christos }
434 1.1.1.3 christos
435 1.1.1.3 christos /* Match the name in the info table */
436 1.1.1.3 christos
437 1.1.1.4 christos Info = AcpiAhMatchPredefinedName (Tag);
438 1.1.1.4 christos if (Info)
439 1.1.1.3 christos {
440 1.1.1.4 christos AcpiOsPrintf (" // %4.4s: %s", Tag,
441 1.1.1.4 christos ACPI_CAST_PTR (char, Info->Description));
442 1.1.1.3 christos }
443 1.1.1.3 christos
444 1.1.1.3 christos #endif
445 1.1.1.3 christos return;
446 1.1.1.3 christos }
447 1.1.1.3 christos
448 1.1.1.3 christos
449 1.1.1.3 christos /*******************************************************************************
450 1.1.1.3 christos *
451 1.1 jruoho * FUNCTION: AcpiDmMethodFlags
452 1.1 jruoho *
453 1.1 jruoho * PARAMETERS: Op - Method Object to be examined
454 1.1 jruoho *
455 1.1 jruoho * RETURN: None
456 1.1 jruoho *
457 1.1 jruoho * DESCRIPTION: Decode control method flags
458 1.1 jruoho *
459 1.1 jruoho ******************************************************************************/
460 1.1 jruoho
461 1.1 jruoho void
462 1.1 jruoho AcpiDmMethodFlags (
463 1.1 jruoho ACPI_PARSE_OBJECT *Op)
464 1.1 jruoho {
465 1.1 jruoho UINT32 Flags;
466 1.1 jruoho UINT32 Args;
467 1.1 jruoho
468 1.1 jruoho
469 1.1 jruoho /* The next Op contains the flags */
470 1.1 jruoho
471 1.1 jruoho Op = AcpiPsGetDepthNext (NULL, Op);
472 1.1 jruoho Flags = (UINT8) Op->Common.Value.Integer;
473 1.1 jruoho Args = Flags & 0x07;
474 1.1 jruoho
475 1.1 jruoho /* Mark the Op as completed */
476 1.1 jruoho
477 1.1 jruoho Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
478 1.1 jruoho
479 1.1 jruoho /* 1) Method argument count */
480 1.1 jruoho
481 1.1 jruoho AcpiOsPrintf (", %u, ", Args);
482 1.1 jruoho
483 1.1 jruoho /* 2) Serialize rule */
484 1.1 jruoho
485 1.1 jruoho if (!(Flags & 0x08))
486 1.1 jruoho {
487 1.1 jruoho AcpiOsPrintf ("Not");
488 1.1 jruoho }
489 1.1 jruoho
490 1.1 jruoho AcpiOsPrintf ("Serialized");
491 1.1 jruoho
492 1.1 jruoho /* 3) SyncLevel */
493 1.1 jruoho
494 1.1 jruoho if (Flags & 0xF0)
495 1.1 jruoho {
496 1.1 jruoho AcpiOsPrintf (", %u", Flags >> 4);
497 1.1 jruoho }
498 1.1 jruoho }
499 1.1 jruoho
500 1.1 jruoho
501 1.1 jruoho /*******************************************************************************
502 1.1 jruoho *
503 1.1 jruoho * FUNCTION: AcpiDmFieldFlags
504 1.1 jruoho *
505 1.1 jruoho * PARAMETERS: Op - Field Object to be examined
506 1.1 jruoho *
507 1.1 jruoho * RETURN: None
508 1.1 jruoho *
509 1.1 jruoho * DESCRIPTION: Decode Field definition flags
510 1.1 jruoho *
511 1.1 jruoho ******************************************************************************/
512 1.1 jruoho
513 1.1 jruoho void
514 1.1 jruoho AcpiDmFieldFlags (
515 1.1 jruoho ACPI_PARSE_OBJECT *Op)
516 1.1 jruoho {
517 1.1 jruoho UINT32 Flags;
518 1.1 jruoho
519 1.1 jruoho
520 1.1 jruoho Op = Op->Common.Next;
521 1.1 jruoho Flags = (UINT8) Op->Common.Value.Integer;
522 1.1 jruoho
523 1.1 jruoho /* Mark the Op as completed */
524 1.1 jruoho
525 1.1 jruoho Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
526 1.1 jruoho
527 1.1 jruoho AcpiOsPrintf ("%s, ", AcpiGbl_AccessTypes [Flags & 0x07]);
528 1.1 jruoho AcpiOsPrintf ("%s, ", AcpiGbl_LockRule [(Flags & 0x10) >> 4]);
529 1.1 jruoho AcpiOsPrintf ("%s)", AcpiGbl_UpdateRules [(Flags & 0x60) >> 5]);
530 1.1 jruoho }
531 1.1 jruoho
532 1.1 jruoho
533 1.1 jruoho /*******************************************************************************
534 1.1 jruoho *
535 1.1 jruoho * FUNCTION: AcpiDmAddressSpace
536 1.1 jruoho *
537 1.1 jruoho * PARAMETERS: SpaceId - ID to be translated
538 1.1 jruoho *
539 1.1 jruoho * RETURN: None
540 1.1 jruoho *
541 1.1 jruoho * DESCRIPTION: Decode a SpaceId to an AddressSpaceKeyword
542 1.1 jruoho *
543 1.1 jruoho ******************************************************************************/
544 1.1 jruoho
545 1.1 jruoho void
546 1.1 jruoho AcpiDmAddressSpace (
547 1.1 jruoho UINT8 SpaceId)
548 1.1 jruoho {
549 1.1 jruoho
550 1.1 jruoho if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
551 1.1 jruoho {
552 1.1 jruoho if (SpaceId == 0x7F)
553 1.1 jruoho {
554 1.1 jruoho AcpiOsPrintf ("FFixedHW, ");
555 1.1 jruoho }
556 1.1 jruoho else
557 1.1 jruoho {
558 1.1 jruoho AcpiOsPrintf ("0x%.2X, ", SpaceId);
559 1.1 jruoho }
560 1.1 jruoho }
561 1.1 jruoho else
562 1.1 jruoho {
563 1.1 jruoho AcpiOsPrintf ("%s, ", AcpiGbl_RegionTypes [SpaceId]);
564 1.1 jruoho }
565 1.1 jruoho }
566 1.1 jruoho
567 1.1 jruoho
568 1.1 jruoho /*******************************************************************************
569 1.1 jruoho *
570 1.1 jruoho * FUNCTION: AcpiDmRegionFlags
571 1.1 jruoho *
572 1.1 jruoho * PARAMETERS: Op - Object to be examined
573 1.1 jruoho *
574 1.1 jruoho * RETURN: None
575 1.1 jruoho *
576 1.1 jruoho * DESCRIPTION: Decode OperationRegion flags
577 1.1 jruoho *
578 1.1 jruoho ******************************************************************************/
579 1.1 jruoho
580 1.1 jruoho void
581 1.1 jruoho AcpiDmRegionFlags (
582 1.1 jruoho ACPI_PARSE_OBJECT *Op)
583 1.1 jruoho {
584 1.1 jruoho
585 1.1 jruoho /* The next Op contains the SpaceId */
586 1.1 jruoho
587 1.1 jruoho Op = AcpiPsGetDepthNext (NULL, Op);
588 1.1 jruoho
589 1.1 jruoho /* Mark the Op as completed */
590 1.1 jruoho
591 1.1 jruoho Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
592 1.1 jruoho
593 1.1 jruoho AcpiOsPrintf (", ");
594 1.1 jruoho AcpiDmAddressSpace ((UINT8) Op->Common.Value.Integer);
595 1.1 jruoho }
596 1.1 jruoho
597 1.1 jruoho
598 1.1 jruoho /*******************************************************************************
599 1.1 jruoho *
600 1.1 jruoho * FUNCTION: AcpiDmMatchOp
601 1.1 jruoho *
602 1.1 jruoho * PARAMETERS: Op - Match Object to be examined
603 1.1 jruoho *
604 1.1 jruoho * RETURN: None
605 1.1 jruoho *
606 1.1 jruoho * DESCRIPTION: Decode Match opcode operands
607 1.1 jruoho *
608 1.1 jruoho ******************************************************************************/
609 1.1 jruoho
610 1.1 jruoho void
611 1.1 jruoho AcpiDmMatchOp (
612 1.1 jruoho ACPI_PARSE_OBJECT *Op)
613 1.1 jruoho {
614 1.1 jruoho ACPI_PARSE_OBJECT *NextOp;
615 1.1 jruoho
616 1.1 jruoho
617 1.1 jruoho NextOp = AcpiPsGetDepthNext (NULL, Op);
618 1.1 jruoho NextOp = NextOp->Common.Next;
619 1.1 jruoho
620 1.1 jruoho if (!NextOp)
621 1.1 jruoho {
622 1.1 jruoho /* Handle partial tree during single-step */
623 1.1 jruoho
624 1.1 jruoho return;
625 1.1 jruoho }
626 1.1 jruoho
627 1.1 jruoho /* Mark the two nodes that contain the encoding for the match keywords */
628 1.1 jruoho
629 1.1 jruoho NextOp->Common.DisasmOpcode = ACPI_DASM_MATCHOP;
630 1.1 jruoho
631 1.1 jruoho NextOp = NextOp->Common.Next;
632 1.1 jruoho NextOp = NextOp->Common.Next;
633 1.1 jruoho NextOp->Common.DisasmOpcode = ACPI_DASM_MATCHOP;
634 1.1 jruoho }
635 1.1 jruoho
636 1.1 jruoho
637 1.1 jruoho /*******************************************************************************
638 1.1 jruoho *
639 1.1 jruoho * FUNCTION: AcpiDmMatchKeyword
640 1.1 jruoho *
641 1.1 jruoho * PARAMETERS: Op - Match Object to be examined
642 1.1 jruoho *
643 1.1 jruoho * RETURN: None
644 1.1 jruoho *
645 1.1 jruoho * DESCRIPTION: Decode Match opcode operands
646 1.1 jruoho *
647 1.1 jruoho ******************************************************************************/
648 1.1 jruoho
649 1.1 jruoho static void
650 1.1 jruoho AcpiDmMatchKeyword (
651 1.1 jruoho ACPI_PARSE_OBJECT *Op)
652 1.1 jruoho {
653 1.1 jruoho
654 1.1 jruoho if (((UINT32) Op->Common.Value.Integer) > ACPI_MAX_MATCH_OPCODE)
655 1.1 jruoho {
656 1.1 jruoho AcpiOsPrintf ("/* Unknown Match Keyword encoding */");
657 1.1 jruoho }
658 1.1 jruoho else
659 1.1 jruoho {
660 1.1.1.8 christos AcpiOsPrintf ("%s",
661 1.1.1.8 christos AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer]);
662 1.1 jruoho }
663 1.1 jruoho }
664 1.1 jruoho
665 1.1 jruoho
666 1.1 jruoho /*******************************************************************************
667 1.1 jruoho *
668 1.1 jruoho * FUNCTION: AcpiDmDisassembleOneOp
669 1.1 jruoho *
670 1.1 jruoho * PARAMETERS: WalkState - Current walk info
671 1.1 jruoho * Info - Parse tree walk info
672 1.1 jruoho * Op - Op that is to be printed
673 1.1 jruoho *
674 1.1 jruoho * RETURN: None
675 1.1 jruoho *
676 1.1 jruoho * DESCRIPTION: Disassemble a single AML opcode
677 1.1 jruoho *
678 1.1 jruoho ******************************************************************************/
679 1.1 jruoho
680 1.1 jruoho void
681 1.1 jruoho AcpiDmDisassembleOneOp (
682 1.1 jruoho ACPI_WALK_STATE *WalkState,
683 1.1 jruoho ACPI_OP_WALK_INFO *Info,
684 1.1 jruoho ACPI_PARSE_OBJECT *Op)
685 1.1 jruoho {
686 1.1 jruoho const ACPI_OPCODE_INFO *OpInfo = NULL;
687 1.1 jruoho UINT32 Offset;
688 1.1 jruoho UINT32 Length;
689 1.1 jruoho ACPI_PARSE_OBJECT *Child;
690 1.1 jruoho ACPI_STATUS Status;
691 1.1.1.3 christos UINT8 *Aml;
692 1.1.1.4 christos const AH_DEVICE_ID *IdInfo;
693 1.1 jruoho
694 1.1 jruoho
695 1.1 jruoho if (!Op)
696 1.1 jruoho {
697 1.1 jruoho AcpiOsPrintf ("<NULL OP PTR>");
698 1.1 jruoho return;
699 1.1 jruoho }
700 1.1 jruoho
701 1.1.1.7 christos if (Op->Common.DisasmFlags & ACPI_PARSEOP_ELSEIF)
702 1.1.1.7 christos {
703 1.1.1.7 christos return; /* ElseIf macro was already emitted */
704 1.1.1.7 christos }
705 1.1.1.7 christos
706 1.1 jruoho switch (Op->Common.DisasmOpcode)
707 1.1 jruoho {
708 1.1 jruoho case ACPI_DASM_MATCHOP:
709 1.1 jruoho
710 1.1 jruoho AcpiDmMatchKeyword (Op);
711 1.1 jruoho return;
712 1.1 jruoho
713 1.1 jruoho case ACPI_DASM_LNOT_SUFFIX:
714 1.1.1.3 christos
715 1.1.1.5 christos if (!AcpiGbl_CstyleDisassembly)
716 1.1 jruoho {
717 1.1.1.5 christos switch (Op->Common.AmlOpcode)
718 1.1.1.5 christos {
719 1.1.1.5 christos case AML_LEQUAL_OP:
720 1.1.1.5 christos AcpiOsPrintf ("LNotEqual");
721 1.1.1.5 christos break;
722 1.1.1.3 christos
723 1.1.1.5 christos case AML_LGREATER_OP:
724 1.1.1.5 christos AcpiOsPrintf ("LLessEqual");
725 1.1.1.5 christos break;
726 1.1 jruoho
727 1.1.1.5 christos case AML_LLESS_OP:
728 1.1.1.5 christos AcpiOsPrintf ("LGreaterEqual");
729 1.1.1.5 christos break;
730 1.1.1.3 christos
731 1.1.1.5 christos default:
732 1.1.1.5 christos break;
733 1.1.1.5 christos }
734 1.1 jruoho }
735 1.1.1.5 christos
736 1.1 jruoho Op->Common.DisasmOpcode = 0;
737 1.1 jruoho Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
738 1.1 jruoho return;
739 1.1 jruoho
740 1.1 jruoho default:
741 1.1 jruoho break;
742 1.1 jruoho }
743 1.1 jruoho
744 1.1 jruoho OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
745 1.1 jruoho
746 1.1 jruoho /* The op and arguments */
747 1.1 jruoho
748 1.1 jruoho switch (Op->Common.AmlOpcode)
749 1.1 jruoho {
750 1.1 jruoho case AML_LNOT_OP:
751 1.1 jruoho
752 1.1 jruoho Child = Op->Common.Value.Arg;
753 1.1 jruoho if ((Child->Common.AmlOpcode == AML_LEQUAL_OP) ||
754 1.1 jruoho (Child->Common.AmlOpcode == AML_LGREATER_OP) ||
755 1.1 jruoho (Child->Common.AmlOpcode == AML_LLESS_OP))
756 1.1 jruoho {
757 1.1 jruoho Child->Common.DisasmOpcode = ACPI_DASM_LNOT_SUFFIX;
758 1.1 jruoho Op->Common.DisasmOpcode = ACPI_DASM_LNOT_PREFIX;
759 1.1 jruoho }
760 1.1 jruoho else
761 1.1 jruoho {
762 1.1 jruoho AcpiOsPrintf ("%s", OpInfo->Name);
763 1.1 jruoho }
764 1.1 jruoho break;
765 1.1 jruoho
766 1.1 jruoho case AML_BYTE_OP:
767 1.1 jruoho
768 1.1 jruoho AcpiOsPrintf ("0x%2.2X", (UINT32) Op->Common.Value.Integer);
769 1.1 jruoho break;
770 1.1 jruoho
771 1.1 jruoho case AML_WORD_OP:
772 1.1 jruoho
773 1.1 jruoho if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID)
774 1.1 jruoho {
775 1.1.1.4 christos AcpiDmDecompressEisaId ((UINT32) Op->Common.Value.Integer);
776 1.1 jruoho }
777 1.1 jruoho else
778 1.1 jruoho {
779 1.1 jruoho AcpiOsPrintf ("0x%4.4X", (UINT32) Op->Common.Value.Integer);
780 1.1 jruoho }
781 1.1 jruoho break;
782 1.1 jruoho
783 1.1 jruoho case AML_DWORD_OP:
784 1.1 jruoho
785 1.1 jruoho if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID)
786 1.1 jruoho {
787 1.1.1.4 christos AcpiDmDecompressEisaId ((UINT32) Op->Common.Value.Integer);
788 1.1 jruoho }
789 1.1 jruoho else
790 1.1 jruoho {
791 1.1 jruoho AcpiOsPrintf ("0x%8.8X", (UINT32) Op->Common.Value.Integer);
792 1.1 jruoho }
793 1.1 jruoho break;
794 1.1 jruoho
795 1.1 jruoho case AML_QWORD_OP:
796 1.1 jruoho
797 1.1 jruoho AcpiOsPrintf ("0x%8.8X%8.8X",
798 1.1 jruoho ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
799 1.1 jruoho break;
800 1.1 jruoho
801 1.1 jruoho case AML_STRING_OP:
802 1.1 jruoho
803 1.1.1.3 christos AcpiUtPrintString (Op->Common.Value.String, ACPI_UINT16_MAX);
804 1.1.1.4 christos
805 1.1.1.4 christos /* For _HID/_CID strings, attempt to output a descriptive comment */
806 1.1.1.4 christos
807 1.1.1.4 christos if (Op->Common.DisasmOpcode == ACPI_DASM_HID_STRING)
808 1.1.1.4 christos {
809 1.1.1.4 christos /* If we know about the ID, emit the description */
810 1.1.1.4 christos
811 1.1.1.4 christos IdInfo = AcpiAhMatchHardwareId (Op->Common.Value.String);
812 1.1.1.4 christos if (IdInfo)
813 1.1.1.4 christos {
814 1.1.1.4 christos AcpiOsPrintf (" /* %s */", IdInfo->Description);
815 1.1.1.4 christos }
816 1.1.1.4 christos }
817 1.1 jruoho break;
818 1.1 jruoho
819 1.1 jruoho case AML_BUFFER_OP:
820 1.1 jruoho /*
821 1.1.1.3 christos * Determine the type of buffer. We can have one of the following:
822 1.1 jruoho *
823 1.1 jruoho * 1) ResourceTemplate containing Resource Descriptors.
824 1.1 jruoho * 2) Unicode String buffer
825 1.1 jruoho * 3) ASCII String buffer
826 1.1 jruoho * 4) Raw data buffer (if none of the above)
827 1.1 jruoho *
828 1.1 jruoho * Since there are no special AML opcodes to differentiate these
829 1.1 jruoho * types of buffers, we have to closely look at the data in the
830 1.1 jruoho * buffer to determine the type.
831 1.1 jruoho */
832 1.1.1.3 christos if (!AcpiGbl_NoResourceDisassembly)
833 1.1 jruoho {
834 1.1.1.3 christos Status = AcpiDmIsResourceTemplate (WalkState, Op);
835 1.1.1.3 christos if (ACPI_SUCCESS (Status))
836 1.1.1.3 christos {
837 1.1.1.3 christos Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE;
838 1.1.1.3 christos AcpiOsPrintf ("ResourceTemplate");
839 1.1.1.3 christos break;
840 1.1.1.3 christos }
841 1.1.1.3 christos else if (Status == AE_AML_NO_RESOURCE_END_TAG)
842 1.1.1.3 christos {
843 1.1.1.7 christos AcpiOsPrintf (
844 1.1.1.7 christos "/**** Is ResourceTemplate, "
845 1.1.1.7 christos "but EndTag not at buffer end ****/ ");
846 1.1.1.3 christos }
847 1.1 jruoho }
848 1.1 jruoho
849 1.1.1.4 christos if (AcpiDmIsUuidBuffer (Op))
850 1.1.1.4 christos {
851 1.1.1.4 christos Op->Common.DisasmOpcode = ACPI_DASM_UUID;
852 1.1.1.4 christos AcpiOsPrintf ("ToUUID (");
853 1.1.1.4 christos }
854 1.1.1.4 christos else if (AcpiDmIsUnicodeBuffer (Op))
855 1.1 jruoho {
856 1.1 jruoho Op->Common.DisasmOpcode = ACPI_DASM_UNICODE;
857 1.1 jruoho AcpiOsPrintf ("Unicode (");
858 1.1 jruoho }
859 1.1 jruoho else if (AcpiDmIsStringBuffer (Op))
860 1.1 jruoho {
861 1.1 jruoho Op->Common.DisasmOpcode = ACPI_DASM_STRING;
862 1.1 jruoho AcpiOsPrintf ("Buffer");
863 1.1 jruoho }
864 1.1.1.3 christos else if (AcpiDmIsPldBuffer (Op))
865 1.1.1.3 christos {
866 1.1.1.3 christos Op->Common.DisasmOpcode = ACPI_DASM_PLD_METHOD;
867 1.1.1.5 christos AcpiOsPrintf ("ToPLD (");
868 1.1.1.3 christos }
869 1.1 jruoho else
870 1.1 jruoho {
871 1.1 jruoho Op->Common.DisasmOpcode = ACPI_DASM_BUFFER;
872 1.1 jruoho AcpiOsPrintf ("Buffer");
873 1.1 jruoho }
874 1.1 jruoho break;
875 1.1 jruoho
876 1.1 jruoho case AML_INT_NAMEPATH_OP:
877 1.1 jruoho
878 1.1 jruoho AcpiDmNamestring (Op->Common.Value.Name);
879 1.1 jruoho break;
880 1.1 jruoho
881 1.1 jruoho case AML_INT_NAMEDFIELD_OP:
882 1.1 jruoho
883 1.1 jruoho Length = AcpiDmDumpName (Op->Named.Name);
884 1.1 jruoho AcpiOsPrintf (",%*.s %u", (unsigned) (5 - Length), " ",
885 1.1 jruoho (UINT32) Op->Common.Value.Integer);
886 1.1 jruoho AcpiDmCommaIfFieldMember (Op);
887 1.1 jruoho
888 1.1 jruoho Info->BitOffset += (UINT32) Op->Common.Value.Integer;
889 1.1 jruoho break;
890 1.1 jruoho
891 1.1 jruoho case AML_INT_RESERVEDFIELD_OP:
892 1.1 jruoho
893 1.1 jruoho /* Offset() -- Must account for previous offsets */
894 1.1 jruoho
895 1.1 jruoho Offset = (UINT32) Op->Common.Value.Integer;
896 1.1 jruoho Info->BitOffset += Offset;
897 1.1 jruoho
898 1.1 jruoho if (Info->BitOffset % 8 == 0)
899 1.1 jruoho {
900 1.1.1.3 christos AcpiOsPrintf ("Offset (0x%.2X)", ACPI_DIV_8 (Info->BitOffset));
901 1.1 jruoho }
902 1.1 jruoho else
903 1.1 jruoho {
904 1.1 jruoho AcpiOsPrintf (" , %u", Offset);
905 1.1 jruoho }
906 1.1 jruoho
907 1.1 jruoho AcpiDmCommaIfFieldMember (Op);
908 1.1 jruoho break;
909 1.1 jruoho
910 1.1 jruoho case AML_INT_ACCESSFIELD_OP:
911 1.1.1.3 christos case AML_INT_EXTACCESSFIELD_OP:
912 1.1.1.3 christos
913 1.1.1.3 christos AcpiOsPrintf ("AccessAs (%s, ",
914 1.1.1.3 christos AcpiGbl_AccessTypes [(UINT32) (Op->Common.Value.Integer & 0x7)]);
915 1.1.1.3 christos
916 1.1.1.3 christos AcpiDmDecodeAttribute ((UINT8) (Op->Common.Value.Integer >> 8));
917 1.1 jruoho
918 1.1.1.3 christos if (Op->Common.AmlOpcode == AML_INT_EXTACCESSFIELD_OP)
919 1.1.1.3 christos {
920 1.1.1.7 christos AcpiOsPrintf (" (0x%2.2X)", (unsigned)
921 1.1.1.7 christos ((Op->Common.Value.Integer >> 16) & 0xFF));
922 1.1.1.3 christos }
923 1.1 jruoho
924 1.1 jruoho AcpiOsPrintf (")");
925 1.1 jruoho AcpiDmCommaIfFieldMember (Op);
926 1.1 jruoho break;
927 1.1 jruoho
928 1.1.1.3 christos case AML_INT_CONNECTION_OP:
929 1.1.1.3 christos /*
930 1.1.1.3 christos * Two types of Connection() - one with a buffer object, the
931 1.1.1.3 christos * other with a namestring that points to a buffer object.
932 1.1.1.3 christos */
933 1.1.1.3 christos AcpiOsPrintf ("Connection (");
934 1.1.1.3 christos Child = Op->Common.Value.Arg;
935 1.1.1.3 christos
936 1.1.1.3 christos if (Child->Common.AmlOpcode == AML_INT_BYTELIST_OP)
937 1.1.1.3 christos {
938 1.1.1.3 christos AcpiOsPrintf ("\n");
939 1.1.1.3 christos
940 1.1.1.3 christos Aml = Child->Named.Data;
941 1.1.1.3 christos Length = (UINT32) Child->Common.Value.Integer;
942 1.1.1.3 christos
943 1.1.1.3 christos Info->Level += 1;
944 1.1.1.4 christos Info->MappingOp = Op;
945 1.1.1.3 christos Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE;
946 1.1.1.4 christos
947 1.1.1.3 christos AcpiDmResourceTemplate (Info, Op->Common.Parent, Aml, Length);
948 1.1.1.3 christos
949 1.1.1.3 christos Info->Level -= 1;
950 1.1.1.3 christos AcpiDmIndent (Info->Level);
951 1.1.1.3 christos }
952 1.1.1.3 christos else
953 1.1.1.3 christos {
954 1.1.1.3 christos AcpiDmNamestring (Child->Common.Value.Name);
955 1.1.1.3 christos }
956 1.1.1.3 christos
957 1.1.1.3 christos AcpiOsPrintf (")");
958 1.1.1.3 christos AcpiDmCommaIfFieldMember (Op);
959 1.1.1.3 christos AcpiOsPrintf ("\n");
960 1.1.1.3 christos
961 1.1.1.3 christos Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; /* for now, ignore in AcpiDmAscendingOp */
962 1.1.1.3 christos Child->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
963 1.1.1.3 christos break;
964 1.1 jruoho
965 1.1 jruoho case AML_INT_BYTELIST_OP:
966 1.1 jruoho
967 1.1 jruoho AcpiDmByteList (Info, Op);
968 1.1 jruoho break;
969 1.1 jruoho
970 1.1 jruoho case AML_INT_METHODCALL_OP:
971 1.1 jruoho
972 1.1 jruoho Op = AcpiPsGetDepthNext (NULL, Op);
973 1.1 jruoho Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
974 1.1 jruoho
975 1.1 jruoho AcpiDmNamestring (Op->Common.Value.Name);
976 1.1 jruoho break;
977 1.1 jruoho
978 1.1.1.10.2.1 bouyer case AML_WHILE_OP:
979 1.1.1.10.2.1 bouyer
980 1.1.1.10.2.1 bouyer if (AcpiDmIsSwitchBlock(Op))
981 1.1.1.10.2.1 bouyer {
982 1.1.1.10.2.1 bouyer AcpiOsPrintf ("%s", "Switch");
983 1.1.1.10.2.1 bouyer break;
984 1.1.1.10.2.1 bouyer }
985 1.1.1.10.2.1 bouyer
986 1.1.1.10.2.1 bouyer AcpiOsPrintf ("%s", OpInfo->Name);
987 1.1.1.10.2.1 bouyer break;
988 1.1.1.10.2.1 bouyer
989 1.1.1.10.2.1 bouyer case AML_IF_OP:
990 1.1.1.10.2.1 bouyer
991 1.1.1.10.2.1 bouyer if (Op->Common.DisasmOpcode == ACPI_DASM_CASE)
992 1.1.1.10.2.1 bouyer {
993 1.1.1.10.2.1 bouyer AcpiOsPrintf ("%s", "Case");
994 1.1.1.10.2.1 bouyer break;
995 1.1.1.10.2.1 bouyer }
996 1.1.1.10.2.1 bouyer
997 1.1.1.10.2.1 bouyer AcpiOsPrintf ("%s", OpInfo->Name);
998 1.1.1.10.2.1 bouyer break;
999 1.1.1.10.2.1 bouyer
1000 1.1.1.7 christos case AML_ELSE_OP:
1001 1.1.1.7 christos
1002 1.1.1.7 christos AcpiDmConvertToElseIf (Op);
1003 1.1.1.7 christos break;
1004 1.1.1.7 christos
1005 1.1.1.8 christos case AML_EXTERNAL_OP:
1006 1.1.1.8 christos
1007 1.1.1.9 christos if (AcpiGbl_DmEmitExternalOpcodes)
1008 1.1.1.9 christos {
1009 1.1.1.9 christos AcpiOsPrintf ("/* Opcode 0x15 */ ");
1010 1.1.1.9 christos
1011 1.1.1.9 christos /* Fallthrough */
1012 1.1.1.9 christos }
1013 1.1.1.9 christos else
1014 1.1.1.9 christos {
1015 1.1.1.9 christos break;
1016 1.1.1.9 christos }
1017 1.1.1.8 christos
1018 1.1 jruoho default:
1019 1.1 jruoho
1020 1.1 jruoho /* Just get the opcode name and print it */
1021 1.1 jruoho
1022 1.1 jruoho AcpiOsPrintf ("%s", OpInfo->Name);
1023 1.1 jruoho
1024 1.1 jruoho
1025 1.1 jruoho #ifdef ACPI_DEBUGGER
1026 1.1 jruoho
1027 1.1 jruoho if ((Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) &&
1028 1.1 jruoho (WalkState) &&
1029 1.1 jruoho (WalkState->Results) &&
1030 1.1 jruoho (WalkState->ResultCount))
1031 1.1 jruoho {
1032 1.1.1.6 christos AcpiDbDecodeInternalObject (
1033 1.1 jruoho WalkState->Results->Results.ObjDesc [
1034 1.1 jruoho (WalkState->ResultCount - 1) %
1035 1.1 jruoho ACPI_RESULTS_FRAME_OBJ_NUM]);
1036 1.1 jruoho }
1037 1.1 jruoho #endif
1038 1.1 jruoho
1039 1.1 jruoho break;
1040 1.1 jruoho }
1041 1.1 jruoho }
1042 1.1 jruoho
1043 1.1.1.7 christos
1044 1.1.1.7 christos /*******************************************************************************
1045 1.1.1.7 christos *
1046 1.1.1.7 christos * FUNCTION: AcpiDmConvertToElseIf
1047 1.1.1.7 christos *
1048 1.1.1.7 christos * PARAMETERS: OriginalElseOp - ELSE Object to be examined
1049 1.1.1.7 christos *
1050 1.1.1.7 christos * RETURN: None. Emits either an "Else" or an "ElseIf" ASL operator.
1051 1.1.1.7 christos *
1052 1.1.1.7 christos * DESCRIPTION: Detect and convert an If..Else..If sequence to If..ElseIf
1053 1.1.1.7 christos *
1054 1.1.1.7 christos * EXAMPLE:
1055 1.1.1.7 christos *
1056 1.1.1.7 christos * This If..Else..If nested sequence:
1057 1.1.1.7 christos *
1058 1.1.1.7 christos * If (Arg0 == 1)
1059 1.1.1.7 christos * {
1060 1.1.1.7 christos * Local0 = 4
1061 1.1.1.7 christos * }
1062 1.1.1.7 christos * Else
1063 1.1.1.7 christos * {
1064 1.1.1.7 christos * If (Arg0 == 2)
1065 1.1.1.7 christos * {
1066 1.1.1.7 christos * Local0 = 5
1067 1.1.1.7 christos * }
1068 1.1.1.7 christos * }
1069 1.1.1.7 christos *
1070 1.1.1.7 christos * Is converted to this simpler If..ElseIf sequence:
1071 1.1.1.7 christos *
1072 1.1.1.7 christos * If (Arg0 == 1)
1073 1.1.1.7 christos * {
1074 1.1.1.7 christos * Local0 = 4
1075 1.1.1.7 christos * }
1076 1.1.1.7 christos * ElseIf (Arg0 == 2)
1077 1.1.1.7 christos * {
1078 1.1.1.7 christos * Local0 = 5
1079 1.1.1.7 christos * }
1080 1.1.1.7 christos *
1081 1.1.1.7 christos * NOTE: There is no actual ElseIf AML opcode. ElseIf is essentially an ASL
1082 1.1.1.7 christos * macro that emits an Else opcode followed by an If opcode. This function
1083 1.1.1.7 christos * reverses these AML sequences back to an ElseIf macro where possible. This
1084 1.1.1.7 christos * can make the disassembled ASL code simpler and more like the original code.
1085 1.1.1.7 christos *
1086 1.1.1.7 christos ******************************************************************************/
1087 1.1.1.7 christos
1088 1.1.1.7 christos static void
1089 1.1.1.7 christos AcpiDmConvertToElseIf (
1090 1.1.1.7 christos ACPI_PARSE_OBJECT *OriginalElseOp)
1091 1.1.1.7 christos {
1092 1.1.1.7 christos ACPI_PARSE_OBJECT *IfOp;
1093 1.1.1.7 christos ACPI_PARSE_OBJECT *ElseOp;
1094 1.1.1.7 christos
1095 1.1.1.7 christos
1096 1.1.1.8 christos /*
1097 1.1.1.8 christos * To be able to perform the conversion, two conditions must be satisfied:
1098 1.1.1.8 christos * 1) The first child of the Else must be an If statement.
1099 1.1.1.8 christos * 2) The If block can only be followed by an Else block and these must
1100 1.1.1.8 christos * be the only blocks under the original Else.
1101 1.1.1.8 christos */
1102 1.1.1.7 christos IfOp = OriginalElseOp->Common.Value.Arg;
1103 1.1.1.10 christos
1104 1.1.1.8 christos if (!IfOp ||
1105 1.1.1.8 christos (IfOp->Common.AmlOpcode != AML_IF_OP) ||
1106 1.1.1.8 christos (IfOp->Asl.Next && (IfOp->Asl.Next->Common.AmlOpcode != AML_ELSE_OP)))
1107 1.1.1.7 christos {
1108 1.1.1.10 christos /* Not a proper Else..If sequence, cannot convert to ElseIf */
1109 1.1.1.10 christos
1110 1.1.1.10.2.1 bouyer if (OriginalElseOp->Common.DisasmOpcode == ACPI_DASM_DEFAULT)
1111 1.1.1.10.2.1 bouyer {
1112 1.1.1.10.2.1 bouyer AcpiOsPrintf ("%s", "Default");
1113 1.1.1.10.2.1 bouyer return;
1114 1.1.1.10.2.1 bouyer }
1115 1.1.1.10.2.1 bouyer
1116 1.1.1.10 christos AcpiOsPrintf ("%s", "Else");
1117 1.1.1.10 christos return;
1118 1.1.1.10 christos }
1119 1.1.1.10 christos
1120 1.1.1.10 christos /* Cannot have anything following the If...Else block */
1121 1.1.1.7 christos
1122 1.1.1.10 christos ElseOp = IfOp->Common.Next;
1123 1.1.1.10 christos if (ElseOp && ElseOp->Common.Next)
1124 1.1.1.10 christos {
1125 1.1.1.10.2.1 bouyer if (OriginalElseOp->Common.DisasmOpcode == ACPI_DASM_DEFAULT)
1126 1.1.1.10.2.1 bouyer {
1127 1.1.1.10.2.1 bouyer AcpiOsPrintf ("%s", "Default");
1128 1.1.1.10.2.1 bouyer return;
1129 1.1.1.10.2.1 bouyer }
1130 1.1.1.10.2.1 bouyer
1131 1.1.1.7 christos AcpiOsPrintf ("%s", "Else");
1132 1.1.1.7 christos return;
1133 1.1.1.7 christos }
1134 1.1.1.7 christos
1135 1.1.1.10.2.1 bouyer if (OriginalElseOp->Common.DisasmOpcode == ACPI_DASM_DEFAULT)
1136 1.1.1.10.2.1 bouyer {
1137 1.1.1.10.2.1 bouyer /*
1138 1.1.1.10.2.1 bouyer * There is an ElseIf but in this case the Else is actually
1139 1.1.1.10.2.1 bouyer * a Default block for a Switch/Case statement. No conversion.
1140 1.1.1.10.2.1 bouyer */
1141 1.1.1.10.2.1 bouyer AcpiOsPrintf ("%s", "Default");
1142 1.1.1.10.2.1 bouyer return;
1143 1.1.1.10.2.1 bouyer }
1144 1.1.1.10.2.1 bouyer
1145 1.1.1.10.2.1 bouyer if (OriginalElseOp->Common.DisasmOpcode == ACPI_DASM_CASE)
1146 1.1.1.10.2.1 bouyer {
1147 1.1.1.10.2.1 bouyer /*
1148 1.1.1.10.2.1 bouyer * This ElseIf is actually a Case block for a Switch/Case
1149 1.1.1.10.2.1 bouyer * statement. Print Case but do not return so that we can
1150 1.1.1.10.2.1 bouyer * promote the subtree and keep the indentation level.
1151 1.1.1.10.2.1 bouyer */
1152 1.1.1.10.2.1 bouyer AcpiOsPrintf ("%s", "Case");
1153 1.1.1.10.2.1 bouyer }
1154 1.1.1.10.2.1 bouyer else
1155 1.1.1.10.2.1 bouyer {
1156 1.1.1.10.2.1 bouyer /* Emit ElseIf, mark the IF as now an ELSEIF */
1157 1.1.1.10.2.1 bouyer
1158 1.1.1.10.2.1 bouyer AcpiOsPrintf ("%s", "ElseIf");
1159 1.1.1.10.2.1 bouyer }
1160 1.1.1.7 christos
1161 1.1.1.7 christos IfOp->Common.DisasmFlags |= ACPI_PARSEOP_ELSEIF;
1162 1.1.1.7 christos
1163 1.1.1.7 christos /* The IF parent will now be the same as the original ELSE parent */
1164 1.1.1.7 christos
1165 1.1.1.7 christos IfOp->Common.Parent = OriginalElseOp->Common.Parent;
1166 1.1.1.7 christos
1167 1.1.1.7 christos /*
1168 1.1.1.7 christos * Update the NEXT pointers to restructure the parse tree, essentially
1169 1.1.1.7 christos * promoting an If..Else block up to the same level as the original
1170 1.1.1.7 christos * Else.
1171 1.1.1.7 christos *
1172 1.1.1.7 christos * Check if the IF has a corresponding ELSE peer
1173 1.1.1.7 christos */
1174 1.1.1.7 christos ElseOp = IfOp->Common.Next;
1175 1.1.1.7 christos if (ElseOp &&
1176 1.1.1.7 christos (ElseOp->Common.AmlOpcode == AML_ELSE_OP))
1177 1.1.1.7 christos {
1178 1.1.1.7 christos /* If an ELSE matches the IF, promote it also */
1179 1.1.1.7 christos
1180 1.1.1.7 christos ElseOp->Common.Parent = OriginalElseOp->Common.Parent;
1181 1.1.1.10 christos
1182 1.1.1.10 christos /* Promote the entire block under the ElseIf (All Next OPs) */
1183 1.1.1.10 christos
1184 1.1.1.10 christos AcpiDmPromoteSubtree (OriginalElseOp);
1185 1.1.1.7 christos }
1186 1.1.1.7 christos else
1187 1.1.1.7 christos {
1188 1.1.1.7 christos /* Otherwise, set the IF NEXT to the original ELSE NEXT */
1189 1.1.1.7 christos
1190 1.1.1.7 christos IfOp->Common.Next = OriginalElseOp->Common.Next;
1191 1.1.1.7 christos }
1192 1.1.1.7 christos
1193 1.1.1.7 christos /* Detach the child IF block from the original ELSE */
1194 1.1.1.7 christos
1195 1.1.1.7 christos OriginalElseOp->Common.Value.Arg = NULL;
1196 1.1.1.7 christos
1197 1.1.1.7 christos /* Ignore the original ELSE from now on */
1198 1.1.1.7 christos
1199 1.1.1.7 christos OriginalElseOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
1200 1.1.1.7 christos OriginalElseOp->Common.DisasmOpcode = ACPI_DASM_LNOT_PREFIX;
1201 1.1.1.7 christos
1202 1.1.1.7 christos /* Insert IF (now ELSEIF) as next peer of the original ELSE */
1203 1.1.1.7 christos
1204 1.1.1.7 christos OriginalElseOp->Common.Next = IfOp;
1205 1.1.1.7 christos }
1206 1.1.1.10 christos
1207 1.1.1.10 christos
1208 1.1.1.10 christos /*******************************************************************************
1209 1.1.1.10 christos *
1210 1.1.1.10 christos * FUNCTION: AcpiDmPromoteSubtree
1211 1.1.1.10 christos *
1212 1.1.1.10 christos * PARAMETERS: StartOpOp - Original parent of the entire subtree
1213 1.1.1.10 christos *
1214 1.1.1.10 christos * RETURN: None
1215 1.1.1.10 christos *
1216 1.1.1.10 christos * DESCRIPTION: Promote an entire parse subtree up one level.
1217 1.1.1.10 christos *
1218 1.1.1.10 christos ******************************************************************************/
1219 1.1.1.10 christos
1220 1.1.1.10 christos static void
1221 1.1.1.10 christos AcpiDmPromoteSubtree (
1222 1.1.1.10 christos ACPI_PARSE_OBJECT *StartOp)
1223 1.1.1.10 christos {
1224 1.1.1.10 christos ACPI_PARSE_OBJECT *Op;
1225 1.1.1.10 christos ACPI_PARSE_OBJECT *ParentOp;
1226 1.1.1.10 christos
1227 1.1.1.10 christos
1228 1.1.1.10 christos /* New parent for subtree elements */
1229 1.1.1.10 christos
1230 1.1.1.10 christos ParentOp = StartOp->Common.Parent;
1231 1.1.1.10 christos
1232 1.1.1.10 christos /* First child starts the subtree */
1233 1.1.1.10 christos
1234 1.1.1.10 christos Op = StartOp->Common.Value.Arg;
1235 1.1.1.10 christos
1236 1.1.1.10 christos /* Walk the top-level elements of the subtree */
1237 1.1.1.10 christos
1238 1.1.1.10 christos while (Op)
1239 1.1.1.10 christos {
1240 1.1.1.10 christos Op->Common.Parent = ParentOp;
1241 1.1.1.10 christos if (!Op->Common.Next)
1242 1.1.1.10 christos {
1243 1.1.1.10 christos /* Last Op in list, update its next field */
1244 1.1.1.10 christos
1245 1.1.1.10 christos Op->Common.Next = StartOp->Common.Next;
1246 1.1.1.10 christos break;
1247 1.1.1.10 christos }
1248 1.1.1.10 christos Op = Op->Common.Next;
1249 1.1.1.10 christos }
1250 1.1.1.10 christos }
1251 1.1.1.10.2.1 bouyer
1252 1.1.1.10.2.1 bouyer /*******************************************************************************
1253 1.1.1.10.2.1 bouyer *
1254 1.1.1.10.2.1 bouyer * FUNCTION: AcpiDmIsTempName
1255 1.1.1.10.2.1 bouyer *
1256 1.1.1.10.2.1 bouyer * PARAMETERS: Op - Object to be examined
1257 1.1.1.10.2.1 bouyer *
1258 1.1.1.10.2.1 bouyer * RETURN: TRUE if object is a temporary (_T_x) name
1259 1.1.1.10.2.1 bouyer *
1260 1.1.1.10.2.1 bouyer * DESCRIPTION: Determine if an object is a temporary name and ignore it.
1261 1.1.1.10.2.1 bouyer * Temporary names are only used for Switch statements. This
1262 1.1.1.10.2.1 bouyer * function depends on this restriced usage.
1263 1.1.1.10.2.1 bouyer *
1264 1.1.1.10.2.1 bouyer ******************************************************************************/
1265 1.1.1.10.2.1 bouyer
1266 1.1.1.10.2.1 bouyer BOOLEAN
1267 1.1.1.10.2.1 bouyer AcpiDmIsTempName (
1268 1.1.1.10.2.1 bouyer ACPI_PARSE_OBJECT *Op)
1269 1.1.1.10.2.1 bouyer {
1270 1.1.1.10.2.1 bouyer char *Temp;
1271 1.1.1.10.2.1 bouyer
1272 1.1.1.10.2.1 bouyer if (Op->Common.AmlOpcode != AML_NAME_OP)
1273 1.1.1.10.2.1 bouyer {
1274 1.1.1.10.2.1 bouyer return (FALSE);
1275 1.1.1.10.2.1 bouyer }
1276 1.1.1.10.2.1 bouyer
1277 1.1.1.10.2.1 bouyer Temp = (char *)(Op->Common.Aml);
1278 1.1.1.10.2.1 bouyer ++Temp;
1279 1.1.1.10.2.1 bouyer
1280 1.1.1.10.2.1 bouyer if (strncmp(Temp, "_T_", 3))
1281 1.1.1.10.2.1 bouyer {
1282 1.1.1.10.2.1 bouyer return (FALSE);
1283 1.1.1.10.2.1 bouyer }
1284 1.1.1.10.2.1 bouyer
1285 1.1.1.10.2.1 bouyer /* Ignore Op */
1286 1.1.1.10.2.1 bouyer
1287 1.1.1.10.2.1 bouyer Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
1288 1.1.1.10.2.1 bouyer
1289 1.1.1.10.2.1 bouyer return (TRUE);
1290 1.1.1.10.2.1 bouyer }
1291 1.1.1.10.2.1 bouyer
1292 1.1.1.10.2.1 bouyer /*******************************************************************************
1293 1.1.1.10.2.1 bouyer *
1294 1.1.1.10.2.1 bouyer * FUNCTION: AcpiDmIsSwitchBlock
1295 1.1.1.10.2.1 bouyer *
1296 1.1.1.10.2.1 bouyer * PARAMETERS: Op - While Object
1297 1.1.1.10.2.1 bouyer *
1298 1.1.1.10.2.1 bouyer * RETURN: TRUE if While block can be converted to a Switch/Case block
1299 1.1.1.10.2.1 bouyer *
1300 1.1.1.10.2.1 bouyer * DESCRIPTION: Determines if While block is a Switch/Case statement. Modifies
1301 1.1.1.10.2.1 bouyer * parse tree to allow for Switch/Case disassembly during walk.
1302 1.1.1.10.2.1 bouyer *
1303 1.1.1.10.2.1 bouyer * EXAMPLE: Example of parse tree to be converted
1304 1.1.1.10.2.1 bouyer *
1305 1.1.1.10.2.1 bouyer * While
1306 1.1.1.10.2.1 bouyer * One
1307 1.1.1.10.2.1 bouyer * Store
1308 1.1.1.10.2.1 bouyer * ByteConst
1309 1.1.1.10.2.1 bouyer * -NamePath-
1310 1.1.1.10.2.1 bouyer * If
1311 1.1.1.10.2.1 bouyer * LEqual
1312 1.1.1.10.2.1 bouyer * -NamePath-
1313 1.1.1.10.2.1 bouyer * Zero
1314 1.1.1.10.2.1 bouyer * Return
1315 1.1.1.10.2.1 bouyer * One
1316 1.1.1.10.2.1 bouyer * Else
1317 1.1.1.10.2.1 bouyer * Return
1318 1.1.1.10.2.1 bouyer * WordConst
1319 1.1.1.10.2.1 bouyer * Break
1320 1.1.1.10.2.1 bouyer *
1321 1.1.1.10.2.1 bouyer ******************************************************************************/
1322 1.1.1.10.2.1 bouyer
1323 1.1.1.10.2.1 bouyer static BOOLEAN
1324 1.1.1.10.2.1 bouyer AcpiDmIsSwitchBlock (
1325 1.1.1.10.2.1 bouyer ACPI_PARSE_OBJECT *Op)
1326 1.1.1.10.2.1 bouyer {
1327 1.1.1.10.2.1 bouyer ACPI_PARSE_OBJECT *OneOp;
1328 1.1.1.10.2.1 bouyer ACPI_PARSE_OBJECT *StoreOp;
1329 1.1.1.10.2.1 bouyer ACPI_PARSE_OBJECT *NamePathOp;
1330 1.1.1.10.2.1 bouyer ACPI_PARSE_OBJECT *PredicateOp;
1331 1.1.1.10.2.1 bouyer ACPI_PARSE_OBJECT *CurrentOp;
1332 1.1.1.10.2.1 bouyer ACPI_PARSE_OBJECT *TempOp;
1333 1.1.1.10.2.1 bouyer
1334 1.1.1.10.2.1 bouyer /* Check for One Op Predicate */
1335 1.1.1.10.2.1 bouyer
1336 1.1.1.10.2.1 bouyer OneOp = AcpiPsGetArg (Op, 0);
1337 1.1.1.10.2.1 bouyer if (!OneOp || (OneOp->Common.AmlOpcode != AML_ONE_OP))
1338 1.1.1.10.2.1 bouyer {
1339 1.1.1.10.2.1 bouyer return (FALSE);
1340 1.1.1.10.2.1 bouyer }
1341 1.1.1.10.2.1 bouyer
1342 1.1.1.10.2.1 bouyer /* Check for Store Op */
1343 1.1.1.10.2.1 bouyer
1344 1.1.1.10.2.1 bouyer StoreOp = OneOp->Common.Next;
1345 1.1.1.10.2.1 bouyer if (!StoreOp || (StoreOp->Common.AmlOpcode != AML_STORE_OP))
1346 1.1.1.10.2.1 bouyer {
1347 1.1.1.10.2.1 bouyer return (FALSE);
1348 1.1.1.10.2.1 bouyer }
1349 1.1.1.10.2.1 bouyer
1350 1.1.1.10.2.1 bouyer /* Check for Name Op with _T_ string */
1351 1.1.1.10.2.1 bouyer
1352 1.1.1.10.2.1 bouyer NamePathOp = AcpiPsGetArg (StoreOp, 1);
1353 1.1.1.10.2.1 bouyer if (!NamePathOp || (NamePathOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP))
1354 1.1.1.10.2.1 bouyer {
1355 1.1.1.10.2.1 bouyer return (FALSE);
1356 1.1.1.10.2.1 bouyer }
1357 1.1.1.10.2.1 bouyer
1358 1.1.1.10.2.1 bouyer if (strncmp((char *)(NamePathOp->Common.Aml), "_T_", 3))
1359 1.1.1.10.2.1 bouyer {
1360 1.1.1.10.2.1 bouyer return (FALSE);
1361 1.1.1.10.2.1 bouyer }
1362 1.1.1.10.2.1 bouyer
1363 1.1.1.10.2.1 bouyer /* This is a Switch/Case control block */
1364 1.1.1.10.2.1 bouyer
1365 1.1.1.10.2.1 bouyer /* Ignore the One Op Predicate */
1366 1.1.1.10.2.1 bouyer
1367 1.1.1.10.2.1 bouyer OneOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
1368 1.1.1.10.2.1 bouyer
1369 1.1.1.10.2.1 bouyer /* Ignore the Store Op, but not the children */
1370 1.1.1.10.2.1 bouyer
1371 1.1.1.10.2.1 bouyer StoreOp->Common.DisasmOpcode = ACPI_DASM_IGNORE_SINGLE;
1372 1.1.1.10.2.1 bouyer
1373 1.1.1.10.2.1 bouyer /*
1374 1.1.1.10.2.1 bouyer * First arg of Store Op is the Switch condition.
1375 1.1.1.10.2.1 bouyer * Mark it as a Switch predicate and as a parameter list for paren
1376 1.1.1.10.2.1 bouyer * closing and correct indentation.
1377 1.1.1.10.2.1 bouyer */
1378 1.1.1.10.2.1 bouyer PredicateOp = AcpiPsGetArg (StoreOp, 0);
1379 1.1.1.10.2.1 bouyer PredicateOp->Common.DisasmOpcode = ACPI_DASM_SWITCH_PREDICATE;
1380 1.1.1.10.2.1 bouyer PredicateOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
1381 1.1.1.10.2.1 bouyer
1382 1.1.1.10.2.1 bouyer /* Ignore the Name Op */
1383 1.1.1.10.2.1 bouyer
1384 1.1.1.10.2.1 bouyer NamePathOp->Common.DisasmFlags = ACPI_PARSEOP_IGNORE;
1385 1.1.1.10.2.1 bouyer
1386 1.1.1.10.2.1 bouyer /* Remaining opcodes are the Case statements (If/ElseIf's) */
1387 1.1.1.10.2.1 bouyer
1388 1.1.1.10.2.1 bouyer CurrentOp = StoreOp->Common.Next;
1389 1.1.1.10.2.1 bouyer while (AcpiDmIsCaseBlock (CurrentOp))
1390 1.1.1.10.2.1 bouyer {
1391 1.1.1.10.2.1 bouyer /* Block is a Case structure */
1392 1.1.1.10.2.1 bouyer
1393 1.1.1.10.2.1 bouyer if (CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
1394 1.1.1.10.2.1 bouyer {
1395 1.1.1.10.2.1 bouyer /* ElseIf */
1396 1.1.1.10.2.1 bouyer
1397 1.1.1.10.2.1 bouyer CurrentOp->Common.DisasmOpcode = ACPI_DASM_CASE;
1398 1.1.1.10.2.1 bouyer CurrentOp = AcpiPsGetArg (CurrentOp, 0);
1399 1.1.1.10.2.1 bouyer }
1400 1.1.1.10.2.1 bouyer
1401 1.1.1.10.2.1 bouyer /* If */
1402 1.1.1.10.2.1 bouyer
1403 1.1.1.10.2.1 bouyer CurrentOp->Common.DisasmOpcode = ACPI_DASM_CASE;
1404 1.1.1.10.2.1 bouyer
1405 1.1.1.10.2.1 bouyer /*
1406 1.1.1.10.2.1 bouyer * Mark the parse tree for Case disassembly. There are two
1407 1.1.1.10.2.1 bouyer * types of Case statements. The first type of statement begins with
1408 1.1.1.10.2.1 bouyer * an LEqual. The second starts with an LNot and uses a Match statement
1409 1.1.1.10.2.1 bouyer * on a Package of constants.
1410 1.1.1.10.2.1 bouyer */
1411 1.1.1.10.2.1 bouyer TempOp = AcpiPsGetArg (CurrentOp, 0);
1412 1.1.1.10.2.1 bouyer switch (TempOp->Common.AmlOpcode)
1413 1.1.1.10.2.1 bouyer {
1414 1.1.1.10.2.1 bouyer case (AML_LEQUAL_OP):
1415 1.1.1.10.2.1 bouyer
1416 1.1.1.10.2.1 bouyer /* Ignore just the LEqual Op */
1417 1.1.1.10.2.1 bouyer
1418 1.1.1.10.2.1 bouyer TempOp->Common.DisasmOpcode = ACPI_DASM_IGNORE_SINGLE;
1419 1.1.1.10.2.1 bouyer
1420 1.1.1.10.2.1 bouyer /* Ignore the NamePath Op */
1421 1.1.1.10.2.1 bouyer
1422 1.1.1.10.2.1 bouyer TempOp = AcpiPsGetArg (TempOp, 0);
1423 1.1.1.10.2.1 bouyer TempOp->Common.DisasmFlags = ACPI_PARSEOP_IGNORE;
1424 1.1.1.10.2.1 bouyer
1425 1.1.1.10.2.1 bouyer /*
1426 1.1.1.10.2.1 bouyer * Second arg of LEqual will be the Case predicate.
1427 1.1.1.10.2.1 bouyer * Mark it as a predicate and also as a parameter list for paren
1428 1.1.1.10.2.1 bouyer * closing and correct indentation.
1429 1.1.1.10.2.1 bouyer */
1430 1.1.1.10.2.1 bouyer PredicateOp = TempOp->Common.Next;
1431 1.1.1.10.2.1 bouyer PredicateOp->Common.DisasmOpcode = ACPI_DASM_SWITCH_PREDICATE;
1432 1.1.1.10.2.1 bouyer PredicateOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
1433 1.1.1.10.2.1 bouyer
1434 1.1.1.10.2.1 bouyer break;
1435 1.1.1.10.2.1 bouyer
1436 1.1.1.10.2.1 bouyer case (AML_LNOT_OP):
1437 1.1.1.10.2.1 bouyer
1438 1.1.1.10.2.1 bouyer /*
1439 1.1.1.10.2.1 bouyer * The Package will be the predicate of the Case statement.
1440 1.1.1.10.2.1 bouyer * It's under:
1441 1.1.1.10.2.1 bouyer * LNOT
1442 1.1.1.10.2.1 bouyer * LEQUAL
1443 1.1.1.10.2.1 bouyer * MATCH
1444 1.1.1.10.2.1 bouyer * PACKAGE
1445 1.1.1.10.2.1 bouyer */
1446 1.1.1.10.2.1 bouyer
1447 1.1.1.10.2.1 bouyer /* Get the LEqual Op from LNot */
1448 1.1.1.10.2.1 bouyer
1449 1.1.1.10.2.1 bouyer TempOp = AcpiPsGetArg (TempOp, 0);
1450 1.1.1.10.2.1 bouyer
1451 1.1.1.10.2.1 bouyer /* Get the Match Op from LEqual */
1452 1.1.1.10.2.1 bouyer
1453 1.1.1.10.2.1 bouyer TempOp = AcpiPsGetArg (TempOp, 0);
1454 1.1.1.10.2.1 bouyer
1455 1.1.1.10.2.1 bouyer /* Get the Package Op from Match */
1456 1.1.1.10.2.1 bouyer
1457 1.1.1.10.2.1 bouyer PredicateOp = AcpiPsGetArg (TempOp, 0);
1458 1.1.1.10.2.1 bouyer
1459 1.1.1.10.2.1 bouyer /* Mark as parameter list for paren closing */
1460 1.1.1.10.2.1 bouyer
1461 1.1.1.10.2.1 bouyer PredicateOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
1462 1.1.1.10.2.1 bouyer
1463 1.1.1.10.2.1 bouyer /*
1464 1.1.1.10.2.1 bouyer * The Package list would be too deeply indented if we
1465 1.1.1.10.2.1 bouyer * chose to simply ignore the all the parent opcodes, so
1466 1.1.1.10.2.1 bouyer * we rearrange the parse tree instead.
1467 1.1.1.10.2.1 bouyer */
1468 1.1.1.10.2.1 bouyer
1469 1.1.1.10.2.1 bouyer /*
1470 1.1.1.10.2.1 bouyer * Save the second arg of the If/Else Op which is the
1471 1.1.1.10.2.1 bouyer * block code of code for this Case statement.
1472 1.1.1.10.2.1 bouyer */
1473 1.1.1.10.2.1 bouyer TempOp = AcpiPsGetArg (CurrentOp, 1);
1474 1.1.1.10.2.1 bouyer
1475 1.1.1.10.2.1 bouyer /*
1476 1.1.1.10.2.1 bouyer * Move the Package Op to the child (predicate) of the
1477 1.1.1.10.2.1 bouyer * Case statement.
1478 1.1.1.10.2.1 bouyer */
1479 1.1.1.10.2.1 bouyer CurrentOp->Common.Value.Arg = PredicateOp;
1480 1.1.1.10.2.1 bouyer PredicateOp->Common.Parent = CurrentOp;
1481 1.1.1.10.2.1 bouyer
1482 1.1.1.10.2.1 bouyer /* Add the block code */
1483 1.1.1.10.2.1 bouyer
1484 1.1.1.10.2.1 bouyer PredicateOp->Common.Next = TempOp;
1485 1.1.1.10.2.1 bouyer
1486 1.1.1.10.2.1 bouyer break;
1487 1.1.1.10.2.1 bouyer
1488 1.1.1.10.2.1 bouyer default:
1489 1.1.1.10.2.1 bouyer
1490 1.1.1.10.2.1 bouyer /* Should never get here */
1491 1.1.1.10.2.1 bouyer
1492 1.1.1.10.2.1 bouyer break;
1493 1.1.1.10.2.1 bouyer }
1494 1.1.1.10.2.1 bouyer
1495 1.1.1.10.2.1 bouyer /* Advance to next Case block */
1496 1.1.1.10.2.1 bouyer
1497 1.1.1.10.2.1 bouyer CurrentOp = CurrentOp->Common.Next;
1498 1.1.1.10.2.1 bouyer }
1499 1.1.1.10.2.1 bouyer
1500 1.1.1.10.2.1 bouyer /* If CurrentOp is now an Else, then this is a Default block */
1501 1.1.1.10.2.1 bouyer
1502 1.1.1.10.2.1 bouyer if (CurrentOp && CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
1503 1.1.1.10.2.1 bouyer {
1504 1.1.1.10.2.1 bouyer CurrentOp->Common.DisasmOpcode = ACPI_DASM_DEFAULT;
1505 1.1.1.10.2.1 bouyer }
1506 1.1.1.10.2.1 bouyer
1507 1.1.1.10.2.1 bouyer /*
1508 1.1.1.10.2.1 bouyer * From the first If advance to the Break op. It's possible to
1509 1.1.1.10.2.1 bouyer * have an Else (Default) op here when there is only one Case
1510 1.1.1.10.2.1 bouyer * statement, so check for it.
1511 1.1.1.10.2.1 bouyer */
1512 1.1.1.10.2.1 bouyer CurrentOp = StoreOp->Common.Next->Common.Next;
1513 1.1.1.10.2.1 bouyer if (CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
1514 1.1.1.10.2.1 bouyer {
1515 1.1.1.10.2.1 bouyer CurrentOp = CurrentOp->Common.Next;
1516 1.1.1.10.2.1 bouyer }
1517 1.1.1.10.2.1 bouyer
1518 1.1.1.10.2.1 bouyer /* Ignore the Break Op */
1519 1.1.1.10.2.1 bouyer
1520 1.1.1.10.2.1 bouyer CurrentOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
1521 1.1.1.10.2.1 bouyer
1522 1.1.1.10.2.1 bouyer return (TRUE);
1523 1.1.1.10.2.1 bouyer }
1524 1.1.1.10.2.1 bouyer
1525 1.1.1.10.2.1 bouyer /*******************************************************************************
1526 1.1.1.10.2.1 bouyer *
1527 1.1.1.10.2.1 bouyer * FUNCTION: AcpiDmIsCaseBlock
1528 1.1.1.10.2.1 bouyer *
1529 1.1.1.10.2.1 bouyer * PARAMETERS: Op - Object to test
1530 1.1.1.10.2.1 bouyer *
1531 1.1.1.10.2.1 bouyer * RETURN: TRUE if Object is beginning of a Case block.
1532 1.1.1.10.2.1 bouyer *
1533 1.1.1.10.2.1 bouyer * DESCRIPTION: Determines if an Object is the beginning of a Case block for a
1534 1.1.1.10.2.1 bouyer * Switch/Case statement. Parse tree must be one of the following
1535 1.1.1.10.2.1 bouyer * forms:
1536 1.1.1.10.2.1 bouyer *
1537 1.1.1.10.2.1 bouyer * Else (Optional)
1538 1.1.1.10.2.1 bouyer * If
1539 1.1.1.10.2.1 bouyer * LEqual
1540 1.1.1.10.2.1 bouyer * -NamePath- _T_x
1541 1.1.1.10.2.1 bouyer *
1542 1.1.1.10.2.1 bouyer * Else (Optional)
1543 1.1.1.10.2.1 bouyer * If
1544 1.1.1.10.2.1 bouyer * LNot
1545 1.1.1.10.2.1 bouyer * LEqual
1546 1.1.1.10.2.1 bouyer * Match
1547 1.1.1.10.2.1 bouyer * Package
1548 1.1.1.10.2.1 bouyer * ByteConst
1549 1.1.1.10.2.1 bouyer * -NamePath- _T_x
1550 1.1.1.10.2.1 bouyer *
1551 1.1.1.10.2.1 bouyer ******************************************************************************/
1552 1.1.1.10.2.1 bouyer
1553 1.1.1.10.2.1 bouyer static BOOLEAN
1554 1.1.1.10.2.1 bouyer AcpiDmIsCaseBlock (
1555 1.1.1.10.2.1 bouyer ACPI_PARSE_OBJECT *Op)
1556 1.1.1.10.2.1 bouyer {
1557 1.1.1.10.2.1 bouyer ACPI_PARSE_OBJECT *CurrentOp;
1558 1.1.1.10.2.1 bouyer
1559 1.1.1.10.2.1 bouyer if (!Op)
1560 1.1.1.10.2.1 bouyer {
1561 1.1.1.10.2.1 bouyer return (FALSE);
1562 1.1.1.10.2.1 bouyer }
1563 1.1.1.10.2.1 bouyer
1564 1.1.1.10.2.1 bouyer /* Look for an If or ElseIf */
1565 1.1.1.10.2.1 bouyer
1566 1.1.1.10.2.1 bouyer CurrentOp = Op;
1567 1.1.1.10.2.1 bouyer if (CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
1568 1.1.1.10.2.1 bouyer {
1569 1.1.1.10.2.1 bouyer CurrentOp = AcpiPsGetArg (CurrentOp, 0);
1570 1.1.1.10.2.1 bouyer if (!CurrentOp)
1571 1.1.1.10.2.1 bouyer {
1572 1.1.1.10.2.1 bouyer return (FALSE);
1573 1.1.1.10.2.1 bouyer }
1574 1.1.1.10.2.1 bouyer }
1575 1.1.1.10.2.1 bouyer
1576 1.1.1.10.2.1 bouyer if (!CurrentOp || CurrentOp->Common.AmlOpcode != AML_IF_OP)
1577 1.1.1.10.2.1 bouyer {
1578 1.1.1.10.2.1 bouyer return (FALSE);
1579 1.1.1.10.2.1 bouyer }
1580 1.1.1.10.2.1 bouyer
1581 1.1.1.10.2.1 bouyer /* Child must be LEqual or LNot */
1582 1.1.1.10.2.1 bouyer
1583 1.1.1.10.2.1 bouyer CurrentOp = AcpiPsGetArg (CurrentOp, 0);
1584 1.1.1.10.2.1 bouyer if (!CurrentOp)
1585 1.1.1.10.2.1 bouyer {
1586 1.1.1.10.2.1 bouyer return (FALSE);
1587 1.1.1.10.2.1 bouyer }
1588 1.1.1.10.2.1 bouyer
1589 1.1.1.10.2.1 bouyer switch (CurrentOp->Common.AmlOpcode)
1590 1.1.1.10.2.1 bouyer {
1591 1.1.1.10.2.1 bouyer case (AML_LEQUAL_OP):
1592 1.1.1.10.2.1 bouyer
1593 1.1.1.10.2.1 bouyer /* Next child must be NamePath with string _T_ */
1594 1.1.1.10.2.1 bouyer
1595 1.1.1.10.2.1 bouyer CurrentOp = AcpiPsGetArg (CurrentOp, 0);
1596 1.1.1.10.2.1 bouyer if (!CurrentOp || !CurrentOp->Common.Value.Name ||
1597 1.1.1.10.2.1 bouyer strncmp(CurrentOp->Common.Value.Name, "_T_", 3))
1598 1.1.1.10.2.1 bouyer {
1599 1.1.1.10.2.1 bouyer return (FALSE);
1600 1.1.1.10.2.1 bouyer }
1601 1.1.1.10.2.1 bouyer
1602 1.1.1.10.2.1 bouyer break;
1603 1.1.1.10.2.1 bouyer
1604 1.1.1.10.2.1 bouyer case (AML_LNOT_OP):
1605 1.1.1.10.2.1 bouyer
1606 1.1.1.10.2.1 bouyer /* Child of LNot must be LEqual op */
1607 1.1.1.10.2.1 bouyer
1608 1.1.1.10.2.1 bouyer CurrentOp = AcpiPsGetArg (CurrentOp, 0);
1609 1.1.1.10.2.1 bouyer if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_LEQUAL_OP))
1610 1.1.1.10.2.1 bouyer {
1611 1.1.1.10.2.1 bouyer return (FALSE);
1612 1.1.1.10.2.1 bouyer }
1613 1.1.1.10.2.1 bouyer
1614 1.1.1.10.2.1 bouyer /* Child of LNot must be Match op */
1615 1.1.1.10.2.1 bouyer
1616 1.1.1.10.2.1 bouyer CurrentOp = AcpiPsGetArg (CurrentOp, 0);
1617 1.1.1.10.2.1 bouyer if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_MATCH_OP))
1618 1.1.1.10.2.1 bouyer {
1619 1.1.1.10.2.1 bouyer return (FALSE);
1620 1.1.1.10.2.1 bouyer }
1621 1.1.1.10.2.1 bouyer
1622 1.1.1.10.2.1 bouyer /* First child of Match must be Package op */
1623 1.1.1.10.2.1 bouyer
1624 1.1.1.10.2.1 bouyer CurrentOp = AcpiPsGetArg (CurrentOp, 0);
1625 1.1.1.10.2.1 bouyer if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_PACKAGE_OP))
1626 1.1.1.10.2.1 bouyer {
1627 1.1.1.10.2.1 bouyer return (FALSE);
1628 1.1.1.10.2.1 bouyer }
1629 1.1.1.10.2.1 bouyer
1630 1.1.1.10.2.1 bouyer /* Third child of Match must be NamePath with string _T_ */
1631 1.1.1.10.2.1 bouyer
1632 1.1.1.10.2.1 bouyer CurrentOp = AcpiPsGetArg (CurrentOp->Common.Parent, 2);
1633 1.1.1.10.2.1 bouyer if (!CurrentOp || !CurrentOp->Common.Value.Name ||
1634 1.1.1.10.2.1 bouyer strncmp(CurrentOp->Common.Value.Name, "_T_", 3))
1635 1.1.1.10.2.1 bouyer {
1636 1.1.1.10.2.1 bouyer return (FALSE);
1637 1.1.1.10.2.1 bouyer }
1638 1.1.1.10.2.1 bouyer
1639 1.1.1.10.2.1 bouyer break;
1640 1.1.1.10.2.1 bouyer
1641 1.1.1.10.2.1 bouyer default:
1642 1.1.1.10.2.1 bouyer
1643 1.1.1.10.2.1 bouyer return (FALSE);
1644 1.1.1.10.2.1 bouyer }
1645 1.1.1.10.2.1 bouyer
1646 1.1.1.10.2.1 bouyer return (TRUE);
1647 1.1.1.10.2.1 bouyer }
1648