summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/compiler')
-rw-r--r--sys/contrib/dev/acpica/compiler/aslanalyze.c10
-rw-r--r--sys/contrib/dev/acpica/compiler/aslascii.c2
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcodegen.c11
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcompile.c13
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcompiler.h2
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcompiler.l2
-rw-r--r--sys/contrib/dev/acpica/compiler/asldefine.h5
-rw-r--r--sys/contrib/dev/acpica/compiler/aslerror.c6
-rw-r--r--sys/contrib/dev/acpica/compiler/aslfileio.c38
-rw-r--r--sys/contrib/dev/acpica/compiler/aslfiles.c55
-rw-r--r--sys/contrib/dev/acpica/compiler/aslfold.c59
-rw-r--r--sys/contrib/dev/acpica/compiler/aslglobal.h4
-rw-r--r--sys/contrib/dev/acpica/compiler/aslmain.c2
-rw-r--r--sys/contrib/dev/acpica/compiler/aslmapenter.c8
-rw-r--r--sys/contrib/dev/acpica/compiler/aslmapoutput.c4
-rw-r--r--sys/contrib/dev/acpica/compiler/aslmethod.c4
-rw-r--r--sys/contrib/dev/acpica/compiler/aslopcodes.c6
-rw-r--r--sys/contrib/dev/acpica/compiler/asloperands.c6
-rw-r--r--sys/contrib/dev/acpica/compiler/aslopt.c22
-rw-r--r--sys/contrib/dev/acpica/compiler/asloptions.c1
-rw-r--r--sys/contrib/dev/acpica/compiler/aslprintf.c4
-rw-r--r--sys/contrib/dev/acpica/compiler/aslstartup.c2
-rw-r--r--sys/contrib/dev/acpica/compiler/aslsupport.l9
-rw-r--r--sys/contrib/dev/acpica/compiler/asltypes.h54
-rw-r--r--sys/contrib/dev/acpica/compiler/aslutils.c25
-rw-r--r--sys/contrib/dev/acpica/compiler/asluuid.c2
-rw-r--r--sys/contrib/dev/acpica/compiler/dtcompile.c8
-rw-r--r--sys/contrib/dev/acpica/compiler/dtcompiler.h8
-rw-r--r--sys/contrib/dev/acpica/compiler/dtexpress.c2
-rw-r--r--sys/contrib/dev/acpica/compiler/dtfield.c12
-rw-r--r--sys/contrib/dev/acpica/compiler/dtio.c30
-rw-r--r--sys/contrib/dev/acpica/compiler/dtparser.y15
-rw-r--r--sys/contrib/dev/acpica/compiler/dtsubtable.c4
-rw-r--r--sys/contrib/dev/acpica/compiler/dttable.c6
-rw-r--r--sys/contrib/dev/acpica/compiler/dttemplate.c28
-rw-r--r--sys/contrib/dev/acpica/compiler/dttemplate.h11
-rw-r--r--sys/contrib/dev/acpica/compiler/dtutils.c10
-rw-r--r--sys/contrib/dev/acpica/compiler/prparser.y11
-rw-r--r--sys/contrib/dev/acpica/compiler/prscan.c160
-rw-r--r--sys/contrib/dev/acpica/compiler/prutils.c9
40 files changed, 469 insertions, 201 deletions
diff --git a/sys/contrib/dev/acpica/compiler/aslanalyze.c b/sys/contrib/dev/acpica/compiler/aslanalyze.c
index 3c3eee8..e9b6fb2 100644
--- a/sys/contrib/dev/acpica/compiler/aslanalyze.c
+++ b/sys/contrib/dev/acpica/compiler/aslanalyze.c
@@ -67,8 +67,8 @@ AnIsInternalMethod (
ACPI_PARSE_OBJECT *Op)
{
- if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) ||
- (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI")))
+ if ((!strcmp (Op->Asl.ExternalName, "\\_OSI")) ||
+ (!strcmp (Op->Asl.ExternalName, "_OSI")))
{
return (TRUE);
}
@@ -94,8 +94,8 @@ AnGetInternalMethodReturnType (
ACPI_PARSE_OBJECT *Op)
{
- if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) ||
- (!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI")))
+ if ((!strcmp (Op->Asl.ExternalName, "\\_OSI")) ||
+ (!strcmp (Op->Asl.ExternalName, "_OSI")))
{
return (ACPI_BTYPE_STRING);
}
@@ -462,7 +462,7 @@ ApCheckForGpeNameConflict (
/* Verify 3rd/4th chars are a valid hex value */
- GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16);
+ GpeNumber = strtoul (&Name[2], NULL, 16);
if (GpeNumber == ACPI_UINT32_MAX)
{
return;
diff --git a/sys/contrib/dev/acpica/compiler/aslascii.c b/sys/contrib/dev/acpica/compiler/aslascii.c
index 08e4630..1583dc3 100644
--- a/sys/contrib/dev/acpica/compiler/aslascii.c
+++ b/sys/contrib/dev/acpica/compiler/aslascii.c
@@ -226,7 +226,7 @@ FlCheckForAscii (
/* Ensure character is either printable or a "space" char */
- else if (!ACPI_IS_PRINT (Byte) && !ACPI_IS_SPACE (Byte))
+ else if (!isprint (Byte) && !isspace (Byte))
{
if ((BadBytes < 10) && (DisplayErrors))
{
diff --git a/sys/contrib/dev/acpica/compiler/aslcodegen.c b/sys/contrib/dev/acpica/compiler/aslcodegen.c
index 8dd30f3..a01afb7 100644
--- a/sys/contrib/dev/acpica/compiler/aslcodegen.c
+++ b/sys/contrib/dev/acpica/compiler/aslcodegen.c
@@ -110,7 +110,7 @@ CgGenerateAmlOutput (
DbgPrint (ASL_TREE_OUTPUT,
"%*s Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr"
- " Parent Child Next Flags AcTyp Final Col L\n",
+ " Parent Child Next Flags AcTyp Final Col L# EL# LL# ELL#\n",
76, " ");
CgCloseTable ();
@@ -145,7 +145,7 @@ CgAmlWriteWalk (
"Final parse tree used for AML output:\n");
DbgPrint (ASL_TREE_OUTPUT,
"%*s Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr"
- " Parent Child Next Flags AcTyp Final Col L\n",
+ " Parent Child Next Flags AcTyp Final Col L# EL# LL# ELL#\n",
76, " ");
}
@@ -169,7 +169,7 @@ CgAmlWriteWalk (
DbgPrint (ASL_TREE_OUTPUT,
"%08X %04X %04X %01X %04X %04X %04X %04X "
- "%08X %08X %08X %08X %08X %08X %04X %02d %02d\n",
+ "%08X %08X %08X %08X %08X %08X %04X %02d %02d %02d %02d %02d\n",
/* 1 */ (UINT32) Op->Asl.Value.Integer,
/* 2 */ Op->Asl.ParseOpcode,
/* 3 */ Op->Asl.AmlOpcode,
@@ -186,7 +186,10 @@ CgAmlWriteWalk (
/* 14 */ Op->Asl.AcpiBtype,
/* 15 */ Op->Asl.FinalAmlLength,
/* 16 */ Op->Asl.Column,
- /* 17 */ Op->Asl.LineNumber);
+ /* 17 */ Op->Asl.LineNumber,
+ /* 18 */ Op->Asl.EndLine,
+ /* 19 */ Op->Asl.LogicalLineNumber,
+ /* 20 */ Op->Asl.EndLogicalLine);
/* Generate the AML for this node */
diff --git a/sys/contrib/dev/acpica/compiler/aslcompile.c b/sys/contrib/dev/acpica/compiler/aslcompile.c
index 0b0ca7a..9aaac3b 100644
--- a/sys/contrib/dev/acpica/compiler/aslcompile.c
+++ b/sys/contrib/dev/acpica/compiler/aslcompile.c
@@ -103,6 +103,9 @@ CmDoCompile (
/* Preprocessor */
PrDoPreprocess ();
+ Gbl_CurrentLineNumber = 1;
+ Gbl_LogicalLineNumber = 1;
+
if (Gbl_PreprocessOnly)
{
UtEndEvent (Event);
@@ -112,6 +115,7 @@ CmDoCompile (
}
UtEndEvent (Event);
+
/* Build the parse tree */
Event = UtBeginEvent ("Parse source code and build parse tree");
@@ -708,7 +712,7 @@ CmCleanupAndExit (
/* Close all open files */
/*
- * Take care with the preprocessor file (.i), it might be the same
+ * Take care with the preprocessor file (.pre), it might be the same
* as the "input" file, depending on where the compiler has terminated
* or aborted. Prevent attempt to close the same file twice in
* loop below.
@@ -733,10 +737,9 @@ CmCleanupAndExit (
FlDeleteFile (ASL_FILE_AML_OUTPUT);
}
- /* Delete the preprocessor output file (.i) unless -li flag is set */
+ /* Delete the preprocessor temp file unless full debug was specified */
- if (!Gbl_PreprocessorOutputFlag &&
- Gbl_PreprocessFlag)
+ if (Gbl_PreprocessFlag && !Gbl_KeepPreprocessorTempFile)
{
FlDeleteFile (ASL_FILE_PREPROCESSOR);
}
@@ -752,8 +755,6 @@ CmCleanupAndExit (
* Note: Handles are cleared by FlCloseFile above, so we look at the
* filename instead, to determine if the .SRC file was actually
* created.
- *
- * TBD: SourceOutput should be .TMP, then rename if we want to keep it?
*/
if (!Gbl_SourceOutputFlag)
{
diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.h b/sys/contrib/dev/acpica/compiler/aslcompiler.h
index 181b36c..f84f988 100644
--- a/sys/contrib/dev/acpica/compiler/aslcompiler.h
+++ b/sys/contrib/dev/acpica/compiler/aslcompiler.h
@@ -1003,7 +1003,7 @@ UtDoConstant (
char *String);
ACPI_STATUS
-UtStrtoul64 (
+stroul64 (
char *String,
UINT32 Base,
UINT64 *RetInteger);
diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.l b/sys/contrib/dev/acpica/compiler/aslcompiler.l
index 621f5ae..6a3541b 100644
--- a/sys/contrib/dev/acpica/compiler/aslcompiler.l
+++ b/sys/contrib/dev/acpica/compiler/aslcompiler.l
@@ -709,7 +709,7 @@ NamePathTail [.]{NameSeg}
return (PARSEOP_NAMESTRING); }
. { count (1);
- if (ACPI_IS_PRINT (*AslCompilertext))
+ if (isprint ((int) *AslCompilertext))
{
sprintf (MsgBuffer,
"Invalid character (%c), expecting ASL keyword or name",
diff --git a/sys/contrib/dev/acpica/compiler/asldefine.h b/sys/contrib/dev/acpica/compiler/asldefine.h
index 0697276..0b5f614 100644
--- a/sys/contrib/dev/acpica/compiler/asldefine.h
+++ b/sys/contrib/dev/acpica/compiler/asldefine.h
@@ -105,7 +105,8 @@
/* filename suffixes for output files */
-#define FILE_SUFFIX_PREPROCESSOR "i"
+#define FILE_SUFFIX_PREPROC_USER "i "
+#define FILE_SUFFIX_PREPROCESSOR "pre"
#define FILE_SUFFIX_AML_CODE "aml"
#define FILE_SUFFIX_MAP "map"
#define FILE_SUFFIX_LISTING "lst"
@@ -136,6 +137,8 @@
#define ASL_ABORT TRUE
#define ASL_NO_ABORT FALSE
#define ASL_EOF ACPI_UINT32_MAX
+#define ASL_WITHIN_COMMENT (ACPI_UINT32_MAX -1)
+#define ASL_BLANK_LINE (ACPI_UINT32_MAX -1)
/* Listings */
diff --git a/sys/contrib/dev/acpica/compiler/aslerror.c b/sys/contrib/dev/acpica/compiler/aslerror.c
index 9b8928c..870e30b 100644
--- a/sys/contrib/dev/acpica/compiler/aslerror.c
+++ b/sys/contrib/dev/acpica/compiler/aslerror.c
@@ -561,11 +561,11 @@ AslCommonError2 (
/* Keep a copy of the extra message */
- ACPI_STRCPY (MessageBuffer, ExtraMessage);
+ strcpy (MessageBuffer, ExtraMessage);
}
LineBuffer = UtLocalCalloc (strlen (SourceLine) + 1);
- ACPI_STRCPY (LineBuffer, SourceLine);
+ strcpy (LineBuffer, SourceLine);
/* Initialize the error node */
@@ -647,7 +647,7 @@ AslCommonError (
/* Keep a copy of the extra message */
- ACPI_STRCPY (MessageBuffer, ExtraMessage);
+ strcpy (MessageBuffer, ExtraMessage);
}
/* Initialize the error node */
diff --git a/sys/contrib/dev/acpica/compiler/aslfileio.c b/sys/contrib/dev/acpica/compiler/aslfileio.c
index cf726dd..3feb8ea 100644
--- a/sys/contrib/dev/acpica/compiler/aslfileio.c
+++ b/sys/contrib/dev/acpica/compiler/aslfileio.c
@@ -218,6 +218,19 @@ FlWriteFile (
FlFileError (FileId, ASL_MSG_WRITE);
AslAbort ();
}
+
+ if ((FileId == ASL_FILE_PREPROCESSOR) && Gbl_PreprocessorOutputFlag)
+ {
+ /* Duplicate the output to the user preprocessor (.i) file */
+
+ Actual = fwrite ((char *) Buffer, 1, Length,
+ Gbl_Files[ASL_FILE_PREPROCESSOR_USER].Handle);
+ if (Actual != Length)
+ {
+ FlFileError (FileId, ASL_MSG_WRITE);
+ AslAbort ();
+ }
+ }
}
@@ -247,7 +260,6 @@ FlPrintFile (
va_start (Args, Format);
-
Actual = vfprintf (Gbl_Files[FileId].Handle, Format, Args);
va_end (Args);
@@ -256,6 +268,30 @@ FlPrintFile (
FlFileError (FileId, ASL_MSG_WRITE);
AslAbort ();
}
+
+ if ((FileId == ASL_FILE_PREPROCESSOR) && Gbl_PreprocessorOutputFlag)
+ {
+ /*
+ * Duplicate the output to the user preprocessor (.i) file,
+ * except: no #line directives.
+ */
+ if (!strncmp (Format, "#line", 5))
+ {
+ return;
+ }
+
+ va_start (Args, Format);
+ Actual = vfprintf (Gbl_Files[ASL_FILE_PREPROCESSOR_USER].Handle,
+ Format, Args);
+ va_end (Args);
+
+ if (Actual == -1)
+ {
+ FlFileError (FileId, ASL_MSG_WRITE);
+ AslAbort ();
+ }
+ }
+
}
diff --git a/sys/contrib/dev/acpica/compiler/aslfiles.c b/sys/contrib/dev/acpica/compiler/aslfiles.c
index d8c9ed5..37043cb 100644
--- a/sys/contrib/dev/acpica/compiler/aslfiles.c
+++ b/sys/contrib/dev/acpica/compiler/aslfiles.c
@@ -43,6 +43,7 @@
#include <contrib/dev/acpica/compiler/aslcompiler.h>
#include <contrib/dev/acpica/include/acapps.h>
+#include <contrib/dev/acpica/compiler/dtcompiler.h>
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslfiles")
@@ -84,7 +85,6 @@ FlSetLineNumber (
LineNumber, Gbl_LogicalLineNumber);
Gbl_CurrentLineNumber = LineNumber;
- Gbl_LogicalLineNumber = LineNumber;
}
@@ -303,6 +303,7 @@ FlOpenIncludeWithPrefix (
{
FILE *IncludeFile;
char *Pathname;
+ UINT32 OriginalLineNumber;
/* Build the full pathname to the file */
@@ -322,13 +323,20 @@ FlOpenIncludeWithPrefix (
return (NULL);
}
-#ifdef _MUST_HANDLE_COMMENTS
/*
- * Check entire include file for any # preprocessor directives.
+ * Check the entire include file for any # preprocessor directives.
* This is because there may be some confusion between the #include
- * preprocessor directive and the ASL Include statement.
+ * preprocessor directive and the ASL Include statement. A file included
+ * by the ASL include cannot contain preprocessor directives because
+ * the preprocessor has already run by the time the ASL include is
+ * recognized (by the compiler, not the preprocessor.)
+ *
+ * Note: DtGetNextLine strips/ignores comments.
+ * Save current line number since DtGetNextLine modifies it.
*/
- while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, IncludeFile))
+ Gbl_CurrentLineNumber--;
+ OriginalLineNumber = Gbl_CurrentLineNumber;
+ while (DtGetNextLine (IncludeFile, DT_ALLOW_MULTILINE_QUOTES) != ASL_EOF)
{
if (Gbl_CurrentLineBuffer[0] == '#')
{
@@ -336,7 +344,7 @@ FlOpenIncludeWithPrefix (
Op, "use #include instead");
}
}
-#endif
+ Gbl_CurrentLineNumber = OriginalLineNumber;
/* Must seek back to the start of the file */
@@ -579,8 +587,6 @@ FlOpenMiscOutputFiles (
/* Open the debug file as STDERR, text mode */
- /* TBD: hide this behind a FlReopenFile function */
-
Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename;
Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle =
freopen (Filename, "w+t", stderr);
@@ -588,13 +594,15 @@ FlOpenMiscOutputFiles (
if (!Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle)
{
/*
- * A problem with freopen is that on error,
- * we no longer have stderr.
+ * A problem with freopen is that on error, we no longer
+ * have stderr and cannot emit normal error messages.
+ * Emit error to stdout, close files, and exit.
*/
- Gbl_DebugFlag = FALSE;
- memcpy (stderr, stdout, sizeof (FILE));
- FlFileError (ASL_FILE_DEBUG_OUTPUT, ASL_MSG_DEBUG_FILENAME);
- AslAbort ();
+ fprintf (stdout,
+ "\nCould not open debug output file: %s\n\n", Filename);
+
+ CmCleanupAndExit ();
+ exit (1);
}
AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT);
@@ -621,7 +629,7 @@ FlOpenMiscOutputFiles (
AslCompilerFileHeader (ASL_FILE_LISTING_OUTPUT);
}
- /* Create the preprocessor output file if preprocessor enabled */
+ /* Create the preprocessor output temp file if preprocessor enabled */
if (Gbl_PreprocessFlag)
{
@@ -636,6 +644,23 @@ FlOpenMiscOutputFiles (
FlOpenFile (ASL_FILE_PREPROCESSOR, Filename, "w+t");
}
+ /*
+ * Create the "user" preprocessor output file if -li flag set.
+ * Note, this file contains no embedded #line directives.
+ */
+ if (Gbl_PreprocessorOutputFlag)
+ {
+ Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_PREPROC_USER);
+ if (!Filename)
+ {
+ AslCommonError (ASL_ERROR, ASL_MSG_PREPROCESSOR_FILENAME,
+ 0, 0, 0, 0, NULL, NULL);
+ return (AE_ERROR);
+ }
+
+ FlOpenFile (ASL_FILE_PREPROCESSOR_USER, Filename, "w+t");
+ }
+
/* All done for data table compiler */
if (Gbl_FileType == ASL_INPUT_TYPE_ASCII_DATA)
diff --git a/sys/contrib/dev/acpica/compiler/aslfold.c b/sys/contrib/dev/acpica/compiler/aslfold.c
index 26b786d..af7a019 100644
--- a/sys/contrib/dev/acpica/compiler/aslfold.c
+++ b/sys/contrib/dev/acpica/compiler/aslfold.c
@@ -236,6 +236,8 @@ OpcAmlCheckForConstant (
*/
if (WalkState->Opcode == AML_BUFFER_OP)
{
+ DbgPrint (ASL_PARSE_OUTPUT,
+ "\nBuffer+Buffer->Buffer constant reduction is not supported yet");
Status = AE_TYPE;
goto CleanupAndExit;
}
@@ -380,10 +382,12 @@ TrSimpleConstantReduction (
return (Status);
}
+ /* Disconnect any existing children, install new constant */
+
+ Op->Asl.Child = NULL;
TrInstallReducedConstant (Op, ObjDesc);
UtSetParseOpName (Op);
- Op->Asl.Child = NULL;
return (AE_OK);
}
@@ -494,6 +498,10 @@ TrTransformToStoreOp (
goto EvalError;
}
+ /* Truncate any subtree expressions, they have been evaluated */
+
+ Child1->Asl.Child = NULL;
+
/* Folded constant is in ObjDesc, store into Child1 */
TrInstallReducedConstant (Child1, ObjDesc);
@@ -505,11 +513,6 @@ TrTransformToStoreOp (
UtSetParseOpName (Op);
Op->Common.Parent = OriginalParent;
- /* Truncate any subtree expressions, they have been evaluated */
-
- Child1->Asl.Child = NULL;
- Child2->Asl.Child = NULL;
-
/* First child is the folded constant */
/* Second child will be the target */
@@ -547,7 +550,8 @@ TrInstallReducedConstant (
ACPI_PARSE_OBJECT *Op,
ACPI_OPERAND_OBJECT *ObjDesc)
{
- ACPI_PARSE_OBJECT *RootOp;
+ ACPI_PARSE_OBJECT *LengthOp;
+ ACPI_PARSE_OBJECT *DataOp;
TotalFolds++;
@@ -574,17 +578,22 @@ TrInstallReducedConstant (
Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
Op->Common.AmlOpcode = AML_STRING_OP;
- Op->Asl.AmlLength = ACPI_STRLEN (ObjDesc->String.Pointer) + 1;
+ Op->Asl.AmlLength = strlen (ObjDesc->String.Pointer) + 1;
Op->Common.Value.String = ObjDesc->String.Pointer;
DbgPrint (ASL_PARSE_OUTPUT,
"Constant expression reduced to (STRING) %s\n\n",
Op->Common.Value.String);
-
break;
case ACPI_TYPE_BUFFER:
-
+ /*
+ * Create a new parse subtree of the form:
+ *
+ * BUFFER (Buffer AML opcode)
+ * INTEGER (Buffer length in bytes)
+ * RAW_DATA (Buffer byte data)
+ */
Op->Asl.ParseOpcode = PARSEOP_BUFFER;
Op->Common.AmlOpcode = AML_BUFFER_OP;
Op->Asl.CompileFlags = NODE_AML_PACKAGE;
@@ -592,28 +601,24 @@ TrInstallReducedConstant (
/* Child node is the buffer length */
- RootOp = TrAllocateNode (PARSEOP_INTEGER);
+ LengthOp = TrAllocateNode (PARSEOP_INTEGER);
- RootOp->Asl.AmlOpcode = AML_DWORD_OP;
- RootOp->Asl.Value.Integer = ObjDesc->Buffer.Length;
- RootOp->Asl.Parent = Op;
+ LengthOp->Asl.AmlOpcode = AML_DWORD_OP;
+ LengthOp->Asl.Value.Integer = ObjDesc->Buffer.Length;
+ LengthOp->Asl.Parent = Op;
+ (void) OpcSetOptimalIntegerSize (LengthOp);
- (void) OpcSetOptimalIntegerSize (RootOp);
-
- Op->Asl.Child = RootOp;
- Op = RootOp;
- UtSetParseOpName (Op);
+ Op->Asl.Child = LengthOp;
- /* Peer to the child is the raw buffer data */
+ /* Next child is the raw buffer data */
- RootOp = TrAllocateNode (PARSEOP_RAW_DATA);
- RootOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
- RootOp->Asl.AmlLength = ObjDesc->Buffer.Length;
- RootOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer;
- RootOp->Asl.Parent = Op->Asl.Parent;
+ DataOp = TrAllocateNode (PARSEOP_RAW_DATA);
+ DataOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
+ DataOp->Asl.AmlLength = ObjDesc->Buffer.Length;
+ DataOp->Asl.Value.String = (char *) ObjDesc->Buffer.Pointer;
+ DataOp->Asl.Parent = Op;
- Op->Asl.Next = RootOp;
- Op = RootOp;
+ LengthOp->Asl.Next = DataOp;
DbgPrint (ASL_PARSE_OUTPUT,
"Constant expression reduced to (BUFFER) length %X\n\n",
diff --git a/sys/contrib/dev/acpica/compiler/aslglobal.h b/sys/contrib/dev/acpica/compiler/aslglobal.h
index c61b8ff..0696b67 100644
--- a/sys/contrib/dev/acpica/compiler/aslglobal.h
+++ b/sys/contrib/dev/acpica/compiler/aslglobal.h
@@ -73,6 +73,7 @@ ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] =
{NULL, NULL, "Binary Output:", "AML Output"},
{NULL, NULL, "Source Output:", "Source Output"},
{NULL, NULL, "Preprocessor: ", "Preprocessor Output"},
+ {NULL, NULL, "Preprocessor: ", "Preprocessor Temp File"},
{NULL, NULL, "Listing File: ", "Listing Output"},
{NULL, NULL, "Hex Dump: ", "Hex Table Output"},
{NULL, NULL, "Namespace: ", "Namespace Output"},
@@ -123,10 +124,10 @@ ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_CurrentLineBuffer, NUL
ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_LineBufPtr, NULL);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_LineBufferSize, ASL_DEFAULT_LINE_BUFFER_SIZE);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentColumn, 0);
-ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_PreviousLineNumber, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineNumber, 1);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_LogicalLineNumber, 1);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineOffset, 0);
+ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_OriginalInputFileSize, 0);
ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_SyntaxError, 0);
/* Exception reporting */
@@ -146,6 +147,7 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseDefaultAmlFilename,
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_MapfileFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NsOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_PreprocessorOutputFlag, FALSE);
+ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_KeepPreprocessorTempFile, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DebugFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_AsmOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_C_OutputFlag, FALSE);
diff --git a/sys/contrib/dev/acpica/compiler/aslmain.c b/sys/contrib/dev/acpica/compiler/aslmain.c
index 99745ad..611183a 100644
--- a/sys/contrib/dev/acpica/compiler/aslmain.c
+++ b/sys/contrib/dev/acpica/compiler/aslmain.c
@@ -261,7 +261,7 @@ AslSignalHandler (
/* Close all open files */
- Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .i file is same as source file */
+ Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .pre file is same as source file */
for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++)
{
diff --git a/sys/contrib/dev/acpica/compiler/aslmapenter.c b/sys/contrib/dev/acpica/compiler/aslmapenter.c
index 87ad28a..2d2b863 100644
--- a/sys/contrib/dev/acpica/compiler/aslmapenter.c
+++ b/sys/contrib/dev/acpica/compiler/aslmapenter.c
@@ -239,7 +239,7 @@ MpCreateGpioInfo (
/* Sort on source DeviceName first */
while (NextGpio &&
- (ACPI_STRCMP (DeviceName, NextGpio->DeviceName) > 0))
+ (strcmp (DeviceName, NextGpio->DeviceName) > 0))
{
PrevGpio = NextGpio;
NextGpio = NextGpio->Next;
@@ -249,7 +249,7 @@ MpCreateGpioInfo (
while (NextGpio &&
(NextGpio->PinNumber < PinNumber) &&
- !ACPI_STRCMP (DeviceName, NextGpio->DeviceName))
+ !strcmp (DeviceName, NextGpio->DeviceName))
{
PrevGpio = NextGpio;
NextGpio = NextGpio->Next;
@@ -316,7 +316,7 @@ MpCreateSerialInfo (
/* Sort on source DeviceName */
while (NextSerial &&
- (ACPI_STRCMP (DeviceName, NextSerial->DeviceName) > 0))
+ (strcmp (DeviceName, NextSerial->DeviceName) > 0))
{
PrevSerial = NextSerial;
NextSerial = NextSerial->Next;
@@ -326,7 +326,7 @@ MpCreateSerialInfo (
while (NextSerial &&
(NextSerial->Address < Address) &&
- !ACPI_STRCMP (DeviceName, NextSerial->DeviceName))
+ !strcmp (DeviceName, NextSerial->DeviceName))
{
PrevSerial = NextSerial;
NextSerial = NextSerial->Next;
diff --git a/sys/contrib/dev/acpica/compiler/aslmapoutput.c b/sys/contrib/dev/acpica/compiler/aslmapoutput.c
index 622b1bd..1cf1e53 100644
--- a/sys/contrib/dev/acpica/compiler/aslmapoutput.c
+++ b/sys/contrib/dev/acpica/compiler/aslmapoutput.c
@@ -207,7 +207,7 @@ MpEmitGpioInfo (
/* Print header info for the controller itself */
if (!PrevDeviceName ||
- ACPI_STRCMP (PrevDeviceName, Info->DeviceName))
+ strcmp (PrevDeviceName, Info->DeviceName))
{
FlPrintFile (ASL_FILE_MAP_OUTPUT,
"\n\nGPIO Controller: %-8s %-28s",
@@ -360,7 +360,7 @@ MpEmitSerialInfo (
/* Print header info for the controller itself */
if (!PrevDeviceName ||
- ACPI_STRCMP (PrevDeviceName, Info->DeviceName))
+ strcmp (PrevDeviceName, Info->DeviceName))
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n%s Controller: ",
Type);
diff --git a/sys/contrib/dev/acpica/compiler/aslmethod.c b/sys/contrib/dev/acpica/compiler/aslmethod.c
index fa9216e..bee488f 100644
--- a/sys/contrib/dev/acpica/compiler/aslmethod.c
+++ b/sys/contrib/dev/acpica/compiler/aslmethod.c
@@ -430,7 +430,7 @@ MtMethodAnalysisWalkBegin (
/* Special typechecking for _HID */
- if (!ACPI_STRCMP (METHOD_NAME__HID, Op->Asl.NameSeg))
+ if (!strcmp (METHOD_NAME__HID, Op->Asl.NameSeg))
{
Next = Op->Asl.Child->Asl.Next;
AnCheckId (Next, ASL_TYPE_HID);
@@ -438,7 +438,7 @@ MtMethodAnalysisWalkBegin (
/* Special typechecking for _CID */
- else if (!ACPI_STRCMP (METHOD_NAME__CID, Op->Asl.NameSeg))
+ else if (!strcmp (METHOD_NAME__CID, Op->Asl.NameSeg))
{
Next = Op->Asl.Child->Asl.Next;
diff --git a/sys/contrib/dev/acpica/compiler/aslopcodes.c b/sys/contrib/dev/acpica/compiler/aslopcodes.c
index d4dbbe3..43628f9 100644
--- a/sys/contrib/dev/acpica/compiler/aslopcodes.c
+++ b/sys/contrib/dev/acpica/compiler/aslopcodes.c
@@ -636,7 +636,7 @@ OpcDoEisaId (
* The EISAID string must be exactly 7 characters and of the form
* "UUUXXXX" -- 3 uppercase letters and 4 hex digits (e.g., "PNP0001")
*/
- if (ACPI_STRLEN (InString) != 7)
+ if (strlen (InString) != 7)
{
Status = AE_BAD_PARAMETER;
}
@@ -855,7 +855,7 @@ OpcFindName (
for (i = 0, Str = List[0]; Str; i++, Str = List[i])
{
- if (!(ACPI_STRNCMP (Str, Name, ACPI_STRLEN (Name))))
+ if (!(strncmp (Str, Name, strlen (Name))))
{
*Index = i;
return (TRUE);
@@ -907,7 +907,7 @@ OpcDoPld (
return;
}
- ACPI_MEMSET (&PldInfo, 0, sizeof (ACPI_PLD_INFO));
+ memset (&PldInfo, 0, sizeof (ACPI_PLD_INFO));
Node = Op->Asl.Child;
while (Node)
diff --git a/sys/contrib/dev/acpica/compiler/asloperands.c b/sys/contrib/dev/acpica/compiler/asloperands.c
index b2972d4..df63357 100644
--- a/sys/contrib/dev/acpica/compiler/asloperands.c
+++ b/sys/contrib/dev/acpica/compiler/asloperands.c
@@ -932,7 +932,7 @@ OpnDoDefinitionBlock (
if (Child->Asl.Value.String)
{
Gbl_TableSignature = Child->Asl.Value.String;
- if (ACPI_STRLEN (Gbl_TableSignature) != 4)
+ if (strlen (Gbl_TableSignature) != 4)
{
AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
"Length not exactly 4");
@@ -967,9 +967,9 @@ OpnDoDefinitionBlock (
Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
if (Child->Asl.Value.String)
{
- Length = ACPI_STRLEN (Child->Asl.Value.String);
+ Length = strlen (Child->Asl.Value.String);
Gbl_TableId = UtStringCacheCalloc (Length + 1);
- ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String);
+ strcpy (Gbl_TableId, Child->Asl.Value.String);
/*
* Convert anything non-alphanumeric to an underscore. This
diff --git a/sys/contrib/dev/acpica/compiler/aslopt.c b/sys/contrib/dev/acpica/compiler/aslopt.c
index 1079f9c..a65a25e 100644
--- a/sys/contrib/dev/acpica/compiler/aslopt.c
+++ b/sys/contrib/dev/acpica/compiler/aslopt.c
@@ -168,9 +168,9 @@ OptSearchToRoot (
/* We must allocate a new string for the name (TargetPath gets deleted) */
*NewPath = UtStringCacheCalloc (ACPI_NAME_SIZE + 1);
- ACPI_STRCPY (*NewPath, Path);
+ strcpy (*NewPath, Path);
- if (ACPI_STRNCMP (*NewPath, "_T_", 3))
+ if (strncmp (*NewPath, "_T_", 3))
{
AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION, Op,
*NewPath);
@@ -341,7 +341,7 @@ OptBuildShortestPath (
Index = TargetPath->Length;
}
- ACPI_STRCPY (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]);
+ strcpy (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal));
/*
@@ -358,11 +358,11 @@ OptBuildShortestPath (
return (Status);
}
- if (ACPI_STRLEN (NewPath) >= AmlNameStringLength)
+ if (strlen (NewPath) >= AmlNameStringLength)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
" NOT SHORTER (New %u old %u)",
- (UINT32) ACPI_STRLEN (NewPath), (UINT32) AmlNameStringLength));
+ (UINT32) strlen (NewPath), (UINT32) AmlNameStringLength));
ACPI_FREE (NewPathExternal);
return (AE_NOT_FOUND);
}
@@ -597,7 +597,7 @@ OptOptimizeNamePath (
* The original path must be longer than one NameSeg (4 chars) for there
* to be any possibility that it can be optimized to a shorter string
*/
- AmlNameStringLength = ACPI_STRLEN (AmlNameString);
+ AmlNameStringLength = strlen (AmlNameString);
if (AmlNameStringLength <= ACPI_NAME_SIZE)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
@@ -745,7 +745,7 @@ OptOptimizeNamePath (
*/
if (ACPI_SUCCESS (Status))
{
- HowMuchShorter = (AmlNameStringLength - ACPI_STRLEN (NewPath));
+ HowMuchShorter = (AmlNameStringLength - strlen (NewPath));
OptTotal += HowMuchShorter;
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
@@ -761,12 +761,12 @@ OptOptimizeNamePath (
* (alias name) is the second operand
*/
Op->Asl.Child->Asl.Next->Asl.Value.String = NewPath;
- Op->Asl.Child->Asl.Next->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ Op->Asl.Child->Asl.Next->Asl.AmlLength = strlen (NewPath);
}
else
{
Op->Asl.Child->Asl.Value.String = NewPath;
- Op->Asl.Child->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ Op->Asl.Child->Asl.AmlLength = strlen (NewPath);
}
}
else if (Flags & AML_CREATE)
@@ -781,14 +781,14 @@ OptOptimizeNamePath (
/* Update the parse node with the new NamePath */
NextOp->Asl.Value.String = NewPath;
- NextOp->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ NextOp->Asl.AmlLength = strlen (NewPath);
}
else
{
/* Update the parse node with the new NamePath */
Op->Asl.Value.String = NewPath;
- Op->Asl.AmlLength = ACPI_STRLEN (NewPath);
+ Op->Asl.AmlLength = strlen (NewPath);
}
}
else
diff --git a/sys/contrib/dev/acpica/compiler/asloptions.c b/sys/contrib/dev/acpica/compiler/asloptions.c
index cc20bcd..4cff853 100644
--- a/sys/contrib/dev/acpica/compiler/asloptions.c
+++ b/sys/contrib/dev/acpica/compiler/asloptions.c
@@ -194,6 +194,7 @@ AslDoOptions (
DtParserdebug = 1;
PrParserdebug = 1;
Gbl_DebugFlag = TRUE;
+ Gbl_KeepPreprocessorTempFile = TRUE;
break;
case 'p': /* Prune ASL parse tree */
diff --git a/sys/contrib/dev/acpica/compiler/aslprintf.c b/sys/contrib/dev/acpica/compiler/aslprintf.c
index c8647ea..1d8d4d7 100644
--- a/sys/contrib/dev/acpica/compiler/aslprintf.c
+++ b/sys/contrib/dev/acpica/compiler/aslprintf.c
@@ -186,7 +186,7 @@ OpcParsePrintf (
if (StringToProcess)
{
NewString = UtStringCacheCalloc (StringLength + 1);
- ACPI_STRNCPY (NewString, StartPosition, StringLength);
+ strncpy (NewString, StartPosition, StringLength);
NewOp = TrAllocateNode (PARSEOP_STRING_LITERAL);
NewOp->Asl.Value.String = NewString;
@@ -275,7 +275,7 @@ OpcParsePrintf (
if (StringToProcess)
{
NewString = UtStringCacheCalloc (StringLength + 1);
- ACPI_STRNCPY (NewString, StartPosition, StringLength);
+ strncpy (NewString, StartPosition, StringLength);
NewOp = TrAllocateNode (PARSEOP_STRING_LITERAL);
NewOp->Asl.Value.String = NewString;
diff --git a/sys/contrib/dev/acpica/compiler/aslstartup.c b/sys/contrib/dev/acpica/compiler/aslstartup.c
index 85e2f88..211658b 100644
--- a/sys/contrib/dev/acpica/compiler/aslstartup.c
+++ b/sys/contrib/dev/acpica/compiler/aslstartup.c
@@ -359,6 +359,8 @@ AslDoOneFile (
return (AE_ERROR);
}
+ Gbl_OriginalInputFileSize = FlGetFileSize (ASL_FILE_INPUT);
+
/* Determine input file type */
Gbl_FileType = AslDetectSourceFileType (&Gbl_Files[ASL_FILE_INPUT]);
diff --git a/sys/contrib/dev/acpica/compiler/aslsupport.l b/sys/contrib/dev/acpica/compiler/aslsupport.l
index b3149cf..0016626 100644
--- a/sys/contrib/dev/acpica/compiler/aslsupport.l
+++ b/sys/contrib/dev/acpica/compiler/aslsupport.l
@@ -113,6 +113,7 @@ AslDoLineDirective (
char *Filename;
UINT32 i;
+ Gbl_HasIncludeFiles = TRUE;
/* Eat the entire line that contains the #line directive */
@@ -713,7 +714,7 @@ DoCharacter:
* string and resume processing of the next character
*/
ConvertBuffer[i] = 0;
- Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 8);
+ Digit = (UINT8) strtoul (ConvertBuffer, NULL, 8);
/* Check for NULL or non-ascii character (ignore if so) */
@@ -749,7 +750,7 @@ DoCharacter:
/* Up to two hex digits allowed */
- if (!ACPI_IS_XDIGIT (StringChar) ||
+ if (!isxdigit (StringChar) ||
(i > 1))
{
/*
@@ -757,7 +758,7 @@ DoCharacter:
* string and resume processing of the next character
*/
ConvertBuffer[i] = 0;
- Digit = (UINT8) ACPI_STRTOUL (ConvertBuffer, NULL, 16);
+ Digit = (UINT8) strtoul (ConvertBuffer, NULL, 16);
/* Check for NULL or non-ascii character (ignore if so) */
@@ -830,7 +831,7 @@ CompletedString:
return (FALSE);
}
- ACPI_STRCPY (CleanString, MsgBuffer);
+ strcpy (CleanString, MsgBuffer);
AslCompilerlval.s = CleanString;
return (TRUE);
diff --git a/sys/contrib/dev/acpica/compiler/asltypes.h b/sys/contrib/dev/acpica/compiler/asltypes.h
index 4bd24da..343c364 100644
--- a/sys/contrib/dev/acpica/compiler/asltypes.h
+++ b/sys/contrib/dev/acpica/compiler/asltypes.h
@@ -148,32 +148,56 @@ typedef struct asl_file_status
/*
* File types. Note: Any changes to this table must also be reflected
* in the Gbl_Files array.
+ *
+ * Corresponding filename suffixes are in comments
+ *
+ * NOTE: Don't move the first 4 file types
*/
typedef enum
{
ASL_FILE_STDOUT = 0,
ASL_FILE_STDERR,
- ASL_FILE_INPUT,
- ASL_FILE_AML_OUTPUT, /* Don't move these first 4 file types */
- ASL_FILE_SOURCE_OUTPUT,
- ASL_FILE_PREPROCESSOR,
- ASL_FILE_LISTING_OUTPUT,
- ASL_FILE_HEX_OUTPUT,
- ASL_FILE_NAMESPACE_OUTPUT,
- ASL_FILE_DEBUG_OUTPUT,
- ASL_FILE_ASM_SOURCE_OUTPUT,
- ASL_FILE_C_SOURCE_OUTPUT,
- ASL_FILE_ASM_INCLUDE_OUTPUT,
- ASL_FILE_C_INCLUDE_OUTPUT,
- ASL_FILE_C_OFFSET_OUTPUT,
- ASL_FILE_MAP_OUTPUT
+ ASL_FILE_INPUT, /* .asl */
+ ASL_FILE_AML_OUTPUT, /* .aml */
+ ASL_FILE_SOURCE_OUTPUT, /* .src */
+ ASL_FILE_PREPROCESSOR, /* .pre */
+ ASL_FILE_PREPROCESSOR_USER, /* .i */
+ ASL_FILE_LISTING_OUTPUT, /* .lst */
+ ASL_FILE_HEX_OUTPUT, /* .hex */
+ ASL_FILE_NAMESPACE_OUTPUT, /* .nsp */
+ ASL_FILE_DEBUG_OUTPUT, /* .txt */
+ ASL_FILE_ASM_SOURCE_OUTPUT, /* .asm */
+ ASL_FILE_C_SOURCE_OUTPUT, /* .c */
+ ASL_FILE_ASM_INCLUDE_OUTPUT,/* .inc */
+ ASL_FILE_C_INCLUDE_OUTPUT, /* .h */
+ ASL_FILE_C_OFFSET_OUTPUT, /* offset.h */
+ ASL_FILE_MAP_OUTPUT /* .map */
} ASL_FILE_TYPES;
-#define ASL_MAX_FILE_TYPE 15
+#define ASL_MAX_FILE_TYPE 16
#define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1)
+/* filename suffixes for output files */
+
+#define FILE_SUFFIX_PREPROC_USER "i "
+#define FILE_SUFFIX_PREPROCESSOR "pre"
+#define FILE_SUFFIX_AML_CODE "aml"
+#define FILE_SUFFIX_MAP "map"
+#define FILE_SUFFIX_LISTING "lst"
+#define FILE_SUFFIX_HEX_DUMP "hex"
+#define FILE_SUFFIX_DEBUG "txt"
+#define FILE_SUFFIX_SOURCE "src"
+#define FILE_SUFFIX_NAMESPACE "nsp"
+#define FILE_SUFFIX_ASM_SOURCE "asm"
+#define FILE_SUFFIX_C_SOURCE "c"
+#define FILE_SUFFIX_DISASSEMBLY "dsl"
+#define FILE_SUFFIX_ASM_INCLUDE "inc"
+#define FILE_SUFFIX_C_INCLUDE "h"
+#define FILE_SUFFIX_ASL_CODE "asl"
+#define FILE_SUFFIX_C_OFFSET "offset.h"
+
/* Cache block structure for ParseOps and Strings */
diff --git a/sys/contrib/dev/acpica/compiler/aslutils.c b/sys/contrib/dev/acpica/compiler/aslutils.c
index dadd6b1..e0511a4 100644
--- a/sys/contrib/dev/acpica/compiler/aslutils.c
+++ b/sys/contrib/dev/acpica/compiler/aslutils.c
@@ -441,17 +441,20 @@ UtDisplaySummary (
"%-14s %s - %u lines, %u bytes, %u keywords\n",
"ASL Input:",
Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_CurrentLineNumber,
- Gbl_InputByteCount, TotalKeywords);
+ Gbl_OriginalInputFileSize, TotalKeywords);
/* AML summary */
if ((Gbl_ExceptionCount[ASL_ERROR] == 0) || (Gbl_IgnoreErrors))
{
- FlPrintFile (FileId,
- "%-14s %s - %u bytes, %u named objects, %u executable opcodes\n",
- "AML Output:",
- Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength,
- TotalNamedObjects, TotalExecutableOpcodes);
+ if (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle)
+ {
+ FlPrintFile (FileId,
+ "%-14s %s - %u bytes, %u named objects, %u executable opcodes\n",
+ "AML Output:",
+ Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength,
+ TotalNamedObjects, TotalExecutableOpcodes);
+ }
}
}
@@ -471,9 +474,9 @@ UtDisplaySummary (
continue;
}
- /* .I is a temp file unless specifically requested */
+ /* .PRE is the preprocessor intermediate file */
- if ((i == ASL_FILE_PREPROCESSOR) && (!Gbl_PreprocessorOutputFlag))
+ if ((i == ASL_FILE_PREPROCESSOR) && (!Gbl_KeepPreprocessorTempFile))
{
continue;
}
@@ -932,7 +935,7 @@ UtDoConstant (
char ErrBuf[64];
- Status = UtStrtoul64 (String, 0, &Converted);
+ Status = stroul64 (String, 0, &Converted);
if (ACPI_FAILURE (Status))
{
sprintf (ErrBuf, "%s %s\n", "Conversion error:",
@@ -948,7 +951,7 @@ UtDoConstant (
/*******************************************************************************
*
- * FUNCTION: UtStrtoul64
+ * FUNCTION: stroul64
*
* PARAMETERS: String - Null terminated string
* Terminater - Where a pointer to the terminating byte
@@ -962,7 +965,7 @@ UtDoConstant (
******************************************************************************/
ACPI_STATUS
-UtStrtoul64 (
+stroul64 (
char *String,
UINT32 Base,
UINT64 *RetInteger)
diff --git a/sys/contrib/dev/acpica/compiler/asluuid.c b/sys/contrib/dev/acpica/compiler/asluuid.c
index 4e345e9..850ac6a 100644
--- a/sys/contrib/dev/acpica/compiler/asluuid.c
+++ b/sys/contrib/dev/acpica/compiler/asluuid.c
@@ -69,7 +69,7 @@ AuValidateUuid (
UINT32 i;
- if (!InString || (ACPI_STRLEN (InString) != UUID_STRING_LENGTH))
+ if (!InString || (strlen (InString) != UUID_STRING_LENGTH))
{
return (AE_BAD_PARAMETER);
}
diff --git a/sys/contrib/dev/acpica/compiler/dtcompile.c b/sys/contrib/dev/acpica/compiler/dtcompile.c
index 20da143..506c4cd 100644
--- a/sys/contrib/dev/acpica/compiler/dtcompile.c
+++ b/sys/contrib/dev/acpica/compiler/dtcompile.c
@@ -302,7 +302,7 @@ DtCompileDataTable (
return (AE_ERROR);
}
- Gbl_Signature = UtStringCacheCalloc (ACPI_STRLEN (Signature) + 1);
+ Gbl_Signature = UtStringCacheCalloc (strlen (Signature) + 1);
strcpy (Gbl_Signature, Signature);
/*
@@ -358,6 +358,8 @@ DtCompileDataTable (
TableData = AcpiDmGetTableData (Signature);
if (!TableData || Gbl_CompileGeneric)
{
+ /* Unknown table signature and/or force generic compile */
+
DtCompileGeneric ((void **) FieldList, NULL, NULL);
goto FinishHeader;
}
@@ -454,7 +456,7 @@ DtCompileTable (
/* Ignore optional subtable if name does not match */
if ((Info->Flags & DT_OPTIONAL) &&
- ACPI_STRCMP ((*Field)->Name, Info->Name))
+ strcmp ((*Field)->Name, Info->Name))
{
*RetSubtable = NULL;
return (AE_OK);
@@ -591,7 +593,7 @@ DtCompileTable (
DtSetSubtableLength (InlineSubtable);
- ACPI_MEMCPY (Buffer, InlineSubtable->Buffer, FieldLength);
+ memcpy (Buffer, InlineSubtable->Buffer, FieldLength);
LocalField = *Field;
break;
diff --git a/sys/contrib/dev/acpica/compiler/dtcompiler.h b/sys/contrib/dev/acpica/compiler/dtcompiler.h
index 201b2db..daff7aa 100644
--- a/sys/contrib/dev/acpica/compiler/dtcompiler.h
+++ b/sys/contrib/dev/acpica/compiler/dtcompiler.h
@@ -181,7 +181,13 @@ DtCompilePadding (
UINT32
DtGetNextLine (
- FILE *Handle);
+ FILE *Handle,
+ UINT32 Flags);
+
+/* Flags for DtGetNextLine */
+
+#define DT_ALLOW_MULTILINE_QUOTES 0x01
+
DT_FIELD *
DtScanFile (
diff --git a/sys/contrib/dev/acpica/compiler/dtexpress.c b/sys/contrib/dev/acpica/compiler/dtexpress.c
index 90054c9..4316b79 100644
--- a/sys/contrib/dev/acpica/compiler/dtexpress.c
+++ b/sys/contrib/dev/acpica/compiler/dtexpress.c
@@ -413,7 +413,7 @@ DtLookupLabel (
LabelField = Gbl_LabelList;
while (LabelField)
{
- if (!ACPI_STRCMP (Name, LabelField->Value))
+ if (!strcmp (Name, LabelField->Value))
{
return (LabelField);
}
diff --git a/sys/contrib/dev/acpica/compiler/dtfield.c b/sys/contrib/dev/acpica/compiler/dtfield.c
index 3b191ab..621636c 100644
--- a/sys/contrib/dev/acpica/compiler/dtfield.c
+++ b/sys/contrib/dev/acpica/compiler/dtfield.c
@@ -166,7 +166,7 @@ DtCompileString (
UINT32 Length;
- Length = ACPI_STRLEN (Field->Value);
+ Length = strlen (Field->Value);
/* Check if the string is too long for the field */
@@ -177,7 +177,7 @@ DtCompileString (
Length = ByteLength;
}
- ACPI_MEMCPY (Buffer, Field->Value, Length);
+ memcpy (Buffer, Field->Value, Length);
}
@@ -212,7 +212,7 @@ DtCompileUnicode (
AsciiString = Field->Value;
UnicodeString = (UINT16 *) Buffer;
- Count = ACPI_STRLEN (AsciiString) + 1;
+ Count = strlen (AsciiString) + 1;
/* Convert to Unicode string (including null terminator) */
@@ -318,7 +318,7 @@ DtCompileInteger (
/* TBD: Should use a flag rather than compare "Reserved" */
- if (!ACPI_STRCMP (Field->Name, "Reserved"))
+ if (!strcmp (Field->Name, "Reserved"))
{
if (Flags & DT_NON_ZERO)
{
@@ -359,7 +359,7 @@ DtCompileInteger (
DtError (ASL_ERROR, ASL_MSG_INTEGER_SIZE, Field, MsgBuffer);
}
- ACPI_MEMCPY (Buffer, &Value, ByteLength);
+ memcpy (Buffer, &Value, ByteLength);
return;
}
@@ -391,7 +391,7 @@ DtNormalizeBuffer (
char c;
- NewBuffer = UtLocalCalloc (ACPI_STRLEN (Buffer) + 1);
+ NewBuffer = UtLocalCalloc (strlen (Buffer) + 1);
TmpBuffer = NewBuffer;
while ((c = *Buffer++))
diff --git a/sys/contrib/dev/acpica/compiler/dtio.c b/sys/contrib/dev/acpica/compiler/dtio.c
index 4b05bd0..fed9925 100644
--- a/sys/contrib/dev/acpica/compiler/dtio.c
+++ b/sys/contrib/dev/acpica/compiler/dtio.c
@@ -129,7 +129,7 @@ DtTrim (
/* Skip lines that start with a space */
- if (!ACPI_STRCMP (String, " "))
+ if (!strcmp (String, " "))
{
ReturnString = UtStringCacheCalloc (1);
return (ReturnString);
@@ -138,7 +138,7 @@ DtTrim (
/* Setup pointers to start and end of input string */
Start = String;
- End = String + ACPI_STRLEN (String) - 1;
+ End = String + strlen (String) - 1;
/* Find first non-whitespace character */
@@ -180,9 +180,9 @@ DtTrim (
Length = ACPI_PTR_DIFF (End, Start) + 1;
ReturnString = UtStringCacheCalloc (Length + 1);
- if (ACPI_STRLEN (Start))
+ if (strlen (Start))
{
- ACPI_STRNCPY (ReturnString, Start, Length);
+ strncpy (ReturnString, Start, Length);
}
ReturnString[Length] = 0;
@@ -313,7 +313,7 @@ DtParseLine (
Length = ACPI_PTR_DIFF (End, Start);
TmpName = UtLocalCalloc (Length + 1);
- ACPI_STRNCPY (TmpName, Start, Length);
+ strncpy (TmpName, Start, Length);
Name = DtTrim (TmpName);
ACPI_FREE (TmpName);
@@ -360,7 +360,7 @@ DtParseLine (
Length = ACPI_PTR_DIFF (End, Start);
TmpValue = UtLocalCalloc (Length + 1);
- ACPI_STRNCPY (TmpValue, Start, Length);
+ strncpy (TmpValue, Start, Length);
Value = DtTrim (TmpValue);
ACPI_FREE (TmpValue);
@@ -406,7 +406,8 @@ DtParseLine (
UINT32
DtGetNextLine (
- FILE *Handle)
+ FILE *Handle,
+ UINT32 Flags)
{
BOOLEAN LineNotAllBlanks = FALSE;
UINT32 State = DT_NORMAL_TEXT;
@@ -415,7 +416,7 @@ DtGetNextLine (
int c;
- ACPI_MEMSET (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize);
+ memset (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize);
for (i = 0; ;)
{
/*
@@ -550,9 +551,12 @@ DtGetNextLine (
case '\n':
- AcpiOsPrintf ("ERROR at line %u: Unterminated quoted string\n",
- Gbl_CurrentLineNumber++);
- State = DT_NORMAL_TEXT;
+ if (!(Flags & DT_ALLOW_MULTILINE_QUOTES))
+ {
+ AcpiOsPrintf ("ERROR at line %u: Unterminated quoted string\n",
+ Gbl_CurrentLineNumber++);
+ State = DT_NORMAL_TEXT;
+ }
break;
default: /* Get next character */
@@ -746,7 +750,7 @@ DtScanFile (
/* Scan line-by-line */
- while ((Offset = DtGetNextLine (Handle)) != ASL_EOF)
+ while ((Offset = DtGetNextLine (Handle, 0)) != ASL_EOF)
{
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Line %2.2u/%4.4X - %s",
Gbl_CurrentLineNumber, Offset, Gbl_CurrentLineBuffer));
@@ -897,7 +901,7 @@ DtDumpBuffer (
}
BufChar = Buffer[(ACPI_SIZE) i + j];
- if (ACPI_IS_PRINT (BufChar))
+ if (isprint (BufChar))
{
FlPrintFile (FileId, "%c", BufChar);
}
diff --git a/sys/contrib/dev/acpica/compiler/dtparser.y b/sys/contrib/dev/acpica/compiler/dtparser.y
index 0271d78..9d6f1e2 100644
--- a/sys/contrib/dev/acpica/compiler/dtparser.y
+++ b/sys/contrib/dev/acpica/compiler/dtparser.y
@@ -48,6 +48,13 @@
#define _COMPONENT DT_COMPILER
ACPI_MODULE_NAME ("dtparser")
+void * AslLocalAllocate (unsigned int Size);
+
+/* Bison/yacc configuration */
+
+#undef alloca
+#define alloca AslLocalAllocate
+
int DtParserlex (void);
int DtParserparse (void);
void DtParsererror (char const *msg);
@@ -162,15 +169,15 @@ Expression
/* Default base for a non-prefixed integer is 16 */
- | EXPOP_NUMBER { UtStrtoul64 (DtParsertext, 16, &$$);}
+ | EXPOP_NUMBER { stroul64 (DtParsertext, 16, &$$);}
/* Standard hex number (0x1234) */
- | EXPOP_HEX_NUMBER { UtStrtoul64 (DtParsertext, 16, &$$);}
+ | EXPOP_HEX_NUMBER { stroul64 (DtParsertext, 16, &$$);}
- /* TBD: Decimal number with prefix (0d1234) - Not supported by UtStrtoul64 at this time */
+ /* TBD: Decimal number with prefix (0d1234) - Not supported by stroul64 at this time */
- | EXPOP_DECIMAL_NUMBER { UtStrtoul64 (DtParsertext, 10, &$$);}
+ | EXPOP_DECIMAL_NUMBER { stroul64 (DtParsertext, 10, &$$);}
;
%%
diff --git a/sys/contrib/dev/acpica/compiler/dtsubtable.c b/sys/contrib/dev/acpica/compiler/dtsubtable.c
index 1152656..8cb5253 100644
--- a/sys/contrib/dev/acpica/compiler/dtsubtable.c
+++ b/sys/contrib/dev/acpica/compiler/dtsubtable.c
@@ -80,7 +80,7 @@ DtCreateSubtable (
String = UtStringCacheCalloc (Length);
Subtable->Buffer = ACPI_CAST_PTR (UINT8, String);
- ACPI_MEMCPY (Subtable->Buffer, Buffer, Length);
+ memcpy (Subtable->Buffer, Buffer, Length);
Subtable->Length = Length;
Subtable->TotalLength = Length;
@@ -379,6 +379,6 @@ DtSetSubtableLength (
return;
}
- ACPI_MEMCPY (Subtable->LengthField, &Subtable->TotalLength,
+ memcpy (Subtable->LengthField, &Subtable->TotalLength,
Subtable->SizeOfLengthField);
}
diff --git a/sys/contrib/dev/acpica/compiler/dttable.c b/sys/contrib/dev/acpica/compiler/dttable.c
index bae80ad..1c32fe0 100644
--- a/sys/contrib/dev/acpica/compiler/dttable.c
+++ b/sys/contrib/dev/acpica/compiler/dttable.c
@@ -1824,7 +1824,7 @@ DtCompileIvrs (
if (IvrsHeader->Type == ACPI_IVRS_TYPE_HARDWARE)
{
while (*PFieldList &&
- !ACPI_STRCMP ((*PFieldList)->Name, "Entry Type"))
+ !strcmp ((*PFieldList)->Name, "Entry Type"))
{
SubtableStart = *PFieldList;
DtCompileInteger (&EntryType, *PFieldList, 1, 0);
@@ -3403,13 +3403,13 @@ DtCompileGeneric (
/* Now we can actually compile the parse tree */
- if (*Length)
+ if (Length && *Length)
{
*Length = 0;
}
while (*PFieldList)
{
- if (Name && !ACPI_STRCMP ((*PFieldList)->Name, Name))
+ if (Name && !strcmp ((*PFieldList)->Name, Name))
{
break;
}
diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.c b/sys/contrib/dev/acpica/compiler/dttemplate.c
index 90b6b17..07e930f 100644
--- a/sys/contrib/dev/acpica/compiler/dttemplate.c
+++ b/sys/contrib/dev/acpica/compiler/dttemplate.c
@@ -85,6 +85,7 @@ AcpiUtIsSpecialTable (
{
if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT) ||
+ ACPI_COMPARE_NAME (Signature, ACPI_SIG_OSDT) ||
ACPI_COMPARE_NAME (Signature, ACPI_SIG_SSDT) ||
ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS) ||
ACPI_COMPARE_NAME (Signature, ACPI_RSDP_NAME))
@@ -127,8 +128,8 @@ DtCreateTemplates (
}
AcpiUtStrupr (Signature);
- if (!ACPI_STRCMP (Signature, "ALL") ||
- !ACPI_STRCMP (Signature, "*"))
+ if (!strcmp (Signature, "ALL") ||
+ !strcmp (Signature, "*"))
{
/* Create all available/known templates */
@@ -327,7 +328,7 @@ DtCreateOneTemplate (
AcpiOsPrintf ("/*\n");
AcpiOsPrintf (ACPI_COMMON_HEADER ("iASL Compiler/Disassembler", " * "));
- AcpiOsPrintf (" * Template for [%4.4s] ACPI Table\n",
+ AcpiOsPrintf (" * Template for [%4.4s] ACPI Table",
Signature);
/* Dump the actual ACPI table */
@@ -336,6 +337,8 @@ DtCreateOneTemplate (
{
/* Normal case, tables that appear in AcpiDmTableData */
+ AcpiOsPrintf (" (static data table)\n");
+
if (Gbl_VerboseTemplates)
{
AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength]"
@@ -344,7 +347,7 @@ DtCreateOneTemplate (
else
{
AcpiOsPrintf (" * Format: [ByteLength]"
- " FieldName : HexFieldValue\n */\n\n");
+ " FieldName : HexFieldValue\n */\n");
}
AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER,
@@ -352,9 +355,11 @@ DtCreateOneTemplate (
}
else
{
- /* Special ACPI tables - DSDT, SSDT, FADT, RSDP */
+ /* Special ACPI tables - DSDT, SSDT, OSDT, FADT, RSDP */
+
+ AcpiOsPrintf (" (AML byte code table)\n");
- AcpiOsPrintf (" */\n\n");
+ AcpiOsPrintf (" */\n");
if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT))
{
Actual = fwrite (TemplateDsdt, 1, sizeof (TemplateDsdt) -1, File);
@@ -377,6 +382,17 @@ DtCreateOneTemplate (
goto Cleanup;
}
}
+ else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_OSDT))
+ {
+ Actual = fwrite (TemplateOsdt, 1, sizeof (TemplateOsdt) -1, File);
+ if (Actual != sizeof (TemplateOsdt) -1)
+ {
+ fprintf (stderr,
+ "Could not write to output file %s\n", DisasmFilename);
+ Status = AE_ERROR;
+ goto Cleanup;
+ }
+ }
else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) /* FADT */
{
AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER,
diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.h b/sys/contrib/dev/acpica/compiler/dttemplate.h
index 1b27b4e..6d76f4d 100644
--- a/sys/contrib/dev/acpica/compiler/dttemplate.h
+++ b/sys/contrib/dev/acpica/compiler/dttemplate.h
@@ -45,7 +45,7 @@
#define __DTTEMPLATE_H
-/* Special templates for DSDT and SSDT (AML byte-code tables) */
+/* Special templates for the ASL/AML tables: DSDT, SSDT, and OSDT */
const char TemplateDsdt[] =
"DefinitionBlock (\"dsdt.aml\", \"DSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n"
@@ -65,6 +65,15 @@ const char TemplateSsdt[] =
" }\n"
"}\n\n";
+const char TemplateOsdt[] =
+ "DefinitionBlock (\"osdt.aml\", \"OSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n"
+ "{\n"
+ " Method (MAIN, 0, NotSerialized)\n"
+ " {\n"
+ " Return (Zero)\n"
+ " }\n"
+ "}\n\n";
+
/* Templates for ACPI data tables */
diff --git a/sys/contrib/dev/acpica/compiler/dtutils.c b/sys/contrib/dev/acpica/compiler/dtutils.c
index 2d5b762..ce996c4 100644
--- a/sys/contrib/dev/acpica/compiler/dtutils.c
+++ b/sys/contrib/dev/acpica/compiler/dtutils.c
@@ -241,7 +241,7 @@ DtStrtoul64 (
while (*ThisChar)
{
- if (ACPI_IS_DIGIT (*ThisChar))
+ if (isdigit ((int) *ThisChar))
{
/* Convert ASCII 0-9 to Decimal value */
@@ -249,8 +249,8 @@ DtStrtoul64 (
}
else /* Letter */
{
- ThisDigit = (UINT32) ACPI_TOUPPER (*ThisChar);
- if (!ACPI_IS_XDIGIT ((char) ThisDigit))
+ ThisDigit = (UINT32) toupper ((int) *ThisChar);
+ if (!isxdigit ((int) ThisDigit))
{
/* Not A-F */
@@ -568,7 +568,7 @@ DtGetFieldLength (
Value = DtGetFieldValue (Field);
if (Value)
{
- ByteLength = ACPI_STRLEN (Value) + 1;
+ ByteLength = strlen (Value) + 1;
}
else
{ /* At this point, this is a fatal error */
@@ -633,7 +633,7 @@ DtGetFieldLength (
/* TBD: error if Value is NULL? (as below?) */
- ByteLength = (ACPI_STRLEN (Value) + 1) * sizeof(UINT16);
+ ByteLength = (strlen (Value) + 1) * sizeof(UINT16);
break;
default:
diff --git a/sys/contrib/dev/acpica/compiler/prparser.y b/sys/contrib/dev/acpica/compiler/prparser.y
index 20d6e6a..f0c5f9b 100644
--- a/sys/contrib/dev/acpica/compiler/prparser.y
+++ b/sys/contrib/dev/acpica/compiler/prparser.y
@@ -48,6 +48,13 @@
#define _COMPONENT ASL_PREPROCESSOR
ACPI_MODULE_NAME ("prparser")
+void * AslLocalAllocate (unsigned int Size);
+
+/* Bison/yacc configuration */
+
+#undef alloca
+#define alloca AslLocalAllocate
+
int PrParserlex (void);
int PrParserparse (void);
void PrParsererror (char const *msg);
@@ -175,11 +182,11 @@ Expression
/* Default base for a non-prefixed integer is 10 */
- | EXPOP_NUMBER { UtStrtoul64 (PrParsertext, 10, &$$);}
+ | EXPOP_NUMBER { stroul64 (PrParsertext, 10, &$$);}
/* Standard hex number (0x1234) */
- | EXPOP_HEX_NUMBER { UtStrtoul64 (PrParsertext, 16, &$$);}
+ | EXPOP_HEX_NUMBER { stroul64 (PrParsertext, 16, &$$);}
;
%%
diff --git a/sys/contrib/dev/acpica/compiler/prscan.c b/sys/contrib/dev/acpica/compiler/prscan.c
index 12d303c..cbf82a9 100644
--- a/sys/contrib/dev/acpica/compiler/prscan.c
+++ b/sys/contrib/dev/acpica/compiler/prscan.c
@@ -67,6 +67,14 @@ PrDoDirective (
char *DirectiveToken,
char **Next);
+static void
+PrGetNextLineInit (
+ void);
+
+static UINT32
+PrGetNextLine (
+ FILE *Handle);
+
static int
PrMatchDirective (
char *Directive);
@@ -186,7 +194,7 @@ PrInitializeGlobals (
/* Init globals */
Gbl_InputFileList = NULL;
- Gbl_CurrentLineNumber = 0;
+ Gbl_CurrentLineNumber = 1;
Gbl_PreprocessorLineNumber = 1;
Gbl_PreprocessorError = FALSE;
@@ -271,7 +279,7 @@ PrDoPreprocess (
} while (MoreInputFiles);
- /* Point compiler input to the new preprocessor output file (.i) */
+ /* Point compiler input to the new preprocessor output file (.pre) */
FlCloseFile (ASL_FILE_INPUT);
Gbl_Files[ASL_FILE_INPUT].Handle = Gbl_Files[ASL_FILE_PREPROCESSOR].Handle;
@@ -280,7 +288,10 @@ PrDoPreprocess (
/* Reset globals to allow compiler to run */
FlSeekFile (ASL_FILE_INPUT, 0);
- Gbl_CurrentLineNumber = 1;
+ if (!Gbl_PreprocessOnly)
+ {
+ Gbl_CurrentLineNumber = 0;
+ }
DbgPrint (ASL_DEBUG_OUTPUT, "Preprocessing phase complete \n\n");
}
@@ -297,7 +308,8 @@ PrDoPreprocess (
* DESCRIPTION: Preprocess one entire file, line-by-line.
*
* Input: Raw user ASL from ASL_FILE_INPUT
- * Output: Preprocessed file written to ASL_FILE_PREPROCESSOR
+ * Output: Preprocessed file written to ASL_FILE_PREPROCESSOR and
+ * (optionally) ASL_FILE_PREPROCESSOR_USER
*
******************************************************************************/
@@ -305,7 +317,7 @@ static void
PrPreprocessInputFile (
void)
{
- UINT32 Offset;
+ UINT32 Status;
char *Token;
char *ReplaceString;
PR_DEFINE_INFO *DefineInfo;
@@ -314,10 +326,21 @@ PrPreprocessInputFile (
int OffsetAdjust;
+ PrGetNextLineInit ();
+
/* Scan line-by-line. Comments and blank lines are skipped by this function */
- while ((Offset = DtGetNextLine (Gbl_Files[ASL_FILE_INPUT].Handle)) != ASL_EOF)
+ while ((Status = PrGetNextLine (Gbl_Files[ASL_FILE_INPUT].Handle)) != ASL_EOF)
{
+ Gbl_CurrentLineNumber++;
+ Gbl_LogicalLineNumber++;
+
+ if ((Status == ASL_WITHIN_COMMENT) ||
+ (Status == ASL_BLANK_LINE))
+ {
+ goto WriteEntireLine;
+ }
+
/* Need a copy of the input line for strok() */
strcpy (Gbl_MainTokenBuffer, Gbl_CurrentLineBuffer);
@@ -397,24 +420,13 @@ PrPreprocessInputFile (
Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next);
}
- /*
- * Emit a #line directive if necessary, to keep the line numbers in
- * the (.i) file synchronized with the original source code file, so
- * that the correct line number appears in any error messages
- * generated by the actual compiler.
- */
- if (Gbl_CurrentLineNumber > (Gbl_PreviousLineNumber + 1))
- {
- FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u\n",
- Gbl_CurrentLineNumber);
- }
-
- Gbl_PreviousLineNumber = Gbl_CurrentLineNumber;
Gbl_PreprocessorLineNumber++;
+
+WriteEntireLine:
/*
* Now we can write the possibly modified source line to the
- * preprocessor (.i) file
+ * preprocessor file(s).
*/
FlWriteFile (ASL_FILE_PREPROCESSOR, Gbl_CurrentLineBuffer,
strlen (Gbl_CurrentLineBuffer));
@@ -654,7 +666,7 @@ PrDoDirective (
{
#ifndef MACROS_SUPPORTED
AcpiOsPrintf ("%s ERROR - line %u: #define macros are not supported yet\n",
- Gbl_CurrentLineBuffer, Gbl_CurrentLineNumber);
+ Gbl_CurrentLineBuffer, Gbl_LogicalLineNumber);
exit(1);
#else
PrAddMacro (Token, Next);
@@ -691,7 +703,7 @@ PrDoDirective (
#endif
DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
"New #define: %s->%s\n",
- Gbl_CurrentLineNumber, Token, Token2);
+ Gbl_LogicalLineNumber, Token, Token2);
PrAddDefine (Token, Token2, FALSE);
}
@@ -760,10 +772,7 @@ PrDoDirective (
"User #line invocation %s\n", Gbl_CurrentLineNumber,
Token);
- /* Update local line numbers */
-
Gbl_CurrentLineNumber = (UINT32) Value;
- Gbl_PreviousLineNumber = 0;
/* Emit #line into the preprocessor file */
@@ -839,6 +848,107 @@ SyntaxError:
/*******************************************************************************
*
+ * FUNCTION: PrGetNextLine, PrGetNextLineInit
+ *
+ * PARAMETERS: Handle - Open file handle for the source file
+ *
+ * RETURN: Status of the GetLine operation:
+ * AE_OK - Normal line, OK status
+ * ASL_WITHIN_COMMENT - Line is part of a multi-line comment
+ * ASL_EOF - End-of-file reached
+ *
+ * DESCRIPTION: Get the next text line from the input file. Does not strip
+ * comments.
+ *
+ ******************************************************************************/
+
+#define PR_NORMAL_TEXT 0
+#define PR_WITHIN_COMMENT 1
+
+static UINT8 AcpiGbl_LineScanState = PR_NORMAL_TEXT;
+
+static void
+PrGetNextLineInit (
+ void)
+{
+ AcpiGbl_LineScanState = 0;
+}
+
+static UINT32
+PrGetNextLine (
+ FILE *Handle)
+{
+ UINT32 i;
+ int c = 0;
+ int PreviousChar;
+
+
+ /* Always clear the global line buffer */
+
+ memset (Gbl_CurrentLineBuffer, 0, Gbl_LineBufferSize);
+ for (i = 0; ;)
+ {
+ /*
+ * If line is too long, expand the line buffers. Also increases
+ * Gbl_LineBufferSize.
+ */
+ if (i >= Gbl_LineBufferSize)
+ {
+ UtExpandLineBuffers ();
+ }
+
+ PreviousChar = c;
+ c = getc (Handle);
+ if (c == EOF)
+ {
+ return (ASL_EOF);
+ }
+
+ /* We need to worry about multi-line slash-asterisk comments */
+
+ /* Check for comment open */
+
+ if ((AcpiGbl_LineScanState == PR_NORMAL_TEXT) &&
+ (PreviousChar == '/') && (c == '*'))
+ {
+ AcpiGbl_LineScanState = PR_WITHIN_COMMENT;
+ }
+
+ /* Check for comment close */
+
+ if ((AcpiGbl_LineScanState == PR_WITHIN_COMMENT) &&
+ (PreviousChar == '*') && (c == '/'))
+ {
+ AcpiGbl_LineScanState = PR_NORMAL_TEXT;
+ }
+
+ /* Always copy the character into line buffer */
+
+ Gbl_CurrentLineBuffer[i] = (char) c;
+ i++;
+
+ /* Always exit on end-of-line */
+
+ if (c == '\n')
+ {
+ /* Handle multi-line comments */
+
+ if (AcpiGbl_LineScanState == PR_WITHIN_COMMENT)
+ {
+ return (ASL_WITHIN_COMMENT);
+ }
+ if (i == 1)
+ {
+ return (ASL_BLANK_LINE);
+ }
+ return (AE_OK);
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: PrMatchDirective
*
* PARAMETERS: Directive - Pointer to directive name token
diff --git a/sys/contrib/dev/acpica/compiler/prutils.c b/sys/contrib/dev/acpica/compiler/prutils.c
index 7e880b1..751d1a0 100644
--- a/sys/contrib/dev/acpica/compiler/prutils.c
+++ b/sys/contrib/dev/acpica/compiler/prutils.c
@@ -382,6 +382,8 @@ PrPushInputFileStack (
PR_FILE_NODE *Fnode;
+ Gbl_HasIncludeFiles = TRUE;
+
/* Save the current state in an Fnode */
Fnode = UtLocalCalloc (sizeof (PR_FILE_NODE));
@@ -406,11 +408,11 @@ PrPushInputFileStack (
strcpy (Gbl_Files[ASL_FILE_INPUT].Filename, Filename);
Gbl_Files[ASL_FILE_INPUT].Handle = InputFile;
- Gbl_PreviousLineNumber = 0;
- Gbl_CurrentLineNumber = 0;
+ Gbl_CurrentLineNumber = 1;
/* Emit a new #line directive for the include file */
+ Gbl_CurrentLineNumber = 1;
FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n", 1, Filename);
}
@@ -460,12 +462,11 @@ PrPopInputFileStack (
Gbl_Files[ASL_FILE_INPUT].Filename = Fnode->Filename;
Gbl_Files[ASL_FILE_INPUT].Handle = Fnode->File;
Gbl_CurrentLineNumber = Fnode->CurrentLineNumber;
- Gbl_PreviousLineNumber = 0;
/* Emit a new #line directive after the include file */
FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n",
- Gbl_CurrentLineNumber + 1, Fnode->Filename);
+ Gbl_CurrentLineNumber, Fnode->Filename);
/* All done with this node */
OpenPOWER on IntegriCloud