13446Smrj /*******************************************************************************
23446Smrj *
33446Smrj * Module Name: dmbuffer - AML disassembler, buffer and string support
43446Smrj *
53446Smrj ******************************************************************************/
63446Smrj
73446Smrj /******************************************************************************
83446Smrj *
93446Smrj * 1. Copyright Notice
103446Smrj *
11*9980SDana.Myers@Sun.COM * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
123446Smrj * All rights reserved.
133446Smrj *
143446Smrj * 2. License
153446Smrj *
163446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property
173446Smrj * rights. You may have additional license terms from the party that provided
183446Smrj * you this software, covering your right to use that party's intellectual
193446Smrj * property rights.
203446Smrj *
213446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
223446Smrj * copy of the source code appearing in this file ("Covered Code") an
233446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the
243446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy,
253446Smrj * make derivatives, distribute, use and display any portion of the Covered
263446Smrj * Code in any form, with the right to sublicense such rights; and
273446Smrj *
283446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
293446Smrj * license (with the right to sublicense), under only those claims of Intel
303446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell,
313446Smrj * offer to sell, and import the Covered Code and derivative works thereof
323446Smrj * solely to the minimum extent necessary to exercise the above copyright
333446Smrj * license, and in no event shall the patent license extend to any additions
343446Smrj * to or modifications of the Original Intel Code. No other license or right
353446Smrj * is granted directly or by implication, estoppel or otherwise;
363446Smrj *
373446Smrj * The above copyright and patent license is granted only if the following
383446Smrj * conditions are met:
393446Smrj *
403446Smrj * 3. Conditions
413446Smrj *
423446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source.
433446Smrj * Redistribution of source code of any substantial portion of the Covered
443446Smrj * Code or modification with rights to further distribute source must include
453446Smrj * the above Copyright Notice, the above License, this list of Conditions,
463446Smrj * and the following Disclaimer and Export Compliance provision. In addition,
473446Smrj * Licensee must cause all Covered Code to which Licensee contributes to
483446Smrj * contain a file documenting the changes Licensee made to create that Covered
493446Smrj * Code and the date of any change. Licensee must include in that file the
503446Smrj * documentation of any changes made by any predecessor Licensee. Licensee
513446Smrj * must include a prominent statement that the modification is derived,
523446Smrj * directly or indirectly, from Original Intel Code.
533446Smrj *
543446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
553446Smrj * Redistribution of source code of any substantial portion of the Covered
563446Smrj * Code or modification without rights to further distribute source must
573446Smrj * include the following Disclaimer and Export Compliance provision in the
583446Smrj * documentation and/or other materials provided with distribution. In
593446Smrj * addition, Licensee may not authorize further sublicense of source of any
603446Smrj * portion of the Covered Code, and must include terms to the effect that the
613446Smrj * license from Licensee to its licensee is limited to the intellectual
623446Smrj * property embodied in the software Licensee provides to its licensee, and
633446Smrj * not to intellectual property embodied in modifications its licensee may
643446Smrj * make.
653446Smrj *
663446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any
673446Smrj * substantial portion of the Covered Code or modification must reproduce the
683446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance
693446Smrj * provision in the documentation and/or other materials provided with the
703446Smrj * distribution.
713446Smrj *
723446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original
733446Smrj * Intel Code.
743446Smrj *
753446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by
763446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or
773446Smrj * other dealings in products derived from or relating to the Covered Code
783446Smrj * without prior written authorization from Intel.
793446Smrj *
803446Smrj * 4. Disclaimer and Export Compliance
813446Smrj *
823446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
833446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
843446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
853446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
863446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
873446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
883446Smrj * PARTICULAR PURPOSE.
893446Smrj *
903446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
913446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
923446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
933446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
943446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
953446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
963446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
973446Smrj * LIMITED REMEDY.
983446Smrj *
993446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this
1003446Smrj * software or system incorporating such software without first obtaining any
1013446Smrj * required license or other approval from the U. S. Department of Commerce or
1023446Smrj * any other agency or department of the United States Government. In the
1033446Smrj * event Licensee exports any such software from the United States or
1043446Smrj * re-exports any such software from a foreign destination, Licensee shall
1053446Smrj * ensure that the distribution and export/re-export of the software is in
1063446Smrj * compliance with all laws, regulations, orders, or other restrictions of the
1073446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1083446Smrj * any of its subsidiaries will export/re-export any technical data, process,
1093446Smrj * software, or service, directly or indirectly, to any country for which the
1103446Smrj * United States government or any agency thereof requires an export license,
1113446Smrj * other governmental approval, or letter of assurance, without first obtaining
1123446Smrj * such license, approval or letter.
1133446Smrj *
1143446Smrj *****************************************************************************/
1153446Smrj
1163446Smrj
1173446Smrj #include "acpi.h"
118*9980SDana.Myers@Sun.COM #include "accommon.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
135*9980SDana.Myers@Sun.COM static void
136*9980SDana.Myers@Sun.COM AcpiDmIsEisaIdElement (
137*9980SDana.Myers@Sun.COM ACPI_PARSE_OBJECT *Op);
138*9980SDana.Myers@Sun.COM
1393446Smrj
1403446Smrj /*******************************************************************************
1413446Smrj *
1423446Smrj * FUNCTION: AcpiDmDisasmByteList
1433446Smrj *
1443446Smrj * PARAMETERS: Level - Current source code indentation level
1453446Smrj * ByteData - Pointer to the byte list
1463446Smrj * ByteCount - Length of the byte list
1473446Smrj *
1483446Smrj * RETURN: None
1493446Smrj *
1507851SDana.Myers@Sun.COM * DESCRIPTION: Dump an AML "ByteList" in Hex format. 8 bytes per line, prefixed
1517851SDana.Myers@Sun.COM * with the hex buffer offset.
1523446Smrj *
1533446Smrj ******************************************************************************/
1543446Smrj
1553446Smrj void
AcpiDmDisasmByteList(UINT32 Level,UINT8 * ByteData,UINT32 ByteCount)1563446Smrj AcpiDmDisasmByteList (
1573446Smrj UINT32 Level,
1583446Smrj UINT8 *ByteData,
1593446Smrj UINT32 ByteCount)
1603446Smrj {
1613446Smrj UINT32 i;
1623446Smrj
1633446Smrj
1643446Smrj if (!ByteCount)
1653446Smrj {
1663446Smrj return;
1673446Smrj }
1683446Smrj
1693446Smrj /* Dump the byte list */
1703446Smrj
1713446Smrj for (i = 0; i < ByteCount; i++)
1723446Smrj {
1737851SDana.Myers@Sun.COM /* New line every 8 bytes */
1747851SDana.Myers@Sun.COM
1757851SDana.Myers@Sun.COM if (((i % 8) == 0) && (i < ByteCount))
1767851SDana.Myers@Sun.COM {
1777851SDana.Myers@Sun.COM if (i > 0)
1787851SDana.Myers@Sun.COM {
1797851SDana.Myers@Sun.COM AcpiOsPrintf ("\n");
1807851SDana.Myers@Sun.COM }
1817851SDana.Myers@Sun.COM
1827851SDana.Myers@Sun.COM AcpiDmIndent (Level);
1837851SDana.Myers@Sun.COM if (ByteCount > 7)
1847851SDana.Myers@Sun.COM {
1857851SDana.Myers@Sun.COM AcpiOsPrintf ("/* %04X */ ", i);
1867851SDana.Myers@Sun.COM }
1877851SDana.Myers@Sun.COM }
1887851SDana.Myers@Sun.COM
1893446Smrj AcpiOsPrintf ("0x%2.2X", (UINT32) ByteData[i]);
1903446Smrj
1913446Smrj /* Add comma if there are more bytes to display */
1923446Smrj
1933446Smrj if (i < (ByteCount -1))
1943446Smrj {
1953446Smrj AcpiOsPrintf (", ");
1963446Smrj }
1973446Smrj }
1983446Smrj
1993446Smrj if (Level)
2003446Smrj {
2013446Smrj AcpiOsPrintf ("\n");
2023446Smrj }
2033446Smrj }
2043446Smrj
2053446Smrj
2063446Smrj /*******************************************************************************
2073446Smrj *
2083446Smrj * FUNCTION: AcpiDmByteList
2093446Smrj *
2103446Smrj * PARAMETERS: Info - Parse tree walk info
2113446Smrj * Op - Byte list op
2123446Smrj *
2133446Smrj * RETURN: None
2143446Smrj *
2153446Smrj * DESCRIPTION: Dump a buffer byte list, handling the various types of buffers.
2163446Smrj * Buffer type must be already set in the Op DisasmOpcode.
2173446Smrj *
2183446Smrj ******************************************************************************/
2193446Smrj
2203446Smrj void
AcpiDmByteList(ACPI_OP_WALK_INFO * Info,ACPI_PARSE_OBJECT * Op)2213446Smrj AcpiDmByteList (
2223446Smrj ACPI_OP_WALK_INFO *Info,
2233446Smrj ACPI_PARSE_OBJECT *Op)
2243446Smrj {
2253446Smrj UINT8 *ByteData;
2263446Smrj UINT32 ByteCount;
2273446Smrj
2283446Smrj
2293446Smrj ByteData = Op->Named.Data;
2303446Smrj ByteCount = (UINT32) Op->Common.Value.Integer;
2313446Smrj
2323446Smrj /*
2333446Smrj * The byte list belongs to a buffer, and can be produced by either
2343446Smrj * a ResourceTemplate, Unicode, quoted string, or a plain byte list.
2353446Smrj */
2363446Smrj switch (Op->Common.Parent->Common.DisasmOpcode)
2373446Smrj {
2383446Smrj case ACPI_DASM_RESOURCE:
2393446Smrj
2403446Smrj AcpiDmResourceTemplate (Info, Op->Common.Parent, ByteData, ByteCount);
2413446Smrj break;
2423446Smrj
2433446Smrj case ACPI_DASM_STRING:
2443446Smrj
2453446Smrj AcpiDmIndent (Info->Level);
2463446Smrj AcpiUtPrintString ((char *) ByteData, ACPI_UINT8_MAX);
2473446Smrj AcpiOsPrintf ("\n");
2483446Smrj break;
2493446Smrj
2503446Smrj case ACPI_DASM_UNICODE:
2513446Smrj
2523446Smrj AcpiDmUnicode (Op);
2533446Smrj break;
2543446Smrj
2553446Smrj case ACPI_DASM_BUFFER:
2563446Smrj default:
2573446Smrj
2583446Smrj /*
2593446Smrj * Not a resource, string, or unicode string.
2603446Smrj * Just dump the buffer
2613446Smrj */
2623446Smrj AcpiDmDisasmByteList (Info->Level, ByteData, ByteCount);
2633446Smrj break;
2643446Smrj }
2653446Smrj }
2663446Smrj
2673446Smrj
2683446Smrj /*******************************************************************************
2693446Smrj *
2703446Smrj * FUNCTION: AcpiDmIsUnicodeBuffer
2713446Smrj *
2723446Smrj * PARAMETERS: Op - Buffer Object to be examined
2733446Smrj *
2743446Smrj * RETURN: TRUE if buffer contains a UNICODE string
2753446Smrj *
2763446Smrj * DESCRIPTION: Determine if a buffer Op contains a Unicode string
2773446Smrj *
2783446Smrj ******************************************************************************/
2793446Smrj
2803446Smrj BOOLEAN
AcpiDmIsUnicodeBuffer(ACPI_PARSE_OBJECT * Op)2813446Smrj AcpiDmIsUnicodeBuffer (
2823446Smrj ACPI_PARSE_OBJECT *Op)
2833446Smrj {
2843446Smrj UINT8 *ByteData;
2853446Smrj UINT32 ByteCount;
2863446Smrj UINT32 WordCount;
2873446Smrj ACPI_PARSE_OBJECT *SizeOp;
2883446Smrj ACPI_PARSE_OBJECT *NextOp;
2897851SDana.Myers@Sun.COM UINT32 i;
2903446Smrj
2913446Smrj
2923446Smrj /* Buffer size is the buffer argument */
2933446Smrj
2943446Smrj SizeOp = Op->Common.Value.Arg;
2953446Smrj
2963446Smrj /* Next, the initializer byte list to examine */
2973446Smrj
2983446Smrj NextOp = SizeOp->Common.Next;
2993446Smrj if (!NextOp)
3003446Smrj {
3013446Smrj return (FALSE);
3023446Smrj }
3033446Smrj
3043446Smrj /* Extract the byte list info */
3053446Smrj
3063446Smrj ByteData = NextOp->Named.Data;
3073446Smrj ByteCount = (UINT32) NextOp->Common.Value.Integer;
3083446Smrj WordCount = ACPI_DIV_2 (ByteCount);
3093446Smrj
3103446Smrj /*
3113446Smrj * Unicode string must have an even number of bytes and last
3123446Smrj * word must be zero
3133446Smrj */
3143446Smrj if ((!ByteCount) ||
3153446Smrj (ByteCount < 4) ||
3163446Smrj (ByteCount & 1) ||
3173446Smrj ((UINT16 *) (void *) ByteData)[WordCount - 1] != 0)
3183446Smrj {
3193446Smrj return (FALSE);
3203446Smrj }
3213446Smrj
3223446Smrj /* For each word, 1st byte must be ascii, 2nd byte must be zero */
3233446Smrj
3243446Smrj for (i = 0; i < (ByteCount - 2); i += 2)
3253446Smrj {
3263446Smrj if ((!ACPI_IS_PRINT (ByteData[i])) ||
3277851SDana.Myers@Sun.COM (ByteData[(ACPI_SIZE) i + 1] != 0))
3283446Smrj {
3293446Smrj return (FALSE);
3303446Smrj }
3313446Smrj }
3323446Smrj
3333446Smrj /* Ignore the Size argument in the disassembly of this buffer op */
3343446Smrj
3353446Smrj SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
3363446Smrj return (TRUE);
3373446Smrj }
3383446Smrj
3393446Smrj
3403446Smrj /*******************************************************************************
3413446Smrj *
3423446Smrj * FUNCTION: AcpiDmIsStringBuffer
3433446Smrj *
3443446Smrj * PARAMETERS: Op - Buffer Object to be examined
3453446Smrj *
3463446Smrj * RETURN: TRUE if buffer contains a ASCII string, FALSE otherwise
3473446Smrj *
3483446Smrj * DESCRIPTION: Determine if a buffer Op contains a ASCII string
3493446Smrj *
3503446Smrj ******************************************************************************/
3513446Smrj
3523446Smrj BOOLEAN
AcpiDmIsStringBuffer(ACPI_PARSE_OBJECT * Op)3533446Smrj AcpiDmIsStringBuffer (
3543446Smrj ACPI_PARSE_OBJECT *Op)
3553446Smrj {
3563446Smrj UINT8 *ByteData;
3573446Smrj UINT32 ByteCount;
3583446Smrj ACPI_PARSE_OBJECT *SizeOp;
3593446Smrj ACPI_PARSE_OBJECT *NextOp;
3603446Smrj UINT32 i;
3613446Smrj
3623446Smrj
3633446Smrj /* Buffer size is the buffer argument */
3643446Smrj
3653446Smrj SizeOp = Op->Common.Value.Arg;
3663446Smrj
3673446Smrj /* Next, the initializer byte list to examine */
3683446Smrj
3693446Smrj NextOp = SizeOp->Common.Next;
3703446Smrj if (!NextOp)
3713446Smrj {
3723446Smrj return (FALSE);
3733446Smrj }
3743446Smrj
3753446Smrj /* Extract the byte list info */
3763446Smrj
3773446Smrj ByteData = NextOp->Named.Data;
3783446Smrj ByteCount = (UINT32) NextOp->Common.Value.Integer;
3793446Smrj
3803446Smrj /* Last byte must be the null terminator */
3813446Smrj
3823446Smrj if ((!ByteCount) ||
3833446Smrj (ByteCount < 2) ||
3843446Smrj (ByteData[ByteCount-1] != 0))
3853446Smrj {
3863446Smrj return (FALSE);
3873446Smrj }
3883446Smrj
3893446Smrj for (i = 0; i < (ByteCount - 1); i++)
3903446Smrj {
3913446Smrj /* TBD: allow some escapes (non-ascii chars).
3923446Smrj * they will be handled in the string output routine
3933446Smrj */
3943446Smrj
3953446Smrj if (!ACPI_IS_PRINT (ByteData[i]))
3963446Smrj {
3973446Smrj return (FALSE);
3983446Smrj }
3993446Smrj }
4003446Smrj
4013446Smrj return (TRUE);
4023446Smrj }
4033446Smrj
4043446Smrj
4053446Smrj /*******************************************************************************
4063446Smrj *
4073446Smrj * FUNCTION: AcpiDmUnicode
4083446Smrj *
4093446Smrj * PARAMETERS: Op - Byte List op containing Unicode string
4103446Smrj *
4113446Smrj * RETURN: None
4123446Smrj *
4133446Smrj * DESCRIPTION: Dump Unicode string as a standard ASCII string. (Remove
4143446Smrj * the extra zero bytes).
4153446Smrj *
4163446Smrj ******************************************************************************/
4173446Smrj
4183446Smrj static void
AcpiDmUnicode(ACPI_PARSE_OBJECT * Op)4193446Smrj AcpiDmUnicode (
4203446Smrj ACPI_PARSE_OBJECT *Op)
4213446Smrj {
4223446Smrj UINT16 *WordData;
4233446Smrj UINT32 WordCount;
4243446Smrj UINT32 i;
4253446Smrj
4263446Smrj
4273446Smrj /* Extract the buffer info as a WORD buffer */
4283446Smrj
4293446Smrj WordData = ACPI_CAST_PTR (UINT16, Op->Named.Data);
4303446Smrj WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Integer));
4313446Smrj
4323446Smrj
4333446Smrj AcpiOsPrintf ("\"");
4343446Smrj
4353446Smrj /* Write every other byte as an ASCII character */
4363446Smrj
4373446Smrj for (i = 0; i < (WordCount - 1); i++)
4383446Smrj {
4393446Smrj AcpiOsPrintf ("%c", (int) WordData[i]);
4403446Smrj }
4413446Smrj
4423446Smrj AcpiOsPrintf ("\")");
4433446Smrj }
4443446Smrj
4453446Smrj
4463446Smrj /*******************************************************************************
4473446Smrj *
4487851SDana.Myers@Sun.COM * FUNCTION: AcpiDmIsEisaIdElement
4493446Smrj *
4503446Smrj * PARAMETERS: Op - Op to be examined
4513446Smrj *
4523446Smrj * RETURN: None
4533446Smrj *
4547851SDana.Myers@Sun.COM * DESCRIPTION: Determine if an Op (argument to _HID or _CID) can be converted
4557851SDana.Myers@Sun.COM * to an EISA ID.
4563446Smrj *
4573446Smrj ******************************************************************************/
4583446Smrj
459*9980SDana.Myers@Sun.COM static void
AcpiDmIsEisaIdElement(ACPI_PARSE_OBJECT * Op)4607851SDana.Myers@Sun.COM AcpiDmIsEisaIdElement (
4613446Smrj ACPI_PARSE_OBJECT *Op)
4623446Smrj {
4633446Smrj UINT32 BigEndianId;
4643446Smrj UINT32 Prefix[3];
4657851SDana.Myers@Sun.COM UINT32 i;
4663446Smrj
4673446Smrj
4683446Smrj /* The parameter must be either a word or a dword */
4693446Smrj
4707851SDana.Myers@Sun.COM if ((Op->Common.AmlOpcode != AML_DWORD_OP) &&
4717851SDana.Myers@Sun.COM (Op->Common.AmlOpcode != AML_WORD_OP))
4723446Smrj {
4733446Smrj return;
4743446Smrj }
4753446Smrj
4763446Smrj /* Swap from little-endian to big-endian to simplify conversion */
4773446Smrj
4787851SDana.Myers@Sun.COM BigEndianId = AcpiUtDwordByteSwap ((UINT32) Op->Common.Value.Integer);
4793446Smrj
4803446Smrj /* Create the 3 leading ASCII letters */
4813446Smrj
4823446Smrj Prefix[0] = ((BigEndianId >> 26) & 0x1F) + 0x40;
4833446Smrj Prefix[1] = ((BigEndianId >> 21) & 0x1F) + 0x40;
4843446Smrj Prefix[2] = ((BigEndianId >> 16) & 0x1F) + 0x40;
4853446Smrj
4863446Smrj /* Verify that all 3 are ascii and alpha */
4873446Smrj
4883446Smrj for (i = 0; i < 3; i++)
4893446Smrj {
4903446Smrj if (!ACPI_IS_ASCII (Prefix[i]) ||
4913446Smrj !ACPI_IS_ALPHA (Prefix[i]))
4923446Smrj {
4933446Smrj return;
4943446Smrj }
4953446Smrj }
4963446Smrj
4973446Smrj /* OK - mark this node as convertable to an EISA ID */
4983446Smrj
4997851SDana.Myers@Sun.COM Op->Common.DisasmOpcode = ACPI_DASM_EISAID;
5007851SDana.Myers@Sun.COM }
5017851SDana.Myers@Sun.COM
5027851SDana.Myers@Sun.COM
5037851SDana.Myers@Sun.COM /*******************************************************************************
5047851SDana.Myers@Sun.COM *
5057851SDana.Myers@Sun.COM * FUNCTION: AcpiDmIsEisaId
5067851SDana.Myers@Sun.COM *
5077851SDana.Myers@Sun.COM * PARAMETERS: Op - Op to be examined
5087851SDana.Myers@Sun.COM *
5097851SDana.Myers@Sun.COM * RETURN: None
5107851SDana.Myers@Sun.COM *
5117851SDana.Myers@Sun.COM * DESCRIPTION: Determine if a Name() Op can be converted to an EisaId.
5127851SDana.Myers@Sun.COM *
5137851SDana.Myers@Sun.COM ******************************************************************************/
5147851SDana.Myers@Sun.COM
5157851SDana.Myers@Sun.COM void
AcpiDmIsEisaId(ACPI_PARSE_OBJECT * Op)5167851SDana.Myers@Sun.COM AcpiDmIsEisaId (
5177851SDana.Myers@Sun.COM ACPI_PARSE_OBJECT *Op)
5187851SDana.Myers@Sun.COM {
5197851SDana.Myers@Sun.COM UINT32 Name;
5207851SDana.Myers@Sun.COM ACPI_PARSE_OBJECT *NextOp;
5217851SDana.Myers@Sun.COM
5227851SDana.Myers@Sun.COM
5237851SDana.Myers@Sun.COM /* Get the NameSegment */
5247851SDana.Myers@Sun.COM
5257851SDana.Myers@Sun.COM Name = AcpiPsGetName (Op);
5267851SDana.Myers@Sun.COM if (!Name)
5277851SDana.Myers@Sun.COM {
5287851SDana.Myers@Sun.COM return;
5297851SDana.Myers@Sun.COM }
5307851SDana.Myers@Sun.COM
5317851SDana.Myers@Sun.COM NextOp = AcpiPsGetDepthNext (NULL, Op);
5327851SDana.Myers@Sun.COM if (!NextOp)
5337851SDana.Myers@Sun.COM {
5347851SDana.Myers@Sun.COM return;
5357851SDana.Myers@Sun.COM }
5367851SDana.Myers@Sun.COM
5377851SDana.Myers@Sun.COM /* Check for _HID - has one argument */
5387851SDana.Myers@Sun.COM
5397851SDana.Myers@Sun.COM if (ACPI_COMPARE_NAME (&Name, METHOD_NAME__HID))
5407851SDana.Myers@Sun.COM {
5417851SDana.Myers@Sun.COM AcpiDmIsEisaIdElement (NextOp);
5427851SDana.Myers@Sun.COM return;
5437851SDana.Myers@Sun.COM }
5447851SDana.Myers@Sun.COM
5457851SDana.Myers@Sun.COM /* Exit if not _CID */
5467851SDana.Myers@Sun.COM
5477851SDana.Myers@Sun.COM if (!ACPI_COMPARE_NAME (&Name, METHOD_NAME__CID))
5487851SDana.Myers@Sun.COM {
5497851SDana.Myers@Sun.COM return;
5507851SDana.Myers@Sun.COM }
5517851SDana.Myers@Sun.COM
5527851SDana.Myers@Sun.COM /* _CID can contain a single argument or a package */
5537851SDana.Myers@Sun.COM
5547851SDana.Myers@Sun.COM if (NextOp->Common.AmlOpcode != AML_PACKAGE_OP)
5557851SDana.Myers@Sun.COM {
5567851SDana.Myers@Sun.COM AcpiDmIsEisaIdElement (NextOp);
5577851SDana.Myers@Sun.COM return;
5587851SDana.Myers@Sun.COM }
5597851SDana.Myers@Sun.COM
5607851SDana.Myers@Sun.COM /* _CID with Package: get the package length */
5617851SDana.Myers@Sun.COM
5627851SDana.Myers@Sun.COM NextOp = AcpiPsGetDepthNext (NULL, NextOp);
5637851SDana.Myers@Sun.COM
5647851SDana.Myers@Sun.COM /* Don't need to use the length, just walk the peer list */
5657851SDana.Myers@Sun.COM
5667851SDana.Myers@Sun.COM NextOp = NextOp->Common.Next;
5677851SDana.Myers@Sun.COM while (NextOp)
5687851SDana.Myers@Sun.COM {
5697851SDana.Myers@Sun.COM AcpiDmIsEisaIdElement (NextOp);
5707851SDana.Myers@Sun.COM NextOp = NextOp->Common.Next;
5717851SDana.Myers@Sun.COM }
5723446Smrj }
5733446Smrj
5743446Smrj
5753446Smrj /*******************************************************************************
5763446Smrj *
5773446Smrj * FUNCTION: AcpiDmEisaId
5783446Smrj *
5793446Smrj * PARAMETERS: EncodedId - Raw encoded EISA ID.
5803446Smrj *
5813446Smrj * RETURN: None
5823446Smrj *
5833446Smrj * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String.
5843446Smrj *
5853446Smrj ******************************************************************************/
5863446Smrj
5873446Smrj void
AcpiDmEisaId(UINT32 EncodedId)5883446Smrj AcpiDmEisaId (
5893446Smrj UINT32 EncodedId)
5903446Smrj {
5913446Smrj UINT32 BigEndianId;
5923446Smrj
5933446Smrj
5943446Smrj /* Swap from little-endian to big-endian to simplify conversion */
5953446Smrj
5963446Smrj BigEndianId = AcpiUtDwordByteSwap (EncodedId);
5973446Smrj
5983446Smrj
5993446Smrj /* Split to form "AAANNNN" string */
6003446Smrj
6013446Smrj AcpiOsPrintf ("EisaId (\"%c%c%c%4.4X\")",
6023446Smrj
6033446Smrj /* Three Alpha characters (AAA), 5 bits each */
6043446Smrj
6053446Smrj (int) ((BigEndianId >> 26) & 0x1F) + 0x40,
6063446Smrj (int) ((BigEndianId >> 21) & 0x1F) + 0x40,
6073446Smrj (int) ((BigEndianId >> 16) & 0x1F) + 0x40,
6083446Smrj
6093446Smrj /* Numeric part (NNNN) is simply the lower 16 bits */
6103446Smrj
6113446Smrj (UINT32) (BigEndianId & 0xFFFF));
6123446Smrj }
6133446Smrj
6143446Smrj #endif
615