mirror of
https://github.com/acpica/acpica/
synced 2025-02-25 01:44:33 +03:00
iASL: Add support for multiple ACPI tables in a single ASL file.
Initial support to simply compile the file to a single AML file. Probably mostly useful for testing/debugging purposes.
This commit is contained in:
parent
64b8d2b4c4
commit
5cdee2df86
@ -478,7 +478,7 @@ AnIsResultUsed (
|
||||
/* Not used if one of these is the parent */
|
||||
|
||||
case PARSEOP_METHOD:
|
||||
case PARSEOP_DEFINITIONBLOCK:
|
||||
case PARSEOP_DEFINITION_BLOCK:
|
||||
case PARSEOP_ELSE:
|
||||
|
||||
return (FALSE);
|
||||
|
@ -542,10 +542,68 @@ CgWriteTableHeader (
|
||||
|
||||
/* Table length. Checksum zero for now, will rewrite later */
|
||||
|
||||
TableHeader.Length = Gbl_TableLength;
|
||||
TableHeader.Length = sizeof (ACPI_TABLE_HEADER) +
|
||||
Op->Asl.AmlSubtreeLength;
|
||||
TableHeader.Checksum = 0;
|
||||
|
||||
Op->Asl.FinalAmlOffset = ftell (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle);
|
||||
|
||||
/* Write entire header and clear the table header global */
|
||||
|
||||
CgLocalWriteAmlData (Op, &TableHeader, sizeof (ACPI_TABLE_HEADER));
|
||||
memset (&TableHeader, 0, sizeof (ACPI_TABLE_HEADER));
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* FUNCTION: CgUpdateHeader
|
||||
*
|
||||
* PARAMETERS: Op - Op for the Definition Block
|
||||
*
|
||||
* RETURN: None.
|
||||
*
|
||||
* DESCRIPTION: Complete the ACPI table by calculating the checksum and
|
||||
* re-writing the header for the input definition block
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
static void
|
||||
CgUpdateHeader (
|
||||
ACPI_PARSE_OBJECT *Op)
|
||||
{
|
||||
signed char Sum;
|
||||
UINT32 i;
|
||||
UINT32 Length;
|
||||
UINT8 FileByte;
|
||||
UINT8 Checksum;
|
||||
|
||||
|
||||
/* Calculate the checksum over the entire definition block */
|
||||
|
||||
Sum = 0;
|
||||
Length = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength;
|
||||
FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset);
|
||||
|
||||
for (i = 0; i < Length; i++)
|
||||
{
|
||||
if (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) != AE_OK)
|
||||
{
|
||||
printf ("EOF while reading checksum bytes\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Sum = (signed char) (Sum + FileByte);
|
||||
}
|
||||
|
||||
Checksum = (UINT8) (0 - Sum);
|
||||
|
||||
/* Re-write the the checksum byte */
|
||||
|
||||
FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset +
|
||||
ACPI_OFFSET (ACPI_TABLE_HEADER, Checksum));
|
||||
|
||||
FlWriteFile (ASL_FILE_AML_OUTPUT, &Checksum, 1);
|
||||
}
|
||||
|
||||
|
||||
@ -558,7 +616,8 @@ CgWriteTableHeader (
|
||||
* RETURN: None.
|
||||
*
|
||||
* DESCRIPTION: Complete the ACPI table by calculating the checksum and
|
||||
* re-writing the header.
|
||||
* re-writing each table header. This allows support for
|
||||
* multiple definition blocks in a single source file.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
@ -566,26 +625,17 @@ static void
|
||||
CgCloseTable (
|
||||
void)
|
||||
{
|
||||
signed char Sum;
|
||||
UINT8 FileByte;
|
||||
ACPI_PARSE_OBJECT *Op;
|
||||
|
||||
|
||||
FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
|
||||
Sum = 0;
|
||||
/* Process all definition blocks */
|
||||
|
||||
/* Calculate the checksum over the entire file */
|
||||
|
||||
while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) == AE_OK)
|
||||
Op = RootNode->Asl.Child;
|
||||
while (Op)
|
||||
{
|
||||
Sum = (signed char) (Sum + FileByte);
|
||||
CgUpdateHeader (Op);
|
||||
Op = Op->Asl.Next;
|
||||
}
|
||||
|
||||
/* Re-write the table header with the checksum */
|
||||
|
||||
TableHeader.Checksum = (UINT8) (0 - Sum);
|
||||
|
||||
FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
|
||||
CgLocalWriteAmlData (NULL, &TableHeader, sizeof (ACPI_TABLE_HEADER));
|
||||
}
|
||||
|
||||
|
||||
@ -661,7 +711,7 @@ CgWriteNode (
|
||||
|
||||
break;
|
||||
|
||||
case PARSEOP_DEFINITIONBLOCK:
|
||||
case PARSEOP_DEFINITION_BLOCK:
|
||||
|
||||
CgWriteTableHeader (Op);
|
||||
break;
|
||||
|
@ -238,7 +238,7 @@ CmDoCompile (
|
||||
|
||||
LsDumpParseTree ();
|
||||
|
||||
OpcGetIntegerWidth (RootNode);
|
||||
OpcGetIntegerWidth (RootNode->Asl.Child);
|
||||
UtEndEvent (Event);
|
||||
|
||||
/* Pre-process parse tree for any operator transforms */
|
||||
|
@ -282,7 +282,7 @@ NamePathTail [.]{NameSeg}
|
||||
"Debug" { count (1); return (PARSEOP_DEBUG); }
|
||||
"Decrement" { count (3); return (PARSEOP_DECREMENT); }
|
||||
"Default" { count (3); return (PARSEOP_DEFAULT); }
|
||||
"DefinitionBlock" { count (1); return (PARSEOP_DEFINITIONBLOCK); }
|
||||
"DefinitionBlock" { count (1); return (PARSEOP_DEFINITION_BLOCK); }
|
||||
"DeRefOf" { count (3); return (PARSEOP_DEREFOF); }
|
||||
"Device" { count (2); return (PARSEOP_DEVICE); }
|
||||
"Divide" { count (3); return (PARSEOP_DIVIDE); }
|
||||
|
@ -405,7 +405,7 @@ CgGenerateAmlLengths (
|
||||
|
||||
switch (Op->Asl.ParseOpcode)
|
||||
{
|
||||
case PARSEOP_DEFINITIONBLOCK:
|
||||
case PARSEOP_DEFINITION_BLOCK:
|
||||
|
||||
Gbl_TableLength = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength;
|
||||
break;
|
||||
|
@ -389,7 +389,7 @@ LsWriteNodeToListing (
|
||||
{
|
||||
switch (Op->Asl.ParseOpcode)
|
||||
{
|
||||
case PARSEOP_DEFINITIONBLOCK:
|
||||
case PARSEOP_DEFINITION_BLOCK:
|
||||
case PARSEOP_METHODCALL:
|
||||
case PARSEOP_INCLUDE:
|
||||
case PARSEOP_INCLUDE_END:
|
||||
@ -435,7 +435,7 @@ LsWriteNodeToListing (
|
||||
|
||||
switch (Op->Asl.ParseOpcode)
|
||||
{
|
||||
case PARSEOP_DEFINITIONBLOCK:
|
||||
case PARSEOP_DEFINITION_BLOCK:
|
||||
|
||||
LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);
|
||||
|
||||
|
@ -551,6 +551,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] =
|
||||
/* HORIZONTALOFFSET */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
|
||||
/* PRINTF */ OP_TABLE_ENTRY (AML_STORE_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE),
|
||||
/* FPRINTF */ OP_TABLE_ENTRY (AML_STORE_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE),
|
||||
/* ASLCODE */ OP_TABLE_ENTRY (0, 0, 0, 0)
|
||||
/*! [End] no source code translation !*/
|
||||
|
||||
};
|
||||
|
@ -573,9 +573,10 @@ MtCheckNamedObjectInMethod (
|
||||
const ACPI_OPCODE_INFO *OpInfo;
|
||||
|
||||
|
||||
/* We don't care about actual method declarations */
|
||||
/* We don't care about actual method declarations or scopes */
|
||||
|
||||
if (Op->Asl.AmlOpcode == AML_METHOD_OP)
|
||||
if ((Op->Asl.AmlOpcode == AML_METHOD_OP) ||
|
||||
(Op->Asl.AmlOpcode == AML_SCOPE_OP))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ OpcSetOptimalIntegerSize (
|
||||
*/
|
||||
if (Op->Asl.Parent &&
|
||||
Op->Asl.Parent->Asl.Parent &&
|
||||
(Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK))
|
||||
(Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK))
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
@ -1206,7 +1206,7 @@ OpnGenerateAmlOperands (
|
||||
|
||||
switch (Op->Asl.ParseOpcode)
|
||||
{
|
||||
case PARSEOP_DEFINITIONBLOCK:
|
||||
case PARSEOP_DEFINITION_BLOCK:
|
||||
|
||||
OpnDoDefinitionBlock (Op);
|
||||
break;
|
||||
|
@ -518,7 +518,7 @@ OptOptimizeNameDeclaration (
|
||||
|
||||
|
||||
if (((CurrentNode == AcpiGbl_RootNode) ||
|
||||
(Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK)) &&
|
||||
(Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK)) &&
|
||||
(ACPI_IS_ROOT_PREFIX (AmlNameString[0])))
|
||||
{
|
||||
/*
|
||||
|
@ -126,11 +126,12 @@ NoEcho('
|
||||
* Root term. Allow multiple #line directives before the definition block
|
||||
* to handle output from preprocessors
|
||||
*/
|
||||
ASLCode
|
||||
: DefinitionBlockTerm
|
||||
AslCode
|
||||
: DefinitionBlockList {$<n>$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_ASL_CODE),1, $1);}
|
||||
| error {YYABORT; $$ = NULL;}
|
||||
;
|
||||
|
||||
|
||||
/*
|
||||
* Note concerning support for "module-level code".
|
||||
*
|
||||
@ -147,7 +148,7 @@ ASLCode
|
||||
* of Type1 and Type2 opcodes at module level.
|
||||
*/
|
||||
DefinitionBlockTerm
|
||||
: PARSEOP_DEFINITIONBLOCK '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEFINITIONBLOCK);}
|
||||
: PARSEOP_DEFINITION_BLOCK '(' {$<n>$ = TrCreateLeafNode (PARSEOP_DEFINITION_BLOCK);}
|
||||
String ','
|
||||
String ','
|
||||
ByteConst ','
|
||||
@ -158,6 +159,12 @@ DefinitionBlockTerm
|
||||
'{' TermList '}' {$$ = TrLinkChildren ($<n>3,7,$4,$6,$8,$10,$12,$14,$18);}
|
||||
;
|
||||
|
||||
DefinitionBlockList
|
||||
: DefinitionBlockTerm
|
||||
| DefinitionBlockTerm
|
||||
DefinitionBlockList {$$ = TrLinkPeerNodes (2, $1,$2);}
|
||||
;
|
||||
|
||||
SuperName
|
||||
: NameString {}
|
||||
| ArgTerm {}
|
||||
|
@ -196,7 +196,7 @@ NoEcho('
|
||||
%token <i> PARSEOP_DECREMENT
|
||||
%token <i> PARSEOP_DEFAULT
|
||||
%token <i> PARSEOP_DEFAULT_ARG
|
||||
%token <i> PARSEOP_DEFINITIONBLOCK
|
||||
%token <i> PARSEOP_DEFINITION_BLOCK
|
||||
%token <i> PARSEOP_DEREFOF
|
||||
%token <i> PARSEOP_DEVICE
|
||||
%token <i> PARSEOP_DEVICEPOLARITY_HIGH
|
||||
@ -536,6 +536,9 @@ NoEcho('
|
||||
/* PARSEOP_EXP_PAREN_OPEN */
|
||||
/* PARSEOP_EXP_PAREN_CLOSE */
|
||||
|
||||
|
||||
%token <i> PARSEOP_ASL_CODE
|
||||
|
||||
/*
|
||||
* Special functions. These should probably stay at the end of this
|
||||
* table.
|
||||
|
@ -370,7 +370,7 @@ TrTransformSubtree (
|
||||
|
||||
switch (Op->Asl.ParseOpcode)
|
||||
{
|
||||
case PARSEOP_DEFINITIONBLOCK:
|
||||
case PARSEOP_DEFINITION_BLOCK:
|
||||
|
||||
TrDoDefinitionBlock (Op);
|
||||
break;
|
||||
@ -718,7 +718,7 @@ TrDoSwitch (
|
||||
|
||||
Next = StartNode;
|
||||
while ((Next->Asl.ParseOpcode != PARSEOP_METHOD) &&
|
||||
(Next->Asl.ParseOpcode != PARSEOP_DEFINITIONBLOCK))
|
||||
(Next->Asl.ParseOpcode != PARSEOP_DEFINITION_BLOCK))
|
||||
{
|
||||
Next = Next->Asl.Parent;
|
||||
}
|
||||
|
@ -1032,9 +1032,15 @@ TrCreateNode (
|
||||
|
||||
switch (ParseOpcode)
|
||||
{
|
||||
case PARSEOP_DEFINITIONBLOCK:
|
||||
case PARSEOP_ASL_CODE:
|
||||
|
||||
RootNode = Op;
|
||||
Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
|
||||
DbgPrint (ASL_PARSE_OUTPUT, "ASLCODE (Tree Completed)->");
|
||||
break;
|
||||
|
||||
case PARSEOP_DEFINITION_BLOCK:
|
||||
|
||||
DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->");
|
||||
break;
|
||||
|
||||
@ -1155,9 +1161,15 @@ TrLinkChildren (
|
||||
|
||||
switch (Op->Asl.ParseOpcode)
|
||||
{
|
||||
case PARSEOP_DEFINITIONBLOCK:
|
||||
case PARSEOP_ASL_CODE:
|
||||
|
||||
RootNode = Op;
|
||||
Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
|
||||
DbgPrint (ASL_PARSE_OUTPUT, "ASLCODE (Tree Completed)->");
|
||||
break;
|
||||
|
||||
case PARSEOP_DEFINITION_BLOCK:
|
||||
|
||||
DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->");
|
||||
break;
|
||||
|
||||
|
@ -123,12 +123,13 @@ NoEcho('
|
||||
*****************************************************************************/
|
||||
|
||||
%type <n> ArgList
|
||||
%type <n> ASLCode
|
||||
%type <n> AslCode
|
||||
%type <n> BufferData
|
||||
%type <n> BufferTermData
|
||||
%type <n> CompilerDirective
|
||||
%type <n> DataObject
|
||||
%type <n> DefinitionBlockTerm
|
||||
%type <n> DefinitionBlockList
|
||||
%type <n> IntegerData
|
||||
%type <n> NamedObject
|
||||
%type <n> NameSpaceModifier
|
||||
|
Loading…
x
Reference in New Issue
Block a user