dmopcode.c revision 272444
1193323Sed/*******************************************************************************
2193323Sed *
3193323Sed * Module Name: dmopcode - AML disassembler, specific AML opcodes
4193323Sed *
5193323Sed ******************************************************************************/
6193323Sed
7193323Sed/*
8193323Sed * Copyright (C) 2000 - 2014, Intel Corp.
9193323Sed * All rights reserved.
10218893Sdim *
11218893Sdim * Redistribution and use in source and binary forms, with or without
12218893Sdim * modification, are permitted provided that the following conditions
13193323Sed * are met:
14193323Sed * 1. Redistributions of source code must retain the above copyright
15193323Sed *    notice, this list of conditions, and the following disclaimer,
16193323Sed *    without modification.
17218893Sdim * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18218893Sdim *    substantially similar to the "NO WARRANTY" disclaimer below
19193323Sed *    ("Disclaimer") and any redistribution must be conditioned upon
20221345Sdim *    including a substantially similar Disclaimer requirement for further
21205218Srdivacky *    binary redistribution.
22205218Srdivacky * 3. Neither the names of the above-listed copyright holders nor the names
23193323Sed *    of any contributors may be used to endorse or promote products derived
24193323Sed *    from this software without specific prior written permission.
25193323Sed *
26193323Sed * Alternatively, this software may be distributed under the terms of the
27218893Sdim * GNU General Public License ("GPL") version 2 as published by the Free
28218893Sdim * Software Foundation.
29218893Sdim *
30218893Sdim * NO WARRANTY
31218893Sdim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32218893Sdim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33218893Sdim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34218893Sdim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35218893Sdim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36218893Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37218893Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38218893Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39218893Sdim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40218893Sdim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41218893Sdim * POSSIBILITY OF SUCH DAMAGES.
42218893Sdim */
43218893Sdim
44218893Sdim#include <contrib/dev/acpica/include/acpi.h>
45218893Sdim#include <contrib/dev/acpica/include/accommon.h>
46218893Sdim#include <contrib/dev/acpica/include/acparser.h>
47218893Sdim#include <contrib/dev/acpica/include/amlcode.h>
48218893Sdim#include <contrib/dev/acpica/include/acdisasm.h>
49218893Sdim#include <contrib/dev/acpica/include/acinterp.h>
50218893Sdim#include <contrib/dev/acpica/include/acnamesp.h>
51224145Sdim
52218893Sdim#ifdef ACPI_DISASSEMBLER
53224145Sdim
54224145Sdim#define _COMPONENT          ACPI_CA_DEBUGGER
55224145Sdim        ACPI_MODULE_NAME    ("dmopcode")
56224145Sdim
57218893Sdim/* Local prototypes */
58218893Sdim
59218893Sdimstatic void
60218893SdimAcpiDmMatchKeyword (
61218893Sdim    ACPI_PARSE_OBJECT       *Op);
62218893Sdim
63218893Sdim
64218893Sdim/*******************************************************************************
65218893Sdim *
66218893Sdim * FUNCTION:    AcpiDmDisplayTargetPathname
67218893Sdim *
68218893Sdim * PARAMETERS:  Op              - Parse object
69218893Sdim *
70218893Sdim * RETURN:      None
71218893Sdim *
72218893Sdim * DESCRIPTION: For AML opcodes that have a target operand, display the full
73218893Sdim *              pathname for the target, in a comment field. Handles Return()
74193323Sed *              statements also.
75193323Sed *
76193323Sed ******************************************************************************/
77193323Sed
78193323Sedvoid
79193323SedAcpiDmDisplayTargetPathname (
80193323Sed    ACPI_PARSE_OBJECT       *Op)
81193323Sed{
82193323Sed    ACPI_PARSE_OBJECT       *NextOp;
83193323Sed    ACPI_PARSE_OBJECT       *PrevOp = NULL;
84193323Sed    char                    *Pathname;
85193323Sed    const ACPI_OPCODE_INFO  *OpInfo;
86193323Sed
87193323Sed
88193323Sed    if (Op->Common.AmlOpcode == AML_RETURN_OP)
89193323Sed    {
90193323Sed        PrevOp = Op->Asl.Value.Arg;
91193323Sed    }
92193323Sed    else
93193323Sed    {
94193323Sed        OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
95193323Sed        if (!(OpInfo->Flags & AML_HAS_TARGET))
96193323Sed        {
97193323Sed            return;
98193323Sed        }
99193323Sed
100193323Sed        /* Target is the last Op in the arg list */
101193323Sed
102193323Sed        NextOp = Op->Asl.Value.Arg;
103193323Sed        while (NextOp)
104193323Sed        {
105193323Sed            PrevOp = NextOp;
106193323Sed            NextOp = PrevOp->Asl.Next;
107193323Sed        }
108193323Sed    }
109193323Sed
110221345Sdim    if (!PrevOp)
111221345Sdim    {
112221345Sdim        return;
113221345Sdim    }
114193323Sed
115193323Sed    /* We must have a namepath AML opcode */
116193323Sed
117193323Sed    if (PrevOp->Asl.AmlOpcode != AML_INT_NAMEPATH_OP)
118193323Sed    {
119193323Sed        return;
120193323Sed    }
121193323Sed
122193323Sed    /* A null string is the "no target specified" case */
123193323Sed
124193323Sed    if (!PrevOp->Asl.Value.String)
125193323Sed    {
126193323Sed        return;
127193323Sed    }
128193323Sed
129193323Sed    /* No node means "unresolved external reference" */
130193323Sed
131193323Sed    if (!PrevOp->Asl.Node)
132193323Sed    {
133193323Sed        AcpiOsPrintf (" /* External reference */");
134193323Sed        return;
135193323Sed    }
136193323Sed
137193323Sed    /* Ignore if path is already from the root */
138193323Sed
139193323Sed    if (*PrevOp->Asl.Value.String == '\\')
140193323Sed    {
141193323Sed        return;
142193323Sed    }
143193323Sed
144193323Sed    /* Now: we can get the full pathname */
145193323Sed
146221345Sdim    Pathname = AcpiNsGetExternalPathname (PrevOp->Asl.Node);
147221345Sdim    if (!Pathname)
148221345Sdim    {
149221345Sdim        return;
150205218Srdivacky    }
151205218Srdivacky
152205218Srdivacky    AcpiOsPrintf (" /* %s */", Pathname);
153205218Srdivacky    ACPI_FREE (Pathname);
154205218Srdivacky}
155193323Sed
156193323Sed
157193323Sed/*******************************************************************************
158193323Sed *
159193323Sed * FUNCTION:    AcpiDmNotifyDescription
160193323Sed *
161193323Sed * PARAMETERS:  Op              - Name() parse object
162193323Sed *
163193323Sed * RETURN:      None
164193323Sed *
165193323Sed * DESCRIPTION: Emit a description comment for the value associated with a
166193323Sed *              Notify() operator.
167193323Sed *
168193323Sed ******************************************************************************/
169193323Sed
170205218Srdivackyvoid
171205218SrdivackyAcpiDmNotifyDescription (
172205218Srdivacky    ACPI_PARSE_OBJECT       *Op)
173205218Srdivacky{
174221345Sdim    ACPI_PARSE_OBJECT       *NextOp;
175221345Sdim    ACPI_NAMESPACE_NODE     *Node;
176221345Sdim    UINT8                   NotifyValue;
177221345Sdim    UINT8                   Type = ACPI_TYPE_ANY;
178221345Sdim
179221345Sdim
180221345Sdim    /* The notify value is the second argument */
181221345Sdim
182221345Sdim    NextOp = Op->Asl.Value.Arg;
183221345Sdim    NextOp = NextOp->Asl.Next;
184221345Sdim
185221345Sdim    switch (NextOp->Common.AmlOpcode)
186221345Sdim    {
187221345Sdim    case AML_ZERO_OP:
188221345Sdim    case AML_ONE_OP:
189221345Sdim
190        NotifyValue = (UINT8) NextOp->Common.AmlOpcode;
191        break;
192
193    case AML_BYTE_OP:
194
195        NotifyValue = (UINT8) NextOp->Asl.Value.Integer;
196        break;
197
198    default:
199        return;
200    }
201
202    /*
203     * Attempt to get the namespace node so we can determine the object type.
204     * Some notify values are dependent on the object type (Device, Thermal,
205     * or Processor).
206     */
207    Node = Op->Asl.Node;
208    if (Node)
209    {
210        Type = Node->Type;
211    }
212
213    AcpiOsPrintf (" // %s", AcpiUtGetNotifyName (NotifyValue, Type));
214}
215
216
217/*******************************************************************************
218 *
219 * FUNCTION:    AcpiDmPredefinedDescription
220 *
221 * PARAMETERS:  Op              - Name() parse object
222 *
223 * RETURN:      None
224 *
225 * DESCRIPTION: Emit a description comment for a predefined ACPI name.
226 *              Used for iASL compiler only.
227 *
228 ******************************************************************************/
229
230void
231AcpiDmPredefinedDescription (
232    ACPI_PARSE_OBJECT       *Op)
233{
234#ifdef ACPI_ASL_COMPILER
235    const AH_PREDEFINED_NAME    *Info;
236    char                        *NameString;
237    int                         LastCharIsDigit;
238    int                         LastCharsAreHex;
239
240
241    if (!Op)
242    {
243        return;
244    }
245
246    /* Ensure that the comment field is emitted only once */
247
248    if (Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEF_CHECKED)
249    {
250        return;
251    }
252    Op->Common.DisasmFlags |= ACPI_PARSEOP_PREDEF_CHECKED;
253
254    /* Predefined name must start with an underscore */
255
256    NameString = ACPI_CAST_PTR (char, &Op->Named.Name);
257    if (NameString[0] != '_')
258    {
259        return;
260    }
261
262    /*
263     * Check for the special ACPI names:
264     * _ACd, _ALd, _EJd, _Exx, _Lxx, _Qxx, _Wxx, _T_a
265     * (where d=decimal_digit, x=hex_digit, a=anything)
266     *
267     * Convert these to the generic name for table lookup.
268     * Note: NameString is guaranteed to be upper case here.
269     */
270    LastCharIsDigit =
271        (ACPI_IS_DIGIT (NameString[3]));    /* d */
272    LastCharsAreHex =
273        (ACPI_IS_XDIGIT (NameString[2]) &&  /* xx */
274         ACPI_IS_XDIGIT (NameString[3]));
275
276    switch (NameString[1])
277    {
278    case 'A':
279
280        if ((NameString[2] == 'C') && (LastCharIsDigit))
281        {
282            NameString = "_ACx";
283        }
284        else if ((NameString[2] == 'L') && (LastCharIsDigit))
285        {
286            NameString = "_ALx";
287        }
288        break;
289
290    case 'E':
291
292        if ((NameString[2] == 'J') && (LastCharIsDigit))
293        {
294            NameString = "_EJx";
295        }
296        else if (LastCharsAreHex)
297        {
298            NameString = "_Exx";
299        }
300        break;
301
302    case 'L':
303
304        if (LastCharsAreHex)
305        {
306            NameString = "_Lxx";
307        }
308        break;
309
310    case 'Q':
311
312        if (LastCharsAreHex)
313        {
314            NameString = "_Qxx";
315        }
316        break;
317
318    case 'T':
319
320        if (NameString[2] == '_')
321        {
322            NameString = "_T_x";
323        }
324        break;
325
326    case 'W':
327
328        if (LastCharsAreHex)
329        {
330            NameString = "_Wxx";
331        }
332        break;
333
334    default:
335
336        break;
337    }
338
339    /* Match the name in the info table */
340
341    Info = AcpiAhMatchPredefinedName (NameString);
342    if (Info)
343    {
344        AcpiOsPrintf ("  // %4.4s: %s",
345            NameString, ACPI_CAST_PTR (char, Info->Description));
346    }
347
348#endif
349    return;
350}
351
352
353/*******************************************************************************
354 *
355 * FUNCTION:    AcpiDmFieldPredefinedDescription
356 *
357 * PARAMETERS:  Op              - Parse object
358 *
359 * RETURN:      None
360 *
361 * DESCRIPTION: Emit a description comment for a resource descriptor tag
362 *              (which is a predefined ACPI name.) Used for iASL compiler only.
363 *
364 ******************************************************************************/
365
366void
367AcpiDmFieldPredefinedDescription (
368    ACPI_PARSE_OBJECT       *Op)
369{
370#ifdef ACPI_ASL_COMPILER
371    ACPI_PARSE_OBJECT       *IndexOp;
372    char                    *Tag;
373    const ACPI_OPCODE_INFO  *OpInfo;
374    const AH_PREDEFINED_NAME *Info;
375
376
377    if (!Op)
378    {
379        return;
380    }
381
382    /* Ensure that the comment field is emitted only once */
383
384    if (Op->Common.DisasmFlags & ACPI_PARSEOP_PREDEF_CHECKED)
385    {
386        return;
387    }
388    Op->Common.DisasmFlags |= ACPI_PARSEOP_PREDEF_CHECKED;
389
390    /*
391     * Op must be one of the Create* operators: CreateField, CreateBitField,
392     * CreateByteField, CreateWordField, CreateDwordField, CreateQwordField
393     */
394    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
395    if (!(OpInfo->Flags & AML_CREATE))
396    {
397        return;
398    }
399
400    /* Second argument is the Index argument */
401
402    IndexOp = Op->Common.Value.Arg;
403    IndexOp = IndexOp->Common.Next;
404
405    /* Index argument must be a namepath */
406
407    if (IndexOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP)
408    {
409        return;
410    }
411
412    /* Major cheat: We previously put the Tag ptr in the Node field */
413
414    Tag = ACPI_CAST_PTR (char, IndexOp->Common.Node);
415    if (!Tag)
416    {
417        return;
418    }
419
420    /* Match the name in the info table */
421
422    Info = AcpiAhMatchPredefinedName (Tag);
423    if (Info)
424    {
425        AcpiOsPrintf ("  // %4.4s: %s", Tag,
426            ACPI_CAST_PTR (char, Info->Description));
427    }
428
429#endif
430    return;
431}
432
433
434/*******************************************************************************
435 *
436 * FUNCTION:    AcpiDmMethodFlags
437 *
438 * PARAMETERS:  Op              - Method Object to be examined
439 *
440 * RETURN:      None
441 *
442 * DESCRIPTION: Decode control method flags
443 *
444 ******************************************************************************/
445
446void
447AcpiDmMethodFlags (
448    ACPI_PARSE_OBJECT       *Op)
449{
450    UINT32                  Flags;
451    UINT32                  Args;
452
453
454    /* The next Op contains the flags */
455
456    Op = AcpiPsGetDepthNext (NULL, Op);
457    Flags = (UINT8) Op->Common.Value.Integer;
458    Args = Flags & 0x07;
459
460    /* Mark the Op as completed */
461
462    Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
463
464    /* 1) Method argument count */
465
466    AcpiOsPrintf (", %u, ", Args);
467
468    /* 2) Serialize rule */
469
470    if (!(Flags & 0x08))
471    {
472        AcpiOsPrintf ("Not");
473    }
474
475    AcpiOsPrintf ("Serialized");
476
477    /* 3) SyncLevel */
478
479    if (Flags & 0xF0)
480    {
481        AcpiOsPrintf (", %u", Flags >> 4);
482    }
483}
484
485
486/*******************************************************************************
487 *
488 * FUNCTION:    AcpiDmFieldFlags
489 *
490 * PARAMETERS:  Op              - Field Object to be examined
491 *
492 * RETURN:      None
493 *
494 * DESCRIPTION: Decode Field definition flags
495 *
496 ******************************************************************************/
497
498void
499AcpiDmFieldFlags (
500    ACPI_PARSE_OBJECT       *Op)
501{
502    UINT32                  Flags;
503
504
505    Op = Op->Common.Next;
506    Flags = (UINT8) Op->Common.Value.Integer;
507
508    /* Mark the Op as completed */
509
510    Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
511
512    AcpiOsPrintf ("%s, ", AcpiGbl_AccessTypes [Flags & 0x07]);
513    AcpiOsPrintf ("%s, ", AcpiGbl_LockRule [(Flags & 0x10) >> 4]);
514    AcpiOsPrintf ("%s)",  AcpiGbl_UpdateRules [(Flags & 0x60) >> 5]);
515}
516
517
518/*******************************************************************************
519 *
520 * FUNCTION:    AcpiDmAddressSpace
521 *
522 * PARAMETERS:  SpaceId         - ID to be translated
523 *
524 * RETURN:      None
525 *
526 * DESCRIPTION: Decode a SpaceId to an AddressSpaceKeyword
527 *
528 ******************************************************************************/
529
530void
531AcpiDmAddressSpace (
532    UINT8                   SpaceId)
533{
534
535    if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
536    {
537        if (SpaceId == 0x7F)
538        {
539            AcpiOsPrintf ("FFixedHW, ");
540        }
541        else
542        {
543            AcpiOsPrintf ("0x%.2X, ", SpaceId);
544        }
545    }
546    else
547    {
548        AcpiOsPrintf ("%s, ", AcpiGbl_RegionTypes [SpaceId]);
549    }
550}
551
552
553/*******************************************************************************
554 *
555 * FUNCTION:    AcpiDmRegionFlags
556 *
557 * PARAMETERS:  Op              - Object to be examined
558 *
559 * RETURN:      None
560 *
561 * DESCRIPTION: Decode OperationRegion flags
562 *
563 ******************************************************************************/
564
565void
566AcpiDmRegionFlags (
567    ACPI_PARSE_OBJECT       *Op)
568{
569
570
571    /* The next Op contains the SpaceId */
572
573    Op = AcpiPsGetDepthNext (NULL, Op);
574
575    /* Mark the Op as completed */
576
577    Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
578
579    AcpiOsPrintf (", ");
580    AcpiDmAddressSpace ((UINT8) Op->Common.Value.Integer);
581}
582
583
584/*******************************************************************************
585 *
586 * FUNCTION:    AcpiDmMatchOp
587 *
588 * PARAMETERS:  Op              - Match Object to be examined
589 *
590 * RETURN:      None
591 *
592 * DESCRIPTION: Decode Match opcode operands
593 *
594 ******************************************************************************/
595
596void
597AcpiDmMatchOp (
598    ACPI_PARSE_OBJECT       *Op)
599{
600    ACPI_PARSE_OBJECT       *NextOp;
601
602
603    NextOp = AcpiPsGetDepthNext (NULL, Op);
604    NextOp = NextOp->Common.Next;
605
606    if (!NextOp)
607    {
608        /* Handle partial tree during single-step */
609
610        return;
611    }
612
613    /* Mark the two nodes that contain the encoding for the match keywords */
614
615    NextOp->Common.DisasmOpcode = ACPI_DASM_MATCHOP;
616
617    NextOp = NextOp->Common.Next;
618    NextOp = NextOp->Common.Next;
619    NextOp->Common.DisasmOpcode = ACPI_DASM_MATCHOP;
620}
621
622
623/*******************************************************************************
624 *
625 * FUNCTION:    AcpiDmMatchKeyword
626 *
627 * PARAMETERS:  Op              - Match Object to be examined
628 *
629 * RETURN:      None
630 *
631 * DESCRIPTION: Decode Match opcode operands
632 *
633 ******************************************************************************/
634
635static void
636AcpiDmMatchKeyword (
637    ACPI_PARSE_OBJECT       *Op)
638{
639
640
641    if (((UINT32) Op->Common.Value.Integer) > ACPI_MAX_MATCH_OPCODE)
642    {
643        AcpiOsPrintf ("/* Unknown Match Keyword encoding */");
644    }
645    else
646    {
647        AcpiOsPrintf ("%s", ACPI_CAST_PTR (char,
648            AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer]));
649    }
650}
651
652
653/*******************************************************************************
654 *
655 * FUNCTION:    AcpiDmDisassembleOneOp
656 *
657 * PARAMETERS:  WalkState           - Current walk info
658 *              Info                - Parse tree walk info
659 *              Op                  - Op that is to be printed
660 *
661 * RETURN:      None
662 *
663 * DESCRIPTION: Disassemble a single AML opcode
664 *
665 ******************************************************************************/
666
667void
668AcpiDmDisassembleOneOp (
669    ACPI_WALK_STATE         *WalkState,
670    ACPI_OP_WALK_INFO       *Info,
671    ACPI_PARSE_OBJECT       *Op)
672{
673    const ACPI_OPCODE_INFO  *OpInfo = NULL;
674    UINT32                  Offset;
675    UINT32                  Length;
676    ACPI_PARSE_OBJECT       *Child;
677    ACPI_STATUS             Status;
678    UINT8                   *Aml;
679    const AH_DEVICE_ID      *IdInfo;
680
681
682    if (!Op)
683    {
684        AcpiOsPrintf ("<NULL OP PTR>");
685        return;
686    }
687
688    switch (Op->Common.DisasmOpcode)
689    {
690    case ACPI_DASM_MATCHOP:
691
692        AcpiDmMatchKeyword (Op);
693        return;
694
695    case ACPI_DASM_LNOT_SUFFIX:
696
697        switch (Op->Common.AmlOpcode)
698        {
699        case AML_LEQUAL_OP:
700
701            AcpiOsPrintf ("LNotEqual");
702            break;
703
704        case AML_LGREATER_OP:
705
706            AcpiOsPrintf ("LLessEqual");
707            break;
708
709        case AML_LLESS_OP:
710
711            AcpiOsPrintf ("LGreaterEqual");
712            break;
713
714        default:
715
716            break;
717        }
718        Op->Common.DisasmOpcode = 0;
719        Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
720        return;
721
722    default:
723        break;
724    }
725
726
727    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
728
729    /* The op and arguments */
730
731    switch (Op->Common.AmlOpcode)
732    {
733    case AML_LNOT_OP:
734
735        Child = Op->Common.Value.Arg;
736        if ((Child->Common.AmlOpcode == AML_LEQUAL_OP) ||
737            (Child->Common.AmlOpcode == AML_LGREATER_OP) ||
738            (Child->Common.AmlOpcode == AML_LLESS_OP))
739        {
740            Child->Common.DisasmOpcode = ACPI_DASM_LNOT_SUFFIX;
741            Op->Common.DisasmOpcode = ACPI_DASM_LNOT_PREFIX;
742        }
743        else
744        {
745            AcpiOsPrintf ("%s", OpInfo->Name);
746        }
747        break;
748
749    case AML_BYTE_OP:
750
751        AcpiOsPrintf ("0x%2.2X", (UINT32) Op->Common.Value.Integer);
752        break;
753
754    case AML_WORD_OP:
755
756        if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID)
757        {
758            AcpiDmDecompressEisaId ((UINT32) Op->Common.Value.Integer);
759        }
760        else
761        {
762            AcpiOsPrintf ("0x%4.4X", (UINT32) Op->Common.Value.Integer);
763        }
764        break;
765
766    case AML_DWORD_OP:
767
768        if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID)
769        {
770            AcpiDmDecompressEisaId ((UINT32) Op->Common.Value.Integer);
771        }
772        else
773        {
774            AcpiOsPrintf ("0x%8.8X", (UINT32) Op->Common.Value.Integer);
775        }
776        break;
777
778    case AML_QWORD_OP:
779
780        AcpiOsPrintf ("0x%8.8X%8.8X",
781            ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
782        break;
783
784    case AML_STRING_OP:
785
786        AcpiUtPrintString (Op->Common.Value.String, ACPI_UINT16_MAX);
787
788        /* For _HID/_CID strings, attempt to output a descriptive comment */
789
790        if (Op->Common.DisasmOpcode == ACPI_DASM_HID_STRING)
791        {
792            /* If we know about the ID, emit the description */
793
794            IdInfo = AcpiAhMatchHardwareId (Op->Common.Value.String);
795            if (IdInfo)
796            {
797                AcpiOsPrintf (" /* %s */", IdInfo->Description);
798            }
799        }
800        break;
801
802    case AML_BUFFER_OP:
803        /*
804         * Determine the type of buffer. We can have one of the following:
805         *
806         * 1) ResourceTemplate containing Resource Descriptors.
807         * 2) Unicode String buffer
808         * 3) ASCII String buffer
809         * 4) Raw data buffer (if none of the above)
810         *
811         * Since there are no special AML opcodes to differentiate these
812         * types of buffers, we have to closely look at the data in the
813         * buffer to determine the type.
814         */
815        if (!AcpiGbl_NoResourceDisassembly)
816        {
817            Status = AcpiDmIsResourceTemplate (WalkState, Op);
818            if (ACPI_SUCCESS (Status))
819            {
820                Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE;
821                AcpiOsPrintf ("ResourceTemplate");
822                break;
823            }
824            else if (Status == AE_AML_NO_RESOURCE_END_TAG)
825            {
826                AcpiOsPrintf ("/**** Is ResourceTemplate, but EndTag not at buffer end ****/ ");
827            }
828        }
829
830        if (AcpiDmIsUuidBuffer (Op))
831        {
832            Op->Common.DisasmOpcode = ACPI_DASM_UUID;
833            AcpiOsPrintf ("ToUUID (");
834        }
835        else if (AcpiDmIsUnicodeBuffer (Op))
836        {
837            Op->Common.DisasmOpcode = ACPI_DASM_UNICODE;
838            AcpiOsPrintf ("Unicode (");
839        }
840        else if (AcpiDmIsStringBuffer (Op))
841        {
842            Op->Common.DisasmOpcode = ACPI_DASM_STRING;
843            AcpiOsPrintf ("Buffer");
844        }
845        else if (AcpiDmIsPldBuffer (Op))
846        {
847            Op->Common.DisasmOpcode = ACPI_DASM_PLD_METHOD;
848            AcpiOsPrintf ("Buffer");
849        }
850        else
851        {
852            Op->Common.DisasmOpcode = ACPI_DASM_BUFFER;
853            AcpiOsPrintf ("Buffer");
854        }
855        break;
856
857    case AML_INT_STATICSTRING_OP:
858
859        if (Op->Common.Value.String)
860        {
861            AcpiOsPrintf ("%s", Op->Common.Value.String);
862        }
863        else
864        {
865            AcpiOsPrintf ("\"<NULL STATIC STRING PTR>\"");
866        }
867        break;
868
869    case AML_INT_NAMEPATH_OP:
870
871        AcpiDmNamestring (Op->Common.Value.Name);
872        break;
873
874    case AML_INT_NAMEDFIELD_OP:
875
876        Length = AcpiDmDumpName (Op->Named.Name);
877        AcpiOsPrintf (",%*.s  %u", (unsigned) (5 - Length), " ",
878            (UINT32) Op->Common.Value.Integer);
879        AcpiDmCommaIfFieldMember (Op);
880
881        Info->BitOffset += (UINT32) Op->Common.Value.Integer;
882        break;
883
884    case AML_INT_RESERVEDFIELD_OP:
885
886        /* Offset() -- Must account for previous offsets */
887
888        Offset = (UINT32) Op->Common.Value.Integer;
889        Info->BitOffset += Offset;
890
891        if (Info->BitOffset % 8 == 0)
892        {
893            AcpiOsPrintf ("Offset (0x%.2X)", ACPI_DIV_8 (Info->BitOffset));
894        }
895        else
896        {
897            AcpiOsPrintf ("    ,   %u", Offset);
898        }
899
900        AcpiDmCommaIfFieldMember (Op);
901        break;
902
903    case AML_INT_ACCESSFIELD_OP:
904    case AML_INT_EXTACCESSFIELD_OP:
905
906        AcpiOsPrintf ("AccessAs (%s, ",
907            AcpiGbl_AccessTypes [(UINT32) (Op->Common.Value.Integer & 0x7)]);
908
909        AcpiDmDecodeAttribute ((UINT8) (Op->Common.Value.Integer >> 8));
910
911        if (Op->Common.AmlOpcode == AML_INT_EXTACCESSFIELD_OP)
912        {
913            AcpiOsPrintf (" (0x%2.2X)", (unsigned) ((Op->Common.Value.Integer >> 16) & 0xFF));
914        }
915
916        AcpiOsPrintf (")");
917        AcpiDmCommaIfFieldMember (Op);
918        break;
919
920    case AML_INT_CONNECTION_OP:
921        /*
922         * Two types of Connection() - one with a buffer object, the
923         * other with a namestring that points to a buffer object.
924         */
925        AcpiOsPrintf ("Connection (");
926        Child = Op->Common.Value.Arg;
927
928        if (Child->Common.AmlOpcode == AML_INT_BYTELIST_OP)
929        {
930            AcpiOsPrintf ("\n");
931
932            Aml = Child->Named.Data;
933            Length = (UINT32) Child->Common.Value.Integer;
934
935            Info->Level += 1;
936            Info->MappingOp = Op;
937            Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE;
938
939            AcpiDmResourceTemplate (Info, Op->Common.Parent, Aml, Length);
940
941            Info->Level -= 1;
942            AcpiDmIndent (Info->Level);
943        }
944        else
945        {
946            AcpiDmNamestring (Child->Common.Value.Name);
947        }
948
949        AcpiOsPrintf (")");
950        AcpiDmCommaIfFieldMember (Op);
951        AcpiOsPrintf ("\n");
952
953        Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; /* for now, ignore in AcpiDmAscendingOp */
954        Child->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
955        break;
956
957    case AML_INT_BYTELIST_OP:
958
959        AcpiDmByteList (Info, Op);
960        break;
961
962    case AML_INT_METHODCALL_OP:
963
964        Op = AcpiPsGetDepthNext (NULL, Op);
965        Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
966
967        AcpiDmNamestring (Op->Common.Value.Name);
968        break;
969
970    default:
971
972        /* Just get the opcode name and print it */
973
974        AcpiOsPrintf ("%s", OpInfo->Name);
975
976
977#ifdef ACPI_DEBUGGER
978
979        if ((Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) &&
980            (WalkState) &&
981            (WalkState->Results) &&
982            (WalkState->ResultCount))
983        {
984            AcpiDmDecodeInternalObject (
985                WalkState->Results->Results.ObjDesc [
986                    (WalkState->ResultCount - 1) %
987                        ACPI_RESULTS_FRAME_OBJ_NUM]);
988        }
989#endif
990
991        break;
992    }
993}
994
995#endif  /* ACPI_DISASSEMBLER */
996