diff options
Diffstat (limited to 'source')
32 files changed, 1070 insertions, 703 deletions
diff --git a/source/common/dmrestag.c b/source/common/dmrestag.c index 58a43e6ddba6..9d18539a7f32 100644 --- a/source/common/dmrestag.c +++ b/source/common/dmrestag.c @@ -469,6 +469,11 @@ AcpiDmCheckResourceReference ( /* Get the Index term, must be an integer constant to convert */ IndexOp = BufferNameOp->Common.Next; + + /* Major cheat: The Node field is also used for the Tag ptr. Clear it now */ + + IndexOp->Common.Node = NULL; + OpInfo = AcpiPsGetOpcodeInfo (IndexOp->Common.AmlOpcode); if (OpInfo->ObjectType != ACPI_TYPE_INTEGER) { diff --git a/source/compiler/aslcompile.c b/source/compiler/aslcompile.c index a6ffe1e89b90..3ac3c24d67f3 100644 --- a/source/compiler/aslcompile.c +++ b/source/compiler/aslcompile.c @@ -800,6 +800,7 @@ CmCleanupAndExit ( void) { UINT32 i; + BOOLEAN DeleteAmlFile = FALSE; AePrintErrorLog (ASL_FILE_STDERR); @@ -851,6 +852,16 @@ CmCleanupAndExit ( UtDisplaySummary (ASL_FILE_STDOUT); + /* + * We will delete the AML file if there are errors and the + * force AML output option has not been used. + */ + if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors) && + Gbl_Files[ASL_FILE_AML_OUTPUT].Handle) + { + DeleteAmlFile = TRUE; + } + /* Close all open files */ Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .i file is same as source file */ @@ -862,29 +873,17 @@ CmCleanupAndExit ( /* Delete AML file if there are errors */ - if ((Gbl_ExceptionCount[ASL_ERROR] > 0) && (!Gbl_IgnoreErrors) && - Gbl_Files[ASL_FILE_AML_OUTPUT].Handle) + if (DeleteAmlFile) { - if (remove (Gbl_Files[ASL_FILE_AML_OUTPUT].Filename)) - { - printf ("%s: ", - Gbl_Files[ASL_FILE_AML_OUTPUT].Filename); - perror ("Could not delete AML file"); - } + FlDeleteFile (ASL_FILE_AML_OUTPUT); } /* Delete the preprocessor output file (.i) unless -li flag is set */ if (!Gbl_PreprocessorOutputFlag && - Gbl_PreprocessFlag && - Gbl_Files[ASL_FILE_PREPROCESSOR].Filename) + Gbl_PreprocessFlag) { - if (remove (Gbl_Files[ASL_FILE_PREPROCESSOR].Filename)) - { - printf ("%s: ", - Gbl_Files[ASL_FILE_PREPROCESSOR].Filename); - perror ("Could not delete preprocessor .i file"); - } + FlDeleteFile (ASL_FILE_PREPROCESSOR); } /* @@ -901,14 +900,9 @@ CmCleanupAndExit ( * * TBD: SourceOutput should be .TMP, then rename if we want to keep it? */ - if (!Gbl_SourceOutputFlag && Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename) + if (!Gbl_SourceOutputFlag) { - if (remove (Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename)) - { - printf ("%s: ", - Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); - perror ("Could not delete SRC file"); - } + FlDeleteFile (ASL_FILE_SOURCE_OUTPUT); } } diff --git a/source/compiler/aslcompiler.h b/source/compiler/aslcompiler.h index 09b3f6c2f66c..c68fcb45cc2b 100644 --- a/source/compiler/aslcompiler.h +++ b/source/compiler/aslcompiler.h @@ -661,6 +661,10 @@ FlPrintFile ( ...); void +FlDeleteFile ( + UINT32 FileId); + +void FlSetLineNumber ( UINT32 LineNumber); @@ -779,6 +783,10 @@ char * UtGetStringBuffer ( UINT32 Length); +void +UtExpandLineBuffers ( + void); + ACPI_STATUS UtInternalizeName ( char *ExternalName, diff --git a/source/compiler/aslerror.c b/source/compiler/aslerror.c index e00f5e40cd0e..c125dfcfdce0 100644 --- a/source/compiler/aslerror.c +++ b/source/compiler/aslerror.c @@ -183,6 +183,7 @@ AePrintException ( FILE *SourceFile = NULL; long FileSize; BOOLEAN PrematureEOF = FALSE; + UINT32 Total = 0; if (Gbl_NoErrors) @@ -300,11 +301,21 @@ AePrintException ( "[*** iASL: Read error on source code temp file %s ***]", Gbl_Files[ASL_FILE_SOURCE_OUTPUT].Filename); } - - else while (RActual && SourceByte && (SourceByte != '\n')) + else { - fwrite (&SourceByte, 1, 1, OutputFile); - RActual = fread (&SourceByte, 1, 1, SourceFile); + while (RActual && SourceByte && (SourceByte != '\n') && (Total < 256)) + { + fwrite (&SourceByte, 1, 1, OutputFile); + RActual = fread (&SourceByte, 1, 1, SourceFile); + Total++; + } + + if (Total >= 256) + { + fprintf (OutputFile, + "\n[*** iASL: Long input line, an error occurred at column %u ***]", + Enode->Column); + } } } } @@ -381,20 +392,28 @@ AePrintException ( if (Gbl_VerboseErrors && !PrematureEOF) { - SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2; - ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1; - - if ((MsgLength + ErrorColumn) < (SourceColumn - 1)) + if (Total >= 256) { - fprintf (OutputFile, "%*s%s", - (int) ((SourceColumn - 1) - ErrorColumn), - MainMessage, " ^ "); + fprintf (OutputFile, " %s", + MainMessage); } else { - fprintf (OutputFile, "%*s %s", - (int) ((SourceColumn - ErrorColumn) + 1), "^", - MainMessage); + SourceColumn = Enode->Column + Enode->FilenameLength + 6 + 2; + ErrorColumn = ASL_ERROR_LEVEL_LENGTH + 5 + 2 + 1; + + if ((MsgLength + ErrorColumn) < (SourceColumn - 1)) + { + fprintf (OutputFile, "%*s%s", + (int) ((SourceColumn - 1) - ErrorColumn), + MainMessage, " ^ "); + } + else + { + fprintf (OutputFile, "%*s %s", + (int) ((SourceColumn - ErrorColumn) + 1), "^", + MainMessage); + } } } else diff --git a/source/compiler/aslfiles.c b/source/compiler/aslfiles.c index bc5b52dcfe1d..7aa426c590d0 100644 --- a/source/compiler/aslfiles.c +++ b/source/compiler/aslfiles.c @@ -63,6 +63,7 @@ FlParseInputPathname ( #endif + /******************************************************************************* * * FUNCTION: AslAbort @@ -376,6 +377,42 @@ FlCloseFile ( /******************************************************************************* * + * FUNCTION: FlDeleteFile + * + * PARAMETERS: FileId - Index into file info array + * + * RETURN: None + * + * DESCRIPTION: Delete a file. + * + ******************************************************************************/ + +void +FlDeleteFile ( + UINT32 FileId) +{ + ASL_FILE_INFO *Info = &Gbl_Files[FileId]; + + + if (!Info->Filename) + { + return; + } + + if (remove (Info->Filename)) + { + printf ("%s (%s file) ", + Info->Filename, Info->Description); + perror ("Could not delete"); + } + + Info->Filename = NULL; + return; +} + + +/******************************************************************************* + * * FUNCTION: FlSetLineNumber * * PARAMETERS: Op - Parse node for the LINE asl statement diff --git a/source/compiler/aslfold.c b/source/compiler/aslfold.c index 6c8cb37b8ec9..425a328a9e88 100644 --- a/source/compiler/aslfold.c +++ b/source/compiler/aslfold.c @@ -200,6 +200,19 @@ OpcAmlCheckForConstant ( DbgPrint (ASL_PARSE_OUTPUT, "[%.4d] Opcode: %12.12s ", Op->Asl.LogicalLineNumber, Op->Asl.ParseOpName); + /* + * These opcodes do not appear in the OpcodeInfo table, but + * they represent constants, so abort the constant walk now. + */ + if ((WalkState->Opcode == AML_RAW_DATA_BYTE) || + (WalkState->Opcode == AML_RAW_DATA_WORD) || + (WalkState->Opcode == AML_RAW_DATA_DWORD) || + (WalkState->Opcode == AML_RAW_DATA_QWORD)) + { + WalkState->WalkType = ACPI_WALK_CONST_OPTIONAL; + return (AE_TYPE); + } + if (!(WalkState->OpInfo->Flags & AML_CONSTANT)) { /* The opcode is not a Type 3/4/5 opcode */ @@ -254,8 +267,8 @@ OpcAmlCheckForConstant ( { DbgPrint (ASL_PARSE_OUTPUT, " TERMARG"); } - DbgPrint (ASL_PARSE_OUTPUT, "\n"); + DbgPrint (ASL_PARSE_OUTPUT, "\n"); return (AE_OK); } diff --git a/source/compiler/aslglobal.h b/source/compiler/aslglobal.h index 64cb76bb2555..0451fecd7101 100644 --- a/source/compiler/aslglobal.h +++ b/source/compiler/aslglobal.h @@ -63,6 +63,41 @@ #endif +#ifdef _DECLARE_GLOBALS +UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0,0,0}; +char AslHexLookup[] = +{ + '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' +}; + + +/* Table below must match ASL_FILE_TYPES in asltypes.h */ + +ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES] = +{ + {NULL, NULL, "stdout: ", "Standard Output"}, + {NULL, NULL, "stderr: ", "Standard Error"}, + {NULL, NULL, "Table Input: ", "Source Input"}, + {NULL, NULL, "Binary Output:", "AML Output"}, + {NULL, NULL, "Source Output:", "Source Output"}, + {NULL, NULL, "Preprocessor: ", "Preprocessor Output"}, + {NULL, NULL, "Listing File: ", "Listing Output"}, + {NULL, NULL, "Hex Dump: ", "Hex Table Output"}, + {NULL, NULL, "Namespace: ", "Namespace Output"}, + {NULL, NULL, "Debug File: ", "Debug Output"}, + {NULL, NULL, "ASM Source: ", "Assembly Code Output"}, + {NULL, NULL, "C Source: ", "C Code Output"}, + {NULL, NULL, "ASM Include: ", "Assembly Header Output"}, + {NULL, NULL, "C Include: ", "C Header Output"} +}; + +#else +extern UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS]; +extern char AslHexLookup[]; +extern ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES]; +#endif + + /* * Parser and other externals */ @@ -74,21 +109,22 @@ extern int PrParserdebug; extern const ASL_MAPPING_ENTRY AslKeywordMapping[]; extern char *AslCompilertext; -#define ASL_LINE_BUFFER_SIZE (4096 * 4) /* 16K */ -#define ASL_MSG_BUFFER_SIZE 4096 -#define HEX_TABLE_LINE_SIZE 8 -#define HEX_LISTING_LINE_SIZE 8 +#define ASL_DEFAULT_LINE_BUFFER_SIZE (1024 * 32) /* 32K */ +#define ASL_MSG_BUFFER_SIZE 4096 +#define HEX_TABLE_LINE_SIZE 8 +#define HEX_LISTING_LINE_SIZE 8 /* Source code buffers and pointers for error reporting */ -ASL_EXTERN char Gbl_CurrentLineBuffer[ASL_LINE_BUFFER_SIZE]; +ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_CurrentLineBuffer, NULL); +ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_LineBufPtr, NULL); +ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_LineBufferSize, ASL_DEFAULT_LINE_BUFFER_SIZE); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentColumn, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_PreviousLineNumber, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineNumber, 1); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_LogicalLineNumber, 1); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_CurrentLineOffset, 0); -ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_LineBufPtr, Gbl_CurrentLineBuffer); /* Exception reporting */ @@ -135,18 +171,16 @@ ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DoTemplates, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_CompileGeneric, FALSE); -#define HEX_OUTPUT_NONE 0 -#define HEX_OUTPUT_C 1 -#define HEX_OUTPUT_ASM 2 -#define HEX_OUTPUT_ASL 3 +#define HEX_OUTPUT_NONE 0 +#define HEX_OUTPUT_C 1 +#define HEX_OUTPUT_ASM 2 +#define HEX_OUTPUT_ASL 3 ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_HexOutputFlag, HEX_OUTPUT_NONE); /* Files */ -ASL_EXTERN ASL_FILE_INFO Gbl_Files [ASL_NUM_FILES]; - ASL_EXTERN char *Gbl_DirectoryPath; ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_IncludeFilename, NULL); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_OutputFilenamePrefix, NULL); @@ -203,7 +237,6 @@ ASL_EXTERN FILE *AcpiGbl_DebugFile; /* Placeholder for oswin ASL_EXTERN ASL_ANALYSIS_WALK_INFO AnalysisWalkInfo; ASL_EXTERN ACPI_TABLE_HEADER TableHeader; -extern char AslHexLookup[]; /* Event timing */ @@ -220,11 +253,5 @@ ASL_EXTERN char StringBuffer[ASL_MSG_BUFFER_SIZE]; ASL_EXTERN char StringBuffer2[ASL_MSG_BUFFER_SIZE]; -#ifdef _DECLARE_GLOBALS -UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0,0,0}; -#else -extern UINT32 Gbl_ExceptionCount[ASL_NUM_REPORT_LEVELS]; -#endif - #endif /* __ASLGLOBAL_H */ diff --git a/source/compiler/aslmain.c b/source/compiler/aslmain.c index 568f395becf8..75262c76ac11 100644 --- a/source/compiler/aslmain.c +++ b/source/compiler/aslmain.c @@ -48,6 +48,7 @@ #include "aslcompiler.h" #include "acapps.h" #include "acdisasm.h" +#include <signal.h> #ifdef _DEBUG #include <crtdbg.h> @@ -70,6 +71,10 @@ static void Usage ( void); +static void ACPI_SYSTEM_XFACE +AslSignalHandler ( + int Sig); + static void AslInitialize ( void); @@ -96,7 +101,7 @@ AslDoResponseFile ( #define ASL_TOKEN_SEPARATORS " \t\n" -#define ASL_SUPPORTED_OPTIONS "@:2b|c|d^D:e:fgh^i|I:l^mno|p:P^r:s|t|T:G^v^w|x:z" +#define ASL_SUPPORTED_OPTIONS "@:2b|c|d^D:e:fgh^i|I:l^m:no|p:P^r:s|t|T:G^v^w|x:z" /******************************************************************************* @@ -163,10 +168,10 @@ Options ( printf ("\nAML Disassembler:\n"); ACPI_OPTION ("-d [file]", "Disassemble or decode binary ACPI table to file (*.dsl)"); ACPI_OPTION ("-da [f1,f2]", "Disassemble multiple tables from single namespace"); + ACPI_OPTION ("-db", "Do not translate Buffers to Resource Templates"); ACPI_OPTION ("-dc [file]", "Disassemble AML and immediately compile it"); ACPI_OPTION ("", "(Obtain DSDT from current system if no input file)"); ACPI_OPTION ("-e [f1,f2]", "Include ACPI table(s) for external symbol resolution"); - ACPI_OPTION ("-m", "Do not translate Buffers to Resource Templates"); ACPI_OPTION ("-2", "Emit ACPI 2.0 compatible ASL code"); ACPI_OPTION ("-g", "Get ACPI tables and write to files (*.dat)"); @@ -238,6 +243,49 @@ Usage ( } +/****************************************************************************** + * + * FUNCTION: AslSignalHandler + * + * PARAMETERS: Sig - Signal that invoked this handler + * + * RETURN: None + * + * DESCRIPTION: Control-C handler. Delete any intermediate files and any + * output files that may be left in an indeterminate state. + * + *****************************************************************************/ + +static void ACPI_SYSTEM_XFACE +AslSignalHandler ( + int Sig) +{ + UINT32 i; + + + signal (Sig, SIG_IGN); + printf ("Aborting\n\n"); + + /* Close all open files */ + + Gbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL; /* the .i file is same as source file */ + + for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++) + { + FlCloseFile (i); + } + + /* Delete any output files */ + + for (i = ASL_FILE_AML_OUTPUT; i < ASL_MAX_FILE_TYPE; i++) + { + FlDeleteFile (i); + } + + exit (0); +} + + /******************************************************************************* * * FUNCTION: AslInitialize @@ -261,7 +309,6 @@ AslInitialize ( _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CrtSetDbgFlag(0)); #endif - AcpiDbgLevel = 0; for (i = 0; i < ASL_NUM_FILES; i++) { @@ -274,6 +321,11 @@ AslInitialize ( Gbl_Files[ASL_FILE_STDERR].Handle = stderr; Gbl_Files[ASL_FILE_STDERR].Filename = "STDERR"; + + /* Allocate the line buffer(s) */ + + Gbl_LineBufferSize /= 2; + UtExpandLineBuffers (); } @@ -475,6 +527,10 @@ AslDoOptions ( Gbl_DisassembleAll = TRUE; break; + case 'b': /* Do not convert buffers to resource descriptors */ + AcpiGbl_NoResourceDisassembly = TRUE; + break; + case 'c': break; @@ -613,8 +669,13 @@ AslDoOptions ( break; - case 'm': /* Do not convert buffers to resource descriptors */ - AcpiGbl_NoResourceDisassembly = TRUE; + case 'm': /* Set line buffer size */ + Gbl_LineBufferSize = (UINT32) strtoul (AcpiGbl_Optarg, NULL, 0) * 1024; + if (Gbl_LineBufferSize < ASL_DEFAULT_LINE_BUFFER_SIZE) + { + Gbl_LineBufferSize = ASL_DEFAULT_LINE_BUFFER_SIZE; + } + printf ("Line Buffer Size: %u\n", Gbl_LineBufferSize); break; @@ -946,7 +1007,10 @@ main ( int Index2; + signal (SIGINT, AslSignalHandler); + AcpiGbl_ExternalFileList = NULL; + AcpiDbgLevel = 0; #ifdef _DEBUG _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | @@ -955,9 +1019,10 @@ main ( /* Init and command line */ + Index1 = Index2 = AslCommandLine (argc, argv); + AslInitialize (); PrInitializePreprocessor (); - Index1 = Index2 = AslCommandLine (argc, argv); /* Options that have no additional parameters or pathnames */ diff --git a/source/compiler/aslmessages.h b/source/compiler/aslmessages.h index 4c4e79aa07ef..f2d86d0b0fbb 100644 --- a/source/compiler/aslmessages.h +++ b/source/compiler/aslmessages.h @@ -198,6 +198,7 @@ typedef enum ASL_MSG_VENDOR_LIST, ASL_MSG_WRITE, ASL_MSG_RANGE, + ASL_MSG_BUFFER_ALLOCATION, /* These messages are used by the Preprocessor only */ @@ -373,6 +374,7 @@ char *AslMessages [] = { /* ASL_MSG_VENDOR_LIST */ "Too many vendor data bytes (7 max)", /* ASL_MSG_WRITE */ "Could not write file", /* ASL_MSG_RANGE */ "Constant out of range", +/* ASL_MSG_BUFFER_ALLOCATION */ "Could not allocate line buffer", /* Preprocessor */ diff --git a/source/compiler/asloperands.c b/source/compiler/asloperands.c index 37274e79d610..6d4433d873ea 100644 --- a/source/compiler/asloperands.c +++ b/source/compiler/asloperands.c @@ -182,6 +182,10 @@ OpnDoMethod ( Next = Next->Asl.Next; if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { + /* This is a ByteConstExpr, so eval the constant now */ + + OpcAmlConstantWalk (Next, 0, NULL); + if (Next->Asl.Value.Integer > 15) { AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL); diff --git a/source/compiler/aslopt.c b/source/compiler/aslopt.c index 6942f7b5ebaf..b31c5870b60d 100644 --- a/source/compiler/aslopt.c +++ b/source/compiler/aslopt.c @@ -441,7 +441,6 @@ OptOptimizeNameDeclaration ( { ACPI_STATUS Status; char *NewPathExternal; - ACPI_GENERIC_STATE ScopeInfo; ACPI_NAMESPACE_NODE *Node; @@ -473,9 +472,10 @@ OptOptimizeNameDeclaration ( * Check to make sure that the optimization finds the node we are * looking for. This is simply a sanity check on the new * path that has been created. + * + * We know that we are at the root, so NULL is used for the scope. */ - ScopeInfo.Scope.Node = CurrentNode; - Status = AcpiNsLookup (&ScopeInfo, *NewPath, + Status = AcpiNsLookup (NULL, *NewPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node)); if (ACPI_SUCCESS (Status)) @@ -624,11 +624,21 @@ OptOptimizeNamePath ( ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME")); /* - * The node of interest is the parent of this node - * (the containing scope) + * The node of interest is the parent of this node (the containing + * scope). The actual namespace node may be up more than one level + * of parse op or it may not exist at all (if we traverse back + * up to the root.) */ - CurrentNode = Op->Asl.Parent->Asl.Node; - if (!CurrentNode) + NextOp = Op->Asl.Parent; + while (NextOp && (!NextOp->Asl.Node)) + { + NextOp = NextOp->Asl.Parent; + } + if (NextOp && NextOp->Asl.Node) + { + CurrentNode = NextOp->Asl.Node; + } + else { CurrentNode = AcpiGbl_RootNode; } diff --git a/source/compiler/aslstartup.c b/source/compiler/aslstartup.c index a302164d452b..1f51c7115a5a 100644 --- a/source/compiler/aslstartup.c +++ b/source/compiler/aslstartup.c @@ -239,7 +239,7 @@ AslDetectSourceFileType ( * File is ASCII. Determine if this is an ASL file or an ACPI data * table file. */ - while (fgets (Gbl_CurrentLineBuffer, ASL_LINE_BUFFER_SIZE, Info->Handle)) + while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, Info->Handle)) { /* Uppercase the buffer for caseless compare */ diff --git a/source/compiler/aslsupport.l b/source/compiler/aslsupport.l index f63519cd3fd5..eef9411222cd 100644 --- a/source/compiler/aslsupport.l +++ b/source/compiler/aslsupport.l @@ -343,14 +343,14 @@ AslInsertLineBuffer ( *Gbl_LineBufPtr = (UINT8) SourceChar; Gbl_LineBufPtr++; - if (Gbl_LineBufPtr > (Gbl_CurrentLineBuffer + (ASL_LINE_BUFFER_SIZE - 1))) + if (Gbl_LineBufPtr > (Gbl_CurrentLineBuffer + (Gbl_LineBufferSize - 1))) { #if 0 /* * Warning if we have split a long source line. * <Probably overkill> */ - sprintf (MsgBuffer, "Max %u", ASL_LINE_BUFFER_SIZE); + sprintf (MsgBuffer, "Max %u", Gbl_LineBufferSize); AslCommonError (ASL_WARNING, ASL_MSG_LONG_LINE, Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, Gbl_CurrentLineOffset, Gbl_CurrentColumn, diff --git a/source/compiler/asltypes.h b/source/compiler/asltypes.h index 7e3bd0a5c34d..b9f4fbe304c0 100644 --- a/source/compiler/asltypes.h +++ b/source/compiler/asltypes.h @@ -133,6 +133,8 @@ typedef struct asl_file_info { FILE *Handle; char *Filename; + const char *ShortDescription; + const char *Description; } ASL_FILE_INFO; @@ -146,14 +148,14 @@ typedef struct asl_file_status /* * File types. Note: Any changes to this table must also be reflected - * in the AslFileTypeNames array. + * in the Gbl_Files array. */ typedef enum { ASL_FILE_STDOUT = 0, ASL_FILE_STDERR, - ASL_FILE_INPUT, /* Don't move these first 3 file types */ - ASL_FILE_AML_OUTPUT, + ASL_FILE_INPUT, + ASL_FILE_AML_OUTPUT, /* Don't move these first 4 file types */ ASL_FILE_SOURCE_OUTPUT, ASL_FILE_PREPROCESSOR, ASL_FILE_LISTING_OUTPUT, diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index 771ba09e584e..43bf8238630f 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -54,31 +54,6 @@ ACPI_MODULE_NAME ("aslutils") -char AslHexLookup[] = -{ - '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' -}; - -/* Table below must match ASL_FILE_TYPES in asltypes.h */ - -static const char *AslFileTypeNames [ASL_NUM_FILES] = -{ - "stdout: ", - "stderr: ", - "Table Input: ", - "Binary Output:", - "Source Output:", - "Preprocessor: ", - "Listing File: ", - "Hex Dump: ", - "Namespace: ", - "Debug File: ", - "ASM Source: ", - "C Source: ", - "ASM Include: ", - "C Include: " -}; - /* Local prototypes */ @@ -547,7 +522,7 @@ UtDisplaySummary ( } FlPrintFile (FileId, "%14s %s - %u bytes\n", - AslFileTypeNames [i], + Gbl_Files[i].ShortDescription, Gbl_Files[i].Filename, FlGetFileSize (i)); } @@ -646,6 +621,79 @@ UtGetStringBuffer ( } +/****************************************************************************** + * + * FUNCTION: UtExpandLineBuffers + * + * PARAMETERS: None. Updates global line buffer pointers. + * + * RETURN: None. Reallocates the global line buffers + * + * DESCRIPTION: Called if the current line buffer becomes filled. Reallocates + * all global line buffers and updates Gbl_LineBufferSize. NOTE: + * Also used for the initial allocation of the buffers, when + * all of the buffer pointers are NULL. Initial allocations are + * of size ASL_DEFAULT_LINE_BUFFER_SIZE + * + *****************************************************************************/ + +void +UtExpandLineBuffers ( + void) +{ + UINT32 NewSize; + + + /* Attempt to double the size of all line buffers */ + + NewSize = Gbl_LineBufferSize * 2; + if (Gbl_CurrentLineBuffer) + { + DbgPrint (ASL_DEBUG_OUTPUT,"Increasing line buffer size from %u to %u\n", + Gbl_LineBufferSize, NewSize); + } + + Gbl_CurrentLineBuffer = realloc (Gbl_CurrentLineBuffer, NewSize); + Gbl_LineBufPtr = Gbl_CurrentLineBuffer; + if (!Gbl_CurrentLineBuffer) + { + goto ErrorExit; + } + + Gbl_MainTokenBuffer = realloc (Gbl_MainTokenBuffer, NewSize); + if (!Gbl_MainTokenBuffer) + { + goto ErrorExit; + } + + Gbl_MacroTokenBuffer = realloc (Gbl_MacroTokenBuffer, NewSize); + if (!Gbl_MacroTokenBuffer) + { + goto ErrorExit; + } + + Gbl_ExpressionTokenBuffer = realloc (Gbl_ExpressionTokenBuffer, NewSize); + if (!Gbl_ExpressionTokenBuffer) + { + goto ErrorExit; + } + + Gbl_LineBufferSize = NewSize; + return; + + + /* On error above, simply issue error messages and abort, cannot continue */ + +ErrorExit: + printf ("Could not increase line buffer size from %u to %u\n", + Gbl_LineBufferSize, Gbl_LineBufferSize * 2); + + AslError (ASL_ERROR, ASL_MSG_BUFFER_ALLOCATION, + NULL, NULL); + AslAbort (); +} + + /******************************************************************************* * * FUNCTION: UtInternalizeName diff --git a/source/compiler/dtio.c b/source/compiler/dtio.c index 2b4e433d0e2d..aa9cd7b3d417 100644 --- a/source/compiler/dtio.c +++ b/source/compiler/dtio.c @@ -413,13 +413,21 @@ DtGetNextLine ( BOOLEAN LineNotAllBlanks = FALSE; UINT32 State = DT_NORMAL_TEXT; UINT32 CurrentLineOffset; - UINT32 BeyondBufferCount; UINT32 i; char c; - for (i = 0; i < ASL_LINE_BUFFER_SIZE;) + for (i = 0; ;) { + /* + * If line is too long, expand the line buffers. Also increases + * Gbl_LineBufferSize. + */ + if (i >= Gbl_LineBufferSize) + { + UtExpandLineBuffers (); + } + c = (char) getc (Handle); if (c == EOF) { @@ -491,6 +499,11 @@ DtGetNextLine ( */ if ((i != 0) && LineNotAllBlanks) { + if ((i + 1) >= Gbl_LineBufferSize) + { + UtExpandLineBuffers (); + } + Gbl_CurrentLineBuffer[i+1] = 0; /* Terminate string */ return (CurrentLineOffset); } @@ -565,6 +578,11 @@ DtGetNextLine ( default: /* Not a comment */ i++; /* Save the preceeding slash */ + if (i >= Gbl_LineBufferSize) + { + UtExpandLineBuffers (); + } + Gbl_CurrentLineBuffer[i] = c; i++; State = DT_NORMAL_TEXT; @@ -668,21 +686,6 @@ DtGetNextLine ( return (ASL_EOF); } } - - /* Line is too long for internal buffer. Determine actual length */ - - BeyondBufferCount = 1; - c = (char) getc (Handle); - while (c != '\n') - { - c = (char) getc (Handle); - BeyondBufferCount++; - } - - printf ("ERROR - At %u: Input line (%u bytes) is too long (max %u)\n", - Gbl_CurrentLineNumber++, ASL_LINE_BUFFER_SIZE + BeyondBufferCount, - ASL_LINE_BUFFER_SIZE); - return (ASL_EOF); } diff --git a/source/compiler/new_table.txt b/source/compiler/new_table.txt deleted file mode 100755 index 1e48d385b6e8..000000000000 --- a/source/compiler/new_table.txt +++ /dev/null @@ -1,88 +0,0 @@ -How to add a new ACPI table to ACPICA and the iASL compiler. ------------------------------------------------------------- - -There are four main tasks that are needed to provide support for a -new ACPI table: - 1) Create a full definition of the table and any subtables - in the ACPICA headers. - 2) Add disassembler support for the new table - 3) Add iASL table compiler support for the new table - 4) Create a default template for the new table for iASL -T - option. - -Notes for each of these tasks provided below. - - -1) Header Support ------------------ - -New tables should be added to the appropriate header: - actbl2.h: Used for new tables that are not defined in the ACPI spec. - actbl3.h: Used for new tables that are defined in the ACPI spec. - -Use ACPI_TABLE_HEADER for the common ACPI table header. -Subtables should be defined separately from the main table. -Don't add placeholder fields for subtables and other multiple data items. - (Don't use xxxxx[1] for a field that can have multiple items.) - The disassembler and data table compiler depends on this. -For tables not defined in the ACPI spec, add a comment to indicate where - the table came from. -Use other table definitions for additional guidance. - - -2) iASL Disassembler Support ----------------------------- - -Add definition of the table (and subtables) in common/dmtbinfo.c -Add table access macro(s) of the form ACPI_xxxx_OFFSET -Add ACPI_DMT_TERMINATOR at the end of every table/subtable definition - -Add externals for the table/subtable definitions in acdisasm.h -Add an entry for the new table in the AcpiDmTableData in common/dmtable.c - -If there are no subtables, add the AcpiDmTableInfoXXXX name to the - AcpiDmTableData and it will automatically be disassembled. - -If there are subtables, a dump routine must be written: -Add an AcpiDmDumpXXXX function to dmtbdump.c -- note, code for another - similar table can often be ported for the new table. -Add an external for this function to acdisasm.h -Add this function to the AcpiDmTableData entry for the new ACPI table - -Debug/Test: Either find an existing example of the new ACPI table, or - create one using the "generic ACPI table support" included in the - iASL data table compiler. Use the -G option to force a - generic compile. It is often best to create the table from scratch, - since this clearly exposes the dependencies (lengths, offsets, etc.) - that the Table Compiler support will need to generate. - - -3) iASL Table Compiler Support ------------------------------- - -Simple tables do not require a compile routine. The definition of the - table in common/dmtbinfo.c (created in step 2 above) will suffice. - -Complex tables with subtables will require a compile routine with a name - of the form DtCompileXXXX. -Add a DtCompileXXXX function to the dttable.c module. -Add an external for this function in dtcompiler.h -Add this function to the AcpiDmTableData entry for the new ACPI table - in common/dmtable.c - - -4) Template Support (-T iASL option) ------------------------------------- - -Create an example of the new ACPI table. This example should create - multiple subtables (if supported), and multiple instances of any - variable length data. - -Compile the example file with the -sc option. This will create a C - array that contains the table contents. - -Add this array to the dttemplate.h file. Name the array TemplateXXXX. -Add this array name to the AcpiDmTableData entry for the new ACPI table - -Debug/Test: Create the template file. Compile the file. Disassemble the file. - Compile the disassembly file. diff --git a/source/compiler/preprocess.h b/source/compiler/preprocess.h index 920c0b9eac1a..f97434f3a892 100644 --- a/source/compiler/preprocess.h +++ b/source/compiler/preprocess.h @@ -128,10 +128,13 @@ typedef struct pr_file_node /* * Globals */ -PR_EXTERN char XXXEvalBuffer[ASL_LINE_BUFFER_SIZE]; -PR_EXTERN char Gbl_MainTokenBuffer[ASL_LINE_BUFFER_SIZE]; -PR_EXTERN char Gbl_MacroTokenBuffer[ASL_LINE_BUFFER_SIZE]; -PR_EXTERN char Gbl_ExpressionTokenBuffer[ASL_LINE_BUFFER_SIZE]; +#if 0 /* TBD for macros */ +PR_EXTERN char PR_INIT_GLOBAL (*XXXEvalBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */ +#endif + +PR_EXTERN char PR_INIT_GLOBAL (*Gbl_MainTokenBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */ +PR_EXTERN char PR_INIT_GLOBAL (*Gbl_MacroTokenBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */ +PR_EXTERN char PR_INIT_GLOBAL (*Gbl_ExpressionTokenBuffer, NULL); /* [ASL_LINE_BUFFER_SIZE]; */ PR_EXTERN PR_FILE_NODE *Gbl_InputFileList; PR_EXTERN PR_DEFINE_INFO PR_INIT_GLOBAL (*Gbl_DefineList, NULL); diff --git a/source/components/debugger/dbexec.c b/source/components/debugger/dbexec.c index 86c6579e322a..d8ec3d3febfe 100644 --- a/source/components/debugger/dbexec.c +++ b/source/components/debugger/dbexec.c @@ -607,7 +607,7 @@ AcpiDbExecuteSetup ( AcpiDbPrepNamestring (Info->Pathname); AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); - AcpiOsPrintf ("Executing %s\n", Info->Pathname); + AcpiOsPrintf ("Evaluating %s\n", Info->Pathname); if (Info->Flags & EX_SINGLE_STEP) { @@ -701,7 +701,7 @@ AcpiDbExecutionWalk ( ReturnObj.Pointer = NULL; ReturnObj.Length = ACPI_ALLOCATE_BUFFER; - AcpiNsPrintNodePathname (Node, "Execute"); + AcpiNsPrintNodePathname (Node, "Evaluating"); /* Do the actual method execution */ @@ -710,7 +710,7 @@ AcpiDbExecutionWalk ( Status = AcpiEvaluateObject (Node, NULL, NULL, &ReturnObj); - AcpiOsPrintf ("[%4.4s] returned %s\n", AcpiUtGetNodeName (Node), + AcpiOsPrintf ("Evaluation of [%4.4s] returned %s\n", AcpiUtGetNodeName (Node), AcpiFormatException (Status)); AcpiGbl_MethodExecuting = FALSE; @@ -1009,14 +1009,14 @@ AcpiDbExecute ( if (Allocations > 0) { - AcpiOsPrintf ("Outstanding: 0x%X allocations after execution\n", - Allocations); + AcpiOsPrintf ("0x%X Outstanding allocations after evaluation of %s\n", + Allocations, AcpiGbl_DbMethodInfo.Pathname); } #endif if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Execution of %s failed with status %s\n", + AcpiOsPrintf ("Evaluation of %s failed with status %s\n", AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status)); } else @@ -1025,7 +1025,8 @@ AcpiDbExecute ( if (ReturnObj.Length) { - AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", + AcpiOsPrintf ( + "Evaluation of %s returned object %p, external buffer length %X\n", AcpiGbl_DbMethodInfo.Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length); AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); @@ -1040,7 +1041,7 @@ AcpiDbExecute ( } else { - AcpiOsPrintf ("No return object from execution of %s\n", + AcpiOsPrintf ("No object was returned from evaluation of %s\n", AcpiGbl_DbMethodInfo.Pathname); } } @@ -1111,7 +1112,7 @@ AcpiDbMethodThread ( Status = AcpiDbExecuteMethod (&LocalInfo, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("%s During execution of %s at iteration %X\n", + AcpiOsPrintf ("%s During evaluation of %s at iteration %X\n", AcpiFormatException (Status), Info->Pathname, i); if (Status == AE_ABORT_METHOD) { @@ -1122,12 +1123,12 @@ AcpiDbMethodThread ( #if 0 if ((i % 100) == 0) { - AcpiOsPrintf ("%u executions, Thread 0x%x\n", i, AcpiOsGetThreadId ()); + AcpiOsPrintf ("%u loops, Thread 0x%x\n", i, AcpiOsGetThreadId ()); } if (ReturnObj.Length) { - AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", + AcpiOsPrintf ("Evaluation of %s returned object %p Buflen %X\n", Info->Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length); AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); } diff --git a/source/components/debugger/dbinput.c b/source/components/debugger/dbinput.c index 42452ac8749f..2d48171c4a1d 100644 --- a/source/components/debugger/dbinput.c +++ b/source/components/debugger/dbinput.c @@ -67,8 +67,18 @@ AcpiDbSingleThread ( void); static void +AcpiDbDisplayCommandInfo ( + char *Command, + BOOLEAN DisplayAll); + +static void AcpiDbDisplayHelp ( - void); + char *Command); + +static BOOLEAN +AcpiDbMatchCommandHelp ( + char *Command, + const ACPI_DB_COMMAND_HELP *Help); /* @@ -92,6 +102,7 @@ enum AcpiExDebuggerCommands CMD_DISASSEMBLE, CMD_DUMP, CMD_ENABLEACPI, + CMD_EVALUATE, CMD_EVENT, CMD_EXECUTE, CMD_EXIT, @@ -145,7 +156,7 @@ enum AcpiExDebuggerCommands /* Second parameter is the required argument count */ -static const COMMAND_INFO AcpiGbl_DbCommands[] = +static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] = { {"<NOT FOUND>", 0}, {"<NULL>", 0}, @@ -161,6 +172,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = {"DISASSEMBLE", 1}, {"DUMP", 1}, {"ENABLEACPI", 0}, + {"EVALUATE", 1}, {"EVENT", 1}, {"EXECUTE", 1}, {"EXIT", 0}, @@ -197,7 +209,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = {"RESULTS", 0}, {"SET", 3}, {"SLEEP", 1}, - {"STATS", 0}, + {"STATS", 1}, {"STOP", 0}, {"TABLES", 0}, {"TEMPLATE", 1}, @@ -210,100 +222,229 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = {NULL, 0} }; +/* + * Help for all debugger commands. First argument is the number of lines + * of help to output for the command. + */ +static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] = +{ + {0, "\nGeneral-Purpose Commands:", "\n"}, + {1, " Allocations", "Display list of current memory allocations\n"}, + {2, " Dump <Address>|<Namepath>", "\n"}, + {0, " [Byte|Word|Dword|Qword]", "Display ACPI objects or memory\n"}, + {1, " EnableAcpi", "Enable ACPI (hardware) mode\n"}, + {1, " Handlers", "Info about global handlers\n"}, + {1, " Help [Command]", "This help screen or individual command\n"}, + {1, " History", "Display command history buffer\n"}, + {1, " Level <DebugLevel>] [console]", "Get/Set debug level for file or console\n"}, + {1, " Locks", "Current status of internal mutexes\n"}, + {1, " Osi [Install|Remove <name>]", "Display or modify global _OSI list\n"}, + {1, " Quit or Exit", "Exit this command\n"}, + {9, " Stats [Allocations|Memory|Misc|", "\n"}, + {1, " Objects|Sizes|Stack|Tables]", "Display namespace and memory statistics\n"}, + {1, " Allocations", "Display list of current memory allocations\n"}, + {1, " Memory", "Dump internal memory lists\n"}, + {1, " Misc", "Namespace search and mutex stats\n"}, + {1, " Objects", "Summary of namespace objects\n"}, + {1, " Sizes", "Sizes for each of the internal objects\n"}, + {1, " Stack", "Display CPU stack usage\n"}, + {1, " Tables", "Info about current ACPI table(s)\n"}, + {1, " Tables", "Display info about loaded ACPI tables\n"}, + {1, " Unload <Namepath>", "Unload an ACPI table via namespace object\n"}, + {1, " ! <CommandNumber>", "Execute command from history buffer\n"}, + {1, " !!", "Execute last command again\n"}, + + {0, "\nNamespace Access Commands:", "\n"}, + {1, " Businfo", "Display system bus info\n"}, + {1, " Disassemble <Method>", "Disassemble a control method\n"}, + {1, " Event <F|G> <Value>", "Generate AcpiEvent (Fixed/GPE)\n"}, + {1, " Find <AcpiName> (? is wildcard)", "Find ACPI name(s) with wildcards\n"}, + {1, " Gpe <GpeNum> <GpeBlock>", "Simulate a GPE\n"}, + {1, " Gpes", "Display info on all GPEs\n"}, + {1, " Integrity", "Validate namespace integrity\n"}, + {1, " Methods", "Display list of loaded control methods\n"}, + {1, " Namespace [Object] [Depth]", "Display loaded namespace tree/subtree\n"}, + {1, " Notify <Object> <Value>", "Send a notification on Object\n"}, + {1, " Objects <ObjectType>", "Display all objects of the given type\n"}, + {1, " Owner <OwnerId> [Depth]", "Display loaded namespace by object owner\n"}, + {1, " Predefined", "Check all predefined names\n"}, + {1, " Prefix [<NamePath>]", "Set or Get current execution prefix\n"}, + {1, " References <Addr>", "Find all references to object at addr\n"}, + {1, " Resources <DeviceName | *>", "Display Device resources (* = all devices)\n"}, + {1, " Set N <NamedObject> <Value>", "Set value for named integer\n"}, + {1, " Sleep <SleepState>", "Simulate sleep/wake sequence\n"}, + {1, " Template <Object>", "Format/dump a Buffer/ResourceTemplate\n"}, + {1, " Terminate", "Delete namespace and all internal objects\n"}, + {1, " Type <Object>", "Display object type\n"}, + + {0, "\nControl Method Execution Commands:","\n"}, + {1, " Arguments (or Args)", "Display method arguments\n"}, + {1, " Breakpoint <AmlOffset>", "Set an AML execution breakpoint\n"}, + {1, " Call", "Run to next control method invocation\n"}, + {1, " Debug <Namepath> [Arguments]", "Single Step a control method\n"}, + {6, " Evaluate", "Synonym for Execute\n"}, + {5, " Execute <Namepath> [Arguments]", "Execute control method\n"}, + {1, " Hex Integer", "Integer method argument\n"}, + {1, " \"Ascii String\"", "String method argument\n"}, + {1, " (Byte List)", "Buffer method argument\n"}, + {1, " [Package Element List]", "Package method argument\n"}, + {1, " Go", "Allow method to run to completion\n"}, + {1, " Information", "Display info about the current method\n"}, + {1, " Into", "Step into (not over) a method call\n"}, + {1, " List [# of Aml Opcodes]", "Display method ASL statements\n"}, + {1, " Locals", "Display method local variables\n"}, + {1, " Results", "Display method result stack\n"}, + {1, " Set <A|L> <#> <Value>", "Set method data (Arguments/Locals)\n"}, + {1, " Stop", "Terminate control method\n"}, + {1, " Thread <Threads><Loops><NamePath>", "Spawn threads to execute method(s)\n"}, + {1, " Trace <method name>", "Trace method execution\n"}, + {1, " Tree", "Display control method calling tree\n"}, + {1, " <Enter>", "Single step next AML opcode (over calls)\n"}, + + {0, "\nFile I/O Commands:", "\n"}, + {1, " Close", "Close debug output file\n"}, + {1, " Load <Input Filename>", "Load ACPI table from a file\n"}, + {1, " Open <Output Filename>", "Open a file for debug output\n"}, + {0, NULL, NULL} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiDbMatchCommandHelp + * + * PARAMETERS: Command - Command string to match + * Help - Help table entry to attempt match + * + * RETURN: TRUE if command matched, FALSE otherwise + * + * DESCRIPTION: Attempt to match a command in the help table in order to + * print help information for a single command. + * + ******************************************************************************/ + +static BOOLEAN +AcpiDbMatchCommandHelp ( + char *Command, + const ACPI_DB_COMMAND_HELP *Help) +{ + char *Invocation = Help->Invocation; + UINT32 LineCount; + + + /* Valid commands in the help table begin with a couple of spaces */ + + if (*Invocation != ' ') + { + return (FALSE); + } + + while (*Invocation == ' ') + { + Invocation++; + } + + /* Match command name (full command or substring) */ + + while ((*Command) && (*Invocation) && (*Invocation != ' ')) + { + if (ACPI_TOLOWER (*Command) != ACPI_TOLOWER (*Invocation)) + { + return (FALSE); + } + + Invocation++; + Command++; + } + + /* Print the appropriate number of help lines */ + + LineCount = Help->LineCount; + while (LineCount) + { + AcpiOsPrintf ("%-38s : %s", Help->Invocation, Help->Description); + Help++; + LineCount--; + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbDisplayCommandInfo + * + * PARAMETERS: Command - Command string to match + * DisplayAll - Display all matching commands, or just + * the first one (substring match) + * + * RETURN: None + * + * DESCRIPTION: Display help information for a Debugger command. + * + ******************************************************************************/ + +static void +AcpiDbDisplayCommandInfo ( + char *Command, + BOOLEAN DisplayAll) +{ + const ACPI_DB_COMMAND_HELP *Next; + BOOLEAN Matched; + + + Next = AcpiGbl_DbCommandHelp; + while (Next->Invocation) + { + Matched = AcpiDbMatchCommandHelp (Command, Next); + if (!DisplayAll && Matched) + { + return; + } + + Next++; + } +} + /******************************************************************************* * * FUNCTION: AcpiDbDisplayHelp * - * PARAMETERS: None + * PARAMETERS: Command - Optional command string to display help. + * if not specified, all debugger command + * help strings are displayed * * RETURN: None * - * DESCRIPTION: Print a usage message. + * DESCRIPTION: Display help for a single debugger command, or all of them. * ******************************************************************************/ static void AcpiDbDisplayHelp ( - void) + char *Command) { + const ACPI_DB_COMMAND_HELP *Next = AcpiGbl_DbCommandHelp; + - AcpiOsPrintf ("\nGeneral-Purpose Commands:\n"); - AcpiOsPrintf (" Allocations Display list of current memory allocations\n"); - AcpiOsPrintf (" Dump <Address>|<Namepath>\n"); - AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n"); - AcpiOsPrintf (" EnableAcpi Enable ACPI (hardware) mode\n"); - AcpiOsPrintf (" Handlers Info about global handlers\n"); - AcpiOsPrintf (" Help This help screen\n"); - AcpiOsPrintf (" History Display command history buffer\n"); - AcpiOsPrintf (" Level [<DebugLevel>] [console] Get/Set debug level for file or console\n"); - AcpiOsPrintf (" Locks Current status of internal mutexes\n"); - AcpiOsPrintf (" Osi [Install|Remove <name>] Display or modify global _OSI list\n"); - AcpiOsPrintf (" Quit or Exit Exit this command\n"); - AcpiOsPrintf (" Stats [Allocations|Memory|Misc|\n"); - AcpiOsPrintf (" Objects|Sizes|Stack|Tables] Display namespace and memory statistics\n"); - AcpiOsPrintf (" Allocations Display list of current memory allocations\n"); - AcpiOsPrintf (" Memory Dump internal memory lists\n"); - AcpiOsPrintf (" Misc Namespace search and mutex stats\n"); - AcpiOsPrintf (" Objects Summary of namespace objects\n"); - AcpiOsPrintf (" Sizes Sizes for each of the internal objects\n"); - AcpiOsPrintf (" Stack Display CPU stack usage\n"); - AcpiOsPrintf (" Tables Info about current ACPI table(s)\n"); - AcpiOsPrintf (" Tables Display info about loaded ACPI tables\n"); - AcpiOsPrintf (" Unload <Namepath> Unload an ACPI table via namespace object\n"); - AcpiOsPrintf (" ! <CommandNumber> Execute command from history buffer\n"); - AcpiOsPrintf (" !! Execute last command again\n"); - - AcpiOsPrintf ("\nNamespace Access Commands:\n"); - AcpiOsPrintf (" Businfo Display system bus info\n"); - AcpiOsPrintf (" Disassemble <Method> Disassemble a control method\n"); - AcpiOsPrintf (" Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n"); - AcpiOsPrintf (" Find <AcpiName> (? is wildcard) Find ACPI name(s) with wildcards\n"); - AcpiOsPrintf (" Gpe <GpeNum> <GpeBlock> Simulate a GPE\n"); - AcpiOsPrintf (" Gpes Display info on all GPEs\n"); - AcpiOsPrintf (" Integrity Validate namespace integrity\n"); - AcpiOsPrintf (" Methods Display list of loaded control methods\n"); - AcpiOsPrintf (" Namespace [Object] [Depth] Display loaded namespace tree/subtree\n"); - AcpiOsPrintf (" Notify <Object> <Value> Send a notification on Object\n"); - AcpiOsPrintf (" Objects <ObjectType> Display all objects of the given type\n"); - AcpiOsPrintf (" Owner <OwnerId> [Depth] Display loaded namespace by object owner\n"); - AcpiOsPrintf (" Predefined Check all predefined names\n"); - AcpiOsPrintf (" Prefix [<NamePath>] Set or Get current execution prefix\n"); - AcpiOsPrintf (" References <Addr> Find all references to object at addr\n"); - AcpiOsPrintf (" Resources <DeviceName | *> Display Device resources (* = all devices)\n"); - AcpiOsPrintf (" Set N <NamedObject> <Value> Set value for named integer\n"); - AcpiOsPrintf (" Sleep <SleepState> Simulate sleep/wake sequence\n"); - AcpiOsPrintf (" Template <Object> Format/dump a Buffer/ResourceTemplate\n"); - AcpiOsPrintf (" Terminate Delete namespace and all internal objects\n"); - AcpiOsPrintf (" Type <Object> Display object type\n"); - - AcpiOsPrintf ("\nControl Method Execution Commands:\n"); - AcpiOsPrintf (" Arguments (or Args) Display method arguments\n"); - AcpiOsPrintf (" Breakpoint <AmlOffset> Set an AML execution breakpoint\n"); - AcpiOsPrintf (" Call Run to next control method invocation\n"); - AcpiOsPrintf (" Debug <Namepath> [Arguments] Single Step a control method\n"); - AcpiOsPrintf (" Execute <Namepath> [Arguments] Execute control method\n"); - AcpiOsPrintf (" Hex Integer Integer method argument\n"); - AcpiOsPrintf (" \"Ascii String\" String method argument\n"); - AcpiOsPrintf (" (Byte List) Buffer method argument\n"); - AcpiOsPrintf (" [Package Element List] Package method argument\n"); - AcpiOsPrintf (" Go Allow method to run to completion\n"); - AcpiOsPrintf (" Information Display info about the current method\n"); - AcpiOsPrintf (" Into Step into (not over) a method call\n"); - AcpiOsPrintf (" List [# of Aml Opcodes] Display method ASL statements\n"); - AcpiOsPrintf (" Locals Display method local variables\n"); - AcpiOsPrintf (" Results Display method result stack\n"); - AcpiOsPrintf (" Set <A|L> <#> <Value> Set method data (Arguments/Locals)\n"); - AcpiOsPrintf (" Stop Terminate control method\n"); - AcpiOsPrintf (" Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n"); - AcpiOsPrintf (" Trace <method name> Trace method execution\n"); - AcpiOsPrintf (" Tree Display control method calling tree\n"); - AcpiOsPrintf (" <Enter> Single step next AML opcode (over calls)\n"); - - AcpiOsPrintf ("\nFile I/O Commands:\n"); - AcpiOsPrintf (" Close Close debug output file\n"); - AcpiOsPrintf (" Load <Input Filename> Load ACPI table from a file\n"); - AcpiOsPrintf (" Open <Output Filename> Open a file for debug output\n"); + if (!Command) + { + /* No argument to help, display help for all commands */ + + while (Next->Invocation) + { + AcpiOsPrintf ("%-38s%s", Next->Invocation, Next->Description); + Next++; + } + } + else + { + /* Display help for all commands that match the subtring */ + + AcpiDbDisplayCommandInfo (Command, TRUE); + } } @@ -601,6 +742,7 @@ AcpiDbCommandDispatch ( ParamCount, AcpiGbl_DbCommands[CommandIndex].Name, AcpiGbl_DbCommands[CommandIndex].MinArgs); + AcpiDbDisplayCommandInfo (AcpiGbl_DbCommands[CommandIndex].Name, FALSE); return (AE_CTRL_TRUE); } @@ -677,6 +819,7 @@ AcpiDbCommandDispatch ( AcpiOsPrintf ("Event command not implemented\n"); break; + case CMD_EVALUATE: case CMD_EXECUTE: AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP); @@ -704,7 +847,7 @@ AcpiDbCommandDispatch ( case CMD_HELP: case CMD_HELP2: - AcpiDbDisplayHelp (); + AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]); break; case CMD_HISTORY: diff --git a/source/components/debugger/dbmethod.c b/source/components/debugger/dbmethod.c index 0d45d68150b4..5335611278f7 100644 --- a/source/components/debugger/dbmethod.c +++ b/source/components/debugger/dbmethod.c @@ -402,7 +402,7 @@ AcpiDbWalkForExecute ( void **ReturnValue) { ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; - ACPI_EXECUTE_WALK *Info = (ACPI_EXECUTE_WALK *) Context; + ACPI_DB_EXECUTE_WALK *Info = (ACPI_DB_EXECUTE_WALK *) Context; ACPI_BUFFER ReturnObj; ACPI_STATUS Status; char *Pathname; @@ -502,7 +502,7 @@ void AcpiDbBatchExecute ( char *CountArg) { - ACPI_EXECUTE_WALK Info; + ACPI_DB_EXECUTE_WALK Info; Info.Count = 0; @@ -519,7 +519,7 @@ AcpiDbBatchExecute ( (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, AcpiDbWalkForExecute, NULL, (void *) &Info, NULL); - AcpiOsPrintf ("Executed %u predefined names in the namespace\n", Info.Count); + AcpiOsPrintf ("Evaluated %u predefined names in the namespace\n", Info.Count); } #endif /* ACPI_DEBUGGER */ diff --git a/source/components/debugger/dbnames.c b/source/components/debugger/dbnames.c index be326c5390a7..0393e6ba3755 100644 --- a/source/components/debugger/dbnames.c +++ b/source/components/debugger/dbnames.c @@ -102,7 +102,7 @@ AcpiDbBusWalk ( * Arguments for the Objects command * These object types map directly to the ACPI_TYPES */ -static ARGUMENT_INFO AcpiDbObjectTypes [] = +static ACPI_DB_ARGUMENT_INFO AcpiDbObjectTypes [] = { {"ANY"}, {"INTEGERS"}, diff --git a/source/components/debugger/dbstats.c b/source/components/debugger/dbstats.c index fcc4998edec5..64c847a493ea 100644 --- a/source/components/debugger/dbstats.c +++ b/source/components/debugger/dbstats.c @@ -79,7 +79,7 @@ AcpiDbListInfo ( /* * Statistics subcommands */ -static ARGUMENT_INFO AcpiDbStatTypes [] = +static ACPI_DB_ARGUMENT_INFO AcpiDbStatTypes [] = { {"ALLOCATIONS"}, {"OBJECTS"}, @@ -398,12 +398,6 @@ AcpiDbDisplayStatistics ( UINT32 Temp; - if (!TypeArg) - { - AcpiOsPrintf ("The following subcommands are available:\n ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n"); - return (AE_OK); - } - AcpiUtStrupr (TypeArg); Temp = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes); if (Temp == (UINT32) -1) diff --git a/source/components/debugger/dbutils.c b/source/components/debugger/dbutils.c index 7ce909033965..36a6d207d920 100644 --- a/source/components/debugger/dbutils.c +++ b/source/components/debugger/dbutils.c @@ -85,7 +85,7 @@ static char *Converter = "0123456789ABCDEF"; ACPI_OBJECT_TYPE AcpiDbMatchArgument ( char *UserArgument, - ARGUMENT_INFO *Arguments) + ACPI_DB_ARGUMENT_INFO *Arguments) { UINT32 i; diff --git a/source/components/disassembler/dmopcode.c b/source/components/disassembler/dmopcode.c index 2ce08a33f16f..caebe26a1e45 100644 --- a/source/components/disassembler/dmopcode.c +++ b/source/components/disassembler/dmopcode.c @@ -254,6 +254,10 @@ AcpiDmFieldPredefinedDescription ( /* Major cheat: We previously put the Tag ptr in the Node field */ Tag = ACPI_CAST_PTR (char, IndexOp->Common.Node); + if (!Tag) + { + return; + } /* Match the name in the info table */ diff --git a/source/components/tables/tbinstal.c b/source/components/tables/tbinstal.c index 648ee75a8963..06264404ce9d 100644 --- a/source/components/tables/tbinstal.c +++ b/source/components/tables/tbinstal.c @@ -374,6 +374,7 @@ AcpiTbResizeRootTableList ( void) { ACPI_TABLE_DESC *Tables; + UINT32 TableCount; ACPI_FUNCTION_TRACE (TbResizeRootTableList); @@ -389,9 +390,17 @@ AcpiTbResizeRootTableList ( /* Increase the Table Array size */ + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + TableCount = AcpiGbl_RootTableList.MaxTableCount; + } + else + { + TableCount = AcpiGbl_RootTableList.CurrentTableCount; + } + Tables = ACPI_ALLOCATE_ZEROED ( - ((ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount + - ACPI_ROOT_TABLE_SIZE_INCREMENT) * + ((ACPI_SIZE) TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) * sizeof (ACPI_TABLE_DESC)); if (!Tables) { @@ -404,7 +413,7 @@ AcpiTbResizeRootTableList ( if (AcpiGbl_RootTableList.Tables) { ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, - (ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount * sizeof (ACPI_TABLE_DESC)); + (ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC)); if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) { @@ -413,8 +422,9 @@ AcpiTbResizeRootTableList ( } AcpiGbl_RootTableList.Tables = Tables; - AcpiGbl_RootTableList.MaxTableCount += ACPI_ROOT_TABLE_SIZE_INCREMENT; - AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED; + AcpiGbl_RootTableList.MaxTableCount = + TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT; + AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED; return_ACPI_STATUS (AE_OK); } diff --git a/source/components/tables/tbxface.c b/source/components/tables/tbxface.c index fcc44f30c619..d2f31ea7b2c4 100644 --- a/source/components/tables/tbxface.c +++ b/source/components/tables/tbxface.c @@ -175,7 +175,7 @@ ACPI_EXPORT_SYMBOL (AcpiInitializeTables) * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the * root list from the previously provided scratch area. Should * be called once dynamic memory allocation is available in the - * kernel + * kernel. * ******************************************************************************/ @@ -183,9 +183,7 @@ ACPI_STATUS AcpiReallocateRootTable ( void) { - ACPI_TABLE_DESC *Tables; - ACPI_SIZE NewSize; - ACPI_SIZE CurrentSize; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE (AcpiReallocateRootTable); @@ -200,38 +198,10 @@ AcpiReallocateRootTable ( return_ACPI_STATUS (AE_SUPPORT); } - /* - * Get the current size of the root table and add the default - * increment to create the new table size. - */ - CurrentSize = (ACPI_SIZE) - AcpiGbl_RootTableList.CurrentTableCount * sizeof (ACPI_TABLE_DESC); - - NewSize = CurrentSize + - (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof (ACPI_TABLE_DESC)); - - /* Create new array and copy the old array */ - - Tables = ACPI_ALLOCATE_ZEROED (NewSize); - if (!Tables) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, CurrentSize); + AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE; - /* - * Update the root table descriptor. The new size will be the current - * number of tables plus the increment, independent of the reserved - * size of the original table list. - */ - AcpiGbl_RootTableList.Tables = Tables; - AcpiGbl_RootTableList.MaxTableCount = - AcpiGbl_RootTableList.CurrentTableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT; - AcpiGbl_RootTableList.Flags = - ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE; - - return_ACPI_STATUS (AE_OK); + Status = AcpiTbResizeRootTableList (); + return_ACPI_STATUS (Status); } ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable) diff --git a/source/include/acdebug.h b/source/include/acdebug.h index 5c91c87dafaa..de915b44017a 100644 --- a/source/include/acdebug.h +++ b/source/include/acdebug.h @@ -47,25 +47,33 @@ #define ACPI_DEBUG_BUFFER_SIZE 0x4000 /* 16K buffer for return objects */ -typedef struct CommandInfo +typedef struct acpi_db_command_info { char *Name; /* Command Name */ UINT8 MinArgs; /* Minimum arguments required */ -} COMMAND_INFO; +} ACPI_DB_COMMAND_INFO; -typedef struct ArgumentInfo +typedef struct acpi_db_command_help +{ + UINT8 LineCount; /* Number of help lines */ + char *Invocation; /* Command Invocation */ + char *Description; /* Command Description */ + +} ACPI_DB_COMMAND_HELP; + +typedef struct acpi_db_argument_info { char *Name; /* Argument Name */ -} ARGUMENT_INFO; +} ACPI_DB_ARGUMENT_INFO; -typedef struct acpi_execute_walk +typedef struct acpi_db_execute_walk { UINT32 Count; UINT32 MaxCount; -} ACPI_EXECUTE_WALK; +} ACPI_DB_EXECUTE_WALK; #define PARAM_LIST(pl) pl @@ -304,7 +312,7 @@ AcpiDbGetCacheInfo ( ACPI_OBJECT_TYPE AcpiDbMatchArgument ( char *UserArgument, - ARGUMENT_INFO *Arguments); + ACPI_DB_ARGUMENT_INFO *Arguments); void AcpiDbCloseDebugFile ( diff --git a/source/include/acpixf.h b/source/include/acpixf.h index cdec63a337bd..cd04e260acee 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -48,7 +48,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20120816 +#define ACPI_CA_VERSION 0x20120913 #include "acconfig.h" #include "actypes.h" diff --git a/source/include/actbl1.h b/source/include/actbl1.h index c95d0c944e3d..d7cc59b021f2 100644 --- a/source/include/actbl1.h +++ b/source/include/actbl1.h @@ -567,7 +567,9 @@ enum AcpiHestNotifyTypes ACPI_HEST_NOTIFY_LOCAL = 2, ACPI_HEST_NOTIFY_SCI = 3, ACPI_HEST_NOTIFY_NMI = 4, - ACPI_HEST_NOTIFY_RESERVED = 5 /* 5 and greater are reserved */ + ACPI_HEST_NOTIFY_CMCI = 5, /* ACPI 5.0 */ + ACPI_HEST_NOTIFY_MCE = 6, /* ACPI 5.0 */ + ACPI_HEST_NOTIFY_RESERVED = 7 /* 7 and greater are reserved */ }; /* Values for ConfigWriteEnable bitfield above */ diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c index 11d91a69f2a2..38061d227a42 100644 --- a/source/tools/acpiexec/aemain.c +++ b/source/tools/acpiexec/aemain.c @@ -47,26 +47,54 @@ #include <crtdbg.h> #endif -#define _COMPONENT PARSER +#define _COMPONENT ACPI_TOOLS ACPI_MODULE_NAME ("aemain") +/* Local prototypes */ -UINT8 AcpiGbl_RegionFillValue = 0; -BOOLEAN AcpiGbl_IgnoreErrors = FALSE; -BOOLEAN AcpiGbl_DbOpt_NoRegionSupport = FALSE; -BOOLEAN AcpiGbl_DebugTimeout = FALSE; -UINT8 AcpiGbl_UseHwReducedFadt = FALSE; -BOOLEAN AcpiGbl_DoInterfaceTests = FALSE; +static int +AeDoOptions ( + int argc, + char **argv); + +static ACPI_STATUS +AcpiDbRunBatchMode ( + void); + +static char * +FlStrdup ( + char *String); + +static char ** +AsDoWildcard ( + char *DirectoryPathname, + char *FileSpecifier); + + +#define AE_BUFFER_SIZE 1024 +#define ASL_MAX_FILES 256 + +/* Execution modes */ + +#define AE_MODE_COMMAND_LOOP 0 /* Normal command execution loop */ +#define AE_MODE_BATCH_MULTIPLE 1 /* -b option to execute a command line */ +#define AE_MODE_BATCH_SINGLE 2 /* -m option to execute a single control method */ -static UINT8 AcpiGbl_BatchMode = 0; -static char BatchBuffer[128]; -static AE_TABLE_DESC *AeTableListHead = NULL; -#define ASL_MAX_FILES 256 -static char *FileList[ASL_MAX_FILES]; +/* Globals */ +UINT8 AcpiGbl_RegionFillValue = 0; +BOOLEAN AcpiGbl_IgnoreErrors = FALSE; +BOOLEAN AcpiGbl_DbOpt_NoRegionSupport = FALSE; +BOOLEAN AcpiGbl_DebugTimeout = FALSE; +UINT8 AcpiGbl_UseHwReducedFadt = FALSE; +BOOLEAN AcpiGbl_DoInterfaceTests = FALSE; +static UINT8 AcpiGbl_ExecutionMode = AE_MODE_COMMAND_LOOP; +static char BatchBuffer[AE_BUFFER_SIZE]; /* Batch command buffer */ +static char *FileList[ASL_MAX_FILES]; +static AE_TABLE_DESC *AeTableListHead = NULL; -#define AE_SUPPORTED_OPTIONS "?b:d:e:f:gm^orv:x:" +#define AE_SUPPORTED_OPTIONS "?b:d:e:f:gm^orv:x:" /****************************************************************************** @@ -82,13 +110,14 @@ static char *FileList[ASL_MAX_FILES]; *****************************************************************************/ static void -usage (void) +usage ( + void) { ACPI_USAGE_HEADER ("acpiexec [options] AMLfile1 AMLfile2 ..."); ACPI_OPTION ("-?", "Display this message"); - ACPI_OPTION ("-b <CommandLine>", "Batch mode command execution"); + ACPI_OPTION ("-b \"CommandLine\"", "Batch mode command line execution (cmd1;cmd2;...)"); ACPI_OPTION ("-m [Method]", "Batch mode method execution. Default=MAIN"); printf ("\n"); @@ -116,314 +145,34 @@ usage (void) /****************************************************************************** * - * FUNCTION: AcpiDbRunBatchMode - * - * PARAMETERS: BatchCommandLine - A semicolon separated list of commands - * to be executed. - * Use only commas to separate elements of - * particular command. - * RETURN: Status - * - * DESCRIPTION: For each command of list separated by ';' prepare the command - * buffer and pass it to AcpiDbCommandDispatch. - * - *****************************************************************************/ - -static ACPI_STATUS -AcpiDbRunBatchMode ( - void) -{ - ACPI_STATUS Status; - char *Ptr = BatchBuffer; - char *Cmd = Ptr; - UINT8 Run = 0; - - - AcpiGbl_MethodExecuting = FALSE; - AcpiGbl_StepToNextCall = FALSE; - - while (*Ptr) - { - if (*Ptr == ',') - { - /* Convert commas to spaces */ - *Ptr = ' '; - } - else if (*Ptr == ';') - { - *Ptr = '\0'; - Run = 1; - } - - Ptr++; - - if (Run || (*Ptr == '\0')) - { - (void) AcpiDbCommandDispatch (Cmd, NULL, NULL); - Run = 0; - Cmd = Ptr; - } - } - - Status = AcpiTerminate (); - return (Status); -} - - -/******************************************************************************* - * - * FUNCTION: FlStrdup - * - * DESCRIPTION: Local strdup function - * - ******************************************************************************/ - -static char * -FlStrdup ( - char *String) -{ - char *NewString; - - - NewString = AcpiOsAllocate (strlen (String) + 1); - if (!NewString) - { - return (NULL); - } - - strcpy (NewString, String); - return (NewString); -} - - -/******************************************************************************* - * - * FUNCTION: FlSplitInputPathname - * - * PARAMETERS: InputFilename - The user-specified ASL source file to be - * compiled - * OutDirectoryPath - Where the directory path prefix is - * returned - * OutFilename - Where the filename part is returned - * - * RETURN: Status - * - * DESCRIPTION: Split the input path into a directory and filename part - * 1) Directory part used to open include files - * 2) Filename part used to generate output filenames - * - ******************************************************************************/ - -ACPI_STATUS -FlSplitInputPathname ( - char *InputPath, - char **OutDirectoryPath, - char **OutFilename) -{ - char *Substring; - char *DirectoryPath; - char *Filename; - - - *OutDirectoryPath = NULL; - *OutFilename = NULL; - - if (!InputPath) - { - return (AE_OK); - } - - /* Get the path to the input filename's directory */ - - DirectoryPath = FlStrdup (InputPath); - if (!DirectoryPath) - { - return (AE_NO_MEMORY); - } - - /* Convert backslashes to slashes in the entire path */ - - UtConvertBackslashes (DirectoryPath); - - /* Backup to last slash or colon */ - - Substring = strrchr (DirectoryPath, '/'); - if (!Substring) - { - Substring = strrchr (DirectoryPath, ':'); - } - - /* Extract the simple filename */ - - if (!Substring) - { - DirectoryPath[0] = 0; - Filename = FlStrdup (InputPath); - } - else - { - Filename = FlStrdup (Substring + 1); - *(Substring+1) = 0; - } - - if (!Filename) - { - return (AE_NO_MEMORY); - } - - *OutDirectoryPath = DirectoryPath; - *OutFilename = Filename; - return (AE_OK); -} - - -/****************************************************************************** - * - * FUNCTION: AsDoWildcard + * FUNCTION: AeDoOptions * - * PARAMETERS: DirectoryPathname - Path to parent directory - * FileSpecifier - the wildcard specification (*.c, etc.) - * - * RETURN: Pointer to a list of filenames - * - * DESCRIPTION: Process files via wildcards. This function is for the Windows - * case only. - * - ******************************************************************************/ - -static char ** -AsDoWildcard ( - char *DirectoryPathname, - char *FileSpecifier) -{ -#ifdef WIN32 - void *DirInfo; - char *Filename; - int FileCount; - - - FileCount = 0; - - /* Open parent directory */ - - DirInfo = AcpiOsOpenDirectory (DirectoryPathname, FileSpecifier, REQUEST_FILE_ONLY); - if (!DirInfo) - { - /* Either the directory or file does not exist */ - - printf ("File or directory %s%s does not exist\n", DirectoryPathname, FileSpecifier); - return (NULL); - } - - /* Process each file that matches the wildcard specification */ - - while ((Filename = AcpiOsGetNextFilename (DirInfo))) - { - /* Add the filename to the file list */ - - FileList[FileCount] = AcpiOsAllocate (strlen (Filename) + 1); - strcpy (FileList[FileCount], Filename); - FileCount++; - - if (FileCount >= ASL_MAX_FILES) - { - printf ("Max files reached\n"); - FileList[0] = NULL; - return (FileList); - } - } - - /* Cleanup */ - - AcpiOsCloseDirectory (DirInfo); - FileList[FileCount] = NULL; - return (FileList); - -#else - if (!FileSpecifier) - { - return (NULL); - } - - /* - * Linux/Unix cases - Wildcards are expanded by the shell automatically. - * Just return the filename in a null terminated list - */ - FileList[0] = AcpiOsAllocate (strlen (FileSpecifier) + 1); - strcpy (FileList[0], FileSpecifier); - FileList[1] = NULL; - - return (FileList); -#endif -} - - -/****************************************************************************** - * - * FUNCTION: main - * - * PARAMETERS: argc, argv + * PARAMETERS: argc/argv - Standard argc/argv * * RETURN: Status * - * DESCRIPTION: Main routine for AcpiDump utility + * DESCRIPTION: Command line option processing * *****************************************************************************/ -int ACPI_SYSTEM_XFACE -main ( +static int +AeDoOptions ( int argc, char **argv) { int j; - ACPI_STATUS Status; - UINT32 InitFlags; - ACPI_TABLE_HEADER *Table = NULL; - UINT32 TableCount; - AE_TABLE_DESC *TableDesc; - char **WildcardList; - char *Filename; - char *Directory; - char *FullPathname; - - -#ifdef _DEBUG - _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | - _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); -#endif - - printf (ACPI_COMMON_SIGNON ("AML Execution/Debug Utility")); - - if (argc < 2) - { - usage (); - return (0); - } - - signal (SIGINT, AeCtrlCHandler); - - /* Init globals */ - - AcpiDbgLevel = ACPI_NORMAL_DEFAULT; - AcpiDbgLayer = 0xFFFFFFFF; - - /* Init ACPI and start debugger thread */ - - Status = AcpiInitializeSubsystem (); - AE_CHECK_OK (AcpiInitializeSubsystem, Status); - /* Get the command line options */ - while ((j = AcpiGetopt (argc, argv, AE_SUPPORTED_OPTIONS)) != EOF) switch(j) + while ((j = AcpiGetopt (argc, argv, AE_SUPPORTED_OPTIONS)) != EOF) switch (j) { case 'b': - if (strlen (AcpiGbl_Optarg) > 127) + if (strlen (AcpiGbl_Optarg) > (AE_BUFFER_SIZE -1)) { - printf ("**** The length of command line (%u) exceeded maximum (127)\n", - (UINT32) strlen (AcpiGbl_Optarg)); + printf ("**** The length of command line (%u) exceeded maximum (%u)\n", + (UINT32) strlen (AcpiGbl_Optarg), (AE_BUFFER_SIZE -1)); return (-1); } - AcpiGbl_BatchMode = 1; + AcpiGbl_ExecutionMode = AE_MODE_BATCH_MULTIPLE; strcpy (BatchBuffer, AcpiGbl_Optarg); break; @@ -501,7 +250,7 @@ main ( break; case 'm': - AcpiGbl_BatchMode = 2; + AcpiGbl_ExecutionMode = AE_MODE_BATCH_SINGLE; switch (AcpiGbl_Optarg[0]) { case '^': @@ -554,11 +303,72 @@ main ( return (-1); } + return (0); +} + - InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE); - if (!AcpiGbl_DbOpt_ini_methods) +/****************************************************************************** + * + * FUNCTION: main + * + * PARAMETERS: argc, argv + * + * RETURN: Status + * + * DESCRIPTION: Main routine for AcpiExec utility + * + *****************************************************************************/ + +int ACPI_SYSTEM_XFACE +main ( + int argc, + char **argv) +{ + ACPI_STATUS Status; + UINT32 InitFlags; + ACPI_TABLE_HEADER *Table = NULL; + UINT32 TableCount; + AE_TABLE_DESC *TableDesc; + char **WildcardList; + char *Filename; + char *Directory; + char *FullPathname; + + +#ifdef _DEBUG + _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | + _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); +#endif + + printf (ACPI_COMMON_SIGNON ("AML Execution/Debug Utility")); + + if (argc < 2) { - InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); + usage (); + return (0); + } + + signal (SIGINT, AeCtrlCHandler); + + /* Init globals */ + + AcpiDbgLevel = ACPI_NORMAL_DEFAULT; + AcpiDbgLayer = 0xFFFFFFFF; + + /* Init ACPI and start debugger thread */ + + Status = AcpiInitializeSubsystem (); + AE_CHECK_OK (AcpiInitializeSubsystem, Status); + if (ACPI_FAILURE (Status)) + { + return (-1); + } + + /* Get the command line options */ + + if (AeDoOptions (argc, argv)) + { + return (-1); } /* The remaining arguments are filenames for ACPI tables */ @@ -574,10 +384,11 @@ main ( { /* Split incoming path into a directory/filename combo */ - Status = FlSplitInputPathname (argv[AcpiGbl_Optind], &Directory, &Filename); + Status = FlSplitInputPathname (argv[AcpiGbl_Optind], + &Directory, &Filename); if (ACPI_FAILURE (Status)) { - return (Status); + return (-1); } /* Expand wildcards (Windows only) */ @@ -603,9 +414,9 @@ main ( Status = AcpiDbReadTableFromFile (FullPathname, &Table); if (ACPI_FAILURE (Status)) { - printf ("**** Could not get input table %s, %s\n", FullPathname, - AcpiFormatException (Status)); - goto enterloop; + printf ("**** Could not get input table %s, %s\n", + FullPathname, AcpiFormatException (Status)); + goto EnterDebugger; } AcpiOsFree (FullPathname); @@ -618,7 +429,8 @@ main ( if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FADT) && !AcpiUtIsAmlTable (Table)) { - ACPI_WARNING ((AE_INFO,"Table %4.4s is not an AML table, ignoring", + ACPI_WARNING ((AE_INFO, + "Table %4.4s is not an AML table, ignoring", Table->Signature)); AcpiOsFree (Table); continue; @@ -648,35 +460,47 @@ main ( Status = AeInstallTables (); if (ACPI_FAILURE (Status)) { - printf ("**** Could not load ACPI tables, %s\n", AcpiFormatException (Status)); - goto enterloop; + printf ("**** Could not load ACPI tables, %s\n", + AcpiFormatException (Status)); + goto EnterDebugger; } - /* - * Install most of the handlers. - * Override some default region handlers, especially SystemMemory - */ + /* + * Install most of the handlers. + * Override some default region handlers, especially SystemMemory + */ Status = AeInstallEarlyHandlers (); if (ACPI_FAILURE (Status)) { - goto enterloop; + goto EnterDebugger; + } + + /* Setup initialization flags for ACPICA */ + + InitFlags = (ACPI_NO_HANDLER_INIT | ACPI_NO_ACPI_ENABLE); + if (!AcpiGbl_DbOpt_ini_methods) + { + InitFlags |= (ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); } /* - * TBD: Need a way to call this after the "LOAD" command + * Main initialization for ACPICA subsystem + * TBD: Need a way to call this after the ACPI table "LOAD" command */ Status = AcpiEnableSubsystem (InitFlags); if (ACPI_FAILURE (Status)) { - printf ("**** Could not EnableSubsystem, %s\n", AcpiFormatException (Status)); - goto enterloop; + printf ("**** Could not EnableSubsystem, %s\n", + AcpiFormatException (Status)); + goto EnterDebugger; } Status = AcpiInitializeObjects (InitFlags); if (ACPI_FAILURE (Status)) { - printf ("**** Could not InitializeObjects, %s\n", AcpiFormatException (Status)); - goto enterloop; + printf ("**** Could not InitializeObjects, %s\n", + AcpiFormatException (Status)); + goto EnterDebugger; } /* @@ -687,23 +511,281 @@ main ( AeMiscellaneousTests (); } -enterloop: +EnterDebugger: - if (AcpiGbl_BatchMode == 1) + /* Exit if error above and we are in one of the batch modes */ + + if (ACPI_FAILURE (Status) && (AcpiGbl_ExecutionMode > 0)) { - AcpiDbRunBatchMode (); + return (-1); } - else if (AcpiGbl_BatchMode == 2) + + /* Run a batch command or enter the command loop */ + + switch (AcpiGbl_ExecutionMode) { + default: + case AE_MODE_COMMAND_LOOP: + + AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL); + break; + + case AE_MODE_BATCH_MULTIPLE: + + AcpiDbRunBatchMode (); + break; + + case AE_MODE_BATCH_SINGLE: + AcpiDbExecute (BatchBuffer, NULL, NULL, EX_NO_SINGLE_STEP); + break; + } + + return (0); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiDbRunBatchMode + * + * PARAMETERS: BatchCommandLine - A semicolon separated list of commands + * to be executed. + * Use only commas to separate elements of + * particular command. + * RETURN: Status + * + * DESCRIPTION: For each command of list separated by ';' prepare the command + * buffer and pass it to AcpiDbCommandDispatch. + * + *****************************************************************************/ + +static ACPI_STATUS +AcpiDbRunBatchMode ( + void) +{ + ACPI_STATUS Status; + char *Ptr = BatchBuffer; + char *Cmd = Ptr; + UINT8 Run = 0; + + + AcpiGbl_MethodExecuting = FALSE; + AcpiGbl_StepToNextCall = FALSE; + + while (*Ptr) + { + if (*Ptr == ',') + { + /* Convert commas to spaces */ + *Ptr = ' '; + } + else if (*Ptr == ';') + { + *Ptr = '\0'; + Run = 1; + } + + Ptr++; + + if (Run || (*Ptr == '\0')) + { + (void) AcpiDbCommandDispatch (Cmd, NULL, NULL); + Run = 0; + Cmd = Ptr; + } + } + + Status = AcpiTerminate (); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: FlStrdup + * + * DESCRIPTION: Local strdup function + * + *****************************************************************************/ + +static char * +FlStrdup ( + char *String) +{ + char *NewString; + + + NewString = AcpiOsAllocate (strlen (String) + 1); + if (!NewString) + { + return (NULL); + } + + strcpy (NewString, String); + return (NewString); +} + + +/****************************************************************************** + * + * FUNCTION: FlSplitInputPathname + * + * PARAMETERS: InputFilename - The user-specified ASL source file to be + * compiled + * OutDirectoryPath - Where the directory path prefix is + * returned + * OutFilename - Where the filename part is returned + * + * RETURN: Status + * + * DESCRIPTION: Split the input path into a directory and filename part + * 1) Directory part used to open include files + * 2) Filename part used to generate output filenames + * + *****************************************************************************/ + +ACPI_STATUS +FlSplitInputPathname ( + char *InputPath, + char **OutDirectoryPath, + char **OutFilename) +{ + char *Substring; + char *DirectoryPath; + char *Filename; + + + *OutDirectoryPath = NULL; + *OutFilename = NULL; + + if (!InputPath) + { + return (AE_OK); + } + + /* Get the path to the input filename's directory */ + + DirectoryPath = FlStrdup (InputPath); + if (!DirectoryPath) + { + return (AE_NO_MEMORY); + } + + /* Convert backslashes to slashes in the entire path */ + + UtConvertBackslashes (DirectoryPath); + + /* Backup to last slash or colon */ + + Substring = strrchr (DirectoryPath, '/'); + if (!Substring) + { + Substring = strrchr (DirectoryPath, ':'); + } + + /* Extract the simple filename */ + + if (!Substring) + { + DirectoryPath[0] = 0; + Filename = FlStrdup (InputPath); } else { - /* Enter the debugger command loop */ + Filename = FlStrdup (Substring + 1); + *(Substring + 1) = 0; + } - AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL); + if (!Filename) + { + return (AE_NO_MEMORY); } - return (0); + *OutDirectoryPath = DirectoryPath; + *OutFilename = Filename; + return (AE_OK); } + +/****************************************************************************** + * + * FUNCTION: AsDoWildcard + * + * PARAMETERS: DirectoryPathname - Path to parent directory + * FileSpecifier - the wildcard specification (*.c, etc.) + * + * RETURN: Pointer to a list of filenames + * + * DESCRIPTION: Process files via wildcards. This function is for the Windows + * case only. + * + *****************************************************************************/ + +static char ** +AsDoWildcard ( + char *DirectoryPathname, + char *FileSpecifier) +{ +#ifdef WIN32 + void *DirInfo; + char *Filename; + int FileCount; + + + FileCount = 0; + + /* Open parent directory */ + + DirInfo = AcpiOsOpenDirectory (DirectoryPathname, FileSpecifier, + REQUEST_FILE_ONLY); + if (!DirInfo) + { + /* Either the directory or file does not exist */ + + printf ("File or directory \"%s%s\" does not exist\n", + DirectoryPathname, FileSpecifier); + return (NULL); + } + + /* Process each file that matches the wildcard specification */ + + while ((Filename = AcpiOsGetNextFilename (DirInfo))) + { + /* Add the filename to the file list */ + + FileList[FileCount] = AcpiOsAllocate (strlen (Filename) + 1); + strcpy (FileList[FileCount], Filename); + FileCount++; + + if (FileCount >= ASL_MAX_FILES) + { + printf ("Max files reached\n"); + FileList[0] = NULL; + return (FileList); + } + } + + /* Cleanup */ + + AcpiOsCloseDirectory (DirInfo); + FileList[FileCount] = NULL; + return (FileList); + +#else + if (!FileSpecifier) + { + return (NULL); + } + + /* + * Linux/Unix cases - Wildcards are expanded by the shell automatically. + * Just return the filename in a null terminated list + */ + FileList[0] = AcpiOsAllocate (strlen (FileSpecifier) + 1); + strcpy (FileList[0], FileSpecifier); + FileList[1] = NULL; + + return (FileList); +#endif +} diff --git a/source/tools/acpisrc/astable.c b/source/tools/acpisrc/astable.c index 1d782f48357d..3159b4435074 100644 --- a/source/tools/acpisrc/astable.c +++ b/source/tools/acpisrc/astable.c @@ -197,6 +197,10 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_CONVERSION_TABLE", SRC_TYPE_STRUCT}, {"ACPI_CPU_FLAGS", SRC_TYPE_SIMPLE}, {"ACPI_CREATE_FIELD_INFO", SRC_TYPE_STRUCT}, + {"ACPI_DB_ARGUMENT_INFO", SRC_TYPE_STRUCT}, + {"ACPI_DB_COMMAND_HELP", SRC_TYPE_STRUCT}, + {"ACPI_DB_COMMAND_INFO", SRC_TYPE_STRUCT}, + {"ACPI_DB_EXECUTE_WALK", SRC_TYPE_STRUCT}, {"ACPI_DB_METHOD_INFO", SRC_TYPE_STRUCT}, {"ACPI_DEBUG_MEM_BLOCK", SRC_TYPE_STRUCT}, {"ACPI_DEBUG_MEM_HEADER", SRC_TYPE_STRUCT}, @@ -217,7 +221,6 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ACPI_EXDUMP_INFO", SRC_TYPE_STRUCT}, {"ACPI_EXECUTE_OP", SRC_TYPE_SIMPLE}, {"ACPI_EXECUTE_TYPE", SRC_TYPE_SIMPLE}, - {"ACPI_EXECUTE_WALK", SRC_TYPE_STRUCT}, {"ACPI_EXTERNAL_LIST", SRC_TYPE_STRUCT}, {"ACPI_EXTERNAL_FILE", SRC_TYPE_STRUCT}, {"ACPI_FADT_INFO", SRC_TYPE_STRUCT}, @@ -455,7 +458,6 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"AML_RESOURCE_VENDOR_SMALL", SRC_TYPE_STRUCT}, {"APIC_HEADER", SRC_TYPE_STRUCT}, - {"ARGUMENT_INFO", SRC_TYPE_STRUCT}, {"AE_DEBUG_REGIONS", SRC_TYPE_STRUCT}, {"AE_REGION", SRC_TYPE_STRUCT}, {"AE_TABLE_DESC", SRC_TYPE_STRUCT}, @@ -471,7 +473,6 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = { {"ASL_RESERVED_INFO", SRC_TYPE_STRUCT}, {"ASL_RESOURCE_NODE", SRC_TYPE_STRUCT}, {"ASL_WALK_CALLBACK", SRC_TYPE_SIMPLE}, - {"COMMAND_INFO", SRC_TYPE_STRUCT}, {"UINT64_OVERLAY", SRC_TYPE_UNION}, {"UINT64_STRUCT", SRC_TYPE_STRUCT}, |