xref: /onnv-gate/usr/src/uts/intel/io/acpica/disassembler/dmbuffer.c (revision 7851:e828bbb1689c)
13446Smrj /*******************************************************************************
23446Smrj  *
33446Smrj  * Module Name: dmbuffer - AML disassembler, buffer and string support
4*7851SDana.Myers@Sun.COM  *              $Revision: 1.26 $
53446Smrj  *
63446Smrj  ******************************************************************************/
73446Smrj 
83446Smrj /******************************************************************************
93446Smrj  *
103446Smrj  * 1. Copyright Notice
113446Smrj  *
12*7851SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp.
133446Smrj  * All rights reserved.
143446Smrj  *
153446Smrj  * 2. License
163446Smrj  *
173446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
183446Smrj  * rights.  You may have additional license terms from the party that provided
193446Smrj  * you this software, covering your right to use that party's intellectual
203446Smrj  * property rights.
213446Smrj  *
223446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
233446Smrj  * copy of the source code appearing in this file ("Covered Code") an
243446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
253446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
263446Smrj  * make derivatives, distribute, use and display any portion of the Covered
273446Smrj  * Code in any form, with the right to sublicense such rights; and
283446Smrj  *
293446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
303446Smrj  * license (with the right to sublicense), under only those claims of Intel
313446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
323446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
333446Smrj  * solely to the minimum extent necessary to exercise the above copyright
343446Smrj  * license, and in no event shall the patent license extend to any additions
353446Smrj  * to or modifications of the Original Intel Code.  No other license or right
363446Smrj  * is granted directly or by implication, estoppel or otherwise;
373446Smrj  *
383446Smrj  * The above copyright and patent license is granted only if the following
393446Smrj  * conditions are met:
403446Smrj  *
413446Smrj  * 3. Conditions
423446Smrj  *
433446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
443446Smrj  * Redistribution of source code of any substantial portion of the Covered
453446Smrj  * Code or modification with rights to further distribute source must include
463446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
473446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
483446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
493446Smrj  * contain a file documenting the changes Licensee made to create that Covered
503446Smrj  * Code and the date of any change.  Licensee must include in that file the
513446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
523446Smrj  * must include a prominent statement that the modification is derived,
533446Smrj  * directly or indirectly, from Original Intel Code.
543446Smrj  *
553446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
563446Smrj  * Redistribution of source code of any substantial portion of the Covered
573446Smrj  * Code or modification without rights to further distribute source must
583446Smrj  * include the following Disclaimer and Export Compliance provision in the
593446Smrj  * documentation and/or other materials provided with distribution.  In
603446Smrj  * addition, Licensee may not authorize further sublicense of source of any
613446Smrj  * portion of the Covered Code, and must include terms to the effect that the
623446Smrj  * license from Licensee to its licensee is limited to the intellectual
633446Smrj  * property embodied in the software Licensee provides to its licensee, and
643446Smrj  * not to intellectual property embodied in modifications its licensee may
653446Smrj  * make.
663446Smrj  *
673446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
683446Smrj  * substantial portion of the Covered Code or modification must reproduce the
693446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
703446Smrj  * provision in the documentation and/or other materials provided with the
713446Smrj  * distribution.
723446Smrj  *
733446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
743446Smrj  * Intel Code.
753446Smrj  *
763446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
773446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
783446Smrj  * other dealings in products derived from or relating to the Covered Code
793446Smrj  * without prior written authorization from Intel.
803446Smrj  *
813446Smrj  * 4. Disclaimer and Export Compliance
823446Smrj  *
833446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
843446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
853446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
863446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
873446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
883446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
893446Smrj  * PARTICULAR PURPOSE.
903446Smrj  *
913446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
923446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
933446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
943446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
953446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
963446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
973446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
983446Smrj  * LIMITED REMEDY.
993446Smrj  *
1003446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1013446Smrj  * software or system incorporating such software without first obtaining any
1023446Smrj  * required license or other approval from the U. S. Department of Commerce or
1033446Smrj  * any other agency or department of the United States Government.  In the
1043446Smrj  * event Licensee exports any such software from the United States or
1053446Smrj  * re-exports any such software from a foreign destination, Licensee shall
1063446Smrj  * ensure that the distribution and export/re-export of the software is in
1073446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
1083446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1093446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
1103446Smrj  * software, or service, directly or indirectly, to any country for which the
1113446Smrj  * United States government or any agency thereof requires an export license,
1123446Smrj  * other governmental approval, or letter of assurance, without first obtaining
1133446Smrj  * such license, approval or letter.
1143446Smrj  *
1153446Smrj  *****************************************************************************/
1163446Smrj 
1173446Smrj 
1183446Smrj #include "acpi.h"
1193446Smrj #include "acdisasm.h"
1203446Smrj #include "acparser.h"
1213446Smrj #include "amlcode.h"
1223446Smrj 
1233446Smrj 
1243446Smrj #ifdef ACPI_DISASSEMBLER
1253446Smrj 
1263446Smrj #define _COMPONENT          ACPI_CA_DEBUGGER
1273446Smrj         ACPI_MODULE_NAME    ("dmbuffer")
1283446Smrj 
1293446Smrj /* Local prototypes */
1303446Smrj 
1313446Smrj static void
1323446Smrj AcpiDmUnicode (
1333446Smrj     ACPI_PARSE_OBJECT       *Op);
1343446Smrj 
1353446Smrj 
1363446Smrj /*******************************************************************************
1373446Smrj  *
1383446Smrj  * FUNCTION:    AcpiDmDisasmByteList
1393446Smrj  *
1403446Smrj  * PARAMETERS:  Level               - Current source code indentation level
1413446Smrj  *              ByteData            - Pointer to the byte list
1423446Smrj  *              ByteCount           - Length of the byte list
1433446Smrj  *
1443446Smrj  * RETURN:      None
1453446Smrj  *
146*7851SDana.Myers@Sun.COM  * DESCRIPTION: Dump an AML "ByteList" in Hex format. 8 bytes per line, prefixed
147*7851SDana.Myers@Sun.COM  *              with the hex buffer offset.
1483446Smrj  *
1493446Smrj  ******************************************************************************/
1503446Smrj 
1513446Smrj void
1523446Smrj AcpiDmDisasmByteList (
1533446Smrj     UINT32                  Level,
1543446Smrj     UINT8                   *ByteData,
1553446Smrj     UINT32                  ByteCount)
1563446Smrj {
1573446Smrj     UINT32                  i;
1583446Smrj 
1593446Smrj 
1603446Smrj     if (!ByteCount)
1613446Smrj     {
1623446Smrj         return;
1633446Smrj     }
1643446Smrj 
1653446Smrj     /* Dump the byte list */
1663446Smrj 
1673446Smrj     for (i = 0; i < ByteCount; i++)
1683446Smrj     {
169*7851SDana.Myers@Sun.COM         /* New line every 8 bytes */
170*7851SDana.Myers@Sun.COM 
171*7851SDana.Myers@Sun.COM         if (((i % 8) == 0) && (i < ByteCount))
172*7851SDana.Myers@Sun.COM         {
173*7851SDana.Myers@Sun.COM             if (i > 0)
174*7851SDana.Myers@Sun.COM             {
175*7851SDana.Myers@Sun.COM                 AcpiOsPrintf ("\n");
176*7851SDana.Myers@Sun.COM             }
177*7851SDana.Myers@Sun.COM 
178*7851SDana.Myers@Sun.COM             AcpiDmIndent (Level);
179*7851SDana.Myers@Sun.COM             if (ByteCount > 7)
180*7851SDana.Myers@Sun.COM             {
181*7851SDana.Myers@Sun.COM                 AcpiOsPrintf ("/* %04X */    ", i);
182*7851SDana.Myers@Sun.COM             }
183*7851SDana.Myers@Sun.COM         }
184*7851SDana.Myers@Sun.COM 
1853446Smrj         AcpiOsPrintf ("0x%2.2X", (UINT32) ByteData[i]);
1863446Smrj 
1873446Smrj         /* Add comma if there are more bytes to display */
1883446Smrj 
1893446Smrj         if (i < (ByteCount -1))
1903446Smrj         {
1913446Smrj             AcpiOsPrintf (", ");
1923446Smrj         }
1933446Smrj     }
1943446Smrj 
1953446Smrj     if (Level)
1963446Smrj     {
1973446Smrj         AcpiOsPrintf ("\n");
1983446Smrj     }
1993446Smrj }
2003446Smrj 
2013446Smrj 
2023446Smrj /*******************************************************************************
2033446Smrj  *
2043446Smrj  * FUNCTION:    AcpiDmByteList
2053446Smrj  *
2063446Smrj  * PARAMETERS:  Info            - Parse tree walk info
2073446Smrj  *              Op              - Byte list op
2083446Smrj  *
2093446Smrj  * RETURN:      None
2103446Smrj  *
2113446Smrj  * DESCRIPTION: Dump a buffer byte list, handling the various types of buffers.
2123446Smrj  *              Buffer type must be already set in the Op DisasmOpcode.
2133446Smrj  *
2143446Smrj  ******************************************************************************/
2153446Smrj 
2163446Smrj void
2173446Smrj AcpiDmByteList (
2183446Smrj     ACPI_OP_WALK_INFO       *Info,
2193446Smrj     ACPI_PARSE_OBJECT       *Op)
2203446Smrj {
2213446Smrj     UINT8                   *ByteData;
2223446Smrj     UINT32                  ByteCount;
2233446Smrj 
2243446Smrj 
2253446Smrj     ByteData = Op->Named.Data;
2263446Smrj     ByteCount = (UINT32) Op->Common.Value.Integer;
2273446Smrj 
2283446Smrj     /*
2293446Smrj      * The byte list belongs to a buffer, and can be produced by either
2303446Smrj      * a ResourceTemplate, Unicode, quoted string, or a plain byte list.
2313446Smrj      */
2323446Smrj     switch (Op->Common.Parent->Common.DisasmOpcode)
2333446Smrj     {
2343446Smrj     case ACPI_DASM_RESOURCE:
2353446Smrj 
2363446Smrj         AcpiDmResourceTemplate (Info, Op->Common.Parent, ByteData, ByteCount);
2373446Smrj         break;
2383446Smrj 
2393446Smrj     case ACPI_DASM_STRING:
2403446Smrj 
2413446Smrj         AcpiDmIndent (Info->Level);
2423446Smrj         AcpiUtPrintString ((char *) ByteData, ACPI_UINT8_MAX);
2433446Smrj         AcpiOsPrintf ("\n");
2443446Smrj         break;
2453446Smrj 
2463446Smrj     case ACPI_DASM_UNICODE:
2473446Smrj 
2483446Smrj         AcpiDmUnicode (Op);
2493446Smrj         break;
2503446Smrj 
2513446Smrj     case ACPI_DASM_BUFFER:
2523446Smrj     default:
2533446Smrj 
2543446Smrj         /*
2553446Smrj          * Not a resource, string, or unicode string.
2563446Smrj          * Just dump the buffer
2573446Smrj          */
2583446Smrj         AcpiDmDisasmByteList (Info->Level, ByteData, ByteCount);
2593446Smrj         break;
2603446Smrj     }
2613446Smrj }
2623446Smrj 
2633446Smrj 
2643446Smrj /*******************************************************************************
2653446Smrj  *
2663446Smrj  * FUNCTION:    AcpiDmIsUnicodeBuffer
2673446Smrj  *
2683446Smrj  * PARAMETERS:  Op              - Buffer Object to be examined
2693446Smrj  *
2703446Smrj  * RETURN:      TRUE if buffer contains a UNICODE string
2713446Smrj  *
2723446Smrj  * DESCRIPTION: Determine if a buffer Op contains a Unicode string
2733446Smrj  *
2743446Smrj  ******************************************************************************/
2753446Smrj 
2763446Smrj BOOLEAN
2773446Smrj AcpiDmIsUnicodeBuffer (
2783446Smrj     ACPI_PARSE_OBJECT       *Op)
2793446Smrj {
2803446Smrj     UINT8                   *ByteData;
2813446Smrj     UINT32                  ByteCount;
2823446Smrj     UINT32                  WordCount;
2833446Smrj     ACPI_PARSE_OBJECT       *SizeOp;
2843446Smrj     ACPI_PARSE_OBJECT       *NextOp;
285*7851SDana.Myers@Sun.COM     UINT32                  i;
2863446Smrj 
2873446Smrj 
2883446Smrj     /* Buffer size is the buffer argument */
2893446Smrj 
2903446Smrj     SizeOp = Op->Common.Value.Arg;
2913446Smrj 
2923446Smrj     /* Next, the initializer byte list to examine */
2933446Smrj 
2943446Smrj     NextOp = SizeOp->Common.Next;
2953446Smrj     if (!NextOp)
2963446Smrj     {
2973446Smrj         return (FALSE);
2983446Smrj     }
2993446Smrj 
3003446Smrj     /* Extract the byte list info */
3013446Smrj 
3023446Smrj     ByteData = NextOp->Named.Data;
3033446Smrj     ByteCount = (UINT32) NextOp->Common.Value.Integer;
3043446Smrj     WordCount = ACPI_DIV_2 (ByteCount);
3053446Smrj 
3063446Smrj     /*
3073446Smrj      * Unicode string must have an even number of bytes and last
3083446Smrj      * word must be zero
3093446Smrj      */
3103446Smrj     if ((!ByteCount)     ||
3113446Smrj          (ByteCount < 4) ||
3123446Smrj          (ByteCount & 1) ||
3133446Smrj         ((UINT16 *) (void *) ByteData)[WordCount - 1] != 0)
3143446Smrj     {
3153446Smrj         return (FALSE);
3163446Smrj     }
3173446Smrj 
3183446Smrj     /* For each word, 1st byte must be ascii, 2nd byte must be zero */
3193446Smrj 
3203446Smrj     for (i = 0; i < (ByteCount - 2); i += 2)
3213446Smrj     {
3223446Smrj         if ((!ACPI_IS_PRINT (ByteData[i])) ||
323*7851SDana.Myers@Sun.COM             (ByteData[(ACPI_SIZE) i + 1] != 0))
3243446Smrj         {
3253446Smrj             return (FALSE);
3263446Smrj         }
3273446Smrj     }
3283446Smrj 
3293446Smrj     /* Ignore the Size argument in the disassembly of this buffer op */
3303446Smrj 
3313446Smrj     SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
3323446Smrj     return (TRUE);
3333446Smrj }
3343446Smrj 
3353446Smrj 
3363446Smrj /*******************************************************************************
3373446Smrj  *
3383446Smrj  * FUNCTION:    AcpiDmIsStringBuffer
3393446Smrj  *
3403446Smrj  * PARAMETERS:  Op              - Buffer Object to be examined
3413446Smrj  *
3423446Smrj  * RETURN:      TRUE if buffer contains a ASCII string, FALSE otherwise
3433446Smrj  *
3443446Smrj  * DESCRIPTION: Determine if a buffer Op contains a ASCII string
3453446Smrj  *
3463446Smrj  ******************************************************************************/
3473446Smrj 
3483446Smrj BOOLEAN
3493446Smrj AcpiDmIsStringBuffer (
3503446Smrj     ACPI_PARSE_OBJECT       *Op)
3513446Smrj {
3523446Smrj     UINT8                   *ByteData;
3533446Smrj     UINT32                  ByteCount;
3543446Smrj     ACPI_PARSE_OBJECT       *SizeOp;
3553446Smrj     ACPI_PARSE_OBJECT       *NextOp;
3563446Smrj     UINT32                  i;
3573446Smrj 
3583446Smrj 
3593446Smrj     /* Buffer size is the buffer argument */
3603446Smrj 
3613446Smrj     SizeOp = Op->Common.Value.Arg;
3623446Smrj 
3633446Smrj     /* Next, the initializer byte list to examine */
3643446Smrj 
3653446Smrj     NextOp = SizeOp->Common.Next;
3663446Smrj     if (!NextOp)
3673446Smrj     {
3683446Smrj         return (FALSE);
3693446Smrj     }
3703446Smrj 
3713446Smrj     /* Extract the byte list info */
3723446Smrj 
3733446Smrj     ByteData = NextOp->Named.Data;
3743446Smrj     ByteCount = (UINT32) NextOp->Common.Value.Integer;
3753446Smrj 
3763446Smrj     /* Last byte must be the null terminator */
3773446Smrj 
3783446Smrj     if ((!ByteCount)     ||
3793446Smrj          (ByteCount < 2) ||
3803446Smrj          (ByteData[ByteCount-1] != 0))
3813446Smrj     {
3823446Smrj         return (FALSE);
3833446Smrj     }
3843446Smrj 
3853446Smrj     for (i = 0; i < (ByteCount - 1); i++)
3863446Smrj     {
3873446Smrj         /* TBD: allow some escapes (non-ascii chars).
3883446Smrj          * they will be handled in the string output routine
3893446Smrj          */
3903446Smrj 
3913446Smrj         if (!ACPI_IS_PRINT (ByteData[i]))
3923446Smrj         {
3933446Smrj             return (FALSE);
3943446Smrj         }
3953446Smrj     }
3963446Smrj 
3973446Smrj     return (TRUE);
3983446Smrj }
3993446Smrj 
4003446Smrj 
4013446Smrj /*******************************************************************************
4023446Smrj  *
4033446Smrj  * FUNCTION:    AcpiDmUnicode
4043446Smrj  *
4053446Smrj  * PARAMETERS:  Op              - Byte List op containing Unicode string
4063446Smrj  *
4073446Smrj  * RETURN:      None
4083446Smrj  *
4093446Smrj  * DESCRIPTION: Dump Unicode string as a standard ASCII string.  (Remove
4103446Smrj  *              the extra zero bytes).
4113446Smrj  *
4123446Smrj  ******************************************************************************/
4133446Smrj 
4143446Smrj static void
4153446Smrj AcpiDmUnicode (
4163446Smrj     ACPI_PARSE_OBJECT       *Op)
4173446Smrj {
4183446Smrj     UINT16                  *WordData;
4193446Smrj     UINT32                  WordCount;
4203446Smrj     UINT32                  i;
4213446Smrj 
4223446Smrj 
4233446Smrj     /* Extract the buffer info as a WORD buffer */
4243446Smrj 
4253446Smrj     WordData = ACPI_CAST_PTR (UINT16, Op->Named.Data);
4263446Smrj     WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Integer));
4273446Smrj 
4283446Smrj 
4293446Smrj     AcpiOsPrintf ("\"");
4303446Smrj 
4313446Smrj     /* Write every other byte as an ASCII character */
4323446Smrj 
4333446Smrj     for (i = 0; i < (WordCount - 1); i++)
4343446Smrj     {
4353446Smrj         AcpiOsPrintf ("%c", (int) WordData[i]);
4363446Smrj     }
4373446Smrj 
4383446Smrj     AcpiOsPrintf ("\")");
4393446Smrj }
4403446Smrj 
4413446Smrj 
4423446Smrj /*******************************************************************************
4433446Smrj  *
444*7851SDana.Myers@Sun.COM  * FUNCTION:    AcpiDmIsEisaIdElement
4453446Smrj  *
4463446Smrj  * PARAMETERS:  Op              - Op to be examined
4473446Smrj  *
4483446Smrj  * RETURN:      None
4493446Smrj  *
450*7851SDana.Myers@Sun.COM  * DESCRIPTION: Determine if an Op (argument to _HID or _CID) can be converted
451*7851SDana.Myers@Sun.COM  *              to an EISA ID.
4523446Smrj  *
4533446Smrj  ******************************************************************************/
4543446Smrj 
4553446Smrj void
456*7851SDana.Myers@Sun.COM AcpiDmIsEisaIdElement (
4573446Smrj     ACPI_PARSE_OBJECT       *Op)
4583446Smrj {
4593446Smrj     UINT32                  BigEndianId;
4603446Smrj     UINT32                  Prefix[3];
461*7851SDana.Myers@Sun.COM     UINT32                  i;
4623446Smrj 
4633446Smrj 
4643446Smrj     /* The parameter must be either a word or a dword */
4653446Smrj 
466*7851SDana.Myers@Sun.COM     if ((Op->Common.AmlOpcode != AML_DWORD_OP) &&
467*7851SDana.Myers@Sun.COM         (Op->Common.AmlOpcode != AML_WORD_OP))
4683446Smrj     {
4693446Smrj         return;
4703446Smrj     }
4713446Smrj 
4723446Smrj     /* Swap from little-endian to big-endian to simplify conversion */
4733446Smrj 
474*7851SDana.Myers@Sun.COM     BigEndianId = AcpiUtDwordByteSwap ((UINT32) Op->Common.Value.Integer);
4753446Smrj 
4763446Smrj     /* Create the 3 leading ASCII letters */
4773446Smrj 
4783446Smrj     Prefix[0] = ((BigEndianId >> 26) & 0x1F) + 0x40;
4793446Smrj     Prefix[1] = ((BigEndianId >> 21) & 0x1F) + 0x40;
4803446Smrj     Prefix[2] = ((BigEndianId >> 16) & 0x1F) + 0x40;
4813446Smrj 
4823446Smrj     /* Verify that all 3 are ascii and alpha */
4833446Smrj 
4843446Smrj     for (i = 0; i < 3; i++)
4853446Smrj     {
4863446Smrj         if (!ACPI_IS_ASCII (Prefix[i]) ||
4873446Smrj             !ACPI_IS_ALPHA (Prefix[i]))
4883446Smrj         {
4893446Smrj             return;
4903446Smrj         }
4913446Smrj     }
4923446Smrj 
4933446Smrj     /* OK - mark this node as convertable to an EISA ID */
4943446Smrj 
495*7851SDana.Myers@Sun.COM     Op->Common.DisasmOpcode = ACPI_DASM_EISAID;
496*7851SDana.Myers@Sun.COM }
497*7851SDana.Myers@Sun.COM 
498*7851SDana.Myers@Sun.COM 
499*7851SDana.Myers@Sun.COM /*******************************************************************************
500*7851SDana.Myers@Sun.COM  *
501*7851SDana.Myers@Sun.COM  * FUNCTION:    AcpiDmIsEisaId
502*7851SDana.Myers@Sun.COM  *
503*7851SDana.Myers@Sun.COM  * PARAMETERS:  Op              - Op to be examined
504*7851SDana.Myers@Sun.COM  *
505*7851SDana.Myers@Sun.COM  * RETURN:      None
506*7851SDana.Myers@Sun.COM  *
507*7851SDana.Myers@Sun.COM  * DESCRIPTION: Determine if a Name() Op can be converted to an EisaId.
508*7851SDana.Myers@Sun.COM  *
509*7851SDana.Myers@Sun.COM  ******************************************************************************/
510*7851SDana.Myers@Sun.COM 
511*7851SDana.Myers@Sun.COM void
512*7851SDana.Myers@Sun.COM AcpiDmIsEisaId (
513*7851SDana.Myers@Sun.COM     ACPI_PARSE_OBJECT       *Op)
514*7851SDana.Myers@Sun.COM {
515*7851SDana.Myers@Sun.COM     UINT32                  Name;
516*7851SDana.Myers@Sun.COM     ACPI_PARSE_OBJECT       *NextOp;
517*7851SDana.Myers@Sun.COM 
518*7851SDana.Myers@Sun.COM 
519*7851SDana.Myers@Sun.COM     /* Get the NameSegment */
520*7851SDana.Myers@Sun.COM 
521*7851SDana.Myers@Sun.COM     Name = AcpiPsGetName (Op);
522*7851SDana.Myers@Sun.COM     if (!Name)
523*7851SDana.Myers@Sun.COM     {
524*7851SDana.Myers@Sun.COM         return;
525*7851SDana.Myers@Sun.COM     }
526*7851SDana.Myers@Sun.COM 
527*7851SDana.Myers@Sun.COM     NextOp = AcpiPsGetDepthNext (NULL, Op);
528*7851SDana.Myers@Sun.COM     if (!NextOp)
529*7851SDana.Myers@Sun.COM     {
530*7851SDana.Myers@Sun.COM         return;
531*7851SDana.Myers@Sun.COM     }
532*7851SDana.Myers@Sun.COM 
533*7851SDana.Myers@Sun.COM     /* Check for _HID - has one argument */
534*7851SDana.Myers@Sun.COM 
535*7851SDana.Myers@Sun.COM     if (ACPI_COMPARE_NAME (&Name, METHOD_NAME__HID))
536*7851SDana.Myers@Sun.COM     {
537*7851SDana.Myers@Sun.COM         AcpiDmIsEisaIdElement (NextOp);
538*7851SDana.Myers@Sun.COM         return;
539*7851SDana.Myers@Sun.COM     }
540*7851SDana.Myers@Sun.COM 
541*7851SDana.Myers@Sun.COM     /* Exit if not _CID */
542*7851SDana.Myers@Sun.COM 
543*7851SDana.Myers@Sun.COM     if (!ACPI_COMPARE_NAME (&Name, METHOD_NAME__CID))
544*7851SDana.Myers@Sun.COM     {
545*7851SDana.Myers@Sun.COM         return;
546*7851SDana.Myers@Sun.COM     }
547*7851SDana.Myers@Sun.COM 
548*7851SDana.Myers@Sun.COM     /* _CID can contain a single argument or a package */
549*7851SDana.Myers@Sun.COM 
550*7851SDana.Myers@Sun.COM     if (NextOp->Common.AmlOpcode != AML_PACKAGE_OP)
551*7851SDana.Myers@Sun.COM     {
552*7851SDana.Myers@Sun.COM         AcpiDmIsEisaIdElement (NextOp);
553*7851SDana.Myers@Sun.COM         return;
554*7851SDana.Myers@Sun.COM     }
555*7851SDana.Myers@Sun.COM 
556*7851SDana.Myers@Sun.COM     /* _CID with Package: get the package length */
557*7851SDana.Myers@Sun.COM 
558*7851SDana.Myers@Sun.COM     NextOp = AcpiPsGetDepthNext (NULL, NextOp);
559*7851SDana.Myers@Sun.COM 
560*7851SDana.Myers@Sun.COM     /* Don't need to use the length, just walk the peer list */
561*7851SDana.Myers@Sun.COM 
562*7851SDana.Myers@Sun.COM     NextOp = NextOp->Common.Next;
563*7851SDana.Myers@Sun.COM     while (NextOp)
564*7851SDana.Myers@Sun.COM     {
565*7851SDana.Myers@Sun.COM         AcpiDmIsEisaIdElement (NextOp);
566*7851SDana.Myers@Sun.COM         NextOp = NextOp->Common.Next;
567*7851SDana.Myers@Sun.COM     }
5683446Smrj }
5693446Smrj 
5703446Smrj 
5713446Smrj /*******************************************************************************
5723446Smrj  *
5733446Smrj  * FUNCTION:    AcpiDmEisaId
5743446Smrj  *
5753446Smrj  * PARAMETERS:  EncodedId       - Raw encoded EISA ID.
5763446Smrj  *
5773446Smrj  * RETURN:      None
5783446Smrj  *
5793446Smrj  * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String.
5803446Smrj  *
5813446Smrj  ******************************************************************************/
5823446Smrj 
5833446Smrj void
5843446Smrj AcpiDmEisaId (
5853446Smrj     UINT32                  EncodedId)
5863446Smrj {
5873446Smrj     UINT32                  BigEndianId;
5883446Smrj 
5893446Smrj 
5903446Smrj     /* Swap from little-endian to big-endian to simplify conversion */
5913446Smrj 
5923446Smrj     BigEndianId = AcpiUtDwordByteSwap (EncodedId);
5933446Smrj 
5943446Smrj 
5953446Smrj     /* Split to form "AAANNNN" string */
5963446Smrj 
5973446Smrj     AcpiOsPrintf ("EisaId (\"%c%c%c%4.4X\")",
5983446Smrj 
5993446Smrj         /* Three Alpha characters (AAA), 5 bits each */
6003446Smrj 
6013446Smrj         (int) ((BigEndianId >> 26) & 0x1F) + 0x40,
6023446Smrj         (int) ((BigEndianId >> 21) & 0x1F) + 0x40,
6033446Smrj         (int) ((BigEndianId >> 16) & 0x1F) + 0x40,
6043446Smrj 
6053446Smrj         /* Numeric part (NNNN) is simply the lower 16 bits */
6063446Smrj 
6073446Smrj         (UINT32) (BigEndianId & 0xFFFF));
6083446Smrj }
6093446Smrj 
6103446Smrj #endif
611