aboutsummaryrefslogtreecommitdiff
path: root/source/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'source/compiler')
-rw-r--r--source/compiler/aslcompile.c14
-rw-r--r--source/compiler/aslmessages.h3
-rw-r--r--source/compiler/asltree.c3
-rw-r--r--source/compiler/aslutils.c3
-rw-r--r--source/compiler/dtfield.c3
-rw-r--r--source/compiler/dtio.c25
-rw-r--r--source/compiler/dttable.c32
-rw-r--r--source/compiler/dttemplate.h18
-rw-r--r--source/compiler/dtutils.c6
-rw-r--r--source/compiler/preprocess.h20
-rw-r--r--source/compiler/prscan.c404
11 files changed, 360 insertions, 171 deletions
diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c
index bbd8ab95ca05..87f97efaad7a 100644
--- a/source/compiler/aslcompile.c
+++ b/source/compiler/aslcompile.c
@@ -966,7 +966,19 @@ CmCleanupAndExit (
/* Close all open files */
- Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .i file is same as source file */
+ /*
+ * Take care with the preprocessor file (.i), 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.
+ */
+ if (Gbl_Files[ASL_FILE_PREPROCESSOR].Handle ==
+ Gbl_Files[ASL_FILE_INPUT].Handle)
+ {
+ Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL;
+ }
+
+ /* Close the standard I/O files */
for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++)
{
diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h
index a104a440840d..9fb7229c44e9 100644
--- a/source/compiler/aslmessages.h
+++ b/source/compiler/aslmessages.h
@@ -248,7 +248,7 @@ typedef enum
ASL_MSG_TOO_MANY_ARGUMENTS,
ASL_MSG_UNKNOWN_DIRECTIVE,
ASL_MSG_UNKNOWN_PRAGMA,
-
+ ASL_MSG_WARNING_DIRECTIVE,
/* These messages are used by the data table compiler only */
@@ -433,6 +433,7 @@ char *AslMessages [] =
/* ASL_MSG_TOO_MANY_ARGUMENTS */ "Too many macro arguments",
/* ASL_MSG_UNKNOWN_DIRECTIVE */ "Unknown directive",
/* ASL_MSG_UNKNOWN_PRAGMA */ "Unknown pragma",
+/* ASL_MSG_WARNING_DIRECTIVE */ "#warning",
/* Table compiler */
diff --git a/source/compiler/asltree.c b/source/compiler/asltree.c
index ca880716fbb4..c8d05e4bc3c4 100644
--- a/source/compiler/asltree.c
+++ b/source/compiler/asltree.c
@@ -823,6 +823,7 @@ TrLinkChildren (
{
AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Child,
"Child node list invalid");
+ va_end(ap);
return (Op);
}
@@ -869,8 +870,8 @@ TrLinkChildren (
}
PrevChild = Child;
}
- va_end(ap);
+ va_end(ap);
DbgPrint (ASL_PARSE_OUTPUT, "\n\n");
return (Op);
}
diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c
index 8174eebb5c03..6537c2e23135 100644
--- a/source/compiler/aslutils.c
+++ b/source/compiler/aslutils.c
@@ -353,8 +353,6 @@ DbgPrint (
va_list Args;
- va_start (Args, Fmt);
-
if (!Gbl_DebugFlag)
{
return;
@@ -366,6 +364,7 @@ DbgPrint (
return;
}
+ va_start (Args, Fmt);
(void) vfprintf (stderr, Fmt, Args);
va_end (Args);
return;
diff --git a/source/compiler/dtfield.c b/source/compiler/dtfield.c
index 697b277172a5..a5642a114890 100644
--- a/source/compiler/dtfield.c
+++ b/source/compiler/dtfield.c
@@ -467,12 +467,13 @@ DtCompileBuffer (
if (ACPI_FAILURE (Status))
{
DtError (ASL_ERROR, ASL_MSG_BUFFER_ELEMENT, Field, MsgBuffer);
- return (ByteLength - Count);
+ goto Exit;
}
Buffer[i] = (UINT8) Value;
}
+Exit:
ACPI_FREE (StringValue);
return (ByteLength - Count);
}
diff --git a/source/compiler/dtio.c b/source/compiler/dtio.c
index c26b2b83a74e..8b0323413fc9 100644
--- a/source/compiler/dtio.c
+++ b/source/compiler/dtio.c
@@ -287,31 +287,21 @@ DtParseLine (
while (Start < Colon)
{
- if (*Start == ' ')
- {
- Start++;
- continue;
- }
-
- /* Found left bracket, go to the right bracket */
-
if (*Start == '[')
{
+ /* Found left bracket, go to the right bracket */
+
while (Start < Colon && *Start != ']')
{
Start++;
}
-
- if (Start == Colon)
- {
- break;
- }
-
- Start++;
- continue;
+ }
+ else if (*Start != ' ')
+ {
+ break;
}
- break;
+ Start++;
}
/*
@@ -1138,4 +1128,5 @@ DtWriteTableToListing (
AcpiUtDumpBuffer (Buffer, Gbl_TableLength, DB_BYTE_DISPLAY, 0);
AcpiOsRedirectOutput (stdout);
+ ACPI_FREE (Buffer);
}
diff --git a/source/compiler/dttable.c b/source/compiler/dttable.c
index 4236c6c4daba..3b84956a6389 100644
--- a/source/compiler/dttable.c
+++ b/source/compiler/dttable.c
@@ -541,8 +541,9 @@ DtCompileDmar (
DT_FIELD *SubtableStart;
ACPI_DMTABLE_INFO *InfoTable;
ACPI_DMAR_HEADER *DmarHeader;
- UINT8 *ReservedBuffer;
- UINT32 ReservedSize;
+ ACPI_DMAR_DEVICE_SCOPE *DmarDeviceScope;
+ UINT32 DeviceScopeLength;
+ UINT32 PciPathLength;
Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable, TRUE);
@@ -553,17 +554,7 @@ DtCompileDmar (
ParentTable = DtPeekSubtable ();
DtInsertSubtable (ParentTable, Subtable);
-
- /* DMAR Reserved area */
-
- ReservedSize = (UINT32) sizeof (((ACPI_TABLE_DMAR *) NULL)->Reserved);
- ReservedBuffer = UtLocalCalloc (ReservedSize);
-
- DtCreateSubtable (ReservedBuffer, ReservedSize, &Subtable);
-
- ACPI_FREE (ReservedBuffer);
- ParentTable = DtPeekSubtable ();
- DtInsertSubtable (ParentTable, Subtable);
+ DtPushSubtable (Subtable);
while (*PFieldList)
{
@@ -621,10 +612,13 @@ DtCompileDmar (
ParentTable = DtPeekSubtable ();
DtInsertSubtable (ParentTable, Subtable);
+ DtPushSubtable (Subtable);
/* Optional Device Scope subtables */
- while (*PFieldList)
+ DeviceScopeLength = DmarHeader->Length - Subtable->Length -
+ ParentTable->Length;
+ while (DeviceScopeLength)
{
Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarScope,
&Subtable, FALSE);
@@ -637,9 +631,12 @@ DtCompileDmar (
DtInsertSubtable (ParentTable, Subtable);
DtPushSubtable (Subtable);
+ DmarDeviceScope = ACPI_CAST_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable->Buffer);
+
/* Optional PCI Paths */
- while (*PFieldList)
+ PciPathLength = DmarDeviceScope->Length - Subtable->Length;
+ while (PciPathLength)
{
Status = DtCompileTable (PFieldList, TableInfoDmarPciPath,
&Subtable, FALSE);
@@ -651,10 +648,15 @@ DtCompileDmar (
ParentTable = DtPeekSubtable ();
DtInsertSubtable (ParentTable, Subtable);
+ PciPathLength -= Subtable->Length;
}
+
+ DtPopSubtable ();
+ DeviceScopeLength -= DmarDeviceScope->Length;
}
DtPopSubtable ();
+ DtPopSubtable ();
}
return (AE_OK);
diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h
index d3fadf504ef9..f620abd21dee 100644
--- a/source/compiler/dttemplate.h
+++ b/source/compiler/dttemplate.h
@@ -188,22 +188,22 @@ const unsigned char TemplateDbgp[] =
const unsigned char TemplateDmar[] =
{
0x44,0x4D,0x41,0x52,0x8C,0x00,0x00,0x00, /* 00000000 "DMAR...." */
- 0x01,0x15,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
+ 0x01,0x03,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */
0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
- 0x28,0x05,0x10,0x20,0x2F,0x01,0x00,0x00, /* 00000020 "(.. /..." */
+ 0x17,0x05,0x13,0x20,0x2F,0x01,0x00,0x00, /* 00000020 "... /..." */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */
0x00,0x00,0x18,0x00,0x01,0x00,0x00,0x00, /* 00000030 "........" */
- 0x00,0x00,0x02,0xFD,0x00,0x00,0x00,0x00, /* 00000038 "........" */
- 0x03,0x08,0x00,0x00,0x08,0xF0,0x1F,0x07, /* 00000040 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */
+ 0x03,0x08,0x00,0x00,0x08,0x00,0x00,0x01, /* 00000040 "........" */
0x01,0x00,0x20,0x00,0x00,0x00,0x00,0x00, /* 00000048 ".. ....." */
- 0x00,0x10,0xC2,0x78,0x00,0x00,0x00,0x00, /* 00000050 "...x...." */
- 0xFF,0x3F,0xC2,0x78,0x00,0x00,0x00,0x00, /* 00000058 ".?.x...." */
- 0x01,0x08,0x00,0x00,0x00,0x00,0x1D,0x00, /* 00000060 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */
+ 0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */
+ 0x01,0x08,0x00,0x00,0x00,0x00,0x00,0x02, /* 00000060 "........" */
0x02,0x00,0x10,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */
- 0x02,0x08,0x00,0x00,0x00,0x00,0x01,0x00, /* 00000070 "........" */
+ 0x02,0x08,0x00,0x00,0x00,0x00,0x00,0x03, /* 00000070 "........" */
0x03,0x00,0x14,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */
- 0x00,0x00,0x02,0xFD,0x00,0x00,0x00,0x00, /* 00000080 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */
0x00,0x00,0x00,0x00 /* 00000088 "...." */
};
diff --git a/source/compiler/dtutils.c b/source/compiler/dtutils.c
index 1f4207ab8741..e7376f43d09d 100644
--- a/source/compiler/dtutils.c
+++ b/source/compiler/dtutils.c
@@ -397,6 +397,7 @@ DtGetFieldType (
case ACPI_DMT_BUFFER:
case ACPI_DMT_BUF7:
+ case ACPI_DMT_BUF10:
case ACPI_DMT_BUF16:
case ACPI_DMT_BUF128:
case ACPI_DMT_PCI_PATH:
@@ -630,6 +631,11 @@ DtGetFieldLength (
}
break;
+ case ACPI_DMT_BUF10:
+
+ ByteLength = 10;
+ break;
+
case ACPI_DMT_BUF16:
case ACPI_DMT_UUID:
diff --git a/source/compiler/preprocess.h b/source/compiler/preprocess.h
index 6decc009dab9..ae32a8c47f71 100644
--- a/source/compiler/preprocess.h
+++ b/source/compiler/preprocess.h
@@ -124,6 +124,17 @@ typedef struct pr_file_node
} PR_FILE_NODE;
+#define MAX_ARGUMENT_LENGTH 24
+
+typedef struct directive_info
+{
+ struct directive_info *Next;
+ char Argument[MAX_ARGUMENT_LENGTH];
+ int Directive;
+ BOOLEAN IgnoringThisCodeBlock;
+
+} DIRECTIVE_INFO;
+
/*
* Globals
@@ -136,12 +147,13 @@ PR_EXTERN char PR_INIT_GLOBAL (*Gbl_MainTokenBuffer, NULL); /*
PR_EXTERN char PR_INIT_GLOBAL (*Gbl_MacroTokenBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */
PR_EXTERN char PR_INIT_GLOBAL (*Gbl_ExpressionTokenBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */
-PR_EXTERN PR_FILE_NODE *Gbl_InputFileList;
-PR_EXTERN PR_DEFINE_INFO PR_INIT_GLOBAL (*Gbl_DefineList, NULL);
PR_EXTERN UINT32 Gbl_PreprocessorLineNumber;
PR_EXTERN int Gbl_IfDepth;
+PR_EXTERN PR_FILE_NODE *Gbl_InputFileList;
+PR_EXTERN PR_DEFINE_INFO PR_INIT_GLOBAL (*Gbl_DefineList, NULL);
PR_EXTERN BOOLEAN PR_INIT_GLOBAL (Gbl_PreprocessorError, FALSE);
-
+PR_EXTERN BOOLEAN PR_INIT_GLOBAL (Gbl_IgnoringThisCodeBlock, FALSE);
+PR_EXTERN DIRECTIVE_INFO PR_INIT_GLOBAL (*Gbl_DirectiveStack, NULL);
/*
* prscan - Preprocessor entry
@@ -158,7 +170,7 @@ void
PrTerminatePreprocessor (
void);
-BOOLEAN
+void
PrDoPreprocess (
void);
diff --git a/source/compiler/prscan.c b/source/compiler/prscan.c
index cc9b3ce5783c..3b5416a61195 100644
--- a/source/compiler/prscan.c
+++ b/source/compiler/prscan.c
@@ -65,13 +65,27 @@ PrPreprocessInputFile (
static void
PrDoDirective (
char *DirectiveToken,
- char **Next,
- BOOLEAN *IgnoringThisCodeBlock);
+ char **Next);
static int
PrMatchDirective (
char *Directive);
+static void
+PrPushDirective (
+ int Directive,
+ char *Argument);
+
+static ACPI_STATUS
+PrPopDirective (
+ void);
+
+static void
+PrDbgPrint (
+ char *Action,
+ char *DirectiveName);
+
+
/*
* Supported preprocessor directives
*/
@@ -156,11 +170,16 @@ PrInitializeGlobals (
{
/* Init globals */
- Gbl_IfDepth = 0;
Gbl_InputFileList = NULL;
Gbl_CurrentLineNumber = 0;
Gbl_PreprocessorLineNumber = 1;
Gbl_PreprocessorError = FALSE;
+
+ /* These are used to track #if/#else blocks (possibly nested) */
+
+ Gbl_IfDepth = 0;
+ Gbl_IgnoringThisCodeBlock = FALSE;
+ Gbl_DirectiveStack = NULL;
}
@@ -207,7 +226,7 @@ PrTerminatePreprocessor (
*
* PARAMETERS: None
*
- * RETURN: Error Status. TRUE if error, FALSE if OK.
+ * RETURN: None
*
* DESCRIPTION: Main entry point for the iASL Preprocessor. Input file must
* be already open. Handles multiple input files via the
@@ -215,7 +234,7 @@ PrTerminatePreprocessor (
*
******************************************************************************/
-BOOLEAN
+void
PrDoPreprocess (
void)
{
@@ -237,20 +256,7 @@ PrDoPreprocess (
} while (MoreInputFiles);
-
- /*
- * TBD: is this necessary? (Do we abort on any preprocessing errors?)
- */
- if (Gbl_PreprocessorError)
- {
- /* TBD: can't use source_output file for preprocessor error reporting */
-
- Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Handle = NULL;
- PrTerminatePreprocessor ();
- return (TRUE);
- }
-
- /* Point compiler input to the new preprocessor file (.i) */
+ /* Point compiler input to the new preprocessor output file (.i) */
FlCloseFile (ASL_FILE_INPUT);
Gbl_Files[ASL_FILE_INPUT].Handle = Gbl_Files[ASL_FILE_PREPROCESSOR].Handle;
@@ -262,7 +268,6 @@ PrDoPreprocess (
Gbl_CurrentLineNumber = 1;
DbgPrint (ASL_DEBUG_OUTPUT, "Preprocessing phase complete \n\n");
- return (FALSE);
}
@@ -290,7 +295,6 @@ PrPreprocessInputFile (
char *ReplaceString;
PR_DEFINE_INFO *DefineInfo;
ACPI_SIZE TokenOffset;
- BOOLEAN IgnoringThisCodeBlock = FALSE;
char *Next;
int OffsetAdjust;
@@ -320,7 +324,7 @@ PrPreprocessInputFile (
/* Execute the directive, do not write line to output file */
- PrDoDirective (Token, &Next, &IgnoringThisCodeBlock);
+ PrDoDirective (Token, &Next);
continue;
}
@@ -329,7 +333,7 @@ PrPreprocessInputFile (
* FALSE, ignore the line and do not write it to the output file.
* This continues until an #else or #endif is encountered.
*/
- if (IgnoringThisCodeBlock == TRUE)
+ if (Gbl_IgnoringThisCodeBlock)
{
continue;
}
@@ -416,12 +420,8 @@ PrPreprocessInputFile (
*
* PARAMETERS: Directive - Pointer to directive name token
* Next - "Next" buffer from GetNextToken
- * IgnoringThisCodeBlock - Where the "ignore code" flag is
- * returned.
*
- * RETURN: IgnoringThisCodeBlock: Set to TRUE if we are skipping the FALSE
- * part of an #if or #else block. Set to FALSE when the
- * corresponding #else or #endif is encountered.
+ * RETURN: None.
*
* DESCRIPTION: Main processing for all preprocessor directives
*
@@ -430,8 +430,7 @@ PrPreprocessInputFile (
static void
PrDoDirective (
char *DirectiveToken,
- char **Next,
- BOOLEAN *IgnoringThisCodeBlock)
+ char **Next)
{
char *Token = Gbl_MainTokenBuffer;
char *Token2;
@@ -459,14 +458,28 @@ PrDoDirective (
return;
}
- /* TBD: Need a faster way to do this: */
-
- if ((Directive == PR_DIRECTIVE_ELIF) ||
- (Directive == PR_DIRECTIVE_ELSE) ||
- (Directive == PR_DIRECTIVE_ENDIF))
+ /*
+ * If we are currently ignoring this block and we encounter a #else or
+ * #elif, we must ignore their blocks also if the parent block is also
+ * being ignored.
+ */
+ if (Gbl_IgnoringThisCodeBlock)
{
- DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID "Begin #%s\n",
- Gbl_CurrentLineNumber, Gbl_DirectiveInfo[Directive].Name);
+ switch (Directive)
+ {
+ case PR_DIRECTIVE_ELSE:
+ case PR_DIRECTIVE_ELIF:
+
+ if (Gbl_DirectiveStack && Gbl_DirectiveStack->IgnoringThisCodeBlock)
+ {
+ PrDbgPrint ("Ignoring", Gbl_DirectiveInfo[Directive].Name);
+ return;
+ }
+ break;
+
+ default:
+ break;
+ }
}
/*
@@ -476,57 +489,54 @@ PrDoDirective (
*/
switch (Directive)
{
+ case PR_DIRECTIVE_ELSE:
+
+ Gbl_IgnoringThisCodeBlock = !(Gbl_IgnoringThisCodeBlock);
+ PrDbgPrint ("Executing", "else block");
+ return;
+
case PR_DIRECTIVE_ELIF:
- *IgnoringThisCodeBlock = !(*IgnoringThisCodeBlock);
- if (*IgnoringThisCodeBlock == TRUE)
+ Gbl_IgnoringThisCodeBlock = !(Gbl_IgnoringThisCodeBlock);
+ Directive = PR_DIRECTIVE_IF;
+
+ if (Gbl_IgnoringThisCodeBlock == TRUE)
{
/* Not executing the ELSE part -- all done here */
+ PrDbgPrint ("Ignoring", "elif block");
return;
}
- /* Will execute the ELSE..IF part */
+ /*
+ * After this, we will execute the IF part further below.
+ * First, however, pop off the original #if directive.
+ */
+ if (ACPI_FAILURE (PrPopDirective ()))
+ {
+ PrError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL,
+ THIS_TOKEN_OFFSET (DirectiveToken));
+ }
- DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
- "#elif - Executing else block\n",
- Gbl_CurrentLineNumber);
- Directive = PR_DIRECTIVE_IF;
+ PrDbgPrint ("Executing", "elif block");
break;
- case PR_DIRECTIVE_ELSE:
+ case PR_DIRECTIVE_ENDIF:
- *IgnoringThisCodeBlock = !(*IgnoringThisCodeBlock);
- return;
+ PrDbgPrint ("Executing", "endif");
- case PR_DIRECTIVE_ENDIF:
+ /* Pop the owning #if/#ifdef/#ifndef */
- *IgnoringThisCodeBlock = FALSE;
- Gbl_IfDepth--;
- if (Gbl_IfDepth < 0)
+ if (ACPI_FAILURE (PrPopDirective ()))
{
PrError (ASL_ERROR, ASL_MSG_ENDIF_MISMATCH,
THIS_TOKEN_OFFSET (DirectiveToken));
- Gbl_IfDepth = 0;
}
return;
default:
-
break;
}
- /*
- * At this point, if we are ignoring the current code block,
- * do not process any more directives (i.e., ignore them also.)
- */
- if (*IgnoringThisCodeBlock == TRUE)
- {
- return;
- }
-
- DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID "Begin #%s\n",
- Gbl_CurrentLineNumber, Gbl_DirectiveInfo[Directive].Name);
-
/* Most directives have at least one argument */
if (Gbl_DirectiveInfo[Directive].ArgCount == 1)
@@ -538,8 +548,85 @@ PrDoDirective (
}
}
+ /*
+ * At this point, if we are ignoring the current code block,
+ * do not process any more directives (i.e., ignore them also.)
+ * For "if" style directives, open/push a new block anyway. We
+ * must do this to keep track of #endif directives
+ */
+ if (Gbl_IgnoringThisCodeBlock)
+ {
+ switch (Directive)
+ {
+ case PR_DIRECTIVE_IF:
+ case PR_DIRECTIVE_IFDEF:
+ case PR_DIRECTIVE_IFNDEF:
+
+ PrPushDirective (Directive, Token);
+ PrDbgPrint ("Ignoring", Gbl_DirectiveInfo[Directive].Name);
+ break;
+
+ default:
+ break;
+ }
+
+ return;
+ }
+
+ /*
+ * Execute the directive
+ */
+ PrDbgPrint ("Begin execution", Gbl_DirectiveInfo[Directive].Name);
+
switch (Directive)
{
+ case PR_DIRECTIVE_IF:
+
+ TokenOffset = Token - Gbl_MainTokenBuffer;
+
+ /* Need to expand #define macros in the expression string first */
+
+ Status = PrResolveIntegerExpression (
+ &Gbl_CurrentLineBuffer[TokenOffset-1], &Value);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ PrPushDirective (Directive, Token);
+ if (!Value)
+ {
+ Gbl_IgnoringThisCodeBlock = TRUE;
+ }
+
+ DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
+ "Resolved #if: %8.8X%8.8X %s\n",
+ Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Value),
+ Gbl_IgnoringThisCodeBlock ? "<Skipping Block>" : "<Executing Block>");
+ break;
+
+ case PR_DIRECTIVE_IFDEF:
+
+ PrPushDirective (Directive, Token);
+ if (!PrMatchDefine (Token))
+ {
+ Gbl_IgnoringThisCodeBlock = TRUE;
+ }
+
+ PrDbgPrint ("Evaluated", "ifdef");
+ break;
+
+ case PR_DIRECTIVE_IFNDEF:
+
+ PrPushDirective (Directive, Token);
+ if (PrMatchDefine (Token))
+ {
+ Gbl_IgnoringThisCodeBlock = TRUE;
+ }
+
+ PrDbgPrint ("Evaluated", "ifndef");
+ break;
+
case PR_DIRECTIVE_DEFINE:
/*
* By definition, if first char after the name is a paren,
@@ -595,64 +682,15 @@ PrDoDirective (
case PR_DIRECTIVE_ERROR:
- /* TBD compiler should abort */
/* Note: No macro expansion */
PrError (ASL_ERROR, ASL_MSG_ERROR_DIRECTIVE,
THIS_TOKEN_OFFSET (Token));
- break;
-
- case PR_DIRECTIVE_IF:
- TokenOffset = Token - Gbl_MainTokenBuffer;
-
- /* Need to expand #define macros in the expression string first */
-
- Status = PrResolveIntegerExpression (
- &Gbl_CurrentLineBuffer[TokenOffset-1], &Value);
- if (ACPI_FAILURE (Status))
- {
- return;
- }
-
- if (!Value)
- {
- *IgnoringThisCodeBlock = TRUE;
- }
-
- DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
- "Resolved #if: %8.8X%8.8X %s\n",
- Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Value),
- *IgnoringThisCodeBlock ? "<Skipping Block>" : "<Executing Block>");
-
- Gbl_IfDepth++;
- break;
-
- case PR_DIRECTIVE_IFDEF:
-
- if (!PrMatchDefine (Token))
- {
- *IgnoringThisCodeBlock = TRUE;
- }
-
- Gbl_IfDepth++;
- DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
- "Start #ifdef %s\n", Gbl_CurrentLineNumber,
- *IgnoringThisCodeBlock ? "<Skipping Block>" : "<Executing Block>");
- break;
-
- case PR_DIRECTIVE_IFNDEF:
-
- if (PrMatchDefine (Token))
- {
- *IgnoringThisCodeBlock = TRUE;
- }
-
- Gbl_IfDepth++;
- DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
- "Start #ifndef %2.2X\n", Gbl_CurrentLineNumber,
- *IgnoringThisCodeBlock, Gbl_CurrentLineNumber);
- break;
+ Gbl_SourceLine = 0;
+ Gbl_NextError = Gbl_ErrorLog;
+ CmCleanupAndExit ();
+ exit(1);
case PR_DIRECTIVE_INCLUDE:
@@ -738,7 +776,7 @@ PrDoDirective (
case PR_DIRECTIVE_WARNING:
- PrError (ASL_WARNING, ASL_MSG_ERROR_DIRECTIVE,
+ PrError (ASL_WARNING, ASL_MSG_WARNING_DIRECTIVE,
THIS_TOKEN_OFFSET (Token));
break;
@@ -753,7 +791,6 @@ PrDoDirective (
return;
-
SyntaxError:
PrError (ASL_ERROR, ASL_MSG_DIRECTIVE_SYNTAX,
@@ -796,3 +833,130 @@ PrMatchDirective (
return (ASL_DIRECTIVE_NOT_FOUND); /* Command not recognized */
}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: PrPushDirective
+ *
+ * PARAMETERS: Directive - Encoded directive ID
+ * Argument - String containing argument to the
+ * directive
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Push an item onto the directive stack. Used for processing
+ * nested #if/#else type conditional compilation directives.
+ * Specifically: Used on detection of #if/#ifdef/#ifndef to open
+ * a block.
+ *
+ ******************************************************************************/
+
+static void
+PrPushDirective (
+ int Directive,
+ char *Argument)
+{
+ DIRECTIVE_INFO *Info;
+
+
+ /* Allocate and populate a stack info item */
+
+ Info = ACPI_ALLOCATE (sizeof (DIRECTIVE_INFO));
+
+ Info->Next = Gbl_DirectiveStack;
+ Info->Directive = Directive;
+ Info->IgnoringThisCodeBlock = Gbl_IgnoringThisCodeBlock;
+ strncpy (Info->Argument, Argument, MAX_ARGUMENT_LENGTH);
+
+ DbgPrint (ASL_DEBUG_OUTPUT,
+ "Pr(%.4u) - [%u %s] %*s Pushed [#%s %s]: IgnoreFlag = %s\n",
+ Gbl_CurrentLineNumber, Gbl_IfDepth,
+ Gbl_IgnoringThisCodeBlock ? "I" : "E",
+ Gbl_IfDepth * 4, " ",
+ Gbl_DirectiveInfo[Directive].Name,
+ Argument, Gbl_IgnoringThisCodeBlock ? "TRUE" : "FALSE");
+
+ /* Push new item */
+
+ Gbl_DirectiveStack = Info;
+ Gbl_IfDepth++;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: PrPopDirective
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status. Error if the stack is empty.
+ *
+ * DESCRIPTION: Pop an item off the directive stack. Used for processing
+ * nested #if/#else type conditional compilation directives.
+ * Specifically: Used on detection of #elif and #endif to remove
+ * the original #if/#ifdef/#ifndef from the stack and close
+ * the block.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+PrPopDirective (
+ void)
+{
+ DIRECTIVE_INFO *Info;
+
+
+ /* Check for empty stack */
+
+ Info = Gbl_DirectiveStack;
+ if (!Info)
+ {
+ return (AE_ERROR);
+ }
+
+ /* Pop one item, keep globals up-to-date */
+
+ Gbl_IfDepth--;
+ Gbl_IgnoringThisCodeBlock = Info->IgnoringThisCodeBlock;
+ Gbl_DirectiveStack = Info->Next;
+
+ DbgPrint (ASL_DEBUG_OUTPUT,
+ "Pr(%.4u) - [%u %s] %*s Popped [#%s %s]: IgnoreFlag now = %s\n",
+ Gbl_CurrentLineNumber, Gbl_IfDepth,
+ Gbl_IgnoringThisCodeBlock ? "I" : "E",
+ Gbl_IfDepth * 4, " ",
+ Gbl_DirectiveInfo[Info->Directive].Name,
+ Info->Argument, Gbl_IgnoringThisCodeBlock ? "TRUE" : "FALSE");
+
+ ACPI_FREE (Info);
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: PrDbgPrint
+ *
+ * PARAMETERS: Action - Action being performed
+ * DirectiveName - Directive being processed
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Special debug print for directive processing.
+ *
+ ******************************************************************************/
+
+static void
+PrDbgPrint (
+ char *Action,
+ char *DirectiveName)
+{
+
+ DbgPrint (ASL_DEBUG_OUTPUT, "Pr(%.4u) - [%u %s] "
+ "%*s %s #%s, Depth %u\n",
+ Gbl_CurrentLineNumber, Gbl_IfDepth,
+ Gbl_IgnoringThisCodeBlock ? "I" : "E",
+ Gbl_IfDepth * 4, " ",
+ Action, DirectiveName, Gbl_IfDepth);
+}