1 /******************************************************************************
3 * Module Name: aslutils -- compiler utilities
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2017, 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 "aslcompiler.h"
153 #include "aslcompiler.y.h"
154 #include "acdisasm.h"
155 #include "acnamesp.h"
158 #include <sys/stat.h>
161 #define _COMPONENT ACPI_COMPILER
162 ACPI_MODULE_NAME ("aslutils")
165 /* Local prototypes */
168 UtPadNameWithUnderscores (
170 char *PaddedNameSeg
);
174 ACPI_PARSE_OBJECT
*Op
,
178 UtReallocLineBuffers (
184 /*******************************************************************************
186 * FUNCTION: UtIsBigEndianMachine
190 * RETURN: TRUE if machine is big endian
191 * FALSE if machine is little endian
193 * DESCRIPTION: Detect whether machine is little endian or big endian.
195 ******************************************************************************/
198 UtIsBigEndianMachine (
204 } Overlay
= {0xFF000000};
207 return (Overlay
.Bytes
[0]); /* Returns 0xFF (TRUE) for big endian */
211 /******************************************************************************
213 * FUNCTION: UtQueryForOverwrite
215 * PARAMETERS: Pathname - Output filename
217 * RETURN: TRUE if file does not exist or overwrite is authorized
219 * DESCRIPTION: Query for file overwrite if it already exists.
221 ******************************************************************************/
224 UtQueryForOverwrite (
227 struct stat StatInfo
;
230 if (!stat (Pathname
, &StatInfo
))
232 fprintf (stderr
, "Target file \"%s\" already exists, overwrite? [y|n] ",
235 if (getchar () != 'y')
245 /*******************************************************************************
247 * FUNCTION: UtDisplaySupportedTables
253 * DESCRIPTION: Print all supported ACPI table names.
255 ******************************************************************************/
258 UtDisplaySupportedTables (
261 const AH_TABLE
*TableData
;
265 printf ("\nACPI tables supported by iASL version %8.8X:\n"
266 " (Compiler, Disassembler, Template Generator)\n\n",
269 /* All ACPI tables with the common table header */
271 printf ("\n Supported ACPI tables:\n");
272 for (TableData
= Gbl_AcpiSupportedTables
, i
= 1;
273 TableData
->Signature
; TableData
++, i
++)
275 printf ("%8u) %s %s\n", i
,
276 TableData
->Signature
, TableData
->Description
);
281 /*******************************************************************************
283 * FUNCTION: UtDisplayConstantOpcodes
289 * DESCRIPTION: Print AML opcodes that can be used in constant expressions.
291 ******************************************************************************/
294 UtDisplayConstantOpcodes (
300 printf ("Constant expression opcode information\n\n");
302 for (i
= 0; i
< sizeof (AcpiGbl_AmlOpInfo
) / sizeof (ACPI_OPCODE_INFO
); i
++)
304 if (AcpiGbl_AmlOpInfo
[i
].Flags
& AML_CONSTANT
)
306 printf ("%s\n", AcpiGbl_AmlOpInfo
[i
].Name
);
312 /*******************************************************************************
314 * FUNCTION: UtLocalCalloc
316 * PARAMETERS: Size - Bytes to be allocated
318 * RETURN: Pointer to the allocated memory. Guaranteed to be valid.
320 * DESCRIPTION: Allocate zero-initialized memory. Aborts the compile on an
321 * allocation failure, on the assumption that nothing more can be
324 ******************************************************************************/
333 Allocated
= ACPI_ALLOCATE_ZEROED (Size
);
336 AslCommonError (ASL_ERROR
, ASL_MSG_MEMORY_ALLOCATION
,
337 Gbl_CurrentLineNumber
, Gbl_LogicalLineNumber
,
338 Gbl_InputByteCount
, Gbl_CurrentColumn
,
339 Gbl_Files
[ASL_FILE_INPUT
].Filename
, NULL
);
346 TotalAllocated
+= Size
;
351 /*******************************************************************************
353 * FUNCTION: UtBeginEvent
355 * PARAMETERS: Name - Ascii name of this event
357 * RETURN: Event number (integer index)
359 * DESCRIPTION: Saves the current time with this event
361 ******************************************************************************/
368 if (AslGbl_NextEvent
>= ASL_NUM_EVENTS
)
370 AcpiOsPrintf ("Ran out of compiler event structs!\n");
371 return (AslGbl_NextEvent
);
374 /* Init event with current (start) time */
376 AslGbl_Events
[AslGbl_NextEvent
].StartTime
= AcpiOsGetTimer ();
377 AslGbl_Events
[AslGbl_NextEvent
].EventName
= Name
;
378 AslGbl_Events
[AslGbl_NextEvent
].Valid
= TRUE
;
379 return (AslGbl_NextEvent
++);
383 /*******************************************************************************
385 * FUNCTION: UtEndEvent
387 * PARAMETERS: Event - Event number (integer index)
391 * DESCRIPTION: Saves the current time (end time) with this event
393 ******************************************************************************/
400 if (Event
>= ASL_NUM_EVENTS
)
405 /* Insert end time for event */
407 AslGbl_Events
[Event
].EndTime
= AcpiOsGetTimer ();
411 /*******************************************************************************
415 * PARAMETERS: Type - Type of output
416 * Fmt - Printf format string
417 * ... - variable printf list
421 * DESCRIPTION: Conditional print statement. Prints to stderr only if the
424 ******************************************************************************/
440 if ((Type
== ASL_PARSE_OUTPUT
) &&
441 (!(AslCompilerdebug
)))
446 va_start (Args
, Fmt
);
447 (void) vfprintf (stderr
, Fmt
, Args
);
453 /*******************************************************************************
455 * FUNCTION: UtSetParseOpName
457 * PARAMETERS: Op - Parse op to be named.
461 * DESCRIPTION: Insert the ascii name of the parse opcode
463 ******************************************************************************/
467 ACPI_PARSE_OBJECT
*Op
)
470 strncpy (Op
->Asl
.ParseOpName
, UtGetOpName (Op
->Asl
.ParseOpcode
),
471 ACPI_MAX_PARSEOP_NAME
);
475 /*******************************************************************************
477 * FUNCTION: UtDisplaySummary
479 * PARAMETERS: FileID - ID of outpout file
483 * DESCRIPTION: Display compilation statistics
485 ******************************************************************************/
494 if (FileId
!= ASL_FILE_STDOUT
)
496 /* Compiler name and version number */
498 FlPrintFile (FileId
, "%s version %X [%s]\n\n",
499 ASL_COMPILER_NAME
, (UINT32
) ACPI_CA_VERSION
, __DATE__
);
502 /* Summary of main input and output files */
504 if (Gbl_FileType
== ASL_INPUT_TYPE_ASCII_DATA
)
507 "%-14s %s - %u lines, %u bytes, %u fields\n",
509 Gbl_Files
[ASL_FILE_INPUT
].Filename
, Gbl_CurrentLineNumber
,
510 Gbl_InputByteCount
, Gbl_InputFieldCount
);
512 if ((Gbl_ExceptionCount
[ASL_ERROR
] == 0) || (Gbl_IgnoreErrors
))
515 "%-14s %s - %u bytes\n",
517 Gbl_Files
[ASL_FILE_AML_OUTPUT
].Filename
, Gbl_TableLength
);
523 "%-14s %s - %u lines, %u bytes, %u keywords\n",
525 Gbl_Files
[ASL_FILE_INPUT
].Filename
, Gbl_CurrentLineNumber
,
526 Gbl_OriginalInputFileSize
, TotalKeywords
);
530 if ((Gbl_ExceptionCount
[ASL_ERROR
] == 0) || (Gbl_IgnoreErrors
))
532 if (Gbl_Files
[ASL_FILE_AML_OUTPUT
].Handle
)
535 "%-14s %s - %u bytes, %u named objects, "
536 "%u executable opcodes\n",
538 Gbl_Files
[ASL_FILE_AML_OUTPUT
].Filename
,
539 FlGetFileSize (ASL_FILE_AML_OUTPUT
),
540 TotalNamedObjects
, TotalExecutableOpcodes
);
545 /* Display summary of any optional files */
547 for (i
= ASL_FILE_SOURCE_OUTPUT
; i
<= ASL_MAX_FILE_TYPE
; i
++)
549 if (!Gbl_Files
[i
].Filename
|| !Gbl_Files
[i
].Handle
)
554 /* .SRC is a temp file unless specifically requested */
556 if ((i
== ASL_FILE_SOURCE_OUTPUT
) && (!Gbl_SourceOutputFlag
))
561 /* .PRE is the preprocessor intermediate file */
563 if ((i
== ASL_FILE_PREPROCESSOR
) && (!Gbl_KeepPreprocessorTempFile
))
568 FlPrintFile (FileId
, "%14s %s - %u bytes\n",
569 Gbl_Files
[i
].ShortDescription
,
570 Gbl_Files
[i
].Filename
, FlGetFileSize (i
));
576 "\nCompilation complete. %u Errors, %u Warnings, %u Remarks",
577 Gbl_ExceptionCount
[ASL_ERROR
],
578 Gbl_ExceptionCount
[ASL_WARNING
] +
579 Gbl_ExceptionCount
[ASL_WARNING2
] +
580 Gbl_ExceptionCount
[ASL_WARNING3
],
581 Gbl_ExceptionCount
[ASL_REMARK
]);
583 if (Gbl_FileType
!= ASL_INPUT_TYPE_ASCII_DATA
)
585 FlPrintFile (FileId
, ", %u Optimizations",
586 Gbl_ExceptionCount
[ASL_OPTIMIZATION
]);
590 FlPrintFile (FileId
, ", %u Constants Folded", TotalFolds
);
594 FlPrintFile (FileId
, "\n");
598 /*******************************************************************************
600 * FUNCTION: UtCheckIntegerRange
602 * PARAMETERS: Op - Integer parse node
603 * LowValue - Smallest allowed value
604 * HighValue - Largest allowed value
606 * RETURN: Op if OK, otherwise NULL
608 * DESCRIPTION: Check integer for an allowable range
610 ******************************************************************************/
613 UtCheckIntegerRange (
614 ACPI_PARSE_OBJECT
*Op
,
624 if ((Op
->Asl
.Value
.Integer
< LowValue
) ||
625 (Op
->Asl
.Value
.Integer
> HighValue
))
627 sprintf (MsgBuffer
, "0x%X, allowable: 0x%X-0x%X",
628 (UINT32
) Op
->Asl
.Value
.Integer
, LowValue
, HighValue
);
630 AslError (ASL_ERROR
, ASL_MSG_RANGE
, Op
, MsgBuffer
);
638 /*******************************************************************************
640 * FUNCTION: UtStringCacheCalloc
642 * PARAMETERS: Length - Size of buffer requested
644 * RETURN: Pointer to the buffer. Aborts compiler on allocation failure
646 * DESCRIPTION: Allocate a string buffer. Bypass the local
647 * dynamic memory manager for performance reasons (This has a
648 * major impact on the speed of the compiler.)
650 ******************************************************************************/
653 UtStringCacheCalloc (
657 ASL_CACHE_INFO
*Cache
;
658 UINT32 CacheSize
= ASL_STRING_CACHE_SIZE
;
661 if (Length
> CacheSize
)
665 if (Gbl_StringCacheList
)
667 Cache
= UtLocalCalloc (sizeof (Cache
->Next
) + CacheSize
);
669 /* Link new cache buffer just following head of list */
671 Cache
->Next
= Gbl_StringCacheList
->Next
;
672 Gbl_StringCacheList
->Next
= Cache
;
674 /* Leave cache management pointers alone as they pertain to head */
677 Gbl_StringSize
+= Length
;
679 return (Cache
->Buffer
);
683 if ((Gbl_StringCacheNext
+ Length
) >= Gbl_StringCacheLast
)
685 /* Allocate a new buffer */
687 Cache
= UtLocalCalloc (sizeof (Cache
->Next
) + CacheSize
);
689 /* Link new cache buffer to head of list */
691 Cache
->Next
= Gbl_StringCacheList
;
692 Gbl_StringCacheList
= Cache
;
694 /* Setup cache management pointers */
696 Gbl_StringCacheNext
= Cache
->Buffer
;
697 Gbl_StringCacheLast
= Gbl_StringCacheNext
+ CacheSize
;
701 Gbl_StringSize
+= Length
;
703 Buffer
= Gbl_StringCacheNext
;
704 Gbl_StringCacheNext
+= Length
;
709 /******************************************************************************
711 * FUNCTION: UtExpandLineBuffers
713 * PARAMETERS: None. Updates global line buffer pointers.
715 * RETURN: None. Reallocates the global line buffers
717 * DESCRIPTION: Called if the current line buffer becomes filled. Reallocates
718 * all global line buffers and updates Gbl_LineBufferSize. NOTE:
719 * Also used for the initial allocation of the buffers, when
720 * all of the buffer pointers are NULL. Initial allocations are
721 * of size ASL_DEFAULT_LINE_BUFFER_SIZE
723 *****************************************************************************/
726 UtExpandLineBuffers (
732 /* Attempt to double the size of all line buffers */
734 NewSize
= Gbl_LineBufferSize
* 2;
735 if (Gbl_CurrentLineBuffer
)
737 DbgPrint (ASL_DEBUG_OUTPUT
,
738 "Increasing line buffer size from %u to %u\n",
739 Gbl_LineBufferSize
, NewSize
);
742 UtReallocLineBuffers (&Gbl_CurrentLineBuffer
, Gbl_LineBufferSize
, NewSize
);
743 UtReallocLineBuffers (&Gbl_MainTokenBuffer
, Gbl_LineBufferSize
, NewSize
);
744 UtReallocLineBuffers (&Gbl_MacroTokenBuffer
, Gbl_LineBufferSize
, NewSize
);
745 UtReallocLineBuffers (&Gbl_ExpressionTokenBuffer
, Gbl_LineBufferSize
, NewSize
);
747 Gbl_LineBufPtr
= Gbl_CurrentLineBuffer
;
748 Gbl_LineBufferSize
= NewSize
;
752 /******************************************************************************
754 * FUNCTION: UtReallocLineBuffers
756 * PARAMETERS: Buffer - Buffer to realloc
757 * OldSize - Old size of Buffer
758 * NewSize - New size of Buffer
762 * DESCRIPTION: Reallocate and initialize Buffer
764 *****************************************************************************/
767 UtReallocLineBuffers (
773 *Buffer
= realloc (*Buffer
, NewSize
);
776 memset (*Buffer
+ OldSize
, 0, NewSize
- OldSize
);
780 printf ("Could not increase line buffer size from %u to %u\n",
783 AslError (ASL_ERROR
, ASL_MSG_BUFFER_ALLOCATION
, NULL
, NULL
);
788 /******************************************************************************
790 * FUNCTION: UtFreeLineBuffers
796 * DESCRIPTION: Free all line buffers
798 *****************************************************************************/
805 free (Gbl_CurrentLineBuffer
);
806 free (Gbl_MainTokenBuffer
);
807 free (Gbl_MacroTokenBuffer
);
808 free (Gbl_ExpressionTokenBuffer
);
812 /*******************************************************************************
814 * FUNCTION: UtInternalizeName
816 * PARAMETERS: ExternalName - Name to convert
817 * ConvertedName - Where the converted name is returned
821 * DESCRIPTION: Convert an external (ASL) name to an internal (AML) name
823 ******************************************************************************/
828 char **ConvertedName
)
830 ACPI_NAMESTRING_INFO Info
;
839 /* Get the length of the new internal name */
841 Info
.ExternalName
= ExternalName
;
842 AcpiNsGetInternalNameLength (&Info
);
844 /* We need a segment to store the internal name */
846 Info
.InternalName
= UtStringCacheCalloc (Info
.Length
);
850 Status
= AcpiNsBuildInternalName (&Info
);
851 if (ACPI_FAILURE (Status
))
856 *ConvertedName
= Info
.InternalName
;
861 /*******************************************************************************
863 * FUNCTION: UtPadNameWithUnderscores
865 * PARAMETERS: NameSeg - Input nameseg
866 * PaddedNameSeg - Output padded nameseg
868 * RETURN: Padded nameseg.
870 * DESCRIPTION: Pads a NameSeg with underscores if necessary to form a full
873 ******************************************************************************/
876 UtPadNameWithUnderscores (
883 for (i
= 0; (i
< ACPI_NAME_SIZE
); i
++)
887 *PaddedNameSeg
= *NameSeg
;
892 *PaddedNameSeg
= '_';
900 /*******************************************************************************
902 * FUNCTION: UtAttachNameseg
904 * PARAMETERS: Op - Parent parse node
905 * Name - Full ExternalName
907 * RETURN: None; Sets the NameSeg field in parent node
909 * DESCRIPTION: Extract the last nameseg of the ExternalName and store it
910 * in the NameSeg field of the Op.
912 ******************************************************************************/
916 ACPI_PARSE_OBJECT
*Op
,
920 char PaddedNameSeg
[4];
928 /* Look for the last dot in the namepath */
930 NameSeg
= strrchr (Name
, '.');
933 /* Found last dot, we have also found the final nameseg */
936 UtPadNameWithUnderscores (NameSeg
, PaddedNameSeg
);
940 /* No dots in the namepath, there is only a single nameseg. */
941 /* Handle prefixes */
943 while (ACPI_IS_ROOT_PREFIX (*Name
) ||
944 ACPI_IS_PARENT_PREFIX (*Name
))
949 /* Remaining string should be one single nameseg */
951 UtPadNameWithUnderscores (Name
, PaddedNameSeg
);
954 ACPI_MOVE_NAME (Op
->Asl
.NameSeg
, PaddedNameSeg
);
958 /*******************************************************************************
960 * FUNCTION: UtAttachNamepathToOwner
962 * PARAMETERS: Op - Parent parse node
963 * NameOp - Node that contains the name
965 * RETURN: Sets the ExternalName and Namepath in the parent node
967 * DESCRIPTION: Store the name in two forms in the parent node: The original
968 * (external) name, and the internalized name that is used within
969 * the ACPI namespace manager.
971 ******************************************************************************/
974 UtAttachNamepathToOwner (
975 ACPI_PARSE_OBJECT
*Op
,
976 ACPI_PARSE_OBJECT
*NameOp
)
981 /* Full external path */
983 Op
->Asl
.ExternalName
= NameOp
->Asl
.Value
.String
;
985 /* Save the NameOp for possible error reporting later */
987 Op
->Asl
.ParentMethod
= (void *) NameOp
;
989 /* Last nameseg of the path */
991 UtAttachNameseg (Op
, Op
->Asl
.ExternalName
);
993 /* Create internalized path */
995 Status
= UtInternalizeName (NameOp
->Asl
.Value
.String
, &Op
->Asl
.Namepath
);
996 if (ACPI_FAILURE (Status
))
998 /* TBD: abort on no memory */
1003 /*******************************************************************************
1005 * FUNCTION: UtDoConstant
1007 * PARAMETERS: String - Hex/Decimal/Octal
1009 * RETURN: Converted Integer
1011 * DESCRIPTION: Convert a string to an integer, with overflow/error checking.
1013 ******************************************************************************/
1020 UINT64 ConvertedInteger
;
1024 Status
= AcpiUtStrtoul64 (String
, &ConvertedInteger
);
1025 if (ACPI_FAILURE (Status
))
1027 sprintf (ErrBuf
, "While creating 64-bit constant: %s\n",
1028 AcpiFormatException (Status
));
1030 AslCommonError (ASL_ERROR
, ASL_MSG_SYNTAX
, Gbl_CurrentLineNumber
,
1031 Gbl_LogicalLineNumber
, Gbl_CurrentLineOffset
,
1032 Gbl_CurrentColumn
, Gbl_Files
[ASL_FILE_INPUT
].Filename
, ErrBuf
);
1035 return (ConvertedInteger
);