1 /*******************************************************************************
3 * Module Name: dmbuffer - AML disassembler, buffer and string support
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2016, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
53 #ifdef ACPI_DISASSEMBLER
55 #define _COMPONENT ACPI_CA_DEBUGGER
56 ACPI_MODULE_NAME ("dmbuffer")
58 /* Local prototypes */
62 ACPI_PARSE_OBJECT
*Op
);
66 ACPI_PARSE_OBJECT
*Op
);
69 AcpiDmGetHardwareIdType (
70 ACPI_PARSE_OBJECT
*Op
);
79 AcpiDmFindNameByIndex (
84 #define ACPI_BUFFER_BYTES_PER_LINE 8
87 /*******************************************************************************
89 * FUNCTION: AcpiDmDisasmByteList
91 * PARAMETERS: Level - Current source code indentation level
92 * ByteData - Pointer to the byte list
93 * ByteCount - Length of the byte list
97 * DESCRIPTION: Dump an AML "ByteList" in Hex format. 8 bytes per line, prefixed
98 * with the hex buffer offset.
100 ******************************************************************************/
103 AcpiDmDisasmByteList (
119 for (i
= 0; i
< ByteCount
; i
+= ACPI_BUFFER_BYTES_PER_LINE
)
121 /* Line indent and offset prefix for each new line */
123 AcpiDmIndent (Level
);
124 if (ByteCount
> ACPI_BUFFER_BYTES_PER_LINE
)
126 AcpiOsPrintf ("/* %04X */ ", i
);
129 /* Dump the actual hex values */
131 for (j
= 0; j
< ACPI_BUFFER_BYTES_PER_LINE
; j
++)
133 CurrentIndex
= i
+ j
;
134 if (CurrentIndex
>= ByteCount
)
136 /* Dump fill spaces */
142 AcpiOsPrintf (" 0x%2.2X", ByteData
[CurrentIndex
]);
144 /* Add comma if there are more bytes to display */
146 if (CurrentIndex
< (ByteCount
- 1))
156 /* Dump the ASCII equivalents within a comment */
158 AcpiOsPrintf (" /* ");
159 for (j
= 0; j
< ACPI_BUFFER_BYTES_PER_LINE
; j
++)
161 CurrentIndex
= i
+ j
;
162 if (CurrentIndex
>= ByteCount
)
167 BufChar
= ByteData
[CurrentIndex
];
168 if (isprint (BufChar
))
170 AcpiOsPrintf ("%c", BufChar
);
178 /* Finished with this line */
180 AcpiOsPrintf (" */\n");
185 /*******************************************************************************
187 * FUNCTION: AcpiDmByteList
189 * PARAMETERS: Info - Parse tree walk info
194 * DESCRIPTION: Dump a buffer byte list, handling the various types of buffers.
195 * Buffer type must be already set in the Op DisasmOpcode.
197 ******************************************************************************/
201 ACPI_OP_WALK_INFO
*Info
,
202 ACPI_PARSE_OBJECT
*Op
)
208 ByteData
= Op
->Named
.Data
;
209 ByteCount
= (UINT32
) Op
->Common
.Value
.Integer
;
212 * The byte list belongs to a buffer, and can be produced by either
213 * a ResourceTemplate, Unicode, quoted string, or a plain byte list.
215 switch (Op
->Common
.Parent
->Common
.DisasmOpcode
)
217 case ACPI_DASM_RESOURCE
:
219 AcpiDmResourceTemplate (
220 Info
, Op
->Common
.Parent
, ByteData
, ByteCount
);
223 case ACPI_DASM_STRING
:
225 AcpiDmIndent (Info
->Level
);
226 AcpiUtPrintString ((char *) ByteData
, ACPI_UINT16_MAX
);
235 case ACPI_DASM_UNICODE
:
240 case ACPI_DASM_PLD_METHOD
:
242 AcpiDmDisasmByteList (Info
->Level
, ByteData
, ByteCount
);
244 AcpiDmPldBuffer (Info
->Level
, ByteData
, ByteCount
);
247 case ACPI_DASM_BUFFER
:
250 * Not a resource, string, or unicode string.
251 * Just dump the buffer
253 AcpiDmDisasmByteList (Info
->Level
, ByteData
, ByteCount
);
259 /*******************************************************************************
261 * FUNCTION: AcpiDmIsUuidBuffer
263 * PARAMETERS: Op - Buffer Object to be examined
265 * RETURN: TRUE if buffer contains a UUID
267 * DESCRIPTION: Determine if a buffer Op contains a UUID
269 * To help determine whether the buffer is a UUID versus a raw data buffer,
270 * there a are a couple bytes we can look at:
272 * xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
274 * The variant covered by the UUID specification is indicated by the two most
275 * significant bits of N being 1 0 (i.e., the hexadecimal N will always be
278 * The variant covered by the UUID specification has five versions. For this
279 * variant, the four bits of M indicates the UUID version (i.e., the
280 * hexadecimal M will be either 1, 2, 3, 4, or 5).
282 ******************************************************************************/
286 ACPI_PARSE_OBJECT
*Op
)
290 ACPI_PARSE_OBJECT
*SizeOp
;
291 ACPI_PARSE_OBJECT
*NextOp
;
294 /* Buffer size is the buffer argument */
296 SizeOp
= Op
->Common
.Value
.Arg
;
298 /* Next, the initializer byte list to examine */
300 NextOp
= SizeOp
->Common
.Next
;
306 /* Extract the byte list info */
308 ByteData
= NextOp
->Named
.Data
;
309 ByteCount
= (UINT32
) NextOp
->Common
.Value
.Integer
;
311 /* Byte count must be exactly 16 */
313 if (ByteCount
!= UUID_BUFFER_LENGTH
)
318 /* Check for valid "M" and "N" values (see function header above) */
320 if (((ByteData
[7] & 0xF0) == 0x00) || /* M={1,2,3,4,5} */
321 ((ByteData
[7] & 0xF0) > 0x50) ||
322 ((ByteData
[8] & 0xF0) < 0x80) || /* N={8,9,A,B} */
323 ((ByteData
[8] & 0xF0) > 0xB0))
328 /* Ignore the Size argument in the disassembly of this buffer op */
330 SizeOp
->Common
.DisasmFlags
|= ACPI_PARSEOP_IGNORE
;
335 /*******************************************************************************
337 * FUNCTION: AcpiDmUuid
339 * PARAMETERS: Op - Byte List op containing a UUID
343 * DESCRIPTION: Dump a buffer containing a UUID as a standard ASCII string.
346 * In its canonical form, the UUID is represented by a string containing 32
347 * lowercase hexadecimal digits, displayed in 5 groups separated by hyphens.
348 * The complete form is 8-4-4-4-12 for a total of 36 characters (32
349 * alphanumeric characters representing hex digits and 4 hyphens). In bytes,
350 * 4-2-2-2-6. Example:
352 * ToUUID ("107ededd-d381-4fd7-8da9-08e9a6c79644")
354 ******************************************************************************/
358 ACPI_PARSE_OBJECT
*Op
)
361 const char *Description
;
364 Data
= ACPI_CAST_PTR (UINT8
, Op
->Named
.Data
);
366 /* Emit the 36-byte UUID string in the proper format/order */
369 "\"%2.2x%2.2x%2.2x%2.2x-"
373 "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\")",
374 Data
[3], Data
[2], Data
[1], Data
[0],
378 Data
[10], Data
[11], Data
[12], Data
[13], Data
[14], Data
[15]);
380 /* Dump the UUID description string if available */
382 Description
= AcpiAhMatchUuid (Data
);
385 AcpiOsPrintf (" /* %s */", Description
);
390 /*******************************************************************************
392 * FUNCTION: AcpiDmIsUnicodeBuffer
394 * PARAMETERS: Op - Buffer Object to be examined
396 * RETURN: TRUE if buffer contains a UNICODE string
398 * DESCRIPTION: Determine if a buffer Op contains a Unicode string
400 ******************************************************************************/
403 AcpiDmIsUnicodeBuffer (
404 ACPI_PARSE_OBJECT
*Op
)
409 ACPI_PARSE_OBJECT
*SizeOp
;
410 ACPI_PARSE_OBJECT
*NextOp
;
414 /* Buffer size is the buffer argument */
416 SizeOp
= Op
->Common
.Value
.Arg
;
418 /* Next, the initializer byte list to examine */
420 NextOp
= SizeOp
->Common
.Next
;
426 /* Extract the byte list info */
428 ByteData
= NextOp
->Named
.Data
;
429 ByteCount
= (UINT32
) NextOp
->Common
.Value
.Integer
;
430 WordCount
= ACPI_DIV_2 (ByteCount
);
433 * Unicode string must have an even number of bytes and last
439 ((UINT16
*) (void *) ByteData
)[WordCount
- 1] != 0)
444 /* For each word, 1st byte must be ascii (1-0x7F), 2nd byte must be zero */
446 for (i
= 0; i
< (ByteCount
- 2); i
+= 2)
448 if ((ByteData
[i
] == 0) ||
449 (ByteData
[i
] > 0x7F) ||
450 (ByteData
[(ACPI_SIZE
) i
+ 1] != 0))
456 /* Ignore the Size argument in the disassembly of this buffer op */
458 SizeOp
->Common
.DisasmFlags
|= ACPI_PARSEOP_IGNORE
;
463 /*******************************************************************************
465 * FUNCTION: AcpiDmIsStringBuffer
467 * PARAMETERS: Op - Buffer Object to be examined
469 * RETURN: TRUE if buffer contains a ASCII string, FALSE otherwise
471 * DESCRIPTION: Determine if a buffer Op contains a ASCII string
473 ******************************************************************************/
476 AcpiDmIsStringBuffer (
477 ACPI_PARSE_OBJECT
*Op
)
481 ACPI_PARSE_OBJECT
*SizeOp
;
482 ACPI_PARSE_OBJECT
*NextOp
;
486 /* Buffer size is the buffer argument */
488 SizeOp
= Op
->Common
.Value
.Arg
;
490 /* Next, the initializer byte list to examine */
492 NextOp
= SizeOp
->Common
.Next
;
498 /* Extract the byte list info */
500 ByteData
= NextOp
->Named
.Data
;
501 ByteCount
= (UINT32
) NextOp
->Common
.Value
.Integer
;
503 /* Last byte must be the null terminator */
507 (ByteData
[ByteCount
-1] != 0))
512 for (i
= 0; i
< (ByteCount
- 1); i
++)
514 /* TBD: allow some escapes (non-ascii chars).
515 * they will be handled in the string output routine
518 if (!isprint (ByteData
[i
]))
528 /*******************************************************************************
530 * FUNCTION: AcpiDmIsPldBuffer
532 * PARAMETERS: Op - Buffer Object to be examined
534 * RETURN: TRUE if buffer appears to contain data produced via the
535 * ToPLD macro, FALSE otherwise
537 * DESCRIPTION: Determine if a buffer Op contains a _PLD structure
539 ******************************************************************************/
543 ACPI_PARSE_OBJECT
*Op
)
545 ACPI_NAMESPACE_NODE
*Node
;
546 ACPI_PARSE_OBJECT
*SizeOp
;
547 ACPI_PARSE_OBJECT
*ByteListOp
;
548 ACPI_PARSE_OBJECT
*ParentOp
;
550 UINT64 InitializerSize
;
554 * Get the BufferSize argument - Buffer(BufferSize)
555 * If the buffer was generated by the ToPld macro, it must
556 * be a BYTE constant.
558 SizeOp
= Op
->Common
.Value
.Arg
;
559 if (SizeOp
->Common
.AmlOpcode
!= AML_BYTE_OP
)
564 /* Check the declared BufferSize, two possibilities */
566 BufferSize
= SizeOp
->Common
.Value
.Integer
;
567 if ((BufferSize
!= ACPI_PLD_REV1_BUFFER_SIZE
) &&
568 (BufferSize
!= ACPI_PLD_REV2_BUFFER_SIZE
))
574 * Check the initializer list length. This is the actual
575 * number of bytes in the buffer as counted by the AML parser.
576 * The declared BufferSize can be larger than the actual length.
577 * However, for the ToPLD macro, the BufferSize will be the same
578 * as the initializer list length.
580 ByteListOp
= SizeOp
->Common
.Next
;
583 return (FALSE
); /* Zero-length buffer case */
586 InitializerSize
= ByteListOp
->Common
.Value
.Integer
;
587 if ((InitializerSize
!= ACPI_PLD_REV1_BUFFER_SIZE
) &&
588 (InitializerSize
!= ACPI_PLD_REV2_BUFFER_SIZE
))
593 /* Final size check */
595 if (BufferSize
!= InitializerSize
)
600 /* Now examine the buffer parent */
602 ParentOp
= Op
->Common
.Parent
;
608 /* Check for form: Name(_PLD, Buffer() {}). Not legal, however */
610 if (ParentOp
->Common
.AmlOpcode
== AML_NAME_OP
)
612 Node
= ParentOp
->Common
.Node
;
614 if (ACPI_COMPARE_NAME (Node
->Name
.Ascii
, METHOD_NAME__PLD
))
616 /* Ignore the Size argument in the disassembly of this buffer op */
618 SizeOp
->Common
.DisasmFlags
|= ACPI_PARSEOP_IGNORE
;
626 * Check for proper form: Name(_PLD, Package() {ToPLD()})
628 * Note: All other forms such as
629 * Return (Package() {ToPLD()})
631 * etc. are not converted back to the ToPLD macro, because
632 * there is really no deterministic way to disassemble the buffer
633 * back to the ToPLD macro, other than trying to find the "_PLD"
636 if (ParentOp
->Common
.AmlOpcode
== AML_PACKAGE_OP
)
638 ParentOp
= ParentOp
->Common
.Parent
;
644 if (ParentOp
->Common
.AmlOpcode
== AML_NAME_OP
)
646 Node
= ParentOp
->Common
.Node
;
648 if (ACPI_COMPARE_NAME (Node
->Name
.Ascii
, METHOD_NAME__PLD
))
650 /* Ignore the Size argument in the disassembly of this buffer op */
652 SizeOp
->Common
.DisasmFlags
|= ACPI_PARSEOP_IGNORE
;
662 /*******************************************************************************
664 * FUNCTION: AcpiDmFindNameByIndex
666 * PARAMETERS: Index - Index of array to check
667 * List - Array to reference
669 * RETURN: String from List or empty string
671 * DESCRIPTION: Finds and returns the char string located at the given index
674 ******************************************************************************/
677 AcpiDmFindNameByIndex (
681 const char *NameString
;
687 NameString
= List
[0];
693 NameString
= List
[i
];
698 /* TBD: Add error msg */
703 return (List
[Index
]);
707 /*******************************************************************************
709 * FUNCTION: AcpiDmPldBuffer
711 * PARAMETERS: Level - Current source code indentation level
712 * ByteData - Pointer to the byte list
713 * ByteCount - Length of the byte list
717 * DESCRIPTION: Dump and format the contents of a _PLD buffer object
719 ******************************************************************************/
721 #define ACPI_PLD_OUTPUT08 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " "
722 #define ACPI_PLD_OUTPUT08P "%*.s%-22s = 0x%X)\n", ACPI_MUL_4 (Level), " "
723 #define ACPI_PLD_OUTPUT16 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " "
724 #define ACPI_PLD_OUTPUT16P "%*.s%-22s = 0x%X)\n", ACPI_MUL_4 (Level), " "
725 #define ACPI_PLD_OUTPUT24 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " "
726 #define ACPI_PLD_OUTPUTSTR "%*.s%-22s = \"%s\",\n", ACPI_MUL_4 (Level), " "
734 ACPI_PLD_INFO
*PldInfo
;
738 /* Check for valid byte count */
740 if (ByteCount
< ACPI_PLD_REV1_BUFFER_SIZE
)
745 /* Convert _PLD buffer to local _PLD struct */
747 Status
= AcpiDecodePldBuffer (ByteData
, ByteCount
, &PldInfo
);
748 if (ACPI_FAILURE (Status
))
755 /* First 32-bit dword */
757 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_Revision", PldInfo
->Revision
);
758 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_IgnoreColor", PldInfo
->IgnoreColor
);
759 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_Red", PldInfo
->Red
);
760 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_Green", PldInfo
->Green
);
761 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_Blue", PldInfo
->Blue
);
763 /* Second 32-bit dword */
765 AcpiOsPrintf (ACPI_PLD_OUTPUT16
, "PLD_Width", PldInfo
->Width
);
766 AcpiOsPrintf (ACPI_PLD_OUTPUT16
, "PLD_Height", PldInfo
->Height
);
768 /* Third 32-bit dword */
770 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_UserVisible", PldInfo
->UserVisible
);
771 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_Dock", PldInfo
->Dock
);
772 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_Lid", PldInfo
->Lid
);
773 AcpiOsPrintf (ACPI_PLD_OUTPUTSTR
, "PLD_Panel",
774 AcpiDmFindNameByIndex(PldInfo
->Panel
, AcpiGbl_PldPanelList
));
776 AcpiOsPrintf (ACPI_PLD_OUTPUTSTR
, "PLD_VerticalPosition",
777 AcpiDmFindNameByIndex(PldInfo
->VerticalPosition
, AcpiGbl_PldVerticalPositionList
));
779 AcpiOsPrintf (ACPI_PLD_OUTPUTSTR
, "PLD_HorizontalPosition",
780 AcpiDmFindNameByIndex(PldInfo
->HorizontalPosition
, AcpiGbl_PldHorizontalPositionList
));
782 AcpiOsPrintf (ACPI_PLD_OUTPUTSTR
, "PLD_Shape",
783 AcpiDmFindNameByIndex(PldInfo
->Shape
, AcpiGbl_PldShapeList
));
784 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_GroupOrientation", PldInfo
->GroupOrientation
);
786 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_GroupToken", PldInfo
->GroupToken
);
787 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_GroupPosition", PldInfo
->GroupPosition
);
788 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_Bay", PldInfo
->Bay
);
790 /* Fourth 32-bit dword */
792 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_Ejectable", PldInfo
->Ejectable
);
793 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_EjectRequired", PldInfo
->OspmEjectRequired
);
794 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_CabinetNumber", PldInfo
->CabinetNumber
);
795 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_CardCageNumber", PldInfo
->CardCageNumber
);
796 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_Reference", PldInfo
->Reference
);
797 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_Rotation", PldInfo
->Rotation
);
799 if (ByteCount
>= ACPI_PLD_REV2_BUFFER_SIZE
)
801 AcpiOsPrintf (ACPI_PLD_OUTPUT08
, "PLD_Order", PldInfo
->Order
);
803 /* Fifth 32-bit dword */
805 AcpiOsPrintf (ACPI_PLD_OUTPUT16
, "PLD_VerticalOffset", PldInfo
->VerticalOffset
);
806 AcpiOsPrintf (ACPI_PLD_OUTPUT16P
, "PLD_HorizontalOffset", PldInfo
->HorizontalOffset
);
808 else /* Rev 1 buffer */
810 AcpiOsPrintf (ACPI_PLD_OUTPUT08P
, "PLD_Order", PldInfo
->Order
);
817 /*******************************************************************************
819 * FUNCTION: AcpiDmUnicode
821 * PARAMETERS: Op - Byte List op containing Unicode string
825 * DESCRIPTION: Dump Unicode string as a standard ASCII string. (Remove
826 * the extra zero bytes).
828 ******************************************************************************/
832 ACPI_PARSE_OBJECT
*Op
)
840 /* Extract the buffer info as a WORD buffer */
842 WordData
= ACPI_CAST_PTR (UINT16
, Op
->Named
.Data
);
843 WordCount
= ACPI_DIV_2 (((UINT32
) Op
->Common
.Value
.Integer
));
845 /* Write every other byte as an ASCII character */
848 for (i
= 0; i
< (WordCount
- 1); i
++)
850 OutputValue
= (int) WordData
[i
];
852 /* Handle values that must be escaped */
854 if ((OutputValue
== '\"') ||
855 (OutputValue
== '\\'))
857 AcpiOsPrintf ("\\%c", OutputValue
);
859 else if (!isprint (OutputValue
))
861 AcpiOsPrintf ("\\x%2.2X", OutputValue
);
865 AcpiOsPrintf ("%c", OutputValue
);
869 AcpiOsPrintf ("\")");
873 /*******************************************************************************
875 * FUNCTION: AcpiDmGetHardwareIdType
877 * PARAMETERS: Op - Op to be examined
881 * DESCRIPTION: Determine the type of the argument to a _HID or _CID
882 * 1) Strings are allowed
883 * 2) If Integer, determine if it is a valid EISAID
885 ******************************************************************************/
888 AcpiDmGetHardwareIdType (
889 ACPI_PARSE_OBJECT
*Op
)
896 switch (Op
->Common
.AmlOpcode
)
900 /* Mark this string as an _HID/_CID string */
902 Op
->Common
.DisasmOpcode
= ACPI_DASM_HID_STRING
;
908 /* Determine if a Word/Dword is a valid encoded EISAID */
910 /* Swap from little-endian to big-endian to simplify conversion */
912 BigEndianId
= AcpiUtDwordByteSwap ((UINT32
) Op
->Common
.Value
.Integer
);
914 /* Create the 3 leading ASCII letters */
916 Prefix
[0] = ((BigEndianId
>> 26) & 0x1F) + 0x40;
917 Prefix
[1] = ((BigEndianId
>> 21) & 0x1F) + 0x40;
918 Prefix
[2] = ((BigEndianId
>> 16) & 0x1F) + 0x40;
920 /* Verify that all 3 are ascii and alpha */
922 for (i
= 0; i
< 3; i
++)
924 if (!ACPI_IS_ASCII (Prefix
[i
]) ||
925 !isalpha (Prefix
[i
]))
931 /* Mark this node as convertable to an EISA ID string */
933 Op
->Common
.DisasmOpcode
= ACPI_DASM_EISAID
;
942 /*******************************************************************************
944 * FUNCTION: AcpiDmCheckForHardwareId
946 * PARAMETERS: Op - Op to be examined
950 * DESCRIPTION: Determine if a Name() Op is a _HID/_CID.
952 ******************************************************************************/
955 AcpiDmCheckForHardwareId (
956 ACPI_PARSE_OBJECT
*Op
)
959 ACPI_PARSE_OBJECT
*NextOp
;
962 /* Get the NameSegment */
964 Name
= AcpiPsGetName (Op
);
970 NextOp
= AcpiPsGetDepthNext (NULL
, Op
);
976 /* Check for _HID - has one argument */
978 if (ACPI_COMPARE_NAME (&Name
, METHOD_NAME__HID
))
980 AcpiDmGetHardwareIdType (NextOp
);
984 /* Exit if not _CID */
986 if (!ACPI_COMPARE_NAME (&Name
, METHOD_NAME__CID
))
991 /* _CID can contain a single argument or a package */
993 if (NextOp
->Common
.AmlOpcode
!= AML_PACKAGE_OP
)
995 AcpiDmGetHardwareIdType (NextOp
);
999 /* _CID with Package: get the package length, check all elements */
1001 NextOp
= AcpiPsGetDepthNext (NULL
, NextOp
);
1007 /* Don't need to use the length, just walk the peer list */
1009 NextOp
= NextOp
->Common
.Next
;
1012 AcpiDmGetHardwareIdType (NextOp
);
1013 NextOp
= NextOp
->Common
.Next
;
1018 /*******************************************************************************
1020 * FUNCTION: AcpiDmDecompressEisaId
1022 * PARAMETERS: EncodedId - Raw encoded EISA ID.
1026 * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String
1027 * and emit the correct ASL statement. If the ID is known, emit
1028 * a description of the ID as a comment.
1030 ******************************************************************************/
1033 AcpiDmDecompressEisaId (
1036 char IdBuffer
[ACPI_EISAID_STRING_SIZE
];
1037 const AH_DEVICE_ID
*Info
;
1040 /* Convert EISAID to a string an emit the statement */
1042 AcpiExEisaIdToString (IdBuffer
, EncodedId
);
1043 AcpiOsPrintf ("EisaId (\"%s\")", IdBuffer
);
1045 /* If we know about the ID, emit the description */
1047 Info
= AcpiAhMatchHardwareId (IdBuffer
);
1050 AcpiOsPrintf (" /* %s */", Info
->Description
);