diff options
Diffstat (limited to 'source/compiler')
-rw-r--r-- | source/compiler/asloffset.c | 172 | ||||
-rw-r--r-- | source/compiler/asloperands.c | 9 | ||||
-rw-r--r-- | source/compiler/asloptions.c | 2 | ||||
-rw-r--r-- | source/compiler/dttemplate.c | 23 |
4 files changed, 152 insertions, 54 deletions
diff --git a/source/compiler/asloffset.c b/source/compiler/asloffset.c index 25e5b0f..b2fe775 100644 --- a/source/compiler/asloffset.c +++ b/source/compiler/asloffset.c @@ -57,10 +57,12 @@ static void LsEmitOffsetTableEntry ( UINT32 FileId, ACPI_NAMESPACE_NODE *Node, + UINT32 NamepathOffset, UINT32 Offset, char *OpName, UINT64 Value, - UINT8 AmlOpcode); + UINT8 AmlOpcode, + UINT16 ParentOpcode); /******************************************************************************* @@ -94,7 +96,8 @@ LsAmlOffsetWalk ( UINT32 FileId = (UINT32) ACPI_TO_INTEGER (Context); ACPI_NAMESPACE_NODE *Node; UINT32 Length; - UINT32 OffsetOfOpcode; + UINT32 NamepathOffset; + UINT32 DataOffset; ACPI_PARSE_OBJECT *NextOp; @@ -119,8 +122,9 @@ LsAmlOffsetWalk ( if ((Node->Type == ACPI_TYPE_LOCAL_RESOURCE) && (Op->Asl.CompileFlags & NODE_IS_RESOURCE_DESC)) { - LsEmitOffsetTableEntry (FileId, Node, Gbl_CurrentAmlOffset, - Op->Asl.ParseOpName, 0, Op->Asl.Extra); + LsEmitOffsetTableEntry (FileId, Node, 0, Gbl_CurrentAmlOffset, + Op->Asl.ParseOpName, 0, Op->Asl.Extra, AML_BUFFER_OP); + Gbl_CurrentAmlOffset += Op->Asl.FinalAmlLength; return (AE_OK); } @@ -138,22 +142,25 @@ LsAmlOffsetWalk ( } Length = Op->Asl.FinalAmlLength; + NamepathOffset = Gbl_CurrentAmlOffset + Length; /* Get to the NameSeg/NamePath Op (and length of the name) */ Op = Op->Asl.Child; - OffsetOfOpcode = Length + Op->Asl.FinalAmlLength; + + /* Get offset of last nameseg and the actual data */ + + NamepathOffset = Gbl_CurrentAmlOffset + Length + + (Op->Asl.FinalAmlLength - ACPI_NAME_SIZE); + + DataOffset = Gbl_CurrentAmlOffset + Length + + Op->Asl.FinalAmlLength; /* Get actual value associated with the name */ Op = Op->Asl.Next; switch (Op->Asl.AmlOpcode) { - /* - * We are only interested in integer constants that can be changed - * at boot time. Note, the One/Ones/Zero opcodes are considered - * non-changeable, so we ignore them here. - */ case AML_BYTE_OP: case AML_WORD_OP: case AML_DWORD_OP: @@ -161,22 +168,32 @@ LsAmlOffsetWalk ( /* The +1 is to handle the integer size prefix (opcode) */ - LsEmitOffsetTableEntry (FileId, Node, - (Gbl_CurrentAmlOffset + OffsetOfOpcode + 1), + LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, (DataOffset + 1), Op->Asl.ParseOpName, Op->Asl.Value.Integer, - (UINT8) Op->Asl.AmlOpcode); + (UINT8) Op->Asl.AmlOpcode, AML_NAME_OP); + break; + + case AML_ONE_OP: + case AML_ONES_OP: + case AML_ZERO_OP: + + /* For these, offset will point to the opcode */ + + LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, DataOffset, + Op->Asl.ParseOpName, Op->Asl.Value.Integer, + (UINT8) Op->Asl.AmlOpcode, AML_NAME_OP); break; case AML_PACKAGE_OP: case AML_VAR_PACKAGE_OP: + /* Get the package element count */ + NextOp = Op->Asl.Child; - LsEmitOffsetTableEntry (FileId, Node, - (Gbl_CurrentAmlOffset + OffsetOfOpcode), - Op->Asl.ParseOpName, - NextOp->Asl.Value.Integer, - (UINT8) Op->Asl.AmlOpcode); + LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, DataOffset, + Op->Asl.ParseOpName, NextOp->Asl.Value.Integer, + (UINT8) Op->Asl.AmlOpcode, AML_NAME_OP); break; default: @@ -195,7 +212,14 @@ LsAmlOffsetWalk ( /* Get the name/namepath node */ NextOp = Op->Asl.Child; - OffsetOfOpcode = Length + NextOp->Asl.FinalAmlLength + 1; + + /* Get offset of last nameseg and the actual data */ + + NamepathOffset = Gbl_CurrentAmlOffset + Length + + (NextOp->Asl.FinalAmlLength - ACPI_NAME_SIZE); + + DataOffset = Gbl_CurrentAmlOffset + Length + + (NextOp->Asl.FinalAmlLength + 1); /* Get the SpaceId node, then the Offset (address) node */ @@ -214,10 +238,9 @@ LsAmlOffsetWalk ( case AML_DWORD_OP: case AML_QWORD_OP: - LsEmitOffsetTableEntry (FileId, Node, - (Gbl_CurrentAmlOffset + OffsetOfOpcode + 1), + LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, (DataOffset + 1), Op->Asl.ParseOpName, NextOp->Asl.Value.Integer, - (UINT8) NextOp->Asl.AmlOpcode); + (UINT8) NextOp->Asl.AmlOpcode, AML_REGION_OP); Gbl_CurrentAmlOffset += Length; return (AE_OK); @@ -237,15 +260,62 @@ LsAmlOffsetWalk ( NextOp = Op->Asl.Child; - /* Point to the *last* nameseg in the namepath */ + /* Get offset of last nameseg and the actual data (flags byte) */ - OffsetOfOpcode = NextOp->Asl.FinalAmlLength - ACPI_NAME_SIZE; + NamepathOffset = Gbl_CurrentAmlOffset + Length + + (NextOp->Asl.FinalAmlLength - ACPI_NAME_SIZE); - LsEmitOffsetTableEntry (FileId, Node, - (Gbl_CurrentAmlOffset + OffsetOfOpcode + Length), - Op->Asl.ParseOpName, - *((UINT32 *) &NextOp->Asl.Value.Buffer[OffsetOfOpcode]), - (UINT8) Op->Asl.AmlOpcode); + DataOffset = Gbl_CurrentAmlOffset + Length + + NextOp->Asl.FinalAmlLength; + + /* Get the flags byte Op */ + + NextOp = NextOp->Asl.Next; + + LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, DataOffset, + Op->Asl.ParseOpName, NextOp->Asl.Value.Integer, + (UINT8) Op->Asl.AmlOpcode, AML_METHOD_OP); + break; + + case AML_PROCESSOR_OP: + + /* Processor (Namepath, ProcessorId, Address, Length) */ + + Length = Op->Asl.FinalAmlLength; + NextOp = Op->Asl.Child; /* Get Namepath */ + + /* Get offset of last nameseg and the actual data (PBlock address) */ + + NamepathOffset = Gbl_CurrentAmlOffset + Length + + (NextOp->Asl.FinalAmlLength - ACPI_NAME_SIZE); + + DataOffset = Gbl_CurrentAmlOffset + Length + + (NextOp->Asl.FinalAmlLength + 1); + + NextOp = NextOp->Asl.Next; /* Get ProcessorID (BYTE) */ + NextOp = NextOp->Asl.Next; /* Get Address (DWORD) */ + + LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, DataOffset, + Op->Asl.ParseOpName, NextOp->Asl.Value.Integer, + (UINT8) AML_DWORD_OP, AML_PROCESSOR_OP); + break; + + case AML_DEVICE_OP: + case AML_SCOPE_OP: + case AML_THERMAL_ZONE_OP: + + /* Device/Scope/ThermalZone (Namepath) */ + + Length = Op->Asl.FinalAmlLength; + NextOp = Op->Asl.Child; /* Get Namepath */ + + /* Get offset of last nameseg */ + + NamepathOffset = Gbl_CurrentAmlOffset + Length + + (NextOp->Asl.FinalAmlLength - ACPI_NAME_SIZE); + + LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, 0, + Op->Asl.ParseOpName, 0, (UINT8) 0, Op->Asl.AmlOpcode); break; default: @@ -267,6 +337,7 @@ LsAmlOffsetWalk ( * OpName - Name of the AML opcode * Value - Current value of the AML field * AmlOpcode - Opcode associated with the field + * ObjectType - ACPI object type * * RETURN: None * @@ -278,10 +349,12 @@ static void LsEmitOffsetTableEntry ( UINT32 FileId, ACPI_NAMESPACE_NODE *Node, + UINT32 NamepathOffset, UINT32 Offset, char *OpName, UINT64 Value, - UINT8 AmlOpcode) + UINT8 AmlOpcode, + UINT16 ParentOpcode) { ACPI_BUFFER TargetPath; ACPI_STATUS Status; @@ -308,8 +381,9 @@ LsEmitOffsetTableEntry ( * Max Length for Integers is 8 bytes. */ FlPrintFile (FileId, - " {%-29s 0x%8.8X, 0x%2.2X, 0x%8.8X%8.8X}, /* %s */\n", - MsgBuffer, Offset, AmlOpcode, ACPI_FORMAT_UINT64 (Value), OpName); + " {%-29s 0x%4.4X, 0x%8.8X, 0x%2.2X, 0x%8.8X, 0x%8.8X%8.8X}, /* %s */\n", + MsgBuffer, ParentOpcode, NamepathOffset, AmlOpcode, + Offset, ACPI_FORMAT_UINT64 (Value), OpName); } @@ -335,10 +409,12 @@ LsDoOffsetTableHeader ( "#define __AML_OFFSET_TABLE_H\n\n"); FlPrintFile (FileId, "typedef struct {\n" - " char *Pathname;\n" - " unsigned long Offset;\n" - " unsigned char Opcode;\n" - " unsigned long long Value;\n" + " char *Pathname; /* Full pathname (from root) to the object */\n" + " unsigned short ParentOpcode; /* AML opcode for the parent object */\n" + " unsigned long NamesegOffset; /* Offset of last nameseg in the parent namepath */\n" + " unsigned char Opcode; /* AML opcode for the data */\n" + " unsigned long Offset; /* Offset for the data */\n" + " unsigned long long Value; /* Original value of the data (as applicable) */\n" "} AML_OFFSET_TABLE_ENTRY;\n\n"); FlPrintFile (FileId, @@ -346,29 +422,37 @@ LsDoOffsetTableHeader ( FlPrintFile (FileId, "/*\n" - " * Information about supported object types:\n" + " * Information specific to the supported object types:\n" " *\n" " * Integers:\n" - " * Offset points to the actual integer data\n" " * Opcode is the integer prefix, indicates length of the data\n" + " * (One of: BYTE, WORD, DWORD, QWORD, ZERO, ONE, ONES)\n" + " * Offset points to the actual integer data\n" " * Value is the existing value in the AML\n" " *\n" " * Packages:\n" - " * Offset points to the package opcode\n" " * Opcode is the package or var_package opcode\n" - " * Value is the package element cound\n" + " * Offset points to the package opcode\n" + " * Value is the package element count\n" " *\n" " * Operation Regions:\n" - " * Offset points to the region address data\n" " * Opcode is the address integer prefix, indicates length of the data\n" + " * Offset points to the region address\n" " * Value is the existing address value in the AML\n" " *\n" " * Control Methods:\n" - " * Offset points to the first byte of the namepath\n" + " * Offset points to the method flags byte\n" + " * Value is the existing flags value in the AML\n" + " *\n" + " * Processors:\n" + " * Offset points to the first byte of the PBlock Address\n" " *\n" " * Resource Descriptors:\n" - " * Offset points to the start of the descriptor\n" " * Opcode is the descriptor type\n" + " * Offset points to the start of the descriptor\n" + " *\n" + " * Scopes/Devices/ThermalZones:\n" + " * Nameseg offset only\n" " */\n"); FlPrintFile (FileId, @@ -383,6 +467,6 @@ LsDoOffsetTableFooter ( { FlPrintFile (FileId, - " {0,0,0,0} /* Table terminator */\n};\n\n"); + " {NULL,0,0,0,0,0} /* Table terminator */\n};\n\n"); Gbl_CurrentAmlOffset = 0; } diff --git a/source/compiler/asloperands.c b/source/compiler/asloperands.c index deb4bd4..4afbd96 100644 --- a/source/compiler/asloperands.c +++ b/source/compiler/asloperands.c @@ -971,12 +971,15 @@ OpnDoDefinitionBlock ( Gbl_TableId = AcpiOsAllocate (Length + 1); ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String); + /* + * Convert anything non-alphanumeric to an underscore. This + * allows us to use the TableID to generate unique C symbols. + */ for (i = 0; i < Length; i++) { - if (Gbl_TableId[i] == ' ') + if (!isalnum ((int) Gbl_TableId[i])) { - Gbl_TableId[i] = 0; - break; + Gbl_TableId[i] = '_'; } } } diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index bfb3d75..441dbb3 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -68,7 +68,7 @@ AslDoResponseFile ( #define ASL_TOKEN_SEPARATORS " \t\n" -#define ASL_SUPPORTED_OPTIONS "@:b|c|d^D:e:fgh^i|I:l^m:no|p:P^r:s|t|T:G^v^w|x:z" +#define ASL_SUPPORTED_OPTIONS "@:b|c|d^D:e:fgh^i|I:l^m:no|p:P^r:s|t|T+G^v^w|x:z" /******************************************************************************* diff --git a/source/compiler/dttemplate.c b/source/compiler/dttemplate.c index 09e9990..7370855 100644 --- a/source/compiler/dttemplate.c +++ b/source/compiler/dttemplate.c @@ -117,13 +117,21 @@ DtCreateTemplates ( AslInitializeGlobals (); - AcpiUtStrupr (Signature); - /* Create all known templates if requested */ + /* Default (no signature) is DSDT */ + + if (!Signature) + { + Signature = "DSDT"; + goto GetTemplate; + } - if (!ACPI_STRNCMP (Signature, "ALL", 3) || + AcpiUtStrupr (Signature); + if (!ACPI_STRCMP (Signature, "ALL") || !ACPI_STRCMP (Signature, "*")) { + /* Create all available/known templates */ + Status = DtCreateAllTemplates (); return (Status); } @@ -136,7 +144,9 @@ DtCreateTemplates ( */ if (strlen (Signature) != ACPI_NAME_SIZE) { - fprintf (stderr, "%s, Invalid ACPI table signature\n", Signature); + fprintf (stderr, + "%s: Invalid ACPI table signature (length must be 4 characters)\n", + Signature); return (AE_ERROR); } @@ -153,19 +163,20 @@ DtCreateTemplates ( Signature = "FACP"; } +GetTemplate: TableData = AcpiDmGetTableData (Signature); if (TableData) { if (!TableData->Template) { - fprintf (stderr, "%4.4s, No template available\n", Signature); + fprintf (stderr, "%4.4s: No template available\n", Signature); return (AE_ERROR); } } else if (!AcpiUtIsSpecialTable (Signature)) { fprintf (stderr, - "%4.4s, Unrecognized ACPI table signature\n", Signature); + "%4.4s: Unrecognized ACPI table signature\n", Signature); return (AE_ERROR); } |