diff options
author | Robert Moore <Robert.Moore@intel.com> | 2016-12-02 12:54:50 -0800 |
---|---|---|
committer | Robert Moore <Robert.Moore@intel.com> | 2016-12-02 12:54:50 -0800 |
commit | bee9af547cc31e365620a5ad40c88b882636ab5b (patch) | |
tree | 6bc164e589e7586b385e26bf134d9d3b6ad90bba | |
parent | aa72e7745f9a801c836b7804fe041559038972b8 (diff) | |
parent | e033071cf5e989ec31e922dbc86702546de7a7d0 (diff) | |
download | acpica-bee9af547cc31e365620a5ad40c88b882636ab5b.tar.gz |
Merge branch 'master' of ssh://ssh.github.com/acpica/acpica
-rwxr-xr-x | generate/msvc/AcpiExec.dsp | 4 | ||||
-rwxr-xr-x | generate/msvc9/AcpiExec.vcproj | 4 | ||||
-rw-r--r-- | generate/unix/acpiexec/Makefile | 1 | ||||
-rw-r--r-- | source/components/debugger/dbinput.c | 111 | ||||
-rw-r--r-- | source/components/debugger/dbxface.c | 70 | ||||
-rw-r--r-- | source/components/executer/exfldio.c | 15 | ||||
-rw-r--r-- | source/components/hardware/hwesleep.c | 27 | ||||
-rw-r--r-- | source/components/hardware/hwregs.c | 230 | ||||
-rw-r--r-- | source/components/hardware/hwsleep.c | 10 | ||||
-rw-r--r-- | source/components/utilities/utmutex.c | 19 | ||||
-rw-r--r-- | source/include/acdebug.h | 3 | ||||
-rw-r--r-- | source/include/acexcep.h | 8 | ||||
-rw-r--r-- | source/include/acglobal.h | 5 | ||||
-rw-r--r-- | source/include/acmacros.h | 77 | ||||
-rw-r--r-- | source/include/acpiosxf.h | 34 | ||||
-rw-r--r-- | source/include/acpixf.h | 13 | ||||
-rw-r--r-- | source/include/platform/aclinux.h | 5 | ||||
-rw-r--r-- | source/include/platform/aclinuxex.h | 14 | ||||
-rw-r--r-- | source/os_specific/service_layers/osgendbg.c | 438 | ||||
-rw-r--r-- | source/os_specific/service_layers/osunixxf.c | 27 | ||||
-rw-r--r-- | source/os_specific/service_layers/oswinxf.c | 27 | ||||
-rw-r--r-- | source/tools/acpiexec/aemain.c | 65 |
22 files changed, 915 insertions, 292 deletions
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/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/hwesleep.c b/source/components/hardware/hwesleep.c index 51f006b20..05f5b49f1 100644 --- a/source/components/hardware/hwesleep.c +++ b/source/components/hardware/hwesleep.c @@ -185,7 +185,7 @@ AcpiHwExtendedSleep ( UINT8 SleepState) { ACPI_STATUS Status; - UINT8 SleepTypeValue; + UINT8 SleepControl; UINT64 SleepStatus; @@ -211,10 +211,6 @@ AcpiHwExtendedSleep ( AcpiGbl_SystemAwakeAndRunning = FALSE; - /* Flush caches, as per ACPI specification */ - - ACPI_FLUSH_CPU_CACHE (); - /* * Set the SLP_TYP and SLP_EN bits. * @@ -224,11 +220,24 @@ AcpiHwExtendedSleep ( ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Entering sleep state [S%u]\n", SleepState)); - SleepTypeValue = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) & - ACPI_X_SLEEP_TYPE_MASK); + SleepControl = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) & + ACPI_X_SLEEP_TYPE_MASK) | ACPI_X_SLEEP_ENABLE; + + /* Flush caches, as per ACPI specification */ + + ACPI_FLUSH_CPU_CACHE (); + + Status = AcpiOsEnterSleep (SleepState, SleepControl, 0); + if (Status == AE_CTRL_TERMINATE) + { + return_ACPI_STATUS (AE_OK); + } + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } - Status = AcpiWrite ((UINT64) (SleepTypeValue | ACPI_X_SLEEP_ENABLE), - &AcpiGbl_FADT.SleepControl); + Status = AcpiWrite ((UINT64) SleepControl, &AcpiGbl_FADT.SleepControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); 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/hardware/hwsleep.c b/source/components/hardware/hwsleep.c index c2a2a7f0a..567e312ad 100644 --- a/source/components/hardware/hwsleep.c +++ b/source/components/hardware/hwsleep.c @@ -231,6 +231,16 @@ AcpiHwLegacySleep ( ACPI_FLUSH_CPU_CACHE (); + Status = AcpiOsEnterSleep (SleepState, Pm1aControl, Pm1bControl); + if (Status == AE_CTRL_TERMINATE) + { + return_ACPI_STATUS (AE_OK); + } + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + /* Write #2: Write both SLP_TYP + SLP_EN */ Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); 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/acexcep.h b/source/include/acexcep.h index c5217295d..e6d6adb9e 100644 --- a/source/include/acexcep.h +++ b/source/include/acexcep.h @@ -289,11 +289,10 @@ typedef struct acpi_exception_info #define AE_CTRL_TRANSFER EXCEP_CTL (0x0008) #define AE_CTRL_BREAK EXCEP_CTL (0x0009) #define AE_CTRL_CONTINUE EXCEP_CTL (0x000A) -#define AE_CTRL_SKIP EXCEP_CTL (0x000B) -#define AE_CTRL_PARSE_CONTINUE EXCEP_CTL (0x000C) -#define AE_CTRL_PARSE_PENDING EXCEP_CTL (0x000D) +#define AE_CTRL_PARSE_CONTINUE EXCEP_CTL (0x000B) +#define AE_CTRL_PARSE_PENDING EXCEP_CTL (0x000C) -#define AE_CODE_CTRL_MAX 0x000D +#define AE_CODE_CTRL_MAX 0x000C /* Exception strings for AcpiFormatException */ @@ -416,7 +415,6 @@ static const ACPI_EXCEPTION_INFO AcpiGbl_ExceptionNames_Ctrl[] = EXCEP_TXT ("AE_CTRL_TRANSFER", "Transfer control to called method"), EXCEP_TXT ("AE_CTRL_BREAK", "A Break has been executed"), EXCEP_TXT ("AE_CTRL_CONTINUE", "A Continue has been executed"), - EXCEP_TXT ("AE_CTRL_SKIP", "Not currently used"), EXCEP_TXT ("AE_CTRL_PARSE_CONTINUE", "Used to skip over bad opcodes"), EXCEP_TXT ("AE_CTRL_PARSE_PENDING", "Used to implement AML While loops") }; 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 60d61f119..c4d160685 100644 --- a/source/include/acpiosxf.h +++ b/source/include/acpiosxf.h @@ -528,6 +528,14 @@ AcpiOsSignal ( void *Info); #endif +#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsEnterSleep +ACPI_STATUS +AcpiOsEnterSleep ( + UINT8 SleepState, + UINT32 RegaValue, + UINT32 RegbValue); +#endif + /* * Debug print routines @@ -554,7 +562,7 @@ AcpiOsRedirectOutput ( /* - * Debug input + * Debug IO */ #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetLine ACPI_STATUS @@ -564,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 479404b1a..c491ae159 100644 --- a/source/include/acpixf.h +++ b/source/include/acpixf.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/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/os_specific/service_layers/osunixxf.c b/source/os_specific/service_layers/osunixxf.c index 413a708cc..c58bdfba2 100644 --- a/source/os_specific/service_layers/osunixxf.c +++ b/source/os_specific/service_layers/osunixxf.c @@ -433,6 +433,33 @@ AcpiOsPhysicalTableOverride ( /****************************************************************************** * + * FUNCTION: AcpiOsEnterSleep + * + * PARAMETERS: SleepState - Which sleep state to enter + * RegaValue - Register A value + * RegbValue - Register B value + * + * RETURN: Status + * + * DESCRIPTION: A hook before writing sleep registers to enter the sleep + * state. Return AE_CTRL_SKIP to skip further sleep register + * writes. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsEnterSleep ( + UINT8 SleepState, + UINT32 RegaValue, + UINT32 RegbValue) +{ + + return (AE_OK); +} + + +/****************************************************************************** + * * FUNCTION: AcpiOsRedirectOutput * * PARAMETERS: Destination - An open file handle/pointer diff --git a/source/os_specific/service_layers/oswinxf.c b/source/os_specific/service_layers/oswinxf.c index 07f284492..dd0e5f132 100644 --- a/source/os_specific/service_layers/oswinxf.c +++ b/source/os_specific/service_layers/oswinxf.c @@ -361,6 +361,33 @@ AcpiOsPhysicalTableOverride ( /****************************************************************************** * + * FUNCTION: AcpiOsEnterSleep + * + * PARAMETERS: SleepState - Which sleep state to enter + * RegaValue - Register A value + * RegbValue - Register B value + * + * RETURN: Status + * + * DESCRIPTION: A hook before writing sleep registers to enter the sleep + * state. Return AE_CTRL_SKIP to skip further sleep register + * writes. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiOsEnterSleep ( + UINT8 SleepState, + UINT32 RegaValue, + UINT32 RegbValue) +{ + + return (AE_OK); +} + + +/****************************************************************************** + * * FUNCTION: AcpiOsGetTimer * * PARAMETERS: None 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; - } - } -} |