diff options
29 files changed, 1181 insertions, 527 deletions
diff --git a/documents/changes.txt b/documents/changes.txt index 49c88a49b..52bc749df 100644 --- a/documents/changes.txt +++ b/documents/changes.txt @@ -1,4 +1,83 @@ ---------------------------------------- +17 November 2016. Summary of changes for version 20161117: + + +1) ACPICA kernel-resident subsystem: + +Table Manager: Fixed a regression introduced in 20160729, "FADT support +cleanup". This was an attempt to remove all references in the source to +the FADT version 2, which never was a legal version number. It was +skipped because it was an early version of 64-bit support that was +eventually abandoned for the current 64-bit support. + +Interpreter: Fixed a problem where runtime implicit conversion was +incorrectly disabled for the ASL operators below. This brings the +behavior into compliance with the ACPI specification: + FromBCD + ToBCD + ToDecimalString + ToHexString + ToInteger + ToBuffer + +Table Manager: Added a new public interface, AcpiPutTable, used to +release and free an ACPI table returned by AcpiGetTable and related +interfaces. Lv Zheng. + +Example Code and Data Size: These are the sizes for the OS-independent +acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The +debug version of the code includes the debug output trace mechanism and +has a much larger code and data size. + + Current Release: + Non-Debug Version: 140.5K Code, 58.5K Data, 198.9K Total + Debug Version: 201.3K Code, 82.7K Data, 284.0K Total + Previous Release: + Non-Debug Version: 140.4K Code, 58.1K Data, 198.5K Total + Debug Version: 200.7K Code, 82.1K Data, 282.8K Total + + +2) iASL Compiler/Disassembler and Tools: + +Disassembler: Fixed a regression for disassembly of Resource Template. +Detection of templates in the AML stream missed some types of templates. + +iASL: Fixed a problem where an Access Size error was returned for the PCC +address space when the AccessSize of the GAS register is greater than a +DWORD. Hoan Tran. + +iASL: Implemented several grammar changes for the operators below. These +changes are slated for the next version of the ACPI specification: + RefOf - Disallow method invocation as an operand + CondRefOf - Disallow method invocation as an operand + DerefOf - Disallow operands that use the result from operators +that + do not return a reference (Changed TermArg to +SuperName). + +iASL: Control method invocations are now allowed for Target operands, as +per the ACPI specification. Removed error for using a control method +invocation as a Target operand. + +Disassembler: Improved detection of Resource Templates, Unicode, and +Strings within Buffer objects. These subtypes do not contain a specific +opcode to indicate the originating ASL code, and they must be detected by +other means within the disassembler. + +iASL: Implemented an optimization improvement for 32-bit ACPI tables +(DSDT/SSDT). For the 32-bit case only, compute the optimum integer opcode +only after 64-bit to 32-bit truncation. A truncation warning message is +still emitted, however. + +AcpiXtract: Implemented handling for both types of line terminators (LF +or CR/LF) so that it can accept AcpiDump output files from any system. +Peter Wu. + +AcpiBin: Added two new options for comparing AML files: + -a: compare and display ALL mismatches + -o: start compare at this offset into the second file + +---------------------------------------- 30 September 2016. Summary of changes for version 20160930: diff --git a/generate/msvc/AcpiExec.dsp b/generate/msvc/AcpiExec.dsp index 95f1b97e5..856652303 100755 --- a/generate/msvc/AcpiExec.dsp +++ b/generate/msvc/AcpiExec.dsp @@ -614,6 +614,10 @@ SOURCE=..\..\source\common\getopt.c # End Source File # Begin Source File +SOURCE=..\..\source\os_specific\service_layers\osgendbg.c +# End Source File +# Begin Source File + SOURCE=..\..\source\os_specific\service_layers\oswindir.c # End Source File # Begin Source File diff --git a/generate/msvc9/AcpiExec.vcproj b/generate/msvc9/AcpiExec.vcproj index bc2f6e919..245286cf4 100755 --- a/generate/msvc9/AcpiExec.vcproj +++ b/generate/msvc9/AcpiExec.vcproj @@ -735,6 +735,10 @@ > </File> <File + RelativePath="..\..\source\os_specific\service_layers\osgendbg.c" + > + </File> + <File RelativePath="..\..\source\os_specific\service_layers\oswindir.c" > </File> diff --git a/generate/unix/acpiexec/Makefile b/generate/unix/acpiexec/Makefile index 62850ac27..3191850ad 100644 --- a/generate/unix/acpiexec/Makefile +++ b/generate/unix/acpiexec/Makefile @@ -163,6 +163,7 @@ OBJECTS = \ $(OBJDIR)/nsxfeval.o\ $(OBJDIR)/nsxfname.o\ $(OBJDIR)/nsxfobj.o\ + $(OBJDIR)/osgendbg.o\ $(OBJDIR)/osunixxf.o\ $(OBJDIR)/psargs.o\ $(OBJDIR)/psloop.o\ diff --git a/source/common/acfileio.c b/source/common/acfileio.c index 6cb953633..9b4564ea3 100644 --- a/source/common/acfileio.c +++ b/source/common/acfileio.c @@ -184,7 +184,7 @@ AcGetAllTablesFromFile ( if (FileSize == ACPI_UINT32_MAX) { Status = AE_ERROR; - goto ErrorExit; + goto Exit; } fprintf (stderr, @@ -196,7 +196,7 @@ AcGetAllTablesFromFile ( if (FileSize < sizeof (ACPI_TABLE_HEADER)) { Status = AE_BAD_HEADER; - goto ErrorExit; + goto Exit; } /* Check for an non-binary file */ @@ -206,7 +206,8 @@ AcGetAllTablesFromFile ( fprintf (stderr, " %s: File does not appear to contain a valid AML table\n", Filename); - return (AE_TYPE); + Status = AE_TYPE; + goto Exit; } /* Read all tables within the file */ @@ -225,23 +226,31 @@ AcGetAllTablesFromFile ( } else if (Status == AE_TYPE) { - return (AE_OK); + Status = AE_OK; + goto Exit; } else if (ACPI_FAILURE (Status)) { - goto ErrorExit; + goto Exit; } /* Print table header for iASL/disassembler only */ #ifdef ACPI_ASL_COMPILER - AcpiTbPrintTableHeader (0, Table); + AcpiTbPrintTableHeader (0, Table); #endif /* Allocate and link a table descriptor */ TableDesc = AcpiOsAllocate (sizeof (ACPI_NEW_TABLE_DESC)); + if (!TableDesc) + { + AcpiOsFree (Table); + Status = AE_NO_MEMORY; + goto Exit; + } + TableDesc->Table = Table; TableDesc->Next = NULL; @@ -276,7 +285,7 @@ AcGetAllTablesFromFile ( *ReturnListHead = ListHead; } -ErrorExit: +Exit: fclose(File); return (Status); } @@ -334,7 +343,6 @@ AcGetOneTableFromFile ( return (Status); } - if (GetOnlyAmlTables) { /* diff --git a/source/common/dmtbdump.c b/source/common/dmtbdump.c index fe4ce2fd3..ae4827656 100644 --- a/source/common/dmtbdump.c +++ b/source/common/dmtbdump.c @@ -124,31 +124,12 @@ ACPI_MODULE_NAME ("dmtbdump") -/* Table of revision-dependent FADT sizes */ +/* Local prototypes */ -static const UINT32 FadtRevisionLength [ACPI_FADT_MAX_VERSION + 1] = -{ - 0, /* 0 - illegal */ - ACPI_FADT_V1_SIZE, /* 1 - ACPI 1.0 */ - 0, /* 2 - illegal */ - ACPI_FADT_V3_SIZE, /* 3 - ACPI 2.0 */ - ACPI_FADT_V4_SIZE, /* 4 - ACPI 3.0 and ACPI 4.0 */ - ACPI_FADT_V5_SIZE, /* 5 - ACPI 5.0 */ - ACPI_FADT_V6_SIZE /* 6 - ACPI 6.0 */ -}; - -/* Table of revision-dependent FADT info tables */ - -ACPI_DMTABLE_INFO *FadtRevisionInfo [ACPI_FADT_MAX_VERSION + 1] = -{ - NULL, /* 0 - illegal */ - AcpiDmTableInfoFadt1, /* 1 - ACPI 1.0 */ - NULL, /* 2 - illegal */ - AcpiDmTableInfoFadt3, /* 3 - ACPI 2.0 */ - AcpiDmTableInfoFadt4, /* 4 - ACPI 3.0 and ACPI 4.0 */ - AcpiDmTableInfoFadt5, /* 5 - ACPI 5.0 */ - AcpiDmTableInfoFadt6 /* 6 - ACPI 6.0 */ -}; +static void +AcpiDmValidateFadtLength ( + UINT32 Revision, + UINT32 Length); /******************************************************************************* @@ -438,11 +419,6 @@ AcpiDmDumpXsdt ( * * DESCRIPTION: Format the contents of a FADT * - * Check the FADT revision against the expected table length for - * that revision. Issue a warning if the length is not what was - * expected. This seems to be such a common BIOS bug that the - * FADT revision has been rendered virtually meaningless. - * * NOTE: We cannot depend on the FADT version to indicate the actual * contents of the FADT because of BIOS bugs. The table length * is the only reliable indicator. @@ -454,72 +430,142 @@ AcpiDmDumpFadt ( ACPI_TABLE_HEADER *Table) { ACPI_STATUS Status; - UINT8 FadtRevision; - UINT32 ExpectedLength; - UINT32 i; - - FadtRevision = Table->Revision; - /* FADT revision/length validation */ + /* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */ - if ((FadtRevision == 0) || - (FadtRevision == 2)) + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt1); + if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ( - "// ACPI Warning: Invalid or unsupported FADT revision: %u\n", - FadtRevision); return; } - if (FadtRevision > ACPI_FADT_MAX_VERSION) - { - AcpiOsPrintf ("// ACPI Warning: Revision %u is not fully supported, " - "disassembling known fields (up to revision %u)\n\n", - FadtRevision, ACPI_FADT_MAX_VERSION); - } - else + /* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */ + + if ((Table->Length > ACPI_FADT_V1_SIZE) && + (Table->Length <= ACPI_FADT_V2_SIZE)) { - ExpectedLength = FadtRevisionLength[FadtRevision]; - if (Table->Length != ExpectedLength) + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt2); + if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ( - "// ACPI Warning: Input FADT revision %X does not match " - "expected length: found 0x%X expected 0x%X\n", - FadtRevision, Table->Length, ExpectedLength); + return; } } - /* - * Dump the input table on a per-version basis, but is actually - * based upon the length of the table. Table length must - * be larger than the required length of the previous version. - */ - for (i = 1; i <= ACPI_FADT_MAX_VERSION; i++) + /* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */ + + else if (Table->Length > ACPI_FADT_V2_SIZE) { - if (!FadtRevisionLength[i]) /* Skip any empty slots */ + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt3); + if (ACPI_FAILURE (Status)) { - continue; + return; } - /* Dump the fields specific to FADT revision[i] */ + /* Check for FADT revision 5 fields and up (ACPI 5.0+) */ - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, - FadtRevisionInfo[i]); - if (ACPI_FAILURE (Status)) + if (Table->Length > ACPI_FADT_V3_SIZE) { - return; + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt5); + if (ACPI_FAILURE (Status)) + { + return; + } } - if (Table->Length <= FadtRevisionLength[i]) + /* Check for FADT revision 6 fields and up (ACPI 6.0+) */ + + if (Table->Length > ACPI_FADT_V3_SIZE) { - break; /* End of table */ + Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, + AcpiDmTableInfoFadt6); + if (ACPI_FAILURE (Status)) + { + return; + } } } - /* Build a local FADT to test some FADT values */ + /* Validate various fields in the FADT, including length */ AcpiTbCreateLocalFadt (Table, Table->Length); + + /* Validate FADT length against the revision */ + + AcpiDmValidateFadtLength (Table->Revision, Table->Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmValidateFadtLength + * + * PARAMETERS: Revision - FADT revision (Header->Revision) + * Length - FADT length (Header->Length + * + * RETURN: None + * + * DESCRIPTION: Check the FADT revision against the expected table length for + * that revision. Issue a warning if the length is not what was + * expected. This seems to be such a common BIOS bug that the + * FADT revision has been rendered virtually meaningless. + * + ******************************************************************************/ + +static void +AcpiDmValidateFadtLength ( + UINT32 Revision, + UINT32 Length) +{ + UINT32 ExpectedLength; + + + switch (Revision) + { + case 0: + + AcpiOsPrintf ("// ACPI Warning: Invalid FADT revision: 0\n"); + return; + + case 1: + + ExpectedLength = ACPI_FADT_V1_SIZE; + break; + + case 2: + + ExpectedLength = ACPI_FADT_V2_SIZE; + break; + + case 3: + case 4: + + ExpectedLength = ACPI_FADT_V3_SIZE; + break; + + case 5: + + ExpectedLength = ACPI_FADT_V5_SIZE; + break; + + default: + + return; + } + + if (Length == ExpectedLength) + { + return; + } + + AcpiOsPrintf ( + "\n// ACPI Warning: FADT revision %X does not match length: " + "found %X expected %X\n", + Revision, Length, ExpectedLength); } diff --git a/source/common/dmtbinfo.c b/source/common/dmtbinfo.c index e92072437..522ed00e4 100644 --- a/source/common/dmtbinfo.c +++ b/source/common/dmtbinfo.c @@ -472,7 +472,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[] = * ******************************************************************************/ -/* FADT version 1 (ACPI 1.0) */ +/* ACPI 1.0 FADT (Version 1) */ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[] = { @@ -558,7 +558,18 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[] = ACPI_DMT_TERMINATOR }; -/* FADT version 3 (ACPI 2.0) */ +/* ACPI 1.0 MS Extensions (FADT version 2) */ + +ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[] = +{ + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset", 0}, + {ACPI_DMT_UINT16, ACPI_FADT_OFFSET (ArmBootFlags), "Reserved", 0}, + {ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MinorRevision), "Reserved", 0}, + ACPI_DMT_TERMINATOR +}; + +/* ACPI 2.0+ Extensions (FADT version 3, 4, and 5) */ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[] = { @@ -582,23 +593,16 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[] = ACPI_DMT_TERMINATOR }; -/* FADT version 4 (ACPI 3.0 and ACPI 4.0) */ - -ACPI_DMTABLE_INFO AcpiDmTableInfoFadt4[] = -{ - {ACPI_DMT_GAS, ACPI_FADT_OFFSET (SleepControl), "Sleep Control Register", 0}, - ACPI_DMT_TERMINATOR -}; - -/* FADT version 5 (ACPI 5.0) */ +/* ACPI 5.0 Extensions (FADT version 5) */ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt5[] = { + {ACPI_DMT_GAS, ACPI_FADT_OFFSET (SleepControl), "Sleep Control Register", 0}, {ACPI_DMT_GAS, ACPI_FADT_OFFSET (SleepStatus), "Sleep Status Register", 0}, ACPI_DMT_TERMINATOR }; -/* FADT version 6 (ACPI 6.0) */ +/* ACPI 6.0 Extensions (FADT version 6) */ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt6[] = { diff --git a/source/compiler/dttable.c b/source/compiler/dttable.c index ee3d26d59..561c5ce15 100644 --- a/source/compiler/dttable.c +++ b/source/compiler/dttable.c @@ -201,12 +201,9 @@ DtCompileFadt ( DT_SUBTABLE *ParentTable; DT_FIELD **PFieldList = (DT_FIELD **) List; ACPI_TABLE_HEADER *Table; - UINT8 FadtRevision; - UINT32 i; + UINT8 Revision; - /* Minimum table is the FADT version 1 (ACPI 1.0) */ - Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1, &Subtable, TRUE); if (ACPI_FAILURE (Status)) @@ -218,41 +215,22 @@ DtCompileFadt ( DtInsertSubtable (ParentTable, Subtable); Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer); - FadtRevision = Table->Revision; - - /* Revision 0 and 2 are illegal */ - - if ((FadtRevision == 0) || - (FadtRevision == 2)) - { - DtError (ASL_ERROR, 0, NULL, - "Invalid value for FADT revision"); - - return (AE_BAD_VALUE); - } - - /* Revision out of supported range? */ + Revision = Table->Revision; - if (FadtRevision > ACPI_FADT_MAX_VERSION) + if (Revision == 2) { - DtError (ASL_ERROR, 0, NULL, - "Unknown or unsupported value for FADT revision"); - - return (AE_BAD_VALUE); - } - - /* Compile individual sub-parts of the FADT, per-revision */ - - for (i = 3; i <= ACPI_FADT_MAX_VERSION; i++) - { - if (i > FadtRevision) + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt2, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) { - break; + return (Status); } - /* Compile the fields specific to this FADT revision */ - - Status = DtCompileTable (PFieldList, FadtRevisionInfo[i], + DtInsertSubtable (ParentTable, Subtable); + } + else if (Revision >= 2) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt3, &Subtable, TRUE); if (ACPI_FAILURE (Status)) { @@ -260,6 +238,30 @@ DtCompileFadt ( } DtInsertSubtable (ParentTable, Subtable); + + if (Revision >= 5) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt5, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } + + if (Revision >= 6) + { + Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt6, + &Subtable, TRUE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + DtInsertSubtable (ParentTable, Subtable); + } } return (AE_OK); diff --git a/source/components/debugger/dbinput.c b/source/components/debugger/dbinput.c index f41ad81fd..6bcb84be5 100644 --- a/source/components/debugger/dbinput.c +++ b/source/components/debugger/dbinput.c @@ -136,10 +136,6 @@ AcpiDbMatchCommand ( char *UserCommand); static void -AcpiDbSingleThread ( - void); - -static void AcpiDbDisplayCommandInfo ( const char *Command, BOOLEAN DisplayAll); @@ -1303,61 +1299,17 @@ void ACPI_SYSTEM_XFACE AcpiDbExecuteThread ( void *Context) { - ACPI_STATUS Status = AE_OK; - ACPI_STATUS MStatus; - - - while (Status != AE_CTRL_TERMINATE && !AcpiGbl_DbTerminateLoop) - { - AcpiGbl_MethodExecuting = FALSE; - AcpiGbl_StepToNextCall = FALSE; - MStatus = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, - ACPI_WAIT_FOREVER); - if (ACPI_FAILURE (MStatus)) - { - return; - } - - Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL); - - AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete); - } + (void) AcpiDbUserCommands (); AcpiGbl_DbThreadsTerminated = TRUE; } /******************************************************************************* * - * FUNCTION: AcpiDbSingleThread - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Debugger execute thread. Waits for a command line, then - * simply dispatches it. - * - ******************************************************************************/ - -static void -AcpiDbSingleThread ( - void) -{ - - AcpiGbl_MethodExecuting = FALSE; - AcpiGbl_StepToNextCall = FALSE; - - (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL); -} - - -/******************************************************************************* - * * FUNCTION: AcpiDbUserCommands * - * PARAMETERS: Prompt - User prompt (depends on mode) - * Op - Current executing parse op + * PARAMETERS: None * * RETURN: None * @@ -1368,8 +1320,7 @@ AcpiDbSingleThread ( ACPI_STATUS AcpiDbUserCommands ( - char Prompt, - ACPI_PARSE_OBJECT *Op) + void) { ACPI_STATUS Status = AE_OK; @@ -1380,55 +1331,33 @@ AcpiDbUserCommands ( while (!AcpiGbl_DbTerminateLoop) { - /* Force output to console until a command is entered */ - - AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); - - /* Different prompt if method is executing */ + /* Wait the readiness of the command */ - if (!AcpiGbl_MethodExecuting) - { - AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT); - } - else + Status = AcpiOsWaitCommandReady (); + if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT); + break; } - /* Get the user input line */ + /* Just call to the command line interpreter */ - Status = AcpiOsGetLine (AcpiGbl_DbLineBuf, - ACPI_DB_LINE_BUFFER_SIZE, NULL); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line")); - return (Status); - } + AcpiGbl_MethodExecuting = FALSE; + AcpiGbl_StepToNextCall = FALSE; - /* Check for single or multithreaded debug */ + (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL); - if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) - { - /* - * Signal the debug thread that we have a command to execute, - * and wait for the command to complete. - */ - AcpiOsReleaseMutex (AcpiGbl_DbCommandReady); - - Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete, - ACPI_WAIT_FOREVER); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - else - { - /* Just call to the command line interpreter */ + /* Notify the completion of the command */ - AcpiDbSingleThread (); + Status = AcpiOsNotifyCommandComplete (); + if (ACPI_FAILURE (Status)) + { + break; } } + if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE) + { + ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line")); + } return (Status); } diff --git a/source/components/debugger/dbxface.c b/source/components/debugger/dbxface.c index fe803bc9a..6a1c231f9 100644 --- a/source/components/debugger/dbxface.c +++ b/source/components/debugger/dbxface.c @@ -167,50 +167,23 @@ AcpiDbStartCommand ( AcpiGbl_MethodExecuting = TRUE; Status = AE_CTRL_TRUE; + while (Status == AE_CTRL_TRUE) { - if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED) - { - /* Handshake with the front-end that gets user command lines */ + /* Notify the completion of the command */ - AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete); - - Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, - ACPI_WAIT_FOREVER); - if (ACPI_FAILURE (Status)) - { - return (Status); - } - } - else + Status = AcpiOsNotifyCommandComplete (); + if (ACPI_FAILURE (Status)) { - /* Single threaded, we must get a command line ourselves */ - - /* Force output to console until a command is entered */ - - AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); - - /* Different prompt if method is executing */ - - if (!AcpiGbl_MethodExecuting) - { - AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT); - } - else - { - AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT); - } + goto ErrorExit; + } - /* Get the user input line */ + /* Wait the readiness of the command */ - Status = AcpiOsGetLine (AcpiGbl_DbLineBuf, - ACPI_DB_LINE_BUFFER_SIZE, NULL); - if (ACPI_FAILURE (Status)) - { - ACPI_EXCEPTION ((AE_INFO, Status, - "While parsing command line")); - return (Status); - } + Status = AcpiOsWaitCommandReady (); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; } Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op); @@ -218,6 +191,12 @@ AcpiDbStartCommand ( /* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */ +ErrorExit: + if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While parsing/handling command line")); + } return (Status); } @@ -565,16 +544,7 @@ AcpiInitializeDebugger ( { /* These were created with one unit, grab it */ - Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete, - ACPI_WAIT_FOREVER); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not get debugger mutex\n"); - return_ACPI_STATUS (Status); - } - - Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, - ACPI_WAIT_FOREVER); + Status = AcpiOsInitializeDebugger (); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not get debugger mutex\n"); @@ -628,14 +598,14 @@ AcpiTerminateDebugger ( if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) { - AcpiOsReleaseMutex (AcpiGbl_DbCommandReady); - /* Wait the AML Debugger threads */ while (!AcpiGbl_DbThreadsTerminated) { AcpiOsSleep (100); } + + AcpiOsTerminateDebugger (); } if (AcpiGbl_DbBuffer) diff --git a/source/components/executer/exfldio.c b/source/components/executer/exfldio.c index b7e86fdb0..578ba48e0 100644 --- a/source/components/executer/exfldio.c +++ b/source/components/executer/exfldio.c @@ -1018,20 +1018,9 @@ AcpiExInsertIntoField ( AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth); - /* - * Create the bitmasks used for bit insertion. - * Note: This if/else is used to bypass compiler differences with the - * shift operator - */ - if (AccessBitWidth == ACPI_INTEGER_BIT_SIZE) - { - WidthMask = ACPI_UINT64_MAX; - } - else - { - WidthMask = ACPI_MASK_BITS_ABOVE (AccessBitWidth); - } + /* Create the bitmasks used for bit insertion */ + WidthMask = ACPI_MASK_BITS_ABOVE_64 (AccessBitWidth); Mask = WidthMask & ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); diff --git a/source/components/hardware/hwregs.c b/source/components/hardware/hwregs.c index ffad33fcf..1f9e4c245 100644 --- a/source/components/hardware/hwregs.c +++ b/source/components/hardware/hwregs.c @@ -126,6 +126,12 @@ /* Local Prototypes */ +static UINT8 +AcpiHwGetAccessBitWidth ( + UINT64 Address, + ACPI_GENERIC_ADDRESS *Reg, + UINT8 MaxBitWidth); + static ACPI_STATUS AcpiHwReadMultiple ( UINT32 *Value, @@ -143,6 +149,90 @@ AcpiHwWriteMultiple ( /****************************************************************************** * + * FUNCTION: AcpiHwGetAccessBitWidth + * + * PARAMETERS: Address - GAS register address + * Reg - GAS register structure + * MaxBitWidth - Max BitWidth supported (32 or 64) + * + * RETURN: Status + * + * DESCRIPTION: Obtain optimal access bit width + * + ******************************************************************************/ + +static UINT8 +AcpiHwGetAccessBitWidth ( + UINT64 Address, + ACPI_GENERIC_ADDRESS *Reg, + UINT8 MaxBitWidth) +{ + UINT8 AccessBitWidth; + + + /* + * GAS format "register", used by FADT: + * 1. Detected if BitOffset is 0 and BitWidth is 8/16/32/64; + * 2. AccessSize field is ignored and BitWidth field is used for + * determining the boundary of the IO accesses. + * GAS format "region", used by APEI registers: + * 1. Detected if BitOffset is not 0 or BitWidth is not 8/16/32/64; + * 2. AccessSize field is used for determining the boundary of the + * IO accesses; + * 3. BitOffset/BitWidth fields are used to describe the "region". + * + * Note: This algorithm assumes that the "Address" fields should always + * contain aligned values. + */ + if (!Reg->BitOffset && Reg->BitWidth && + ACPI_IS_POWER_OF_TWO (Reg->BitWidth) && + ACPI_IS_ALIGNED (Reg->BitWidth, 8)) + { + AccessBitWidth = Reg->BitWidth; + } + else if (Reg->AccessWidth) + { + AccessBitWidth = (1 << (Reg->AccessWidth + 2)); + } + else + { + AccessBitWidth = ACPI_ROUND_UP_POWER_OF_TWO_8 ( + Reg->BitOffset + Reg->BitWidth); + if (AccessBitWidth <= 8) + { + AccessBitWidth = 8; + } + else + { + while (!ACPI_IS_ALIGNED (Address, AccessBitWidth >> 3)) + { + AccessBitWidth >>= 1; + } + } + } + + /* Maximum IO port access bit width is 32 */ + + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO) + { + MaxBitWidth = 32; + } + + /* + * Return access width according to the requested maximum access bit width, + * as the caller should know the format of the register and may enforce + * a 32-bit accesses. + */ + if (AccessBitWidth < MaxBitWidth) + { + return (AccessBitWidth); + } + return (MaxBitWidth); +} + + +/****************************************************************************** + * * FUNCTION: AcpiHwValidateRegister * * PARAMETERS: Reg - GAS register structure @@ -163,6 +253,9 @@ AcpiHwValidateRegister ( UINT8 MaxBitWidth, UINT64 *Address) { + UINT8 BitWidth; + UINT8 AccessWidth; + /* Must have a valid pointer to a GAS structure */ @@ -192,24 +285,25 @@ AcpiHwValidateRegister ( return (AE_SUPPORT); } - /* Validate the BitWidth */ + /* Validate the AccessWidth */ - if ((Reg->BitWidth != 8) && - (Reg->BitWidth != 16) && - (Reg->BitWidth != 32) && - (Reg->BitWidth != MaxBitWidth)) + if (Reg->AccessWidth > 4) { ACPI_ERROR ((AE_INFO, - "Unsupported register bit width: 0x%X", Reg->BitWidth)); + "Unsupported register access width: 0x%X", Reg->AccessWidth)); return (AE_SUPPORT); } - /* Validate the BitOffset. Just a warning for now. */ + /* Validate the BitWidth, convert AccessWidth into number of bits */ - if (Reg->BitOffset != 0) + AccessWidth = AcpiHwGetAccessBitWidth (*Address, Reg, MaxBitWidth); + BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth); + if (MaxBitWidth < BitWidth) { ACPI_WARNING ((AE_INFO, - "Unsupported register bit offset: 0x%X", Reg->BitOffset)); + "Requested bit width 0x%X is smaller than register bit width 0x%X", + MaxBitWidth, BitWidth)); + return (AE_SUPPORT); } return (AE_OK); @@ -230,10 +324,7 @@ AcpiHwValidateRegister ( * 64-bit values is not needed. * * LIMITATIONS: <These limitations also apply to AcpiHwWrite> - * BitWidth must be exactly 8, 16, or 32. * SpaceID must be SystemMemory or SystemIO. - * BitOffset and AccessWidth are currently ignored, as there has - * not been a need to implement these. * ******************************************************************************/ @@ -243,7 +334,12 @@ AcpiHwRead ( ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; + UINT8 AccessWidth; + UINT32 BitWidth; + UINT8 BitOffset; UINT64 Value64; + UINT32 Value32; + UINT8 Index; ACPI_STATUS Status; @@ -258,30 +354,58 @@ AcpiHwRead ( return (Status); } - /* Initialize entire 32-bit return value to zero */ - + /* + * Initialize entire 32-bit return value to zero, convert AccessWidth + * into number of bits based + */ *Value = 0; + AccessWidth = AcpiHwGetAccessBitWidth (Address, Reg, 32); + BitWidth = Reg->BitOffset + Reg->BitWidth; + BitOffset = Reg->BitOffset; /* * Two address spaces supported: Memory or IO. PCI_Config is * not supported here because the GAS structure is insufficient */ - if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + Index = 0; + while (BitWidth) { - Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) - Address, &Value64, Reg->BitWidth); + if (BitOffset >= AccessWidth) + { + Value32 = 0; + BitOffset -= AccessWidth; + } + else + { + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + &Value64, AccessWidth); + Value32 = (UINT32) Value64; + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + &Value32, AccessWidth); + } + } - *Value = (UINT32) Value64; - } - else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ - { - Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) - Address, Value, Reg->BitWidth); + /* + * Use offset style bit writes because "Index * AccessWidth" is + * ensured to be less than 32-bits by AcpiHwValidateRegister(). + */ + ACPI_SET_BITS (Value, Index * AccessWidth, + ACPI_MASK_BITS_ABOVE_32 (AccessWidth), Value32); + + BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth; + Index++; } ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", - *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + *Value, AccessWidth, ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); @@ -309,6 +433,12 @@ AcpiHwWrite ( ACPI_GENERIC_ADDRESS *Reg) { UINT64 Address; + UINT8 AccessWidth; + UINT32 BitWidth; + UINT8 BitOffset; + UINT64 Value64; + UINT32 Value32; + UINT8 Index; ACPI_STATUS Status; @@ -323,24 +453,58 @@ AcpiHwWrite ( return (Status); } + /* Convert AccessWidth into number of bits based */ + + AccessWidth = AcpiHwGetAccessBitWidth (Address, Reg, 32); + BitWidth = Reg->BitOffset + Reg->BitWidth; + BitOffset = Reg->BitOffset; + /* * Two address spaces supported: Memory or IO. PCI_Config is * not supported here because the GAS structure is insufficient */ - if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + Index = 0; + while (BitWidth) { - Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) - Address, (UINT64) Value, Reg->BitWidth); - } - else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ - { - Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) - Address, Value, Reg->BitWidth); + /* + * Use offset style bit reads because "Index * AccessWidth" is + * ensured to be less than 32-bits by AcpiHwValidateRegister(). + */ + Value32 = ACPI_GET_BITS (&Value, Index * AccessWidth, + ACPI_MASK_BITS_ABOVE_32 (AccessWidth)); + + if (BitOffset >= AccessWidth) + { + BitOffset -= AccessWidth; + } + else + { + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Value64 = (UINT64) Value32; + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + Value64, AccessWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address + Index * ACPI_DIV_8 (AccessWidth), + Value32, AccessWidth); + } + } + + /* + * Index * AccessWidth is ensured to be less than 32-bits by + * AcpiHwValidateRegister(). + */ + BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth; + Index++; } ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", - Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + Value, AccessWidth, ACPI_FORMAT_UINT64 (Address), AcpiUtGetRegionName (Reg->SpaceId))); return (Status); diff --git a/source/components/tables/tbfadt.c b/source/components/tables/tbfadt.c index 4085db300..f3b6c1cd3 100644 --- a/source/components/tables/tbfadt.c +++ b/source/components/tables/tbfadt.c @@ -595,19 +595,17 @@ AcpiTbConvertFadt ( /* - * For ACPI 1.0 FADTs (revision 1), ensure that reserved fields which + * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which * should be zero are indeed zero. This will workaround BIOSs that * inadvertently place values in these fields. * * The ACPI 1.0 reserved fields that will be zeroed are the bytes located * at offset 45, 55, 95, and the word located at offset 109, 110. * - * Note: The FADT revision value is unreliable because of BIOS errors. - * The table length is instead used as the final word on the version. - * - * Note: FADT revision 3 is the ACPI 2.0 version of the FADT. + * Note: The FADT revision value is unreliable. Only the length can be + * trusted. */ - if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V3_SIZE) + if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE) { AcpiGbl_FADT.PreferredProfile = 0; AcpiGbl_FADT.PstateControl = 0; diff --git a/source/components/utilities/utmutex.c b/source/components/utilities/utmutex.c index d80a57c8d..aaf366065 100644 --- a/source/components/utilities/utmutex.c +++ b/source/components/utilities/utmutex.c @@ -201,19 +201,6 @@ AcpiUtMutexInitialize ( return_ACPI_STATUS (Status); } -#ifdef ACPI_DEBUGGER - - /* Debugger Support */ - - Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandReady); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandComplete); -#endif - return_ACPI_STATUS (Status); } @@ -259,12 +246,6 @@ AcpiUtMutexTerminate ( /* Delete the reader/writer lock */ AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock); - -#ifdef ACPI_DEBUGGER - AcpiOsDeleteMutex (AcpiGbl_DbCommandReady); - AcpiOsDeleteMutex (AcpiGbl_DbCommandComplete); -#endif - return_VOID; } diff --git a/source/include/acdebug.h b/source/include/acdebug.h index c7cfc54f3..ac44660ec 100644 --- a/source/include/acdebug.h +++ b/source/include/acdebug.h @@ -493,8 +493,7 @@ AcpiDbExecuteThread ( ACPI_STATUS AcpiDbUserCommands ( - char Prompt, - ACPI_PARSE_OBJECT *Op); + void); char * AcpiDbGetNextToken ( diff --git a/source/include/acdisasm.h b/source/include/acdisasm.h index 640ecf532..9c01d88bd 100644 --- a/source/include/acdisasm.h +++ b/source/include/acdisasm.h @@ -352,8 +352,8 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoErst[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoErst0[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[]; -extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt4[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt5[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt6[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt[]; @@ -497,9 +497,6 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoXenv[]; extern ACPI_DMTABLE_INFO AcpiDmTableInfoGeneric[][2]; -extern ACPI_DMTABLE_INFO *FadtRevisionInfo [ACPI_FADT_MAX_VERSION + 1]; - - /* * dmtable and ahtable */ diff --git a/source/include/acglobal.h b/source/include/acglobal.h index eb48d408d..d9817411c 100644 --- a/source/include/acglobal.h +++ b/source/include/acglobal.h @@ -403,7 +403,6 @@ ACPI_GLOBAL (ACPI_EXTERNAL_FILE *, AcpiGbl_ExternalFileList); #ifdef ACPI_DEBUGGER ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_AbortMethod, FALSE); -ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_MethodExecuting, FALSE); ACPI_INIT_GLOBAL (ACPI_THREAD_ID, AcpiGbl_DbThreadId, ACPI_INVALID_THREAD_ID); ACPI_GLOBAL (BOOLEAN, AcpiGbl_DbOpt_NoIniMethods); @@ -422,7 +421,6 @@ ACPI_GLOBAL (ACPI_OBJECT_TYPE, AcpiGbl_DbArgTypes[ACPI_DEBUGGER_MAX_ARG /* These buffers should all be the same size */ -ACPI_GLOBAL (char, AcpiGbl_DbLineBuf[ACPI_DB_LINE_BUFFER_SIZE]); ACPI_GLOBAL (char, AcpiGbl_DbParsedBuf[ACPI_DB_LINE_BUFFER_SIZE]); ACPI_GLOBAL (char, AcpiGbl_DbScopeBuf[ACPI_DB_LINE_BUFFER_SIZE]); ACPI_GLOBAL (char, AcpiGbl_DbDebugFilename[ACPI_DB_LINE_BUFFER_SIZE]); @@ -437,9 +435,6 @@ ACPI_GLOBAL (UINT16, AcpiGbl_NodeTypeCountMisc); ACPI_GLOBAL (UINT32, AcpiGbl_NumNodes); ACPI_GLOBAL (UINT32, AcpiGbl_NumObjects); -ACPI_GLOBAL (ACPI_MUTEX, AcpiGbl_DbCommandReady); -ACPI_GLOBAL (ACPI_MUTEX, AcpiGbl_DbCommandComplete); - #endif /* ACPI_DEBUGGER */ #if defined (ACPI_DISASSEMBLER) || defined (ACPI_ASL_COMPILER) diff --git a/source/include/acmacros.h b/source/include/acmacros.h index a805a32ce..0cecfa022 100644 --- a/source/include/acmacros.h +++ b/source/include/acmacros.h @@ -336,14 +336,91 @@ #define ACPI_IS_MISALIGNED(value) (((ACPI_SIZE) value) & (sizeof(ACPI_SIZE)-1)) +/* Generic (power-of-two) rounding */ + +#ifndef ACPI_USE_NATIVE_BIT_FINDER + +#define __ACPI_FIND_LAST_BIT_2(a, r) ((((UINT8) (a)) & 0x02) ? (r)+1 : (r)) +#define __ACPI_FIND_LAST_BIT_4(a, r) ((((UINT8) (a)) & 0x0C) ? \ + __ACPI_FIND_LAST_BIT_2 ((a)>>2, (r)+2) : \ + __ACPI_FIND_LAST_BIT_2 ((a), (r))) +#define __ACPI_FIND_LAST_BIT_8(a, r) ((((UINT8) (a)) & 0xF0) ? \ + __ACPI_FIND_LAST_BIT_4 ((a)>>4, (r)+4) : \ + __ACPI_FIND_LAST_BIT_4 ((a), (r))) +#define __ACPI_FIND_LAST_BIT_16(a, r) ((((UINT16) (a)) & 0xFF00) ? \ + __ACPI_FIND_LAST_BIT_8 ((a)>>8, (r)+8) : \ + __ACPI_FIND_LAST_BIT_8 ((a), (r))) +#define __ACPI_FIND_LAST_BIT_32(a, r) ((((UINT32) (a)) & 0xFFFF0000) ? \ + __ACPI_FIND_LAST_BIT_16 ((a)>>16, (r)+16) : \ + __ACPI_FIND_LAST_BIT_16 ((a), (r))) +#define __ACPI_FIND_LAST_BIT_64(a, r) ((((UINT64) (a)) & 0xFFFFFFFF00000000) ? \ + __ACPI_FIND_LAST_BIT_32 ((a)>>32, (r)+32) : \ + __ACPI_FIND_LAST_BIT_32 ((a), (r))) + +#define ACPI_FIND_LAST_BIT_8(a) ((a) ? __ACPI_FIND_LAST_BIT_8 (a, 1) : 0) +#define ACPI_FIND_LAST_BIT_16(a) ((a) ? __ACPI_FIND_LAST_BIT_16 (a, 1) : 0) +#define ACPI_FIND_LAST_BIT_32(a) ((a) ? __ACPI_FIND_LAST_BIT_32 (a, 1) : 0) +#define ACPI_FIND_LAST_BIT_64(a) ((a) ? __ACPI_FIND_LAST_BIT_64 (a, 1) : 0) + +#define __ACPI_FIND_FIRST_BIT_2(a, r) ((((UINT8) (a)) & 0x01) ? (r) : (r)+1) +#define __ACPI_FIND_FIRST_BIT_4(a, r) ((((UINT8) (a)) & 0x03) ? \ + __ACPI_FIND_FIRST_BIT_2 ((a), (r)) : \ + __ACPI_FIND_FIRST_BIT_2 ((a)>>2, (r)+2)) +#define __ACPI_FIND_FIRST_BIT_8(a, r) ((((UINT8) (a)) & 0x0F) ? \ + __ACPI_FIND_FIRST_BIT_4 ((a), (r)) : \ + __ACPI_FIND_FIRST_BIT_4 ((a)>>4, (r)+4)) +#define __ACPI_FIND_FIRST_BIT_16(a, r) ((((UINT16) (a)) & 0x00FF) ? \ + __ACPI_FIND_FIRST_BIT_8 ((a), (r)) : \ + __ACPI_FIND_FIRST_BIT_8 ((a)>>8, (r)+8)) +#define __ACPI_FIND_FIRST_BIT_32(a, r) ((((UINT32) (a)) & 0x0000FFFF) ? \ + __ACPI_FIND_FIRST_BIT_16 ((a), (r)) : \ + __ACPI_FIND_FIRST_BIT_16 ((a)>>16, (r)+16)) +#define __ACPI_FIND_FIRST_BIT_64(a, r) ((((UINT64) (a)) & 0x00000000FFFFFFFF) ? \ + __ACPI_FIND_FIRST_BIT_32 ((a), (r)) : \ + __ACPI_FIND_FIRST_BIT_32 ((a)>>32, (r)+32)) + +#define ACPI_FIND_FIRST_BIT_8(a) ((a) ? __ACPI_FIND_FIRST_BIT_8 (a, 1) : 0) +#define ACPI_FIND_FIRST_BIT_16(a) ((a) ? __ACPI_FIND_FIRST_BIT_16 (a, 1) : 0) +#define ACPI_FIND_FIRST_BIT_32(a) ((a) ? __ACPI_FIND_FIRST_BIT_32 (a, 1) : 0) +#define ACPI_FIND_FIRST_BIT_64(a) ((a) ? __ACPI_FIND_FIRST_BIT_64 (a, 1) : 0) + +#endif /* ACPI_USE_NATIVE_BIT_FINDER */ + +#define ACPI_ROUND_UP_POWER_OF_TWO_8(a) ((UINT8) \ + (((UINT16) 1) << ACPI_FIND_LAST_BIT_8 ((a) - 1))) +#define ACPI_ROUND_DOWN_POWER_OF_TWO_8(a) ((UINT8) \ + (((UINT16) 1) << (ACPI_FIND_LAST_BIT_8 ((a)) - 1))) +#define ACPI_ROUND_UP_POWER_OF_TWO_16(a) ((UINT16) \ + (((UINT32) 1) << ACPI_FIND_LAST_BIT_16 ((a) - 1))) +#define ACPI_ROUND_DOWN_POWER_OF_TWO_16(a) ((UINT16) \ + (((UINT32) 1) << (ACPI_FIND_LAST_BIT_16 ((a)) - 1))) +#define ACPI_ROUND_UP_POWER_OF_TWO_32(a) ((UINT32) \ + (((UINT64) 1) << ACPI_FIND_LAST_BIT_32 ((a) - 1))) +#define ACPI_ROUND_DOWN_POWER_OF_TWO_32(a) ((UINT32) \ + (((UINT64) 1) << (ACPI_FIND_LAST_BIT_32 ((a)) - 1))) +#define ACPI_IS_ALIGNED(a, s) (((a) & ((s) - 1)) == 0) +#define ACPI_IS_POWER_OF_TWO(a) ACPI_IS_ALIGNED(a, a) + /* * Bitmask creation * Bit positions start at zero. * MASK_BITS_ABOVE creates a mask starting AT the position and above * MASK_BITS_BELOW creates a mask starting one bit BELOW the position + * MASK_BITS_ABOVE/BELOW accpets a bit offset to create a mask + * MASK_BITS_ABOVE/BELOW_32/64 accpets a bit width to create a mask + * Note: The ACPI_INTEGER_BIT_SIZE check is used to bypass compiler + * differences with the shift operator */ #define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_UINT64_MAX) << ((UINT32) (position)))) #define ACPI_MASK_BITS_BELOW(position) ((ACPI_UINT64_MAX) << ((UINT32) (position))) +#define ACPI_MASK_BITS_ABOVE_32(width) ((UINT32) ACPI_MASK_BITS_ABOVE(width)) +#define ACPI_MASK_BITS_BELOW_32(width) ((UINT32) ACPI_MASK_BITS_BELOW(width)) +#define ACPI_MASK_BITS_ABOVE_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \ + ACPI_UINT64_MAX : \ + ACPI_MASK_BITS_ABOVE(width)) +#define ACPI_MASK_BITS_BELOW_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \ + (UINT64) 0 : \ + ACPI_MASK_BITS_BELOW(width)) /* Bitfields within ACPI registers */ diff --git a/source/include/acpiosxf.h b/source/include/acpiosxf.h index df8393e61..c4d160685 100644 --- a/source/include/acpiosxf.h +++ b/source/include/acpiosxf.h @@ -562,7 +562,7 @@ AcpiOsRedirectOutput ( /* - * Debug input + * Debug IO */ #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetLine ACPI_STATUS @@ -572,6 +572,30 @@ AcpiOsGetLine ( UINT32 *BytesRead); #endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitializeDebugger +ACPI_STATUS +AcpiOsInitializeDebugger ( + void); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminateDebugger +void +AcpiOsTerminateDebugger ( + void); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWaitCommandReady +ACPI_STATUS +AcpiOsWaitCommandReady ( + void); +#endif + +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsNotifyCommandComplete +ACPI_STATUS +AcpiOsNotifyCommandComplete ( + void); +#endif + #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTracePoint void AcpiOsTracePoint ( diff --git a/source/include/acpixf.h b/source/include/acpixf.h index bd75a5b5d..c491ae159 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.h @@ -118,7 +118,7 @@ /* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20160930 +#define ACPI_CA_VERSION 0x20161117 #include "acconfig.h" #include "actypes.h" @@ -365,6 +365,15 @@ ACPI_INIT_GLOBAL (UINT32, AcpiDbgLayer, ACPI_COMPONENT_DEFAULT); ACPI_INIT_GLOBAL (UINT8, AcpiGbl_DisplayDebugTimer, FALSE); /* + * Debugger command handshake globals. Host OSes need to access these + * variables to implement their own command handshake mechanism. + */ +#ifdef ACPI_DEBUGGER +ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_MethodExecuting, FALSE); +ACPI_GLOBAL (char, AcpiGbl_DbLineBuf[ACPI_DB_LINE_BUFFER_SIZE]); +#endif + +/* * Other miscellaneous globals */ ACPI_GLOBAL (ACPI_TABLE_FADT, AcpiGbl_FADT); @@ -1339,6 +1348,10 @@ AcpiTerminateDebugger ( void); void +AcpiRunDebugger ( + char *BatchBuffer); + +void AcpiSetDebuggerThreadId ( ACPI_THREAD_ID ThreadId); diff --git a/source/include/actbl.h b/source/include/actbl.h index 73415fc40..4d7fd8afa 100644 --- a/source/include/actbl.h +++ b/source/include/actbl.h @@ -328,72 +328,62 @@ typedef struct acpi_table_facs typedef struct acpi_table_fadt { - ACPI_TABLE_HEADER Header; /* [V1] Common ACPI table header */ - UINT32 Facs; /* [V1] 32-bit physical address of FACS */ - UINT32 Dsdt; /* [V1] 32-bit physical address of DSDT */ - UINT8 Model; /* [V1] System Interrupt Model (ACPI 1.0) - not used in ACPI 2.0+ */ - UINT8 PreferredProfile; /* [V1] Conveys preferred power management profile to OSPM. */ - UINT16 SciInterrupt; /* [V1] System vector of SCI interrupt */ - UINT32 SmiCommand; /* [V1] 32-bit Port address of SMI command port */ - UINT8 AcpiEnable; /* [V1] Value to write to SMI_CMD to enable ACPI */ - UINT8 AcpiDisable; /* [V1] Value to write to SMI_CMD to disable ACPI */ - UINT8 S4BiosRequest; /* [V1] Value to write to SMI_CMD to enter S4BIOS state */ - UINT8 PstateControl; /* [V1] Processor performance state control*/ - UINT32 Pm1aEventBlock; /* [V1] 32-bit port address of Power Mgt 1a Event Reg Blk */ - UINT32 Pm1bEventBlock; /* [V1] 32-bit port address of Power Mgt 1b Event Reg Blk */ - UINT32 Pm1aControlBlock; /* [V1] 32-bit port address of Power Mgt 1a Control Reg Blk */ - UINT32 Pm1bControlBlock; /* [V1] 32-bit port address of Power Mgt 1b Control Reg Blk */ - UINT32 Pm2ControlBlock; /* [V1] 32-bit port address of Power Mgt 2 Control Reg Blk */ - UINT32 PmTimerBlock; /* [V1] 32-bit port address of Power Mgt Timer Ctrl Reg Blk */ - UINT32 Gpe0Block; /* [V1] 32-bit port address of General Purpose Event 0 Reg Blk */ - UINT32 Gpe1Block; /* [V1] 32-bit port address of General Purpose Event 1 Reg Blk */ - UINT8 Pm1EventLength; /* [V1] Byte Length of ports at Pm1xEventBlock */ - UINT8 Pm1ControlLength; /* [V1] Byte Length of ports at Pm1xControlBlock */ - UINT8 Pm2ControlLength; /* [V1] Byte Length of ports at Pm2ControlBlock */ - UINT8 PmTimerLength; /* [V1] Byte Length of ports at PmTimerBlock */ - UINT8 Gpe0BlockLength; /* [V1] Byte Length of ports at Gpe0Block */ - UINT8 Gpe1BlockLength; /* [V1] Byte Length of ports at Gpe1Block */ - UINT8 Gpe1Base; /* [V1] Offset in GPE number space where GPE1 events start */ - UINT8 CstControl; /* [V1] Support for the _CST object and C-States change notification */ - UINT16 C2Latency; /* [V1] Worst case HW latency to enter/exit C2 state */ - UINT16 C3Latency; /* [V1] Worst case HW latency to enter/exit C3 state */ - UINT16 FlushSize; /* [V1] Processor memory cache line width, in bytes */ - UINT16 FlushStride; /* [V1] Number of flush strides that need to be read */ - UINT8 DutyOffset; /* [V1] Processor duty cycle index in processor P_CNT reg */ - UINT8 DutyWidth; /* [V1] Processor duty cycle value bit width in P_CNT register */ - UINT8 DayAlarm; /* [V1] Index to day-of-month alarm in RTC CMOS RAM */ - UINT8 MonthAlarm; /* [V1] Index to month-of-year alarm in RTC CMOS RAM */ - UINT8 Century; /* [V1] Index to century in RTC CMOS RAM */ - UINT16 BootFlags; /* [V3] IA-PC Boot Architecture Flags (see below for individual flags) */ - UINT8 Reserved; /* [V1] Reserved, must be zero */ - UINT32 Flags; /* [V1] Miscellaneous flag bits (see below for individual flags) */ - /* End of Version 1 FADT fields (ACPI 1.0) */ - - ACPI_GENERIC_ADDRESS ResetRegister; /* [V3] 64-bit address of the Reset register */ - UINT8 ResetValue; /* [V3] Value to write to the ResetRegister port to reset the system */ - UINT16 ArmBootFlags; /* [V5] ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */ - UINT8 MinorRevision; /* [V5] FADT Minor Revision (ACPI 5.1) */ - UINT64 XFacs; /* [V3] 64-bit physical address of FACS */ - UINT64 XDsdt; /* [V3] 64-bit physical address of DSDT */ - ACPI_GENERIC_ADDRESS XPm1aEventBlock; /* [V3] 64-bit Extended Power Mgt 1a Event Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm1bEventBlock; /* [V3] 64-bit Extended Power Mgt 1b Event Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm1aControlBlock; /* [V3] 64-bit Extended Power Mgt 1a Control Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm1bControlBlock; /* [V3] 64-bit Extended Power Mgt 1b Control Reg Blk address */ - ACPI_GENERIC_ADDRESS XPm2ControlBlock; /* [V3] 64-bit Extended Power Mgt 2 Control Reg Blk address */ - ACPI_GENERIC_ADDRESS XPmTimerBlock; /* [V3] 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ - ACPI_GENERIC_ADDRESS XGpe0Block; /* [V3] 64-bit Extended General Purpose Event 0 Reg Blk address */ - ACPI_GENERIC_ADDRESS XGpe1Block; /* [V3] 64-bit Extended General Purpose Event 1 Reg Blk address */ - /* End of Version 3 FADT fields (ACPI 2.0) */ - - ACPI_GENERIC_ADDRESS SleepControl; /* [V4] 64-bit Sleep Control register (ACPI 5.0) */ - /* End of Version 4 FADT fields (ACPI 3.0 and ACPI 4.0) (Field was originally reserved in ACPI 3.0) */ - - ACPI_GENERIC_ADDRESS SleepStatus; /* [V5] 64-bit Sleep Status register (ACPI 5.0) */ - /* End of Version 5 FADT fields (ACPI 5.0) */ - - UINT64 HypervisorId; /* [V6] Hypervisor Vendor ID (ACPI 6.0) */ - /* End of Version 6 FADT fields (ACPI 6.0) */ - + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Facs; /* 32-bit physical address of FACS */ + UINT32 Dsdt; /* 32-bit physical address of DSDT */ + UINT8 Model; /* System Interrupt Model (ACPI 1.0) - not used in ACPI 2.0+ */ + UINT8 PreferredProfile; /* Conveys preferred power management profile to OSPM. */ + UINT16 SciInterrupt; /* System vector of SCI interrupt */ + UINT32 SmiCommand; /* 32-bit Port address of SMI command port */ + UINT8 AcpiEnable; /* Value to write to SMI_CMD to enable ACPI */ + UINT8 AcpiDisable; /* Value to write to SMI_CMD to disable ACPI */ + UINT8 S4BiosRequest; /* Value to write to SMI_CMD to enter S4BIOS state */ + UINT8 PstateControl; /* Processor performance state control*/ + UINT32 Pm1aEventBlock; /* 32-bit port address of Power Mgt 1a Event Reg Blk */ + UINT32 Pm1bEventBlock; /* 32-bit port address of Power Mgt 1b Event Reg Blk */ + UINT32 Pm1aControlBlock; /* 32-bit port address of Power Mgt 1a Control Reg Blk */ + UINT32 Pm1bControlBlock; /* 32-bit port address of Power Mgt 1b Control Reg Blk */ + UINT32 Pm2ControlBlock; /* 32-bit port address of Power Mgt 2 Control Reg Blk */ + UINT32 PmTimerBlock; /* 32-bit port address of Power Mgt Timer Ctrl Reg Blk */ + UINT32 Gpe0Block; /* 32-bit port address of General Purpose Event 0 Reg Blk */ + UINT32 Gpe1Block; /* 32-bit port address of General Purpose Event 1 Reg Blk */ + UINT8 Pm1EventLength; /* Byte Length of ports at Pm1xEventBlock */ + UINT8 Pm1ControlLength; /* Byte Length of ports at Pm1xControlBlock */ + UINT8 Pm2ControlLength; /* Byte Length of ports at Pm2ControlBlock */ + UINT8 PmTimerLength; /* Byte Length of ports at PmTimerBlock */ + UINT8 Gpe0BlockLength; /* Byte Length of ports at Gpe0Block */ + UINT8 Gpe1BlockLength; /* Byte Length of ports at Gpe1Block */ + UINT8 Gpe1Base; /* Offset in GPE number space where GPE1 events start */ + UINT8 CstControl; /* Support for the _CST object and C-States change notification */ + UINT16 C2Latency; /* Worst case HW latency to enter/exit C2 state */ + UINT16 C3Latency; /* Worst case HW latency to enter/exit C3 state */ + UINT16 FlushSize; /* Processor memory cache line width, in bytes */ + UINT16 FlushStride; /* Number of flush strides that need to be read */ + UINT8 DutyOffset; /* Processor duty cycle index in processor P_CNT reg */ + UINT8 DutyWidth; /* Processor duty cycle value bit width in P_CNT register */ + UINT8 DayAlarm; /* Index to day-of-month alarm in RTC CMOS RAM */ + UINT8 MonthAlarm; /* Index to month-of-year alarm in RTC CMOS RAM */ + UINT8 Century; /* Index to century in RTC CMOS RAM */ + UINT16 BootFlags; /* IA-PC Boot Architecture Flags (see below for individual flags) */ + UINT8 Reserved; /* Reserved, must be zero */ + UINT32 Flags; /* Miscellaneous flag bits (see below for individual flags) */ + ACPI_GENERIC_ADDRESS ResetRegister; /* 64-bit address of the Reset register */ + UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system */ + UINT16 ArmBootFlags; /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */ + UINT8 MinorRevision; /* FADT Minor Revision (ACPI 5.1) */ + UINT64 XFacs; /* 64-bit physical address of FACS */ + UINT64 XDsdt; /* 64-bit physical address of DSDT */ + ACPI_GENERIC_ADDRESS XPm1aEventBlock; /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bEventBlock; /* 64-bit Extended Power Mgt 1b Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1aControlBlock; /* 64-bit Extended Power Mgt 1a Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bControlBlock; /* 64-bit Extended Power Mgt 1b Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm2ControlBlock; /* 64-bit Extended Power Mgt 2 Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPmTimerBlock; /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe0Block; /* 64-bit Extended General Purpose Event 0 Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe1Block; /* 64-bit Extended General Purpose Event 1 Reg Blk address */ + ACPI_GENERIC_ADDRESS SleepControl; /* 64-bit Sleep Control register (ACPI 5.0) */ + ACPI_GENERIC_ADDRESS SleepStatus; /* 64-bit Sleep Status register (ACPI 5.0) */ + UINT64 HypervisorId; /* Hypervisor Vendor ID (ACPI 6.0) */ } ACPI_TABLE_FADT; @@ -409,8 +399,8 @@ typedef struct acpi_table_fadt /* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) ACPI 5.1 */ -#define ACPI_FADT_PSCI_COMPLIANT (1) /* 00: [V5] PSCI 0.2+ is implemented */ -#define ACPI_FADT_PSCI_USE_HVC (1<<1) /* 01: [V5] HVC must be used instead of SMC as the PSCI conduit */ +#define ACPI_FADT_PSCI_COMPLIANT (1) /* 00: [V5+] PSCI 0.2+ is implemented */ +#define ACPI_FADT_PSCI_USE_HVC (1<<1) /* 01: [V5+] HVC must be used instead of SMC as the PSCI conduit */ /* Masks for FADT flags */ @@ -518,34 +508,20 @@ typedef struct acpi_table_desc * match the expected length. In other words, the length of the * FADT is the bottom line as to what the version really is. * - * NOTE: There is no officialy released V2 of the FADT. This - * version was used only for prototyping and testing during the - * 32-bit to 64-bit transition. V3 was the first official 64-bit - * version of the FADT. - * - * Update this list of defines when a new version of the FADT is - * added to the ACPI specification. Note that the FADT version is - * only incremented when new fields are appended to the existing - * version. Therefore, the FADT version is competely independent - * from the version of the ACPI specification where it is - * defined. - * - * For reference, the various FADT lengths are as follows: - * FADT V1 size: 0x074 ACPI 1.0 - * FADT V3 size: 0x0F4 ACPI 2.0 - * FADT V4 size: 0x100 ACPI 3.0 and ACPI 4.0 - * FADT V5 size: 0x10C ACPI 5.0 - * FADT V6 size: 0x114 ACPI 6.0 + * For reference, the values below are as follows: + * FADT V1 size: 0x074 + * FADT V2 size: 0x084 + * FADT V3 size: 0x0F4 + * FADT V4 size: 0x0F4 + * FADT V5 size: 0x10C + * FADT V6 size: 0x114 */ -#define ACPI_FADT_V1_SIZE (UINT32) (ACPI_FADT_OFFSET (Flags) + 4) /* ACPI 1.0 */ -#define ACPI_FADT_V3_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepControl)) /* ACPI 2.0 */ -#define ACPI_FADT_V4_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepStatus)) /* ACPI 3.0 and ACPI 4.0 */ -#define ACPI_FADT_V5_SIZE (UINT32) (ACPI_FADT_OFFSET (HypervisorId)) /* ACPI 5.0 */ -#define ACPI_FADT_V6_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT)) /* ACPI 6.0 */ - -/* Update these when new FADT versions are added */ +#define ACPI_FADT_V1_SIZE (UINT32) (ACPI_FADT_OFFSET (Flags) + 4) +#define ACPI_FADT_V2_SIZE (UINT32) (ACPI_FADT_OFFSET (MinorRevision) + 1) +#define ACPI_FADT_V3_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepControl)) +#define ACPI_FADT_V5_SIZE (UINT32) (ACPI_FADT_OFFSET (HypervisorId)) +#define ACPI_FADT_V6_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT)) -#define ACPI_FADT_MAX_VERSION 6 #define ACPI_FADT_CONFORMANCE "ACPI 6.1 (FADT version 6)" #endif /* __ACTBL_H__ */ diff --git a/source/include/platform/aclinux.h b/source/include/platform/aclinux.h index 6f7c5775e..27803ad31 100644 --- a/source/include/platform/aclinux.h +++ b/source/include/platform/aclinux.h @@ -225,6 +225,8 @@ */ #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadable #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritable +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitializeDebugger +#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminateDebugger /* * OSL interfaces used by utilities @@ -265,7 +267,8 @@ #define ACPI_CAST_PTHREAD_T(Pthread) ((ACPI_THREAD_ID) (Pthread)) #if defined(__ia64__) || defined(__x86_64__) ||\ - defined(__aarch64__) || defined(__PPC64__) + defined(__aarch64__) || defined(__PPC64__) ||\ + defined(__s390x__) #define ACPI_MACHINE_WIDTH 64 #define COMPILER_DEPENDENT_INT64 long #define COMPILER_DEPENDENT_UINT64 unsigned long diff --git a/source/include/platform/aclinuxex.h b/source/include/platform/aclinuxex.h index 7f24989c9..c39672d43 100644 --- a/source/include/platform/aclinuxex.h +++ b/source/include/platform/aclinuxex.h @@ -216,6 +216,20 @@ AcpiOsReadable ( return TRUE; } +static inline ACPI_STATUS +AcpiOsInitializeDebugger ( + void) +{ + return AE_OK; +} + +static inline void +AcpiOsTerminateDebugger ( + void) +{ + return; +} + /* * OSL interfaces added by Linux diff --git a/source/os_specific/service_layers/osgendbg.c b/source/os_specific/service_layers/osgendbg.c new file mode 100644 index 000000000..10791d871 --- /dev/null +++ b/source/os_specific/service_layers/osgendbg.c @@ -0,0 +1,438 @@ +/****************************************************************************** + * + * Module Name: osgendbg - Generic debugger command singalling + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2015, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include "acpi.h" +#include "accommon.h" +#include "acdebug.h" + + +#define _COMPONENT ACPI_CA_DEBUGGER + ACPI_MODULE_NAME ("osgendbg") + + +/* Local prototypes */ + +static void +AcpiDbRunRemoteDebugger ( + char *BatchBuffer); + + +static ACPI_MUTEX AcpiGbl_DbCommandReady; +static ACPI_MUTEX AcpiGbl_DbCommandComplete; +static BOOLEAN AcpiGbl_DbCommandSignalsInitialized = FALSE; + +/****************************************************************************** + * + * FUNCTION: AcpiDbRunRemoteDebugger + * + * PARAMETERS: BatchBuffer - Buffer containing commands running in + * the batch mode + * + * RETURN: None + * + * DESCRIPTION: Run multi-threading debugger remotely + * + *****************************************************************************/ + +static void +AcpiDbRunRemoteDebugger ( + char *BatchBuffer) +{ + ACPI_STATUS Status; + char *Ptr = BatchBuffer; + char *Cmd = Ptr; + + + while (!AcpiGbl_DbTerminateLoop) + { + if (BatchBuffer) + { + if (*Ptr) + { + while (*Ptr) + { + if (*Ptr == ',') + { + /* Convert commas to spaces */ + *Ptr = ' '; + } + else if (*Ptr == ';') + { + *Ptr = '\0'; + continue; + } + + Ptr++; + } + + strcpy (AcpiGbl_DbLineBuf, Cmd); + Ptr++; + Cmd = Ptr; + } + else + { + return; + } + } + else + { + /* Force output to console until a command is entered */ + + AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); + + /* Different prompt if method is executing */ + + if (!AcpiGbl_MethodExecuting) + { + AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT); + } + else + { + AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT); + } + + /* Get the user input line */ + + Status = AcpiOsGetLine (AcpiGbl_DbLineBuf, + ACPI_DB_LINE_BUFFER_SIZE, NULL); + if (ACPI_FAILURE (Status)) + { + return; + } + } + + /* + * Signal the debug thread that we have a command to execute, + * and wait for the command to complete. + */ + AcpiOsReleaseMutex (AcpiGbl_DbCommandReady); + + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete, + ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return; + } + } +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsWaitCommandReady + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Negotiate with the debugger foreground thread (the user + * thread) to wait the readiness of a command. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsWaitCommandReady ( + void) +{ + ACPI_STATUS Status = AE_OK; + + + if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED) + { + Status = AE_TIME; + + while (Status == AE_TIME) + { + if (AcpiGbl_DbTerminateLoop) + { + Status = AE_CTRL_TERMINATE; + } + else + { + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, 1000); + } + } + } + else + { + /* Force output to console until a command is entered */ + + AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); + + /* Different prompt if method is executing */ + + if (!AcpiGbl_MethodExecuting) + { + AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT); + } + else + { + AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT); + } + + /* Get the user input line */ + + Status = AcpiOsGetLine (AcpiGbl_DbLineBuf, + ACPI_DB_LINE_BUFFER_SIZE, NULL); + } + + if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While parsing/handling command line")); + } + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsNotifyCommandComplete + * + * PARAMETERS: void + * + * RETURN: Status + * + * DESCRIPTION: Negotiate with the debugger foreground thread (the user + * thread) to notify the completion of a command. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsNotifyCommandComplete ( + void) +{ + + if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED) + { + AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete); + } + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsInitializeDebugger + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize OSPM specific part of the debugger + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsInitializeDebugger ( + void) +{ + ACPI_STATUS Status; + + + /* Create command signals */ + + Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandReady); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandComplete); + if (ACPI_FAILURE (Status)) + { + goto ErrorReady; + } + + /* Initialize the states of the command signals */ + + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete, + ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + goto ErrorComplete; + } + Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, + ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + goto ErrorComplete; + } + + AcpiGbl_DbCommandSignalsInitialized = TRUE; + return (Status); + +ErrorComplete: + AcpiOsDeleteMutex (AcpiGbl_DbCommandComplete); +ErrorReady: + AcpiOsDeleteMutex (AcpiGbl_DbCommandReady); + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiOsTerminateDebugger + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Terminate signals used by the multi-threading debugger + * + *****************************************************************************/ + +void +AcpiOsTerminateDebugger ( + void) +{ + + if (AcpiGbl_DbCommandSignalsInitialized) + { + AcpiOsDeleteMutex (AcpiGbl_DbCommandReady); + AcpiOsDeleteMutex (AcpiGbl_DbCommandComplete); + } +} + + +/****************************************************************************** + * + * FUNCTION: AcpiRunDebugger + * + * PARAMETERS: BatchBuffer - Buffer containing commands running in + * the batch mode + * + * RETURN: None + * + * DESCRIPTION: Run a local/remote debugger + * + *****************************************************************************/ + +void +AcpiRunDebugger ( + char *BatchBuffer) +{ + /* Check for single or multithreaded debug */ + + if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED) + { + AcpiDbRunRemoteDebugger (BatchBuffer); + } + else + { + AcpiDbUserCommands (); + } +} + +ACPI_EXPORT_SYMBOL (AcpiRunDebugger) diff --git a/source/tools/acpiexec/aemain.c b/source/tools/acpiexec/aemain.c index 2b3f81020..6ed8f3be8 100644 --- a/source/tools/acpiexec/aemain.c +++ b/source/tools/acpiexec/aemain.c @@ -138,10 +138,6 @@ AeDoOptions ( int argc, char **argv); -static void -AcpiDbRunBatchMode ( - void); - #define AE_BUFFER_SIZE 1024 #define ASL_MAX_FILES 256 @@ -735,12 +731,12 @@ EnterDebugger: default: case AE_MODE_COMMAND_LOOP: - AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL); + AcpiRunDebugger (NULL); break; case AE_MODE_BATCH_MULTIPLE: - AcpiDbRunBatchMode (); + AcpiRunDebugger (BatchBuffer); break; case AE_MODE_BATCH_SINGLE: @@ -751,12 +747,7 @@ EnterDebugger: /* Shut down the debugger and ACPICA */ -#if 0 - - /* Temporarily removed */ AcpiTerminateDebugger (); - (void) AcpiTerminate (); -#endif NormalExit: ExitCode = 0; @@ -765,55 +756,3 @@ ErrorExit: (void) AcpiOsTerminate (); return (ExitCode); } - - -/****************************************************************************** - * - * FUNCTION: AcpiDbRunBatchMode - * - * PARAMETERS: BatchCommandLine - A semicolon separated list of commands - * to be executed. - * Use only commas to separate elements of - * particular command. - * RETURN: None - * - * DESCRIPTION: For each command of list separated by ';' prepare the command - * buffer and pass it to AcpiDbCommandDispatch. - * - *****************************************************************************/ - -static void -AcpiDbRunBatchMode ( - void) -{ - 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; - } - } -} diff --git a/source/tools/acpixtract/acpixtract.c b/source/tools/acpixtract/acpixtract.c index bb937a902..0ea473fae 100644 --- a/source/tools/acpixtract/acpixtract.c +++ b/source/tools/acpixtract/acpixtract.c @@ -159,7 +159,7 @@ AxExtractTables ( /* Open input in text mode, output is in binary mode */ - InputFile = fopen (InputPathname, "rt"); + InputFile = fopen (InputPathname, "r"); if (!InputFile) { printf ("Could not open input file %s\n", InputPathname); @@ -358,7 +358,7 @@ AxExtractToMultiAmlFile ( /* Open the input file in text mode */ - InputFile = fopen (InputPathname, "rt"); + InputFile = fopen (InputPathname, "r"); if (!InputFile) { printf ("Could not open input file %s\n", InputPathname); @@ -489,7 +489,7 @@ AxListTables ( /* Open input in text mode, output is in binary mode */ - InputFile = fopen (InputPathname, "rt"); + InputFile = fopen (InputPathname, "r"); if (!InputFile) { printf ("Could not open input file %s\n", InputPathname); diff --git a/source/tools/acpixtract/axutils.c b/source/tools/acpixtract/axutils.c index 280ee4546..bf24e8622 100644 --- a/source/tools/acpixtract/axutils.c +++ b/source/tools/acpixtract/axutils.c @@ -172,9 +172,9 @@ AxIsEmptyLine ( Buffer++; } - /* If end-of-line, this line is empty */ + /* Line is empty when a Unix or DOS-style line terminator is found. */ - if (*Buffer == '\n') + if ((*Buffer == '\r') || (*Buffer == '\n')) { return (1); } @@ -334,7 +334,7 @@ AxCountTableInstances ( unsigned int Instances = 0; - InputFile = fopen (InputPathname, "rt"); + InputFile = fopen (InputPathname, "r"); if (!InputFile) { printf ("Could not open input file %s\n", InputPathname); diff --git a/tests/aslts/HOW_TO_USE b/tests/aslts/HOW_TO_USE index cb6c23630..233fdbb03 100644 --- a/tests/aslts/HOW_TO_USE +++ b/tests/aslts/HOW_TO_USE @@ -71,7 +71,7 @@ How to execute the run-time tests and the batch execute option. For example: > cd aslts/tmp/aml - > acpiexec -eMAIN 20090320/nopt/32/arithmetic.aml + > acpiexec -b "Execute MAIN" 20090320/nopt/32/arithmetic.aml 6. When all tests are executed in batch mode (Do 1), the individual test diff --git a/tests/aslts/src/runtime/cntl/runmode.asl b/tests/aslts/src/runtime/cntl/runmode.asl index 48bb125c2..1c84838a9 100644 --- a/tests/aslts/src/runtime/cntl/runmode.asl +++ b/tests/aslts/src/runtime/cntl/runmode.asl @@ -29,7 +29,7 @@ /* * Run Tests Parameters Technique (RTPT) * - * Tese parameters have effect only when + * These parameters have effect only when * running a group of tests (collections) * such as all Functional tests, all Complex * tests, all Exceptions tests, Full test @@ -37,10 +37,10 @@ * * Main flag: * 0 - run unconditionally all tests - * 1 - run all the tests whit non-zero params - * 2 - run all the tests whit zero params - * 3 - run all the tests whit params equal to RUN1 - * 4 - run one the particular test specified so: + * 1 - run all the tests with non-zero params + * 2 - run all the tests with zero params + * 3 - run all the tests with params equal to RUN1 + * 4 - run a particular test specified by: * RUN2 - index of collection * RUN3 - index of the test inside the collection */ @@ -117,7 +117,7 @@ Method(SRTP, 1) { /* * Set up the particular desirable set of tests to be run * - * Tese parameters have effect only when + * These parameters have effect only when * running a group of test cases or even * collections) such as all Functional tests, * all Complex tests, all Exceptions tests, @@ -128,10 +128,10 @@ Method(SRTP, 1) { * * RUN0 - main flag * 0 - run unconditionally all tests - * 1 - run all the tests whit non-zero params - * 2 - run all the tests whit zero params - * 3 - run all the tests whit params equal to RUN1 - * 4 - run one the particular test specified in this way: + * 1 - run all the tests with non-zero params + * 2 - run all the tests with zero params + * 3 - run all the tests with params equal to RUN1 + * 4 - run a particular test specified by: * RUN2 - index of collection * 1 - functional * 2 - complex @@ -143,7 +143,7 @@ Method(SRTP, 1) { */ Method(RTPI) { -// PARAMETRES OF MODE +// PARAMETERS OF MODE Store(0, RUN0) // main flag Store(0, RUN1) // level @@ -200,8 +200,8 @@ Store(1, W018) // condbranches 0 * ATTENTION: all these variables should be set to 1 eventually * (after all bugs fixing). * - * Lyout of variable name: y<xxx> - xxx is the number of bug - * 0 - dont run + * Format of variable name: y<xxx> - xxx is the number of bug + * 0 - do not run * non-zero - run * * ATTENTION: see all the qXXX & rnXX conditions of the particular @@ -377,7 +377,7 @@ Name(y902, 1) // Expected is that Serialized method being invoked recursively on * All them should be set to non-zero after * clarifying the relevant issue, or provided * with the comment clarifying what is wrong in - * the sub-test - dont remove them even in the + * the sub-test - don't remove them even in the * latter case. */ Name(q001, 1) // Dereference of Store(Index(x,x,Index(x,x)), Index(x,x)) |