1 /******************************************************************************
3 * Module Name: aslopcode - AML opcode generation
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2020, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include <contrib/dev/acpica/compiler/aslcompiler.h>
153 #include "aslcompiler.y.h"
154 #include <contrib/dev/acpica/include/amlcode.h>
156 #define _COMPONENT ACPI_COMPILER
157 ACPI_MODULE_NAME ("aslopcodes")
160 /* Local prototypes */
164 ACPI_PARSE_OBJECT *Op);
168 ACPI_PARSE_OBJECT *Op);
172 ACPI_PARSE_OBJECT *Op);
176 ACPI_PARSE_OBJECT *Op);
180 ACPI_PARSE_OBJECT *Op);
183 /*******************************************************************************
185 * FUNCTION: OpcAmlOpcodeUpdateWalk
187 * PARAMETERS: ASL_WALK_CALLBACK
191 * DESCRIPTION: Opcode update walk, ascending callback
193 ******************************************************************************/
196 OpcAmlOpcodeUpdateWalk (
197 ACPI_PARSE_OBJECT *Op,
203 * Handle the Package() case where the actual opcode cannot be determined
204 * until the PackageLength operand has been folded and minimized.
205 * (PackageOp versus VarPackageOp)
207 * This is (as of ACPI 3.0) the only case where the AML opcode can change
208 * based upon the value of a parameter.
210 * The parser always inserts a VarPackage opcode, which can possibly be
211 * optimized to a Package opcode.
213 if (Op->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)
222 /*******************************************************************************
224 * FUNCTION: OpcAmlOpcodeWalk
226 * PARAMETERS: ASL_WALK_CALLBACK
230 * DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
233 ******************************************************************************/
237 ACPI_PARSE_OBJECT *Op,
242 AslGbl_TotalParseNodes++;
244 OpcGenerateAmlOpcode (Op);
245 OpnGenerateAmlOperands (Op);
250 /*******************************************************************************
252 * FUNCTION: OpcGetIntegerWidth
254 * PARAMETERS: Op - DEFINITION BLOCK op
258 * DESCRIPTION: Extract integer width from the table revision
260 ******************************************************************************/
264 ACPI_PARSE_OBJECT *Op)
266 ACPI_PARSE_OBJECT *Child;
274 if (AslGbl_RevisionOverride)
276 AcpiUtSetIntegerWidth (AslGbl_RevisionOverride);
280 Child = Op->Asl.Child;
281 Child = Child->Asl.Next;
282 Child = Child->Asl.Next;
284 /* Use the revision to set the integer width */
286 AcpiUtSetIntegerWidth ((UINT8) Child->Asl.Value.Integer);
291 /*******************************************************************************
293 * FUNCTION: OpcSetOptimalIntegerSize
295 * PARAMETERS: Op - A parse tree node
297 * RETURN: Integer width, in bytes. Also sets the node AML opcode to the
298 * optimal integer AML prefix opcode.
300 * DESCRIPTION: Determine the optimal AML encoding of an integer. All leading
301 * zeros can be truncated to squeeze the integer into the
302 * minimal number of AML bytes.
304 ******************************************************************************/
307 OpcSetOptimalIntegerSize (
308 ACPI_PARSE_OBJECT *Op)
313 * TBD: - we don't want to optimize integers in the block header, but the
314 * code below does not work correctly.
316 if (Op->Asl.Parent &&
317 Op->Asl.Parent->Asl.Parent &&
318 (Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK))
325 * Check for the special AML integers first - Zero, One, Ones.
326 * These are single-byte opcodes that are the smallest possible
327 * representation of an integer.
329 * This optimization is optional.
331 if (AslGbl_IntegerOptimizationFlag)
333 switch (Op->Asl.Value.Integer)
337 Op->Asl.AmlOpcode = AML_ZERO_OP;
338 AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
344 Op->Asl.AmlOpcode = AML_ONE_OP;
345 AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
349 case ACPI_UINT32_MAX:
351 /* Check for table integer width (32 or 64) */
353 if (AcpiGbl_IntegerByteWidth == 4)
355 Op->Asl.AmlOpcode = AML_ONES_OP;
356 AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
362 case ACPI_UINT64_MAX:
364 /* Check for table integer width (32 or 64) */
366 if (AcpiGbl_IntegerByteWidth == 8)
368 Op->Asl.AmlOpcode = AML_ONES_OP;
369 AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
381 /* Find the best fit using the various AML integer prefixes */
383 if (Op->Asl.Value.Integer <= ACPI_UINT8_MAX)
385 Op->Asl.AmlOpcode = AML_BYTE_OP;
389 if (Op->Asl.Value.Integer <= ACPI_UINT16_MAX)
391 Op->Asl.AmlOpcode = AML_WORD_OP;
395 if (Op->Asl.Value.Integer <= ACPI_UINT32_MAX)
397 Op->Asl.AmlOpcode = AML_DWORD_OP;
400 else /* 64-bit integer */
402 if (AcpiGbl_IntegerByteWidth == 4)
404 AslError (ASL_WARNING, ASL_MSG_INTEGER_LENGTH,
407 if (!AslGbl_IgnoreErrors)
409 /* Truncate the integer to 32-bit */
411 Op->Asl.Value.Integer &= ACPI_UINT32_MAX;
413 /* Now set the optimal integer size */
415 return (OpcSetOptimalIntegerSize (Op));
419 Op->Asl.AmlOpcode = AML_QWORD_OP;
425 /*******************************************************************************
427 * FUNCTION: OpcDoAccessAs
429 * PARAMETERS: Op - Parse node
433 * DESCRIPTION: Implement the ACCESS_AS ASL keyword.
435 ******************************************************************************/
439 ACPI_PARSE_OBJECT *Op)
441 ACPI_PARSE_OBJECT *TypeOp;
442 ACPI_PARSE_OBJECT *AttribOp;
443 ACPI_PARSE_OBJECT *LengthOp;
447 Op->Asl.AmlOpcodeLength = 1;
448 TypeOp = Op->Asl.Child;
450 /* First child is the access type */
452 TypeOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
453 TypeOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
455 /* Second child is the optional access attribute */
457 AttribOp = TypeOp->Asl.Next;
458 if (AttribOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
460 AttribOp->Asl.Value.Integer = 0;
463 AttribOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
464 AttribOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
466 /* Only a few AccessAttributes support AccessLength */
468 Attribute = (UINT8) AttribOp->Asl.Value.Integer;
469 if ((Attribute != AML_FIELD_ATTRIB_BYTES) &&
470 (Attribute != AML_FIELD_ATTRIB_RAW_BYTES) &&
471 (Attribute != AML_FIELD_ATTRIB_RAW_PROCESS_BYTES))
476 Op->Asl.AmlOpcode = AML_FIELD_EXT_ACCESS_OP;
479 * Child of Attributes is the AccessLength (required for Multibyte,
480 * RawBytes, RawProcess.)
482 LengthOp = AttribOp->Asl.Child;
488 /* TBD: probably can remove */
490 if (LengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
492 LengthOp->Asl.Value.Integer = 16;
495 LengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
496 LengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
500 /*******************************************************************************
502 * FUNCTION: OpcDoConnection
504 * PARAMETERS: Op - Parse node
508 * DESCRIPTION: Implement the Connection ASL keyword.
510 ******************************************************************************/
514 ACPI_PARSE_OBJECT *Op)
516 ASL_RESOURCE_NODE *Rnode;
517 ACPI_PARSE_OBJECT *BufferOp;
518 ACPI_PARSE_OBJECT *BufferLengthOp;
519 ACPI_PARSE_OBJECT *BufferDataOp;
520 ASL_RESOURCE_INFO Info;
524 Op->Asl.AmlOpcodeLength = 1;
526 if (Op->Asl.Child->Asl.AmlOpcode == AML_INT_NAMEPATH_OP)
531 BufferOp = Op->Asl.Child;
532 BufferLengthOp = BufferOp->Asl.Child;
533 BufferDataOp = BufferLengthOp->Asl.Next;
535 Info.DescriptorTypeOp = BufferDataOp->Asl.Next;
536 Info.CurrentByteOffset = 0;
537 State = ACPI_RSTATE_NORMAL;
538 Rnode = RsDoOneResourceDescriptor (&Info, &State);
545 * Transform the nodes into the following
547 * Op -> AML_BUFFER_OP
548 * First Child -> BufferLength
549 * Second Child -> Descriptor Buffer (raw byte data)
551 BufferOp->Asl.ParseOpcode = PARSEOP_BUFFER;
552 BufferOp->Asl.AmlOpcode = AML_BUFFER_OP;
553 BufferOp->Asl.CompileFlags = OP_AML_PACKAGE | OP_IS_RESOURCE_DESC;
554 UtSetParseOpName (BufferOp);
556 BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
557 BufferLengthOp->Asl.Value.Integer = Rnode->BufferLength;
558 (void) OpcSetOptimalIntegerSize (BufferLengthOp);
559 UtSetParseOpName (BufferLengthOp);
561 BufferDataOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
562 BufferDataOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN;
563 BufferDataOp->Asl.AmlOpcodeLength = 0;
564 BufferDataOp->Asl.AmlLength = Rnode->BufferLength;
565 BufferDataOp->Asl.Value.Buffer = (UINT8 *) Rnode;
566 UtSetParseOpName (BufferDataOp);
570 /*******************************************************************************
572 * FUNCTION: OpcDoUnicode
574 * PARAMETERS: Op - Parse node
578 * DESCRIPTION: Implement the UNICODE ASL "macro". Convert the input string
579 * to a unicode buffer. There is no Unicode AML opcode.
581 * Note: The Unicode string is 16 bits per character, no leading signature,
582 * with a 16-bit terminating NULL.
584 ******************************************************************************/
588 ACPI_PARSE_OBJECT *Op)
590 ACPI_PARSE_OBJECT *InitializerOp;
595 UINT16 *UnicodeString;
596 ACPI_PARSE_OBJECT *BufferLengthOp;
599 /* Change op into a buffer object */
601 Op->Asl.CompileFlags &= ~OP_COMPILE_TIME_CONST;
602 Op->Asl.ParseOpcode = PARSEOP_BUFFER;
603 UtSetParseOpName (Op);
605 /* Buffer Length is first, followed by the string */
607 BufferLengthOp = Op->Asl.Child;
608 InitializerOp = BufferLengthOp->Asl.Next;
610 AsciiString = (UINT8 *) InitializerOp->Asl.Value.String;
612 /* Create a new buffer for the Unicode string */
614 Count = strlen (InitializerOp->Asl.Value.String) + 1;
615 Length = Count * sizeof (UINT16);
616 UnicodeString = UtLocalCalloc (Length);
618 /* Convert to Unicode string (including null terminator) */
620 for (i = 0; i < Count; i++)
622 UnicodeString[i] = (UINT16) AsciiString[i];
626 * Just set the buffer size node to be the buffer length, regardless
627 * of whether it was previously an integer or a default_arg placeholder
629 BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
630 BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP;
631 BufferLengthOp->Asl.Value.Integer = Length;
632 UtSetParseOpName (BufferLengthOp);
634 (void) OpcSetOptimalIntegerSize (BufferLengthOp);
636 /* The Unicode string is a raw data buffer */
638 InitializerOp->Asl.Value.Buffer = (UINT8 *) UnicodeString;
639 InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
640 InitializerOp->Asl.AmlLength = Length;
641 InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
642 InitializerOp->Asl.Child = NULL;
643 UtSetParseOpName (InitializerOp);
647 /*******************************************************************************
649 * FUNCTION: OpcDoEisaId
651 * PARAMETERS: Op - Parse node
655 * DESCRIPTION: Convert a string EISA ID to numeric representation. See the
656 * Pnp BIOS Specification for details. Here is an excerpt:
658 * A seven character ASCII representation of the product
659 * identifier compressed into a 32-bit identifier. The seven
660 * character ID consists of a three character manufacturer code,
661 * a three character hexadecimal product identifier, and a one
662 * character hexadecimal revision number. The manufacturer code
663 * is a 3 uppercase character code that is compressed into 3 5-bit
665 * 1) Find hex ASCII value for each letter
666 * 2) Subtract 40h from each ASCII value
667 * 3) Retain 5 least significant bits for each letter by
668 * discarding upper 3 bits because they are always 0.
669 * 4) Compressed code = concatenate 0 and the 3 5-bit values
671 * The format of the compressed product identifier is as follows:
672 * Byte 0: Bit 7 - Reserved (0)
673 * Bits 6-2: - 1st character of compressed mfg code
674 * Bits 1-0 - Upper 2 bits of 2nd character of mfg code
675 * Byte 1: Bits 7-5 - Lower 3 bits of 2nd character of mfg code
676 * Bits 4-0 - 3rd character of mfg code
677 * Byte 2: Bits 7-4 - 1st hex digit of product number
678 * Bits 3-0 - 2nd hex digit of product number
679 * Byte 3: Bits 7-4 - 3st hex digit of product number
680 * Bits 3-0 - Hex digit of the revision number
682 ******************************************************************************/
686 ACPI_PARSE_OBJECT *Op)
691 ACPI_STATUS Status = AE_OK;
695 InString = (char *) Op->Asl.Value.String;
698 * The EISAID string must be exactly 7 characters and of the form
699 * "UUUXXXX" -- 3 uppercase letters and 4 hex digits (e.g., "PNP0001")
701 if (strlen (InString) != 7)
703 Status = AE_BAD_PARAMETER;
707 /* Check all 7 characters for correct format */
709 for (i = 0; i < 7; i++)
711 /* First 3 characters must be uppercase letters */
715 if (!isupper ((int) InString[i]))
717 Status = AE_BAD_PARAMETER;
721 /* Last 4 characters must be hex digits */
723 else if (!isxdigit ((int) InString[i]))
725 Status = AE_BAD_PARAMETER;
730 if (ACPI_FAILURE (Status))
732 AslError (ASL_ERROR, ASL_MSG_INVALID_EISAID, Op, Op->Asl.Value.String);
736 /* Create ID big-endian first (bits are contiguous) */
739 (UINT32) ((UINT8) (InString[0] - 0x40)) << 26 |
740 (UINT32) ((UINT8) (InString[1] - 0x40)) << 21 |
741 (UINT32) ((UINT8) (InString[2] - 0x40)) << 16 |
743 (AcpiUtAsciiCharToHex (InString[3])) << 12 |
744 (AcpiUtAsciiCharToHex (InString[4])) << 8 |
745 (AcpiUtAsciiCharToHex (InString[5])) << 4 |
746 AcpiUtAsciiCharToHex (InString[6]);
748 /* Swap to little-endian to get final ID (see function header) */
750 EisaId = AcpiUtDwordByteSwap (BigEndianId);
754 * Morph the Op into an integer, regardless of whether there
755 * was an error in the EISAID string
757 Op->Asl.Value.Integer = EisaId;
759 Op->Asl.CompileFlags &= ~OP_COMPILE_TIME_CONST;
760 Op->Asl.ParseOpcode = PARSEOP_INTEGER;
761 (void) OpcSetOptimalIntegerSize (Op);
763 /* Op is now an integer */
765 UtSetParseOpName (Op);
769 /*******************************************************************************
771 * FUNCTION: OpcDoUuId
773 * PARAMETERS: Op - Parse node
777 * DESCRIPTION: Convert UUID string to 16-byte buffer
779 ******************************************************************************/
783 ACPI_PARSE_OBJECT *Op)
787 ACPI_STATUS Status = AE_OK;
788 ACPI_PARSE_OBJECT *NewOp;
791 InString = ACPI_CAST_PTR (char, Op->Asl.Value.String);
792 Buffer = UtLocalCalloc (16);
794 Status = AuValidateUuid (InString);
795 if (ACPI_FAILURE (Status))
797 AslError (ASL_ERROR, ASL_MSG_INVALID_UUID, Op, Op->Asl.Value.String);
801 /* Convert UUID string to a buffer, check for a known UUID */
803 AcpiUtConvertStringToUuid (InString, Buffer);
804 if (!AcpiAhMatchUuid (Buffer))
806 AslError (ASL_REMARK, ASL_MSG_UUID_NOT_FOUND, Op, NULL);
810 /* Change Op to a Buffer */
812 Op->Asl.ParseOpcode = PARSEOP_BUFFER;
813 Op->Common.AmlOpcode = AML_BUFFER_OP;
815 /* Disable further optimization */
817 Op->Asl.CompileFlags &= ~OP_COMPILE_TIME_CONST;
818 UtSetParseOpName (Op);
820 /* Child node is the buffer length */
822 NewOp = TrAllocateOp (PARSEOP_INTEGER);
824 NewOp->Asl.AmlOpcode = AML_BYTE_OP;
825 NewOp->Asl.Value.Integer = 16;
826 NewOp->Asl.Parent = Op;
828 Op->Asl.Child = NewOp;
831 /* Peer to the child is the raw buffer data */
833 NewOp = TrAllocateOp (PARSEOP_RAW_DATA);
834 NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
835 NewOp->Asl.AmlLength = 16;
836 NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer);
837 NewOp->Asl.Parent = Op->Asl.Parent;
839 Op->Asl.Next = NewOp;
843 /*******************************************************************************
845 * FUNCTION: OpcGenerateAmlOpcode
847 * PARAMETERS: Op - Parse node
851 * DESCRIPTION: Generate the AML opcode associated with the node and its
852 * parse (lex/flex) keyword opcode. Essentially implements
853 * a mapping between the parse opcodes and the actual AML opcodes.
855 ******************************************************************************/
858 OpcGenerateAmlOpcode (
859 ACPI_PARSE_OBJECT *Op)
864 Index = (UINT16) (Op->Asl.ParseOpcode - ASL_PARSE_OPCODE_BASE);
866 Op->Asl.AmlOpcode = AslKeywordMapping[Index].AmlOpcode;
867 Op->Asl.AcpiBtype = AslKeywordMapping[Index].AcpiBtype;
868 Op->Asl.CompileFlags |= AslKeywordMapping[Index].Flags;
870 if (!Op->Asl.Value.Integer)
872 Op->Asl.Value.Integer = AslKeywordMapping[Index].Value;
875 /* Special handling for some opcodes */
877 switch (Op->Asl.ParseOpcode)
879 case PARSEOP_INTEGER:
881 * Set the opcode based on the size of the integer
883 (void) OpcSetOptimalIntegerSize (Op);
888 Op->Asl.AmlOpcodeLength = 1;
891 case PARSEOP_ACCESSAS:
896 case PARSEOP_CONNECTION:
898 OpcDoConnection (Op);
911 case PARSEOP_FPRINTF:
926 case PARSEOP_UNICODE:
931 case PARSEOP_INCLUDE:
933 AslGbl_HasIncludeFiles = TRUE;
938 if (AcpiGbl_IntegerBitWidth == 32)
940 AslError (ASL_REMARK, ASL_MSG_TRUNCATION, Op, NULL);
946 /* Nothing to do for other opcodes */