dmopcode.c revision 239340
1178431Sscf/*******************************************************************************
2178431Sscf *
3178431Sscf * Module Name: dmopcode - AML disassembler, specific AML opcodes
4178431Sscf *
5178431Sscf ******************************************************************************/
6178431Sscf
7178431Sscf/*
8178431Sscf * Copyright (C) 2000 - 2012, Intel Corp.
9178431Sscf * All rights reserved.
10178431Sscf *
11178431Sscf * Redistribution and use in source and binary forms, with or without
12178431Sscf * modification, are permitted provided that the following conditions
13178431Sscf * are met:
14178431Sscf * 1. Redistributions of source code must retain the above copyright
15178431Sscf *    notice, this list of conditions, and the following disclaimer,
16178431Sscf *    without modification.
17178431Sscf * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18178431Sscf *    substantially similar to the "NO WARRANTY" disclaimer below
19178431Sscf *    ("Disclaimer") and any redistribution must be conditioned upon
20178431Sscf *    including a substantially similar Disclaimer requirement for further
21178431Sscf *    binary redistribution.
22178431Sscf * 3. Neither the names of the above-listed copyright holders nor the names
23178431Sscf *    of any contributors may be used to endorse or promote products derived
24178431Sscf *    from this software without specific prior written permission.
25178431Sscf *
26178431Sscf * Alternatively, this software may be distributed under the terms of the
27178431Sscf * GNU General Public License ("GPL") version 2 as published by the Free
28178431Sscf * Software Foundation.
29178431Sscf *
30178431Sscf * NO WARRANTY
31228545Sbapt * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32228545Sbapt * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33184831Sscf * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34228545Sbapt * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35228545Sbapt * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36228545Sbapt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37178431Sscf * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38178431Sscf * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39184831Sscf * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40228545Sbapt * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41178431Sscf * POSSIBILITY OF SUCH DAMAGES.
42178431Sscf */
43178431Sscf
44178431Sscf#include <contrib/dev/acpica/include/acpi.h>
45228545Sbapt#include <contrib/dev/acpica/include/accommon.h>
46178431Sscf#include <contrib/dev/acpica/include/acparser.h>
47228545Sbapt#include <contrib/dev/acpica/include/amlcode.h>
48228545Sbapt#include <contrib/dev/acpica/include/acdisasm.h>
49228545Sbapt#include <contrib/dev/acpica/include/acnamesp.h>
50228545Sbapt
51228545Sbapt#ifdef ACPI_DISASSEMBLER
52247919Sdb
53247919Sdb#define _COMPONENT          ACPI_CA_DEBUGGER
54228545Sbapt        ACPI_MODULE_NAME    ("dmopcode")
55178431Sscf
56228545Sbapt/* Local prototypes */
57228545Sbapt
58228545Sbaptstatic void
59228545SbaptAcpiDmMatchKeyword (
60228545Sbapt    ACPI_PARSE_OBJECT       *Op);
61242319Sbapt
62228545Sbapt
63228545Sbapt/*******************************************************************************
64228545Sbapt *
65228545Sbapt * FUNCTION:    AcpiDmPredefinedDescription
66228545Sbapt *
67228545Sbapt * PARAMETERS:  Op              - Name() parse object
68228545Sbapt *
69228545Sbapt * RETURN:      None
70228545Sbapt *
71228545Sbapt * DESCRIPTION: Emit a description comment for a predefined ACPI name.
72228545Sbapt *              Used for iASL compiler only.
73228545Sbapt *
74228545Sbapt ******************************************************************************/
75228545Sbapt
76228545Sbaptvoid
77228545SbaptAcpiDmPredefinedDescription (
78228545Sbapt    ACPI_PARSE_OBJECT       *Op)
79228545Sbapt{
80228545Sbapt#ifdef ACPI_ASL_COMPILER
81228545Sbapt    const AH_PREDEFINED_NAME    *Info;
82228545Sbapt    char                        *NameString;
83228545Sbapt    int                         LastCharIsDigit;
84228545Sbapt    int                         LastCharsAreHex;
85228545Sbapt
86228545Sbapt
87242319Sbapt    if (!Op)
88228545Sbapt    {
89228545Sbapt        return;
90228545Sbapt    }
91228545Sbapt
92228545Sbapt    /* Ensure that the comment field is emitted only once */
93228545Sbapt
94228545Sbapt    if (Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEF_CHECKED)
95228545Sbapt    {
96228545Sbapt        return;
97228545Sbapt    }
98228545Sbapt    Op->Common.DisasmFlags |= ACPI_PARSEOP_PREDEF_CHECKED;
99228545Sbapt
100228545Sbapt    /* Predefined name must start with an underscore */
101228545Sbapt
102228545Sbapt    NameString = ACPI_CAST_PTR (char, &Op->Named.Name);
103228545Sbapt    if (NameString[0] != '_')
104244744Sbapt    {
105244735Sbapt        return;
106228545Sbapt    }
107228545Sbapt
108228545Sbapt    /*
109228545Sbapt     * Check for the special ACPI names:
110228545Sbapt     * _ACd, _ALd, _EJd, _Exx, _Lxx, _Qxx, _Wxx, _T_a
111228545Sbapt     * (where d=decimal_digit, x=hex_digit, a=anything)
112228545Sbapt     *
113228545Sbapt     * Convert these to the generic name for table lookup.
114228545Sbapt     * Note: NameString is guaranteed to be upper case here.
115228545Sbapt     */
116228545Sbapt    LastCharIsDigit =
117228545Sbapt        (ACPI_IS_DIGIT (NameString[3]));    /* d */
118228545Sbapt    LastCharsAreHex =
119228545Sbapt        (ACPI_IS_XDIGIT (NameString[2]) &&  /* xx */
120228545Sbapt         ACPI_IS_XDIGIT (NameString[3]));
121228545Sbapt
122228545Sbapt    switch (NameString[1])
123228545Sbapt    {
124228545Sbapt    case 'A':
125228545Sbapt        if ((NameString[2] == 'C') && (LastCharIsDigit))
126228545Sbapt        {
127228545Sbapt            NameString = "_ACx";
128228545Sbapt        }
129228545Sbapt        else if ((NameString[2] == 'L') && (LastCharIsDigit))
130228545Sbapt        {
131228545Sbapt            NameString = "_ALx";
132228545Sbapt        }
133228545Sbapt        break;
134228545Sbapt
135228545Sbapt    case 'E':
136228545Sbapt        if ((NameString[2] == 'J') && (LastCharIsDigit))
137228545Sbapt        {
138228545Sbapt            NameString = "_EJx";
139228545Sbapt        }
140228545Sbapt        else if (LastCharsAreHex)
141228545Sbapt        {
142228545Sbapt            NameString = "_Exx";
143228545Sbapt        }
144228545Sbapt        break;
145228545Sbapt
146228545Sbapt    case 'L':
147228545Sbapt        if (LastCharsAreHex)
148228545Sbapt        {
149228545Sbapt            NameString = "_Lxx";
150228545Sbapt        }
151228545Sbapt        break;
152228545Sbapt
153228545Sbapt    case 'Q':
154228545Sbapt        if (LastCharsAreHex)
155228545Sbapt        {
156228545Sbapt            NameString = "_Qxx";
157228545Sbapt        }
158228545Sbapt        break;
159228545Sbapt
160228545Sbapt    case 'T':
161228545Sbapt        if (NameString[2] == '_')
162228545Sbapt        {
163228545Sbapt            NameString = "_T_x";
164228545Sbapt        }
165228545Sbapt        break;
166228545Sbapt
167228545Sbapt    case 'W':
168228545Sbapt        if (LastCharsAreHex)
169228545Sbapt        {
170228545Sbapt            NameString = "_Wxx";
171228545Sbapt        }
172228545Sbapt        break;
173228545Sbapt
174228545Sbapt    default:
175228545Sbapt        break;
176228545Sbapt    }
177228545Sbapt
178228545Sbapt    /* Match the name in the info table */
179228545Sbapt
180228545Sbapt    for (Info = AslPredefinedInfo; Info->Name; Info++)
181228545Sbapt    {
182228545Sbapt        if (ACPI_COMPARE_NAME (NameString, Info->Name))
183228545Sbapt        {
184228545Sbapt            AcpiOsPrintf ("  // %4.4s: %s",
185228545Sbapt                NameString, ACPI_CAST_PTR (char, Info->Description));
186228545Sbapt            return;
187228545Sbapt        }
188228545Sbapt    }
189228545Sbapt
190228545Sbapt#endif
191228545Sbapt    return;
192228545Sbapt}
193228545Sbapt
194228545Sbapt
195228545Sbapt/*******************************************************************************
196228545Sbapt *
197228545Sbapt * FUNCTION:    AcpiDmFieldPredefinedDescription
198228545Sbapt *
199228545Sbapt * PARAMETERS:  Op              - Parse object
200228545Sbapt *
201228545Sbapt * RETURN:      None
202228545Sbapt *
203228545Sbapt * DESCRIPTION: Emit a description comment for a resource descriptor tag
204228545Sbapt *              (which is a predefined ACPI name.) Used for iASL compiler only.
205228545Sbapt *
206228545Sbapt ******************************************************************************/
207228545Sbapt
208228545Sbaptvoid
209228545SbaptAcpiDmFieldPredefinedDescription (
210228545Sbapt    ACPI_PARSE_OBJECT       *Op)
211228545Sbapt{
212228545Sbapt#ifdef ACPI_ASL_COMPILER
213228545Sbapt    ACPI_PARSE_OBJECT       *IndexOp;
214228545Sbapt    char                    *Tag;
215228545Sbapt    const ACPI_OPCODE_INFO  *OpInfo;
216228545Sbapt    const AH_PREDEFINED_NAME *Info;
217228545Sbapt
218228545Sbapt
219228545Sbapt    if (!Op)
220228545Sbapt    {
221228545Sbapt        return;
222228545Sbapt    }
223228545Sbapt
224228545Sbapt    /* Ensure that the comment field is emitted only once */
225228545Sbapt
226228545Sbapt    if (Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEF_CHECKED)
227228545Sbapt    {
228228545Sbapt        return;
229228545Sbapt    }
230228545Sbapt    Op->Common.DisasmFlags |= ACPI_PARSEOP_PREDEF_CHECKED;
231228545Sbapt
232228545Sbapt    /*
233228545Sbapt     * Op must be one of the Create* operators: CreateField, CreateBitField,
234228545Sbapt     * CreateByteField, CreateWordField, CreateDwordField, CreateQwordField
235228545Sbapt     */
236228545Sbapt    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
237228545Sbapt    if (!(OpInfo->Flags & AML_CREATE))
238228545Sbapt    {
239228545Sbapt        return;
240228545Sbapt    }
241228545Sbapt
242228545Sbapt    /* Second argument is the Index argument */
243228545Sbapt
244228545Sbapt    IndexOp = Op->Common.Value.Arg;
245228545Sbapt    IndexOp = IndexOp->Common.Next;
246228545Sbapt
247228545Sbapt    /* Index argument must be a namepath */
248228545Sbapt
249228545Sbapt    if (IndexOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP)
250228545Sbapt    {
251228545Sbapt        return;
252228545Sbapt    }
253228545Sbapt
254228545Sbapt    /* Major cheat: We previously put the Tag ptr in the Node field */
255228545Sbapt
256228545Sbapt    Tag = ACPI_CAST_PTR (char, IndexOp->Common.Node);
257228545Sbapt
258228545Sbapt    /* Match the name in the info table */
259228545Sbapt
260228545Sbapt    for (Info = AslPredefinedInfo; Info->Name; Info++)
261228545Sbapt    {
262228545Sbapt        if (ACPI_COMPARE_NAME (Tag, Info->Name))
263228545Sbapt        {
264228545Sbapt            AcpiOsPrintf ("  // %4.4s: %s", Tag,
265228545Sbapt                ACPI_CAST_PTR (char, Info->Description));
266228545Sbapt            return;
267228545Sbapt        }
268228545Sbapt    }
269228545Sbapt
270228545Sbapt#endif
271228545Sbapt    return;
272228545Sbapt}
273228545Sbapt
274228545Sbapt
275228545Sbapt/*******************************************************************************
276228545Sbapt *
277228545Sbapt * FUNCTION:    AcpiDmMethodFlags
278228545Sbapt *
279228545Sbapt * PARAMETERS:  Op              - Method Object to be examined
280228545Sbapt *
281228545Sbapt * RETURN:      None
282228545Sbapt *
283228545Sbapt * DESCRIPTION: Decode control method flags
284228545Sbapt *
285228545Sbapt ******************************************************************************/
286228545Sbapt
287228545Sbaptvoid
288228545SbaptAcpiDmMethodFlags (
289228545Sbapt    ACPI_PARSE_OBJECT       *Op)
290228545Sbapt{
291228545Sbapt    UINT32                  Flags;
292228545Sbapt    UINT32                  Args;
293228545Sbapt
294228545Sbapt
295228545Sbapt    /* The next Op contains the flags */
296228545Sbapt
297228545Sbapt    Op = AcpiPsGetDepthNext (NULL, Op);
298228545Sbapt    Flags = (UINT8) Op->Common.Value.Integer;
299228545Sbapt    Args = Flags & 0x07;
300228545Sbapt
301228545Sbapt    /* Mark the Op as completed */
302228545Sbapt
303228545Sbapt    Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
304228545Sbapt
305228545Sbapt    /* 1) Method argument count */
306228545Sbapt
307228545Sbapt    AcpiOsPrintf (", %u, ", Args);
308228545Sbapt
309228545Sbapt    /* 2) Serialize rule */
310228545Sbapt
311228545Sbapt    if (!(Flags & 0x08))
312228545Sbapt    {
313228545Sbapt        AcpiOsPrintf ("Not");
314243334Sbapt    }
315243334Sbapt
316243328Sbapt    AcpiOsPrintf ("Serialized");
317243334Sbapt
318228545Sbapt    /* 3) SyncLevel */
319228545Sbapt
320228545Sbapt    if (Flags & 0xF0)
321245390Smjg    {
322228545Sbapt        AcpiOsPrintf (", %u", Flags >> 4);
323228545Sbapt    }
324228545Sbapt}
325228545Sbapt
326228545Sbapt
327228545Sbapt/*******************************************************************************
328228545Sbapt *
329228545Sbapt * FUNCTION:    AcpiDmFieldFlags
330228545Sbapt *
331228545Sbapt * PARAMETERS:  Op              - Field Object to be examined
332228545Sbapt *
333228545Sbapt * RETURN:      None
334228545Sbapt *
335228545Sbapt * DESCRIPTION: Decode Field definition flags
336228545Sbapt *
337228545Sbapt ******************************************************************************/
338228545Sbapt
339228545Sbaptvoid
340228545SbaptAcpiDmFieldFlags (
341228545Sbapt    ACPI_PARSE_OBJECT       *Op)
342178431Sscf{
343178431Sscf    UINT32                  Flags;
344178431Sscf
345178431Sscf
346178431Sscf    Op = Op->Common.Next;
347185237Sscf    Flags = (UINT8) Op->Common.Value.Integer;
348185237Sscf
349178431Sscf    /* Mark the Op as completed */
350178431Sscf
351185237Sscf    Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
352185237Sscf
353185237Sscf    AcpiOsPrintf ("%s, ", AcpiGbl_AccessTypes [Flags & 0x07]);
354185237Sscf    AcpiOsPrintf ("%s, ", AcpiGbl_LockRule [(Flags & 0x10) >> 4]);
355185237Sscf    AcpiOsPrintf ("%s)",  AcpiGbl_UpdateRules [(Flags & 0x60) >> 5]);
356185237Sscf}
357185237Sscf
358185237Sscf
359185237Sscf/*******************************************************************************
360185237Sscf *
361185237Sscf * FUNCTION:    AcpiDmAddressSpace
362185237Sscf *
363178431Sscf * PARAMETERS:  SpaceId         - ID to be translated
364178431Sscf *
365185237Sscf * RETURN:      None
366185237Sscf *
367185237Sscf * DESCRIPTION: Decode a SpaceId to an AddressSpaceKeyword
368185237Sscf *
369245385Smjg ******************************************************************************/
370245385Smjg
371245385Smjgvoid
372245385SmjgAcpiDmAddressSpace (
373185237Sscf    UINT8                   SpaceId)
374185237Sscf{
375178431Sscf
376178431Sscf    if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
377245385Smjg    {
378178431Sscf        if (SpaceId == 0x7F)
379178431Sscf        {
380178431Sscf            AcpiOsPrintf ("FFixedHW, ");
381185237Sscf        }
382185237Sscf        else
383178431Sscf        {
384178431Sscf            AcpiOsPrintf ("0x%.2X, ", SpaceId);
385185237Sscf        }
386178431Sscf    }
387178431Sscf    else
388178431Sscf    {
389178431Sscf        AcpiOsPrintf ("%s, ", AcpiGbl_RegionTypes [SpaceId]);
390178431Sscf    }
391178431Sscf}
392178431Sscf
393178431Sscf
394245386Smjg/*******************************************************************************
395245387Smjg *
396178431Sscf * FUNCTION:    AcpiDmRegionFlags
397245387Smjg *
398185237Sscf * PARAMETERS:  Op              - Object to be examined
399178431Sscf *
400178431Sscf * RETURN:      None
401178431Sscf *
402185237Sscf * DESCRIPTION: Decode OperationRegion flags
403178431Sscf *
404185237Sscf ******************************************************************************/
405185237Sscf
406185237Sscfvoid
407185237SscfAcpiDmRegionFlags (
408185237Sscf    ACPI_PARSE_OBJECT       *Op)
409185237Sscf{
410178431Sscf
411178431Sscf
412245387Smjg    /* The next Op contains the SpaceId */
413178431Sscf
414245387Smjg    Op = AcpiPsGetDepthNext (NULL, Op);
415200423Sscf
416245387Smjg    /* Mark the Op as completed */
417245387Smjg
418185237Sscf    Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
419245387Smjg
420245387Smjg    AcpiOsPrintf (", ");
421245387Smjg    AcpiDmAddressSpace ((UINT8) Op->Common.Value.Integer);
422185237Sscf}
423245387Smjg
424178431Sscf
425178431Sscf/*******************************************************************************
426178431Sscf *
427178431Sscf * FUNCTION:    AcpiDmMatchOp
428178431Sscf *
429178431Sscf * PARAMETERS:  Op              - Match Object to be examined
430178431Sscf *
431178431Sscf * RETURN:      None
432178431Sscf *
433178431Sscf * DESCRIPTION: Decode Match opcode operands
434247919Sdb *
435247919Sdb ******************************************************************************/
436247919Sdb
437247919Sdbvoid
438247919SdbAcpiDmMatchOp (
439247919Sdb    ACPI_PARSE_OBJECT       *Op)
440247919Sdb{
441247919Sdb    ACPI_PARSE_OBJECT       *NextOp;
442244742Sbapt
443184831Sscf
444185237Sscf    NextOp = AcpiPsGetDepthNext (NULL, Op);
445178431Sscf    NextOp = NextOp->Common.Next;
446247919Sdb
447247919Sdb    if (!NextOp)
448178431Sscf    {
449244742Sbapt        /* Handle partial tree during single-step */
450178431Sscf
451247919Sdb        return;
452247919Sdb    }
453247919Sdb
454247919Sdb    /* Mark the two nodes that contain the encoding for the match keywords */
455247919Sdb
456247919Sdb    NextOp->Common.DisasmOpcode = ACPI_DASM_MATCHOP;
457247919Sdb
458247919Sdb    NextOp = NextOp->Common.Next;
459247919Sdb    NextOp = NextOp->Common.Next;
460247919Sdb    NextOp->Common.DisasmOpcode = ACPI_DASM_MATCHOP;
461247919Sdb}
462247919Sdb
463247919Sdb
464247919Sdb/*******************************************************************************
465247919Sdb *
466247919Sdb * FUNCTION:    AcpiDmMatchKeyword
467247919Sdb *
468247919Sdb * PARAMETERS:  Op              - Match Object to be examined
469247919Sdb *
470247919Sdb * RETURN:      None
471247919Sdb *
472247919Sdb * DESCRIPTION: Decode Match opcode operands
473247919Sdb *
474247919Sdb ******************************************************************************/
475247919Sdb
476247919Sdbstatic void
477247919SdbAcpiDmMatchKeyword (
478247919Sdb    ACPI_PARSE_OBJECT       *Op)
479247919Sdb{
480247919Sdb
481247919Sdb
482247919Sdb    if (((UINT32) Op->Common.Value.Integer) > ACPI_MAX_MATCH_OPCODE)
483247919Sdb    {
484247919Sdb        AcpiOsPrintf ("/* Unknown Match Keyword encoding */");
485247919Sdb    }
486247919Sdb    else
487247919Sdb    {
488247919Sdb        AcpiOsPrintf ("%s", ACPI_CAST_PTR (char,
489244747Sbapt            AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer]));
490244742Sbapt    }
491244742Sbapt}
492244742Sbapt
493247919Sdb
494178431Sscf/*******************************************************************************
495244742Sbapt *
496244742Sbapt * FUNCTION:    AcpiDmDisassembleOneOp
497247919Sdb *
498244777Sbapt * PARAMETERS:  WalkState           - Current walk info
499178431Sscf *              Info                - Parse tree walk info
500244742Sbapt *              Op                  - Op that is to be printed
501244742Sbapt *
502247919Sdb * RETURN:      None
503244777Sbapt *
504244742Sbapt * DESCRIPTION: Disassemble a single AML opcode
505247919Sdb *
506247919Sdb ******************************************************************************/
507247919Sdb
508247919Sdbvoid
509178431SscfAcpiDmDisassembleOneOp (
510247919Sdb    ACPI_WALK_STATE         *WalkState,
511247919Sdb    ACPI_OP_WALK_INFO       *Info,
512247919Sdb    ACPI_PARSE_OBJECT       *Op)
513247919Sdb{
514247919Sdb    const ACPI_OPCODE_INFO  *OpInfo = NULL;
515178431Sscf    UINT32                  Offset;
516244742Sbapt    UINT32                  Length;
517178431Sscf    ACPI_PARSE_OBJECT       *Child;
518178431Sscf    ACPI_STATUS             Status;
519178431Sscf    UINT8                   *Aml;
520247919Sdb
521244736Sbapt
522247919Sdb    if (!Op)
523247919Sdb    {
524244736Sbapt        AcpiOsPrintf ("<NULL OP PTR>");
525247919Sdb        return;
526247919Sdb    }
527244736Sbapt
528247919Sdb    switch (Op->Common.DisasmOpcode)
529247919Sdb    {
530247919Sdb    case ACPI_DASM_MATCHOP:
531247919Sdb
532247919Sdb        AcpiDmMatchKeyword (Op);
533247919Sdb        return;
534247919Sdb
535247919Sdb    case ACPI_DASM_LNOT_SUFFIX:
536244736Sbapt        switch (Op->Common.AmlOpcode)
537247919Sdb        {
538247919Sdb        case AML_LEQUAL_OP:
539247919Sdb            AcpiOsPrintf ("LNotEqual");
540244736Sbapt            break;
541247919Sdb
542244736Sbapt        case AML_LGREATER_OP:
543247919Sdb            AcpiOsPrintf ("LLessEqual");
544247919Sdb            break;
545247919Sdb
546247919Sdb        case AML_LLESS_OP:
547247919Sdb            AcpiOsPrintf ("LGreaterEqual");
548247919Sdb            break;
549244736Sbapt
550244736Sbapt        default:
551244736Sbapt            break;
552178431Sscf        }
553178431Sscf        Op->Common.DisasmOpcode = 0;
554178431Sscf        Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
555178431Sscf        return;
556178431Sscf
557178431Sscf    default:
558178431Sscf        break;
559178431Sscf    }
560178431Sscf
561178431Sscf
562178431Sscf    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
563178431Sscf
564178431Sscf    /* The op and arguments */
565178431Sscf
566184831Sscf    switch (Op->Common.AmlOpcode)
567184831Sscf    {
568178431Sscf    case AML_LNOT_OP:
569178431Sscf
570178431Sscf        Child = Op->Common.Value.Arg;
571178431Sscf        if ((Child->Common.AmlOpcode == AML_LEQUAL_OP) ||
572178431Sscf            (Child->Common.AmlOpcode == AML_LGREATER_OP) ||
573184831Sscf            (Child->Common.AmlOpcode == AML_LLESS_OP))
574178431Sscf        {
575178431Sscf            Child->Common.DisasmOpcode = ACPI_DASM_LNOT_SUFFIX;
576178431Sscf            Op->Common.DisasmOpcode = ACPI_DASM_LNOT_PREFIX;
577178431Sscf        }
578178431Sscf        else
579178431Sscf        {
580178431Sscf            AcpiOsPrintf ("%s", OpInfo->Name);
581185237Sscf        }
582185237Sscf        break;
583185237Sscf
584185237Sscf    case AML_BYTE_OP:
585185237Sscf
586185237Sscf        AcpiOsPrintf ("0x%2.2X", (UINT32) Op->Common.Value.Integer);
587185237Sscf        break;
588185237Sscf
589178431Sscf
590178431Sscf    case AML_WORD_OP:
591185237Sscf
592185237Sscf        if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID)
593178431Sscf        {
594178431Sscf            AcpiDmEisaId ((UINT32) Op->Common.Value.Integer);
595178431Sscf        }
596178431Sscf        else
597178431Sscf        {
598178431Sscf            AcpiOsPrintf ("0x%4.4X", (UINT32) Op->Common.Value.Integer);
599178431Sscf        }
600178431Sscf        break;
601178431Sscf
602178431Sscf
603184831Sscf    case AML_DWORD_OP:
604185237Sscf
605185237Sscf        if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID)
606178431Sscf        {
607185237Sscf            AcpiDmEisaId ((UINT32) Op->Common.Value.Integer);
608178431Sscf        }
609185237Sscf        else
610185237Sscf        {
611178431Sscf            AcpiOsPrintf ("0x%8.8X", (UINT32) Op->Common.Value.Integer);
612178431Sscf        }
613185237Sscf        break;
614185237Sscf
615178431Sscf
616178431Sscf    case AML_QWORD_OP:
617178431Sscf
618185237Sscf        AcpiOsPrintf ("0x%8.8X%8.8X",
619178431Sscf            ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
620        break;
621
622
623    case AML_STRING_OP:
624
625        AcpiUtPrintString (Op->Common.Value.String, ACPI_UINT8_MAX);
626        break;
627
628
629    case AML_BUFFER_OP:
630
631        /*
632         * Determine the type of buffer.  We can have one of the following:
633         *
634         * 1) ResourceTemplate containing Resource Descriptors.
635         * 2) Unicode String buffer
636         * 3) ASCII String buffer
637         * 4) Raw data buffer (if none of the above)
638         *
639         * Since there are no special AML opcodes to differentiate these
640         * types of buffers, we have to closely look at the data in the
641         * buffer to determine the type.
642         */
643        if (!AcpiGbl_NoResourceDisassembly)
644        {
645            Status = AcpiDmIsResourceTemplate (Op);
646            if (ACPI_SUCCESS (Status))
647            {
648                Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE;
649                AcpiOsPrintf ("ResourceTemplate");
650                break;
651            }
652            else if (Status == AE_AML_NO_RESOURCE_END_TAG)
653            {
654                AcpiOsPrintf ("/**** Is ResourceTemplate, but EndTag not at buffer end ****/ ");
655            }
656        }
657
658        if (AcpiDmIsUnicodeBuffer (Op))
659        {
660            Op->Common.DisasmOpcode = ACPI_DASM_UNICODE;
661            AcpiOsPrintf ("Unicode (");
662        }
663        else if (AcpiDmIsStringBuffer (Op))
664        {
665            Op->Common.DisasmOpcode = ACPI_DASM_STRING;
666            AcpiOsPrintf ("Buffer");
667        }
668        else if (AcpiDmIsPldBuffer (Op))
669        {
670            Op->Common.DisasmOpcode = ACPI_DASM_PLD_METHOD;
671            AcpiOsPrintf ("Buffer");
672        }
673        else
674        {
675            Op->Common.DisasmOpcode = ACPI_DASM_BUFFER;
676            AcpiOsPrintf ("Buffer");
677        }
678        break;
679
680
681    case AML_INT_STATICSTRING_OP:
682
683        if (Op->Common.Value.String)
684        {
685            AcpiOsPrintf ("%s", Op->Common.Value.String);
686        }
687        else
688        {
689            AcpiOsPrintf ("\"<NULL STATIC STRING PTR>\"");
690        }
691        break;
692
693
694    case AML_INT_NAMEPATH_OP:
695
696        AcpiDmNamestring (Op->Common.Value.Name);
697        break;
698
699
700    case AML_INT_NAMEDFIELD_OP:
701
702        Length = AcpiDmDumpName (Op->Named.Name);
703        AcpiOsPrintf (",%*.s  %u", (unsigned) (5 - Length), " ",
704            (UINT32) Op->Common.Value.Integer);
705        AcpiDmCommaIfFieldMember (Op);
706
707        Info->BitOffset += (UINT32) Op->Common.Value.Integer;
708        break;
709
710
711    case AML_INT_RESERVEDFIELD_OP:
712
713        /* Offset() -- Must account for previous offsets */
714
715        Offset = (UINT32) Op->Common.Value.Integer;
716        Info->BitOffset += Offset;
717
718        if (Info->BitOffset % 8 == 0)
719        {
720            AcpiOsPrintf ("Offset (0x%.2X)", ACPI_DIV_8 (Info->BitOffset));
721        }
722        else
723        {
724            AcpiOsPrintf ("    ,   %u", Offset);
725        }
726
727        AcpiDmCommaIfFieldMember (Op);
728        break;
729
730
731    case AML_INT_ACCESSFIELD_OP:
732    case AML_INT_EXTACCESSFIELD_OP:
733
734        AcpiOsPrintf ("AccessAs (%s, ",
735            AcpiGbl_AccessTypes [(UINT32) (Op->Common.Value.Integer & 0x7)]);
736
737        AcpiDmDecodeAttribute ((UINT8) (Op->Common.Value.Integer >> 8));
738
739        if (Op->Common.AmlOpcode == AML_INT_EXTACCESSFIELD_OP)
740        {
741            AcpiOsPrintf (" (0x%2.2X)", (unsigned) ((Op->Common.Value.Integer >> 16) & 0xFF));
742        }
743
744        AcpiOsPrintf (")");
745        AcpiDmCommaIfFieldMember (Op);
746        break;
747
748
749    case AML_INT_CONNECTION_OP:
750
751        /*
752         * Two types of Connection() - one with a buffer object, the
753         * other with a namestring that points to a buffer object.
754         */
755        AcpiOsPrintf ("Connection (");
756        Child = Op->Common.Value.Arg;
757
758        if (Child->Common.AmlOpcode == AML_INT_BYTELIST_OP)
759        {
760            AcpiOsPrintf ("\n");
761
762            Aml = Child->Named.Data;
763            Length = (UINT32) Child->Common.Value.Integer;
764
765            Info->Level += 1;
766            Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE;
767            AcpiDmResourceTemplate (Info, Op->Common.Parent, Aml, Length);
768
769            Info->Level -= 1;
770            AcpiDmIndent (Info->Level);
771        }
772        else
773        {
774            AcpiDmNamestring (Child->Common.Value.Name);
775        }
776
777        AcpiOsPrintf (")");
778        AcpiDmCommaIfFieldMember (Op);
779        AcpiOsPrintf ("\n");
780
781        Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; /* for now, ignore in AcpiDmAscendingOp */
782        Child->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
783        break;
784
785    case AML_INT_BYTELIST_OP:
786
787        AcpiDmByteList (Info, Op);
788        break;
789
790
791    case AML_INT_METHODCALL_OP:
792
793        Op = AcpiPsGetDepthNext (NULL, Op);
794        Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
795
796        AcpiDmNamestring (Op->Common.Value.Name);
797        break;
798
799
800    default:
801
802        /* Just get the opcode name and print it */
803
804        AcpiOsPrintf ("%s", OpInfo->Name);
805
806
807#ifdef ACPI_DEBUGGER
808
809        if ((Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) &&
810            (WalkState) &&
811            (WalkState->Results) &&
812            (WalkState->ResultCount))
813        {
814            AcpiDmDecodeInternalObject (
815                WalkState->Results->Results.ObjDesc [
816                    (WalkState->ResultCount - 1) %
817                        ACPI_RESULTS_FRAME_OBJ_NUM]);
818        }
819#endif
820
821        break;
822    }
823}
824
825#endif  /* ACPI_DISASSEMBLER */
826