summaryrefslogtreecommitdiff
path: root/source/compiler/aslcodegen.c
diff options
context:
space:
mode:
authorJung-uk Kim <jkim@FreeBSD.org>2015-11-25 21:04:42 +0000
committerJung-uk Kim <jkim@FreeBSD.org>2015-11-25 21:04:42 +0000
commitb9098066cd6284319bca922f13e59517f774a103 (patch)
treef01fd6c9053cb01ed84c00cb42ee789adafceaf5 /source/compiler/aslcodegen.c
parent1e24cf365bc9c8df179b145c90d52852724e54ee (diff)
Notes
Diffstat (limited to 'source/compiler/aslcodegen.c')
-rw-r--r--source/compiler/aslcodegen.c133
1 files changed, 93 insertions, 40 deletions
diff --git a/source/compiler/aslcodegen.c b/source/compiler/aslcodegen.c
index dc8b7d51e626..cb3a4a5c7831 100644
--- a/source/compiler/aslcodegen.c
+++ b/source/compiler/aslcodegen.c
@@ -168,28 +168,28 @@ CgAmlWriteWalk (
}
DbgPrint (ASL_TREE_OUTPUT,
- "%08X %04X %04X %01X %04X %04X %04X %04X "
- "%08X %08X %08X %08X %08X %08X %04X %02d %02d %02d %02d %02d\n",
- /* 1 */ (UINT32) Op->Asl.Value.Integer,
- /* 2 */ Op->Asl.ParseOpcode,
- /* 3 */ Op->Asl.AmlOpcode,
- /* 4 */ Op->Asl.AmlOpcodeLength,
- /* 5 */ Op->Asl.AmlPkgLenBytes,
- /* 6 */ Op->Asl.AmlLength,
- /* 7 */ Op->Asl.AmlSubtreeLength,
- /* 8 */ Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0,
- /* 9 */ Op,
- /* 10 */ Op->Asl.Parent,
- /* 11 */ Op->Asl.Child,
- /* 12 */ Op->Asl.Next,
- /* 13 */ Op->Asl.CompileFlags,
- /* 14 */ Op->Asl.AcpiBtype,
- /* 15 */ Op->Asl.FinalAmlLength,
- /* 16 */ Op->Asl.Column,
- /* 17 */ Op->Asl.LineNumber,
- /* 18 */ Op->Asl.EndLine,
- /* 19 */ Op->Asl.LogicalLineNumber,
- /* 20 */ Op->Asl.EndLogicalLine);
+ "%08X %04X %04X %01X %04X %04X %04X %04X "
+ "%08X %08X %08X %08X %08X %08X %04X %02d %02d %02d %02d %02d\n",
+ /* 1 */ (UINT32) Op->Asl.Value.Integer,
+ /* 2 */ Op->Asl.ParseOpcode,
+ /* 3 */ Op->Asl.AmlOpcode,
+ /* 4 */ Op->Asl.AmlOpcodeLength,
+ /* 5 */ Op->Asl.AmlPkgLenBytes,
+ /* 6 */ Op->Asl.AmlLength,
+ /* 7 */ Op->Asl.AmlSubtreeLength,
+ /* 8 */ Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0,
+ /* 9 */ Op,
+ /* 10 */ Op->Asl.Parent,
+ /* 11 */ Op->Asl.Child,
+ /* 12 */ Op->Asl.Next,
+ /* 13 */ Op->Asl.CompileFlags,
+ /* 14 */ Op->Asl.AcpiBtype,
+ /* 15 */ Op->Asl.FinalAmlLength,
+ /* 16 */ Op->Asl.Column,
+ /* 17 */ Op->Asl.LineNumber,
+ /* 18 */ Op->Asl.EndLine,
+ /* 19 */ Op->Asl.LogicalLineNumber,
+ /* 20 */ Op->Asl.EndLogicalLine);
/* Generate the AML for this node */
@@ -274,7 +274,8 @@ CgWriteAmlOpcode (
/* These opcodes should not get here */
printf ("Found a node with an unassigned AML opcode\n");
- FlPrintFile (ASL_FILE_STDERR, "Found a node with an unassigned AML opcode\n");
+ FlPrintFile (ASL_FILE_STDERR,
+ "Found a node with an unassigned AML opcode\n");
return;
case AML_INT_RESERVEDFIELD_OP:
@@ -357,8 +358,10 @@ CgWriteAmlOpcode (
*/
PkgLen.Len >>= 4;
- /* Now we can write the remaining bytes - either 1, 2, or 3 bytes */
-
+ /*
+ * Now we can write the remaining bytes -
+ * either 1, 2, or 3 bytes
+ */
for (i = 0; i < (UINT32) (Op->Asl.AmlPkgLenBytes - 1); i++)
{
CgLocalWriteAmlData (Op, &PkgLen.LenBytes[i], 1);
@@ -467,50 +470,100 @@ 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: CgCloseTable
+ * FUNCTION: CgUpdateHeader
*
- * PARAMETERS: None.
+ * PARAMETERS: Op - Op for the Definition Block
*
* RETURN: None.
*
* DESCRIPTION: Complete the ACPI table by calculating the checksum and
- * re-writing the header.
+ * re-writing the header for the input definition block
*
******************************************************************************/
static void
-CgCloseTable (
- void)
+CgUpdateHeader (
+ ACPI_PARSE_OBJECT *Op)
{
signed char Sum;
+ UINT32 i;
+ UINT32 Length;
UINT8 FileByte;
+ UINT8 Checksum;
- FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
- Sum = 0;
+ /* Calculate the checksum over the entire definition block */
- /* Calculate the checksum over the entire file */
+ Sum = 0;
+ Length = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength;
+ FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset);
- while (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) == AE_OK)
+ 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);
}
- /* Re-write the table header with the checksum */
+ Checksum = (UINT8) (0 - Sum);
+
+ /* Re-write the the checksum byte */
- TableHeader.Checksum = (UINT8) (0 - Sum);
+ FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset +
+ ACPI_OFFSET (ACPI_TABLE_HEADER, Checksum));
- FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
- CgLocalWriteAmlData (NULL, &TableHeader, sizeof (ACPI_TABLE_HEADER));
+ FlWriteFile (ASL_FILE_AML_OUTPUT, &Checksum, 1);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: CgCloseTable
+ *
+ * PARAMETERS: None.
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Complete the ACPI table by calculating the checksum and
+ * re-writing each table header. This allows support for
+ * multiple definition blocks in a single source file.
+ *
+ ******************************************************************************/
+
+static void
+CgCloseTable (
+ void)
+{
+ ACPI_PARSE_OBJECT *Op;
+
+
+ /* Process all definition blocks */
+
+ Op = RootNode->Asl.Child;
+ while (Op)
+ {
+ CgUpdateHeader (Op);
+ Op = Op->Asl.Next;
+ }
}
@@ -586,7 +639,7 @@ CgWriteNode (
break;
- case PARSEOP_DEFINITIONBLOCK:
+ case PARSEOP_DEFINITION_BLOCK:
CgWriteTableHeader (Op);
break;