diff options
Diffstat (limited to 'source/compiler')
-rw-r--r-- | source/compiler/aslascii.c | 88 | ||||
-rw-r--r-- | source/compiler/aslcompiler.h | 16 | ||||
-rw-r--r-- | source/compiler/asldefine.h | 8 | ||||
-rw-r--r-- | source/compiler/aslfiles.c | 4 | ||||
-rw-r--r-- | source/compiler/aslglobal.h | 2 | ||||
-rw-r--r-- | source/compiler/asllisting.c | 30 | ||||
-rw-r--r-- | source/compiler/aslmain.c | 3 | ||||
-rw-r--r-- | source/compiler/aslmap.c | 2 | ||||
-rw-r--r-- | source/compiler/aslopcodes.c | 1 | ||||
-rw-r--r-- | source/compiler/asloptions.c | 3 | ||||
-rw-r--r-- | source/compiler/aslrules.y | 10 | ||||
-rw-r--r-- | source/compiler/aslstartup.c | 81 | ||||
-rw-r--r-- | source/compiler/aslsupport.l | 6 | ||||
-rw-r--r-- | source/compiler/asltree.c | 22 | ||||
-rw-r--r-- | source/compiler/aslutils.c | 44 | ||||
-rw-r--r-- | source/compiler/aslwalks.c | 15 | ||||
-rw-r--r-- | source/compiler/dttemplate.c | 293 | ||||
-rw-r--r-- | source/compiler/dttemplate.h | 30 |
18 files changed, 400 insertions, 258 deletions
diff --git a/source/compiler/aslascii.c b/source/compiler/aslascii.c index f164e98f5edf..50b145b2a487 100644 --- a/source/compiler/aslascii.c +++ b/source/compiler/aslascii.c @@ -42,6 +42,7 @@ */ #include "aslcompiler.h" +#include <actables.h> #include <acapps.h> #define _COMPONENT ACPI_COMPILER @@ -63,90 +64,7 @@ FlConsumeNewComment ( /******************************************************************************* * - * FUNCTION: FlCheckForAcpiTable - * - * PARAMETERS: Handle - Open input file - * - * RETURN: Status - * - * DESCRIPTION: Determine if a file seems to be a binary ACPI table, via the - * following checks on what would be the table header: - * 0) File must be at least as long as an ACPI_TABLE_HEADER - * 1) The header length field must match the file size - * 2) Signature, OemId, OemTableId, AslCompilerId must be ASCII - * - ******************************************************************************/ - -ACPI_STATUS -FlCheckForAcpiTable ( - FILE *Handle) -{ - ACPI_TABLE_HEADER Table; - UINT32 FileSize; - size_t Actual; - UINT32 i; - - - /* Read a potential table header */ - - Actual = fread (&Table, 1, sizeof (ACPI_TABLE_HEADER), Handle); - fseek (Handle, 0, SEEK_SET); - - if (Actual < sizeof (ACPI_TABLE_HEADER)) - { - return (AE_ERROR); - } - - /* Header length field must match the file size */ - - FileSize = CmGetFileSize (Handle); - if (Table.Length != FileSize) - { - return (AE_ERROR); - } - - /* - * These fields must be ASCII: - * Signature, OemId, OemTableId, AslCompilerId. - * We allow a NULL terminator in OemId and OemTableId. - */ - for (i = 0; i < ACPI_NAME_SIZE; i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.Signature[i])) - { - return (AE_ERROR); - } - - if (!ACPI_IS_ASCII ((UINT8) Table.AslCompilerId[i])) - { - return (AE_ERROR); - } - } - - for (i = 0; (i < ACPI_OEM_ID_SIZE) && (Table.OemId[i]); i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.OemId[i])) - { - return (AE_ERROR); - } - } - - for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (Table.OemTableId[i]); i++) - { - if (!ACPI_IS_ASCII ((UINT8) Table.OemTableId[i])) - { - return (AE_ERROR); - } - } - - printf ("Binary file appears to be a valid ACPI table, disassembling\n"); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: FlCheckForAscii + * FUNCTION: FlIsFileAsciiSource * * PARAMETERS: Filename - Full input filename * DisplayErrors - TRUE if error messages desired @@ -163,7 +81,7 @@ FlCheckForAcpiTable ( ******************************************************************************/ ACPI_STATUS -FlCheckForAscii ( +FlIsFileAsciiSource ( char *Filename, BOOLEAN DisplayErrors) { diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index dfe80c19b2df..01a63e790f09 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -167,11 +167,7 @@ CmDeleteCaches ( * aslascii - ascii support */ ACPI_STATUS -FlCheckForAcpiTable ( - FILE *Handle); - -ACPI_STATUS -FlCheckForAscii ( +FlIsFileAsciiSource ( char *Filename, BOOLEAN DisplayErrors); @@ -741,6 +737,10 @@ TrSetEndLineNumber ( ACPI_PARSE_OBJECT *Op); void +TrSetCurrentFilename ( + ACPI_PARSE_OBJECT *Op); + +void TrWalkTree ( void); @@ -923,6 +923,10 @@ DbgPrint ( #define ASL_PARSE_OUTPUT 1 #define ASL_TREE_OUTPUT 2 +BOOLEAN +UtQueryForOverwrite ( + char *Pathname); + void UtDisplaySupportedTables ( void); @@ -1281,6 +1285,6 @@ DtDoCompile( ACPI_STATUS DtCreateTemplates ( - char *Signature); + char **argv); #endif /* __ASLCOMPILER_H */ diff --git a/source/compiler/asldefine.h b/source/compiler/asldefine.h index 64ecff3e9e6c..e1aa58275995 100644 --- a/source/compiler/asldefine.h +++ b/source/compiler/asldefine.h @@ -106,10 +106,10 @@ /* Types for input files */ -#define ASL_INPUT_TYPE_BINARY 0 -#define ASL_INPUT_TYPE_ACPI_TABLE 1 -#define ASL_INPUT_TYPE_ASCII_ASL 2 -#define ASL_INPUT_TYPE_ASCII_DATA 3 +#define ASL_INPUT_TYPE_BINARY 0 +#define ASL_INPUT_TYPE_BINARY_ACPI_TABLE 1 +#define ASL_INPUT_TYPE_ASCII_ASL 2 +#define ASL_INPUT_TYPE_ASCII_DATA 3 /* Misc */ diff --git a/source/compiler/aslfiles.c b/source/compiler/aslfiles.c index 3ef1be06cb6c..cd3694454212 100644 --- a/source/compiler/aslfiles.c +++ b/source/compiler/aslfiles.c @@ -336,6 +336,7 @@ FlOpenIncludeWithPrefix ( */ Gbl_CurrentLineNumber--; OriginalLineNumber = Gbl_CurrentLineNumber; + while (DtGetNextLine (IncludeFile, DT_ALLOW_MULTILINE_QUOTES) != ASL_EOF) { if (Gbl_CurrentLineBuffer[0] == '#') @@ -344,6 +345,7 @@ FlOpenIncludeWithPrefix ( Op, "use #include instead"); } } + Gbl_CurrentLineNumber = OriginalLineNumber; /* Must seek back to the start of the file */ @@ -570,7 +572,7 @@ FlOpenMiscOutputFiles ( /* All done for disassembler */ - if (Gbl_FileType == ASL_INPUT_TYPE_ACPI_TABLE) + if (Gbl_FileType == ASL_INPUT_TYPE_BINARY_ACPI_TABLE) { return (AE_OK); } diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index e78e58f76f3a..4e89c12ccb6e 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -197,6 +197,7 @@ ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_OutputFilenamePrefix, ASL_EXTERN ASL_INCLUDE_DIR ASL_INIT_GLOBAL (*Gbl_IncludeDirList, NULL); ASL_EXTERN char *Gbl_CurrentInputFilename; ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_ExternalRefFilename, NULL); +ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_PreviousIncludeFilename, NULL); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE); @@ -246,7 +247,6 @@ ASL_EXTERN ASL_LISTING_NODE ASL_INIT_GLOBAL (*Gbl_ListingNode, NULL); ASL_EXTERN ACPI_PARSE_OBJECT *Gbl_FirstLevelInsertionNode; ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_FileType, 0); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_Signature, NULL); -ASL_EXTERN char *Gbl_TemplateSignature; ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentHexColumn, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentAmlOffset, 0); diff --git a/source/compiler/asllisting.c b/source/compiler/asllisting.c index 91ddcac43a23..c41b80e96c9d 100644 --- a/source/compiler/asllisting.c +++ b/source/compiler/asllisting.c @@ -277,6 +277,34 @@ LsTreeWriteWalk ( UtPrintFormattedName (Op->Asl.ParseOpcode, Level); + if (Op->Asl.ParseOpcode == PARSEOP_NAMESEG) + { + DbgPrint (ASL_TREE_OUTPUT, + "%10.4s ", Op->Asl.Value.Name); + } + else if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) || + (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)) + { + DbgPrint (ASL_TREE_OUTPUT, + "%10.32s ", Op->Asl.Value.String); + } + else if (Op->Asl.ParseOpcode == PARSEOP_INCLUDE) + { + DbgPrint (ASL_TREE_OUTPUT, + "Open: %s\n", Op->Asl.Value.String); + return (AE_OK); + } + else if (Op->Asl.ParseOpcode == PARSEOP_INCLUDE_END) + { + DbgPrint (ASL_TREE_OUTPUT, + "Close: %s\n", Op->Asl.Filename); + return (AE_OK); + } + else + { + DbgPrint (ASL_TREE_OUTPUT, " "); + } + DbgPrint (ASL_TREE_OUTPUT, " (%.4X) Flags %8.8X", Op->Asl.ParseOpcode, Op->Asl.CompileFlags); TrPrintNodeCompileFlags (Op->Asl.CompileFlags); @@ -428,7 +456,7 @@ LsWriteNodeToListing ( /* Create a new listing node and push it */ - LsPushNode (Op->Asl.Child->Asl.Value.String); + LsPushNode (Op->Asl.Value.String); return; diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index c0a3d3f660ed..795a04705ef1 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -127,7 +127,8 @@ Usage ( printf ("\nGeneral:\n"); ACPI_OPTION ("-@ <file>", "Specify command file"); ACPI_OPTION ("-I <dir>", "Specify additional include directory"); - ACPI_OPTION ("-T <sig>|ALL|*", "Create table template file for ACPI <Sig>"); + ACPI_OPTION ("-T <sig list>|ALL", "Create ACPI table template/example files"); + ACPI_OPTION ("-T <count>", "Emit DSDT and <count> SSDTs to same file"); ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files"); ACPI_OPTION ("-v", "Display compiler version"); ACPI_OPTION ("-vo", "Enable optimization comments"); diff --git a/source/compiler/aslmap.c b/source/compiler/aslmap.c index a69d5c0e41e5..e34c22301fa1 100644 --- a/source/compiler/aslmap.c +++ b/source/compiler/aslmap.c @@ -313,7 +313,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* NOR */ OP_TABLE_ENTRY (AML_BIT_NOR_OP, 0, 0, ACPI_BTYPE_INTEGER), /* NOT */ OP_TABLE_ENTRY (AML_BIT_NOT_OP, 0, 0, ACPI_BTYPE_INTEGER), /* NOTIFY */ OP_TABLE_ENTRY (AML_NOTIFY_OP, 0, 0, 0), -/* OBJECTTYPE */ OP_TABLE_ENTRY (AML_TYPE_OP, 0, 0, ACPI_BTYPE_INTEGER), +/* OBJECTTYPE */ OP_TABLE_ENTRY (AML_OBJECT_TYPE_OP, 0, 0, ACPI_BTYPE_INTEGER), /* OBJECTTYPE_BFF */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_BUFFER_FIELD, 0, 0), /* OBJECTTYPE_BUF */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_BUFFER, 0, 0), /* OBJECTTYPE_DDB */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_DDB_HANDLE, 0, 0), diff --git a/source/compiler/aslopcodes.c b/source/compiler/aslopcodes.c index 29e9d795c7be..e0b73ec50869 100644 --- a/source/compiler/aslopcodes.c +++ b/source/compiler/aslopcodes.c @@ -1510,7 +1510,6 @@ OpcGenerateAmlOpcode ( case PARSEOP_INCLUDE: - Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; Gbl_HasIncludeFiles = TRUE; break; diff --git a/source/compiler/asloptions.c b/source/compiler/asloptions.c index 2473a8d142cb..1f7462aaf862 100644 --- a/source/compiler/asloptions.c +++ b/source/compiler/asloptions.c @@ -107,7 +107,7 @@ AslCommandLine ( if (Gbl_DoTemplates) { - Status = DtCreateTemplates (Gbl_TemplateSignature); + Status = DtCreateTemplates (argv); if (ACPI_FAILURE (Status)) { exit (-1); @@ -662,7 +662,6 @@ AslDoOptions ( case 'T': /* Create a ACPI table template file */ Gbl_DoTemplates = TRUE; - Gbl_TemplateSignature = AcpiGbl_Optarg; break; case 'v': /* Version and verbosity settings */ diff --git a/source/compiler/aslrules.y b/source/compiler/aslrules.y index 79accf4dd2e0..f8329e9cb1c4 100644 --- a/source/compiler/aslrules.y +++ b/source/compiler/aslrules.y @@ -427,6 +427,7 @@ String CompilerDirective : IncludeTerm {} + | IncludeEndTerm {} | ExternalTerm {} ; @@ -1033,14 +1034,13 @@ IfTerm ; IncludeTerm - : PARSEOP_INCLUDE '(' {$<n>$ = TrCreateLeafNode (PARSEOP_INCLUDE);} - String ')' {TrLinkChildren ($<n>3,1,$4);FlOpenIncludeFile ($4);} - TermList - IncludeEndTerm {$$ = TrLinkPeerNodes (3,$<n>3,$7,$8);} + : PARSEOP_INCLUDE '(' + String ')' {$$ = TrUpdateNode (PARSEOP_INCLUDE, $3); + FlOpenIncludeFile ($3);} ; IncludeEndTerm - : PARSEOP_INCLUDE_END {$$ = TrCreateLeafNode (PARSEOP_INCLUDE_END);} + : PARSEOP_INCLUDE_END {$<n>$ = TrCreateLeafNode (PARSEOP_INCLUDE_END); TrSetCurrentFilename ($$);} ; IncTerm diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c index c04ae9c12f6a..017b4f899382 100644 --- a/source/compiler/aslstartup.c +++ b/source/compiler/aslstartup.c @@ -144,62 +144,63 @@ AslDetectSourceFileType ( ASL_FILE_INFO *Info) { char *FileChar; - UINT8 Type; + UINT8 Type = ASL_INPUT_TYPE_ASCII_DATA; /* default */ ACPI_STATUS Status; - /* Check for a valid binary ACPI table */ + /* Check for 100% ASCII source file (comments are ignored) */ - Status = FlCheckForAcpiTable (Info->Handle); + Status = FlIsFileAsciiSource (Info->Filename, FALSE); if (ACPI_SUCCESS (Status)) { - Type = ASL_INPUT_TYPE_ACPI_TABLE; - goto Cleanup; - } + /* + * File contains ASCII source code. Determine if this is an ASL + * file or an ACPI data table file. + */ + while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, Info->Handle)) + { + /* Uppercase the buffer for caseless compare */ - /* Check for 100% ASCII source file (comments are ignored) */ + FileChar = Gbl_CurrentLineBuffer; + while (*FileChar) + { + *FileChar = (char) toupper ((int) *FileChar); + FileChar++; + } - Status = FlCheckForAscii (Info->Filename, TRUE); - if (ACPI_FAILURE (Status)) - { - printf ("Invalid characters in input file - %s\n", Info->Filename); + /* Presence of "DefinitionBlock" indicates actual ASL code */ - if (!Gbl_IgnoreErrors) - { - Type = ASL_INPUT_TYPE_BINARY; - goto Cleanup; + if (strstr (Gbl_CurrentLineBuffer, "DEFINITIONBLOCK")) + { + /* Appears to be an ASL file */ + + Type = ASL_INPUT_TYPE_ASCII_ASL; + goto Cleanup; + } } - } - /* - * File is ASCII. Determine if this is an ASL file or an ACPI data - * table file. - */ - while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, Info->Handle)) - { - /* Uppercase the buffer for caseless compare */ + /* Appears to be an ASCII data table source file */ - FileChar = Gbl_CurrentLineBuffer; - while (*FileChar) - { - *FileChar = (char) toupper ((int) *FileChar); - FileChar++; - } + Type = ASL_INPUT_TYPE_ASCII_DATA; + goto Cleanup; + } - /* Presence of "DefinitionBlock" indicates actual ASL code */ + /* We have some sort of binary table, check for valid ACPI table */ - if (strstr (Gbl_CurrentLineBuffer, "DEFINITIONBLOCK")) - { - /* Appears to be an ASL file */ + fseek (Info->Handle, 0, SEEK_SET); - Type = ASL_INPUT_TYPE_ASCII_ASL; - goto Cleanup; - } + Status = AcValidateTableHeader (Info->Handle, 0); + if (ACPI_SUCCESS (Status)) + { + fprintf (stderr, + "Binary file appears to be a valid ACPI table, disassembling\n"); + + Type = ASL_INPUT_TYPE_BINARY_ACPI_TABLE; + goto Cleanup; } - /* Not an ASL source file, default to a data table source file */ + Type = ASL_INPUT_TYPE_BINARY; - Type = ASL_INPUT_TYPE_ASCII_DATA; Cleanup: @@ -248,7 +249,7 @@ AslDoDisassembly ( /* Handle additional output files for disassembler */ - Gbl_FileType = ASL_INPUT_TYPE_ACPI_TABLE; + Gbl_FileType = ASL_INPUT_TYPE_BINARY_ACPI_TABLE; Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix); /* This is where the disassembly happens */ @@ -454,7 +455,7 @@ AslDoOneFile ( /* * Binary ACPI table was auto-detected, disassemble it */ - case ASL_INPUT_TYPE_ACPI_TABLE: + case ASL_INPUT_TYPE_BINARY_ACPI_TABLE: /* We have what appears to be an ACPI table, disassemble it */ diff --git a/source/compiler/aslsupport.l b/source/compiler/aslsupport.l index 0016626e41f0..cd38564d2a6f 100644 --- a/source/compiler/aslsupport.l +++ b/source/compiler/aslsupport.l @@ -196,9 +196,13 @@ AslPopInputFileStack ( ASL_FILE_NODE *Fnode; + Gbl_PreviousIncludeFilename = Gbl_Files[ASL_FILE_INPUT].Filename; Fnode = Gbl_IncludeFileStack; DbgPrint (ASL_PARSE_OUTPUT, - "\nPop InputFile Stack, Fnode %p\n\n", Fnode); + "\nPop InputFile Stack, Fnode %p\n", Fnode); + + DbgPrint (ASL_PARSE_OUTPUT, + "Include: Closing \"%s\"\n\n", Gbl_Files[ASL_FILE_INPUT].Filename); if (!Fnode) { diff --git a/source/compiler/asltree.c b/source/compiler/asltree.c index 0d800654f6ca..5067640742d4 100644 --- a/source/compiler/asltree.c +++ b/source/compiler/asltree.c @@ -157,10 +157,30 @@ TrReleaseNode ( /******************************************************************************* * + * FUNCTION: TrSetCurrentFilename + * + * PARAMETERS: Op - An existing parse node + * + * RETURN: None + * + * DESCRIPTION: Save the include file filename. Used for debug output only. + * + ******************************************************************************/ + +void +TrSetCurrentFilename ( + ACPI_PARSE_OBJECT *Op) +{ + Op->Asl.Filename = Gbl_PreviousIncludeFilename; +} + + +/******************************************************************************* + * * FUNCTION: TrUpdateNode * * PARAMETERS: ParseOpcode - New opcode to be assigned to the node - * Op - An existing parse node + * Op - An existing parse node * * RETURN: The updated node * diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index 47851bddad88..e73f22747429 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -46,7 +46,9 @@ #include "acdisasm.h" #include "acnamesp.h" #include "amlcode.h" -#include <acapps.h> +#include "acapps.h" +#include <sys/stat.h> + #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslutils") @@ -65,6 +67,40 @@ UtAttachNameseg ( char *Name); +/****************************************************************************** + * + * FUNCTION: UtQueryForOverwrite + * + * PARAMETERS: Pathname - Output filename + * + * RETURN: TRUE if file does not exist or overwrite is authorized + * + * DESCRIPTION: Query for file overwrite if it already exists. + * + ******************************************************************************/ + +BOOLEAN +UtQueryForOverwrite ( + char *Pathname) +{ + struct stat StatInfo; + + + if (!stat (Pathname, &StatInfo)) + { + fprintf (stderr, "Target file \"%s\" already exists, overwrite? [y|n] ", + Pathname); + + if (getchar () != 'y') + { + return (FALSE); + } + } + + return (TRUE); +} + + /******************************************************************************* * * FUNCTION: UtDisplaySupportedTables @@ -449,9 +485,11 @@ UtDisplaySummary ( if (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle) { FlPrintFile (FileId, - "%-14s %s - %u bytes, %u named objects, %u executable opcodes\n", + "%-14s %s - %u bytes, %u named objects, " + "%u executable opcodes\n", "AML Output:", - Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength, + Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, + FlGetFileSize (ASL_FILE_AML_OUTPUT), TotalNamedObjects, TotalExecutableOpcodes); } } diff --git a/source/compiler/aslwalks.c b/source/compiler/aslwalks.c index 9485a0ae68b4..16810b49a721 100644 --- a/source/compiler/aslwalks.c +++ b/source/compiler/aslwalks.c @@ -859,21 +859,8 @@ AnAnalyzeStoreOperator ( case PARSEOP_DEREFOF: case PARSEOP_REFOF: case PARSEOP_INDEX: - - return; - case PARSEOP_METHODCALL: - /* - * A target is not allowed to be a method call. - * It is technically allowed to be a method call, but this only - * makes sense in one case: if the method returns a reference object, - * which will then allow the Store to complete successfully. - * However, this is not supported by the ACPICA interpreter, - * and not supported by the MS ASL compiler - * at this time. (09/2015) - */ - AslError (ASL_ERROR, ASL_MSG_UNSUPPORTED, - TargetOperandOp, "Method invocation cannot be a target"); + return; default: diff --git a/source/compiler/dttemplate.c b/source/compiler/dttemplate.c index 622e2011038f..aa47a2a7ce3e 100644 --- a/source/compiler/dttemplate.c +++ b/source/compiler/dttemplate.c @@ -57,14 +57,27 @@ AcpiUtIsSpecialTable ( char *Signature); static ACPI_STATUS +DtCreateOneTemplateFile ( + char *Signature, + UINT32 TableCount); + +static ACPI_STATUS DtCreateOneTemplate ( char *Signature, + UINT32 TableCount, const ACPI_DMTABLE_DATA *TableData); static ACPI_STATUS DtCreateAllTemplates ( void); +static int +DtEmitDefinitionBlock ( + FILE *File, + char *Filename, + char *Signature, + UINT32 Instance); + /******************************************************************************* * @@ -101,7 +114,7 @@ AcpiUtIsSpecialTable ( * * FUNCTION: DtCreateTemplates * - * PARAMETERS: Signature - ACPI table signature + * PARAMETERS: argv - Standard command line arguments * * RETURN: Status * @@ -111,32 +124,115 @@ AcpiUtIsSpecialTable ( ACPI_STATUS DtCreateTemplates ( - char *Signature) + char **argv) { - const ACPI_DMTABLE_DATA *TableData; - ACPI_STATUS Status; + char *Signature; + char *End; + unsigned long TableCount; + ACPI_STATUS Status = AE_OK; AslInitializeGlobals (); - /* Default (no signature) is DSDT */ + Status = AdInitialize (); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Special cases for DSDT, ALL, and '*' + */ + + /* Default (no signature option) is DSDT */ - if (!Signature) + if (AcpiGbl_Optind < 3) { - Signature = "DSDT"; - goto GetTemplate; + Status = DtCreateOneTemplateFile (ACPI_SIG_DSDT, 0); + goto Exit; } + AcpiGbl_Optind--; + Signature = argv[AcpiGbl_Optind]; AcpiUtStrupr (Signature); - if (!strcmp (Signature, "ALL") || - !strcmp (Signature, "*")) + + /* + * Multiple SSDT support (-T <ssdt count>) + */ + TableCount = strtoul (Signature, &End, 0); + if (Signature != End) + { + /* The count is used for table ID and method name - max is 254(+1) */ + + if (TableCount > 254) + { + fprintf (stderr, "%u SSDTs requested, maximum is 254\n", + (unsigned int) TableCount); + + Status = AE_LIMIT; + goto Exit; + } + + Status = DtCreateOneTemplateFile (ACPI_SIG_DSDT, TableCount); + goto Exit; + } + + if (!strcmp (Signature, "ALL")) { /* Create all available/known templates */ Status = DtCreateAllTemplates (); - return (Status); + goto Exit; + } + + /* + * Normal case: Create template for each signature + */ + while (argv[AcpiGbl_Optind]) + { + Signature = argv[AcpiGbl_Optind]; + AcpiUtStrupr (Signature); + + Status = DtCreateOneTemplateFile (Signature, 0); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + AcpiGbl_Optind++; } + +Exit: + /* Shutdown ACPICA subsystem */ + + (void) AcpiTerminate (); + CmDeleteCaches (); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: DtCreateOneTemplateFile + * + * PARAMETERS: Signature - ACPI table signature + * + * RETURN: Status + * + * DESCRIPTION: Create one template file of the requested signature. + * + ******************************************************************************/ + +static ACPI_STATUS +DtCreateOneTemplateFile ( + char *Signature, + UINT32 TableCount) +{ + const ACPI_DMTABLE_DATA *TableData; + ACPI_STATUS Status; + + /* * Validate signature and get the template data: * 1) Signature must be 4 characters @@ -146,8 +242,8 @@ DtCreateTemplates ( if (strlen (Signature) != ACPI_NAME_SIZE) { fprintf (stderr, - "%s: Invalid ACPI table signature (length must be 4 characters)\n", - Signature); + "%s: Invalid ACPI table signature " + "(length must be 4 characters)\n", Signature); return (AE_ERROR); } @@ -164,7 +260,8 @@ DtCreateTemplates ( Signature = "FACP"; } -GetTemplate: + /* TableData will point to the template */ + TableData = AcpiDmGetTableData (Signature); if (TableData) { @@ -181,18 +278,7 @@ GetTemplate: return (AE_ERROR); } - Status = AdInitialize (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - - Status = DtCreateOneTemplate (Signature, TableData); - - /* Shutdown ACPICA subsystem */ - - (void) AcpiTerminate (); - CmDeleteCaches (); + Status = DtCreateOneTemplate (Signature, TableCount, TableData); return (Status); } @@ -217,12 +303,6 @@ DtCreateAllTemplates ( ACPI_STATUS Status; - Status = AdInitialize (); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - fprintf (stderr, "Creating all supported Template files\n"); /* Walk entire ACPI table data structure */ @@ -234,7 +314,7 @@ DtCreateAllTemplates ( if (TableData->Template) { Status = DtCreateOneTemplate (TableData->Signature, - TableData); + 0, TableData); if (ACPI_FAILURE (Status)) { return (Status); @@ -247,25 +327,31 @@ DtCreateAllTemplates ( * 1) DSDT/SSDT are AML tables, not data tables * 2) FACS and RSDP have non-standard headers */ - Status = DtCreateOneTemplate (ACPI_SIG_DSDT, NULL); + Status = DtCreateOneTemplate (ACPI_SIG_DSDT, 0, NULL); if (ACPI_FAILURE (Status)) { return (Status); } - Status = DtCreateOneTemplate (ACPI_SIG_SSDT, NULL); + Status = DtCreateOneTemplate (ACPI_SIG_SSDT, 0, NULL); if (ACPI_FAILURE (Status)) { return (Status); } - Status = DtCreateOneTemplate (ACPI_SIG_FACS, NULL); + Status = DtCreateOneTemplate (ACPI_SIG_OSDT, 0, NULL); if (ACPI_FAILURE (Status)) { return (Status); } - Status = DtCreateOneTemplate (ACPI_RSDP_NAME, NULL); + Status = DtCreateOneTemplate (ACPI_SIG_FACS, 0, NULL); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = DtCreateOneTemplate (ACPI_RSDP_NAME, 0, NULL); if (ACPI_FAILURE (Status)) { return (Status); @@ -280,6 +366,7 @@ DtCreateAllTemplates ( * FUNCTION: DtCreateOneTemplate * * PARAMETERS: Signature - ACPI signature, NULL terminated. + * TableCount - Used for SSDTs in same file as DSDT * TableData - Entry in ACPI table data structure. * NULL if a special ACPI table. * @@ -292,12 +379,14 @@ DtCreateAllTemplates ( static ACPI_STATUS DtCreateOneTemplate ( char *Signature, + UINT32 TableCount, const ACPI_DMTABLE_DATA *TableData) { char *DisasmFilename; FILE *File; ACPI_STATUS Status = AE_OK; - ACPI_SIZE Actual; + int Actual; + UINT32 i; /* New file will have a .asl suffix */ @@ -310,13 +399,17 @@ DtCreateOneTemplate ( return (AE_ERROR); } - /* Probably should prompt to overwrite the file */ - AcpiUtStrlwr (DisasmFilename); + if (!UtQueryForOverwrite (DisasmFilename)) + { + return (AE_ERROR); + } + File = fopen (DisasmFilename, "w+"); if (!File) { - fprintf (stderr, "Could not open output file %s\n", DisasmFilename); + fprintf (stderr, "Could not open output file %s\n", + DisasmFilename); return (AE_ERROR); } @@ -327,8 +420,16 @@ DtCreateOneTemplate ( AcpiOsPrintf ("/*\n"); AcpiOsPrintf (ACPI_COMMON_HEADER ("iASL Compiler/Disassembler", " * ")); - AcpiOsPrintf (" * Template for [%4.4s] ACPI Table", - Signature); + if (TableCount == 0) + { + AcpiOsPrintf (" * Template for [%4.4s] ACPI Table", + Signature); + } + else + { + AcpiOsPrintf (" * Template for [%4.4s] and %u [SSDT] ACPI Tables", + Signature, TableCount); + } /* Dump the actual ACPI table */ @@ -354,45 +455,55 @@ DtCreateOneTemplate ( } else { - /* Special ACPI tables - DSDT, SSDT, OSDT, FADT, RSDP */ + /* Special ACPI tables - DSDT, SSDT, OSDT, FACS, RSDP */ AcpiOsPrintf (" (AML byte code table)\n"); - AcpiOsPrintf (" */\n"); + if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT)) { - Actual = fwrite (TemplateDsdt, 1, sizeof (TemplateDsdt) -1, File); - if (Actual != sizeof (TemplateDsdt) -1) + Actual = DtEmitDefinitionBlock ( + File, DisasmFilename, ACPI_SIG_DSDT, 1); + if (Actual < 0) { - fprintf (stderr, - "Could not write to output file %s\n", DisasmFilename); Status = AE_ERROR; goto Cleanup; } + + /* Emit any requested SSDTs into the same file */ + + for (i = 1; i <= TableCount; i++) + { + Actual = DtEmitDefinitionBlock ( + File, DisasmFilename, ACPI_SIG_SSDT, i + 1); + if (Actual < 0) + { + Status = AE_ERROR; + goto Cleanup; + } + } } else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_SSDT)) { - Actual = fwrite (TemplateSsdt, 1, sizeof (TemplateSsdt) -1, File); - if (Actual != sizeof (TemplateSsdt) -1) + Actual = DtEmitDefinitionBlock ( + File, DisasmFilename, ACPI_SIG_SSDT, 1); + if (Actual < 0) { - fprintf (stderr, - "Could not write to output file %s\n", DisasmFilename); Status = AE_ERROR; goto Cleanup; } } else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_OSDT)) { - Actual = fwrite (TemplateOsdt, 1, sizeof (TemplateOsdt) -1, File); - if (Actual != sizeof (TemplateOsdt) -1) + Actual = DtEmitDefinitionBlock ( + File, DisasmFilename, ACPI_SIG_OSDT, 1); + if (Actual < 0) { - fprintf (stderr, - "Could not write to output file %s\n", DisasmFilename); Status = AE_ERROR; goto Cleanup; } } - else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) /* FADT */ + else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) { AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER, TemplateFacs)); @@ -411,12 +522,72 @@ DtCreateOneTemplate ( } } - fprintf (stderr, - "Created ACPI table template for [%4.4s], written to \"%s\"\n", - Signature, DisasmFilename); + if (TableCount == 0) + { + fprintf (stderr, + "Created ACPI table template for [%4.4s], " + "written to \"%s\"\n", + Signature, DisasmFilename); + } + else + { + fprintf (stderr, + "Created ACPI table templates for [%4.4s] " + "and %u [SSDT], written to \"%s\"\n", + Signature, TableCount, DisasmFilename); + } Cleanup: fclose (File); AcpiOsRedirectOutput (stdout); return (Status); } + + +/******************************************************************************* + * + * FUNCTION: DtEmitDefinitionBlock + * + * PARAMETERS: File - An open file for the block + * Filename - Filename for same, for error msg(s) + * Signature - ACPI signature for the block + * Instance - Used for multiple SSDTs in the same file + * + * RETURN: Status from fprintf + * + * DESCRIPTION: Emit the raw ASL for a complete Definition Block (DSDT or SSDT) + * + * Note: The AMLFileName parameter for DefinitionBlock is left as a NULL + * string. This allows the compiler to create the output AML filename from + * the input filename. + * + ******************************************************************************/ + +static int +DtEmitDefinitionBlock ( + FILE *File, + char *Filename, + char *Signature, + UINT32 Instance) +{ + int Status; + + + Status = fprintf (File, + "DefinitionBlock (\"\", \"%4.4s\", 2, \"Intel\", \"_%4.4s_%.2X\", 0x00000001)\n" + "{\n" + " Method (%2.2s%.2X)\n" + " {\n" + " }\n" + "}\n\n", + Signature, Signature, Instance, Signature, Instance); + + if (Status < 0) + { + fprintf (stderr, + "Could not write %4.4s to output file %s\n", + Signature, Filename); + } + + return (Status); +} diff --git a/source/compiler/dttemplate.h b/source/compiler/dttemplate.h index 6f3ed6407012..031eb9b5bdd6 100644 --- a/source/compiler/dttemplate.h +++ b/source/compiler/dttemplate.h @@ -45,36 +45,6 @@ #define __DTTEMPLATE_H -/* Special templates for the ASL/AML tables: DSDT, SSDT, and OSDT */ - -const char TemplateDsdt[] = - "DefinitionBlock (\"dsdt.aml\", \"DSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n" - "{\n" - " Method (MAIN, 0, NotSerialized)\n" - " {\n" - " Return (Zero)\n" - " }\n" - "}\n\n"; - -const char TemplateSsdt[] = - "DefinitionBlock (\"ssdt.aml\", \"SSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n" - "{\n" - " Method (MAIN, 0, NotSerialized)\n" - " {\n" - " Return (Zero)\n" - " }\n" - "}\n\n"; - -const char TemplateOsdt[] = - "DefinitionBlock (\"osdt.aml\", \"OSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n" - "{\n" - " Method (MAIN, 0, NotSerialized)\n" - " {\n" - " Return (Zero)\n" - " }\n" - "}\n\n"; - - /* Templates for ACPI data tables */ const unsigned char TemplateAsf[] = |