summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorJung-uk Kim <jkim@FreeBSD.org>2011-04-13 18:18:52 +0000
committerJung-uk Kim <jkim@FreeBSD.org>2011-04-13 18:18:52 +0000
commit997de4e17cf02a81027df8d01a4fcefe25da3796 (patch)
treef5abd67cc9e3ada1ae289fe7cf2e23d9abf07fcc /compiler
parent4d8fe534b7309d798d941e14e51985eed6b511bc (diff)
Notes
Diffstat (limited to 'compiler')
-rw-r--r--compiler/Makefile26
-rw-r--r--compiler/aslanalyze.c53
-rw-r--r--compiler/aslcompiler.h13
-rw-r--r--compiler/aslcompiler.y4
-rw-r--r--compiler/asldefine.h1
-rw-r--r--compiler/aslglobal.h1
-rw-r--r--compiler/asllookup.c8
-rw-r--r--compiler/aslmain.c4
-rw-r--r--compiler/aslmap.c18
-rw-r--r--compiler/aslmessages.h3
-rw-r--r--compiler/aslpredef.c6
-rw-r--r--compiler/asltypes.h1
-rw-r--r--compiler/aslutils.c8
-rw-r--r--compiler/aslwalks.c30
-rw-r--r--compiler/dtcompile.c55
-rw-r--r--compiler/dtcompiler.h41
-rw-r--r--compiler/dtexpress.c284
-rw-r--r--compiler/dtfield.c7
-rw-r--r--compiler/dtio.c191
-rw-r--r--compiler/dtparser.l133
-rw-r--r--compiler/dtparser.y266
-rw-r--r--compiler/dtsubtable.c42
-rw-r--r--compiler/dttable.c132
-rw-r--r--compiler/dttemplate.c3
-rw-r--r--compiler/dttemplate.h62
-rw-r--r--compiler/dtutils.c38
26 files changed, 1058 insertions, 372 deletions
diff --git a/compiler/Makefile b/compiler/Makefile
index 6344b059f651..2da41eed92db 100644
--- a/compiler/Makefile
+++ b/compiler/Makefile
@@ -18,10 +18,10 @@ CFLAGS+= -Wall -O2 -Wstrict-prototypes -D_LINUX -DACPI_ASL_COMPILER -I../include
# Bison/Flex configuration
#
YACC= bison
-YFLAGS+= -v -d -y -pAslCompiler
+YFLAGS+= -v -d -y
LEX= flex
-LFLAGS+= -i -s -PAslCompiler
+LFLAGS+= -i -s
COMPILE = $(CC) -c $(CFLAGS) -o$@ $?
@@ -70,6 +70,8 @@ OBJS = \
dtexpress.o \
dtfield.o \
dtio.o \
+ dtparserlex.o \
+ dtparserparse.o \
dtsubtable.o \
dttable.o \
dttemplate.o \
@@ -183,14 +185,22 @@ $(PROG) : $(INTERMEDIATES) $(OBJS)
# Parser and Lexer - intermediate C files
#
aslcompilerlex.c : $(ASL_COMPILER)/aslcompiler.l
- ${LEX} ${LFLAGS} -o$@ $?
+ ${LEX} ${LFLAGS} -PAslCompiler -o$@ $?
aslcompilerparse.c : $(ASL_COMPILER)/aslcompiler.y
- ${YACC} ${YFLAGS} -o$@ $?
+ ${YACC} ${YFLAGS} -pAslCompiler -o$@ $?
@mv -f aslcompilerparse.h aslcompiler.y.h
+dtparserlex.c : $(ASL_COMPILER)/dtparser.l
+ ${LEX} ${LFLAGS} -PDtParser -o$@ $?
+
+dtparserparse.c : $(ASL_COMPILER)/dtparser.y
+ ${YACC} ${YFLAGS} -pDtParser -o$@ $?
+ @mv -f dtparserparse.h dtparser.y.h
+
+
#
-# Parser and Lexer - final object files
+# Parsers and Lexers - final object files
#
# Cannot use the common compile warning flags since the C files are created
# by the utilities above and they are not necessarily ANSI C, etc.
@@ -201,6 +211,12 @@ aslcompilerlex.o : aslcompilerlex.c
aslcompilerparse.o : aslcompilerparse.c
$(CC) -c $(CFLAGS) -Wall -Werror -o$@ $?
+dtparserlex.o : dtparserlex.c
+ $(CC) -c $(CFLAGS) -Wall -Werror -o$@ $?
+
+dtparserparse.o : dtparserparse.c
+ $(CC) -c $(CFLAGS) -Wall -Werror -o$@ $?
+
#
# Compiler source
diff --git a/compiler/aslanalyze.c b/compiler/aslanalyze.c
index 0bb0a4bc0e22..414f8d3682fb 100644
--- a/compiler/aslanalyze.c
+++ b/compiler/aslanalyze.c
@@ -483,3 +483,56 @@ ApCheckForGpeNameConflict (
return;
}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: ApCheckRegMethod
+ *
+ * PARAMETERS: Op - Current parse op
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Ensure that a _REG method has a corresponding Operation
+ * Region declaration within the same scope. Note: _REG is defined
+ * to have two arguments and must therefore be defined as a
+ * control method.
+ *
+ ******************************************************************************/
+
+void
+ApCheckRegMethod (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Next;
+ ACPI_PARSE_OBJECT *Parent;
+
+
+ /* We are only interested in _REG methods */
+
+ if (!ACPI_COMPARE_NAME (METHOD_NAME__REG, &Op->Asl.NameSeg))
+ {
+ return;
+ }
+
+ /* Get the start of the current scope */
+
+ Parent = Op->Asl.Parent;
+ Next = Parent->Asl.Child;
+
+ /* Search entire scope for an operation region declaration */
+
+ while (Next)
+ {
+ if (Next->Asl.ParseOpcode == PARSEOP_OPERATIONREGION)
+ {
+ return; /* Found region, OK */
+ }
+
+ Next = Next->Asl.Next;
+ }
+
+ /* No region found, issue warning */
+
+ AslError (ASL_WARNING, ASL_MSG_NO_REGION, Op, NULL);
+}
diff --git a/compiler/aslcompiler.h b/compiler/aslcompiler.h
index 74bf55f33e1b..8ce206926a1b 100644
--- a/compiler/aslcompiler.h
+++ b/compiler/aslcompiler.h
@@ -265,6 +265,10 @@ void
ApCheckForGpeNameConflict (
ACPI_PARSE_OBJECT *Op);
+void
+ApCheckRegMethod (
+ ACPI_PARSE_OBJECT *Op);
+
/*
* aslerror - error handling/reporting
@@ -457,7 +461,7 @@ AslMapNamedOpcodeToDataType (
/*
* aslpredef - ACPI predefined names support
*/
-void
+BOOLEAN
ApCheckForPredefinedMethod (
ACPI_PARSE_OBJECT *Op,
ASL_METHOD_INFO *MethodInfo);
@@ -763,6 +767,13 @@ UINT64
UtDoConstant (
char *String);
+ACPI_STATUS
+UtStrtoul64 (
+ char *String,
+ UINT32 Base,
+ UINT64 *RetInteger);
+
+
/*
* asluuid - UUID support
*/
diff --git a/compiler/aslcompiler.y b/compiler/aslcompiler.y
index 92517a4234cb..31d2ba68e6d3 100644
--- a/compiler/aslcompiler.y
+++ b/compiler/aslcompiler.y
@@ -1484,7 +1484,7 @@ ReturnTerm
: PARSEOP_RETURN '(' {$<n>$ = TrCreateLeafNode (PARSEOP_RETURN);}
OptionalReturnArg
')' {$$ = TrLinkChildren ($<n>3,1,$4);}
- | PARSEOP_RETURN {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),1,TrCreateLeafNode (PARSEOP_ZERO));}
+ | PARSEOP_RETURN {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),1,TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN));}
| PARSEOP_RETURN '('
error ')' {$$ = AslDoError(); yyclearin;}
;
@@ -3061,7 +3061,7 @@ OptionalTermArg
;
OptionalReturnArg
- : {$$ = TrCreateLeafNode (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */
+ : {$$ = TrSetNodeFlags (TrCreateLeafNode (PARSEOP_ZERO), NODE_IS_NULL_RETURN);} /* Placeholder is a ZeroOp object */
| TermArg {$$ = $1;}
;
diff --git a/compiler/asldefine.h b/compiler/asldefine.h
index 50382fcbe0b7..cfde1e48849f 100644
--- a/compiler/asldefine.h
+++ b/compiler/asldefine.h
@@ -123,6 +123,7 @@
#define ASL_EXTERNAL_METHOD 255
#define ASL_ABORT TRUE
#define ASL_NO_ABORT FALSE
+#define ASL_EOF ACPI_UINT32_MAX
/* Support for reserved method names */
diff --git a/compiler/aslglobal.h b/compiler/aslglobal.h
index f61de6df2485..f80c89f362c7 100644
--- a/compiler/aslglobal.h
+++ b/compiler/aslglobal.h
@@ -69,6 +69,7 @@
extern int yydebug;
extern FILE *AslCompilerin;
extern int AslCompilerdebug;
+extern int DtParserdebug;
extern const ASL_MAPPING_ENTRY AslKeywordMapping[];
extern char *AslCompilertext;
diff --git a/compiler/asllookup.c b/compiler/asllookup.c
index c1785b416b7a..dec2396030c0 100644
--- a/compiler/asllookup.c
+++ b/compiler/asllookup.c
@@ -1251,8 +1251,8 @@ LkNamespaceLocateBegin (
SpaceIdOp = OwningOp->Asl.Child->Asl.Next;
switch ((UINT32) SpaceIdOp->Asl.Value.Integer)
{
- case REGION_EC:
- case REGION_CMOS:
+ case ACPI_ADR_SPACE_EC:
+ case ACPI_ADR_SPACE_CMOS:
if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BYTE)
{
@@ -1260,8 +1260,8 @@ LkNamespaceLocateBegin (
}
break;
- case REGION_SMBUS:
- case REGION_IPMI:
+ case ACPI_ADR_SPACE_SMBUS:
+ case ACPI_ADR_SPACE_IPMI:
if ((UINT8) Op->Asl.Parent->Asl.Value.Integer != AML_FIELD_ACCESS_BUFFER)
{
diff --git a/compiler/aslmain.c b/compiler/aslmain.c
index 0f8353e29b59..d2aef19c33f6 100644
--- a/compiler/aslmain.c
+++ b/compiler/aslmain.c
@@ -148,7 +148,7 @@ Options (
printf (" -ls Create combined source file (expanded includes) (*.src)\n");
printf ("\nACPI Data Tables:\n");
- printf (" -T <Sig> Create table template file for <Sig> (or \"ALL\")\n");
+ printf (" -T <Sig>|ALL|* Create table template file(s) for <Sig>\n");
printf (" -vt Create verbose templates (full disassembly)\n");
printf ("\nAML Disassembler:\n");
@@ -425,10 +425,12 @@ AslDoOptions (
{
case 'b':
AslCompilerdebug = 1; /* same as yydebug */
+ DtParserdebug = 1;
break;
case 'p':
AslCompilerdebug = 1; /* same as yydebug */
+ DtParserdebug = 1;
break;
case 't':
diff --git a/compiler/aslmap.c b/compiler/aslmap.c
index 4b25e69d039c..6ea096200683 100644
--- a/compiler/aslmap.c
+++ b/compiler/aslmap.c
@@ -141,7 +141,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] =
/* ACCESSTYPE_WORD */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_WORD, 0, 0),
/* ACQUIRE */ OP_TABLE_ENTRY (AML_ACQUIRE_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* ADD */ OP_TABLE_ENTRY (AML_ADD_OP, 0, 0, ACPI_BTYPE_INTEGER),
-/* ADDRESSSPACE_FFIXEDHW */ OP_TABLE_ENTRY (AML_BYTE_OP, REGION_FIXED_HW, 0, 0),
+/* ADDRESSSPACE_FFIXEDHW */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_ADR_SPACE_FIXED_HARDWARE, 0, 0),
/* ADDRESSTYPE_ACPI */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* ADDRESSTYPE_MEMORY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* ADDRESSTYPE_NVS */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
@@ -321,14 +321,14 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] =
/* READWRITETYPE_BOTH */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* READWRITETYPE_READONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* REFOF */ OP_TABLE_ENTRY (AML_REF_OF_OP, 0, 0, ACPI_BTYPE_REFERENCE),
-/* REGIONSPACE_CMOS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_CMOS, 0, 0),
-/* REGIONSPACE_EC */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_EC, 0, 0),
-/* REGIONSPACE_IO */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_IO, 0, 0),
-/* REGIONSPACE_IPMI */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_IPMI, 0, 0),
-/* REGIONSPACE_MEM */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_MEMORY, 0, 0),
-/* REGIONSPACE_PCI */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_PCI_CONFIG, 0, 0),
-/* REGIONSPACE_PCIBAR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_PCI_BAR, 0, 0),
-/* REGIONSPACE_SMBUS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, REGION_SMBUS, 0, 0),
+/* REGIONSPACE_CMOS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_CMOS, 0, 0),
+/* REGIONSPACE_EC */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_EC, 0, 0),
+/* REGIONSPACE_IO */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_SYSTEM_IO, 0, 0),
+/* REGIONSPACE_IPMI */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_IPMI, 0, 0),
+/* REGIONSPACE_MEM */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_SYSTEM_MEMORY, 0, 0),
+/* REGIONSPACE_PCI */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_PCI_CONFIG, 0, 0),
+/* REGIONSPACE_PCIBAR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_PCI_BAR_TARGET, 0, 0),
+/* REGIONSPACE_SMBUS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_SMBUS, 0, 0),
/* REGISTER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* RELEASE */ OP_TABLE_ENTRY (AML_RELEASE_OP, 0, 0, 0),
/* RESERVED_BYTES */ OP_TABLE_ENTRY (AML_INT_RESERVEDFIELD_OP, 0, 0, 0),
diff --git a/compiler/aslmessages.h b/compiler/aslmessages.h
index 62c51e424576..269c0a4b3817 100644
--- a/compiler/aslmessages.h
+++ b/compiler/aslmessages.h
@@ -190,6 +190,7 @@ typedef enum
ASL_MSG_LEADING_ASTERISK,
ASL_MSG_RESERVED_NO_RETURN_VAL,
ASL_MSG_GPE_NAME_CONFLICT,
+ ASL_MSG_NO_REGION,
ASL_MSG_INVALID_FIELD_NAME,
ASL_MSG_INTEGER_SIZE,
@@ -343,6 +344,7 @@ char *AslMessages [] = {
/* ASL_MSG_LEADING_ASTERISK */ "Invalid leading asterisk",
/* ASL_MSG_RESERVED_NO_RETURN_VAL */ "Reserved method should not return a value",
/* ASL_MSG_GPE_NAME_CONFLICT */ "Name conflicts with a previous GPE method",
+/* ASL_MSG_NO_REGION */ "_REG has no corresponding Operation Region",
/* These messages are used by the data table compiler only */
@@ -359,7 +361,6 @@ char *AslMessages [] = {
/* ASL_MSG_UNKNOWN_LABEL */ "Label is undefined",
/* ASL_MSG_INVALID_EXPRESSION */ "Invalid expression",
/* ASL_MSG_DIVIDE_BY_ZERO */ "Expression contains divide-by-zero"
-
};
diff --git a/compiler/aslpredef.c b/compiler/aslpredef.c
index 702058fc3bc0..a83674b270c7 100644
--- a/compiler/aslpredef.c
+++ b/compiler/aslpredef.c
@@ -150,7 +150,7 @@ static const ACPI_PREDEFINED_INFO ScopeNames[] = {
*
******************************************************************************/
-void
+BOOLEAN
ApCheckForPredefinedMethod (
ACPI_PARSE_OBJECT *Op,
ASL_METHOD_INFO *MethodInfo)
@@ -171,7 +171,7 @@ ApCheckForPredefinedMethod (
case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */
/* Just return, nothing to do */
- break;
+ return (FALSE);
case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */
@@ -238,6 +238,8 @@ ApCheckForPredefinedMethod (
}
break;
}
+
+ return (TRUE);
}
diff --git a/compiler/asltypes.h b/compiler/asltypes.h
index d9cb3010ccea..8d9b9ed5a127 100644
--- a/compiler/asltypes.h
+++ b/compiler/asltypes.h
@@ -76,6 +76,7 @@
#define NODE_COMPILER_EMITTED 0x00020000
#define NODE_IS_DUPLICATE 0x00040000
#define NODE_IS_RESOURCE_DATA 0x00080000
+#define NODE_IS_NULL_RETURN 0x00100000
/* Keeps information about individual control methods */
diff --git a/compiler/aslutils.c b/compiler/aslutils.c
index 10802bd004d8..d6428197b893 100644
--- a/compiler/aslutils.c
+++ b/compiler/aslutils.c
@@ -68,12 +68,6 @@ char AslHexLookup[] =
/* Local prototypes */
-static ACPI_STATUS
-UtStrtoul64 (
- char *String,
- UINT32 Base,
- UINT64 *RetInteger);
-
static void
UtPadNameWithUnderscores (
char *NameSeg,
@@ -884,7 +878,7 @@ UtDoConstant (
*
******************************************************************************/
-static ACPI_STATUS
+ACPI_STATUS
UtStrtoul64 (
char *String,
UINT32 Base,
diff --git a/compiler/aslwalks.c b/compiler/aslwalks.c
index 82ea1ec6c250..388b653ab40d 100644
--- a/compiler/aslwalks.c
+++ b/compiler/aslwalks.c
@@ -302,10 +302,17 @@ AnMethodAnalysisWalkBegin (
return (AE_ERROR);
}
- /* Child indicates a return value */
-
+ /*
+ * A child indicates a possible return value. A simple Return or
+ * Return() is marked with NODE_IS_NULL_RETURN by the parser so
+ * that it is not counted as a "real" return-with-value, although
+ * the AML code that is actually emitted is Return(0). The AML
+ * definition of Return has a required parameter, so we are
+ * forced to convert a null return to Return(0).
+ */
if ((Op->Asl.Child) &&
- (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
+ (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
+ (!(Op->Asl.Child->Asl.CompileFlags & NODE_IS_NULL_RETURN)))
{
MethodInfo->NumReturnWithValue++;
}
@@ -510,13 +517,22 @@ AnMethodAnalysisWalkEnd (
/*
* Check predefined method names for correct return behavior
- * and correct number of arguments
+ * and correct number of arguments. Also, some special checks
+ * For GPE and _REG methods.
*/
- ApCheckForPredefinedMethod (Op, MethodInfo);
+ if (ApCheckForPredefinedMethod (Op, MethodInfo))
+ {
+ /* Special check for two names like _L01 and _E01 in same scope */
- /* Special check for two names like _L01 and _E01 in same scope */
+ ApCheckForGpeNameConflict (Op);
+
+ /*
+ * Special check for _REG: Must have an operation region definition
+ * within the same scope!
+ */
+ ApCheckRegMethod (Op);
+ }
- ApCheckForGpeNameConflict (Op);
ACPI_FREE (MethodInfo);
break;
diff --git a/compiler/dtcompile.c b/compiler/dtcompile.c
index c1a7b08d5a34..7f4a824b18cf 100644
--- a/compiler/dtcompile.c
+++ b/compiler/dtcompile.c
@@ -277,7 +277,7 @@ DtCompileDataTable (
/* Verify that we at least have a table signature and save it */
- Signature = DtGetFieldValue (*FieldList, "Signature");
+ Signature = DtGetFieldValue (*FieldList);
if (!Signature)
{
sprintf (MsgBuffer, "Expected \"%s\"", "Signature");
@@ -310,20 +310,6 @@ DtCompileDataTable (
Status = DtCompileRsdp (FieldList);
return (Status);
}
- else if (!ACPI_STRNCMP (Signature, "OEM", 3))
- {
- DtFatal (ASL_MSG_OEM_TABLE, *FieldList, Signature);
- return (AE_ERROR);
- }
-
- /* Validate the signature via the ACPI table list */
-
- TableData = AcpiDmGetTableData (Signature);
- if (!TableData)
- {
- DtFatal (ASL_MSG_UNKNOWN_TABLE, *FieldList, Signature);
- return (AE_ERROR);
- }
/*
* All other tables must use the common ACPI table header. Insert the
@@ -340,6 +326,15 @@ DtCompileDataTable (
DtPushSubtable (Gbl_RootTable);
+ /* Validate the signature via the ACPI table list */
+
+ TableData = AcpiDmGetTableData (Signature);
+ if (!TableData)
+ {
+ DtCompileGeneric ((void **) FieldList);
+ goto Out;
+ }
+
/* Dispatch to per-table compile */
if (TableData->CmTableHandler)
@@ -374,6 +369,7 @@ DtCompileDataTable (
return (AE_ERROR);
}
+Out:
/* Set the final table length and then the checksum */
DtSetTableLength ();
@@ -424,6 +420,11 @@ DtCompileTable (
}
Length = DtGetSubtableLength (*Field, Info);
+ if (Length == ASL_EOF)
+ {
+ return (AE_ERROR);
+ }
+
Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE));
if (Length > 0)
@@ -450,29 +451,6 @@ DtCompileTable (
goto Error;
}
- /* Does input field name match what is expected? */
-
- if (ACPI_STRCMP (LocalField->Name, Info->Name))
- {
- /*
- * If Required = TRUE, the subtable must exist.
- * If Required = FALSE, the subtable is optional
- * (For example, AcpiDmTableInfoDmarScope in DMAR table is
- * optional)
- */
- if (Required)
- {
- sprintf (MsgBuffer, "Expected \"%s\"", Info->Name);
- DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
- LocalField, MsgBuffer);
- }
- else
- {
- Status = AE_NOT_FOUND;
- goto Error;
- }
- }
-
/* Maintain table offsets */
LocalField->TableOffset = Gbl_CurrentTableOffset;
@@ -518,7 +496,6 @@ DtCompileTable (
* Recursion (one level max): compile GAS (Generic Address)
* or Notify in-line subtable
*/
- LocalField = LocalField->Next;
*Field = LocalField;
if (Info->Opcode == ACPI_DMT_GAS)
diff --git a/compiler/dtcompiler.h b/compiler/dtcompiler.h
index 9138a78e71bf..f68e4b5f18b0 100644
--- a/compiler/dtcompiler.h
+++ b/compiler/dtcompiler.h
@@ -220,9 +220,20 @@ DtGetParentSubtable (
/* dtexpress - Integer expressions and labels */
-UINT64
+ACPI_STATUS
DtResolveIntegerExpression (
- DT_FIELD *Field);
+ DT_FIELD *Field,
+ UINT64 *ReturnValue);
+
+UINT64
+DtDoOperator (
+ UINT64 LeftValue,
+ UINT32 Operator,
+ UINT64 RightValue);
+
+UINT64
+DtResolveLabel (
+ char *LabelString);
void
DtDetectAllLabels (
@@ -260,6 +271,25 @@ DtCompileFlag (
ACPI_DMTABLE_INFO *Info);
+/* dtparser - lex/yacc files */
+
+UINT64
+DtEvaluateExpression (
+ char *ExprString);
+
+int
+DtInitLexer (
+ char *String);
+
+void
+DtTerminateLexer (
+ void);
+
+char *
+DtGetOpName (
+ UINT32 ParseOpcode);
+
+
/* dtutils - Miscellaneous utilities */
typedef
@@ -306,8 +336,7 @@ DtGetFileSize (
char*
DtGetFieldValue (
- DT_FIELD *Field,
- char *Name);
+ DT_FIELD *Field);
UINT8
DtGetFieldType (
@@ -417,6 +446,10 @@ ACPI_STATUS
DtCompileXsdt (
void **PFieldList);
+ACPI_STATUS
+DtCompileGeneric (
+ void **PFieldList);
+
ACPI_DMTABLE_INFO *
DtGetGenericTableInfo (
char *Name);
diff --git a/compiler/dtexpress.c b/compiler/dtexpress.c
index 20a2e3eb1d06..cb7620eeb37a 100644
--- a/compiler/dtexpress.c
+++ b/compiler/dtexpress.c
@@ -45,6 +45,7 @@
#include "aslcompiler.h"
#include "dtcompiler.h"
+#include "dtparser.y.h"
#define _COMPONENT DT_COMPILER
ACPI_MODULE_NAME ("dtexpress")
@@ -52,11 +53,6 @@
/* Local prototypes */
-static UINT64
-DtResolveInteger (
- DT_FIELD *Field,
- char *IntegerString);
-
static void
DtInsertLabelField (
DT_FIELD *Field);
@@ -65,204 +61,226 @@ static DT_FIELD *
DtLookupLabel (
char *Name);
+/* Global used for errors during parse and related functions */
+
+DT_FIELD *Gbl_CurrentField;
+
/******************************************************************************
*
* FUNCTION: DtResolveIntegerExpression
*
* PARAMETERS: Field - Field object with Integer expression
+ * ReturnValue - Where the integer is returned
*
- * RETURN: A 64-bit integer value
+ * RETURN: Status, and the resolved 64-bit integer value
*
* DESCRIPTION: Resolve an integer expression to a single value. Supports
- * both integer constants and labels. Supported operators are:
- * +,-,*,/,%,|,&,^
+ * both integer constants and labels.
*
*****************************************************************************/
-UINT64
+ACPI_STATUS
DtResolveIntegerExpression (
- DT_FIELD *Field)
+ DT_FIELD *Field,
+ UINT64 *ReturnValue)
{
- char *IntegerString;
- char *Operator;
- UINT64 Value;
- UINT64 Value2;
+ UINT64 Result;
DbgPrint (ASL_DEBUG_OUTPUT, "Full Integer expression: %s\n",
Field->Value);
- strcpy (MsgBuffer, Field->Value); /* Must take a copy for strtok() */
+ Gbl_CurrentField = Field;
- /* Obtain and resolve the first operand */
+ Result = DtEvaluateExpression (Field->Value);
+ *ReturnValue = Result;
+ return (AE_OK);
+}
- IntegerString = strtok (MsgBuffer, " ");
- if (!IntegerString)
- {
- DtError (ASL_ERROR, ASL_MSG_INVALID_EXPRESSION, Field, Field->Value);
- return (0);
- }
- Value = DtResolveInteger (Field, IntegerString);
- DbgPrint (ASL_DEBUG_OUTPUT, "Integer resolved to V1: %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (Value));
+/******************************************************************************
+ *
+ * FUNCTION: DtDoOperator
+ *
+ * PARAMETERS: LeftValue - First 64-bit operand
+ * Operator - Parse token for the operator (EXPOP_*)
+ * RightValue - Second 64-bit operand
+ *
+ * RETURN: 64-bit result of the requested operation
+ *
+ * DESCRIPTION: Perform the various 64-bit integer math functions
+ *
+ *****************************************************************************/
- /*
- * Consume the entire expression string. For the rest of the
- * expression string, values are of the form:
- * <operator> <integer>
- */
- while (1)
+UINT64
+DtDoOperator (
+ UINT64 LeftValue,
+ UINT32 Operator,
+ UINT64 RightValue)
+{
+ UINT64 Result;
+
+
+ /* Perform the requested operation */
+
+ switch (Operator)
{
- Operator = strtok (NULL, " ");
- if (!Operator)
- {
- /* Normal exit */
+ case EXPOP_ONES_COMPLIMENT:
+ Result = ~RightValue;
+ break;
- DbgPrint (ASL_DEBUG_OUTPUT, "Expression Resolved to: %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (Value));
+ case EXPOP_LOGICAL_NOT:
+ Result = !RightValue;
+ break;
- return (Value);
- }
+ case EXPOP_MULTIPLY:
+ Result = LeftValue * RightValue;
+ break;
- IntegerString = strtok (NULL, " ");
- if (!IntegerString ||
- (strlen (Operator) > 1))
+ case EXPOP_DIVIDE:
+ if (!RightValue)
{
- /* No corresponding operand for operator or invalid operator */
+ DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO,
+ Gbl_CurrentField, Gbl_CurrentField->Value);
+ return (0);
+ }
+ Result = LeftValue / RightValue;
+ break;
- DtError (ASL_ERROR, ASL_MSG_INVALID_EXPRESSION, Field, Field->Value);
+ case EXPOP_MODULO:
+ if (!RightValue)
+ {
+ DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO,
+ Gbl_CurrentField, Gbl_CurrentField->Value);
return (0);
}
+ Result = LeftValue % RightValue;
+ break;
- Value2 = DtResolveInteger (Field, IntegerString);
- DbgPrint (ASL_DEBUG_OUTPUT, "Integer resolved to V2: %8.8X%8.8X\n",
- ACPI_FORMAT_UINT64 (Value2));
+ case EXPOP_ADD:
+ Result = LeftValue + RightValue;
+ break;
- /* Perform the requested operation */
+ case EXPOP_SUBTRACT:
+ Result = LeftValue - RightValue;
+ break;
- switch (*Operator)
- {
- case '-':
- Value -= Value2;
- break;
+ case EXPOP_SHIFT_RIGHT:
+ Result = LeftValue >> RightValue;
+ break;
- case '+':
- Value += Value2;
- break;
+ case EXPOP_SHIFT_LEFT:
+ Result = LeftValue << RightValue;
+ break;
- case '*':
- Value *= Value2;
- break;
+ case EXPOP_LESS:
+ Result = LeftValue < RightValue;
+ break;
- case '|':
- Value |= Value2;
- break;
+ case EXPOP_GREATER:
+ Result = LeftValue > RightValue;
+ break;
- case '&':
- Value &= Value2;
- break;
+ case EXPOP_LESS_EQUAL:
+ Result = LeftValue <= RightValue;
+ break;
- case '^':
- Value ^= Value2;
- break;
+ case EXPOP_GREATER_EQUAL:
+ Result = LeftValue >= RightValue;
+ break;
- case '/':
- if (!Value2)
- {
- DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO, Field, Field->Value);
- return (0);
- }
- Value /= Value2;
- break;
+ case EXPOP_EQUAL:
+ Result = LeftValue = RightValue;
+ break;
- case '%':
- if (!Value2)
- {
- DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO, Field, Field->Value);
- return (0);
- }
- Value %= Value2;
- break;
+ case EXPOP_NOT_EQUAL:
+ Result = LeftValue != RightValue;
+ break;
- default:
+ case EXPOP_AND:
+ Result = LeftValue & RightValue;
+ break;
- /* Unknown operator */
+ case EXPOP_XOR:
+ Result = LeftValue ^ RightValue;
+ break;
- DtFatal (ASL_MSG_INVALID_EXPRESSION, Field, Field->Value);
- break;
- }
+ case EXPOP_OR:
+ Result = LeftValue | RightValue;
+ break;
+
+ case EXPOP_LOGICAL_AND:
+ Result = LeftValue && RightValue;
+ break;
+
+ case EXPOP_LOGICAL_OR:
+ Result = LeftValue || RightValue;
+ break;
+
+ default:
+
+ /* Unknown operator */
+
+ DtFatal (ASL_MSG_INVALID_EXPRESSION,
+ Gbl_CurrentField, Gbl_CurrentField->Value);
+ return (0);
}
- return (Value);
+ DbgPrint (ASL_DEBUG_OUTPUT,
+ "IntegerEval: %s (%8.8X%8.8X %s %8.8X%8.8X) = %8.8X%8.8X\n",
+ Gbl_CurrentField->Value,
+ ACPI_FORMAT_UINT64 (LeftValue),
+ DtGetOpName (Operator),
+ ACPI_FORMAT_UINT64 (RightValue),
+ ACPI_FORMAT_UINT64 (Result));
+
+ return (Result);
}
/******************************************************************************
*
- * FUNCTION: DtResolveInteger
+ * FUNCTION: DtResolveLabel
*
- * PARAMETERS: Field - Field object with string to be resolved
- * IntegerString - Integer to be resolved
+ * PARAMETERS: LabelString - Contains the label
*
- * RETURN: A 64-bit integer value
+ * RETURN: Table offset associated with the label
*
- * DESCRIPTION: Resolve a single integer string to a value. Supports both
- * integer constants and labels.
- *
- * NOTE: References to labels must begin with a dollar sign ($)
+ * DESCRIPTION: Lookup a lable and return its value.
*
*****************************************************************************/
-static UINT64
-DtResolveInteger (
- DT_FIELD *Field,
- char *IntegerString)
+UINT64
+DtResolveLabel (
+ char *LabelString)
{
DT_FIELD *LabelField;
- UINT64 Value = 0;
- char *Message = NULL;
- ACPI_STATUS Status;
- DbgPrint (ASL_DEBUG_OUTPUT, "Resolve Integer: %s\n", IntegerString);
+ DbgPrint (ASL_DEBUG_OUTPUT, "Resolve Label: %s\n", LabelString);
/* Resolve a label reference to an integer (table offset) */
- if (*IntegerString == '$')
+ if (*LabelString != '$')
{
- LabelField = DtLookupLabel (IntegerString);
- if (!LabelField)
- {
- DtError (ASL_ERROR, ASL_MSG_UNKNOWN_LABEL, Field, IntegerString);
- return (0);
- }
-
- /* All we need from the label is the offset in the table */
-
- Value = LabelField->TableOffset;
- return (Value);
+ return (0);
}
- /* Convert string to an actual integer */
-
- Status = DtStrtoul64 (IntegerString, &Value);
- if (ACPI_FAILURE (Status))
+ LabelField = DtLookupLabel (LabelString);
+ if (!LabelField)
{
- if (Status == AE_LIMIT)
- {
- Message = "Constant larger than 64 bits";
- }
- else if (Status == AE_BAD_CHARACTER)
- {
- Message = "Invalid character in constant";
- }
-
- DtError (ASL_ERROR, ASL_MSG_INVALID_HEX_INTEGER, Field, Message);
+ DtError (ASL_ERROR, ASL_MSG_UNKNOWN_LABEL,
+ Gbl_CurrentField, LabelString);
+ return (0);
}
- return (Value);
+ /* All we need from the label is the offset in the table */
+
+ DbgPrint (ASL_DEBUG_OUTPUT, "Resolved Label: 0x%8.8X\n",
+ LabelField->TableOffset);
+
+ return (LabelField->TableOffset);
}
diff --git a/compiler/dtfield.c b/compiler/dtfield.c
index 4b631b6cf583..8c9885bb9df1 100644
--- a/compiler/dtfield.c
+++ b/compiler/dtfield.c
@@ -284,6 +284,7 @@ DtCompileInteger (
{
UINT64 Value;
UINT64 MaxValue;
+ ACPI_STATUS Status;
/* Output buffer byte length must be in range 1-8 */
@@ -297,7 +298,11 @@ DtCompileInteger (
/* Resolve integer expression to a single integer value */
- Value = DtResolveIntegerExpression (Field);
+ Status = DtResolveIntegerExpression (Field, &Value);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
/* Ensure that reserved fields are set to zero */
/* TBD: should we set to zero, or just make this an ERROR? */
diff --git a/compiler/dtio.c b/compiler/dtio.c
index ee3f2478245e..fdbf57d488ed 100644
--- a/compiler/dtio.c
+++ b/compiler/dtio.c
@@ -60,10 +60,6 @@ static void
DtLinkField (
DT_FIELD *Field);
-static void
-DtMergeField (
- char *Value);
-
static ACPI_STATUS
DtParseLine (
char *LineBuffer,
@@ -96,6 +92,7 @@ DtDumpBuffer (
#define DT_SLASH_ASTERISK_COMMENT 3
#define DT_SLASH_SLASH_COMMENT 4
#define DT_END_COMMENT 5
+#define DT_MERGE_LINES 6
static UINT32 Gbl_NextLineOffset;
@@ -226,56 +223,6 @@ DtLinkField (
/******************************************************************************
*
- * FUNCTION: DtMergeField
- *
- * PARAMETERS: Value - Merge this line into previous one
- *
- * RETURN: None
- *
- * DESCRIPTION: Merge a field value to the previous one,
- * probably for a multi-line buffer definition.
- *
- *****************************************************************************/
-
-static void
-DtMergeField (
- char *Value)
-{
- DT_FIELD *Prev;
- DT_FIELD *Next;
- char *NewValue;
- UINT32 PrevLength;
- UINT32 ThisLength;
-
-
- Prev = Next = Gbl_FieldList;
-
- while (Next)
- {
- Prev = Next;
- Next = Next->Next;
- }
-
- if (Prev)
- {
- PrevLength = ACPI_STRLEN (Prev->Value);
- ThisLength = ACPI_STRLEN (Value);
-
- /* Add two for: separator + NULL terminator */
-
- NewValue = UtLocalCalloc (PrevLength + ThisLength + 2);
- ACPI_STRNCPY (NewValue, Prev->Value, PrevLength);
- NewValue[PrevLength] = ' ';
-
- ACPI_STRNCPY ((NewValue + PrevLength + 1), Value, ThisLength);
- ACPI_FREE (Prev->Value);
- Prev->Value = NewValue;
- }
-}
-
-
-/******************************************************************************
- *
* FUNCTION: DtParseLine
*
* PARAMETERS: LineBuffer - Current source code line
@@ -305,6 +252,7 @@ DtParseLine (
DT_FIELD *Field;
UINT32 Column;
UINT32 NameColumn;
+ BOOLEAN IsNullString = FALSE;
if (!LineBuffer)
@@ -372,7 +320,6 @@ DtParseLine (
ACPI_FREE (TmpName);
Start = End = (Colon + 1);
-
while (*End)
{
/* Found left quotation, go to the right quotation and break */
@@ -380,6 +327,13 @@ DtParseLine (
if (*End == '"')
{
End++;
+
+ /* Check for an explicit null string */
+
+ if (*End == '"')
+ {
+ IsNullString = TRUE;
+ }
while (*End && (*End != '"'))
{
End++;
@@ -397,12 +351,11 @@ DtParseLine (
* TBD: Perhaps DtGetNextLine should parse the following type
* of comments also.
*/
- if (*End == '(' ||
- *End == '<')
+ if (*End == '[')
{
+ End--;
break;
}
-
End++;
}
@@ -413,7 +366,9 @@ DtParseLine (
Value = DtTrim (TmpValue);
ACPI_FREE (TmpValue);
- if (ACPI_STRLEN (Name) && Value)
+ /* Create a new field object only if we have a valid value field */
+
+ if ((Value && *Value) || IsNullString)
{
Field = UtLocalCalloc (sizeof (DT_FIELD));
Field->Name = Name;
@@ -425,13 +380,7 @@ DtParseLine (
DtLinkField (Field);
}
- else if (!ACPI_STRLEN (Name))
- {
- /* Handle multi-line buffers (length > 16) */
-
- DtMergeField (Value);
- }
- else
+ else /* Ignore this field, it has no valid data */
{
ACPI_FREE (Name);
ACPI_FREE (Value);
@@ -447,7 +396,7 @@ DtParseLine (
*
* PARAMETERS: Handle - Open file handle for the source file
*
- * RETURN: Filled line buffer and offset of start-of-line (zero on EOF)
+ * RETURN: Filled line buffer and offset of start-of-line (ASL_EOF on EOF)
*
* DESCRIPTION: Get the next valid source line. Removes all comments.
* Ignores empty lines.
@@ -464,6 +413,7 @@ UINT32
DtGetNextLine (
FILE *Handle)
{
+ BOOLEAN LineNotAllBlanks = FALSE;
UINT32 State = DT_NORMAL_TEXT;
UINT32 CurrentLineOffset;
UINT32 i;
@@ -488,7 +438,7 @@ DtGetNextLine (
break;
}
- return (0);
+ return (ASL_EOF);
}
switch (State)
@@ -506,24 +456,45 @@ DtGetNextLine (
case '"':
State = DT_START_QUOTED_STRING;
+ LineNotAllBlanks = TRUE;
i++;
break;
+ case '\\':
+ /*
+ * The continuation char MUST be last char on this line.
+ * Otherwise, it will be assumed to be a valid ASL char.
+ */
+ State = DT_MERGE_LINES;
+ break;
+
case '\n':
CurrentLineOffset = Gbl_NextLineOffset;
Gbl_NextLineOffset = (UINT32) ftell (Handle);
Gbl_CurrentLineNumber++;
- /* Exit if line is complete. Ignore blank lines */
-
- if (i != 0)
+ /*
+ * Exit if line is complete. Ignore empty lines (only \n)
+ * or lines that contain nothing but blanks.
+ */
+ if ((i != 0) && LineNotAllBlanks)
{
- Gbl_CurrentLineBuffer[i+1] = 0; /* Terminate line */
+ Gbl_CurrentLineBuffer[i+1] = 0; /* Terminate string */
return (CurrentLineOffset);
}
+
+ /* Toss this line and start a new one */
+
+ i = 0;
+ LineNotAllBlanks = FALSE;
break;
default:
+ if (c != ' ')
+ {
+ LineNotAllBlanks = TRUE;
+ }
+
i++;
break;
}
@@ -624,14 +595,46 @@ DtGetNextLine (
}
break;
+ case DT_MERGE_LINES:
+
+ if (c != '\n')
+ {
+ /*
+ * This is not a continuation backslash, it is a normal
+ * normal ASL backslash - for example: Scope(\_SB_)
+ */
+ i++; /* Keep the backslash that is already in the buffer */
+
+ ungetc (c, Handle);
+ State = DT_NORMAL_TEXT;
+ }
+ else
+ {
+ /*
+ * This is a continuation line -- a backlash followed
+ * immediately by a newline. Insert a space between the
+ * lines (overwrite the backslash)
+ */
+ Gbl_CurrentLineBuffer[i] = ' ';
+ i++;
+
+ /* Ignore newline, this will merge the lines */
+
+ CurrentLineOffset = Gbl_NextLineOffset;
+ Gbl_NextLineOffset = (UINT32) ftell (Handle);
+ Gbl_CurrentLineNumber++;
+ State = DT_NORMAL_TEXT;
+ }
+ break;
+
default:
DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, "Unknown input state");
- return (0);
+ return (ASL_EOF);
}
}
printf ("ERROR - Input line is too long (max %u)\n", ASL_LINE_BUFFER_SIZE);
- return (0);
+ return (ASL_EOF);
}
@@ -654,6 +657,7 @@ DtScanFile (
{
ACPI_STATUS Status;
UINT32 Offset;
+ DT_FIELD *Next;
ACPI_FUNCTION_NAME (DtScanFile);
@@ -669,7 +673,7 @@ DtScanFile (
/* Scan line-by-line */
- while ((Offset = DtGetNextLine (Handle)))
+ while ((Offset = DtGetNextLine (Handle)) != ASL_EOF)
{
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Line %2.2u/%4.4X - %s",
Gbl_CurrentLineNumber, Offset, Gbl_CurrentLineBuffer));
@@ -681,6 +685,30 @@ DtScanFile (
}
}
+ /* Dump the parse tree if debug enabled */
+
+ if (Gbl_DebugFlag)
+ {
+ Next = Gbl_FieldList;
+ DbgPrint (ASL_DEBUG_OUTPUT, "Tree: %32s %32s %8s %8s %8s %8s %8s %8s\n\n",
+ "Name", "Value", "Line", "ByteOff", "NameCol", "Column", "TableOff", "Flags");
+
+ while (Next)
+ {
+ DbgPrint (ASL_DEBUG_OUTPUT, "Field: %32.32s %32.32s %.8X %.8X %.8X %.8X %.8X %.8X\n",
+ Next->Name,
+ Next->Value,
+ Next->Line,
+ Next->ByteOffset,
+ Next->NameColumn,
+ Next->Column,
+ Next->TableOffset,
+ Next->Flags);
+
+ Next = Next->Next;
+ }
+ }
+
return (Gbl_FieldList);
}
@@ -774,7 +802,7 @@ DtDumpBuffer (
UINT8 BufChar;
- FlPrintFile (FileId, "Output: [%3.3Xh %4.4d% 3d] ",
+ FlPrintFile (FileId, "Output: [%3.3Xh %4.4d %3d] ",
Offset, Offset, Length);
i = 0;
@@ -782,7 +810,7 @@ DtDumpBuffer (
{
if (i >= 16)
{
- FlPrintFile (FileId, "%23s", "");
+ FlPrintFile (FileId, "%24s", "");
}
/* Print 16 hex chars */
@@ -876,9 +904,16 @@ DtWriteFieldToListing (
/* Dump the line as parsed and represented internally */
- FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Parsed: %*s : %s\n",
+ FlPrintFile (ASL_FILE_LISTING_OUTPUT, "Parsed: %*s : %.64s",
Field->Column-4, Field->Name, Field->Value);
+ if (strlen (Field->Value) > 64)
+ {
+ FlPrintFile (ASL_FILE_LISTING_OUTPUT, "...Additional data, length 0x%X\n",
+ strlen (Field->Value));
+ }
+ FlPrintFile (ASL_FILE_LISTING_OUTPUT, "\n");
+
/* Dump the hex data that will be output for this field */
DtDumpBuffer (ASL_FILE_LISTING_OUTPUT, Buffer, Field->TableOffset, Length);
diff --git a/compiler/dtparser.l b/compiler/dtparser.l
new file mode 100644
index 000000000000..d915fb0b28aa
--- /dev/null
+++ b/compiler/dtparser.l
@@ -0,0 +1,133 @@
+%{
+/******************************************************************************
+ *
+ * Module Name: dtparser.l - Flex input file for table compiler lexer
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2011, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include "aslcompiler.h"
+#include "dtparser.y.h"
+
+#define YY_NO_INPUT /* No file input, we use strings only */
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("dtscanner")
+%}
+
+%option noyywrap
+%option nounput
+
+Number [0-9a-fA-F]+
+HexNumber 0[xX][0-9a-fA-F]+
+DecimalNumber 0[dD][0-9]+
+LabelRef $[a-zA-Z][0-9a-zA-Z]*
+WhiteSpace [ \t\v\r]+
+NewLine [\n]
+
+%%
+
+\( return (EXPOP_PAREN_OPEN);
+\) return (EXPOP_PAREN_CLOSE);
+\~ return (EXPOP_ONES_COMPLIMENT);
+\! return (EXPOP_LOGICAL_NOT);
+\* return (EXPOP_MULTIPLY);
+\/ return (EXPOP_DIVIDE);
+\% return (EXPOP_MODULO);
+\+ return (EXPOP_ADD);
+\- return (EXPOP_SUBTRACT);
+">>" return (EXPOP_SHIFT_RIGHT);
+"<<" return (EXPOP_SHIFT_LEFT);
+\< return (EXPOP_LESS);
+\> return (EXPOP_GREATER);
+"<=" return (EXPOP_LESS_EQUAL);
+">=" return (EXPOP_GREATER_EQUAL);
+"==" return (EXPOP_EQUAL);
+"!=" return (EXPOP_NOT_EQUAL);
+\& return (EXPOP_AND);
+\^ return (EXPOP_XOR);
+\| return (EXPOP_OR);
+"&&" return (EXPOP_LOGICAL_AND);
+"||" return (EXPOP_LOGICAL_OR);
+<<EOF>> return (EXPOP_EOF); /* null end-of-string */
+
+{LabelRef} return (EXPOP_LABEL);
+{Number} return (EXPOP_NUMBER);
+{HexNumber} return (EXPOP_HEX_NUMBER);
+{NewLine} return (EXPOP_NEW_LINE);
+{WhiteSpace} /* Ignore */
+
+. return (EXPOP_EOF);
+
+%%
+
+/*
+ * Local support functions
+ */
+YY_BUFFER_STATE LexBuffer;
+
+/******************************************************************************
+ *
+ * FUNCTION: DtInitLexer, DtTerminateLexer
+ *
+ * PARAMETERS: String - Input string to be parsed
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Initialization and termination routines for lexer. Lexer needs
+ * a buffer to handle strings instead of a file.
+ *
+ *****************************************************************************/
+
+int
+DtInitLexer (
+ char *String)
+{
+
+ LexBuffer = yy_scan_string (String);
+ return (LexBuffer == NULL);
+}
+
+void
+DtTerminateLexer (
+ void)
+{
+
+ yy_delete_buffer (LexBuffer);
+} \ No newline at end of file
diff --git a/compiler/dtparser.y b/compiler/dtparser.y
new file mode 100644
index 000000000000..4d449febe750
--- /dev/null
+++ b/compiler/dtparser.y
@@ -0,0 +1,266 @@
+%{
+/******************************************************************************
+ *
+ * Module Name: dtparser.y - Bison input file for table compiler parser
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2011, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define YYDEBUG 1
+#define YYERROR_VERBOSE 1
+
+#include "aslcompiler.h"
+#include "dtcompiler.h"
+
+#define _COMPONENT ACPI_COMPILER
+ ACPI_MODULE_NAME ("dtparser")
+
+UINT64 DtParserResult; /* Global for expression return value */
+
+int DtParserlex (void); /* TBD: not sure why this is needed */
+extern char* DtParsertext;
+extern void DtParsererror (char const * msg);
+#define YYFLAG -32768
+
+%}
+
+%union
+{
+ UINT64 value;
+ UINT32 op;
+}
+
+%type <value> Expression
+
+%token <op> EXPOP_EOF
+%token <op> EXPOP_NEW_LINE
+%token <op> EXPOP_NUMBER
+%token <op> EXPOP_HEX_NUMBER
+%token <op> EXPOP_DECIMAL_NUMBER
+%token <op> EXPOP_LABEL
+%token <op> EXPOP_PAREN_OPEN
+%token <op> EXPOP_PAREN_CLOSE
+
+%left <op> EXPOP_LOGICAL_OR
+%left <op> EXPOP_LOGICAL_AND
+%left <op> EXPOP_OR
+%left <op> EXPOP_XOR
+%left <op> EXPOP_AND
+%left <op> EXPOP_EQUAL EXPOP_NOT_EQUAL
+%left <op> EXPOP_GREATER EXPOP_LESS EXPOP_GREATER_EQUAL EXPOP_LESS_EQUAL
+%left <op> EXPOP_SHIFT_RIGHT EXPOP_SHIFT_LEFT
+%left <op> EXPOP_ADD EXPOP_SUBTRACT
+%left <op> EXPOP_MULTIPLY EXPOP_DIVIDE EXPOP_MODULO
+%right <op> EXPOP_ONES_COMPLIMENT EXPOP_LOGICAL_NOT
+
+%%
+
+/*
+ * Operator precedence rules (from K&R)
+ *
+ * 1) ( )
+ * 2) ! ~ (unary operators that are supported here)
+ * 3) * / %
+ * 4) + -
+ * 5) >> <<
+ * 6) < > <= >=
+ * 7) == !=
+ * 8) &
+ * 9) ^
+ * 10) |
+ * 11) &&
+ * 12) ||
+ */
+Value
+ : Expression EXPOP_NEW_LINE { DtParserResult=$1; return 0; } /* End of line (newline) */
+ | Expression EXPOP_EOF { DtParserResult=$1; return 0; } /* End of string (0) */
+ ;
+
+Expression
+
+ /* Unary operators */
+
+ : EXPOP_LOGICAL_NOT Expression { $$ = DtDoOperator ($2, EXPOP_LOGICAL_NOT, $2);}
+ | EXPOP_ONES_COMPLIMENT Expression { $$ = DtDoOperator ($2, EXPOP_ONES_COMPLIMENT, $2);}
+
+ /* Binary operators */
+
+ | Expression EXPOP_MULTIPLY Expression { $$ = DtDoOperator ($1, EXPOP_MULTIPLY, $3);}
+ | Expression EXPOP_DIVIDE Expression { $$ = DtDoOperator ($1, EXPOP_DIVIDE, $3);}
+ | Expression EXPOP_MODULO Expression { $$ = DtDoOperator ($1, EXPOP_MODULO, $3);}
+ | Expression EXPOP_ADD Expression { $$ = DtDoOperator ($1, EXPOP_ADD, $3);}
+ | Expression EXPOP_SUBTRACT Expression { $$ = DtDoOperator ($1, EXPOP_SUBTRACT, $3);}
+ | Expression EXPOP_SHIFT_RIGHT Expression { $$ = DtDoOperator ($1, EXPOP_SHIFT_RIGHT, $3);}
+ | Expression EXPOP_SHIFT_LEFT Expression { $$ = DtDoOperator ($1, EXPOP_SHIFT_LEFT, $3);}
+ | Expression EXPOP_GREATER Expression { $$ = DtDoOperator ($1, EXPOP_GREATER, $3);}
+ | Expression EXPOP_LESS Expression { $$ = DtDoOperator ($1, EXPOP_LESS, $3);}
+ | Expression EXPOP_GREATER_EQUAL Expression { $$ = DtDoOperator ($1, EXPOP_GREATER_EQUAL, $3);}
+ | Expression EXPOP_LESS_EQUAL Expression { $$ = DtDoOperator ($1, EXPOP_LESS_EQUAL, $3);}
+ | Expression EXPOP_EQUAL Expression { $$ = DtDoOperator ($1, EXPOP_EQUAL, $3);}
+ | Expression EXPOP_NOT_EQUAL Expression { $$ = DtDoOperator ($1, EXPOP_NOT_EQUAL, $3);}
+ | Expression EXPOP_AND Expression { $$ = DtDoOperator ($1, EXPOP_AND, $3);}
+ | Expression EXPOP_XOR Expression { $$ = DtDoOperator ($1, EXPOP_XOR, $3);}
+ | Expression EXPOP_OR Expression { $$ = DtDoOperator ($1, EXPOP_OR, $3);}
+ | Expression EXPOP_LOGICAL_AND Expression { $$ = DtDoOperator ($1, EXPOP_LOGICAL_AND, $3);}
+ | Expression EXPOP_LOGICAL_OR Expression { $$ = DtDoOperator ($1, EXPOP_LOGICAL_OR, $3);}
+
+ /* Parentheses: '(' Expression ')' */
+
+ | EXPOP_PAREN_OPEN Expression
+ EXPOP_PAREN_CLOSE { $$ = $2;}
+
+ /* Label references (prefixed with $) */
+
+ | EXPOP_LABEL { $$ = DtResolveLabel (DtParsertext);}
+
+ /* Default base for a non-prefixed integer is 16 */
+
+ | EXPOP_NUMBER { UtStrtoul64 (DtParsertext, 16, &$$);}
+
+ /* Standard hex number (0x1234) */
+
+ | EXPOP_HEX_NUMBER { UtStrtoul64 (DtParsertext, 16, &$$);}
+
+ /* TBD: Decimal number with prefix (0d1234) - Not supported by UtStrtoul64 at this time */
+
+ | EXPOP_DECIMAL_NUMBER { UtStrtoul64 (DtParsertext, 10, &$$);}
+ ;
+%%
+
+/*
+ * Local support functions, including parser entry point
+ */
+extern DT_FIELD *Gbl_CurrentField;
+#define PR_FIRST_PARSE_OPCODE EXPOP_EOF
+#define PR_YYTNAME_START 3
+
+#ifdef _USE_BERKELEY_YACC
+#define yytname DtParsername[];
+#endif
+
+
+/******************************************************************************
+ *
+ * FUNCTION: DtParsererror
+ *
+ * PARAMETERS: Message - Parser-generated error message
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Handler for parser errors
+ *
+ *****************************************************************************/
+
+void
+DtParsererror (
+ char const *Message)
+{
+ DtError (ASL_ERROR, ASL_MSG_SYNTAX,
+ Gbl_CurrentField, (char *) Message);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: DtGetOpName
+ *
+ * PARAMETERS: ParseOpcode - Parser token (EXPOP_*)
+ *
+ * RETURN: Pointer to the opcode name
+ *
+ * DESCRIPTION: Get the ascii name of the parse opcode for debug output
+ *
+ *****************************************************************************/
+
+char *
+DtGetOpName (
+ UINT32 ParseOpcode)
+{
+
+ /*
+ * First entries (PR_YYTNAME_START) in yytname are special reserved names.
+ * Ignore first 6 characters of name (EXPOP_)
+ */
+ return ((char *) yytname
+ [(ParseOpcode - PR_FIRST_PARSE_OPCODE) + PR_YYTNAME_START] + 6);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: DtEvaluateExpression
+ *
+ * PARAMETERS: ExprString - Expression to be evaluated. Must be
+ * terminated by either a newline or a NUL
+ * string terminator
+ *
+ * RETURN: 64-bit value for the expression
+ *
+ * DESCRIPTION: Main entry point for the DT expression parser
+ *
+ *****************************************************************************/
+
+UINT64
+DtEvaluateExpression (
+ char *ExprString)
+{
+
+ DbgPrint (ASL_DEBUG_OUTPUT,
+ "**** Input expression: %s (Base 16)\n", ExprString);
+
+ /* Point lexer to the input string */
+
+ if (DtInitLexer (ExprString))
+ {
+ DtError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL,
+ Gbl_CurrentField, "Could not initialize lexer");
+ return (0);
+ }
+
+ /* Parse/Evaluate the input string (value returned in DtParserResult) */
+
+ DtParserparse ();
+ DtTerminateLexer ();
+
+ DbgPrint (ASL_DEBUG_OUTPUT,
+ "**** Parser returned value: %u (%8.8X%8.8X)\n",
+ (UINT32) DtParserResult, ACPI_FORMAT_UINT64 (DtParserResult));
+
+ return (DtParserResult);
+}
diff --git a/compiler/dtsubtable.c b/compiler/dtsubtable.c
index 6301492e5025..40659764e775 100644
--- a/compiler/dtsubtable.c
+++ b/compiler/dtsubtable.c
@@ -288,16 +288,58 @@ DtGetSubtableLength (
ACPI_DMTABLE_INFO *Info)
{
UINT32 ByteLength = 0;
+ UINT8 Step;
+ UINT8 i;
/* Walk entire Info table; Null name terminates */
for (; Info->Name; Info++)
{
+ if (!Field)
+ {
+ goto Error;
+ }
+
ByteLength += DtGetFieldLength (Field, Info);
+
+ switch (Info->Opcode)
+ {
+ case ACPI_DMT_GAS:
+ Step = 5;
+ break;
+
+ case ACPI_DMT_HESTNTFY:
+ Step = 9;
+ break;
+
+ default:
+ Step = 1;
+ break;
+ }
+
+ for (i = 0; i < Step; i++)
+ {
+ if (!Field)
+ {
+ goto Error;
+ }
+
+ Field = Field->Next;
+ }
}
return (ByteLength);
+
+Error:
+ if (!Field)
+ {
+ sprintf (MsgBuffer, "Found NULL field - Field name \"%s\" needed",
+ Info->Name);
+ DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, MsgBuffer);
+ }
+
+ return (ASL_EOF);
}
diff --git a/compiler/dttable.c b/compiler/dttable.c
index 0ad4dd4f4311..f43403598dbf 100644
--- a/compiler/dttable.c
+++ b/compiler/dttable.c
@@ -1224,7 +1224,6 @@ DtCompileSlit (
DT_FIELD *FieldList;
UINT32 Localities;
UINT8 *LocalityBuffer;
- UINT32 RemainingData;
Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit,
@@ -1240,22 +1239,17 @@ DtCompileSlit (
Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer);
LocalityBuffer = UtLocalCalloc (Localities);
+ /* Compile each locality buffer */
+
FieldList = *PFieldList;
while (FieldList)
{
- /* Handle multiple-line buffer */
-
- RemainingData = Localities;
- while (RemainingData && FieldList)
- {
- RemainingData = DtCompileBuffer (
- LocalityBuffer + (Localities - RemainingData),
- FieldList->Value, FieldList, RemainingData);
- FieldList = FieldList->Next;
- }
+ DtCompileBuffer (LocalityBuffer,
+ FieldList->Value, FieldList, Localities);
DtCreateSubtable (LocalityBuffer, Localities, &Subtable);
DtInsertSubtable (ParentTable, Subtable);
+ FieldList = FieldList->Next;
}
ACPI_FREE (LocalityBuffer);
@@ -1411,7 +1405,6 @@ DtCompileUefi (
DT_SUBTABLE *Subtable;
DT_SUBTABLE *ParentTable;
DT_FIELD **PFieldList = (DT_FIELD **) List;
- ACPI_DMTABLE_INFO *Info;
UINT16 *DataOffset;
@@ -1436,45 +1429,7 @@ DtCompileUefi (
* operators may be used.
*/
- /* Find any and all labels in the entire generic portion */
-
- DtDetectAllLabels (*PFieldList);
-
- /* Now we can actually compile the parse tree */
-
- while (*PFieldList)
- {
- Info = DtGetGenericTableInfo ((*PFieldList)->Name);
- if (!Info)
- {
- sprintf (MsgBuffer, "Generic data type \"%s\" not found",
- (*PFieldList)->Name);
- DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
- (*PFieldList), MsgBuffer);
-
- *PFieldList = (*PFieldList)->Next;
- continue;
- }
-
- Status = DtCompileTable (PFieldList, Info,
- &Subtable, TRUE);
- if (ACPI_SUCCESS (Status))
- {
- DtInsertSubtable (ParentTable, Subtable);
- }
- else
- {
- *PFieldList = (*PFieldList)->Next;
-
- if (Status == AE_NOT_FOUND)
- {
- sprintf (MsgBuffer, "Generic data type \"%s\" not found",
- (*PFieldList)->Name);
- DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
- (*PFieldList), MsgBuffer);
- }
- }
- }
+ DtCompileGeneric ((void **) PFieldList);
return (AE_OK);
}
@@ -1539,3 +1494,78 @@ DtCompileXsdt (
return (AE_OK);
}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: DtCompileGeneric
+ *
+ * PARAMETERS: List - Current field list pointer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Compile generic unknown table.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+DtCompileGeneric (
+ void **List)
+{
+ ACPI_STATUS Status;
+ DT_SUBTABLE *Subtable;
+ DT_SUBTABLE *ParentTable;
+ DT_FIELD **PFieldList = (DT_FIELD **) List;
+ ACPI_DMTABLE_INFO *Info;
+
+
+ ParentTable = DtPeekSubtable ();
+
+ /*
+ * Compile the "generic" portion of the table. This
+ * part of the table is not predefined and any of the generic
+ * operators may be used.
+ */
+
+ /* Find any and all labels in the entire generic portion */
+
+ DtDetectAllLabels (*PFieldList);
+
+ /* Now we can actually compile the parse tree */
+
+ while (*PFieldList)
+ {
+ Info = DtGetGenericTableInfo ((*PFieldList)->Name);
+ if (!Info)
+ {
+ sprintf (MsgBuffer, "Generic data type \"%s\" not found",
+ (*PFieldList)->Name);
+ DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
+ (*PFieldList), MsgBuffer);
+
+ *PFieldList = (*PFieldList)->Next;
+ continue;
+ }
+
+ Status = DtCompileTable (PFieldList, Info,
+ &Subtable, TRUE);
+ if (ACPI_SUCCESS (Status))
+ {
+ DtInsertSubtable (ParentTable, Subtable);
+ }
+ else
+ {
+ *PFieldList = (*PFieldList)->Next;
+
+ if (Status == AE_NOT_FOUND)
+ {
+ sprintf (MsgBuffer, "Generic data type \"%s\" not found",
+ (*PFieldList)->Name);
+ DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME,
+ (*PFieldList), MsgBuffer);
+ }
+ }
+ }
+
+ return (AE_OK);
+}
diff --git a/compiler/dttemplate.c b/compiler/dttemplate.c
index ce49db2cdd36..122d464129bb 100644
--- a/compiler/dttemplate.c
+++ b/compiler/dttemplate.c
@@ -121,7 +121,8 @@ DtCreateTemplates (
/* Create all known templates if requested */
- if (!ACPI_STRNCMP (Signature, "ALL", 3))
+ if (!ACPI_STRNCMP (Signature, "ALL", 3) ||
+ !ACPI_STRCMP (Signature, "*"))
{
Status = DtCreateAllTemplates ();
return (Status);
diff --git a/compiler/dttemplate.h b/compiler/dttemplate.h
index 79b3a61aeaaf..19545919b390 100644
--- a/compiler/dttemplate.h
+++ b/compiler/dttemplate.h
@@ -587,14 +587,62 @@ const unsigned char TemplateSlic[] =
const unsigned char TemplateSlit[] =
{
- 0x53,0x4C,0x49,0x54,0x3C,0x00,0x00,0x00, /* 00000000 "SLIT<..." */
- 0x01,0x1B,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
+ 0x53,0x4C,0x49,0x54,0xBC,0x01,0x00,0x00, /* 00000000 "SLIT...." */
+ 0x01,0x00,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */
- 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
- 0x28,0x05,0x10,0x20,0x04,0x00,0x00,0x00, /* 00000020 "(.. ...." */
- 0x00,0x00,0x00,0x00,0x0A,0x0F,0x0F,0x0F, /* 00000028 "........" */
- 0x0F,0x0A,0x0F,0x0F,0x0F,0x0F,0x0A,0x0F, /* 00000030 "........" */
- 0x0F,0x0F,0x0F,0x0A /* 00000038 "...." */
+ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
+ 0x16,0x03,0x11,0x20,0x14,0x00,0x00,0x00, /* 00000020 "... ...." */
+ 0x00,0x00,0x00,0x00,0x0A,0x10,0x16,0x17, /* 00000028 "........" */
+ 0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F, /* 00000030 "........" */
+ 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27, /* 00000038 " !"#$%&'" */
+ 0x10,0x0A,0x15,0x16,0x17,0x18,0x19,0x1A, /* 00000040 "........" */
+ 0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22, /* 00000048 "..... !"" */
+ 0x23,0x24,0x25,0x26,0x16,0x15,0x0A,0x10, /* 00000050 "#$%&...." */
+ 0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D, /* 00000058 "........" */
+ 0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25, /* 00000060 ".. !"#$%" */
+ 0x17,0x16,0x10,0x0A,0x15,0x16,0x17,0x18, /* 00000068 "........" */
+ 0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20, /* 00000070 "....... " */
+ 0x21,0x22,0x23,0x24,0x18,0x17,0x16,0x15, /* 00000078 "!"#$...." */
+ 0x0A,0x10,0x16,0x17,0x18,0x19,0x1A,0x1B, /* 00000080 "........" */
+ 0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23, /* 00000088 ".... !"#" */
+ 0x19,0x18,0x17,0x16,0x10,0x0A,0x15,0x16, /* 00000090 "........" */
+ 0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E, /* 00000098 "........" */
+ 0x1F,0x20,0x21,0x22,0x1A,0x19,0x18,0x17, /* 000000A0 ". !"...." */
+ 0x16,0x15,0x0A,0x10,0x16,0x17,0x18,0x19, /* 000000A8 "........" */
+ 0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21, /* 000000B0 "...... !" */
+ 0x1B,0x1A,0x19,0x18,0x17,0x16,0x10,0x0A, /* 000000B8 "........" */
+ 0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C, /* 000000C0 "........" */
+ 0x1D,0x1E,0x1F,0x20,0x1C,0x1B,0x1A,0x19, /* 000000C8 "... ...." */
+ 0x18,0x17,0x16,0x15,0x0A,0x10,0x16,0x17, /* 000000D0 "........" */
+ 0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F, /* 000000D8 "........" */
+ 0x1D,0x1C,0x1B,0x1A,0x19,0x18,0x17,0x16, /* 000000E0 "........" */
+ 0x10,0x0A,0x15,0x16,0x17,0x18,0x19,0x1A, /* 000000E8 "........" */
+ 0x1B,0x1C,0x1D,0x1E,0x1E,0x1D,0x1C,0x1B, /* 000000F0 "........" */
+ 0x1A,0x19,0x18,0x17,0x16,0x15,0x0A,0x10, /* 000000F8 "........" */
+ 0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D, /* 00000100 "........" */
+ 0x1F,0x1E,0x1D,0x1C,0x1B,0x1A,0x19,0x18, /* 00000108 "........" */
+ 0x17,0x16,0x10,0x0A,0x15,0x16,0x17,0x18, /* 00000110 "........" */
+ 0x19,0x1A,0x1B,0x1C,0x20,0x1F,0x1E,0x1D, /* 00000118 ".... ..." */
+ 0x1C,0x1B,0x1A,0x19,0x18,0x17,0x16,0x15, /* 00000120 "........" */
+ 0x0A,0x10,0x16,0x17,0x18,0x19,0x1A,0x1B, /* 00000128 "........" */
+ 0x21,0x20,0x1F,0x1E,0x1D,0x1C,0x1B,0x1A, /* 00000130 "! ......" */
+ 0x19,0x18,0x17,0x16,0x10,0x0A,0x15,0x16, /* 00000138 "........" */
+ 0x17,0x18,0x19,0x1A,0x22,0x21,0x20,0x1F, /* 00000140 "...."! ." */
+ 0x1E,0x1D,0x1C,0x1B,0x1A,0x19,0x18,0x17, /* 00000148 "........" */
+ 0x16,0x15,0x0A,0x10,0x16,0x17,0x18,0x19, /* 00000150 "........" */
+ 0x23,0x22,0x21,0x20,0x1F,0x1E,0x1D,0x1C, /* 00000158 "#"! ...." */
+ 0x1B,0x1A,0x19,0x18,0x17,0x16,0x10,0x0A, /* 00000160 "........" */
+ 0x15,0x16,0x17,0x18,0x24,0x23,0x22,0x21, /* 00000168 "....$#"!" */
+ 0x20,0x1F,0x1E,0x1D,0x1C,0x1B,0x1A,0x19, /* 00000170 " ......." */
+ 0x18,0x17,0x16,0x15,0x0A,0x10,0x16,0x17, /* 00000178 "........" */
+ 0x25,0x24,0x23,0x22,0x21,0x20,0x1F,0x1E, /* 00000180 "%$#"! .." */
+ 0x1D,0x1C,0x1B,0x1A,0x19,0x18,0x17,0x16, /* 00000188 "........" */
+ 0x10,0x0A,0x15,0x16,0x26,0x25,0x24,0x23, /* 00000190 "....&%$#" */
+ 0x22,0x21,0x20,0x1F,0x1E,0x1D,0x1C,0x1B, /* 00000198 ""! ....." */
+ 0x1A,0x19,0x18,0x17,0x16,0x15,0x0A,0x10, /* 000001A0 "........" */
+ 0x27,0x26,0x25,0x24,0x23,0x22,0x21,0x20, /* 000001A8 "'&%$#"! " */
+ 0x1F,0x1E,0x1D,0x1C,0x1B,0x1A,0x19,0x18, /* 000001B0 "........" */
+ 0x17,0x16,0x10,0x0A /* 000001B8 "...." */
};
const unsigned char TemplateSpcr[] =
diff --git a/compiler/dtutils.c b/compiler/dtutils.c
index 321ec9343ac6..a733046df744 100644
--- a/compiler/dtutils.c
+++ b/compiler/dtutils.c
@@ -189,8 +189,16 @@ DtFatal (
DtError (ASL_ERROR, MessageId, FieldObject, ExtraMessage);
+/*
+ * TBD: remove this entire function, DtFatal
+ *
+ * We cannot abort the compiler on error, because we may be compiling a
+ * list of files. We must move on to the next file.
+ */
+#ifdef __OBSOLETE
CmCleanupAndExit ();
exit (1);
+#endif
}
@@ -316,7 +324,6 @@ DtGetFileSize (
* FUNCTION: DtGetFieldValue
*
* PARAMETERS: Field - Current field list pointer
- * Name - Field name
*
* RETURN: Field value
*
@@ -326,23 +333,14 @@ DtGetFileSize (
char *
DtGetFieldValue (
- DT_FIELD *Field,
- char *Name)
+ DT_FIELD *Field)
{
-
- /* Search the field list for the name */
-
- while (Field)
+ if (!Field)
{
- if (!ACPI_STRCMP (Name, Field->Name))
- {
- return (Field->Value);
- }
-
- Field = Field->Next;
+ return (NULL);
}
- return (NULL);
+ return (Field->Value);
}
@@ -479,7 +477,7 @@ DtGetBufferLength (
*
* FUNCTION: DtGetFieldLength
*
- * PARAMETERS: Field - Current field list pointer
+ * PARAMETERS: Field - Current field
* Info - Data table info
*
* RETURN: Field length
@@ -567,7 +565,7 @@ DtGetFieldLength (
break;
case ACPI_DMT_STRING:
- Value = DtGetFieldValue (Field, Info->Name);
+ Value = DtGetFieldValue (Field);
if (Value)
{
ByteLength = ACPI_STRLEN (Value) + 1;
@@ -577,6 +575,7 @@ DtGetFieldLength (
sprintf (MsgBuffer, "Expected \"%s\"", Info->Name);
DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, MsgBuffer);
+ return (0);
}
break;
@@ -589,7 +588,7 @@ DtGetFieldLength (
break;
case ACPI_DMT_BUFFER:
- Value = DtGetFieldValue (Field, Info->Name);
+ Value = DtGetFieldValue (Field);
if (Value)
{
ByteLength = DtGetBufferLength (Value);
@@ -599,6 +598,7 @@ DtGetFieldLength (
sprintf (MsgBuffer, "Expected \"%s\"", Info->Name);
DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, MsgBuffer);
+ return (0);
}
break;
@@ -612,7 +612,7 @@ DtGetFieldLength (
break;
case ACPI_DMT_UNICODE:
- Value = DtGetFieldValue (Field, Info->Name);
+ Value = DtGetFieldValue (Field);
/* TBD: error if Value is NULL? (as below?) */
@@ -621,7 +621,7 @@ DtGetFieldLength (
default:
DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, "Invalid table opcode");
- break;
+ return (0);
}
return (ByteLength);