diff options
Diffstat (limited to 'source/common/dmextern.c')
-rw-r--r-- | source/common/dmextern.c | 218 |
1 files changed, 216 insertions, 2 deletions
diff --git a/source/common/dmextern.c b/source/common/dmextern.c index 501a9ee..7825ab1 100644 --- a/source/common/dmextern.c +++ b/source/common/dmextern.c @@ -46,6 +46,7 @@ #include "amlcode.h" #include "acnamesp.h" #include "acdisasm.h" +#include <stdio.h> /* @@ -373,6 +374,7 @@ AcpiDmAddToExternalList ( ACPI_EXTERNAL_LIST *NextExternal; ACPI_EXTERNAL_LIST *PrevExternal = NULL; ACPI_STATUS Status; + BOOLEAN Resolved = FALSE; if (!Path) @@ -380,6 +382,15 @@ AcpiDmAddToExternalList ( return; } + if (Type == ACPI_TYPE_METHOD) + { + if (Value & 0x80) + { + Resolved = TRUE; + } + Value &= 0x07; + } + /* * We don't want External() statements to contain a leading '\'. * This prevents duplicate external statements of the form: @@ -464,6 +475,7 @@ AcpiDmAddToExternalList ( NewExternal->Path = ExternalPath; NewExternal->Type = Type; NewExternal->Value = Value; + NewExternal->Resolved = Resolved; NewExternal->Length = (UINT16) ACPI_STRLEN (ExternalPath); /* Was the external path with parent prefix normalized to a fullpath? */ @@ -684,6 +696,29 @@ AcpiDmEmitExternals ( } /* + * Determine the number of control methods in the external list, and + * also how many of those externals were resolved via the namespace. + */ + NextExternal = AcpiGbl_ExternalList; + while (NextExternal) + { + if (NextExternal->Type == ACPI_TYPE_METHOD) + { + AcpiGbl_NumExternalMethods++; + if (NextExternal->Resolved) + { + AcpiGbl_ResolvedExternalMethods++; + } + } + + NextExternal = NextExternal->Next; + } + + /* Check if any control methods were unresolved */ + + AcpiDmUnresolvedWarning (1); + + /* * Walk the list of externals (unresolved references) * found during the AML parsing */ @@ -695,8 +730,17 @@ AcpiDmEmitExternals ( if (AcpiGbl_ExternalList->Type == ACPI_TYPE_METHOD) { - AcpiOsPrintf (") // %u Arguments\n", - AcpiGbl_ExternalList->Value); + if (AcpiGbl_ExternalList->Resolved) + { + AcpiOsPrintf (") // %u Arguments\n", + AcpiGbl_ExternalList->Value); + } + else + { + AcpiOsPrintf (") // Warning: unresolved Method, " + "assuming %u arguments (may be incorrect, see warning above)\n", + AcpiGbl_ExternalList->Value); + } } else { @@ -718,3 +762,173 @@ AcpiDmEmitExternals ( AcpiOsPrintf ("\n"); } + + +/******************************************************************************* + * + * FUNCTION: AcpiDmUnresolvedWarning + * + * PARAMETERS: Type - Where to output the warning. + * 0 means write to stderr + * 1 means write to AcpiOsPrintf + * + * RETURN: None + * + * DESCRIPTION: Issue warning message if there are unresolved external control + * methods within the disassembly. + * + ******************************************************************************/ + +#if 0 +Summary of the external control method problem: + +When the -e option is used with disassembly, the various SSDTs are simply +loaded into a global namespace for the disassembler to use in order to +resolve control method references (invocations). + +The disassembler tracks any such references, and will emit an External() +statement for these types of methods, with the proper number of arguments . + +Without the SSDTs, the AML does not contain enough information to properly +disassemble the control method invocation -- because the disassembler does +not know how many arguments to parse. + +An example: Assume we have two control methods. ABCD has one argument, and +EFGH has zero arguments. Further, we have two additional control methods +that invoke ABCD and EFGH, named T1 and T2: + + Method (ABCD, 1) + { + } + Method (EFGH, 0) + { + } + Method (T1) + { + ABCD (Add (2, 7, Local0)) + } + Method (T2) + { + EFGH () + Add (2, 7, Local0) + } + +Here is the AML code that is generated for T1 and T2: + + 185: Method (T1) + +0000034C: 14 10 54 31 5F 5F 00 ... "..T1__." + + 186: { + 187: ABCD (Add (2, 7, Local0)) + +00000353: 41 42 43 44 ............ "ABCD" +00000357: 72 0A 02 0A 07 60 ...... "r....`" + + 188: } + + 190: Method (T2) + +0000035D: 14 10 54 32 5F 5F 00 ... "..T2__." + + 191: { + 192: EFGH () + +00000364: 45 46 47 48 ............ "EFGH" + + 193: Add (2, 7, Local0) + +00000368: 72 0A 02 0A 07 60 ...... "r....`" + 194: } + +Note that the AML code for T1 and T2 is essentially identical. When +disassembling this code, the methods ABCD and EFGH must be known to the +disassembler, otherwise it does not know how to handle the method invocations. + +In other words, if ABCD and EFGH are actually external control methods +appearing in an SSDT, the disassembler does not know what to do unless +the owning SSDT has been loaded via the -e option. +#endif + +void +AcpiDmUnresolvedWarning ( + UINT8 Type) +{ + + if (!AcpiGbl_NumExternalMethods) + { + return; + } + + if (Type) + { + if (!AcpiGbl_ExternalFileList) + { + /* The -e option was not specified */ + + AcpiOsPrintf (" /*\n" + " * iASL Warning: There were %u external control methods found during\n" + " * disassembly, but additional ACPI tables to resolve these externals\n" + " * were not specified. This resulting disassembler output file may not\n" + " * compile because the disassembler did not know how many arguments\n" + " * to assign to these methods. To specify the tables needed to resolve\n" + " * external control method references, use the one of the following\n" + " * example iASL invocations:\n" + " * iasl -e <ssdt1.aml,ssdt2.aml...> -d <dsdt.aml>\n" + " * iasl -e <dsdt.aml,ssdt2.aml...> -d <ssdt1.aml>\n" + " */\n", + AcpiGbl_NumExternalMethods); + } + else if (AcpiGbl_NumExternalMethods != AcpiGbl_ResolvedExternalMethods) + { + /* The -e option was specified, but there are still some unresolved externals */ + + AcpiOsPrintf (" /*\n" + " * iASL Warning: There were %u external control methods found during\n" + " * disassembly, but only %u %s resolved (%u unresolved). Additional\n" + " * ACPI tables are required to properly disassemble the code. This\n" + " * resulting disassembler output file may not compile because the\n" + " * disassembler did not know how many arguments to assign to the\n" + " * unresolved methods.\n" + " */\n", + AcpiGbl_NumExternalMethods, AcpiGbl_ResolvedExternalMethods, + (AcpiGbl_ResolvedExternalMethods > 1 ? "were" : "was"), + (AcpiGbl_NumExternalMethods - AcpiGbl_ResolvedExternalMethods)); + } + } + else + { + if (!AcpiGbl_ExternalFileList) + { + /* The -e option was not specified */ + + fprintf (stderr, "\n" + "iASL Warning: There were %u external control methods found during\n" + "disassembly, but additional ACPI tables to resolve these externals\n" + "were not specified. The resulting disassembler output file may not\n" + "compile because the disassembler did not know how many arguments\n" + "to assign to these methods. To specify the tables needed to resolve\n" + "external control method references, use the one of the following\n" + "example iASL invocations:\n" + " iasl -e <ssdt1.aml,ssdt2.aml...> -d <dsdt.aml>\n" + " iasl -e <dsdt.aml,ssdt2.aml...> -d <ssdt1.aml>\n", + AcpiGbl_NumExternalMethods); + } + else if (AcpiGbl_NumExternalMethods != AcpiGbl_ResolvedExternalMethods) + { + /* The -e option was specified, but there are still some unresolved externals */ + + fprintf (stderr, "\n" + "iASL Warning: There were %u external control methods found during\n" + "disassembly, but only %u %s resolved (%u unresolved). Additional\n" + "ACPI tables are required to properly disassemble the code. The\n" + "resulting disassembler output file may not compile because the\n" + "disassembler did not know how many arguments to assign to the\n" + "unresolved methods.\n", + AcpiGbl_NumExternalMethods, AcpiGbl_ResolvedExternalMethods, + (AcpiGbl_ResolvedExternalMethods > 1 ? "were" : "was"), + (AcpiGbl_NumExternalMethods - AcpiGbl_ResolvedExternalMethods)); + } + } + +} |