diff options
author | Mark Santcroos <marks@FreeBSD.org> | 2004-12-01 23:14:10 +0000 |
---|---|---|
committer | Mark Santcroos <marks@FreeBSD.org> | 2004-12-01 23:14:10 +0000 |
commit | c846686064718f6ab1d92107f960542f6f400744 (patch) | |
tree | 4910f03edb15ce309eeb1b58facc922df30dd767 /sys/contrib/dev | |
parent | aaff1d4cfa72d64a9dbbcd65e3a6d260280ae397 (diff) | |
download | src-test2-c846686064718f6ab1d92107f960542f6f400744.tar.gz src-test2-c846686064718f6ab1d92107f960542f6f400744.zip |
Notes
Diffstat (limited to 'sys/contrib/dev')
98 files changed, 3896 insertions, 1854 deletions
diff --git a/sys/contrib/dev/acpica/CHANGES.txt b/sys/contrib/dev/acpica/CHANGES.txt index 81ac58d43c13..112d62d52980 100644 --- a/sys/contrib/dev/acpica/CHANGES.txt +++ b/sys/contrib/dev/acpica/CHANGES.txt @@ -1,4 +1,549 @@ ---------------------------------------- +19 November 2004. Summary of changes for version 20041119: + +1) ACPI CA Core Subsystem: + +Fixed a problem in the internal ConvertToInteger routine where new +integers were not truncated to 32 bits for 32-bit ACPI tables. This +routine converts buffers and strings to integers. + +Implemented support to store a value to an Index() on a String object. +This is an ACPI 2.0 feature that had not yet been implemented. + +Implemented new behavior for storing objects to individual package +elements (via the Index() operator). The previous behavior was to invoke +the implicit conversion rules if an object was already present at the +index. The new behavior is to simply delete any existing object and +directly store the new object. Although the ACPI specification seems +unclear on this subject, other ACPI implementations behave in this +manner. (This is the root of the AE_BAD_HEX_CONSTANT issue.) + +Modified the RSDP memory scan mechanism to support the extended checksum +for ACPI 2.0 (and above) RSDPs. Note that the search continues until a +valid RSDP signature is found with a valid checksum. + +Code and Data Size: Current and previous core subsystem library sizes +are shown below. These are the code and data sizes for the acpica.lib +produced by the Microsoft Visual C++ 6.0 compiler, and these values do +not include any ACPI driver or OSPM code. The debug version of the code +includes the debug output trace mechanism and has a much larger code and +data size. Note that these values will vary depending on the efficiency +of the compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.5K Code, 11.5K Data, 90.0K Total + Debug Version: 165.2K Code, 68.6K Data, 233.8K Total + Current Release: + Non-Debug Version: 78.5K Code, 11.5K Data, 90.0K Total + Debug Version: 165.2K Code, 68.6K Data, 233.8K Total + + +2) iASL Compiler/Disassembler: + +Fixed a missing semicolon in the aslcompiler.y file. + +---------------------------------------- +05 November 2004. Summary of changes for version 20041105: + +1) ACPI CA Core Subsystem: + +Implemented support for FADT revision 2. This was an interim +table (between ACPI 1.0 and ACPI 2.0) that adds support for the +FADT reset register. + +Implemented optional support to allow uninitialized LocalX and +ArgX variables in a control method. The variables are +initialized to an Integer object with a value of zero. This +support is enabled by setting the AcpiGbl_EnableInterpreterSlack +flag to TRUE. + +Implemented support for Integer objects for the SizeOf operator. +Either 4 or 8 is returned, depending on the current integer size +(32-bit or 64-bit, depending on the parent table revision). + +Fixed a problem in the implementation of the SizeOf and +ObjectType operators where the operand was resolved to a value +too early, causing incorrect return values for some objects. + +Fixed some possible memory leaks during exceptional conditions. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.0K Code, 11.5K Data, 89.5K Total + Debug Version: 164.8K Code, 68.6K Data, 233.4K Total + Current Release: + Non-Debug Version: 78.5K Code, 11.5K Data, 90.0K Total + Debug Version: 165.2K Code, 68.6K Data, 233.8K Total + + +2) iASL Compiler/Disassembler: + +Implemented support for all ACPI 3.0 reserved names and methods. + +Implemented all ACPI 3.0 grammar elements in the front-end, +including support for semicolons. + +Implemented the ACPI 3.0 Function() and ToUUID() macros + +Fixed a problem in the disassembler where a Scope() operator +would not be emitted properly if the target of the scope was in +another table. + +---------------------------------------- +15 October 2004. Summary of changes for version 20041015: + +Note: ACPI CA is currently undergoing an in-depth and complete +formal evaluation to test/verify the following areas. Other +suggestions are welcome. This will result in an increase in the +frequency of releases and the number of bug fixes in the next few +months. + - Functional tests for all ASL/AML operators + - All implicit/explicit type conversions + - Bit fields and operation regions + - 64-bit math support and 32-bit-only "truncated" math support + - Exceptional conditions, both compiler and interpreter + - Dynamic object deletion and memory leaks + - ACPI 3.0 support when implemented + - External interfaces to the ACPI subsystem + + +1) ACPI CA Core Subsystem: + +Fixed two alignment issues on 64-bit platforms - within debug +statements in AcpiEvGpeDetect and AcpiEvCreateGpeBlock. Removed +references to the Address field within the non-aligned ACPI +generic address structure. + +Fixed a problem in the Increment and Decrement operators where +incorrect operand resolution could result in the inadvertent +modification of the original integer when the integer is passed +into another method as an argument and the arg is then +incremented/decremented. + +Fixed a problem in the FromBCD operator where the upper 32-bits +of a 64-bit BCD number were truncated during conversion. + +Fixed a problem in the ToDecimal operator where the length of the +resulting string could be set incorrectly too long if the input +operand was a Buffer object. + +Fixed a problem in the Logical operators (LLess, etc.) where a +NULL byte (0) within a buffer would prematurely terminate a +compare between buffer objects. + +Added a check for string overflow (>200 characters as per the +ACPI specification) during the Concatenate operator with two +string operands. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.8K Code, 11.5K Data, 89.3K Total + Debug Version: 164.6K Code, 68.5K Data, 233.1K Total + Current Release: + Non-Debug Version: 78.0K Code, 11.5K Data, 89.5K Total + Debug Version: 164.8K Code, 68.6K Data, 233.4K Total + + +2) iASL Compiler/Disassembler: + +Allow the use of the ObjectType operator on uninitialized Locals +and Args (returns 0 as per the ACPI specification). + +Fixed a problem where the compiler would fault if there was a +syntax error in the FieldName of all of the various +CreateXXXField operators. + +Disallow the use of lower case letters within the EISAID macro, +as per the ACPI specification. All EISAID strings must be of the +form "UUUNNNN" Where U is an uppercase letter and N is a hex +digit. + + +---------------------------------------- +06 October 2004. Summary of changes for version 20041006: + +1) ACPI CA Core Subsystem: + +Implemented support for the ACPI 3.0 Timer operator. This ASL +function implements a 64-bit timer with 100 nanosecond +granularity. + +Defined a new OSL interface, AcpiOsGetTimer. This interface is +used to implement the ACPI 3.0 Timer operator. This allows the +host OS to implement the timer with the best clock available. +Also, it keeps the core subsystem out of the clock handling +business, since the host OS (usually) performs this function. + +Fixed an alignment issue on 64-bit platforms. The +HwLowLevelRead(Write) functions use a 64-bit address which is +part of the packed ACPI Generic Address Structure. Since the +structure is non-aligned, the alignment macros are now used to +extract the address to a local variable before use. + +Fixed a problem where the ToInteger operator assumed all input +strings were hexadecimal. The operator now handles both decimal +strings and hex strings (prefixed with "0x"). + +Fixed a problem where the string length in the string object +created as a result of the internal ConvertToString procedure +could be incorrect. This potentially affected all implicit +conversions and also the ToDecimalString and ToHexString +operators. + +Fixed two problems in the ToString operator. If the length +parameter was zero, an incorrect string object was created and +the value of the input length parameter was inadvertently changed +from zero to Ones. + +Fixed a problem where the optional ResourceSource string in the +ExtendedIRQ resource macro was ignored. + +Simplified the interfaces to the internal division functions, +reducing code size and complexity. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.9K Code, 11.4K Data, 89.3K Total + Debug Version: 164.5K Code, 68.3K Data, 232.8K Total + Current Release: + Non-Debug Version: 77.8K Code, 11.5K Data, 89.3K Total + Debug Version: 164.6K Code, 68.5K Data, 233.1K Total + + +2) iASL Compiler/Disassembler: + +Implemented support for the ACPI 3.0 Timer operator. + +Fixed a problem where the Default() operator was inadvertently +ignored in a Switch/Case block. This was a problem in the +translation of the Switch statement to If...Else pairs. + +Added support to allow a standalone Return operator, with no +parentheses (or operands). + +Fixed a problem with code generation for the ElseIf operator +where the translated Else...If parse tree was improperly +constructed leading to the loss of some code. + +---------------------------------------- +22 September 2004. Summary of changes for version 20040922: + +1) ACPI CA Core Subsystem: + +Fixed a problem with the implementation of the LNot() operator +where "Ones" was not returned for the TRUE case. Changed the code +to return Ones instead of (!Arg) which was usually 1. This change +affects iASL constant folding for this operator also. + +Fixed a problem in AcpiUtInitializeBuffer where an existing +buffer was not initialized properly -- Now zero the entire buffer +in this case where the buffer already exists. + +Changed the interface to AcpiOsSleep from (UINT32 Seconds, UINT32 +Milliseconds) to simply (ACPI_INTEGER Milliseconds). This +simplifies all related code considerably. This will require +changes/updates to all OS interface layers (OSLs.) + +Implemented a new external interface, +AcpiInstallExceptionHandler, to allow a system exception handler +to be installed. This handler is invoked upon any run-time +exception that occurs during control method execution. + +Added support for the DSDT in AcpiTbFindTable. This allows the +DataTableRegion() operator to access the local copy of the DSDT. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.8K Code, 11.4K Data, 89.2K Total + Debug Version: 164.2K Code, 68.2K Data, 232.4K Total + Current Release: + Non-Debug Version: 77.9K Code, 11.4K Data, 89.3K Total + Debug Version: 164.5K Code, 68.3K Data, 232.8K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem with constant folding and the LNot operator. LNot +was returning 1 in the TRUE case, not Ones as per the ACPI +specification. This could result in the generation of an +incorrect folded/reduced constant. + +End-Of-File is now allowed within a "//"-style comment. A parse +error no longer occurs if such a comment is at the very end of +the input ASL source file. + +Implemented the "-r" option to override the Revision in the table +header. The initial use of this option will be to simplify the +evaluation of the AML interpreter by allowing a single ASL source +module to be compiled for either 32-bit or 64-bit integers. + + +---------------------------------------- +27 August 2004. Summary of changes for version 20040827: + +1) ACPI CA Core Subsystem: + +- Implemented support for implicit object conversion in the non- +numeric logical operators (LEqual, LGreater, LGreaterEqual, +LLess, LLessEqual, and LNotEqual.) Any combination of +Integers/Strings/Buffers may now be used; the second operand is +implicitly converted on the fly to match the type of the first +operand. For example: + + LEqual (Source1, Source2) + +Source1 and Source2 must each evaluate to an integer, a string, +or a buffer. The data type of Source1 dictates the required type +of Source2. Source2 is implicitly converted if necessary to match +the type of Source1. + +- Updated and corrected the behavior of the string conversion +support. The rules concerning conversion of buffers to strings +(according to the ACPI specification) are as follows: + +ToDecimalString - explicit byte-wise conversion of buffer to +string of decimal values (0-255) separated by commas. ToHexString +- explicit byte-wise conversion of buffer to string of hex values +(0-FF) separated by commas. ToString - explicit byte-wise +conversion of buffer to string. Byte-by-byte copy with no +transform except NULL terminated. Any other implicit buffer-to- +string conversion - byte-wise conversion of buffer to string of +hex values (0-FF) separated by spaces. + +- Fixed typo in definition of AcpiGbl_EnableInterpreterSlack. + +- Fixed a problem in AcpiNsGetPathnameLength where the returned +length was one byte too short in the case of a node in the root +scope. This could cause a fault during debug output. + +- Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.9K Code, 11.5K Data, 89.4K Total + Debug Version: 164.1K Code, 68.3K Data, 232.4K Total + Current Release: + Non-Debug Version: 77.8K Code, 11.4K Data, 89.2K Total + Debug Version: 164.2K Code, 68.2K Data, 232.4K Total + + +2) iASL Compiler/Disassembler: + +- Fixed a Linux generation error. + + +---------------------------------------- +16 August 2004. Summary of changes for version 20040816: + +1) ACPI CA Core Subsystem: + +Designed and implemented support within the AML interpreter for +the so-called "implicit return". This support returns the result +of the last ASL operation within a control method, in the absence +of an explicit Return() operator. A few machines depend on this +behavior, even though it is not explicitly supported by the ASL +language. It is optional support that can be enabled at runtime +via the AcpiGbl_EnableInterpeterSlack flag. + +Removed support for the PCI_Config address space from the +internal low level hardware interfaces (AcpiHwLowLevelRead and +AcpiHwLowLevelWrite). This support was not used internally, and +would not work correctly anyway because the PCI bus number and +segment number were not supported. There are separate interfaces +for PCI configuration space access because of the unique +interface. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 78.0K Code, 11.5K Data, 89.5K Total + Debug Version: 164.1K Code, 68.2K Data, 232.3K Total + Current Release: + Non-Debug Version: 77.9K Code, 11.5K Data, 89.4K Total + Debug Version: 164.1K Code, 68.3K Data, 232.4K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem where constants in ASL expressions at the root +level (not within a control method) could be inadvertently +truncated during code generation. This problem was introduced in +the 20040715 release. + + +---------------------------------------- +15 July 2004. Summary of changes for version 20040715: + +1) ACPI CA Core Subsystem: + +Restructured the internal HW GPE interfaces to pass/track the +current state of interrupts (enabled/disabled) in order to avoid +possible deadlock and increase flexibility of the interfaces. + +Implemented a "lexicographical compare" for String and Buffer +objects within the logical operators -- LGreater, LLess, +LGreaterEqual, and LLessEqual -- as per further clarification to +the ACPI specification. Behavior is similar to C library +"strcmp". + +Completed a major reduction in CPU stack use for the +AcpiGetFirmwareTable external function. In the 32-bit non-debug +case, the stack use has been reduced from 168 bytes to 32 bytes. + +Deployed a new run-time configuration flag, +AcpiGbl_EnableInterpreterSlack, whose purpose is to allow the AML +interpreter to forgive certain bad AML constructs. Default +setting is FALSE. + +Implemented the first use of AcpiGbl_EnableInterpreterSlack in +the Field IO support code. If enabled, it allows field access to +go beyond the end of a region definition if the field is within +the region length rounded up to the next access width boundary (a +common coding error.) + +Renamed OSD_HANDLER to ACPI_OSD_HANDLER, and +OSD_EXECUTION_CALLBACK to ACPI_OSD_EXEC_CALLBACK for consistency +with other ACPI symbols. Also, these symbols are lowercased by +the latest version of the AcpiSrc tool. + +The prototypes for the PCI interfaces in acpiosxf.h have been +updated to rename "Register" to simply "Reg" to prevent certain +compilers from complaining. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.8K Code, 11.5K Data, 89.3K Total + Debug Version: 163.8K Code, 68.2K Data, 232.0K Total + Current Release: + Non-Debug Version: 78.0K Code, 11.5K Data, 89.5K Total + Debug Version: 164.1K Code, 68.2K Data, 232.3K Total + + +2) iASL Compiler/Disassembler: + +Implemented full support for Package objects within the Case() +operator. Note: The Break() operator is currently not supported +within Case blocks (TermLists) as there is some question about +backward compatibility with ACPI 1.0 interpreters. + +Fixed a problem where complex terms were not supported properly +within the Switch() operator. + +Eliminated extraneous warning for compiler-emitted reserved names +of the form "_T_x". (Used in Switch/Case operators.) + +Eliminated optimization messages for "_T_x" objects and small +constants within the DefinitionBlock operator. + + +---------------------------------------- +15 June 2004. Summary of changes for version 20040615: + +1) ACPI CA Core Subsystem: + +Implemented support for Buffer and String objects (as per ACPI +2.0) for the following ASL operators: LEqual, LGreater, LLess, +LGreaterEqual, and LLessEqual. + +All directory names in the entire source package are lower case, +as they were in earlier releases. + +Implemented "Disassemble" command in the AML debugger that will +disassemble a single control method. + +Code and Data Size: Current and previous core subsystem library +sizes are shown below. These are the code and data sizes for the +acpica.lib produced by the Microsoft Visual C++ 6.0 compiler, and +these values do not include any ACPI driver or OSPM code. The +debug version of the code includes the debug output trace +mechanism and has a much larger code and data size. Note that +these values will vary depending on the efficiency of the +compiler and the compiler options used during generation. + + Previous Release: + Non-Debug Version: 77.7K Code, 11.5K Data, 89.2K Total + Debug Version: 163.3K Code, 67.2K Data, 230.5K Total + Current Release: + Non-Debug Version: 77.8K Code, 11.5K Data, 89.3K Total + Debug Version: 163.8K Code, 68.2K Data, 232.0K Total + + +2) iASL Compiler/Disassembler: + +Implemented support for Buffer and String objects (as per ACPI +2.0) for the following ASL operators: LEqual, LGreater, LLess, +LGreaterEqual, and LLessEqual. + +All directory names in the entire source package are lower case, +as they were in earlier releases. + +Fixed a fault when using the -g or -d<nofilename> options if the +FADT was not found. + +Fixed an issue with the Windows version of the compiler where +later versions of Windows place the FADT in the registry under +the name "FADT" and not "FACP" as earlier versions did. This +applies when using the -g or -d<nofilename> options. The +compiler now looks for both strings as necessary. + +Fixed a problem with compiler namepath optimization where a +namepath within the Scope() operator could not be optimized if +the namepath was a subpath of the current scope path. + +---------------------------------------- 27 May 2004. Summary of changes for version 20040527: 1) ACPI CA Core Subsystem: diff --git a/sys/contrib/dev/acpica/acconfig.h b/sys/contrib/dev/acpica/acconfig.h index a953ca60109a..f5b994a39fae 100644 --- a/sys/contrib/dev/acpica/acconfig.h +++ b/sys/contrib/dev/acpica/acconfig.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acconfig.h - Global configuration constants - * $Revision: 158 $ + * $Revision: 169 $ * *****************************************************************************/ @@ -137,12 +137,12 @@ /* Version string */ -#define ACPI_CA_VERSION 0x20040527 +#define ACPI_CA_VERSION 0x20041119 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, * but there is a large base of ASL/AML code in existing machines that check - * for the string below. The use of this string usually guarantees that + * for the string below. The use of this string usually guarantees that * the ASL will execute down the most tested code path. Also, there is some * code that will not execute the _OSI method unless _OS matches the string * below. Therefore, change this string at your own risk. diff --git a/sys/contrib/dev/acpica/acdebug.h b/sys/contrib/dev/acpica/acdebug.h index c27eebe562d0..2ea965cb1338 100644 --- a/sys/contrib/dev/acpica/acdebug.h +++ b/sys/contrib/dev/acpica/acdebug.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acdebug.h - ACPI/AML debugger - * $Revision: 74 $ + * $Revision: 75 $ * *****************************************************************************/ @@ -181,6 +181,10 @@ AcpiDbMethodEnd ( * dbcmds - debug commands and output routines */ +ACPI_STATUS +AcpiDbDisassembleMethod ( + char *Name); + void AcpiDbDisplayTableInfo ( char *TableArg); diff --git a/sys/contrib/dev/acpica/acenv.h b/sys/contrib/dev/acpica/acenv.h index bc17268aedd5..4b45e0281e06 100644 --- a/sys/contrib/dev/acpica/acenv.h +++ b/sys/contrib/dev/acpica/acenv.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acenv.h - Generation environment specific items - * $Revision: 107 $ + * $Revision: 109 $ * *****************************************************************************/ @@ -225,7 +225,7 @@ #define COMPILER_DEPENDENT_INT64 long long #define COMPILER_DEPENDENT_UINT64 unsigned long long -/* +/* * This macro is used to tag functions as "printf-like" because * some compilers can catch printf format string problems. MSVC * doesn't, so this is proprocessed away. @@ -305,6 +305,7 @@ #define ACPI_STRCAT(d,s) (void) strcat((d), (s)) #define ACPI_STRNCAT(d,s,n) strncat((d), (s), (ACPI_SIZE)(n)) #define ACPI_STRTOUL(d,s,n) strtoul((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMCMP(s1,s2,n) memcmp((s1), (s2), (ACPI_SIZE)(n)) #define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (ACPI_SIZE)(n)) #define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (ACPI_SIZE)(n)) @@ -368,6 +369,7 @@ typedef char *va_list; #define ACPI_STRCAT(d,s) (void) AcpiUtStrcat ((d), (s)) #define ACPI_STRNCAT(d,s,n) AcpiUtStrncat ((d), (s), (ACPI_SIZE)(n)) #define ACPI_STRTOUL(d,s,n) AcpiUtStrtoul ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMCMP(s1,s2,n) AcpiUtMemcmp((s1), (s2), (ACPI_SIZE)(n)) #define ACPI_MEMCPY(d,s,n) (void) AcpiUtMemcpy ((d), (s), (ACPI_SIZE)(n)) #define ACPI_MEMSET(d,v,n) (void) AcpiUtMemset ((d), (v), (ACPI_SIZE)(n)) #define ACPI_TOUPPER AcpiUtToUpper diff --git a/sys/contrib/dev/acpica/acevents.h b/sys/contrib/dev/acpica/acevents.h index 6c50306a5b41..d029d73a0f6e 100644 --- a/sys/contrib/dev/acpica/acevents.h +++ b/sys/contrib/dev/acpica/acevents.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acevents.h - Event subcomponent prototypes and defines - * $Revision: 95 $ + * $Revision: 96 $ * *****************************************************************************/ @@ -184,7 +184,8 @@ AcpiEvNotifyDispatch ( ACPI_STATUS AcpiEvWalkGpeList ( - ACPI_GPE_CALLBACK GpeWalkCallback); + ACPI_GPE_CALLBACK GpeWalkCallback, + UINT32 Flags); BOOLEAN AcpiEvValidGpeEvent ( diff --git a/sys/contrib/dev/acpica/acexcep.h b/sys/contrib/dev/acpica/acexcep.h index fd5ae2908570..07bd4caf7e4b 100644 --- a/sys/contrib/dev/acpica/acexcep.h +++ b/sys/contrib/dev/acpica/acexcep.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acexcep.h - Exception codes returned by the ACPI subsystem - * $Revision: 71 $ + * $Revision: 72 $ * *****************************************************************************/ @@ -239,7 +239,7 @@ #define AE_AML_CIRCULAR_REFERENCE (ACPI_STATUS) (0x0020 | AE_CODE_AML) #define AE_AML_BAD_RESOURCE_LENGTH (ACPI_STATUS) (0x0021 | AE_CODE_AML) -#define AE_CODE_AML_MAX 0x0020 +#define AE_CODE_AML_MAX 0x0021 /* * Internal exceptions used for control diff --git a/sys/contrib/dev/acpica/acglobal.h b/sys/contrib/dev/acpica/acglobal.h index b5935b2d1cce..70c93f188df9 100644 --- a/sys/contrib/dev/acpica/acglobal.h +++ b/sys/contrib/dev/acpica/acglobal.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acglobal.h - Declarations for global variables - * $Revision: 154 $ + * $Revision: 159 $ * *****************************************************************************/ @@ -163,11 +163,14 @@ extern UINT32 AcpiGbl_NestingLevel; ****************************************************************************/ /* - * Create the predefined _OSI method in the namespace? Default is TRUE - * because ACPI CA is fully compatible with other ACPI implementations. - * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior. + * Enable "slack" in the AML interpreter? Default is FALSE, and the + * interpreter strictly follows the ACPI specification. Setting to TRUE + * allows the interpreter to forgive certain bad AML constructs. Currently: + * 1) Allow "implicit return" of last value in a control method + * 2) Allow access beyond end of operation region + * 3) Allow access to uninitialized locals/args (auto-init to integer 0) */ -ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CreateOsiMethod, TRUE); +ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE); /* * Automatically serialize ALL control methods? Default is FALSE, meaning @@ -178,6 +181,13 @@ ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CreateOsiMethod, TRUE); ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_AllMethodsSerialized, FALSE); /* + * Create the predefined _OSI method in the namespace? Default is TRUE + * because ACPI CA is fully compatible with other ACPI implementations. + * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior. + */ +ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_CreateOsiMethod, TRUE); + +/* * Disable wakeup GPEs during runtime? Default is TRUE because WAKE and * RUNTIME GPEs should never be shared, and WAKE GPEs should typically only * be enabled just before going to sleep. @@ -246,6 +256,7 @@ ACPI_EXTERN ACPI_MUTEX_INFO AcpiGbl_MutexInfo[NUM_MUTEX]; ACPI_EXTERN ACPI_MEMORY_LIST AcpiGbl_MemoryLists[ACPI_NUM_MEM_LISTS]; ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_DeviceNotify; ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_SystemNotify; +ACPI_EXTERN ACPI_EXCEPTION_HANDLER AcpiGbl_ExceptionHandler; ACPI_EXTERN ACPI_INIT_HANDLER AcpiGbl_InitHandler; ACPI_EXTERN ACPI_WALK_STATE *AcpiGbl_BreakpointWalk; ACPI_EXTERN ACPI_HANDLE AcpiGbl_GlobalLockSemaphore; diff --git a/sys/contrib/dev/acpica/achware.h b/sys/contrib/dev/acpica/achware.h index b9e0ecc0f971..0d0d00852494 100644 --- a/sys/contrib/dev/acpica/achware.h +++ b/sys/contrib/dev/acpica/achware.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: achware.h -- hardware specific interfaces - * $Revision: 72 $ + * $Revision: 73 $ * *****************************************************************************/ @@ -211,15 +211,15 @@ AcpiHwGetGpeStatus ( ACPI_STATUS AcpiHwDisableAllGpes ( - void); + UINT32 Flags); ACPI_STATUS AcpiHwEnableAllRuntimeGpes ( - void); + UINT32 Flags); ACPI_STATUS AcpiHwEnableAllWakeupGpes ( - void); + UINT32 Flags); ACPI_STATUS AcpiHwEnableRuntimeGpeBlock ( diff --git a/sys/contrib/dev/acpica/acinterp.h b/sys/contrib/dev/acpica/acinterp.h index 29ef9074178c..e5bfc82fd40a 100644 --- a/sys/contrib/dev/acpica/acinterp.h +++ b/sys/contrib/dev/acpica/acinterp.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acinterp.h - Interpreter subcomponent prototypes and defines - * $Revision: 149 $ + * $Revision: 155 $ * *****************************************************************************/ @@ -156,21 +156,25 @@ ACPI_STATUS AcpiExConvertToInteger ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, - ACPI_WALK_STATE *WalkState); + UINT32 Flags); ACPI_STATUS AcpiExConvertToBuffer ( ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ResultDesc, - ACPI_WALK_STATE *WalkState); + ACPI_OPERAND_OBJECT **ResultDesc); ACPI_STATUS AcpiExConvertToString ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, - UINT32 Base, - UINT32 MaxLength, - ACPI_WALK_STATE *WalkState); + UINT32 Type); + +/* Types for ->String conversion */ + +#define ACPI_EXPLICIT_BYTE_COPY 0x00000000 +#define ACPI_EXPLICIT_CONVERT_HEX 0x00000001 +#define ACPI_IMPLICIT_CONVERT_HEX 0x00000002 +#define ACPI_EXPLICIT_CONVERT_DECIMAL 0x00000003 ACPI_STATUS AcpiExConvertToTargetType ( @@ -182,7 +186,7 @@ AcpiExConvertToTargetType ( UINT32 AcpiExConvertToAscii ( ACPI_INTEGER Integer, - UINT32 Base, + UINT16 Base, UINT8 *String, UINT8 MaxLength); @@ -316,11 +320,19 @@ AcpiExDoConcatenate ( ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState); -BOOLEAN +ACPI_STATUS +AcpiExDoLogicalNumericOp ( + UINT16 Opcode, + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1, + BOOLEAN *LogicalResult); + +ACPI_STATUS AcpiExDoLogicalOp ( UINT16 Opcode, - ACPI_INTEGER Operand0, - ACPI_INTEGER Operand1); + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + BOOLEAN *LogicalResult); ACPI_INTEGER AcpiExDoMathOp ( @@ -447,7 +459,7 @@ AcpiExSystemDoNotifyOp ( ACPI_STATUS AcpiExSystemDoSuspend( - UINT32 Time); + ACPI_INTEGER Time); ACPI_STATUS AcpiExSystemDoStall ( @@ -486,6 +498,10 @@ AcpiExSystemWaitSemaphore ( */ ACPI_STATUS +AcpiExOpcode_0A_0T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS AcpiExOpcode_1A_0T_0R ( ACPI_WALK_STATE *WalkState); @@ -543,12 +559,13 @@ AcpiExResolveObjectToValue ( /* - * exdump - Scanner debug output routines + * exdump - Interpreter debug output routines */ void AcpiExDumpOperand ( - ACPI_OPERAND_OBJECT *EntryDesc); + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Depth); void AcpiExDumpOperands ( diff --git a/sys/contrib/dev/acpica/aclocal.h b/sys/contrib/dev/acpica/aclocal.h index e228ccb0738a..87bfc4cfb4f2 100644 --- a/sys/contrib/dev/acpica/aclocal.h +++ b/sys/contrib/dev/acpica/aclocal.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: aclocal.h - Internal data types used across the ACPI subsystem - * $Revision: 201 $ + * $Revision: 202 $ * *****************************************************************************/ @@ -126,7 +126,7 @@ typedef UINT32 ACPI_MUTEX_HANDLE; /* Total number of aml opcodes defined */ -#define AML_NUM_OPCODES 0x7E +#define AML_NUM_OPCODES 0x7F /***************************************************************************** @@ -1050,8 +1050,7 @@ typedef struct acpi_debug_print_info UINT32 Component; \ UINT32 Line; \ char Module[ACPI_MAX_MODULE_NAME]; \ - UINT8 AllocType; \ - UINT8 Padding[3]; + UINT8 AllocType; typedef struct acpi_debug_mem_header { diff --git a/sys/contrib/dev/acpica/acmacros.h b/sys/contrib/dev/acpica/acmacros.h index 6eb509d1ba8b..2925e2f9e679 100644 --- a/sys/contrib/dev/acpica/acmacros.h +++ b/sys/contrib/dev/acpica/acmacros.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acmacros.h - C macros for the entire subsystem. - * $Revision: 151 $ + * $Revision: 154 $ * *****************************************************************************/ @@ -437,24 +437,6 @@ #define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) -/* Macros for GAS addressing */ - -#if ACPI_MACHINE_WIDTH != 16 - -#define ACPI_PCI_DEVICE(a) (UINT16) ((ACPI_HIDWORD ((a))) & 0x0000FFFF) -#define ACPI_PCI_FUNCTION(a) (UINT16) ((ACPI_LODWORD ((a))) >> 16) -#define ACPI_PCI_REGISTER(a) (UINT16) ((ACPI_LODWORD ((a))) & 0x0000FFFF) - -#else - -/* No support for GAS and PCI IDs in 16-bit mode */ - -#define ACPI_PCI_FUNCTION(a) (UINT16) ((a) & 0xFFFF0000) -#define ACPI_PCI_DEVICE(a) (UINT16) ((a) & 0x0000FFFF) -#define ACPI_PCI_REGISTER(a) (UINT16) ((a) & 0x0000FFFF) - -#endif - /* Bitfields within ACPI registers */ @@ -578,19 +560,19 @@ * The first parameter should be the procedure name as a quoted string. This is declared * as a local string ("_ProcName) so that it can be also used by the function exit macros below. */ -#define ACPI_FUNCTION_NAME(a) ACPI_DEBUG_PRINT_INFO _Dbg; \ - _Dbg.ComponentId = _COMPONENT; \ - _Dbg.ProcName = a; \ - _Dbg.ModuleName = _THIS_MODULE; +#define ACPI_FUNCTION_NAME(a) ACPI_DEBUG_PRINT_INFO _DebugInfo; \ + _DebugInfo.ComponentId = _COMPONENT; \ + _DebugInfo.ProcName = a; \ + _DebugInfo.ModuleName = _THIS_MODULE; #define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ - AcpiUtTrace(__LINE__,&_Dbg) + AcpiUtTrace(__LINE__,&_DebugInfo) #define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ - AcpiUtTracePtr(__LINE__,&_Dbg,(void *)b) + AcpiUtTracePtr(__LINE__,&_DebugInfo,(void *)b) #define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ - AcpiUtTraceU32(__LINE__,&_Dbg,(UINT32)b) + AcpiUtTraceU32(__LINE__,&_DebugInfo,(UINT32)b) #define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \ - AcpiUtTraceStr(__LINE__,&_Dbg,(char *)b) + AcpiUtTraceStr(__LINE__,&_DebugInfo,(char *)b) #define ACPI_FUNCTION_ENTRY() AcpiUtTrackStackPtr() @@ -607,10 +589,10 @@ #define ACPI_DO_WHILE0(a) a #endif -#define return_VOID ACPI_DO_WHILE0 ({AcpiUtExit(__LINE__,&_Dbg);return;}) -#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({AcpiUtStatusExit(__LINE__,&_Dbg,(s));return((s));}) -#define return_VALUE(s) ACPI_DO_WHILE0 ({AcpiUtValueExit(__LINE__,&_Dbg,(ACPI_INTEGER)(s));return((s));}) -#define return_PTR(s) ACPI_DO_WHILE0 ({AcpiUtPtrExit(__LINE__,&_Dbg,(UINT8 *)(s));return((s));}) +#define return_VOID ACPI_DO_WHILE0 ({AcpiUtExit(__LINE__,&_DebugInfo);return;}) +#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({AcpiUtStatusExit(__LINE__,&_DebugInfo,(s));return((s));}) +#define return_VALUE(s) ACPI_DO_WHILE0 ({AcpiUtValueExit(__LINE__,&_DebugInfo,(ACPI_INTEGER)(s));return((s));}) +#define return_PTR(s) ACPI_DO_WHILE0 ({AcpiUtPtrExit(__LINE__,&_DebugInfo,(UINT8 *)(s));return((s));}) /* Conditional execution */ @@ -624,7 +606,7 @@ /* Stack and buffer dumping */ -#define ACPI_DUMP_STACK_ENTRY(a) AcpiExDumpOperand(a) +#define ACPI_DUMP_STACK_ENTRY(a) AcpiExDumpOperand((a),0) #define ACPI_DUMP_OPERANDS(a,b,c,d,e) AcpiExDumpOperands(a,b,c,d,e,_THIS_MODULE,__LINE__) diff --git a/sys/contrib/dev/acpica/acobject.h b/sys/contrib/dev/acpica/acobject.h index f47920a878c9..40db575aa657 100644 --- a/sys/contrib/dev/acpica/acobject.h +++ b/sys/contrib/dev/acpica/acobject.h @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only) - * $Revision: 125 $ + * $Revision: 126 $ * *****************************************************************************/ @@ -210,7 +210,10 @@ typedef struct acpi_object_integer } ACPI_OBJECT_INTEGER; - +/* + * Note: The String and Buffer object must be identical through the Pointer + * element. There is code that depends on this. + */ typedef struct acpi_object_string /* Null terminated, ASCII characters only */ { ACPI_OBJECT_COMMON_HEADER diff --git a/sys/contrib/dev/acpica/acoutput.h b/sys/contrib/dev/acpica/acoutput.h index 2ca34be5b625..4811b5c4caa4 100644 --- a/sys/contrib/dev/acpica/acoutput.h +++ b/sys/contrib/dev/acpica/acoutput.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acoutput.h -- debug output - * $Revision: 94 $ + * $Revision: 95 $ * *****************************************************************************/ @@ -209,7 +209,7 @@ /* * Debug level macros that are used in the DEBUG_PRINT macros */ -#define ACPI_DEBUG_LEVEL(dl) (UINT32) dl,__LINE__,&_Dbg +#define ACPI_DEBUG_LEVEL(dl) (UINT32) dl,__LINE__,&_DebugInfo /* Exception level -- used in the global "DebugLevel" */ diff --git a/sys/contrib/dev/acpica/acpiosxf.h b/sys/contrib/dev/acpica/acpiosxf.h index eeedeaedd9f6..1f3cad6612b2 100644 --- a/sys/contrib/dev/acpica/acpiosxf.h +++ b/sys/contrib/dev/acpica/acpiosxf.h @@ -263,13 +263,13 @@ AcpiOsGetPhysicalAddress ( ACPI_STATUS AcpiOsInstallInterruptHandler ( UINT32 InterruptNumber, - OSD_HANDLER ServiceRoutine, + ACPI_OSD_HANDLER ServiceRoutine, void *Context); ACPI_STATUS AcpiOsRemoveInterruptHandler ( UINT32 InterruptNumber, - OSD_HANDLER ServiceRoutine); + ACPI_OSD_HANDLER ServiceRoutine); /* @@ -283,13 +283,16 @@ AcpiOsGetThreadId ( ACPI_STATUS AcpiOsQueueForExecution ( UINT32 Priority, - OSD_EXECUTION_CALLBACK Function, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context); + +void +AcpiOsWaitEventsComplete ( void *Context); void AcpiOsSleep ( - UINT32 Seconds, - UINT32 Milliseconds); + ACPI_INTEGER Milliseconds); void AcpiOsStall ( @@ -332,29 +335,32 @@ AcpiOsWriteMemory ( /* * Platform and hardware-independent PCI configuration space access + * Note: Can't use "Register" as a parameter, changed to "Reg" -- + * certain compilers complain. */ ACPI_STATUS AcpiOsReadPciConfiguration ( ACPI_PCI_ID *PciId, - UINT32 Register, + UINT32 Reg, void *Value, UINT32 Width); ACPI_STATUS AcpiOsWritePciConfiguration ( ACPI_PCI_ID *PciId, - UINT32 Register, + UINT32 Reg, ACPI_INTEGER Value, UINT32 Width); /* * Interim function needed for PCI IRQ routing */ + void AcpiOsDerivePciId( - ACPI_HANDLE rhandle, - ACPI_HANDLE chandle, + ACPI_HANDLE Rhandle, + ACPI_HANDLE Chandle, ACPI_PCI_ID **PciId); /* @@ -371,7 +377,7 @@ AcpiOsWritable ( void *Pointer, ACPI_SIZE Length); -UINT32 +UINT64 AcpiOsGetTimer ( void); diff --git a/sys/contrib/dev/acpica/acpixf.h b/sys/contrib/dev/acpica/acpixf.h index 57fce7761f7b..04c16c4a2aec 100644 --- a/sys/contrib/dev/acpica/acpixf.h +++ b/sys/contrib/dev/acpica/acpixf.h @@ -372,6 +372,15 @@ AcpiInstallGpeHandler ( void *Context); ACPI_STATUS +AcpiInstallExceptionHandler ( + ACPI_EXCEPTION_HANDLER Handler); + + +/* + * Event interfaces + */ + +ACPI_STATUS AcpiAcquireGlobalLock ( UINT16 Timeout, UINT32 *Handle); diff --git a/sys/contrib/dev/acpica/actbl2.h b/sys/contrib/dev/acpica/actbl2.h index 932e84f62f3f..1e5b62ad34d1 100644 --- a/sys/contrib/dev/acpica/actbl2.h +++ b/sys/contrib/dev/acpica/actbl2.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actbl2.h - ACPI Specification Revision 2.0 Tables - * $Revision: 36 $ + * $Revision: 37 $ * *****************************************************************************/ @@ -135,6 +135,7 @@ #define BAF_8042_KEYBOARD_CONTROLLER 0x0002 #define FADT2_REVISION_ID 3 +#define FADT2_MINUS_REVISION_ID 2 #pragma pack(1) @@ -194,48 +195,51 @@ typedef struct acpi_generic_address } ACPI_GENERIC_ADDRESS; +#define FADT_REV2_COMMON \ + UINT32 V1_FirmwareCtrl; /* 32-bit physical address of FACS */ \ + UINT32 V1_Dsdt; /* 32-bit physical address of DSDT */ \ + UINT8 Reserved1; /* System Interrupt Model isn't used in ACPI 2.0*/ \ + UINT8 Prefer_PM_Profile; /* Conveys preferred power management profile to OSPM. */ \ + UINT16 SciInt; /* System vector of SCI interrupt */ \ + UINT32 SmiCmd; /* 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 S4BiosReq; /* Value to write to SMI CMD to enter S4BIOS state */ \ + UINT8 PstateCnt; /* Processor performance state control*/ \ + UINT32 V1_Pm1aEvtBlk; /* Port address of Power Mgt 1a AcpiEvent Reg Blk */ \ + UINT32 V1_Pm1bEvtBlk; /* Port address of Power Mgt 1b AcpiEvent Reg Blk */ \ + UINT32 V1_Pm1aCntBlk; /* Port address of Power Mgt 1a Control Reg Blk */ \ + UINT32 V1_Pm1bCntBlk; /* Port address of Power Mgt 1b Control Reg Blk */ \ + UINT32 V1_Pm2CntBlk; /* Port address of Power Mgt 2 Control Reg Blk */ \ + UINT32 V1_PmTmrBlk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ \ + UINT32 V1_Gpe0Blk; /* Port addr of General Purpose AcpiEvent 0 Reg Blk */ \ + UINT32 V1_Gpe1Blk; /* Port addr of General Purpose AcpiEvent 1 Reg Blk */ \ + UINT8 Pm1EvtLen; /* Byte Length of ports at pm1X_evt_blk */ \ + UINT8 Pm1CntLen; /* Byte Length of ports at pm1X_cnt_blk */ \ + UINT8 Pm2CntLen; /* Byte Length of ports at pm2_cnt_blk */ \ + UINT8 PmTmLen; /* Byte Length of ports at pm_tm_blk */ \ + UINT8 Gpe0BlkLen; /* Byte Length of ports at gpe0_blk */ \ + UINT8 Gpe1BlkLen; /* Byte Length of ports at gpe1_blk */ \ + UINT8 Gpe1Base; /* Offset in gpe model where gpe1 events start */ \ + UINT8 CstCnt; /* Support for the _CST object and C States change notification.*/ \ + UINT16 Plvl2Lat; /* Worst case HW latency to enter/exit C2 state */ \ + UINT16 Plvl3Lat; /* Worst case HW latency to enter/exit C3 state */ \ + UINT16 FlushSize; /* Number of flush strides that need to be read */ \ + UINT16 FlushStride; /* Processor's memory cache line width, in bytes */ \ + UINT8 DutyOffset; /* Processor's duty cycle index in processor's P_CNT reg*/ \ + UINT8 DutyWidth; /* Processor's duty cycle value bit width in P_CNT register.*/ \ + UINT8 DayAlrm; /* Index to day-of-month alarm in RTC CMOS RAM */ \ + UINT8 MonAlrm; /* Index to month-of-year alarm in RTC CMOS RAM */ \ + UINT8 Century; /* Index to century in RTC CMOS RAM */ \ + UINT16 IapcBootArch; /* IA-PC Boot Architecture Flags. See Table 5-10 for description*/ + /* * ACPI 2.0 Fixed ACPI Description Table (FADT) */ typedef struct fadt_descriptor_rev2 { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - UINT32 V1_FirmwareCtrl; /* 32-bit physical address of FACS */ - UINT32 V1_Dsdt; /* 32-bit physical address of DSDT */ - UINT8 Reserved1; /* System Interrupt Model isn't used in ACPI 2.0*/ - UINT8 Prefer_PM_Profile; /* Conveys preferred power management profile to OSPM. */ - UINT16 SciInt; /* System vector of SCI interrupt */ - UINT32 SmiCmd; /* 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 S4BiosReq; /* Value to write to SMI CMD to enter S4BIOS state */ - UINT8 PstateCnt; /* Processor performance state control*/ - UINT32 V1_Pm1aEvtBlk; /* Port address of Power Mgt 1a AcpiEvent Reg Blk */ - UINT32 V1_Pm1bEvtBlk; /* Port address of Power Mgt 1b AcpiEvent Reg Blk */ - UINT32 V1_Pm1aCntBlk; /* Port address of Power Mgt 1a Control Reg Blk */ - UINT32 V1_Pm1bCntBlk; /* Port address of Power Mgt 1b Control Reg Blk */ - UINT32 V1_Pm2CntBlk; /* Port address of Power Mgt 2 Control Reg Blk */ - UINT32 V1_PmTmrBlk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ - UINT32 V1_Gpe0Blk; /* Port addr of General Purpose AcpiEvent 0 Reg Blk */ - UINT32 V1_Gpe1Blk; /* Port addr of General Purpose AcpiEvent 1 Reg Blk */ - UINT8 Pm1EvtLen; /* Byte Length of ports at pm1X_evt_blk */ - UINT8 Pm1CntLen; /* Byte Length of ports at pm1X_cnt_blk */ - UINT8 Pm2CntLen; /* Byte Length of ports at pm2_cnt_blk */ - UINT8 PmTmLen; /* Byte Length of ports at pm_tm_blk */ - UINT8 Gpe0BlkLen; /* Byte Length of ports at gpe0_blk */ - UINT8 Gpe1BlkLen; /* Byte Length of ports at gpe1_blk */ - UINT8 Gpe1Base; /* Offset in gpe model where gpe1 events start */ - UINT8 CstCnt; /* Support for the _CST object and C States change notification.*/ - UINT16 Plvl2Lat; /* Worst case HW latency to enter/exit C2 state */ - UINT16 Plvl3Lat; /* Worst case HW latency to enter/exit C3 state */ - UINT16 FlushSize; /* Number of flush strides that need to be read */ - UINT16 FlushStride; /* Processor's memory cache line width, in bytes */ - UINT8 DutyOffset; /* Processor's duty cycle index in processor's P_CNT reg*/ - UINT8 DutyWidth; /* Processor's duty cycle value bit width in P_CNT register.*/ - UINT8 DayAlrm; /* Index to day-of-month alarm in RTC CMOS RAM */ - UINT8 MonAlrm; /* Index to month-of-year alarm in RTC CMOS RAM */ - UINT8 Century; /* Index to century in RTC CMOS RAM */ - UINT16 IapcBootArch; /* IA-PC Boot Architecture Flags. See Table 5-10 for description*/ + FADT_REV2_COMMON UINT8 Reserved2; /* Reserved */ UINT32_BIT WbInvd : 1; /* The wbinvd instruction works properly */ UINT32_BIT WbInvdFlush : 1; /* The wbinvd flushes but does not invalidate */ @@ -271,6 +275,22 @@ typedef struct fadt_descriptor_rev2 } FADT_DESCRIPTOR_REV2; +/* "Downrevved" ACPI 2.0 FADT descriptor */ + +typedef struct fadt_descriptor_rev2_minus +{ + ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + FADT_REV2_COMMON + UINT8 Reserved2; /* Reserved */ + UINT32 Flags; + ACPI_GENERIC_ADDRESS ResetRegister; /* Reset register address in GAS format */ + UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system. */ + UINT8 Reserved7[3]; /* These three bytes must be zero */ + +} FADT_DESCRIPTOR_REV2_MINUS; + + + /* Embedded Controller */ typedef struct ec_boot_resources diff --git a/sys/contrib/dev/acpica/actypes.h b/sys/contrib/dev/acpica/actypes.h index 98abcc5955c6..889079047af2 100644 --- a/sys/contrib/dev/acpica/actypes.h +++ b/sys/contrib/dev/acpica/actypes.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actypes.h - Common data types for the entire ACPI subsystem - * $Revision: 270 $ + * $Revision: 274 $ * *****************************************************************************/ @@ -382,7 +382,7 @@ typedef struct uint32_struct typedef UINT32 ACPI_INTEGER; #define ACPI_INTEGER_MAX ACPI_UINT32_MAX #define ACPI_INTEGER_BIT_SIZE 32 -#define ACPI_MAX_DECIMAL_DIGITS 10 +#define ACPI_MAX_DECIMAL_DIGITS 10 /* 2^32 = 4,294,967,296 */ #define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 32-bit divide */ @@ -394,13 +394,18 @@ typedef UINT32 ACPI_INTEGER; typedef UINT64 ACPI_INTEGER; #define ACPI_INTEGER_MAX ACPI_UINT64_MAX #define ACPI_INTEGER_BIT_SIZE 64 -#define ACPI_MAX_DECIMAL_DIGITS 19 +#define ACPI_MAX_DECIMAL_DIGITS 20 /* 2^64 = 18,446,744,073,709,551,616 */ + #if ACPI_MACHINE_WIDTH == 64 #define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 64-bit divide */ #endif #endif +#define ACPI_MAX64_DECIMAL_DIGITS 20 +#define ACPI_MAX32_DECIMAL_DIGITS 10 +#define ACPI_MAX16_DECIMAL_DIGITS 5 +#define ACPI_MAX8_DECIMAL_DIGITS 3 /* * Constants with special meanings @@ -882,11 +887,11 @@ typedef struct acpi_system_info */ typedef UINT32 -(ACPI_SYSTEM_XFACE *OSD_HANDLER) ( +(ACPI_SYSTEM_XFACE *ACPI_OSD_HANDLER) ( void *Context); typedef void -(ACPI_SYSTEM_XFACE *OSD_EXECUTION_CALLBACK) ( +(ACPI_SYSTEM_XFACE *ACPI_OSD_EXEC_CALLBACK) ( void *Context); /* @@ -915,6 +920,14 @@ ACPI_STATUS (*ACPI_INIT_HANDLER) ( #define ACPI_INIT_DEVICE_INI 1 +typedef +ACPI_STATUS (*ACPI_EXCEPTION_HANDLER) ( + ACPI_STATUS AmlStatus, + ACPI_NAME Name, + UINT16 Opcode, + UINT32 AmlOffset, + void *Context); + /* Address Spaces (For Operation Regions) */ diff --git a/sys/contrib/dev/acpica/acutils.h b/sys/contrib/dev/acpica/acutils.h index 7aa8fe072336..749e01531805 100644 --- a/sys/contrib/dev/acpica/acutils.h +++ b/sys/contrib/dev/acpica/acutils.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures - * $Revision: 161 $ + * $Revision: 164 $ * *****************************************************************************/ @@ -252,6 +252,12 @@ AcpiUtStrncpy ( ACPI_SIZE Count); int +AcpiUtMemcmp ( + const char *Buffer1, + const char *Buffer2, + ACPI_SIZE Count); + +int AcpiUtStrncmp ( const char *String1, const char *String2, @@ -651,6 +657,10 @@ ACPI_OPERAND_OBJECT * AcpiUtCreateBufferObject ( ACPI_SIZE BufferSize); +ACPI_OPERAND_OBJECT * +AcpiUtCreateStringObject ( + ACPI_SIZE StringSize); + /* * UtRefCnt - Object reference count management @@ -764,14 +774,14 @@ AcpiUtPrintString ( ACPI_STATUS AcpiUtDivide ( - ACPI_INTEGER *InDividend, - ACPI_INTEGER *InDivisor, + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, ACPI_INTEGER *OutQuotient, ACPI_INTEGER *OutRemainder); ACPI_STATUS AcpiUtShortDivide ( - ACPI_INTEGER *InDividend, + ACPI_INTEGER InDividend, UINT32 Divisor, ACPI_INTEGER *OutQuotient, UINT32 *OutRemainder); @@ -790,6 +800,10 @@ AcpiUtStrtoul64 ( UINT32 Base, ACPI_INTEGER *RetInteger); +/* Values for Base above (16=Hex, 10=Decimal) */ + +#define ACPI_ANY_BASE 0 + char * AcpiUtStrupr ( char *SrcString); diff --git a/sys/contrib/dev/acpica/amlcode.h b/sys/contrib/dev/acpica/amlcode.h index dd1f60355b89..ec6b03bca8e7 100644 --- a/sys/contrib/dev/acpica/amlcode.h +++ b/sys/contrib/dev/acpica/amlcode.h @@ -3,7 +3,7 @@ * Name: amlcode.h - Definitions for AML, as included in "definition blocks" * Declarations and definitions contained herein are derived * directly from the ACPI specification. - * $Revision: 75 $ + * $Revision: 77 $ * *****************************************************************************/ @@ -243,6 +243,7 @@ #define AML_REVISION_OP (UINT16) 0x5b30 #define AML_DEBUG_OP (UINT16) 0x5b31 #define AML_FATAL_OP (UINT16) 0x5b32 +#define AML_TIMER_OP (UINT16) 0x5b33 /* ACPI 3.0 */ #define AML_REGION_OP (UINT16) 0x5b80 #define AML_FIELD_OP (UINT16) 0x5b81 #define AML_DEVICE_OP (UINT16) 0x5b82 @@ -378,22 +379,24 @@ /* Opcode flags */ -#define AML_HAS_ARGS 0x0800 -#define AML_HAS_TARGET 0x0400 -#define AML_HAS_RETVAL 0x0200 -#define AML_NSOBJECT 0x0100 -#define AML_NSOPCODE 0x0080 -#define AML_NSNODE 0x0040 -#define AML_NAMED 0x0020 -#define AML_DEFER 0x0010 -#define AML_FIELD 0x0008 -#define AML_CREATE 0x0004 -#define AML_MATH 0x0002 #define AML_LOGICAL 0x0001 -#define AML_CONSTANT 0x1000 +#define AML_LOGICAL_NUMERIC 0x0002 +#define AML_MATH 0x0004 +#define AML_CREATE 0x0008 +#define AML_FIELD 0x0010 +#define AML_DEFER 0x0020 +#define AML_NAMED 0x0040 +#define AML_NSNODE 0x0080 +#define AML_NSOPCODE 0x0100 +#define AML_NSOBJECT 0x0200 +#define AML_HAS_RETVAL 0x0400 +#define AML_HAS_TARGET 0x0800 +#define AML_HAS_ARGS 0x1000 +#define AML_CONSTANT 0x2000 /* Convenient flag groupings */ +#define AML_FLAGS_EXEC_0A_0T_1R AML_HAS_RETVAL #define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */ #define AML_FLAGS_EXEC_1A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Monadic2 */ #define AML_FLAGS_EXEC_1A_1T_0R AML_HAS_ARGS | AML_HAS_TARGET @@ -411,17 +414,18 @@ * The opcode Type is used in a dispatch table, do not change * without updating the table. */ -#define AML_TYPE_EXEC_1A_0T_0R 0x00 /* Monadic1 */ -#define AML_TYPE_EXEC_1A_0T_1R 0x01 /* Monadic2 */ -#define AML_TYPE_EXEC_1A_1T_0R 0x02 -#define AML_TYPE_EXEC_1A_1T_1R 0x03 /* Monadic2R */ -#define AML_TYPE_EXEC_2A_0T_0R 0x04 /* Dyadic1 */ -#define AML_TYPE_EXEC_2A_0T_1R 0x05 /* Dyadic2 */ -#define AML_TYPE_EXEC_2A_1T_1R 0x06 /* Dyadic2R */ -#define AML_TYPE_EXEC_2A_2T_1R 0x07 -#define AML_TYPE_EXEC_3A_0T_0R 0x08 -#define AML_TYPE_EXEC_3A_1T_1R 0x09 -#define AML_TYPE_EXEC_6A_0T_1R 0x0A +#define AML_TYPE_EXEC_0A_0T_1R 0x00 +#define AML_TYPE_EXEC_1A_0T_0R 0x01 /* Monadic1 */ +#define AML_TYPE_EXEC_1A_0T_1R 0x02 /* Monadic2 */ +#define AML_TYPE_EXEC_1A_1T_0R 0x03 +#define AML_TYPE_EXEC_1A_1T_1R 0x04 /* Monadic2R */ +#define AML_TYPE_EXEC_2A_0T_0R 0x05 /* Dyadic1 */ +#define AML_TYPE_EXEC_2A_0T_1R 0x06 /* Dyadic2 */ +#define AML_TYPE_EXEC_2A_1T_1R 0x07 /* Dyadic2R */ +#define AML_TYPE_EXEC_2A_2T_1R 0x08 +#define AML_TYPE_EXEC_3A_0T_0R 0x09 +#define AML_TYPE_EXEC_3A_1T_1R 0x0A +#define AML_TYPE_EXEC_6A_0T_1R 0x0B /* End of types used in dispatch table */ #define AML_TYPE_LITERAL 0x0B diff --git a/sys/contrib/dev/acpica/amlresrc.h b/sys/contrib/dev/acpica/amlresrc.h index d56efcc34937..1ac74a8f77f1 100644 --- a/sys/contrib/dev/acpica/amlresrc.h +++ b/sys/contrib/dev/acpica/amlresrc.h @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: amlresrc.h - AML resource descriptors - * $Revision: 24 $ + * $Revision: 25 $ * *****************************************************************************/ @@ -173,7 +173,7 @@ typedef struct asl_resource_node /* * Resource descriptors defined in the ACPI specification. * - * Alignment must be BYTE because these descriptors + * Packing/alignment must be BYTE because these descriptors * are used to overlay the AML byte stream. */ #pragma pack(1) @@ -390,7 +390,7 @@ typedef struct asl_general_register_desc #pragma pack() -/* Union of all resource descriptors, sow we can allocate the worst case */ +/* Union of all resource descriptors, so we can allocate the worst case */ typedef union asl_resource_desc { diff --git a/sys/contrib/dev/acpica/common/adisasm.c b/sys/contrib/dev/acpica/common/adisasm.c index f30410dbbf67..a1d14117b9b6 100644 --- a/sys/contrib/dev/acpica/common/adisasm.c +++ b/sys/contrib/dev/acpica/common/adisasm.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: adisasm - Application-level disassembler routines - * $Revision: 67 $ + * $Revision: 69 $ * *****************************************************************************/ @@ -880,6 +880,7 @@ AdGetLocalTables ( ACPI_TABLE_HEADER *NewTable; UINT32 NumTables; UINT32 PointerSize; + char *FacsSuffix = ""; if (GetAllTables) @@ -923,6 +924,10 @@ AdGetLocalTables ( AcpiGbl_FADT = (void *) NewTable; AdWriteTable (NewTable, NewTable->Length, FADT_SIG, NewTable->OemTableId); + + /* Use the FADT tableID for the FACS, since FACS has no ID */ + + FacsSuffix = AcpiGbl_FADT->OemTableId; } AcpiOsPrintf ("\n"); @@ -934,7 +939,7 @@ AdGetLocalTables ( { AcpiGbl_FACS = (void *) NewTable; AdWriteTable (NewTable, AcpiGbl_FACS->Length, - FACS_SIG, AcpiGbl_FADT->OemTableId); + FACS_SIG, FacsSuffix); } AcpiOsPrintf ("\n"); } diff --git a/sys/contrib/dev/acpica/compiler/aslanalyze.c b/sys/contrib/dev/acpica/compiler/aslanalyze.c index 9f5dd555e041..93bcca1ed114 100644 --- a/sys/contrib/dev/acpica/compiler/aslanalyze.c +++ b/sys/contrib/dev/acpica/compiler/aslanalyze.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslanalyze.c - check for semantic errors - * $Revision: 80 $ + * $Revision: 84 $ * *****************************************************************************/ @@ -454,8 +454,9 @@ AnGetBtype ( if (!Node) { DbgPrint (ASL_DEBUG_OUTPUT, - "Null attached Nsnode: [%s] at line %d\n", - Op->Asl.ParseOpName, Op->Asl.LineNumber); + "No attached Nsnode: [%s] at line %d name [%s], ignoring typecheck\n", + Op->Asl.ParseOpName, Op->Asl.LineNumber, + Op->Asl.ExternalName); return ACPI_UINT32_MAX; } @@ -582,6 +583,13 @@ AnCheckForReservedName ( else if ((Op->Asl.ExternalName[1] == 'T') && (Op->Asl.ExternalName[2] == '_')) { + /* Ignore if actually emitted by the compiler */ + + if (Op->Asl.CompileFlags & NODE_COMPILER_EMITTED) + { + return (ACPI_NOT_RESERVED_NAME); + } + AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, Op->Asl.ExternalName); return (ACPI_COMPILER_RESERVED_NAME); } @@ -683,6 +691,64 @@ AnCheckForReservedMethod ( } +UINT32 +AnMapObjTypeToBtype ( + ACPI_PARSE_OBJECT *Op) +{ + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_OBJECTTYPE_BFF: /* "BuffFieldObj" */ + return (ACPI_BTYPE_BUFFER_FIELD); + + case PARSEOP_OBJECTTYPE_BUF: /* "BuffObj" */ + return (ACPI_BTYPE_BUFFER); + + case PARSEOP_OBJECTTYPE_DDB: /* "DDBHandleObj" */ + return (ACPI_BTYPE_DDB_HANDLE); + + case PARSEOP_OBJECTTYPE_DEV: /* "DeviceObj" */ + return (ACPI_BTYPE_DEVICE); + + case PARSEOP_OBJECTTYPE_EVT: /* "EventObj" */ + return (ACPI_BTYPE_EVENT); + + case PARSEOP_OBJECTTYPE_FLD: /* "FieldUnitObj" */ + return (ACPI_BTYPE_FIELD_UNIT); + + case PARSEOP_OBJECTTYPE_INT: /* "IntObj" */ + return (ACPI_BTYPE_INTEGER); + + case PARSEOP_OBJECTTYPE_MTH: /* "MethodObj" */ + return (ACPI_BTYPE_METHOD); + + case PARSEOP_OBJECTTYPE_MTX: /* "MutexObj" */ + return (ACPI_BTYPE_MUTEX); + + case PARSEOP_OBJECTTYPE_OPR: /* "OpRegionObj" */ + return (ACPI_BTYPE_REGION); + + case PARSEOP_OBJECTTYPE_PKG: /* "PkgObj" */ + return (ACPI_BTYPE_PACKAGE); + + case PARSEOP_OBJECTTYPE_POW: /* "PowerResObj" */ + return (ACPI_BTYPE_POWER); + + case PARSEOP_OBJECTTYPE_STR: /* "StrObj" */ + return (ACPI_BTYPE_STRING); + + case PARSEOP_OBJECTTYPE_THZ: /* "ThermalZoneObj" */ + return (ACPI_BTYPE_THERMAL); + + case PARSEOP_OBJECTTYPE_UNK: /* "UnknownObj" */ + return (ACPI_BTYPE_OBJECTS_AND_REFS); + + default: + return (0); + } +} + + /******************************************************************************* * * FUNCTION: AnMethodAnalysisWalkBegin @@ -711,6 +777,10 @@ AnMethodAnalysisWalkBegin ( UINT32 i; char LocalName[] = "Local0"; char ArgName[] = "Arg0"; + ACPI_PARSE_OBJECT *ArgNode; + ACPI_PARSE_OBJECT *NextType; + ACPI_PARSE_OBJECT *NextParamType; + char ActualArgs = 0; ACPI_FUNCTION_NAME ("AnMethodAnalysisWalkBegin"); @@ -731,12 +801,76 @@ AnMethodAnalysisWalkBegin ( WalkInfo->MethodStack = MethodInfo; - /* Get the NumArguments node */ + /* Get the name node, ignored here */ Next = Op->Asl.Child; + + /* Get the NumArguments node */ + Next = Next->Asl.Next; MethodInfo->NumArguments = (UINT8) (((UINT8) Next->Asl.Value.Integer) & 0x07); + /* Get the SerializeRule and SyncLevel nodes, ignored here */ + + Next = Next->Asl.Next; + Next = Next->Asl.Next; + ArgNode = Next; + + /* Get the ReturnType node */ + + Next = Next->Asl.Next; + + NextType = Next->Asl.Child; + while (NextType) + { + /* Get and map each of the ReturnTypes */ + + MethodInfo->ValidReturnTypes |= AnMapObjTypeToBtype (NextType); + NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + NextType = NextType->Asl.Next; + } + + /* Get the ParameterType node */ + + Next = Next->Asl.Next; + + NextType = Next->Asl.Child; + while (NextType) + { + if (NextType->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) + { + NextParamType = NextType->Asl.Child; + while (NextParamType) + { + MethodInfo->ValidArgTypes[ActualArgs] |= AnMapObjTypeToBtype (NextParamType); + NextParamType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + NextParamType = NextParamType->Asl.Next; + } + } + else + { + MethodInfo->ValidArgTypes[ActualArgs] = AnMapObjTypeToBtype (NextType); + NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; + } + + ActualArgs++; + NextType = NextType->Asl.Next; + } + + if ((MethodInfo->NumArguments) && + (MethodInfo->NumArguments != ActualArgs)) + { + /* error: Param list did not match number of args */ + } + + /* Allow numarguments == 0 for Function() */ + + if ((!MethodInfo->NumArguments) && (ActualArgs)) + { + MethodInfo->NumArguments = ActualArgs; + ArgNode->Asl.Value.Integer |= ActualArgs; + } + /* * Actual arguments are initialized at method entry. * All other ArgX "registers" can be used as locals, so we @@ -746,7 +880,6 @@ AnMethodAnalysisWalkBegin ( { MethodInfo->ArgInitialized[i] = TRUE; } - break; @@ -791,8 +924,11 @@ AnMethodAnalysisWalkBegin ( /* * Otherwise, this is a reference, check if the local * has been previously initialized. + * + * The only operator that accepts an uninitialized value is ObjectType() */ - else if (!MethodInfo->LocalInitialized[RegisterNumber]) + else if ((!MethodInfo->LocalInitialized[RegisterNumber]) && + (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) { LocalName[strlen (LocalName) -1] = (char) (RegisterNumber + 0x30); AslError (ASL_ERROR, ASL_MSG_LOCAL_INIT, Op, LocalName); @@ -831,8 +967,11 @@ AnMethodAnalysisWalkBegin ( /* * Otherwise, this is a reference, check if the Arg * has been previously initialized. + * + * The only operator that accepts an uninitialized value is ObjectType() */ - else if (!MethodInfo->ArgInitialized[RegisterNumber]) + else if ((!MethodInfo->ArgInitialized[RegisterNumber]) && + (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) { AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName); } diff --git a/sys/contrib/dev/acpica/compiler/aslcodegen.c b/sys/contrib/dev/acpica/compiler/aslcodegen.c index fc5ddbd563de..6087bfbc72e6 100644 --- a/sys/contrib/dev/acpica/compiler/aslcodegen.c +++ b/sys/contrib/dev/acpica/compiler/aslcodegen.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslcodegen - AML code generation - * $Revision: 50 $ + * $Revision: 51 $ * *****************************************************************************/ @@ -445,6 +445,13 @@ CgWriteTableHeader ( Child = Child->Asl.Next; TableHeader.Revision = (UINT8) Child->Asl.Value.Integer; + /* Command-line Revision override */ + + if (Gbl_RevisionOverride) + { + TableHeader.Revision = Gbl_RevisionOverride; + } + /* OEMID */ Child = Child->Asl.Next; diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.h b/sys/contrib/dev/acpica/compiler/aslcompiler.h index 0172e4717580..3da39afeeab5 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.h +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.h @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslcompiler.h - common include file - * $Revision: 129 $ + * $Revision: 130 $ * *****************************************************************************/ @@ -581,11 +581,6 @@ void TrDoDefinitionBlock ( ACPI_PARSE_OBJECT *Op); -void -TrDoElseif ( - ACPI_PARSE_OBJECT *Op); - - /* * asltree - parse tree support */ diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.l b/sys/contrib/dev/acpica/compiler/aslcompiler.l index c2b25819ed3a..dbef089ed4b3 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.l +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.l @@ -207,6 +207,7 @@ NamePathTail [.]{NameSeg} "Device" { count (2); return (PARSEOP_DEVICE); } "Event" { count (2); return (PARSEOP_EVENT); } "Field" { count (2); return (PARSEOP_FIELD); } +"Function" { count (2); return (PARSEOP_FUNCTION); } "IndexField" { count (2); return (PARSEOP_INDEXFIELD); } "Method" { count (2); return (PARSEOP_METHOD); } "Mutex" { count (2); return (PARSEOP_MUTEX); } @@ -279,6 +280,7 @@ NamePathTail [.]{NameSeg} "SizeOf" { count (3); return (PARSEOP_SIZEOF); } "Store" { count (3); return (PARSEOP_STORE); } "Subtract" { count (3); return (PARSEOP_SUBTRACT); } +"Timer" { count (3); return (PARSEOP_TIMER); } "ToBCD" { count (3); return (PARSEOP_TOBCD); } "ToBuffer" { count (3); return (PARSEOP_TOBUFFER); } "ToDecimalString" { count (3); return (PARSEOP_TODECIMALSTRING); } @@ -313,11 +315,16 @@ NamePathTail [.]{NameSeg} "EISAID" { count (1); return (PARSEOP_EISAID); } "ResourceTemplate" { count (1); return (PARSEOP_RESOURCETEMPLATE); } +"ToUUID" { count (1); return (PARSEOP_TOUUID); } "Unicode" { count (1); return (PARSEOP_UNICODE); } "DMA" { count (1); return (PARSEOP_DMA); } "DWordIO" { count (1); return (PARSEOP_DWORDIO); } "DWordMemory" { count (1); return (PARSEOP_DWORDMEMORY); } +"DWordSpace" { count (1); return (PARSEOP_DWORDSPACE); } "EndDependentFn" { count (1); return (PARSEOP_ENDDEPENDENTFN); } +"ExtendedIO" { count (1); return (PARSEOP_EXTENDEDIO); } +"ExtendedMemory" { count (1); return (PARSEOP_EXTENDEDMEMORY); } +"ExtendedSpace" { count (1); return (PARSEOP_EXTENDEDSPACE); } "FixedIO" { count (1); return (PARSEOP_FIXEDIO); } "Interrupt" { count (1); return (PARSEOP_INTERRUPT); } "IO" { count (1); return (PARSEOP_IO); } @@ -328,6 +335,7 @@ NamePathTail [.]{NameSeg} "Memory32" { count (1); return (PARSEOP_MEMORY32); } "QWordIO" { count (1); return (PARSEOP_QWORDIO); } "QWordMemory" { count (1); return (PARSEOP_QWORDMEMORY); } +"QWordSpace" { count (1); return (PARSEOP_QWORDSPACE); } "Register" { count (1); return (PARSEOP_REGISTER); } "StartDependentFn" { count (1); return (PARSEOP_STARTDEPENDENTFN); } "StartDependentFnNoPri" { count (1); return (PARSEOP_STARTDEPENDENTFN_NOPRI); } @@ -335,6 +343,7 @@ NamePathTail [.]{NameSeg} "VendorShort" { count (1); return (PARSEOP_VENDORSHORT); } "WordBusNumber" { count (1); return (PARSEOP_WORDBUSNUMBER); } "WordIO" { count (1); return (PARSEOP_WORDIO); } +"WordSpace" { count (1); return (PARSEOP_WORDSPACE); } "UnknownObj" { count (0); return (PARSEOP_OBJECTTYPE_UNK); } "IntObj" { count (0); return (PARSEOP_OBJECTTYPE_INT); } @@ -886,14 +895,9 @@ comment2 (void) if (c == EOF) { - /* - * Premature End-Of-File - */ - AslCommonError (ASL_ERROR, ASL_MSG_EARLY_EOF, - Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, - Gbl_CurrentLineOffset, Gbl_CurrentColumn, - Gbl_Files[ASL_FILE_INPUT].Filename, NULL); - return (FALSE); + /* End of file is OK, change to newline. Let parser detect EOF later */ + + c = '\n'; } InsertLineBuffer (c); diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.y b/sys/contrib/dev/acpica/compiler/aslcompiler.y index a3cbf5a899b5..dec6d339f4dc 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.y +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.y @@ -250,12 +250,16 @@ AslLocalAllocate (unsigned int Size); %token <i> PARSEOP_DWORDCONST %token <i> PARSEOP_DWORDIO %token <i> PARSEOP_DWORDMEMORY +%token <i> PARSEOP_DWORDSPACE %token <i> PARSEOP_EISAID %token <i> PARSEOP_ELSE %token <i> PARSEOP_ELSEIF %token <i> PARSEOP_ENDDEPENDENTFN %token <i> PARSEOP_ERRORNODE %token <i> PARSEOP_EVENT +%token <i> PARSEOP_EXTENDEDIO +%token <i> PARSEOP_EXTENDEDMEMORY +%token <i> PARSEOP_EXTENDEDSPACE %token <i> PARSEOP_EXTERNAL %token <i> PARSEOP_FATAL %token <i> PARSEOP_FIELD @@ -263,6 +267,7 @@ AslLocalAllocate (unsigned int Size); %token <i> PARSEOP_FINDSETRIGHTBIT %token <i> PARSEOP_FIXEDIO %token <i> PARSEOP_FROMBCD +%token <i> PARSEOP_FUNCTION %token <i> PARSEOP_IF %token <i> PARSEOP_INCLUDE %token <i> PARSEOP_INCLUDE_CSTYLE @@ -363,6 +368,7 @@ AslLocalAllocate (unsigned int Size); %token <i> PARSEOP_QWORDCONST %token <i> PARSEOP_QWORDIO %token <i> PARSEOP_QWORDMEMORY +%token <i> PARSEOP_QWORDSPACE %token <i> PARSEOP_RANGETYPE_ENTIRE %token <i> PARSEOP_RANGETYPE_ISAONLY %token <i> PARSEOP_RANGETYPE_NONISAONLY @@ -404,12 +410,14 @@ AslLocalAllocate (unsigned int Size); %token <i> PARSEOP_SUBTRACT %token <i> PARSEOP_SWITCH %token <i> PARSEOP_THERMALZONE +%token <i> PARSEOP_TIMER %token <i> PARSEOP_TOBCD %token <i> PARSEOP_TOBUFFER %token <i> PARSEOP_TODECIMALSTRING %token <i> PARSEOP_TOHEXSTRING %token <i> PARSEOP_TOINTEGER %token <i> PARSEOP_TOSTRING +%token <i> PARSEOP_TOUUID %token <i> PARSEOP_TRANSLATIONTYPE_DENSE %token <i> PARSEOP_TRANSLATIONTYPE_SPARSE %token <i> PARSEOP_TYPE_STATIC @@ -427,6 +435,7 @@ AslLocalAllocate (unsigned int Size); %token <i> PARSEOP_WORDBUSNUMBER %token <i> PARSEOP_WORDCONST %token <i> PARSEOP_WORDIO +%token <i> PARSEOP_WORDSPACE %token <i> PARSEOP_XFERTYPE_8 %token <i> PARSEOP_XFERTYPE_8_16 %token <i> PARSEOP_XFERTYPE_16 @@ -460,6 +469,10 @@ AslLocalAllocate (unsigned int Size); %type <n> RequiredTarget %type <n> SimpleTarget %type <n> BufferTermData +%type <n> ParameterTypePackage +%type <n> ParameterTypePackageList +%type <n> ParameterTypesPackage +%type <n> ParameterTypesPackageList %type <n> Type1Opcode %type <n> Type2Opcode @@ -502,6 +515,7 @@ AslLocalAllocate (unsigned int Size); %type <n> DeviceTerm %type <n> EventTerm %type <n> FieldTerm +%type <n> FunctionTerm %type <n> IndexFieldTerm %type <n> MethodTerm %type <n> MutexTerm @@ -586,6 +600,7 @@ AslLocalAllocate (unsigned int Size); %type <n> SizeOfTerm %type <n> StoreTerm %type <n> SubtractTerm +%type <n> TimerTerm %type <n> ToBCDTerm %type <n> ToBufferTerm %type <n> ToDecimalStringTerm @@ -671,9 +686,11 @@ AslLocalAllocate (unsigned int Size); %type <n> VarPackageLengthTerm +/* Macros */ %type <n> EISAIDTerm %type <n> ResourceTemplateTerm +%type <n> ToUUIDTerm %type <n> UnicodeTerm %type <n> ResourceMacroList %type <n> ResourceMacroTerm @@ -681,7 +698,11 @@ AslLocalAllocate (unsigned int Size); %type <n> DMATerm %type <n> DWordIOTerm %type <n> DWordMemoryTerm +%type <n> DWordSpaceTerm %type <n> EndDependentFnTerm +%type <n> ExtendedIOTerm +%type <n> ExtendedMemoryTerm +%type <n> ExtendedSpaceTerm %type <n> FixedIOTerm %type <n> InterruptTerm %type <n> IOTerm @@ -692,6 +713,7 @@ AslLocalAllocate (unsigned int Size); %type <n> Memory32Term %type <n> QWordIOTerm %type <n> QWordMemoryTerm +%type <n> QWordSpaceTerm %type <n> RegisterTerm %type <n> StartDependentFnTerm %type <n> StartDependentFnNoPriTerm @@ -699,6 +721,7 @@ AslLocalAllocate (unsigned int Size); %type <n> VendorShortTerm %type <n> WordBusNumberTerm %type <n> WordIOTerm +%type <n> WordSpaceTerm %type <n> NameString %type <n> NameSeg @@ -710,8 +733,10 @@ AslLocalAllocate (unsigned int Size); %type <n> AmlPackageLengthTerm %type <n> OptionalByteConstExpr %type <n> OptionalDWordConstExpr +%type <n> OptionalQWordConstExpr %type <n> OptionalSerializeRuleKeyword %type <n> OptionalResourceType_First +%type <n> OptionalResourceType %type <n> OptionalMinType %type <n> OptionalMaxType %type <n> OptionalMemType @@ -728,6 +753,8 @@ AslLocalAllocate (unsigned int Size); %type <n> OptionalNameString_Last %type <n> OptionalAddressRange %type <n> OptionalObjectTypeKeyword +%type <n> OptionalParameterTypePackage +%type <n> OptionalParameterTypesPackage %type <n> OptionalReference @@ -769,9 +796,12 @@ DefinitionBlockTerm '{' ObjectList '}' {$$ = TrLinkChildren ($<n>3,7,$4,$6,$8,$10,$12,$14,$18);} ; +/* ACPI 3.0 -- allow semicolons between terms */ + TermList : {$$ = NULL;} | Term TermList {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$2);} + | Term ';' TermList {$$ = TrLinkPeerNode (TrSetNodeFlags ($1, NODE_RESULT_NOT_USED),$3);} ; Term @@ -846,6 +876,7 @@ NamedObject | DeviceTerm {} | EventTerm {} | FieldTerm {} + | FunctionTerm {} | IndexFieldTerm {} | MethodTerm {} | MutexTerm {} @@ -905,6 +936,52 @@ SimpleTarget | ArgTerm {} ; +/* Rules for specifying the Return type for control methods */ + +ParameterTypePackageList + : {$$ = NULL;} + | ObjectTypeKeyword {$$ = $1;} + | ObjectTypeKeyword ',' + ParameterTypePackageList {$$ = TrLinkPeerNodes (2,$1,$3);} + ; + +ParameterTypePackage + : {$$ = NULL;} + | ObjectTypeKeyword {$$ = $1;} + | '{' + ParameterTypePackageList + '}' {$$ = $2;} + ; + +OptionalParameterTypePackage + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | ',' {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | ',' ParameterTypePackage {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} + ; + +/* Rules for specifying the Argument types for control methods */ + +ParameterTypesPackageList + : {$$ = NULL;} + | ObjectTypeKeyword {$$ = $1;} + | ObjectTypeKeyword ',' + ParameterTypesPackage {$$ = TrLinkPeerNodes (2,$1,$3);} + ; + +ParameterTypesPackage + : {$$ = NULL;} + | ObjectTypeKeyword {$$ = $1;} + | '{' + ParameterTypesPackageList + '}' {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} + ; + +OptionalParameterTypesPackage + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | ',' {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | ',' ParameterTypesPackage {$$ = $2;} + ; + /* Opcode types */ @@ -937,12 +1014,13 @@ Type2Opcode | RefOfTerm {} | SizeOfTerm {} | StoreTerm {} + | TimerTerm {} | WaitTerm {} | UserTerm {} ; /* - * A type 2 opcode evaluates to an Integer and cannot have a destination operand + * Type 3/4/5 opcodes */ Type2IntegerOpcode /* "Type3" opcodes */ @@ -980,7 +1058,6 @@ Type2IntegerOpcode /* "Type3" opcodes */ | XOrTerm {} ; - Type2StringOpcode /* "Type4" Opcodes */ : ToDecimalStringTerm {} | ToHexStringTerm {} @@ -1019,6 +1096,7 @@ Type4Opcode Type5Opcode : ResourceTemplateTerm {} | UnicodeTerm {} + | ToUUIDTerm {} ; Type6Opcode @@ -1053,7 +1131,9 @@ ExternalTerm : PARSEOP_EXTERNAL '(' NameString OptionalObjectTypeKeyword - ')' {$$ = TrCreateNode (PARSEOP_EXTERNAL,2,$3,$4);} + OptionalParameterTypePackage + OptionalParameterTypesPackage + ')' {$$ = TrCreateNode (PARSEOP_EXTERNAL,4,$3,$4,$5,$6);} | PARSEOP_EXTERNAL '(' error ')' {$$ = AslDoError(); yyclearin;} ; @@ -1219,6 +1299,20 @@ FieldTerm error ')' {$$ = AslDoError(); yyclearin;} ; +FunctionTerm + : PARSEOP_FUNCTION '(' {$$ = TrCreateLeafNode (PARSEOP_METHOD);} + NameString + OptionalParameterTypePackage + OptionalParameterTypesPackage + ')' '{' + TermList '}' {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION), + TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0), + TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL), + TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),$5,$6,$9);} + | PARSEOP_FUNCTION '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + IndexFieldTerm : PARSEOP_INDEXFIELD '(' {$$ = TrCreateLeafNode (PARSEOP_INDEXFIELD);} NameString @@ -1238,8 +1332,10 @@ MethodTerm OptionalByteConstExpr {$$ = UtCheckIntegerRange ($5, 0, 7);} OptionalSerializeRuleKeyword OptionalByteConstExpr + OptionalParameterTypePackage + OptionalParameterTypesPackage ')' '{' - TermList '}' {$$ = TrLinkChildren ($<n>3,5,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$7,$8,$11);} + TermList '}' {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION),$5,$7,$8,$9,$10,$13);} | PARSEOP_METHOD '(' error ')' {$$ = AslDoError(); yyclearin;} ; @@ -1377,13 +1473,15 @@ ElseTerm | PARSEOP_ELSE '{' {$$ = TrCreateLeafNode (PARSEOP_ELSE);} TermList '}' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_ELSE '{' + error '}' {$$ = AslDoError(); yyclearin;} - | PARSEOP_ELSEIF '(' {$$ = TrCreateLeafNode (PARSEOP_ELSEIF);} - TermArg + | PARSEOP_ELSEIF '(' {$$ = TrCreateLeafNode (PARSEOP_ELSE);} + TermArg {$$ = TrCreateLeafNode (PARSEOP_IF);} ')' '{' - TermList '}' - ElseTerm {$$ = TrLinkChildren ($<n>3,3,$4,$7,$9);} - + TermList '}' {$$ = TrLinkChildren ($<n>5,2,$4,$8);} + ElseTerm {$$ = TrLinkPeerNode ($<n>5,$11);} + {$$ = TrLinkChildren ($<n>3,1,$<n>5);} | PARSEOP_ELSEIF '(' error ')' {$$ = AslDoError(); yyclearin;} ; @@ -1430,6 +1528,7 @@ ReturnTerm : PARSEOP_RETURN '(' {$$ = TrCreateLeafNode (PARSEOP_RETURN);} OptionalTermArg ')' {$$ = TrLinkChildren ($<n>3,1,$4);} + | PARSEOP_RETURN {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),0);} | PARSEOP_RETURN '(' error ')' {$$ = AslDoError(); yyclearin;} ; @@ -1496,8 +1595,8 @@ CaseTerm DefaultTerm : PARSEOP_DEFAULT '{' {$$ = TrCreateLeafNode (PARSEOP_DEFAULT);} TermList '}' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_DEFAULT '(' - error ')' {$$ = AslDoError(); yyclearin;} + | PARSEOP_DEFAULT '{' + error '}' {$$ = AslDoError(); yyclearin;} ; UnloadTerm @@ -1902,6 +2001,14 @@ SubtractTerm error ')' {$$ = AslDoError(); yyclearin;} ; +TimerTerm + : PARSEOP_TIMER '(' {$$ = TrCreateLeafNode (PARSEOP_TIMER);} + ')' {$$ = TrLinkChildren ($<n>3,0);} + | PARSEOP_TIMER {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_TIMER),0);} + | PARSEOP_TIMER '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + ToBCDTerm : PARSEOP_TOBCD '(' {$$ = TrCreateLeafNode (PARSEOP_TOBCD);} TermArg @@ -1957,6 +2064,13 @@ ToStringTerm error ')' {$$ = AslDoError(); yyclearin;} ; +ToUUIDTerm + : PARSEOP_TOUUID '(' + StringData ')' {$$ = TrUpdateNode (PARSEOP_TOUUID, $3);} + | PARSEOP_TOUUID '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + WaitTerm : PARSEOP_WAIT '(' {$$ = TrCreateLeafNode (PARSEOP_WAIT);} SuperName @@ -2381,7 +2495,11 @@ ResourceMacroTerm : DMATerm {} | DWordIOTerm {} | DWordMemoryTerm {} + | DWordSpaceTerm {} | EndDependentFnTerm {} + | ExtendedIOTerm {} + | ExtendedMemoryTerm {} + | ExtendedSpaceTerm {} | FixedIOTerm {} | InterruptTerm {} | IOTerm {} @@ -2392,6 +2510,7 @@ ResourceMacroTerm | Memory32Term {} | QWordIOTerm {} | QWordMemoryTerm {} + | QWordSpaceTerm {} | RegisterTerm {} | StartDependentFnTerm {} | StartDependentFnNoPriTerm {} @@ -2399,6 +2518,7 @@ ResourceMacroTerm | VendorShortTerm {} | WordBusNumberTerm {} | WordIOTerm {} + | WordSpaceTerm {} ; DMATerm @@ -2458,6 +2578,28 @@ DWordMemoryTerm error ')' {$$ = AslDoError(); yyclearin;} ; +DWordSpaceTerm + : PARSEOP_DWORDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_DWORDSPACE);} + ByteConstExpr {$$ = UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + ',' DWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} + | PARSEOP_DWORDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + + EndDependentFnTerm : PARSEOP_ENDDEPENDENTFN '(' ')' {$$ = TrCreateLeafNode (PARSEOP_ENDDEPENDENTFN);} @@ -2465,6 +2607,69 @@ EndDependentFnTerm error ')' {$$ = AslDoError(); yyclearin;} ; +ExtendedIOTerm + : PARSEOP_EXTENDEDIO '(' {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDIO);} + OptionalResourceType_First + OptionalMinType + OptionalMaxType + OptionalDecodeType + OptionalRangeType + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalQWordConstExpr + OptionalNameString + OptionalType + OptionalTranslationType_Last + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$19,$20,$21,$22);} + | PARSEOP_EXTENDEDIO '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ExtendedMemoryTerm + : PARSEOP_EXTENDEDMEMORY '(' {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDMEMORY);} + OptionalResourceType_First + OptionalDecodeType + OptionalMinType + OptionalMaxType + OptionalMemType + ',' ReadWriteKeyword + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalQWordConstExpr + OptionalNameString + OptionalAddressRange + OptionalType_Last + ')' {$$ = TrLinkChildren ($<n>3,15,$4,$5,$6,$7,$8,$10,$12,$14,$16,$18,$20,$21,$22,$23,$24);} + | PARSEOP_EXTENDEDMEMORY '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + +ExtendedSpaceTerm + : PARSEOP_EXTENDEDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_EXTENDEDSPACE);} + ByteConstExpr {$$ = UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalQWordConstExpr + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,13,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23);} + | PARSEOP_EXTENDEDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + FixedIOTerm : PARSEOP_FIXEDIO '(' {$$ = TrCreateLeafNode (PARSEOP_FIXEDIO);} WordConstExpr @@ -2606,6 +2811,27 @@ QWordMemoryTerm error ')' {$$ = AslDoError(); yyclearin;} ; +QWordSpaceTerm + : PARSEOP_QWORDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_QWORDSPACE);} + ByteConstExpr {$$ = UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + ',' QWordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} + | PARSEOP_QWORDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + RegisterTerm : PARSEOP_REGISTER '(' {$$ = TrCreateLeafNode (PARSEOP_REGISTER);} AddressSpaceKeyword @@ -2694,6 +2920,27 @@ WordIOTerm error ')' {$$ = AslDoError(); yyclearin;} ; +WordSpaceTerm + : PARSEOP_WORDSPACE '(' {$$ = TrCreateLeafNode (PARSEOP_WORDSPACE);} + ByteConstExpr {$$ = UtCheckIntegerRange ($4, 0xC0, 0xFF);} + OptionalResourceType + OptionalDecodeType + OptionalMinType + OptionalMaxType + ',' ByteConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + ',' WordConstExpr + OptionalByteConstExpr + OptionalStringData + OptionalNameString_Last + ')' {$$ = TrLinkChildren ($<n>3,14,$4,$6,$7,$8,$9,$11,$13,$15,$17,$19,$21,$22,$23,$24);} + | PARSEOP_WORDSPACE '(' + error ')' {$$ = AslDoError(); yyclearin;} + ; + /******* Object References ***********************************************/ @@ -2788,6 +3035,12 @@ OptionalObjectTypeKeyword | ',' ObjectTypeKeyword {$$ = $2;} ; +OptionalQWordConstExpr + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' QWordConstExpr {$$ = $2;} + ; + OptionalRangeType : ',' {$$ = NULL;} | ',' RangeTypeKeyword {$$ = $2;} @@ -2805,6 +3058,12 @@ OptionalResourceType_First | ResourceTypeKeyword {$$ = $1;} ; +OptionalResourceType + : {$$ = NULL;} + | ',' {$$ = NULL;} + | ',' ResourceTypeKeyword {$$ = $2;} + ; + OptionalSerializeRuleKeyword : {$$ = NULL;} | ',' {$$ = NULL;} diff --git a/sys/contrib/dev/acpica/compiler/aslglobal.h b/sys/contrib/dev/acpica/compiler/aslglobal.h index 199178fc9eb5..6dfe3cb4066e 100644 --- a/sys/contrib/dev/acpica/compiler/aslglobal.h +++ b/sys/contrib/dev/acpica/compiler/aslglobal.h @@ -3,7 +3,7 @@ /****************************************************************************** * * Module Name: aslglobal.h - Global variable definitions - * $Revision: 43 $ + * $Revision: 44 $ * *****************************************************************************/ @@ -225,6 +225,7 @@ ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalFolds, 0); /* Misc */ +ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_RevisionOverride, 0); ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*RootNode, NULL); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_TableLength, 0); ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_SourceLine, 0); diff --git a/sys/contrib/dev/acpica/compiler/aslmain.c b/sys/contrib/dev/acpica/compiler/aslmain.c index 203a6e76e728..8d82026ad9b5 100644 --- a/sys/contrib/dev/acpica/compiler/aslmain.c +++ b/sys/contrib/dev/acpica/compiler/aslmain.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslmain - compiler main and utilities - * $Revision: 76 $ + * $Revision: 77 $ * *****************************************************************************/ @@ -161,16 +161,17 @@ Options ( printf (" -vr Disable remarks\n"); printf (" -vs Disable signon\n"); - printf ("\nAML Output:\n"); + printf ("\nAML Output Files:\n"); printf (" -s<a|c> Create AML in assembler or C source file (*.asm or *.c)\n"); printf (" -i<a|c> Create assembler or C include file (*.inc or *.h)\n"); printf (" -t<a|c> Create AML in assembler or C hex table (*.hex)\n"); - printf ("\nAML Optimization:\n"); + printf ("\nAML Code Generation:\n"); printf (" -oa Disable all optimizations (compatibility mode)\n"); printf (" -of Disable constant folding\n"); printf (" -oi Disable integer optimization to Zero/One/Ones\n"); printf (" -on Disable named reference string optimization\n"); + printf (" -r<Revision> Override table header Revision (1-255)\n"); printf ("\nListings:\n"); printf (" -l Create mixed listing file (ASL source and AML) (*.lst)\n"); @@ -321,8 +322,13 @@ AslCommandLine ( /* Get the command line options */ - while ((j = AcpiGetopt (argc, argv, "b:cd^efgh^i^l^o:p:rs:t:v:x:")) != EOF) switch (j) + while ((j = AcpiGetopt (argc, argv, "ab:cd^efgh^i^l^o:p:r:s:t:v:x:")) != EOF) switch (j) { + case 'a': + AslToFile = FALSE; + break; + + case 'b': switch (AcpiGbl_Optarg[0]) @@ -544,7 +550,7 @@ AslCommandLine ( case 'r': - AslToFile = FALSE; + Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0); break; diff --git a/sys/contrib/dev/acpica/compiler/aslmap.c b/sys/contrib/dev/acpica/compiler/aslmap.c index d631dd43419a..b0927f65706d 100644 --- a/sys/contrib/dev/acpica/compiler/aslmap.c +++ b/sys/contrib/dev/acpica/compiler/aslmap.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslmap - parser to AML opcode mapping table - * $Revision: 71 $ + * $Revision: 76 $ * *****************************************************************************/ @@ -209,7 +209,12 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_AL7", 0, ASL_RSVD_RETURN_VALUE}, {"_AL8", 0, ASL_RSVD_RETURN_VALUE}, {"_AL9", 0, ASL_RSVD_RETURN_VALUE}, + {"_ALC", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_ALI", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_ALN", 0, ASL_RSVD_RESOURCE_NAME}, + {"_ALP", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_ALR", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_ALT", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_ASI", 0, ASL_RSVD_RESOURCE_NAME}, {"_BAS", 0, ASL_RSVD_RESOURCE_NAME}, {"_BBN", 0, ASL_RSVD_RETURN_VALUE}, @@ -218,12 +223,19 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_BDN", 0, ASL_RSVD_RETURN_VALUE}, {"_BFS", 1, 0}, {"_BIF", 0, ASL_RSVD_RETURN_VALUE}, + {"_BLT", 3, 0}, /* Acpi 3.0 */ {"_BM_", 0, ASL_RSVD_RESOURCE_NAME}, + {"_BMC", 1, 0}, /* Acpi 3.0 */ + {"_BMD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_BQC", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_BST", 0, ASL_RSVD_RETURN_VALUE}, + {"_BTM", 1, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_BTP", 1, 0}, + {"_CBA", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_CID", 0, ASL_RSVD_RETURN_VALUE}, {"_CRS", 0, ASL_RSVD_RETURN_VALUE}, {"_CRT", 0, ASL_RSVD_RETURN_VALUE}, + {"_CSD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_CST", 0, ASL_RSVD_RETURN_VALUE}, {"_DCK", 1, ASL_RSVD_RETURN_VALUE}, {"_DCS", 0, ASL_RSVD_RETURN_VALUE}, @@ -235,7 +247,9 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_DMA", 0, ASL_RSVD_RETURN_VALUE}, {"_DOD", 0, ASL_RSVD_RETURN_VALUE}, {"_DOS", 1, 0}, + {"_DSM", 4, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_DSS", 1, 0}, + {"_DSW", 3, 0}, /* Acpi 3.0 */ {"_EC_", 0, ASL_RSVD_RETURN_VALUE}, {"_EDL", 0, ASL_RSVD_RETURN_VALUE}, {"_EJ0", 1, 0}, @@ -244,6 +258,7 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_EJ3", 1, 0}, {"_EJ4", 1, 0}, {"_EJD", 0, ASL_RSVD_RETURN_VALUE}, + {"_ERR", 2, ASL_RSVD_RETURN_VALUE}, {"_FDE", 0, ASL_RSVD_RETURN_VALUE}, {"_FDI", 0, ASL_RSVD_RETURN_VALUE}, {"_FDM", 1, 0}, @@ -253,6 +268,7 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_GPD", 0, ASL_RSVD_RETURN_VALUE}, {"_GPE", 0, ASL_RSVD_RETURN_VALUE}, {"_GRA", 0, ASL_RSVD_RESOURCE_NAME}, + {"_GSB", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_GTF", 0, ASL_RSVD_RETURN_VALUE}, {"_GTM", 0, ASL_RSVD_RETURN_VALUE}, {"_GTS", 1, 0}, @@ -260,6 +276,8 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_HID", 0, ASL_RSVD_RETURN_VALUE}, {"_HOT", 0, ASL_RSVD_RETURN_VALUE}, {"_HPP", 0, ASL_RSVD_RETURN_VALUE}, + {"_HPX", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_IFT", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_INI", 0, 0}, {"_INT", 0, ASL_RSVD_RESOURCE_NAME}, {"_IRC", 0, 0}, @@ -273,16 +291,21 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_MEM", 0, ASL_RSVD_RESOURCE_NAME}, {"_MIF", 0, ASL_RSVD_RESOURCE_NAME}, {"_MIN", 0, ASL_RSVD_RESOURCE_NAME}, + {"_MLS", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_MSG", 1, 0}, {"_OFF", 0, 0}, {"_ON_", 0, 0}, {"_OS_", 0, ASL_RSVD_RETURN_VALUE}, + {"_OSC", 4, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_OSI", 1, ASL_RSVD_RETURN_VALUE}, + {"_OST", 3, 0}, /* Acpi 3.0 */ {"_PCL", 0, ASL_RSVD_RETURN_VALUE}, {"_PCT", 0, ASL_RSVD_RETURN_VALUE}, {"_PDC", 1, 0}, {"_PIC", 1, 0}, + {"_PLD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_PPC", 0, ASL_RSVD_RETURN_VALUE}, + {"_PPE", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_PR0", 0, ASL_RSVD_RETURN_VALUE}, {"_PR1", 0, ASL_RSVD_RETURN_VALUE}, {"_PR2", 0, ASL_RSVD_RETURN_VALUE}, @@ -294,6 +317,7 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_PS2", 0, 0}, {"_PS3", 0, 0}, {"_PSC", 0, ASL_RSVD_RETURN_VALUE}, + {"_PSD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_PSL", 0, ASL_RSVD_RETURN_VALUE}, {"_PSR", 0, ASL_RSVD_RETURN_VALUE}, {"_PSS", 0, ASL_RSVD_RETURN_VALUE}, @@ -309,6 +333,8 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_RMV", 0, ASL_RSVD_RETURN_VALUE}, {"_RNG", 0, ASL_RSVD_RESOURCE_NAME}, {"_ROM", 2, ASL_RSVD_RETURN_VALUE}, + {"_RT_", 0, ASL_RSVD_RESOURCE_NAME}, /* Acpi 3.0 */ + {"_RTV", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_RW_", 0, ASL_RSVD_RESOURCE_NAME}, {"_S0_", 0, ASL_RSVD_RETURN_VALUE}, {"_S1_", 0, ASL_RSVD_RETURN_VALUE}, @@ -320,32 +346,53 @@ const ASL_RESERVED_INFO ReservedMethods[] = { {"_S2D", 0, ASL_RSVD_RETURN_VALUE}, {"_S3D", 0, ASL_RSVD_RETURN_VALUE}, {"_S4D", 0, ASL_RSVD_RETURN_VALUE}, + {"_S0W", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_S1W", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_S2W", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_S3W", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_S4W", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_SB_", 0, ASL_RSVD_SCOPE}, {"_SBS", 0, ASL_RSVD_RETURN_VALUE}, {"_SCP", 1, 0}, + {"_SDD", 1, 0}, /* Acpi 3.0 */ {"_SEG", 0, ASL_RSVD_RETURN_VALUE}, {"_SHR", 0, ASL_RSVD_RESOURCE_NAME}, {"_SI_", 0, ASL_RSVD_SCOPE}, {"_SIZ", 0, ASL_RSVD_RESOURCE_NAME}, + {"_SLI", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_SPD", 1, ASL_RSVD_RETURN_VALUE}, {"_SRS", 1, 0}, + {"_SRV", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_SST", 1, 0}, {"_STA", 0, ASL_RSVD_RETURN_VALUE}, {"_STM", 3, 0}, {"_STR", 0, ASL_RSVD_RETURN_VALUE}, {"_SUN", 0, ASL_RSVD_RETURN_VALUE}, + {"_SWS", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_TC1", 0, ASL_RSVD_RETURN_VALUE}, {"_TC2", 0, ASL_RSVD_RETURN_VALUE}, {"_TMP", 0, ASL_RSVD_RETURN_VALUE}, + {"_TPC", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_TPT", 1, 0}, /* Acpi 3.0 */ {"_TRA", 0, ASL_RSVD_RESOURCE_NAME}, {"_TRS", 0, ASL_RSVD_RESOURCE_NAME}, + {"_TRT", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_TSD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_TSF", 0, ASL_RSVD_RESOURCE_NAME}, /* Acpi 3.0 */ {"_TSP", 0, ASL_RSVD_RETURN_VALUE}, + {"_TSS", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_TST", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_TTP", 0, ASL_RSVD_RESOURCE_NAME}, + {"_TTS", 1, 0}, /* Acpi 3.0 */ {"_TYP", 0, ASL_RSVD_RESOURCE_NAME}, {"_TZ_", 0, ASL_RSVD_SCOPE}, {"_TZD", 0, ASL_RSVD_RETURN_VALUE}, + {"_TZM", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_TZP", 0, ASL_RSVD_RETURN_VALUE}, {"_UID", 0, ASL_RSVD_RETURN_VALUE}, + {"_UPC", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_UPD", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ + {"_UPP", 0, ASL_RSVD_RETURN_VALUE}, /* Acpi 3.0 */ {"_VPO", 0, ASL_RSVD_RETURN_VALUE}, {"_WAK", 1, ASL_RSVD_RETURN_VALUE}, {NULL, 0, 0}, @@ -497,12 +544,16 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* DWORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_DWORD, 0, 0, ACPI_BTYPE_INTEGER), /* DWORDIO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* DWORDMEMORY */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), +/* DWORDSPACE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* EISAID */ OP_TABLE_ENTRY (AML_DWORD_OP, 0, 0, ACPI_BTYPE_INTEGER), /* ELSE */ OP_TABLE_ENTRY (AML_ELSE_OP, 0, NODE_AML_PACKAGE, 0), /* ELSEIF */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, NODE_AML_PACKAGE, 0), /* ENDDEPENDENTFN */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* ERRORNODE */ OP_TABLE_ENTRY (AML_NOOP_OP, 0, 0, 0), /* EVENT */ OP_TABLE_ENTRY (AML_EVENT_OP, 0, 0, 0), +/* EXTENDEDIO */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* EXTENDEDMEMORY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* EXTENDEDSPACE */ OP_TABLE_ENTRY (AML_RAW_DATA_QWORD, 0, 0, ACPI_BTYPE_INTEGER), /* EXTERNAL */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* FATAL */ OP_TABLE_ENTRY (AML_FATAL_OP, 0, 0, 0), /* FIELD */ OP_TABLE_ENTRY (AML_FIELD_OP, 0, NODE_AML_PACKAGE, 0), @@ -510,6 +561,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* FINDSETRIGHTBIT */ OP_TABLE_ENTRY (AML_FIND_SET_RIGHT_BIT_OP, 0, 0, ACPI_BTYPE_INTEGER), /* FIXEDIO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* FROMBCD */ OP_TABLE_ENTRY (AML_FROM_BCD_OP, 0, 0, ACPI_BTYPE_INTEGER), +/* FUNCTION */ OP_TABLE_ENTRY (AML_METHOD_OP, 0, NODE_AML_PACKAGE, 0), /* IF */ OP_TABLE_ENTRY (AML_IF_OP, 0, NODE_AML_PACKAGE, 0), /* INCLUDE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* INCLUDE_CSTYLE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), @@ -610,6 +662,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* QWORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_QWORD, 0, 0, ACPI_BTYPE_INTEGER), /* QWORDIO */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* QWORDMEMORY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* QWORDSPACE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* RANGE_TYPE_ENTIRE */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0), /* RANGE_TYPE_ISAONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0), /* RANGE_TYPE_NONISAONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0), @@ -651,12 +704,14 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* SUBTRACT */ OP_TABLE_ENTRY (AML_SUBTRACT_OP, 0, 0, ACPI_BTYPE_INTEGER), /* SWITCH */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0), /* THERMALZONE */ OP_TABLE_ENTRY (AML_THERMAL_ZONE_OP, 0, NODE_AML_PACKAGE, 0), +/* TIMER */ OP_TABLE_ENTRY (AML_TIMER_OP, 0, 0, ACPI_BTYPE_INTEGER), /* TOBCD */ OP_TABLE_ENTRY (AML_TO_BCD_OP, 0, 0, ACPI_BTYPE_INTEGER), /* TOBUFFER */ OP_TABLE_ENTRY (AML_TO_BUFFER_OP, 0, 0, ACPI_BTYPE_COMPUTE_DATA), /* TODECIMALSTRING */ OP_TABLE_ENTRY (AML_TO_DECSTRING_OP, 0, 0, ACPI_BTYPE_STRING), /* TOHEXSTRING */ OP_TABLE_ENTRY (AML_TO_HEXSTRING_OP, 0, 0, ACPI_BTYPE_STRING), /* TOINTEGER */ OP_TABLE_ENTRY (AML_TO_INTEGER_OP, 0, 0, ACPI_BTYPE_INTEGER), /* TOSTRING */ OP_TABLE_ENTRY (AML_TO_STRING_OP, 0, 0, ACPI_BTYPE_STRING), +/* TOUUID */ OP_TABLE_ENTRY (AML_DWORD_OP, 0, NODE_AML_PACKAGE, ACPI_BTYPE_INTEGER), /* TRANSLATIONTYPE_DENSE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* TRANSLATIONTYPE_SPARSE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0), /* TYPE_STATIC */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), @@ -674,6 +729,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* WORDBUSNUMBER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* WORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_WORD, 0, 0, ACPI_BTYPE_INTEGER), /* WORDIO */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), +/* WORDSPACE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* XFERTYPE_8 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0), /* XFERTYPE_8_16 */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0), /* XFERTYPE_16 */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0), diff --git a/sys/contrib/dev/acpica/compiler/aslopcodes.c b/sys/contrib/dev/acpica/compiler/aslopcodes.c index e838d7bfb3f2..4f2033b9c761 100644 --- a/sys/contrib/dev/acpica/compiler/aslopcodes.c +++ b/sys/contrib/dev/acpica/compiler/aslopcodes.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslopcode - AML opcode generation - * $Revision: 55 $ + * $Revision: 60 $ * *****************************************************************************/ @@ -206,6 +206,18 @@ OpcSetOptimalIntegerSize ( ACPI_PARSE_OBJECT *Op) { +/* + TBD: - we don't want to optimize integers in the block header, but the + code below does not work correctly. + + if (Op->Asl.Parent && + Op->Asl.Parent->Asl.Parent && + (Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK)) + { + return 0; + } +*/ + /* * Check for the special AML integers first - Zero, One, Ones. * These are single-byte opcodes that are the smallest possible @@ -407,7 +419,6 @@ OpcDoUnicode ( * * RETURN: None * - * * DESCRIPTION: Convert a string EISA ID to numeric representation. See the * Pnp BIOS Specification for details. Here is an excerpt: * @@ -464,11 +475,11 @@ OpcDoEisaId ( for (i = 0; i < 7; i++) { - /* First 3 characters must be letters */ + /* First 3 characters must be uppercase letters */ if (i < 3) { - if (!isalpha (InString[i])) + if (!isupper (InString[i])) { Status = AE_BAD_PARAMETER; } @@ -523,6 +534,102 @@ OpcDoEisaId ( /******************************************************************************* * + * FUNCTION: OpcDoUiId + * + * PARAMETERS: Op - Parse node + * + * RETURN: None + * + * DESCRIPTION: + * + ******************************************************************************/ + +static UINT8 OpcMapToUUID[16] = {6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34}; + +void +OpcDoUuId ( + ACPI_PARSE_OBJECT *Op) +{ + char *InString; + char *Buffer; + ACPI_STATUS Status = AE_OK; + ACPI_NATIVE_UINT i; + ACPI_PARSE_OBJECT *NewOp; + + + InString = (char *) Op->Asl.Value.String; + + if (ACPI_STRLEN (InString) != 36) + { + Status = AE_BAD_PARAMETER; + } + else + { + /* Check all 36 characters for correct format */ + + for (i = 0; i < 36; i++) + { + if ((i == 8) || (i == 13) || (i == 18) || (i == 23)) + { + if (InString[i] != '-') + { + Status = AE_BAD_PARAMETER; + } + } + else + { + if (!isxdigit (InString[i])) + { + Status = AE_BAD_PARAMETER; + } + } + } + } + + Buffer = UtLocalCalloc (16); + + if (ACPI_FAILURE (Status)) + { + AslError (ASL_ERROR, ASL_MSG_INVALID_UUID, Op, Op->Asl.Value.String); + } + else for (i = 0; i < 16; i++) + { + Buffer[i] = (char) (UtHexCharToValue (InString[OpcMapToUUID[i]]) << 4); + Buffer[i] = (char) UtHexCharToValue (InString[OpcMapToUUID[i] + 1]); + } + + /* Change Op to a Buffer */ + + Op->Asl.ParseOpcode = PARSEOP_BUFFER; + Op->Common.AmlOpcode = AML_BUFFER_OP; + Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST; /* Disable further optimization */ + UtSetParseOpName (Op); + + /* Child node is the buffer length */ + + NewOp = TrAllocateNode (PARSEOP_INTEGER); + + NewOp->Asl.AmlOpcode = AML_BYTE_OP; + NewOp->Asl.Value.Integer = 16; + NewOp->Asl.Parent = Op; + + Op->Asl.Child = NewOp; + Op = NewOp; + + /* Peer to the child is the raw buffer data */ + + NewOp = TrAllocateNode (PARSEOP_RAW_DATA); + NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER; + NewOp->Asl.AmlLength = 16; + NewOp->Asl.Value.String = (char *) Buffer; + NewOp->Asl.Parent = Op->Asl.Parent; + + Op->Asl.Next = NewOp; +} + + +/******************************************************************************* + * * FUNCTION: OpcGenerateAmlOpcode * * PARAMETERS: Op - Parse node @@ -580,6 +687,11 @@ OpcGenerateAmlOpcode ( OpcDoEisaId (Op); break; + case PARSEOP_TOUUID: + + OpcDoUuId (Op); + break; + case PARSEOP_UNICODE: OpcDoUnicode (Op); diff --git a/sys/contrib/dev/acpica/compiler/aslopt.c b/sys/contrib/dev/acpica/compiler/aslopt.c index 5aeea27fdfff..f0416d8e848b 100644 --- a/sys/contrib/dev/acpica/compiler/aslopt.c +++ b/sys/contrib/dev/acpica/compiler/aslopt.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: aslopt- Compiler optimizations - * $Revision: 13 $ + * $Revision: 16 $ * *****************************************************************************/ @@ -211,8 +211,11 @@ OptSearchToRoot ( *NewPath = ACPI_MEM_CALLOCATE (ACPI_NAME_SIZE + 1); ACPI_STRCPY (*NewPath, Path); - AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION, Op, - *NewPath); + if (ACPI_STRNCMP (*NewPath, "_T_", 3)) + { + AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION, Op, + *NewPath); + } return (AE_OK); } @@ -354,6 +357,15 @@ OptBuildShortestPath ( * of the current path. We must include one more NameSeg of the target path */ Index -= ACPI_PATH_SEGMENT_LENGTH; + + /* Special handling for Scope() operator */ + + if (Op->Asl.AmlOpcode == AML_SCOPE_OP) + { + NewPathExternal[i] = '^'; + i++; + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "(EXTRA ^)")); + } } ACPI_STRCPY (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]); @@ -581,7 +593,7 @@ OptOptimizeNamePath ( /* Various required items */ - if (!TargetNode || !WalkState || !Op->Common.Parent) + if (!TargetNode || !WalkState || !AmlNameString || !Op->Common.Parent) { return_VOID; } diff --git a/sys/contrib/dev/acpica/compiler/asltransform.c b/sys/contrib/dev/acpica/compiler/asltransform.c index fc771d5c4c6c..f05f2f7749ed 100644 --- a/sys/contrib/dev/acpica/compiler/asltransform.c +++ b/sys/contrib/dev/acpica/compiler/asltransform.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: asltransform - Parse tree transforms - * $Revision: 20 $ + * $Revision: 25 $ * *****************************************************************************/ @@ -131,7 +131,7 @@ * * RETURN: A pointer to the second character of the name * - * DESCRIPTION: Generate an ACPI name of the form _Txx. These names are + * DESCRIPTION: Generate an ACPI name of the form _T_x. These names are * reserved for use by the ASL compiler. * ******************************************************************************/ @@ -143,7 +143,7 @@ TrAmlGetNextTempName ( char *TempName; - if (Gbl_TempCount > 255) + if (Gbl_TempCount > (9+26+26)) { /* Too many temps */ /* TBD: issue eror message */ @@ -152,14 +152,27 @@ TrAmlGetNextTempName ( } TempName = UtLocalCalloc (6); - UtConvertByteToHex ((UINT8) Gbl_TempCount, (UINT8 *) &TempName [1]); + + if (Gbl_TempCount < 9) + { + TempName[4] = (char) (Gbl_TempCount + 0x30); + } + else if (Gbl_TempCount < (9 + 26)) + { + TempName[4] = (char) (Gbl_TempCount + 0x41); + } + else + { + TempName[4] = (char) (Gbl_TempCount + 0x61); + } Gbl_TempCount++; - /* First three characters are always "\_T" */ + /* First four characters are always "\_T_" */ TempName[0] = '\\'; TempName[1] = '_'; TempName[2] = 'T'; + TempName[3] = '_'; *NamePath = TempName; return (&TempName[1]); @@ -326,10 +339,6 @@ TrTransformSubtree ( TrDoDefinitionBlock (Op); break; - case PARSEOP_ELSEIF: - TrDoElseif (Op); - break; - case PARSEOP_SWITCH: TrDoSwitch (Op); break; @@ -375,59 +384,6 @@ TrDoDefinitionBlock ( /******************************************************************************* * - * FUNCTION: TrDoElseif - * - * PARAMETERS: Op - Parse node for ELSEIF - * - * RETURN: None - * - * DESCRIPTION: Transform an Elseif into an Else and If AML opcode pair. - * There is no AML opcode for ELSEIF -- it must be simulated - * with an if/else pair. - * - ******************************************************************************/ - -void -TrDoElseif ( - ACPI_PARSE_OBJECT *ElseNode) -{ - ACPI_PARSE_OBJECT *IfNode = NULL; - ACPI_PARSE_OBJECT *NextNode; - - - /* Change the ELSEIF into an ELSE */ - - TrAmlInitNode (ElseNode, PARSEOP_ELSE); - - /* Create a new IF node */ - - IfNode = TrCreateLeafNode (PARSEOP_IF); - IfNode->Asl.Parent = ElseNode; - TrAmlInitLineNumbers (IfNode, ElseNode); - - /* Insert the the IF node first in the ELSE child list */ - - IfNode->Asl.Child = ElseNode->Asl.Child; - ElseNode->Asl.Child = IfNode; - - /* Go to the end of the IF <Predicate><TermList> block */ - - NextNode = IfNode->Asl.Child; /* Next = Predicate */ - NextNode = NextNode->Asl.Next; /* Nest = TermList */ - - /* Make the next node after the IF the rest of the original tree */ - - IfNode->Asl.Next = NextNode->Asl.Next; - - /* Terminate the IF subtree and set IF node as the parent for all nodes */ - - NextNode->Asl.Next = NULL; - TrAmlSetSubtreeParent (IfNode->Asl.Child, IfNode); -} - - -/******************************************************************************* - * * FUNCTION: TrDoSwitch * * PARAMETERS: StartNode - Parse node for SWITCH @@ -493,34 +449,96 @@ TrDoSwitch ( Conditional = CaseOp; CaseBlock = CaseOp->Asl.Child->Asl.Next; Conditional->Asl.Child->Asl.Next = NULL; + Predicate = CaseOp->Asl.Child; - /* - * change CaseOp() to: If (PredicateValue == CaseValue) {...} - * CaseOp->Child is the case value - * CaseOp->Child->Peer is the beginning of the case block - */ - NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, - (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValuePath)); + if (Predicate->Asl.ParseOpcode == PARSEOP_PACKAGE) + { + AcpiOsPrintf ("Package\n"); - Predicate = CaseOp->Asl.Child; - Predicate->Asl.Next = NewOp; - TrAmlInitLineNumbers (NewOp, Predicate); + /* + * Convert the package declaration to this form: + * + * If (LNotEqual (Match (Package(){4}, MEQ, _Txx, MTR, 0, 0), Ones)) + */ + NewOp2 = TrCreateLeafNode (PARSEOP_MATCHTYPE_MEQ); + Predicate->Asl.Next = NewOp2; + TrAmlInitLineNumbers (NewOp2, Conditional); + + NewOp = NewOp2; + NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, + (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValuePath)); + NewOp->Asl.Next = NewOp2; + TrAmlInitLineNumbers (NewOp2, Predicate); + + NewOp = NewOp2; + NewOp2 = TrCreateLeafNode (PARSEOP_MATCHTYPE_MTR); + NewOp->Asl.Next = NewOp2; + TrAmlInitLineNumbers (NewOp2, Predicate); + + NewOp = NewOp2; + NewOp2 = TrCreateLeafNode (PARSEOP_ZERO); + NewOp->Asl.Next = NewOp2; + TrAmlInitLineNumbers (NewOp2, Predicate); + + NewOp = NewOp2; + NewOp2 = TrCreateLeafNode (PARSEOP_ZERO); + NewOp->Asl.Next = NewOp2; + TrAmlInitLineNumbers (NewOp2, Predicate); + + NewOp2 = TrCreateLeafNode (PARSEOP_MATCH); + NewOp2->Asl.Child = Predicate; /* PARSEOP_PACKAGE */ + TrAmlInitLineNumbers (NewOp2, Conditional); + TrAmlSetSubtreeParent (Predicate, NewOp2); + + NewOp = NewOp2; + NewOp2 = TrCreateLeafNode (PARSEOP_ONES); + NewOp->Asl.Next = NewOp2; + TrAmlInitLineNumbers (NewOp2, Conditional); + + NewOp2 = TrCreateLeafNode (PARSEOP_LEQUAL); + NewOp2->Asl.Child = NewOp; + NewOp->Asl.Parent = NewOp2; + TrAmlInitLineNumbers (NewOp2, Conditional); + TrAmlSetSubtreeParent (NewOp, NewOp2); + + NewOp = NewOp2; + NewOp2 = TrCreateLeafNode (PARSEOP_LNOT); + NewOp2->Asl.Child = NewOp; + NewOp2->Asl.Parent = Conditional; + NewOp->Asl.Parent = NewOp2; + TrAmlInitLineNumbers (NewOp2, Conditional); + + Conditional->Asl.Child = NewOp2; + NewOp2->Asl.Next = CaseBlock; + } + else + { + /* + * Change CaseOp() to: If (PredicateValue == CaseValue) {...} + * CaseOp->Child is the case value + * CaseOp->Child->Peer is the beginning of the case block + */ + NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, + (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValuePath)); + Predicate->Asl.Next = NewOp; + TrAmlInitLineNumbers (NewOp, Predicate); - NewOp2 = TrCreateLeafNode (PARSEOP_LEQUAL); - NewOp2->Asl.Parent = Conditional; - NewOp2->Asl.Child = Predicate; - TrAmlInitLineNumbers (NewOp2, Conditional); + NewOp2 = TrCreateLeafNode (PARSEOP_LEQUAL); + NewOp2->Asl.Parent = Conditional; + NewOp2->Asl.Child = Predicate; + TrAmlInitLineNumbers (NewOp2, Conditional); - TrAmlSetSubtreeParent (Predicate, NewOp2); + TrAmlSetSubtreeParent (Predicate, NewOp2); - Predicate = NewOp2; - Predicate->Asl.Next = CaseBlock; + Predicate = NewOp2; + Predicate->Asl.Next = CaseBlock; - TrAmlSetSubtreeParent (Predicate, Conditional); + TrAmlSetSubtreeParent (Predicate, Conditional); + Conditional->Asl.Child = Predicate; + } /* Reinitialize the CASE node to an IF node */ - Conditional->Asl.Child = Predicate; TrAmlInitNode (Conditional, PARSEOP_IF); /* @@ -550,7 +568,12 @@ TrDoSwitch ( { if (DefaultOp) { - /* More than one Default */ + /* + * More than one Default + * (Parser should catch this, should not get here) + */ + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Next, + "Found more than one Default()"); } /* Save the DEFAULT node for later, after CASEs */ @@ -559,7 +582,7 @@ TrDoSwitch ( } else { - /* Unkown peer opcode */ + /* Unknown peer opcode */ printf ("Unknown parse opcode for switch statement: %s (%d)\n", Next->Asl.ParseOpName, Next->Asl.ParseOpcode); @@ -567,30 +590,36 @@ TrDoSwitch ( } /* - * Add the default at the end of the if/else construct + * Add the default case at the end of the if/else construct */ if (DefaultOp) { + /* If no CASE statements, this is an error - see below */ + if (CaseOp) { - /* Add an ELSE first */ + /* Convert the DEFAULT node to an ELSE */ TrAmlInitNode (DefaultOp, PARSEOP_ELSE); DefaultOp->Asl.Parent = Conditional->Asl.Parent; - } - else - { - /* There were no CASE statements, no ELSE needed */ - TrAmlInsertPeer (CurrentParentNode, DefaultOp->Asl.Child); + /* Link ELSE node as a peer to the previous IF */ + + TrAmlInsertPeer (Conditional, DefaultOp); } } + if (!CaseOp) + { + AslError (ASL_ERROR, ASL_MSG_NO_CASES, StartNode, NULL); + } + /* * Add a NAME node for the temp integer */ NewOp = TrCreateLeafNode (PARSEOP_NAME); NewOp->Asl.Parent = Gbl_FirstLevelInsertionNode->Asl.Parent; + NewOp->Asl.CompileFlags |= NODE_COMPILER_EMITTED; NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName)); @@ -612,8 +641,6 @@ TrDoSwitch ( TrAmlInitNode (StartNode, PARSEOP_STORE); Predicate = StartNode->Asl.Child; - Predicate->Asl.Child = NULL; - NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValuePath)); NewOp->Asl.Parent = StartNode; diff --git a/sys/contrib/dev/acpica/compiler/asltypes.h b/sys/contrib/dev/acpica/compiler/asltypes.h index 5f1bcb34499f..ae7876cef95a 100644 --- a/sys/contrib/dev/acpica/compiler/asltypes.h +++ b/sys/contrib/dev/acpica/compiler/asltypes.h @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: asltypes.h - compiler data types and struct definitions - * $Revision: 62 $ + * $Revision: 65 $ * *****************************************************************************/ @@ -149,6 +149,7 @@ #define NODE_IS_TERM_ARG 0x00004000 #define NODE_WAS_ONES_OP 0x00008000 #define NODE_IS_NAME_DECLARATION 0x00010000 +#define NODE_COMPILER_EMITTED 0x00020000 /* Keeps information about individual control methods */ @@ -157,6 +158,8 @@ typedef struct asl_method_info UINT8 NumArguments; UINT8 LocalInitialized[ACPI_METHOD_NUM_LOCALS]; UINT8 ArgInitialized[ACPI_METHOD_NUM_ARGS]; + UINT32 ValidArgTypes[ACPI_METHOD_NUM_ARGS]; + UINT32 ValidReturnTypes; UINT32 NumReturnNoValue; UINT32 NumReturnWithValue; ACPI_PARSE_OBJECT *Op; @@ -387,7 +390,10 @@ typedef enum ASL_MSG_EARLY_EOF, ASL_MSG_SCOPE_FWD_REF, ASL_MSG_NON_ASCII, - ASL_MSG_INVALID_TIME + ASL_MSG_INVALID_TIME, + ASL_MSG_DUPLICATE_CASE, + ASL_MSG_NO_CASES, + ASL_MSG_INVALID_UUID } ASL_MESSAGE_IDS; @@ -477,7 +483,12 @@ char *AslMessages [] = { /* ASL_MSG_EARLY_EOF */ "Premature end-of-file reached", /* ASL_MSG_SCOPE_FWD_REF */ "Forward references from Scope() not allowed", /* ASL_MSG_NON_ASCII */ "Invalid characters found in file", -/* ASL_MSG_INVALID_TIME */ "Time parameter too long (255 max)" +/* ASL_MSG_INVALID_TIME */ "Time parameter too long (255 max)", +/* ASL_MSG_DUPLICATE_CASE */ "Case value already specified", +/* ASL_MSG_NO_CASES */ "No Case() statements under Switch()", +/* ASL_MSG_INVALID_UUID */ "UUID string must be of the form \"aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\"" + + }; diff --git a/sys/contrib/dev/acpica/dbcmds.c b/sys/contrib/dev/acpica/dbcmds.c index 8e91e5e98720..6aaa17791871 100644 --- a/sys/contrib/dev/acpica/dbcmds.c +++ b/sys/contrib/dev/acpica/dbcmds.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbcmds - debug commands and output routines - * $Revision: 113 $ + * $Revision: 115 $ * ******************************************************************************/ @@ -124,6 +124,9 @@ #include "acresrc.h" #include "acdisasm.h" + +#include "acparser.h" + #ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER @@ -157,6 +160,18 @@ static ARGUMENT_INFO AcpiDbObjectTypes [] = }; +/******************************************************************************* + * + * FUNCTION: AcpiDbSleep + * + * PARAMETERS: ObjectArg - Desired sleep state (0-5) + * + * RETURN: Status + * + * DESCRIPTION: Simulate a sleep/wake sequence + * + ******************************************************************************/ + ACPI_STATUS AcpiDbSleep ( char *ObjectArg) @@ -505,6 +520,71 @@ AcpiDbDisassembleAml ( /******************************************************************************* * + * FUNCTION: AcpiDbDisassembleMethod + * + * PARAMETERS: Method - Name of control method + * + * RETURN: None + * + * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number + * of statements specified. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDbDisassembleMethod ( + char *Name) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Method; + + + Method = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ACPI_STRTOUL (Name, NULL, 16)); + if (!Method) + { + return (AE_BAD_PARAMETER); + } + + ObjDesc = Method->Object; + + Op = AcpiPsCreateScopeOp (); + if (!Op) + { + return (AE_NO_MEMORY); + } + + /* Create and initialize a new walk state */ + + WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL); + if (!WalkState) + { + return (AE_NO_MEMORY); + } + + Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength, NULL, 1); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Parse the AML */ + + WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; + Status = AcpiPsParseAml (WalkState); + + AcpiDmDisassemble (NULL, Op, 0); + AcpiPsDeleteParseTree (Op); + return (AE_OK); +} + + +/******************************************************************************* + * * FUNCTION: AcpiDbDumpNamespace * * PARAMETERS: StartArg - Node to begin namespace dump @@ -836,6 +916,8 @@ AcpiDbWalkForSpecificObjects ( if (ObjDesc) { + AcpiOsPrintf (" %p/%p", ObjHandle, ObjDesc); + switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_METHOD: diff --git a/sys/contrib/dev/acpica/dbexec.c b/sys/contrib/dev/acpica/dbexec.c index e06edb8f023a..1833d8f3aaf0 100644 --- a/sys/contrib/dev/acpica/dbexec.c +++ b/sys/contrib/dev/acpica/dbexec.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbexec - debugger control method execution - * $Revision: 60 $ + * $Revision: 62 $ * ******************************************************************************/ @@ -395,7 +395,7 @@ AcpiDbExecute ( * Allow any handlers in separate threads to complete. * (Such as Notify handlers invoked from AML executed above). */ - AcpiOsSleep (0, 10); + AcpiOsSleep (10); #ifdef ACPI_DEBUG_OUTPUT @@ -408,7 +408,7 @@ AcpiDbExecute ( if (Allocations > 0) { - AcpiOsPrintf ("Outstanding: %u allocations after execution\n", + AcpiOsPrintf ("Outstanding: 0x%X allocations after execution\n", Allocations); } #endif diff --git a/sys/contrib/dev/acpica/dbinput.c b/sys/contrib/dev/acpica/dbinput.c index 33d54a3aedca..063a51890f0e 100644 --- a/sys/contrib/dev/acpica/dbinput.c +++ b/sys/contrib/dev/acpica/dbinput.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbinput - user front-end to the AML debugger - * $Revision: 100 $ + * $Revision: 101 $ * ******************************************************************************/ @@ -141,6 +141,7 @@ enum AcpiExDebuggerCommands CMD_CALL, CMD_CLOSE, CMD_DEBUG, + CMD_DISASSEMBLE, CMD_DUMP, CMD_ENABLEACPI, CMD_EVENT, @@ -200,6 +201,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = {"CALL", 0}, {"CLOSE", 0}, {"DEBUG", 1}, + {"DISASSEMBLE", 1}, {"DUMP", 1}, {"ENABLEACPI", 0}, {"EVENT", 1}, @@ -275,6 +277,7 @@ AcpiDbDisplayHelp ( AcpiOsPrintf (" [GENERAL] General-Purpose Commands\n"); AcpiOsPrintf (" [NAMESPACE] Namespace Access Commands\n"); AcpiOsPrintf (" [METHOD] Control Method Execution Commands\n"); + AcpiOsPrintf (" [STATISTICS] Statistical Information\n"); AcpiOsPrintf (" [FILE] File I/O Commands\n"); return; } @@ -298,17 +301,32 @@ AcpiDbDisplayHelp ( AcpiOsPrintf ("Locks Current status of internal mutexes\n"); AcpiOsPrintf ("Quit or Exit Exit this command\n"); AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n"); - AcpiOsPrintf (" |Objects|Tables] Display namespace and memory statistics\n"); + AcpiOsPrintf (" |Objects|Sizes|Stack|Tables] Display namespace and memory statistics\n"); AcpiOsPrintf ("Tables Display info about loaded ACPI tables\n"); AcpiOsPrintf ("Unload <TableSig> [Instance] Unload an ACPI table\n"); AcpiOsPrintf ("! <CommandNumber> Execute command from history buffer\n"); AcpiOsPrintf ("!! Execute last command again\n"); return; + case 'S': + AcpiOsPrintf ("\nStats Subcommands\n\n"); + AcpiOsPrintf ("Allocations Display list of current memory allocations\n"); + AcpiOsPrintf ("Memory Dump internal memory lists\n"); + AcpiOsPrintf ("Misc Namespace search and mutex stats\n"); + AcpiOsPrintf ("Objects Summary of namespace objects\n"); + AcpiOsPrintf ("Sizes Sizes for each of the internal objects\n"); + AcpiOsPrintf ("Stack Display CPU stack usage\n"); + AcpiOsPrintf ("Tables Info about current ACPI table(s)\n"); + return; + case 'N': AcpiOsPrintf ("\nNamespace Access Commands\n\n"); + AcpiOsPrintf ("Disassemble <Method> Disassemble a control method\n"); AcpiOsPrintf ("Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n"); AcpiOsPrintf ("Find <Name> (? is wildcard) Find ACPI name(s) with wildcards\n"); + AcpiOsPrintf ("Gpe <GpeNum> <GpeBlock> Simulate a GPE\n"); + AcpiOsPrintf ("Gpes Display info on all GPEs\n"); + AcpiOsPrintf ("Integrity Validate namespace integrity\n"); AcpiOsPrintf ("Method Display list of loaded control methods\n"); AcpiOsPrintf ("Namespace [<Addr>|<Path>] [Depth] Display loaded namespace tree/subtree\n"); AcpiOsPrintf ("Notify <NamePath> <Value> Send a notification\n"); @@ -317,8 +335,10 @@ AcpiDbDisplayHelp ( AcpiOsPrintf ("Prefix [<NamePath>] Set or Get current execution prefix\n"); AcpiOsPrintf ("References <Addr> Find all references to object at addr\n"); AcpiOsPrintf ("Resources xxx Get and display resources\n"); + AcpiOsPrintf ("Sleep <SleepState> Simulate sleep/wake sequence\n"); AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n"); AcpiOsPrintf ("Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n"); + AcpiOsPrintf ("Type <Object> Display object type\n"); return; case 'M': @@ -601,6 +621,10 @@ AcpiDbCommandDispatch ( AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_SINGLE_STEP); break; + case CMD_DISASSEMBLE: + AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]); + break; + case CMD_DUMP: AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); break; diff --git a/sys/contrib/dev/acpica/dbutils.c b/sys/contrib/dev/acpica/dbutils.c index a74ddda5c6fe..5d8197c8b6e3 100644 --- a/sys/contrib/dev/acpica/dbutils.c +++ b/sys/contrib/dev/acpica/dbutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbutils - AML debugger utilities - * $Revision: 66 $ + * $Revision: 68 $ * ******************************************************************************/ @@ -121,6 +121,7 @@ #include "acnamesp.h" #include "acdebug.h" #include "acdispat.h" +#include "acdisasm.h" #ifdef ACPI_DEBUGGER @@ -261,7 +262,8 @@ AcpiDbDumpObject ( { case ACPI_TYPE_ANY: - AcpiOsPrintf ("[Object Reference] = %p\n", ObjDesc->Reference.Handle); + AcpiOsPrintf ("[Object Reference] = ", ObjDesc->Reference.Handle); + AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL); break; @@ -312,7 +314,8 @@ AcpiDbDumpObject ( case ACPI_TYPE_LOCAL_REFERENCE: - AcpiOsPrintf ("[Object Reference] = %p\n", ObjDesc->Reference.Handle); + AcpiOsPrintf ("[Object Reference] = ", ObjDesc->Reference.Handle); + AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL); break; diff --git a/sys/contrib/dev/acpica/dmwalk.c b/sys/contrib/dev/acpica/dmwalk.c index fa0c01caaedd..e46ef5480c6e 100644 --- a/sys/contrib/dev/acpica/dmwalk.c +++ b/sys/contrib/dev/acpica/dmwalk.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmwalk - AML disassembly tree walk - * $Revision: 13 $ + * $Revision: 14 $ * ******************************************************************************/ @@ -469,7 +469,7 @@ AcpiDmDescendingOp ( while (AcpiGbl_ExternalList) { - AcpiOsPrintf (" External (%s)\n", AcpiGbl_ExternalList->Path); + AcpiOsPrintf (" External (%s, DeviceObj)\n", AcpiGbl_ExternalList->Path); NextExternal = AcpiGbl_ExternalList->Next; ACPI_MEM_FREE (AcpiGbl_ExternalList->Path); diff --git a/sys/contrib/dev/acpica/dsmethod.c b/sys/contrib/dev/acpica/dsmethod.c index 46c7e6694ead..ecff19aa8120 100644 --- a/sys/contrib/dev/acpica/dsmethod.c +++ b/sys/contrib/dev/acpica/dsmethod.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsmethod - Parser/Interpreter interface - control method parsing - * $Revision: 97 $ + * $Revision: 101 $ * *****************************************************************************/ @@ -132,15 +132,12 @@ * * FUNCTION: AcpiDsParseMethod * - * PARAMETERS: ObjHandle - Node of the method - * Level - Current nesting level - * Context - Points to a method counter - * ReturnValue - Not used + * PARAMETERS: ObjHandle - Method node * * RETURN: Status * - * DESCRIPTION: Call the parser and parse the AML that is - * associated with the method. + * DESCRIPTION: Call the parser and parse the AML that is associated with the + * method. * * MUTEX: Assumes parser is locked * @@ -273,8 +270,6 @@ AcpiDsParseMethod ( * increments the thread count, and waits at the method semaphore * for clearance to execute. * - * MUTEX: Locks/unlocks parser. - * ******************************************************************************/ ACPI_STATUS @@ -337,7 +332,8 @@ AcpiDsBeginMethodExecution ( * * FUNCTION: AcpiDsCallControlMethod * - * PARAMETERS: WalkState - Current state of the walk + * PARAMETERS: Thread - Info for this thread + * ThisWalkState - Current walk state * Op - Current Op to be walked * * RETURN: Status @@ -499,12 +495,13 @@ Cleanup: * * FUNCTION: AcpiDsRestartControlMethod * - * PARAMETERS: WalkState - State of the method when it was preempted - * Op - Pointer to new current op + * PARAMETERS: WalkState - State for preempted method (caller) + * ReturnDesc - Return value from the called method * * RETURN: Status * - * DESCRIPTION: Restart a method that was preempted + * DESCRIPTION: Restart a method that was preempted by another (nested) method + * invocation. Handle the return value (if any) from the callee. * ******************************************************************************/ @@ -519,20 +516,38 @@ AcpiDsRestartControlMethod ( ACPI_FUNCTION_TRACE_PTR ("DsRestartControlMethod", WalkState); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n", + (char *) &WalkState->MethodNode->Name, WalkState->MethodCallOp, + ReturnDesc)); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + " ReturnFromThisMethodUsed?=%X ResStack %p Walk %p\n", + WalkState->ReturnUsed, + WalkState->Results, WalkState)); + + /* Did the called method return a value? */ + if (ReturnDesc) { + /* Are we actually going to use the return value? */ + if (WalkState->ReturnUsed) { - /* - * Get the return value (if any) from the previous method. - * NULL if no return value - */ + /* Save the return value from the previous method */ + Status = AcpiDsResultPush (ReturnDesc, WalkState); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ReturnDesc); return_ACPI_STATUS (Status); } + + /* + * Save as THIS method's return value in case it is returned + * immediately to yet another method + */ + WalkState->ReturnDesc = ReturnDesc; } else { @@ -544,11 +559,6 @@ AcpiDsRestartControlMethod ( } } - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Method=%p Return=%p ReturnUsed?=%X ResStack=%p State=%p\n", - WalkState->MethodCallOp, ReturnDesc, WalkState->ReturnUsed, - WalkState->Results, WalkState)); - return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/dsmthdat.c b/sys/contrib/dev/acpica/dsmthdat.c index 1498cf556d2c..32f0ca3bb7a9 100644 --- a/sys/contrib/dev/acpica/dsmthdat.c +++ b/sys/contrib/dev/acpica/dsmthdat.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dsmthdat - control method arguments and local variables - * $Revision: 78 $ + * $Revision: 80 $ * ******************************************************************************/ @@ -398,7 +398,7 @@ AcpiDsMethodDataSetValue ( ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "obj %p op %X, ref count = %d [%s]\n", Object, + "NewObj %p Opcode %X, Refs=%d [%s]\n", Object, Opcode, Object->Common.ReferenceCount, AcpiUtGetTypeName (Object->Common.Type))); @@ -540,7 +540,24 @@ AcpiDsMethodDataGetValue ( * was referenced by the method (via the ASL) * before it was initialized. Either case is an error. */ - switch (Opcode) + + /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */ + + if (AcpiGbl_EnableInterpreterSlack) + { + Object = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!Object) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Object->Integer.Value = 0; + Node->Object = Object; + } + + /* Otherwise, return the error */ + + else switch (Opcode) { case AML_ARG_OP: @@ -667,7 +684,7 @@ AcpiDsStoreObjectToLocal ( ACPI_FUNCTION_TRACE ("DsStoreObjectToLocal"); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n", Opcode, Index, ObjDesc)); /* Parameter validation */ diff --git a/sys/contrib/dev/acpica/dsutils.c b/sys/contrib/dev/acpica/dsutils.c index e968e476acb0..f20fb39937bc 100644 --- a/sys/contrib/dev/acpica/dsutils.c +++ b/sys/contrib/dev/acpica/dsutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dsutils - Dispatcher utilities - * $Revision: 102 $ + * $Revision: 107 $ * ******************************************************************************/ @@ -134,11 +134,10 @@ * * FUNCTION: AcpiDsIsResultUsed * - * PARAMETERS: Op - * ResultObj - * WalkState + * PARAMETERS: Op - Current Op + * WalkState - Current State * - * RETURN: Status + * RETURN: TRUE if result is used, FALSE otherwise * * DESCRIPTION: Check if a result object will be used by the parent * @@ -164,19 +163,41 @@ AcpiDsIsResultUsed ( } /* - * If there is no parent, the result can't possibly be used! - * (An executing method typically has no parent, since each - * method is parsed separately) However, a method that is - * invoked from another method has a parent. + * If there is no parent, we are executing at the method level. + * An executing method typically has no parent, since each method + * is parsed separately. */ if (!Op->Common.Parent) { + /* + * If this is the last statement in the method, we know it is not a + * Return() operator (would not come here.) The following code is the + * optional support for a so-called "implicit return". Some AML code + * assumes that the last value of the method is "implicitly" returned + * to the caller. Just save the last result as the return value. + * NOTE: this is optional because the ASL language does not actually + * support this behavior. + */ + if ((AcpiGbl_EnableInterpreterSlack) && + (WalkState->ParserState.Aml >= WalkState->ParserState.AmlEnd)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result of [%s] will be implicitly returned\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode))); + + /* Use the top of the result stack as the implicit return value */ + + WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc[0]; + return_VALUE (TRUE); + } + + /* No parent, the return value cannot possibly be used */ + return_VALUE (FALSE); } - /* - * Get info on the parent. The root Op is AML_SCOPE - */ + /* Get info on the parent. The RootOp is AML_SCOPE */ + ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); if (ParentInfo->Class == AML_CLASS_UNKNOWN) { @@ -285,9 +306,9 @@ ResultNotUsed: * * FUNCTION: AcpiDsDeleteResultIfNotUsed * - * PARAMETERS: Op - * ResultObj - * WalkState + * PARAMETERS: Op - Current parse Op + * ResultObj - Result of the operation + * WalkState - Current state * * RETURN: Status * @@ -400,7 +421,7 @@ AcpiDsClearOperands ( UINT32 i; - ACPI_FUNCTION_TRACE_PTR ("AcpiDsClearOperands", WalkState); + ACPI_FUNCTION_TRACE_PTR ("DsClearOperands", WalkState); /* @@ -426,8 +447,9 @@ AcpiDsClearOperands ( * * FUNCTION: AcpiDsCreateOperand * - * PARAMETERS: WalkState - * Arg + * PARAMETERS: WalkState - Current walk state + * Arg - Parse object for the argument + * ArgIndex - Which argument (zero based) * * RETURN: Status * diff --git a/sys/contrib/dev/acpica/dswexec.c b/sys/contrib/dev/acpica/dswexec.c index 276514c0173d..25e1a633cf9a 100644 --- a/sys/contrib/dev/acpica/dswexec.c +++ b/sys/contrib/dev/acpica/dswexec.c @@ -2,7 +2,7 @@ * * Module Name: dswexec - Dispatcher method execution callbacks; * dispatch to interpreter. - * $Revision: 106 $ + * $Revision: 113 $ * *****************************************************************************/ @@ -134,17 +134,18 @@ * Dispatch table for opcode classes */ static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = { - AcpiExOpcode_1A_0T_0R, - AcpiExOpcode_1A_0T_1R, - AcpiExOpcode_1A_1T_0R, - AcpiExOpcode_1A_1T_1R, - AcpiExOpcode_2A_0T_0R, - AcpiExOpcode_2A_0T_1R, - AcpiExOpcode_2A_1T_1R, - AcpiExOpcode_2A_2T_1R, - AcpiExOpcode_3A_0T_0R, - AcpiExOpcode_3A_1T_1R, - AcpiExOpcode_6A_0T_1R}; + AcpiExOpcode_0A_0T_1R, + AcpiExOpcode_1A_0T_0R, + AcpiExOpcode_1A_0T_1R, + AcpiExOpcode_1A_1T_0R, + AcpiExOpcode_1A_1T_1R, + AcpiExOpcode_2A_0T_0R, + AcpiExOpcode_2A_0T_1R, + AcpiExOpcode_2A_1T_1R, + AcpiExOpcode_2A_2T_1R, + AcpiExOpcode_3A_0T_0R, + AcpiExOpcode_3A_1T_1R, + AcpiExOpcode_6A_0T_1R}; /***************************************************************************** * @@ -514,7 +515,7 @@ AcpiDsExecEndOp ( * routine. There is one routine per opcode "type" based upon the * number of opcode arguments and return type. */ - Status = AcpiGbl_OpTypeDispatch [OpType] (WalkState); + Status = AcpiGbl_OpTypeDispatch[OpType] (WalkState); } else { @@ -527,7 +528,9 @@ AcpiDsExecEndOp ( (WalkState->Operands[0]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && (WalkState->Operands[1]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && (WalkState->Operands[0]->Reference.Opcode == - WalkState->Operands[1]->Reference.Opcode)) + WalkState->Operands[1]->Reference.Opcode) && + (WalkState->Operands[0]->Reference.Offset == + WalkState->Operands[1]->Reference.Offset)) { Status = AE_OK; } @@ -755,7 +758,8 @@ AcpiDsExecEndOp ( * conditional predicate */ - if ((WalkState->ControlState) && + if ((ACPI_SUCCESS (Status)) && + (WalkState->ControlState) && (WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) && (WalkState->ControlState->Control.PredicateOp == Op)) @@ -766,6 +770,20 @@ AcpiDsExecEndOp ( Cleanup: + + /* Invoke exception handler on error */ + + if (ACPI_FAILURE (Status) && + AcpiGbl_ExceptionHandler && + !(Status & AE_CODE_CONTROL)) + { + AcpiExExitInterpreter (); + Status = AcpiGbl_ExceptionHandler (Status, + WalkState->MethodNode->Name.Integer, WalkState->Opcode, + WalkState->AmlOffset, NULL); + AcpiExEnterInterpreter (); + } + if (WalkState->ResultObj) { /* Break to debugger to display result */ diff --git a/sys/contrib/dev/acpica/dswload.c b/sys/contrib/dev/acpica/dswload.c index 950262931cee..e115ee1520bc 100644 --- a/sys/contrib/dev/acpica/dswload.c +++ b/sys/contrib/dev/acpica/dswload.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dswload - Dispatcher namespace load callbacks - * $Revision: 87 $ + * $Revision: 88 $ * *****************************************************************************/ @@ -262,21 +262,22 @@ AcpiDsLoad1BeginOp ( */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); +#ifdef _ACPI_ASL_COMPILER + if (Status == AE_NOT_FOUND) + { + /* + * Table disassembly: + * Target of Scope() not found. Generate an External for it, and + * insert the name into the namespace. + */ + AcpiDmAddToExternalList (Path); + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, + ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); + } +#endif if (ACPI_FAILURE (Status)) { -#ifdef _ACPI_ASL_COMPILER - if (Status == AE_NOT_FOUND) - { - AcpiDmAddToExternalList (Path); - Status = AE_OK; - } - else - { - ACPI_REPORT_NSERROR (Path, Status); - } -#else ACPI_REPORT_NSERROR (Path, Status); -#endif return (Status); } diff --git a/sys/contrib/dev/acpica/dswstate.c b/sys/contrib/dev/acpica/dswstate.c index ac60760d68ed..c6a12a6e6f1f 100644 --- a/sys/contrib/dev/acpica/dswstate.c +++ b/sys/contrib/dev/acpica/dswstate.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dswstate - Dispatcher parse tree walk management routines - * $Revision: 80 $ + * $Revision: 81 $ * *****************************************************************************/ @@ -977,6 +977,7 @@ AcpiDsCreateWalkState ( Status = AcpiDsResultStackPush (WalkState); if (ACPI_FAILURE (Status)) { + AcpiUtReleaseToCache (ACPI_MEM_LIST_WALK, WalkState); return_PTR (NULL); } diff --git a/sys/contrib/dev/acpica/evgpe.c b/sys/contrib/dev/acpica/evgpe.c index f191d4473d64..31a9585db1ee 100644 --- a/sys/contrib/dev/acpica/evgpe.c +++ b/sys/contrib/dev/acpica/evgpe.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evgpe - General Purpose Event handling and dispatch - * $Revision: 42 $ + * $Revision: 44 $ * *****************************************************************************/ @@ -176,6 +176,8 @@ AcpiEvSetGpeType ( * FUNCTION: AcpiEvUpdateGpeEnableMasks * * PARAMETERS: GpeEventInfo - GPE to update + * Type - What to do: ACPI_GPE_DISABLE or + * ACPI_GPE_ENABLE * * RETURN: Status * @@ -243,6 +245,8 @@ AcpiEvUpdateGpeEnableMasks ( * FUNCTION: AcpiEvEnableGpe * * PARAMETERS: GpeEventInfo - GPE to enable + * WriteToHardware - Enable now, or just mark data structs + * (WAKE GPEs should be deferred) * * RETURN: Status * @@ -525,13 +529,8 @@ AcpiEvGpeDetect ( } ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, - "GPE pair: Status %8.8X%8.8X = %02X, Enable %8.8X%8.8X = %02X\n", - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS ( - GpeRegisterInfo->StatusAddress.Address)), - StatusReg, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS ( - GpeRegisterInfo->EnableAddress.Address)), - EnableReg)); + "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", + GpeRegisterInfo->BaseGpeNumber, StatusReg, EnableReg)); /* First check if there is anything active at all in this register */ @@ -822,7 +821,7 @@ AcpiEvGpeDispatch ( #ifdef ACPI_GPE_NOTIFY_CHECK /******************************************************************************* - * NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED + * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED * * FUNCTION: AcpiEvCheckForWakeOnlyGpe * diff --git a/sys/contrib/dev/acpica/evgpeblk.c b/sys/contrib/dev/acpica/evgpeblk.c index cc8d38002b3c..20cf898320b5 100644 --- a/sys/contrib/dev/acpica/evgpeblk.c +++ b/sys/contrib/dev/acpica/evgpeblk.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evgpeblk - GPE block creation and initialization. - * $Revision: 36 $ + * $Revision: 39 $ * *****************************************************************************/ @@ -181,17 +181,18 @@ AcpiEvValidGpeEvent ( * FUNCTION: AcpiEvWalkGpeList * * PARAMETERS: GpeWalkCallback - Routine called for each GPE block + * Flags - ACPI_NOT_ISR or ACPI_ISR * * RETURN: Status * * DESCRIPTION: Walk the GPE lists. - * FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED * ******************************************************************************/ ACPI_STATUS AcpiEvWalkGpeList ( - ACPI_GPE_CALLBACK GpeWalkCallback) + ACPI_GPE_CALLBACK GpeWalkCallback, + UINT32 Flags) { ACPI_GPE_BLOCK_INFO *GpeBlock; ACPI_GPE_XRUPT_INFO *GpeXruptInfo; @@ -201,7 +202,7 @@ AcpiEvWalkGpeList ( ACPI_FUNCTION_TRACE ("EvWalkGpeList"); - AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_ISR); + AcpiOsAcquireLock (AcpiGbl_GpeLock, Flags); /* Walk the interrupt level descriptor list */ @@ -228,7 +229,7 @@ AcpiEvWalkGpeList ( } UnlockAndExit: - AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_ISR); + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); return_ACPI_STATUS (Status); } @@ -413,7 +414,8 @@ AcpiEvSaveMethodInfo ( * * PARAMETERS: Callback from WalkNamespace * - * RETURN: Status + * RETURN: Status. NOTE: We ignore errors so that the _PRW walk is + * not aborted on a single _PRW failure. * * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a * Device. Run the _PRW method. If present, extract the GPE @@ -1102,16 +1104,14 @@ AcpiEvCreateGpeBlock ( /* Dump info about this GPE block */ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, - "GPE %02X to %02X [%4.4s] %u regs at %8.8X%8.8X on int 0x%X\n", + "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", (UINT32) GpeBlock->BlockBaseNumber, (UINT32) (GpeBlock->BlockBaseNumber + ((GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH) -1)), GpeDevice->Name.Ascii, GpeBlock->RegisterCount, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->BlockAddress.Address)), InterruptLevel)); - /* Enable all valid GPEs found above */ Status = AcpiHwEnableRuntimeGpeBlock (NULL, GpeBlock); diff --git a/sys/contrib/dev/acpica/evmisc.c b/sys/contrib/dev/acpica/evmisc.c index 8a39fbe4f1e8..4770ba9d4737 100644 --- a/sys/contrib/dev/acpica/evmisc.c +++ b/sys/contrib/dev/acpica/evmisc.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evmisc - Miscellaneous event manager support functions - * $Revision: 75 $ + * $Revision: 79 $ * *****************************************************************************/ @@ -162,9 +162,10 @@ AcpiEvIsNotifyObject ( * * FUNCTION: AcpiEvQueueNotifyRequest * - * PARAMETERS: + * PARAMETERS: Node - NS node for the notified object + * NotifyValue - Value from the Notify() request * - * RETURN: None. + * RETURN: Status * * DESCRIPTION: Dispatch a device notification event to a previously * installed handler. @@ -219,9 +220,8 @@ AcpiEvQueueNotifyRequest ( NotifyValue)); } - /* - * Get the notify object attached to the NS Node - */ + /* Get the notify object attached to the NS Node */ + ObjDesc = AcpiNsGetAttachedObject (Node); if (ObjDesc) { @@ -277,8 +277,10 @@ AcpiEvQueueNotifyRequest ( if (!HandlerObj) { - /* There is no per-device notify handler for this device */ - + /* + * There is no per-device notify handler for this device. + * This may or may not be a problem. + */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "No notify handler for Notify(%4.4s, %X) node %p\n", AcpiUtGetNodeName (Node), NotifyValue, Node)); @@ -292,7 +294,7 @@ AcpiEvQueueNotifyRequest ( * * FUNCTION: AcpiEvNotifyDispatch * - * PARAMETERS: + * PARAMETERS: Context - To be passsed to the notify handler * * RETURN: None. * @@ -365,6 +367,8 @@ AcpiEvNotifyDispatch ( * * FUNCTION: AcpiEvGlobalLockThread * + * PARAMETERS: Context - From thread interface, not used + * * RETURN: None * * DESCRIPTION: Invoked by SCI interrupt handler upon acquisition of the @@ -400,7 +404,9 @@ AcpiEvGlobalLockThread ( * * FUNCTION: AcpiEvGlobalLockHandler * - * RETURN: Status + * PARAMETERS: Context - From thread interface, not used + * + * RETURN: ACPI_INTERRUPT_HANDLED or ACPI_INTERRUPT_NOT_HANDLED * * DESCRIPTION: Invoked directly from the SCI handler when a global lock * release interrupt occurs. Grab the global lock and queue @@ -449,6 +455,8 @@ AcpiEvGlobalLockHandler ( * * FUNCTION: AcpiEvInitGlobalLockHandler * + * PARAMETERS: None + * * RETURN: Status * * DESCRIPTION: Install a handler for the global lock release event @@ -489,6 +497,8 @@ AcpiEvInitGlobalLockHandler (void) * * FUNCTION: AcpiEvAcquireGlobalLock * + * PARAMETERS: Timeout - Max time to wait for the lock, in millisec. + * * RETURN: Status * * DESCRIPTION: Attempt to gain ownership of the Global Lock. @@ -559,6 +569,10 @@ AcpiEvAcquireGlobalLock ( * * FUNCTION: AcpiEvReleaseGlobalLock * + * PARAMETERS: None + * + * RETURN: Status + * * DESCRIPTION: Releases ownership of the Global Lock. * ******************************************************************************/ @@ -651,7 +665,7 @@ AcpiEvTerminate (void) /* Disable all GPEs in all GPE blocks */ - Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, ACPI_NOT_ISR); /* Remove SCI handler */ @@ -664,7 +678,7 @@ AcpiEvTerminate (void) /* Deallocate all handler objects installed within GPE info structs */ - Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers); + Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers, ACPI_NOT_ISR); /* Return to original mode if necessary */ diff --git a/sys/contrib/dev/acpica/evregion.c b/sys/contrib/dev/acpica/evregion.c index 55f57aa7aba2..962abb118c7c 100644 --- a/sys/contrib/dev/acpica/evregion.c +++ b/sys/contrib/dev/acpica/evregion.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch - * $Revision: 151 $ + * $Revision: 152 $ * *****************************************************************************/ @@ -261,7 +261,7 @@ AcpiEvInitializeOpRegions ( * FUNCTION: AcpiEvExecuteRegMethod * * PARAMETERS: RegionObj - Object structure - * Function - On (1) or Off (0) + * Function - Passed to _REG: On (1) or Off (0) * * RETURN: Status * @@ -317,7 +317,7 @@ AcpiEvExecuteRegMethod ( goto Cleanup; } - /* Set up the parameter objects */ + /* Setup the parameter objects */ Params[0]->Integer.Value = RegionObj->Region.SpaceId; Params[1]->Integer.Value = Function; @@ -347,7 +347,6 @@ Cleanup: * FUNCTION: AcpiEvAddressSpaceDispatch * * PARAMETERS: RegionObj - Internal region object - * SpaceId - ID of the address space (0-255) * Function - Read or Write operation * Address - Where in the space to read or write * BitWidth - Field width in bits (8, 16, 32, or 64) @@ -523,8 +522,8 @@ AcpiEvAddressSpaceDispatch ( * * FUNCTION: AcpiEvDetachRegion * - * PARAMETERS: RegionObj - Region Object - * AcpiNsIsLocked - Namespace Region Already Locked? + * PARAMETERS: RegionObj - Region Object + * AcpiNsIsLocked - Namespace Region Already Locked? * * RETURN: None * @@ -668,9 +667,9 @@ AcpiEvDetachRegion( * * FUNCTION: AcpiEvAttachRegion * - * PARAMETERS: HandlerObj - Handler Object - * RegionObj - Region Object - * AcpiNsIsLocked - Namespace Region Already Locked? + * PARAMETERS: HandlerObj - Handler Object + * RegionObj - Region Object + * AcpiNsIsLocked - Namespace Region Already Locked? * * RETURN: None * @@ -1103,7 +1102,7 @@ UnlockAndExit: * * RETURN: Status * - * DESCRIPTION: Run _REG methods for the Space ID; + * DESCRIPTION: Run all _REG methods for the input Space ID; * Note: assumes namespace is locked, or system init time. * ******************************************************************************/ diff --git a/sys/contrib/dev/acpica/evrgnini.c b/sys/contrib/dev/acpica/evrgnini.c index 45b05c5575af..f5db1acdd0d9 100644 --- a/sys/contrib/dev/acpica/evrgnini.c +++ b/sys/contrib/dev/acpica/evrgnini.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evrgnini- ACPI AddressSpace (OpRegion) init - * $Revision: 73 $ + * $Revision: 74 $ * *****************************************************************************/ @@ -129,7 +129,7 @@ * * FUNCTION: AcpiEvSystemMemoryRegionSetup * - * PARAMETERS: RegionObj - Region we are interested in + * PARAMETERS: Handle - Region we are interested in * Function - Start or stop * HandlerContext - Address space handler context * RegionContext - Region specific context @@ -186,7 +186,7 @@ AcpiEvSystemMemoryRegionSetup ( * * FUNCTION: AcpiEvIoSpaceRegionSetup * - * PARAMETERS: RegionObj - Region we are interested in + * PARAMETERS: Handle - Region we are interested in * Function - Start or stop * HandlerContext - Address space handler context * RegionContext - Region specific context @@ -224,7 +224,7 @@ AcpiEvIoSpaceRegionSetup ( * * FUNCTION: AcpiEvPciConfigRegionSetup * - * PARAMETERS: RegionObj - Region we are interested in + * PARAMETERS: Handle - Region we are interested in * Function - Start or stop * HandlerContext - Address space handler context * RegionContext - Region specific context @@ -413,7 +413,7 @@ AcpiEvPciConfigRegionSetup ( * * FUNCTION: AcpiEvPciBarRegionSetup * - * PARAMETERS: RegionObj - Region we are interested in + * PARAMETERS: Handle - Region we are interested in * Function - Start or stop * HandlerContext - Address space handler context * RegionContext - Region specific context @@ -444,7 +444,7 @@ AcpiEvPciBarRegionSetup ( * * FUNCTION: AcpiEvCmosRegionSetup * - * PARAMETERS: RegionObj - Region we are interested in + * PARAMETERS: Handle - Region we are interested in * Function - Start or stop * HandlerContext - Address space handler context * RegionContext - Region specific context @@ -475,7 +475,7 @@ AcpiEvCmosRegionSetup ( * * FUNCTION: AcpiEvDefaultRegionSetup * - * PARAMETERS: RegionObj - Region we are interested in + * PARAMETERS: Handle - Region we are interested in * Function - Start or stop * HandlerContext - Address space handler context * RegionContext - Region specific context diff --git a/sys/contrib/dev/acpica/evxface.c b/sys/contrib/dev/acpica/evxface.c index 8dba99b45f36..949787973c1a 100644 --- a/sys/contrib/dev/acpica/evxface.c +++ b/sys/contrib/dev/acpica/evxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evxface - External interfaces for ACPI events - * $Revision: 145 $ + * $Revision: 147 $ * *****************************************************************************/ @@ -128,6 +128,53 @@ /******************************************************************************* * + * FUNCTION: AcpiInstallExceptionHandler + * + * PARAMETERS: Handler - Pointer to the handler function for the + * event + * + * RETURN: Status + * + * DESCRIPTION: Saves the pointer to the handler function + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallExceptionHandler ( + ACPI_EXCEPTION_HANDLER Handler) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("AcpiInstallExceptionHandler"); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Don't allow two handlers. */ + + if (AcpiGbl_ExceptionHandler) + { + Status = AE_ALREADY_EXISTS; + goto Cleanup; + } + + /* Install the handler */ + + AcpiGbl_ExceptionHandler = Handler; + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * * FUNCTION: AcpiInstallFixedEventHandler * * PARAMETERS: Event - Event type to enable. @@ -461,6 +508,7 @@ UnlockAndExit: * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) * ACPI_ALL_NOTIFY: both system and device * Handler - Address of the handler + * * RETURN: Status * * DESCRIPTION: Remove a handler for notifies on an ACPI device @@ -506,9 +554,8 @@ AcpiRemoveNotifyHandler ( goto UnlockAndExit; } - /* - * Root Object - */ + /* Root Object */ + if (Device == ACPI_ROOT_OBJECT) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing notify handler for ROOT object.\n")); @@ -537,9 +584,8 @@ AcpiRemoveNotifyHandler ( } } - /* - * All Other Objects - */ + /* All Other Objects */ + else { /* Notifies allowed on this object? */ diff --git a/sys/contrib/dev/acpica/exconfig.c b/sys/contrib/dev/acpica/exconfig.c index 4686b4a263d5..9ec9f4d04477 100644 --- a/sys/contrib/dev/acpica/exconfig.c +++ b/sys/contrib/dev/acpica/exconfig.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes) - * $Revision: 78 $ + * $Revision: 79 $ * *****************************************************************************/ @@ -171,7 +171,7 @@ AcpiExAddTable ( ACPI_MEMSET (&TableInfo, 0, sizeof (ACPI_TABLE_DESC)); - TableInfo.Type = 5; + TableInfo.Type = ACPI_TABLE_SSDT; TableInfo.Pointer = Table; TableInfo.Length = (ACPI_SIZE) Table->Length; TableInfo.Allocation = ACPI_MEM_ALLOCATED; diff --git a/sys/contrib/dev/acpica/exconvrt.c b/sys/contrib/dev/acpica/exconvrt.c index 42ca183d2fd2..fd3854a556c3 100644 --- a/sys/contrib/dev/acpica/exconvrt.c +++ b/sys/contrib/dev/acpica/exconvrt.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exconvrt - Object conversion routines - * $Revision: 53 $ + * $Revision: 59 $ * *****************************************************************************/ @@ -133,7 +133,7 @@ * PARAMETERS: ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String * ResultDesc - Where the new Integer object is returned - * WalkState - Current method state + * Flags - Used for string conversion * * RETURN: Status * @@ -145,13 +145,13 @@ ACPI_STATUS AcpiExConvertToInteger ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, - ACPI_WALK_STATE *WalkState) + UINT32 Flags) { - UINT32 i; - ACPI_OPERAND_OBJECT *RetDesc; - UINT32 Count; + ACPI_OPERAND_OBJECT *ReturnDesc; UINT8 *Pointer; ACPI_INTEGER Result; + UINT32 i; + UINT32 Count; ACPI_STATUS Status; @@ -161,15 +161,17 @@ AcpiExConvertToInteger ( switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_INTEGER: + + /* No conversion necessary */ + *ResultDesc = ObjDesc; return_ACPI_STATUS (AE_OK); + case ACPI_TYPE_BUFFER: case ACPI_TYPE_STRING: - Pointer = (UINT8 *) ObjDesc->String.Pointer; - Count = ObjDesc->String.Length; - break; - case ACPI_TYPE_BUFFER: + /* Note: Takes advantage of common buffer/string fields */ + Pointer = ObjDesc->Buffer.Pointer; Count = ObjDesc->Buffer.Length; break; @@ -189,13 +191,6 @@ AcpiExConvertToInteger ( */ Result = 0; - /* Transfer no more than an integer's worth of data */ - - if (Count > AcpiGbl_IntegerByteWidth) - { - Count = AcpiGbl_IntegerByteWidth; - } - /* * String conversion is different than Buffer conversion */ @@ -204,10 +199,12 @@ AcpiExConvertToInteger ( case ACPI_TYPE_STRING: /* - * Convert string to an integer - * String must be hexadecimal as per the ACPI specification + * Convert string to an integer - for most cases, the string must be + * hexadecimal as per the ACPI specification. The only exception (as + * of ACPI 3.0) is that the ToInteger() operator allows both decimal + * and hexadecimal strings (hex prefixed with "0x"). */ - Status = AcpiUtStrtoul64 ((char *) Pointer, 16, &Result); + Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, &Result); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -217,9 +214,16 @@ AcpiExConvertToInteger ( case ACPI_TYPE_BUFFER: + /* Transfer no more than an integer's worth of data */ + + if (Count > AcpiGbl_IntegerByteWidth) + { + Count = AcpiGbl_IntegerByteWidth; + } + /* - * Buffer conversion - we simply grab enough raw data from the - * buffer to fill an integer + * Convert buffer to an integer - we simply grab enough raw data + * from the buffer to fill an integer */ for (i = 0; i < Count; i++) { @@ -241,30 +245,17 @@ AcpiExConvertToInteger ( /* * Create a new integer */ - RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); - if (!RetDesc) + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Save the Result */ - RetDesc->Integer.Value = Result; - - /* - * If we are about to overwrite the original object on the operand stack, - * we must remove a reference on the original object because we are - * essentially removing it from the stack. - */ - if (*ResultDesc == ObjDesc) - { - if (WalkState->Opcode != AML_STORE_OP) - { - AcpiUtRemoveReference (ObjDesc); - } - } - - *ResultDesc = RetDesc; + ReturnDesc->Integer.Value = Result; + AcpiExTruncateFor32bitTable (ReturnDesc); + *ResultDesc = ReturnDesc; return_ACPI_STATUS (AE_OK); } @@ -276,7 +267,6 @@ AcpiExConvertToInteger ( * PARAMETERS: ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String * ResultDesc - Where the new buffer object is returned - * WalkState - Current method state * * RETURN: Status * @@ -287,11 +277,9 @@ AcpiExConvertToInteger ( ACPI_STATUS AcpiExConvertToBuffer ( ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT **ResultDesc, - ACPI_WALK_STATE *WalkState) + ACPI_OPERAND_OBJECT **ResultDesc) { - ACPI_OPERAND_OBJECT *RetDesc; - UINT32 i; + ACPI_OPERAND_OBJECT *ReturnDesc; UINT8 *NewBuf; @@ -314,19 +302,18 @@ AcpiExConvertToBuffer ( * Create a new Buffer object. * Need enough space for one integer */ - RetDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth); - if (!RetDesc) + ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth); + if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - /* Copy the integer to the buffer */ + /* Copy the integer to the buffer, LSB first */ - NewBuf = RetDesc->Buffer.Pointer; - for (i = 0; i < AcpiGbl_IntegerByteWidth; i++) - { - NewBuf[i] = (UINT8) (ObjDesc->Integer.Value >> (i * 8)); - } + NewBuf = ReturnDesc->Buffer.Pointer; + ACPI_MEMCPY (NewBuf, + &ObjDesc->Integer.Value, + AcpiGbl_IntegerByteWidth); break; @@ -336,15 +323,15 @@ AcpiExConvertToBuffer ( * Create a new Buffer object * Size will be the string length */ - RetDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) ObjDesc->String.Length); - if (!RetDesc) + ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) ObjDesc->String.Length); + if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Copy the string to the buffer */ - NewBuf = RetDesc->Buffer.Pointer; + NewBuf = ReturnDesc->Buffer.Pointer; ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer, ObjDesc->String.Length); break; @@ -356,34 +343,20 @@ AcpiExConvertToBuffer ( /* Mark buffer initialized */ - RetDesc->Common.Flags |= AOPOBJ_DATA_VALID; - - /* - * If we are about to overwrite the original object on the operand stack, - * we must remove a reference on the original object because we are - * essentially removing it from the stack. - */ - if (*ResultDesc == ObjDesc) - { - if (WalkState->Opcode != AML_STORE_OP) - { - AcpiUtRemoveReference (ObjDesc); - } - } - - *ResultDesc = RetDesc; + ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID; + *ResultDesc = ReturnDesc; return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiExConvertAscii + * FUNCTION: AcpiExConvertToAscii * * PARAMETERS: Integer - Value to be converted - * Base - 10 or 16 + * Base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX * String - Where the string is returned - * DataWidth - Size of data item to be converted + * DataWidth - Size of data item to be converted, in bytes * * RETURN: Actual string length * @@ -394,57 +367,66 @@ AcpiExConvertToBuffer ( UINT32 AcpiExConvertToAscii ( ACPI_INTEGER Integer, - UINT32 Base, + UINT16 Base, UINT8 *String, UINT8 DataWidth) { - UINT32 i; - UINT32 j; - UINT32 k = 0; - char HexDigit; ACPI_INTEGER Digit; + ACPI_NATIVE_UINT i; + ACPI_NATIVE_UINT j; + ACPI_NATIVE_UINT k = 0; + ACPI_NATIVE_UINT HexLength; + ACPI_NATIVE_UINT DecimalLength; UINT32 Remainder; - UINT32 Length; - BOOLEAN LeadingZero; + BOOLEAN SupressZeros; ACPI_FUNCTION_ENTRY (); - if (DataWidth < sizeof (ACPI_INTEGER)) - { - LeadingZero = FALSE; - Length = DataWidth; - } - else - { - LeadingZero = TRUE; - Length = sizeof (ACPI_INTEGER); - } - switch (Base) { case 10: + /* Setup max length for the decimal number */ + + switch (DataWidth) + { + case 1: + DecimalLength = ACPI_MAX8_DECIMAL_DIGITS; + break; + + case 4: + DecimalLength = ACPI_MAX32_DECIMAL_DIGITS; + break; + + case 8: + default: + DecimalLength = ACPI_MAX64_DECIMAL_DIGITS; + break; + } + + SupressZeros = TRUE; /* No leading zeros */ Remainder = 0; - for (i = ACPI_MAX_DECIMAL_DIGITS; i > 0; i--) + + for (i = DecimalLength; i > 0; i--) { /* Divide by nth factor of 10 */ Digit = Integer; for (j = 0; j < i; j++) { - (void) AcpiUtShortDivide (&Digit, 10, &Digit, &Remainder); + (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder); } - /* Create the decimal digit */ + /* Handle leading zeros */ if (Remainder != 0) { - LeadingZero = FALSE; + SupressZeros = FALSE; } - if (!LeadingZero) + if (!SupressZeros) { String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder); k++; @@ -452,31 +434,21 @@ AcpiExConvertToAscii ( } break; - case 16: - /* Copy the integer to the buffer */ + HexLength = ACPI_MUL_2 (DataWidth); /* 2 ascii hex chars per data byte */ - for (i = 0, j = ((Length * 2) -1); i < (Length * 2); i++, j--) + for (i = 0, j = (HexLength-1); i < HexLength; i++, j--) { + /* Get one hex digit, most significant digits first */ - HexDigit = AcpiUtHexToAsciiChar (Integer, (j * 4)); - if (HexDigit != ACPI_ASCII_ZERO) - { - LeadingZero = FALSE; - } - - if (!LeadingZero) - { - String[k] = (UINT8) HexDigit; - k++; - } + String[k] = (UINT8) AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j)); + k++; } break; - default: - break; + return (0); } /* @@ -492,7 +464,7 @@ AcpiExConvertToAscii ( } String [k] = 0; - return (k); + return ((UINT32) k); } @@ -501,11 +473,9 @@ AcpiExConvertToAscii ( * FUNCTION: AcpiExConvertToString * * PARAMETERS: ObjDesc - Object to be converted. Must be an - * Integer, Buffer, or String + * Integer, Buffer, or String * ResultDesc - Where the string object is returned - * Base - 10 or 16 - * MaxLength - Max length of the returned string - * WalkState - Current method state + * Type - String flags (base and conversion type) * * RETURN: Status * @@ -517,15 +487,14 @@ ACPI_STATUS AcpiExConvertToString ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, - UINT32 Base, - UINT32 MaxLength, - ACPI_WALK_STATE *WalkState) + UINT32 Type) { - ACPI_OPERAND_OBJECT *RetDesc; + ACPI_OPERAND_OBJECT *ReturnDesc; UINT8 *NewBuf; - UINT8 *Pointer; - UINT32 StringLength; + UINT32 StringLength = 0; + UINT16 Base = 16; UINT32 i; + UINT8 Separator = ','; ACPI_FUNCTION_TRACE_PTR ("ExConvertToString", ObjDesc); @@ -535,146 +504,137 @@ AcpiExConvertToString ( { case ACPI_TYPE_STRING: - if (MaxLength >= ObjDesc->String.Length) - { - *ResultDesc = ObjDesc; - return_ACPI_STATUS (AE_OK); - } - else - { - /* Must copy the string first and then truncate it */ + /* No conversion necessary */ - return_ACPI_STATUS (AE_NOT_IMPLEMENTED); - } + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); case ACPI_TYPE_INTEGER: - StringLength = AcpiGbl_IntegerByteWidth * 2; - if (Base == 10) + switch (Type) { + case ACPI_EXPLICIT_CONVERT_DECIMAL: + + /* Make room for maximum decimal number */ + StringLength = ACPI_MAX_DECIMAL_DIGITS; + Base = 10; + break; + + default: + + /* Two hex string characters for each integer byte */ + + StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth); + break; } /* * Create a new String + * Need enough space for one ASCII integer (plus null terminator) */ - RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); - if (!RetDesc) + ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength); + if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - /* Need enough space for one ASCII integer plus null terminator */ - - NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1); - if (!NewBuf) - { - ACPI_REPORT_ERROR - (("ExConvertToString: Buffer allocation failure\n")); - AcpiUtRemoveReference (RetDesc); - return_ACPI_STATUS (AE_NO_MEMORY); - } + NewBuf = ReturnDesc->Buffer.Pointer; - /* Convert */ + /* Convert integer to string */ - i = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, NewBuf, sizeof (ACPI_INTEGER)); + StringLength = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, + NewBuf, AcpiGbl_IntegerByteWidth); /* Null terminate at the correct place */ - if (MaxLength < i) - { - NewBuf[MaxLength] = 0; - RetDesc->String.Length = MaxLength; - } - else - { - NewBuf [i] = 0; - RetDesc->String.Length = i; - } - - RetDesc->Buffer.Pointer = NewBuf; + ReturnDesc->String.Length = StringLength; + NewBuf [StringLength] = 0; break; case ACPI_TYPE_BUFFER: - /* Find the string length */ - - Pointer = ObjDesc->Buffer.Pointer; - for (StringLength = 0; StringLength < ObjDesc->Buffer.Length; StringLength++) + switch (Type) { - /* Exit on null terminator */ + case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString operator */ + /* + * From ACPI: "If Data is a buffer, it is converted to a string of + * decimal values separated by commas." + */ + Base = 10; + StringLength = ObjDesc->Buffer.Length; /* 4 chars for each decimal */ - if (!Pointer[StringLength]) + /*lint -fallthrough */ + + case ACPI_IMPLICIT_CONVERT_HEX: + /* + * From the ACPI spec: + *"The entire contents of the buffer are converted to a string of + * two-character hexadecimal numbers, each separated by a space." + */ + if (Type == ACPI_IMPLICIT_CONVERT_HEX) { - break; + Separator = ' '; } - } - if (MaxLength > ACPI_MAX_STRING_CONVERSION) - { - if (StringLength > ACPI_MAX_STRING_CONVERSION) + /*lint -fallthrough */ + + case ACPI_EXPLICIT_CONVERT_HEX: /* Used by ToHexString operator */ + /* + * From ACPI: "If Data is a buffer, it is converted to a string of + * hexadecimal values separated by commas." + */ + StringLength += (ObjDesc->Buffer.Length * 3); + if (StringLength > ACPI_MAX_STRING_CONVERSION) /* ACPI limit */ { return_ACPI_STATUS (AE_AML_STRING_LIMIT); } - } - /* - * Create a new string object - */ - RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); - if (!RetDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } + /* Create a new string object and string buffer */ - /* String length is the lesser of the Max or the actual length */ + ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength -1); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } - if (MaxLength < StringLength) - { - StringLength = MaxLength; - } + NewBuf = ReturnDesc->Buffer.Pointer; - NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1); - if (!NewBuf) - { - ACPI_REPORT_ERROR - (("ExConvertToString: Buffer allocation failure\n")); - AcpiUtRemoveReference (RetDesc); - return_ACPI_STATUS (AE_NO_MEMORY); - } + /* + * Convert buffer bytes to hex or decimal values + * (separated by commas) + */ + for (i = 0; i < ObjDesc->Buffer.Length; i++) + { + NewBuf += AcpiExConvertToAscii ( + (ACPI_INTEGER) ObjDesc->Buffer.Pointer[i], Base, + NewBuf, 1); + *NewBuf++ = Separator; /* each separated by a comma or space */ + } - /* Copy the appropriate number of buffer characters */ + /* Null terminate the string (overwrites final comma from above) */ - ACPI_MEMCPY (NewBuf, Pointer, StringLength); + NewBuf--; + *NewBuf = 0; - /* Null terminate */ + /* Recalculate length */ - NewBuf [StringLength] = 0; - RetDesc->Buffer.Pointer = NewBuf; - RetDesc->String.Length = StringLength; - break; + ReturnDesc->String.Length = (UINT32) + ACPI_STRLEN (ReturnDesc->String.Pointer); + break; + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + break; default: return_ACPI_STATUS (AE_TYPE); } - /* - * If we are about to overwrite the original object on the operand stack, - * we must remove a reference on the original object because we are - * essentially removing it from the stack. - */ - if (*ResultDesc == ObjDesc) - { - if (WalkState->Opcode != AML_STORE_OP) - { - AcpiUtRemoveReference (ObjDesc); - } - } - - *ResultDesc = RetDesc; + *ResultDesc = ReturnDesc; return_ACPI_STATUS (AE_OK); } @@ -756,7 +716,8 @@ AcpiExConvertToTargetType ( * These types require an Integer operand. We can convert * a Buffer or a String to an Integer if necessary. */ - Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, WalkState); + Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, + 16); break; @@ -766,7 +727,8 @@ AcpiExConvertToTargetType ( * The operand must be a String. We can convert an * Integer or Buffer if necessary */ - Status = AcpiExConvertToString (SourceDesc, ResultDesc, 16, ACPI_UINT32_MAX, WalkState); + Status = AcpiExConvertToString (SourceDesc, ResultDesc, + ACPI_IMPLICIT_CONVERT_HEX); break; @@ -776,7 +738,7 @@ AcpiExConvertToTargetType ( * The operand must be a Buffer. We can convert an * Integer or String if necessary */ - Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc, WalkState); + Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc); break; diff --git a/sys/contrib/dev/acpica/exdump.c b/sys/contrib/dev/acpica/exdump.c index 300433d02d46..07e939922bbc 100644 --- a/sys/contrib/dev/acpica/exdump.c +++ b/sys/contrib/dev/acpica/exdump.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exdump - Interpreter debug output routines - * $Revision: 173 $ + * $Revision: 176 $ * *****************************************************************************/ @@ -129,7 +129,6 @@ /* * The following routines are used for debug output only */ - #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /***************************************************************************** @@ -138,7 +137,7 @@ * * PARAMETERS: *ObjDesc - Pointer to entry to be dumped * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Dump an operand object * @@ -146,12 +145,11 @@ void AcpiExDumpOperand ( - ACPI_OPERAND_OBJECT *ObjDesc) + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Depth) { - UINT8 *Buf = NULL; UINT32 Length; - ACPI_OPERAND_OBJECT **Element; - UINT16 ElementIndex; + UINT32 Index; ACPI_FUNCTION_NAME ("ExDumpOperand") @@ -165,9 +163,9 @@ AcpiExDumpOperand ( if (!ObjDesc) { /* - * This usually indicates that something serious is wrong + * This could be a null element of a package */ - AcpiOsPrintf ("Null Object Descriptor\n"); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); return; } @@ -181,15 +179,24 @@ AcpiExDumpOperand ( if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "%p is not a node or operand object: [%s]\n", - ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); + "%p is not a node or operand object: [%s]\n", + ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)); return; } /* ObjDesc is a valid object */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc)); + if (Depth > 0) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ", + Depth, " ", Depth, ObjDesc)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc)); + } + switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { @@ -205,8 +212,8 @@ AcpiExDumpOperand ( case AML_NAME_OP: - ACPI_DUMP_PATHNAME (ObjDesc->Reference.Object, "Reference: Name: ", - ACPI_LV_INFO, _COMPONENT); + ACPI_DUMP_PATHNAME (ObjDesc->Reference.Object, + "Reference: Name: ", ACPI_LV_INFO, _COMPONENT); ACPI_DUMP_ENTRY (ObjDesc->Reference.Object, ACPI_LV_INFO); break; @@ -214,28 +221,28 @@ AcpiExDumpOperand ( case AML_INDEX_OP: AcpiOsPrintf ("Reference: Index %p\n", - ObjDesc->Reference.Object); + ObjDesc->Reference.Object); break; case AML_REF_OF_OP: AcpiOsPrintf ("Reference: (RefOf) %p\n", - ObjDesc->Reference.Object); + ObjDesc->Reference.Object); break; case AML_ARG_OP: AcpiOsPrintf ("Reference: Arg%d", - ObjDesc->Reference.Offset); + ObjDesc->Reference.Offset); if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { /* Value is an Integer */ AcpiOsPrintf (" value is [%8.8X%8.8x]", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); } AcpiOsPrintf ("\n"); @@ -245,7 +252,7 @@ AcpiExDumpOperand ( case AML_LOCAL_OP: AcpiOsPrintf ("Reference: Local%d", - ObjDesc->Reference.Offset); + ObjDesc->Reference.Offset); if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { @@ -253,7 +260,7 @@ AcpiExDumpOperand ( /* Value is an Integer */ AcpiOsPrintf (" value is [%8.8X%8.8x]", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); } AcpiOsPrintf ("\n"); @@ -263,7 +270,7 @@ AcpiExDumpOperand ( case AML_INT_NAMEPATH_OP: AcpiOsPrintf ("Reference.Node->Name %X\n", - ObjDesc->Reference.Node->Name.Integer); + ObjDesc->Reference.Node->Name.Integer); break; @@ -276,18 +283,15 @@ AcpiExDumpOperand ( break; } - break; case ACPI_TYPE_BUFFER: AcpiOsPrintf ("Buffer len %X @ %p \n", - ObjDesc->Buffer.Length, - ObjDesc->Buffer.Pointer); + ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer); Length = ObjDesc->Buffer.Length; - if (Length > 64) { Length = 64; @@ -299,44 +303,40 @@ AcpiExDumpOperand ( { AcpiOsPrintf ("Buffer Contents: "); - for (Buf = ObjDesc->Buffer.Pointer; Length--; ++Buf) + for (Index = 0; Index < Length; Index++) { - AcpiOsPrintf (" %02x", *Buf); + AcpiOsPrintf (" %02x", ObjDesc->Buffer.Pointer[Index]); } AcpiOsPrintf ("\n"); } - break; case ACPI_TYPE_INTEGER: AcpiOsPrintf ("Integer %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); break; case ACPI_TYPE_PACKAGE: - AcpiOsPrintf ("Package count %X @ %p\n", - ObjDesc->Package.Count, ObjDesc->Package.Elements); + AcpiOsPrintf ("Package [Len %X] ElementArray %p\n", + ObjDesc->Package.Count, ObjDesc->Package.Elements); /* - * If elements exist, package vector pointer is valid, + * If elements exist, package element pointer is valid, * and debug_level exceeds 1, dump package's elements. */ if (ObjDesc->Package.Count && ObjDesc->Package.Elements && AcpiDbgLevel > 1) { - for (ElementIndex = 0, Element = ObjDesc->Package.Elements; - ElementIndex < ObjDesc->Package.Count; - ++ElementIndex, ++Element) + for (Index = 0; Index < ObjDesc->Package.Count; Index++) { - AcpiExDumpOperand (*Element); + AcpiExDumpOperand (ObjDesc->Package.Elements[Index], Depth+1); } } - AcpiOsPrintf ("\n"); break; @@ -366,7 +366,7 @@ AcpiExDumpOperand ( case ACPI_TYPE_STRING: AcpiOsPrintf ("String length %X @ %p ", - ObjDesc->String.Length, ObjDesc->String.Pointer); + ObjDesc->String.Length, ObjDesc->String.Pointer); AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); AcpiOsPrintf ("\n"); break; @@ -386,7 +386,7 @@ AcpiExDumpOperand ( ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK, ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK, ObjDesc->Field.BaseByteOffset, ObjDesc->Field.StartFieldBitOffset); - ACPI_DUMP_STACK_ENTRY (ObjDesc->Field.RegionObj); + AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1); break; @@ -413,9 +413,8 @@ AcpiExDumpOperand ( } else { - ACPI_DUMP_STACK_ENTRY (ObjDesc->BufferField.BufferObj); + AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth+1); } - break; @@ -479,10 +478,13 @@ AcpiExDumpOperand ( * * FUNCTION: AcpiExDumpOperands * - * PARAMETERS: InterpreterMode - Load or Exec - * *Ident - Identification + * PARAMETERS: Operands - Operand list + * InterpreterMode - Load or Exec + * Ident - Identification * NumLevels - # of stack entries to dump above line - * *Note - Output notation + * Note - Output notation + * ModuleName - Caller's module name + * LineNumber - Caller's invocation line number * * DESCRIPTION: Dump the object stack * @@ -499,7 +501,6 @@ AcpiExDumpOperands ( UINT32 LineNumber) { ACPI_NATIVE_UINT i; - ACPI_OPERAND_OBJECT **ObjDesc; ACPI_FUNCTION_NAME ("ExDumpOperands"); @@ -528,8 +529,7 @@ AcpiExDumpOperands ( for (i = 0; NumLevels > 0; i--, NumLevels--) { - ObjDesc = &Operands[i]; - AcpiExDumpOperand (*ObjDesc); + AcpiExDumpOperand (Operands[i], 0); } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, @@ -585,8 +585,7 @@ AcpiExOutAddress ( #if ACPI_MACHINE_WIDTH == 16 AcpiOsPrintf ("%20s : %p\n", Title, Value); #else - AcpiOsPrintf ("%20s : %8.8X%8.8X\n", Title, - ACPI_FORMAT_UINT64 (Value)); + AcpiOsPrintf ("%20s : %8.8X%8.8X\n", Title, ACPI_FORMAT_UINT64 (Value)); #endif } @@ -595,7 +594,7 @@ AcpiExOutAddress ( * * FUNCTION: AcpiExDumpNode * - * PARAMETERS: *Node - Descriptor to dump + * PARAMETERS: *Node - Descriptor to dump * Flags - Force display * * DESCRIPTION: Dumps the members of the given.Node @@ -664,23 +663,26 @@ AcpiExDumpObjectDescriptor ( if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) { AcpiExDumpNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags); - AcpiOsPrintf ("\nAttached Object (%p):\n", ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object); - AcpiExDumpObjectDescriptor (((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags); - return; + AcpiOsPrintf ("\nAttached Object (%p):\n", + ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object); + AcpiExDumpObjectDescriptor ( + ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags); + return_VOID; } if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) { - AcpiOsPrintf ("ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n", - ObjDesc, AcpiUtGetDescriptorName (ObjDesc)); + AcpiOsPrintf ( + "ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n", + ObjDesc, AcpiUtGetDescriptorName (ObjDesc)); return_VOID; } /* Common Fields */ - AcpiExOutString ("Type", AcpiUtGetObjectTypeName (ObjDesc)); - AcpiExOutInteger ("Reference Count", ObjDesc->Common.ReferenceCount); - AcpiExOutInteger ("Flags", ObjDesc->Common.Flags); + AcpiExOutString ("Type", AcpiUtGetObjectTypeName (ObjDesc)); + AcpiExOutInteger ("Reference Count", ObjDesc->Common.ReferenceCount); + AcpiExOutInteger ("Flags", ObjDesc->Common.Flags); /* Object-specific Fields */ @@ -695,7 +697,7 @@ AcpiExDumpObjectDescriptor ( case ACPI_TYPE_STRING: - AcpiExOutInteger ("Length", ObjDesc->String.Length); + AcpiExOutInteger ("Length", ObjDesc->String.Length); AcpiOsPrintf ("%20s : %p ", "Pointer", ObjDesc->String.Pointer); AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); @@ -705,17 +707,17 @@ AcpiExDumpObjectDescriptor ( case ACPI_TYPE_BUFFER: - AcpiExOutInteger ("Length", ObjDesc->Buffer.Length); - AcpiExOutPointer ("Pointer", ObjDesc->Buffer.Pointer); + AcpiExOutInteger ("Length", ObjDesc->Buffer.Length); + AcpiExOutPointer ("Pointer", ObjDesc->Buffer.Pointer); ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); break; case ACPI_TYPE_PACKAGE: - AcpiExOutInteger ("Flags", ObjDesc->Package.Flags); - AcpiExOutInteger ("Count", ObjDesc->Package.Count); - AcpiExOutPointer ("Elements", ObjDesc->Package.Elements); + AcpiExOutInteger ("Flags", ObjDesc->Package.Flags); + AcpiExOutInteger ("Count", ObjDesc->Package.Count); + AcpiExOutPointer ("Elements", ObjDesc->Package.Elements); /* Dump the package contents */ @@ -727,7 +729,8 @@ AcpiExDumpObjectDescriptor ( AcpiOsPrintf ("[%.3d] %p", i, ObjDesc->Package.Elements[i]); if (ObjDesc->Package.Elements[i]) { - AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[i])); + AcpiOsPrintf (" %s", + AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[i])); } AcpiOsPrintf ("\n"); } @@ -745,66 +748,66 @@ AcpiExDumpObjectDescriptor ( case ACPI_TYPE_EVENT: - AcpiExOutPointer ("Semaphore", ObjDesc->Event.Semaphore); + AcpiExOutPointer ("Semaphore", ObjDesc->Event.Semaphore); break; case ACPI_TYPE_METHOD: - AcpiExOutInteger ("ParamCount", ObjDesc->Method.ParamCount); - AcpiExOutInteger ("Concurrency", ObjDesc->Method.Concurrency); - AcpiExOutPointer ("Semaphore", ObjDesc->Method.Semaphore); - AcpiExOutInteger ("OwningId", ObjDesc->Method.OwningId); - AcpiExOutInteger ("AmlLength", ObjDesc->Method.AmlLength); - AcpiExOutPointer ("AmlStart", ObjDesc->Method.AmlStart); + AcpiExOutInteger ("ParamCount", ObjDesc->Method.ParamCount); + AcpiExOutInteger ("Concurrency", ObjDesc->Method.Concurrency); + AcpiExOutPointer ("Semaphore", ObjDesc->Method.Semaphore); + AcpiExOutInteger ("OwningId", ObjDesc->Method.OwningId); + AcpiExOutInteger ("AmlLength", ObjDesc->Method.AmlLength); + AcpiExOutPointer ("AmlStart", ObjDesc->Method.AmlStart); break; case ACPI_TYPE_MUTEX: - AcpiExOutInteger ("SyncLevel", ObjDesc->Mutex.SyncLevel); - AcpiExOutPointer ("OwnerThread", ObjDesc->Mutex.OwnerThread); - AcpiExOutInteger ("AcquisitionDepth",ObjDesc->Mutex.AcquisitionDepth); - AcpiExOutPointer ("Semaphore", ObjDesc->Mutex.Semaphore); + AcpiExOutInteger ("SyncLevel", ObjDesc->Mutex.SyncLevel); + AcpiExOutPointer ("OwnerThread", ObjDesc->Mutex.OwnerThread); + AcpiExOutInteger ("AcquireDepth", ObjDesc->Mutex.AcquisitionDepth); + AcpiExOutPointer ("Semaphore", ObjDesc->Mutex.Semaphore); break; case ACPI_TYPE_REGION: - AcpiExOutInteger ("SpaceId", ObjDesc->Region.SpaceId); - AcpiExOutInteger ("Flags", ObjDesc->Region.Flags); - AcpiExOutAddress ("Address", ObjDesc->Region.Address); - AcpiExOutInteger ("Length", ObjDesc->Region.Length); - AcpiExOutPointer ("Handler", ObjDesc->Region.Handler); - AcpiExOutPointer ("Next", ObjDesc->Region.Next); + AcpiExOutInteger ("SpaceId", ObjDesc->Region.SpaceId); + AcpiExOutInteger ("Flags", ObjDesc->Region.Flags); + AcpiExOutAddress ("Address", ObjDesc->Region.Address); + AcpiExOutInteger ("Length", ObjDesc->Region.Length); + AcpiExOutPointer ("Handler", ObjDesc->Region.Handler); + AcpiExOutPointer ("Next", ObjDesc->Region.Next); break; case ACPI_TYPE_POWER: - AcpiExOutInteger ("SystemLevel", ObjDesc->PowerResource.SystemLevel); - AcpiExOutInteger ("ResourceOrder", ObjDesc->PowerResource.ResourceOrder); - AcpiExOutPointer ("SystemNotify", ObjDesc->PowerResource.SystemNotify); - AcpiExOutPointer ("DeviceNotify", ObjDesc->PowerResource.DeviceNotify); + AcpiExOutInteger ("SystemLevel", ObjDesc->PowerResource.SystemLevel); + AcpiExOutInteger ("ResourceOrder", ObjDesc->PowerResource.ResourceOrder); + AcpiExOutPointer ("SystemNotify", ObjDesc->PowerResource.SystemNotify); + AcpiExOutPointer ("DeviceNotify", ObjDesc->PowerResource.DeviceNotify); break; case ACPI_TYPE_PROCESSOR: - AcpiExOutInteger ("Processor ID", ObjDesc->Processor.ProcId); - AcpiExOutInteger ("Length", ObjDesc->Processor.Length); - AcpiExOutAddress ("Address", (ACPI_PHYSICAL_ADDRESS) ObjDesc->Processor.Address); - AcpiExOutPointer ("SystemNotify", ObjDesc->Processor.SystemNotify); - AcpiExOutPointer ("DeviceNotify", ObjDesc->Processor.DeviceNotify); - AcpiExOutPointer ("Handler", ObjDesc->Processor.Handler); + AcpiExOutInteger ("Processor ID", ObjDesc->Processor.ProcId); + AcpiExOutInteger ("Length", ObjDesc->Processor.Length); + AcpiExOutAddress ("Address", (ACPI_PHYSICAL_ADDRESS) ObjDesc->Processor.Address); + AcpiExOutPointer ("SystemNotify", ObjDesc->Processor.SystemNotify); + AcpiExOutPointer ("DeviceNotify", ObjDesc->Processor.DeviceNotify); + AcpiExOutPointer ("Handler", ObjDesc->Processor.Handler); break; case ACPI_TYPE_THERMAL: - AcpiExOutPointer ("SystemNotify", ObjDesc->ThermalZone.SystemNotify); - AcpiExOutPointer ("DeviceNotify", ObjDesc->ThermalZone.DeviceNotify); - AcpiExOutPointer ("Handler", ObjDesc->ThermalZone.Handler); + AcpiExOutPointer ("SystemNotify", ObjDesc->ThermalZone.SystemNotify); + AcpiExOutPointer ("DeviceNotify", ObjDesc->ThermalZone.DeviceNotify); + AcpiExOutPointer ("Handler", ObjDesc->ThermalZone.Handler); break; @@ -813,36 +816,36 @@ AcpiExDumpObjectDescriptor ( case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - AcpiExOutInteger ("FieldFlags", ObjDesc->CommonField.FieldFlags); - AcpiExOutInteger ("AccessByteWidth", ObjDesc->CommonField.AccessByteWidth); - AcpiExOutInteger ("BitLength", ObjDesc->CommonField.BitLength); - AcpiExOutInteger ("FldBitOffset", ObjDesc->CommonField.StartFieldBitOffset); - AcpiExOutInteger ("BaseByteOffset", ObjDesc->CommonField.BaseByteOffset); - AcpiExOutInteger ("DatumValidBits", ObjDesc->CommonField.DatumValidBits); - AcpiExOutInteger ("EndFldValidBits", ObjDesc->CommonField.EndFieldValidBits); - AcpiExOutInteger ("EndBufValidBits", ObjDesc->CommonField.EndBufferValidBits); - AcpiExOutPointer ("ParentNode", ObjDesc->CommonField.Node); + AcpiExOutInteger ("FieldFlags", ObjDesc->CommonField.FieldFlags); + AcpiExOutInteger ("AccessByteWidth",ObjDesc->CommonField.AccessByteWidth); + AcpiExOutInteger ("BitLength", ObjDesc->CommonField.BitLength); + AcpiExOutInteger ("FldBitOffset", ObjDesc->CommonField.StartFieldBitOffset); + AcpiExOutInteger ("BaseByteOffset", ObjDesc->CommonField.BaseByteOffset); + AcpiExOutInteger ("DatumValidBits", ObjDesc->CommonField.DatumValidBits); + AcpiExOutInteger ("EndFldValidBits",ObjDesc->CommonField.EndFieldValidBits); + AcpiExOutInteger ("EndBufValidBits",ObjDesc->CommonField.EndBufferValidBits); + AcpiExOutPointer ("ParentNode", ObjDesc->CommonField.Node); switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_BUFFER_FIELD: - AcpiExOutPointer ("BufferObj", ObjDesc->BufferField.BufferObj); + AcpiExOutPointer ("BufferObj", ObjDesc->BufferField.BufferObj); break; case ACPI_TYPE_LOCAL_REGION_FIELD: - AcpiExOutPointer ("RegionObj", ObjDesc->Field.RegionObj); + AcpiExOutPointer ("RegionObj", ObjDesc->Field.RegionObj); break; case ACPI_TYPE_LOCAL_BANK_FIELD: - AcpiExOutInteger ("Value", ObjDesc->BankField.Value); - AcpiExOutPointer ("RegionObj", ObjDesc->BankField.RegionObj); - AcpiExOutPointer ("BankObj", ObjDesc->BankField.BankObj); + AcpiExOutInteger ("Value", ObjDesc->BankField.Value); + AcpiExOutPointer ("RegionObj", ObjDesc->BankField.RegionObj); + AcpiExOutPointer ("BankObj", ObjDesc->BankField.BankObj); break; case ACPI_TYPE_LOCAL_INDEX_FIELD: - AcpiExOutInteger ("Value", ObjDesc->IndexField.Value); - AcpiExOutPointer ("Index", ObjDesc->IndexField.IndexObj); - AcpiExOutPointer ("Data", ObjDesc->IndexField.DataObj); + AcpiExOutInteger ("Value", ObjDesc->IndexField.Value); + AcpiExOutPointer ("Index", ObjDesc->IndexField.IndexObj); + AcpiExOutPointer ("Data", ObjDesc->IndexField.DataObj); break; default: @@ -854,29 +857,29 @@ AcpiExDumpObjectDescriptor ( case ACPI_TYPE_LOCAL_REFERENCE: - AcpiExOutInteger ("TargetType", ObjDesc->Reference.TargetType); - AcpiExOutString ("Opcode", (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name); - AcpiExOutInteger ("Offset", ObjDesc->Reference.Offset); - AcpiExOutPointer ("ObjDesc", ObjDesc->Reference.Object); - AcpiExOutPointer ("Node", ObjDesc->Reference.Node); - AcpiExOutPointer ("Where", ObjDesc->Reference.Where); + AcpiExOutInteger ("TargetType", ObjDesc->Reference.TargetType); + AcpiExOutString ("Opcode", (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name); + AcpiExOutInteger ("Offset", ObjDesc->Reference.Offset); + AcpiExOutPointer ("ObjDesc", ObjDesc->Reference.Object); + AcpiExOutPointer ("Node", ObjDesc->Reference.Node); + AcpiExOutPointer ("Where", ObjDesc->Reference.Where); break; case ACPI_TYPE_LOCAL_ADDRESS_HANDLER: - AcpiExOutInteger ("SpaceId", ObjDesc->AddressSpace.SpaceId); - AcpiExOutPointer ("Next", ObjDesc->AddressSpace.Next); - AcpiExOutPointer ("RegionList", ObjDesc->AddressSpace.RegionList); - AcpiExOutPointer ("Node", ObjDesc->AddressSpace.Node); - AcpiExOutPointer ("Context", ObjDesc->AddressSpace.Context); + AcpiExOutInteger ("SpaceId", ObjDesc->AddressSpace.SpaceId); + AcpiExOutPointer ("Next", ObjDesc->AddressSpace.Next); + AcpiExOutPointer ("RegionList", ObjDesc->AddressSpace.RegionList); + AcpiExOutPointer ("Node", ObjDesc->AddressSpace.Node); + AcpiExOutPointer ("Context", ObjDesc->AddressSpace.Context); break; case ACPI_TYPE_LOCAL_NOTIFY: - AcpiExOutPointer ("Node", ObjDesc->Notify.Node); - AcpiExOutPointer ("Context", ObjDesc->Notify.Context); + AcpiExOutPointer ("Node", ObjDesc->Notify.Node); + AcpiExOutPointer ("Context", ObjDesc->Notify.Context); break; @@ -886,7 +889,8 @@ AcpiExDumpObjectDescriptor ( case ACPI_TYPE_LOCAL_DATA: default: - AcpiOsPrintf ("ExDumpObjectDescriptor: Display not implemented for object type %s\n", + AcpiOsPrintf ( + "ExDumpObjectDescriptor: Display not implemented for object type %s\n", AcpiUtGetObjectTypeName (ObjDesc)); break; } diff --git a/sys/contrib/dev/acpica/exfldio.c b/sys/contrib/dev/acpica/exfldio.c index 4c9a1f127b7e..25d656180be5 100644 --- a/sys/contrib/dev/acpica/exfldio.c +++ b/sys/contrib/dev/acpica/exfldio.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exfldio - Aml Field I/O - * $Revision: 106 $ + * $Revision: 111 $ * *****************************************************************************/ @@ -212,6 +212,23 @@ AcpiExSetupRegion ( + FieldDatumByteOffset + ObjDesc->CommonField.AccessByteWidth)) { + if (AcpiGbl_EnableInterpreterSlack) + { + /* + * Slack mode only: We will go ahead and allow access to this + * field if it is within the region length rounded up to the next + * access width boundary. + */ + if (ACPI_ROUND_UP (RgnDesc->Region.Length, + ObjDesc->CommonField.AccessByteWidth) >= + (ObjDesc->CommonField.BaseByteOffset + + (ACPI_NATIVE_UINT) ObjDesc->CommonField.AccessByteWidth + + FieldDatumByteOffset)) + { + return_ACPI_STATUS (AE_OK); + } + } + if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth) { /* @@ -891,7 +908,7 @@ AcpiExCommonBufferSetup ( return_ACPI_STATUS (AE_BUFFER_OVERFLOW); } - /* + /* * Create "actual" field byte count (minimum number of bytes that * must be read), then convert to datum count (minimum number * of datum-sized units that must be read) diff --git a/sys/contrib/dev/acpica/exmisc.c b/sys/contrib/dev/acpica/exmisc.c index ae24c5d71715..6abfe5ba6515 100644 --- a/sys/contrib/dev/acpica/exmisc.c +++ b/sys/contrib/dev/acpica/exmisc.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes - * $Revision: 118 $ + * $Revision: 126 $ * *****************************************************************************/ @@ -228,8 +228,9 @@ AcpiExGetObjectReference ( * * FUNCTION: AcpiExConcatTemplate * - * PARAMETERS: *ObjDesc - Object to be converted. Must be an - * Integer, Buffer, or String + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object + * ActualReturnDesc - Where to place the return object * WalkState - Current walk state * * RETURN: Status @@ -240,8 +241,8 @@ AcpiExGetObjectReference ( ACPI_STATUS AcpiExConcatTemplate ( - ACPI_OPERAND_OBJECT *ObjDesc1, - ACPI_OPERAND_OBJECT *ObjDesc2, + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState) { @@ -258,8 +259,8 @@ AcpiExConcatTemplate ( /* Find the EndTags in each resource template */ - EndTag1 = AcpiUtGetResourceEndTag (ObjDesc1); - EndTag2 = AcpiUtGetResourceEndTag (ObjDesc2); + EndTag1 = AcpiUtGetResourceEndTag (Operand0); + EndTag2 = AcpiUtGetResourceEndTag (Operand1); if (!EndTag1 || !EndTag2) { return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -267,8 +268,8 @@ AcpiExConcatTemplate ( /* Compute the length of each part */ - Length1 = ACPI_PTR_DIFF (EndTag1, ObjDesc1->Buffer.Pointer); - Length2 = ACPI_PTR_DIFF (EndTag2, ObjDesc2->Buffer.Pointer) + + Length1 = ACPI_PTR_DIFF (EndTag1, Operand0->Buffer.Pointer); + Length2 = ACPI_PTR_DIFF (EndTag2, Operand1->Buffer.Pointer) + 2; /* Size of END_TAG */ /* Create a new buffer object for the result */ @@ -282,8 +283,8 @@ AcpiExConcatTemplate ( /* Copy the templates to the new descriptor */ NewBuf = ReturnDesc->Buffer.Pointer; - ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer, Length1); - ACPI_MEMCPY (NewBuf + Length1, ObjDesc2->Buffer.Pointer, Length2); + ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length1); + ACPI_MEMCPY (NewBuf + Length1, Operand1->Buffer.Pointer, Length2); /* Compute the new checksum */ @@ -302,8 +303,8 @@ AcpiExConcatTemplate ( * * FUNCTION: AcpiExDoConcatenate * - * PARAMETERS: ObjDesc1 - First source object - * ObjDesc2 - Second source object + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object * ActualReturnDesc - Where to place the return object * WalkState - Current walk state * @@ -315,20 +316,59 @@ AcpiExConcatTemplate ( ACPI_STATUS AcpiExDoConcatenate ( - ACPI_OPERAND_OBJECT *ObjDesc1, - ACPI_OPERAND_OBJECT *ObjDesc2, + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState) { - ACPI_STATUS Status; - UINT32 i; - ACPI_INTEGER ThisInteger; + ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; ACPI_OPERAND_OBJECT *ReturnDesc; char *NewBuf; + ACPI_STATUS Status; + ACPI_SIZE NewLength; - ACPI_FUNCTION_ENTRY (); + ACPI_FUNCTION_TRACE ("ExDoConcatenate"); + + + /* + * Convert the second operand if necessary. The first operand + * determines the type of the second operand, (See the Data Types + * section of the ACPI specification.) Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (ACPI_GET_OBJECT_TYPE (Operand0)) + { + case ACPI_TYPE_INTEGER: + Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); + break; + + case ACPI_TYPE_STRING: + Status = AcpiExConvertToString (Operand1, &LocalOperand1, + ACPI_IMPLICIT_CONVERT_HEX); + break; + + case ACPI_TYPE_BUFFER: + Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1); + break; + + default: + ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n", + ACPI_GET_OBJECT_TYPE (Operand0))); + Status = AE_AML_INTERNAL; + } + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + /* + * Both operands are now known to be the same object type + * (Both are Integer, String, or Buffer), and we can now perform the + * concatenation. + */ /* * There are three cases to handle: @@ -337,120 +377,108 @@ AcpiExDoConcatenate ( * 2) Two Strings concatenated to produce a new String * 3) Two Buffers concatenated to produce a new Buffer */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc1)) + switch (ACPI_GET_OBJECT_TYPE (Operand0)) { case ACPI_TYPE_INTEGER: /* Result of two Integers is a Buffer */ /* Need enough buffer space for two integers */ - ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth * 2); + ReturnDesc = AcpiUtCreateBufferObject ( + ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); if (!ReturnDesc) { - return (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto Cleanup; } NewBuf = (char *) ReturnDesc->Buffer.Pointer; - /* Convert the first integer */ + /* Copy the first integer, LSB first */ - ThisInteger = ObjDesc1->Integer.Value; - for (i = 0; i < AcpiGbl_IntegerByteWidth; i++) - { - NewBuf[i] = (char) ThisInteger; - ThisInteger >>= 8; - } + ACPI_MEMCPY (NewBuf, + &Operand0->Integer.Value, + AcpiGbl_IntegerByteWidth); - /* Convert the second integer */ - - ThisInteger = ObjDesc2->Integer.Value; - for (; i < (ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); i++) - { - NewBuf[i] = (char) ThisInteger; - ThisInteger >>= 8; - } + /* Copy the second integer (LSB first) after the first */ + ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth, + &LocalOperand1->Integer.Value, + AcpiGbl_IntegerByteWidth); break; - case ACPI_TYPE_STRING: /* Result of two Strings is a String */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); - if (!ReturnDesc) + NewLength = (ACPI_SIZE) Operand0->String.Length + + (ACPI_SIZE) LocalOperand1->String.Length; + if (NewLength > ACPI_MAX_STRING_CONVERSION) { - return (AE_NO_MEMORY); + Status = AE_AML_STRING_LIMIT; + goto Cleanup; } - /* Operand0 is string */ - - NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) ObjDesc1->String.Length + - (ACPI_SIZE) ObjDesc2->String.Length + 1); - if (!NewBuf) + ReturnDesc = AcpiUtCreateStringObject (NewLength); + if (!ReturnDesc) { - ACPI_REPORT_ERROR - (("ExDoConcatenate: String allocation failure\n")); Status = AE_NO_MEMORY; goto Cleanup; } - /* Concatenate the strings */ - - ACPI_STRCPY (NewBuf, ObjDesc1->String.Pointer); - ACPI_STRCPY (NewBuf + ObjDesc1->String.Length, - ObjDesc2->String.Pointer); + NewBuf = ReturnDesc->String.Pointer; - /* Complete the String object initialization */ + /* Concatenate the strings */ - ReturnDesc->String.Pointer = NewBuf; - ReturnDesc->String.Length = ObjDesc1->String.Length + - ObjDesc2->String.Length; + ACPI_STRCPY (NewBuf, + Operand0->String.Pointer); + ACPI_STRCPY (NewBuf + Operand0->String.Length, + LocalOperand1->String.Pointer); break; - case ACPI_TYPE_BUFFER: /* Result of two Buffers is a Buffer */ ReturnDesc = AcpiUtCreateBufferObject ( - (ACPI_SIZE) ObjDesc1->Buffer.Length + - (ACPI_SIZE) ObjDesc2->Buffer.Length); + (ACPI_SIZE) Operand0->Buffer.Length + + (ACPI_SIZE) LocalOperand1->Buffer.Length); if (!ReturnDesc) { - return (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto Cleanup; } NewBuf = (char *) ReturnDesc->Buffer.Pointer; /* Concatenate the buffers */ - ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer, - ObjDesc1->Buffer.Length); - ACPI_MEMCPY (NewBuf + ObjDesc1->Buffer.Length, ObjDesc2->Buffer.Pointer, - ObjDesc2->Buffer.Length); - + ACPI_MEMCPY (NewBuf, + Operand0->Buffer.Pointer, + Operand0->Buffer.Length); + ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length, + LocalOperand1->Buffer.Pointer, + LocalOperand1->Buffer.Length); break; - default: /* Invalid object type, should not happen here */ - ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n", - ACPI_GET_OBJECT_TYPE (ObjDesc1))); - Status = AE_AML_INTERNAL; - ReturnDesc = NULL; + ACPI_REPORT_ERROR (("Concatenate - Invalid object type: %X\n", + ACPI_GET_OBJECT_TYPE (Operand0))); + Status =AE_AML_INTERNAL; + goto Cleanup; } *ActualReturnDesc = ReturnDesc; - return (AE_OK); - Cleanup: - - AcpiUtRemoveReference (ReturnDesc); - return (Status); + if (LocalOperand1 != Operand1) + { + AcpiUtRemoveReference (LocalOperand1); + } + return_ACPI_STATUS (AE_OK); } @@ -459,8 +487,8 @@ Cleanup: * FUNCTION: AcpiExDoMathOp * * PARAMETERS: Opcode - AML opcode - * Operand0 - Integer operand #0 - * Operand1 - Integer operand #1 + * Integer0 - Integer operand #0 + * Integer1 - Integer operand #1 * * RETURN: Integer result of the operation * @@ -473,61 +501,63 @@ Cleanup: ACPI_INTEGER AcpiExDoMathOp ( UINT16 Opcode, - ACPI_INTEGER Operand0, - ACPI_INTEGER Operand1) + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1) { + ACPI_FUNCTION_ENTRY (); + switch (Opcode) { - case AML_ADD_OP: /* Add (Operand0, Operand1, Result) */ + case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */ - return (Operand0 + Operand1); + return (Integer0 + Integer1); - case AML_BIT_AND_OP: /* And (Operand0, Operand1, Result) */ + case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */ - return (Operand0 & Operand1); + return (Integer0 & Integer1); - case AML_BIT_NAND_OP: /* NAnd (Operand0, Operand1, Result) */ + case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */ - return (~(Operand0 & Operand1)); + return (~(Integer0 & Integer1)); - case AML_BIT_OR_OP: /* Or (Operand0, Operand1, Result) */ + case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */ - return (Operand0 | Operand1); + return (Integer0 | Integer1); - case AML_BIT_NOR_OP: /* NOr (Operand0, Operand1, Result) */ + case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */ - return (~(Operand0 | Operand1)); + return (~(Integer0 | Integer1)); - case AML_BIT_XOR_OP: /* XOr (Operand0, Operand1, Result) */ + case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */ - return (Operand0 ^ Operand1); + return (Integer0 ^ Integer1); - case AML_MULTIPLY_OP: /* Multiply (Operand0, Operand1, Result) */ + case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */ - return (Operand0 * Operand1); + return (Integer0 * Integer1); case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result) */ - return (Operand0 << Operand1); + return (Integer0 << Integer1); case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */ - return (Operand0 >> Operand1); + return (Integer0 >> Integer1); - case AML_SUBTRACT_OP: /* Subtract (Operand0, Operand1, Result) */ + case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */ - return (Operand0 - Operand1); + return (Integer0 - Integer1); default: @@ -538,18 +568,87 @@ AcpiExDoMathOp ( /******************************************************************************* * + * FUNCTION: AcpiExDoLogicalNumericOp + * + * PARAMETERS: Opcode - AML opcode + * Integer0 - Integer operand #0 + * Integer1 - Integer operand #1 + * LogicalResult - TRUE/FALSE result of the operation + * + * RETURN: Status + * + * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric + * operators (LAnd and LOr), both operands must be integers. + * + * Note: cleanest machine code seems to be produced by the code + * below, rather than using statements of the form: + * Result = (Integer0 && Integer1); + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoLogicalNumericOp ( + UINT16 Opcode, + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1, + BOOLEAN *LogicalResult) +{ + ACPI_STATUS Status = AE_OK; + BOOLEAN LocalResult = FALSE; + + + ACPI_FUNCTION_TRACE ("ExDoLogicalNumericOp"); + + + switch (Opcode) + { + case AML_LAND_OP: /* LAnd (Integer0, Integer1) */ + + if (Integer0 && Integer1) + { + LocalResult = TRUE; + } + break; + + case AML_LOR_OP: /* LOr (Integer0, Integer1) */ + + if (Integer0 || Integer1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + + /* Return the logical result and status */ + + *LogicalResult = LocalResult; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * * FUNCTION: AcpiExDoLogicalOp * * PARAMETERS: Opcode - AML opcode - * Operand0 - Integer operand #0 - * Operand1 - Integer operand #1 + * Operand0 - operand #0 + * Operand1 - operand #1 + * LogicalResult - TRUE/FALSE result of the operation * - * RETURN: TRUE/FALSE result of the operation + * RETURN: Status * * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the * functions here is to prevent a lot of pointer dereferencing * to obtain the operands and to simplify the generation of the - * logical value. + * logical value. For the Numeric operators (LAnd and LOr), both + * operands must be integers. For the other logical operators, + * operands can be any combination of Integer/String/Buffer. The + * first operand determines the type to which the second operand + * will be converted. * * Note: cleanest machine code seems to be produced by the code * below, rather than using statements of the form: @@ -557,66 +656,192 @@ AcpiExDoMathOp ( * ******************************************************************************/ -BOOLEAN +ACPI_STATUS AcpiExDoLogicalOp ( UINT16 Opcode, - ACPI_INTEGER Operand0, - ACPI_INTEGER Operand1) + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + BOOLEAN *LogicalResult) { + ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; + ACPI_INTEGER Integer0; + ACPI_INTEGER Integer1; + UINT32 Length0; + UINT32 Length1; + ACPI_STATUS Status = AE_OK; + BOOLEAN LocalResult = FALSE; + int Compare; - switch (Opcode) - { + ACPI_FUNCTION_TRACE ("ExDoLogicalOp"); - case AML_LAND_OP: /* LAnd (Operand0, Operand1) */ - if (Operand0 && Operand1) - { - return (TRUE); - } + /* + * Convert the second operand if necessary. The first operand + * determines the type of the second operand, (See the Data Types + * section of the ACPI 3.0+ specification.) Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (ACPI_GET_OBJECT_TYPE (Operand0)) + { + case ACPI_TYPE_INTEGER: + Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); break; + case ACPI_TYPE_STRING: + Status = AcpiExConvertToString (Operand1, &LocalOperand1, + ACPI_IMPLICIT_CONVERT_HEX); + break; - case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + case ACPI_TYPE_BUFFER: + Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1); + break; - if (Operand0 == Operand1) - { - return (TRUE); - } + default: + Status = AE_AML_INTERNAL; break; + } + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } - case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + /* + * Two cases: 1) Both Integers, 2) Both Strings or Buffers + */ + if (ACPI_GET_OBJECT_TYPE (Operand0) == ACPI_TYPE_INTEGER) + { + /* + * 1) Both operands are of type integer + * Note: LocalOperand1 may have changed above + */ + Integer0 = Operand0->Integer.Value; + Integer1 = LocalOperand1->Integer.Value; - if (Operand0 > Operand1) + switch (Opcode) { - return (TRUE); - } - break; + case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + if (Integer0 == Integer1) + { + LocalResult = TRUE; + } + break; - case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ - if (Operand0 < Operand1) - { - return (TRUE); + if (Integer0 > Integer1) + { + LocalResult = TRUE; + } + break; + + case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + + if (Integer0 < Integer1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; } - break; + } + else + { + /* + * 2) Both operands are Strings or both are Buffers + * Note: Code below takes advantage of common Buffer/String + * object fields. LocalOperand1 may have changed above. Use + * memcmp to handle nulls in buffers. + */ + Length0 = Operand0->Buffer.Length; + Length1 = LocalOperand1->Buffer.Length; + /* Lexicographic compare: compare the data bytes */ - case AML_LOR_OP: /* LOr (Operand0, Operand1) */ + Compare = ACPI_MEMCMP ((const char * ) Operand0->Buffer.Pointer, + (const char * ) LocalOperand1->Buffer.Pointer, + (Length0 > Length1) ? Length1 : Length0); - if (Operand0 || Operand1) + switch (Opcode) { - return (TRUE); + case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + + /* Length and all bytes must be equal */ + + if ((Length0 == Length1) && + (Compare == 0)) + { + /* Length and all bytes match ==> TRUE */ + + LocalResult = TRUE; + } + break; + + case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + + if (Compare > 0) + { + LocalResult = TRUE; + goto Cleanup; /* TRUE */ + } + if (Compare < 0) + { + goto Cleanup; /* FALSE */ + } + + /* Bytes match (to shortest length), compare lengths */ + + if (Length0 > Length1) + { + LocalResult = TRUE; + } + break; + + case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + + if (Compare > 0) + { + goto Cleanup; /* FALSE */ + } + if (Compare < 0) + { + LocalResult = TRUE; + goto Cleanup; /* TRUE */ + } + + /* Bytes match (to shortest length), compare lengths */ + + if (Length0 < Length1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; } - break; + } - default: - break; +Cleanup: + + /* New object was created if implicit conversion performed - delete */ + + if (LocalOperand1 != Operand1) + { + AcpiUtRemoveReference (LocalOperand1); } - return (FALSE); + /* Return the logical result and status */ + + *LogicalResult = LocalResult; + return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exoparg1.c b/sys/contrib/dev/acpica/exoparg1.c index d52f945366bb..56d98e178ad2 100644 --- a/sys/contrib/dev/acpica/exoparg1.c +++ b/sys/contrib/dev/acpica/exoparg1.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exoparg1 - AML execution - opcodes with 1 argument - * $Revision: 152 $ + * $Revision: 163 $ * *****************************************************************************/ @@ -141,7 +141,7 @@ * Where: * * xA - ARGUMENTS: The number of arguments (input operands) that are - * required for this opcode type (1 through 6 args). + * required for this opcode type (0 through 6 args). * yT - TARGETS: The number of targets (output operands) that are required * for this opcode type (0, 1, or 2 targets). * zR - RETURN VALUE: Indicates whether this opcode type returns a value @@ -153,6 +153,73 @@ /******************************************************************************* * + * FUNCTION: AcpiExOpcode_0A_0T_1R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute operator with no operands, one return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_0A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + + + ACPI_FUNCTION_TRACE_STR ("ExOpcode_0A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_TIMER_OP: /* Timer () */ + + /* Create a return object of type Integer */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + ReturnDesc->Integer.Value = AcpiOsGetTimer (); + break; + + default: /* Unknown opcode */ + + ACPI_REPORT_ERROR (("AcpiExOpcode_0A_0T_1R: Unknown opcode %X\n", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + break; + } + +Cleanup: + + if (!WalkState->ResultObj) + { + WalkState->ResultObj = ReturnDesc; + } + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * * FUNCTION: AcpiExOpcode_1A_0T_0R * * PARAMETERS: WalkState - Current state (contains AML opcode) @@ -199,7 +266,7 @@ AcpiExOpcode_1A_0T_0R ( case AML_SLEEP_OP: /* Sleep (MsecTime) */ - Status = AcpiExSystemDoSuspend ((UINT32) Operand[0]->Integer.Value); + Status = AcpiExSystemDoSuspend (Operand[0]->Integer.Value); break; @@ -298,7 +365,7 @@ AcpiExOpcode_1A_1T_1R ( ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; UINT32 Temp32; UINT32 i; - UINT32 PowerOfTen; + ACPI_INTEGER PowerOfTen; ACPI_INTEGER Digit; @@ -341,7 +408,8 @@ AcpiExOpcode_1A_1T_1R ( * Acpi specification describes Integer type as a little * endian unsigned value, so this boundary condition is valid. */ - for (Temp32 = 0; ReturnDesc->Integer.Value && Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + for (Temp32 = 0; ReturnDesc->Integer.Value && + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) { ReturnDesc->Integer.Value >>= 1; } @@ -358,14 +426,16 @@ AcpiExOpcode_1A_1T_1R ( * The Acpi specification describes Integer type as a little * endian unsigned value, so this boundary condition is valid. */ - for (Temp32 = 0; ReturnDesc->Integer.Value && Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + for (Temp32 = 0; ReturnDesc->Integer.Value && + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) { ReturnDesc->Integer.Value <<= 1; } /* Since the bit position is one-based, subtract from 33 (65) */ - ReturnDesc->Integer.Value = Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32; + ReturnDesc->Integer.Value = Temp32 == 0 ? 0 : + (ACPI_INTEGER_BIT_SIZE + 1) - Temp32; break; @@ -402,7 +472,8 @@ AcpiExOpcode_1A_1T_1R ( /* Sum the digit into the result with the current power of 10 */ - ReturnDesc->Integer.Value += (((ACPI_INTEGER) Temp32) * PowerOfTen); + ReturnDesc->Integer.Value += (((ACPI_INTEGER) Temp32) * + PowerOfTen); /* Shift to next BCD digit */ @@ -424,19 +495,21 @@ AcpiExOpcode_1A_1T_1R ( for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++) { - (void) AcpiUtShortDivide (&Digit, 10, &Digit, &Temp32); + (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32); /* Insert the BCD digit that resides in the remainder from above */ - ReturnDesc->Integer.Value |= (((ACPI_INTEGER) Temp32) << (i * 4)); + ReturnDesc->Integer.Value |= (((ACPI_INTEGER) Temp32) << + ACPI_MUL_4 (i)); } /* Overflow if there is any data left in Digit */ if (Digit > 0) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Integer too large to convert to BCD: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value))); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Integer too large to convert to BCD: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value))); Status = AE_AML_NUMERIC_OVERFLOW; goto Cleanup; } @@ -518,42 +591,47 @@ AcpiExOpcode_1A_1T_1R ( */ case AML_COPY_OP: /* Copy (Source, Target) */ - Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc, WalkState); + Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc, + WalkState); break; case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */ - Status = AcpiExConvertToString (Operand[0], &ReturnDesc, 10, ACPI_UINT32_MAX, WalkState); + Status = AcpiExConvertToString (Operand[0], &ReturnDesc, + ACPI_EXPLICIT_CONVERT_DECIMAL); break; case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */ - Status = AcpiExConvertToString (Operand[0], &ReturnDesc, 16, ACPI_UINT32_MAX, WalkState); + Status = AcpiExConvertToString (Operand[0], &ReturnDesc, + ACPI_EXPLICIT_CONVERT_HEX); break; case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */ - Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc, WalkState); + Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc); break; case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */ - Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, WalkState); + Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, + ACPI_ANY_BASE); break; - case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */ - case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */ + case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */ + case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */ /* * These are two obsolete opcodes */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s is obsolete and not implemented\n", - AcpiPsGetOpcodeName (WalkState->Opcode))); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "%s is obsolete and not implemented\n", + AcpiPsGetOpcodeName (WalkState->Opcode))); Status = AE_SUPPORT; goto Cleanup; @@ -630,7 +708,14 @@ AcpiExOpcode_1A_0T_1R ( goto Cleanup; } - ReturnDesc->Integer.Value = !Operand[0]->Integer.Value; + /* + * Set result to ONES (TRUE) if Value == 0. Note: + * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above. + */ + if (!Operand[0]->Integer.Value) + { + ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + } break; @@ -638,51 +723,79 @@ AcpiExOpcode_1A_0T_1R ( case AML_INCREMENT_OP: /* Increment (Operand) */ /* - * Since we are expecting a Reference operand, it - * can be either a NS Node or an internal object. + * Create a new integer. Can't just get the base integer and + * increment it because it may be an Arg or Field. */ - ReturnDesc = Operand[0]; - if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_OPERAND) + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Since we are expecting a Reference operand, it can be either a + * NS Node or an internal object. + */ + TempDesc = Operand[0]; + if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND) { /* Internal reference object - prevent deletion */ - AcpiUtAddReference (ReturnDesc); + AcpiUtAddReference (TempDesc); } /* - * Convert the ReturnDesc Reference to a Number - * (This removes a reference on the ReturnDesc object) + * Convert the Reference operand to an Integer (This removes a + * reference on the Operand[0] object) + * + * NOTE: We use LNOT_OP here in order to force resolution of the + * reference operand to an actual integer. */ - Status = AcpiExResolveOperands (AML_LNOT_OP, &ReturnDesc, WalkState); + Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n", - AcpiPsGetOpcodeName (WalkState->Opcode), AcpiFormatException(Status))); + AcpiPsGetOpcodeName (WalkState->Opcode), + AcpiFormatException(Status))); goto Cleanup; } /* - * ReturnDesc is now guaranteed to be an Integer object - * Do the actual increment or decrement + * TempDesc is now guaranteed to be an Integer object -- + * Perform the actual increment or decrement */ - if (AML_INCREMENT_OP == WalkState->Opcode) + if (WalkState->Opcode == AML_INCREMENT_OP) { - ReturnDesc->Integer.Value++; + ReturnDesc->Integer.Value = TempDesc->Integer.Value +1; } else { - ReturnDesc->Integer.Value--; + ReturnDesc->Integer.Value = TempDesc->Integer.Value -1; } - /* Store the result back in the original descriptor */ + /* Finished with this Integer object */ + + AcpiUtRemoveReference (TempDesc); + /* + * Store the result back (indirectly) through the original + * Reference object + */ Status = AcpiExStore (ReturnDesc, Operand[0], WalkState); break; case AML_TYPE_OP: /* ObjectType (SourceObject) */ + /* + * Note: The operand is not resolved at this point because we want to + * get the associated object, not its value. For example, we don't want + * to resolve a FieldUnit to its value, we want the actual FieldUnit + * object. + */ + /* Get the type of the base object */ Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL); @@ -690,7 +803,6 @@ AcpiExOpcode_1A_0T_1R ( { goto Cleanup; } - /* Allocate a descriptor to hold the type. */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); @@ -706,6 +818,11 @@ AcpiExOpcode_1A_0T_1R ( case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */ + /* + * Note: The operand is not resolved at this point because we want to + * get the associated object, not its value. + */ + /* Get the base object */ Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, &TempDesc); @@ -715,12 +832,20 @@ AcpiExOpcode_1A_0T_1R ( } /* - * Type is guaranteed to be a buffer, string, or package at this - * point (even if the original operand was an object reference, it - * will be resolved and typechecked during operand resolution.) + * The type of the base object must be integer, buffer, string, or + * package. All others are not supported. + * + * NOTE: Integer is not specifically supported by the ACPI spec, + * but is supported implicitly via implicit operand conversion. + * rather than bother with conversion, we just use the byte width + * global (4 or 8 bytes). */ switch (Type) { + case ACPI_TYPE_INTEGER: + Value = AcpiGbl_IntegerByteWidth; + break; + case ACPI_TYPE_BUFFER: Value = TempDesc->Buffer.Length; break; @@ -734,7 +859,8 @@ AcpiExOpcode_1A_0T_1R ( break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "SizeOf, Not Buf/Str/Pkg - found type %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "SizeOf - Operand is not Buf/Int/Str/Pkg - found type %s\n", AcpiUtGetTypeName (Type))); Status = AE_AML_OPERAND_TYPE; goto Cleanup; @@ -917,7 +1043,8 @@ AcpiExOpcode_1A_0T_1R ( * an uninitialized package element and is thus a * severe error. */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "NULL package element obj %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "NULL package element obj %p\n", Operand[0])); Status = AE_AML_UNINITIALIZED_ELEMENT; goto Cleanup; @@ -929,7 +1056,8 @@ AcpiExOpcode_1A_0T_1R ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Index TargetType %X in obj %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown Index TargetType %X in obj %p\n", Operand[0]->Reference.TargetType, Operand[0])); Status = AE_AML_OPERAND_TYPE; goto Cleanup; @@ -954,7 +1082,8 @@ AcpiExOpcode_1A_0T_1R ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode in ref(%p) - %X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown opcode in ref(%p) - %X\n", Operand[0], Operand[0]->Reference.Opcode)); Status = AE_TYPE; diff --git a/sys/contrib/dev/acpica/exoparg2.c b/sys/contrib/dev/acpica/exoparg2.c index 5ab65d47db29..0c57155874a0 100644 --- a/sys/contrib/dev/acpica/exoparg2.c +++ b/sys/contrib/dev/acpica/exoparg2.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exoparg2 - AML execution - opcodes with 2 arguments - * $Revision: 121 $ + * $Revision: 129 $ * *****************************************************************************/ @@ -278,7 +278,8 @@ AcpiExOpcode_2A_2T_1R ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_2T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_2T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* @@ -304,8 +305,10 @@ AcpiExOpcode_2A_2T_1R ( /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */ - Status = AcpiUtDivide (&Operand[0]->Integer.Value, &Operand[1]->Integer.Value, - &ReturnDesc1->Integer.Value, &ReturnDesc2->Integer.Value); + Status = AcpiUtDivide (Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + &ReturnDesc1->Integer.Value, + &ReturnDesc2->Integer.Value); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -378,13 +381,13 @@ AcpiExOpcode_2A_1T_1R ( { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - ACPI_OPERAND_OBJECT *TempDesc = NULL; UINT32 Index; ACPI_STATUS Status = AE_OK; ACPI_SIZE Length; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_1T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* @@ -421,55 +424,17 @@ AcpiExOpcode_2A_1T_1R ( /* ReturnDesc will contain the remainder */ - Status = AcpiUtDivide (&Operand[0]->Integer.Value, &Operand[1]->Integer.Value, - NULL, &ReturnDesc->Integer.Value); + Status = AcpiUtDivide (Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + NULL, + &ReturnDesc->Integer.Value); break; case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ - /* - * Convert the second operand if necessary. The first operand - * determines the type of the second operand, (See the Data Types - * section of the ACPI specification.) Both object types are - * guaranteed to be either Integer/String/Buffer by the operand - * resolution mechanism above. - */ - switch (ACPI_GET_OBJECT_TYPE (Operand[0])) - { - case ACPI_TYPE_INTEGER: - Status = AcpiExConvertToInteger (Operand[1], &TempDesc, WalkState); - break; - - case ACPI_TYPE_STRING: - Status = AcpiExConvertToString (Operand[1], &TempDesc, 16, ACPI_UINT32_MAX, WalkState); - break; - - case ACPI_TYPE_BUFFER: - Status = AcpiExConvertToBuffer (Operand[1], &TempDesc, WalkState); - break; - - default: - ACPI_REPORT_ERROR (("Concat - invalid obj type: %X\n", - ACPI_GET_OBJECT_TYPE (Operand[0]))); - Status = AE_AML_INTERNAL; - } - - if (ACPI_FAILURE (Status)) - { - goto Cleanup; - } - - /* - * Both operands are now known to be the same object type - * (Both are Integer, String, or Buffer), and we can now perform the - * concatenation. - */ - Status = AcpiExDoConcatenate (Operand[0], TempDesc, &ReturnDesc, WalkState); - if (TempDesc != Operand[1]) - { - AcpiUtRemoveReference (TempDesc); - } + Status = AcpiExDoConcatenate (Operand[0], Operand[1], + &ReturnDesc, WalkState); break; @@ -480,60 +445,48 @@ AcpiExOpcode_2A_1T_1R ( * been converted.) Copy the raw buffer data to a new object of type String. */ - /* Get the length of the new string */ - + /* + * Get the length of the new string. It is the smallest of: + * 1) Length of the input buffer + * 2) Max length as specified in the ToString operator + * 3) Length of input buffer up to a zero byte (null terminator) + * + * NOTE: A length of zero is ok, and will create a zero-length, null + * terminated string. + */ Length = 0; - if (Operand[1]->Integer.Value == 0) - { - /* Handle optional length value */ - - Operand[1]->Integer.Value = ACPI_INTEGER_MAX; - } - while ((Length < Operand[0]->Buffer.Length) && (Length < Operand[1]->Integer.Value) && (Operand[0]->Buffer.Pointer[Length])) { Length++; + if (Length > ACPI_MAX_STRING_CONVERSION) + { + Status = AE_AML_STRING_LIMIT; + goto Cleanup; + } } - if (Length > ACPI_MAX_STRING_CONVERSION) - { - Status = AE_AML_STRING_LIMIT; - goto Cleanup; - } - - /* Create the internal return object */ + /* Allocate a new string object */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); + ReturnDesc = AcpiUtCreateStringObject (Length); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } - /* Allocate a new string buffer (Length + 1 for null terminator) */ + /* Copy the raw buffer data with no transform. NULL terminated already. */ - ReturnDesc->String.Pointer = ACPI_MEM_CALLOCATE (Length + 1); - if (!ReturnDesc->String.Pointer) - { - Status = AE_NO_MEMORY; - goto Cleanup; - } - - /* Copy the raw buffer data with no transform */ - - ACPI_MEMCPY (ReturnDesc->String.Pointer, Operand[0]->Buffer.Pointer, Length); - - /* Set the string length */ - - ReturnDesc->String.Length = (UINT32) Length; + ACPI_MEMCPY (ReturnDesc->String.Pointer, + Operand[0]->Buffer.Pointer, Length); break; case AML_CONCAT_RES_OP: /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */ - Status = AcpiExConcatTemplate (Operand[0], Operand[1], &ReturnDesc, WalkState); + Status = AcpiExConcatTemplate (Operand[0], Operand[1], + &ReturnDesc, WalkState); break; @@ -551,7 +504,7 @@ AcpiExOpcode_2A_1T_1R ( Index = (UINT32) Operand[1]->Integer.Value; /* - * At this point, the Source operand is either a Package or a Buffer + * At this point, the Source operand is a Package, Buffer, or String */ if (ACPI_GET_OBJECT_TYPE (Operand[0]) == ACPI_TYPE_PACKAGE) { @@ -559,7 +512,8 @@ AcpiExOpcode_2A_1T_1R ( if (Index >= Operand[0]->Package.Count) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index value (%X) beyond package end (%X)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Index value (%X) beyond package end (%X)\n", Index, Operand[0]->Package.Count)); Status = AE_AML_PACKAGE_LIMIT; goto Cleanup; @@ -571,11 +525,12 @@ AcpiExOpcode_2A_1T_1R ( } else { - /* Object to be indexed is a Buffer */ + /* Object to be indexed is a Buffer/String */ if (Index >= Operand[0]->Buffer.Length) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index value (%X) beyond end of buffer (%X)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Index value (%X) beyond end of buffer (%X)\n", Index, Operand[0]->Buffer.Length)); Status = AE_AML_BUFFER_LIMIT; goto Cleanup; @@ -665,7 +620,8 @@ AcpiExOpcode_2A_0T_1R ( BOOLEAN LogicalResult = FALSE; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_0T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Create the internal return object */ @@ -680,11 +636,17 @@ AcpiExOpcode_2A_0T_1R ( /* * Execute the Opcode */ - if (WalkState->OpInfo->Flags & AML_LOGICAL) /* LogicalOp (Operand0, Operand1) */ + if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC) /* LogicalOp (Operand0, Operand1) */ + { + Status = AcpiExDoLogicalNumericOp (WalkState->Opcode, + Operand[0]->Integer.Value, Operand[1]->Integer.Value, + &LogicalResult); + goto StoreLogicalResult; + } + else if (WalkState->OpInfo->Flags & AML_LOGICAL) /* LogicalOp (Operand0, Operand1) */ { - LogicalResult = AcpiExDoLogicalOp (WalkState->Opcode, - Operand[0]->Integer.Value, - Operand[1]->Integer.Value); + Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0], + Operand[1], &LogicalResult); goto StoreLogicalResult; } diff --git a/sys/contrib/dev/acpica/exprep.c b/sys/contrib/dev/acpica/exprep.c index 71e48c42cf87..b8580a258c2e 100644 --- a/sys/contrib/dev/acpica/exprep.c +++ b/sys/contrib/dev/acpica/exprep.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities - * $Revision: 127 $ + * $Revision: 128 $ * *****************************************************************************/ @@ -599,6 +599,7 @@ AcpiExPrepFieldValue ( if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj) { ACPI_REPORT_ERROR (("Null Index Object during field prep\n")); + AcpiUtDeleteObjectDesc (ObjDesc); return_ACPI_STATUS (AE_AML_INTERNAL); } diff --git a/sys/contrib/dev/acpica/exregion.c b/sys/contrib/dev/acpica/exregion.c index 6c799f05448a..c3efc382c4fd 100644 --- a/sys/contrib/dev/acpica/exregion.c +++ b/sys/contrib/dev/acpica/exregion.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exregion - ACPI default OpRegion (address space) handlers - * $Revision: 86 $ + * $Revision: 87 $ * *****************************************************************************/ @@ -197,7 +197,7 @@ AcpiExSystemMemorySpaceHandler ( * Hardware does not support non-aligned data transfers, we must verify * the request. */ - (void) AcpiUtShortDivide ((ACPI_INTEGER *) &Address, Length, NULL, &Remainder); + (void) AcpiUtShortDivide ((ACPI_INTEGER) Address, Length, NULL, &Remainder); if (Remainder != 0) { return_ACPI_STATUS (AE_AML_ALIGNMENT); diff --git a/sys/contrib/dev/acpica/exresolv.c b/sys/contrib/dev/acpica/exresolv.c index bc6860e4266f..94d6630234c6 100644 --- a/sys/contrib/dev/acpica/exresolv.c +++ b/sys/contrib/dev/acpica/exresolv.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exresolv - AML Interpreter object resolution - * $Revision: 124 $ + * $Revision: 125 $ * *****************************************************************************/ @@ -412,11 +412,48 @@ AcpiExResolveMultiple ( ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand; ACPI_NAMESPACE_NODE *Node; ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("AcpiExResolveMultiple"); + + /* + * Operand can be either a namespace node or an operand descriptor + */ + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_OPERAND: + Type = ObjDesc->Common.Type; + break; + + case ACPI_DESC_TYPE_NAMED: + Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + + /* If we had an Alias node, use the attached object for type info */ + + if (Type == ACPI_TYPE_LOCAL_ALIAS) + { + Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + } + break; + + default: + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + + /* + * If type is anything other than a reference, we are done + */ + if (Type != ACPI_TYPE_LOCAL_REFERENCE) + { + goto Exit; + } + /* * For reference objects created via the RefOf or Index operators, * we need to get to the base object (as per the ACPI specification @@ -518,6 +555,38 @@ AcpiExResolveMultiple ( break; + case AML_LOCAL_OP: + case AML_ARG_OP: + + if (ReturnDesc) + { + Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Opcode, + ObjDesc->Reference.Offset, WalkState, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiUtRemoveReference (ObjDesc); + } + else + { + Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Opcode, + ObjDesc->Reference.Offset, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + Type = ACPI_TYPE_ANY; + goto Exit; + } + } + break; + + case AML_DEBUG_OP: /* The Debug Object is of type "DebugObject" */ diff --git a/sys/contrib/dev/acpica/exresop.c b/sys/contrib/dev/acpica/exresop.c index 8458dfc54340..08396348ab00 100644 --- a/sys/contrib/dev/acpica/exresop.c +++ b/sys/contrib/dev/acpica/exresop.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exresop - AML Interpreter operand/object resolution - * $Revision: 67 $ + * $Revision: 70 $ * *****************************************************************************/ @@ -240,7 +240,7 @@ AcpiExResolveOperands ( return_ACPI_STATUS (AE_AML_INTERNAL); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X [%s] OperandTypes=%X \n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X [%s] RequiredOperandTypes=%8.8X \n", Opcode, OpInfo->Name, ArgTypes)); /* @@ -314,12 +314,13 @@ AcpiExResolveOperands ( case AML_LOAD_OP: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Reference Opcode: %s\n", OpInfo->Name))); + "Operand is a Reference, RefOpcode [%s]\n", + (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name))); break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown Reference Opcode %X [%s]\n", + "Operand is a Reference, Unknown Reference Opcode %X [%s]\n", ObjDesc->Reference.Opcode, (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name)); @@ -493,7 +494,7 @@ AcpiExResolveOperands ( * But we can implicitly convert from a STRING or BUFFER * Aka - "Implicit Source Operand Conversion" */ - Status = AcpiExConvertToInteger (ObjDesc, StackPtr, WalkState); + Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16); if (ACPI_FAILURE (Status)) { if (Status == AE_TYPE) @@ -517,7 +518,7 @@ AcpiExResolveOperands ( * But we can implicitly convert from a STRING or INTEGER * Aka - "Implicit Source Operand Conversion" */ - Status = AcpiExConvertToBuffer (ObjDesc, StackPtr, WalkState); + Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); if (ACPI_FAILURE (Status)) { if (Status == AE_TYPE) @@ -541,7 +542,8 @@ AcpiExResolveOperands ( * But we can implicitly convert from a BUFFER or INTEGER * Aka - "Implicit Source Operand Conversion" */ - Status = AcpiExConvertToString (ObjDesc, StackPtr, 16, ACPI_UINT32_MAX, WalkState); + Status = AcpiExConvertToString (ObjDesc, StackPtr, + ACPI_IMPLICIT_CONVERT_HEX); if (ACPI_FAILURE (Status)) { if (Status == AE_TYPE) @@ -597,7 +599,7 @@ AcpiExResolveOperands ( /* Highest priority conversion is to type Buffer */ - Status = AcpiExConvertToBuffer (ObjDesc, StackPtr, WalkState); + Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/exstore.c b/sys/contrib/dev/acpica/exstore.c index 82f4fd06521a..f44b42fb2efe 100644 --- a/sys/contrib/dev/acpica/exstore.c +++ b/sys/contrib/dev/acpica/exstore.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exstore - AML Interpreter object store support - * $Revision: 182 $ + * $Revision: 186 $ * *****************************************************************************/ @@ -207,7 +207,8 @@ AcpiExStore ( /* Destination is not a Reference object */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Destination is not a Reference or Constant object [%p]\n", DestDesc)); + "Target is not a Reference or Constant object - %s [%p]\n", + AcpiUtGetObjectTypeName (DestDesc), DestDesc)); ACPI_DUMP_STACK_ENTRY (SourceDesc); ACPI_DUMP_STACK_ENTRY (DestDesc); @@ -261,24 +262,41 @@ AcpiExStore ( * Storing to the Debug object causes the value stored to be * displayed and otherwise has no effect -- see ACPI Specification */ - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Write to Debug Object: ****:\n\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "**** Write to Debug Object: Object %p %s ****:\n\n", + SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %s: ", - AcpiUtGetObjectTypeName (SourceDesc))); + AcpiUtGetObjectTypeName (SourceDesc))); + + if (!AcpiUtValidInternalObject (SourceDesc)) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, + "%p, Invalid Internal Object!\n", SourceDesc)); + break; + } switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) { case ACPI_TYPE_INTEGER: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n", + if (AcpiGbl_IntegerByteWidth == 4) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n", + (UINT32) SourceDesc->Integer.Value)); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "0x%8.8X%8.8X\n", ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value))); + } break; case ACPI_TYPE_BUFFER: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X", - (UINT32) SourceDesc->Buffer.Length)); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]", + (UINT32) SourceDesc->Buffer.Length)); ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer, (SourceDesc->Buffer.Length < 32) ? SourceDesc->Buffer.Length : 32); break; @@ -286,22 +304,22 @@ AcpiExStore ( case ACPI_TYPE_STRING: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length 0x%.2X, \"%s\"\n", - SourceDesc->String.Length, SourceDesc->String.Pointer)); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n", + SourceDesc->String.Length, SourceDesc->String.Pointer)); break; case ACPI_TYPE_PACKAGE: - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Size 0x%.2X Elements Ptr - %p\n", - SourceDesc->Package.Count, SourceDesc->Package.Elements)); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] Elements Ptr - %p\n", + SourceDesc->Package.Count, SourceDesc->Package.Elements)); break; default: ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p\n", - SourceDesc)); + SourceDesc)); break; } @@ -361,60 +379,49 @@ AcpiExStoreObjectToIndex ( { case ACPI_TYPE_PACKAGE: /* - * Storing to a package element is not simple. The source must be - * evaluated and converted to the type of the destination and then the - * source is copied into the destination - we can't just point to the - * source object. - */ - /* + * Storing to a package element. Copy the object and replace + * any existing object with the new object. No implicit + * conversion is performed. + * * The object at *(IndexDesc->Reference.Where) is the * element within the package that is to be modified. * The parent package object is at IndexDesc->Reference.Object */ ObjDesc = *(IndexDesc->Reference.Where); - /* Do the conversion/store */ - - Status = AcpiExStoreObjectToObject (SourceDesc, ObjDesc, &NewDesc, - WalkState); + Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Could not store object to indexed package element\n")); return_ACPI_STATUS (Status); } - /* - * If a new object was created, we must install it as the new - * package element - */ - if (NewDesc != ObjDesc) + if (ObjDesc) { - AcpiUtRemoveReference (ObjDesc); - *(IndexDesc->Reference.Where) = NewDesc; + /* Decrement reference count by the ref count of the parent package */ - /* If same as the original source, add a reference */ - - if (NewDesc == SourceDesc) + for (i = 0; i < ((ACPI_OPERAND_OBJECT *) IndexDesc->Reference.Object)->Common.ReferenceCount; i++) { - AcpiUtAddReference (NewDesc); + AcpiUtRemoveReference (ObjDesc); } + } + + *(IndexDesc->Reference.Where) = NewDesc; - /* Increment reference count by the ref count of the parent package -1 */ + /* Increment reference count by the ref count of the parent package -1 */ - for (i = 1; i < ((ACPI_OPERAND_OBJECT *) IndexDesc->Reference.Object)->Common.ReferenceCount; i++) - { - AcpiUtAddReference (NewDesc); - } + for (i = 1; i < ((ACPI_OPERAND_OBJECT *) IndexDesc->Reference.Object)->Common.ReferenceCount; i++) + { + AcpiUtAddReference (NewDesc); } + break; case ACPI_TYPE_BUFFER_FIELD: /* - * Store into a Buffer (not actually a real BufferField) at a - * location defined by an Index. + * Store into a Buffer or String (not actually a real BufferField) + * at a location defined by an Index. * * The first 8-bit element of the source object is written to the * 8-bit Buffer location defined by the Index destination object, @@ -422,10 +429,13 @@ AcpiExStoreObjectToIndex ( */ /* - * Make sure the target is a Buffer + * Make sure the target is a Buffer or String. An error should + * not happen here, since the ReferenceObject was constructed + * by the INDEX_OP code. */ ObjDesc = IndexDesc->Reference.Object; - if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_BUFFER) + if ((ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_BUFFER) && + (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_STRING)) { return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } @@ -444,13 +454,11 @@ AcpiExStoreObjectToIndex ( break; case ACPI_TYPE_BUFFER: - - Value = SourceDesc->Buffer.Pointer[0]; - break; - case ACPI_TYPE_STRING: - Value = (UINT8) SourceDesc->String.Pointer[0]; + /* Note: Takes advantage of common string/buffer fields */ + + Value = SourceDesc->Buffer.Pointer[0]; break; default: diff --git a/sys/contrib/dev/acpica/exsystem.c b/sys/contrib/dev/acpica/exsystem.c index f74de0795729..39e98a99643d 100644 --- a/sys/contrib/dev/acpica/exsystem.c +++ b/sys/contrib/dev/acpica/exsystem.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exsystem - Interface to OS services - * $Revision: 80 $ + * $Revision: 81 $ * *****************************************************************************/ @@ -246,7 +246,7 @@ AcpiExSystemDoStall ( ACPI_STATUS AcpiExSystemDoSuspend ( - UINT32 HowLong) + ACPI_INTEGER HowLong) { ACPI_STATUS Status; @@ -258,8 +258,7 @@ AcpiExSystemDoSuspend ( AcpiExExitInterpreter (); - AcpiOsSleep ((UINT16) (HowLong / (UINT32) 1000), - (UINT16) (HowLong % (UINT32) 1000)); + AcpiOsSleep (HowLong); /* And now we must get the interpreter again */ diff --git a/sys/contrib/dev/acpica/exutils.c b/sys/contrib/dev/acpica/exutils.c index 4f0c3bf7e6eb..f9d41c744641 100644 --- a/sys/contrib/dev/acpica/exutils.c +++ b/sys/contrib/dev/acpica/exutils.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exutils - interpreter/scanner utilities - * $Revision: 111 $ + * $Revision: 112 $ * *****************************************************************************/ @@ -363,27 +363,27 @@ AcpiExDigitsNeeded ( { UINT32 NumDigits; ACPI_INTEGER CurrentValue; - ACPI_INTEGER Quotient; ACPI_FUNCTION_TRACE ("ExDigitsNeeded"); - /* - * ACPI_INTEGER is unsigned, so we don't worry about a '-' - */ - if ((CurrentValue = Value) == 0) + /* ACPI_INTEGER is unsigned, so we don't worry about a '-' prefix */ + + if (Value == 0) { return_VALUE (1); } + CurrentValue = Value; NumDigits = 0; + /* Count the digits in the requested base */ + while (CurrentValue) { - (void) AcpiUtShortDivide (&CurrentValue, Base, &Quotient, NULL); + (void) AcpiUtShortDivide (CurrentValue, Base, &CurrentValue, NULL); NumDigits++; - CurrentValue = Quotient; } return_VALUE (NumDigits); @@ -446,7 +446,6 @@ AcpiExUnsignedIntegerToString ( UINT32 Count; UINT32 DigitsNeeded; UINT32 Remainder; - ACPI_INTEGER Quotient; ACPI_FUNCTION_ENTRY (); @@ -457,9 +456,8 @@ AcpiExUnsignedIntegerToString ( for (Count = DigitsNeeded; Count > 0; Count--) { - (void) AcpiUtShortDivide (&Value, 10, &Quotient, &Remainder); + (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder); OutString[Count-1] = (char) ('0' + Remainder);\ - Value = Quotient; } } diff --git a/sys/contrib/dev/acpica/hwgpe.c b/sys/contrib/dev/acpica/hwgpe.c index 626836d5463b..06b3cd4b2dd7 100644 --- a/sys/contrib/dev/acpica/hwgpe.c +++ b/sys/contrib/dev/acpica/hwgpe.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: hwgpe - Low level GPE enable/disable/clear functions - * $Revision: 62 $ + * $Revision: 65 $ * *****************************************************************************/ @@ -130,8 +130,8 @@ * * RETURN: Status * - * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must - * already be cleared or set in the parent register + * DESCRIPTION: Write a GPE enable register. Note: The bit for this GPE must + * already be cleared or set in the parent register * EnableForRun mask. * ******************************************************************************/ @@ -170,7 +170,7 @@ AcpiHwWriteGpeEnableReg ( * * PARAMETERS: GpeEventInfo - Info block for the GPE to be cleared * - * RETURN: StatusStatus + * RETURN: Status * * DESCRIPTION: Clear the status bit for a single GPE. * @@ -453,7 +453,7 @@ AcpiHwEnableWakeupGpeBlock ( * * FUNCTION: AcpiHwDisableAllGpes * - * PARAMETERS: None + * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR * * RETURN: Status * @@ -463,7 +463,7 @@ AcpiHwEnableWakeupGpeBlock ( ACPI_STATUS AcpiHwDisableAllGpes ( - void) + UINT32 Flags) { ACPI_STATUS Status; @@ -471,8 +471,8 @@ AcpiHwDisableAllGpes ( ACPI_FUNCTION_TRACE ("HwDisableAllGpes"); - Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock); - Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, Flags); + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, Flags); return_ACPI_STATUS (Status); } @@ -481,7 +481,7 @@ AcpiHwDisableAllGpes ( * * FUNCTION: AcpiHwEnableAllRuntimeGpes * - * PARAMETERS: None + * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR * * RETURN: Status * @@ -491,7 +491,7 @@ AcpiHwDisableAllGpes ( ACPI_STATUS AcpiHwEnableAllRuntimeGpes ( - void) + UINT32 Flags) { ACPI_STATUS Status; @@ -499,7 +499,7 @@ AcpiHwEnableAllRuntimeGpes ( ACPI_FUNCTION_TRACE ("HwEnableAllRuntimeGpes"); - Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, Flags); return_ACPI_STATUS (Status); } @@ -508,7 +508,7 @@ AcpiHwEnableAllRuntimeGpes ( * * FUNCTION: AcpiHwEnableAllWakeupGpes * - * PARAMETERS: None + * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR * * RETURN: Status * @@ -518,7 +518,7 @@ AcpiHwEnableAllRuntimeGpes ( ACPI_STATUS AcpiHwEnableAllWakeupGpes ( - void) + UINT32 Flags) { ACPI_STATUS Status; @@ -526,7 +526,7 @@ AcpiHwEnableAllWakeupGpes ( ACPI_FUNCTION_TRACE ("HwEnableAllWakeupGpes"); - Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, Flags); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/hwregs.c b/sys/contrib/dev/acpica/hwregs.c index 0595010ca192..a5385736c968 100644 --- a/sys/contrib/dev/acpica/hwregs.c +++ b/sys/contrib/dev/acpica/hwregs.c @@ -3,7 +3,7 @@ * * Module Name: hwregs - Read/write access functions for the various ACPI * control and status registers. - * $Revision: 156 $ + * $Revision: 162 $ * ******************************************************************************/ @@ -135,6 +135,7 @@ * RETURN: none * * DESCRIPTION: Clears all fixed and general purpose status bits + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED * ******************************************************************************/ @@ -182,7 +183,7 @@ AcpiHwClearAcpiStatus ( /* Clear the GPE Bits in all GPE registers in all GPE blocks */ - Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, ACPI_ISR); UnlockAndExit: if (Flags & ACPI_MTX_LOCK) @@ -337,8 +338,8 @@ AcpiHwGetBitRegisterInfo ( * ReturnValue - Value that was read from the register * Flags - Lock the hardware or not * - * RETURN: Value is read from specified Register. Value returned is - * normalized to bit0 (is shifted all the way right) + * RETURN: Status and the value read from specified Register. Value + * returned is normalized to bit0 (is shifted all the way right) * * DESCRIPTION: ACPI BitRegister read function. * @@ -375,6 +376,8 @@ AcpiGetRegister ( } } + /* Read from the register */ + Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, BitRegInfo->ParentRegister, &RegisterValue); @@ -406,10 +409,10 @@ AcpiGetRegister ( * * PARAMETERS: RegisterId - ID of ACPI BitRegister to access * Value - (only used on write) value to write to the - * Register, NOT pre-normalized to the bit pos. + * Register, NOT pre-normalized to the bit pos * Flags - Lock the hardware or not * - * RETURN: None + * RETURN: Status * * DESCRIPTION: ACPI Bit Register write function. * @@ -562,10 +565,11 @@ UnlockAndExit: * * FUNCTION: AcpiHwRegisterRead * - * PARAMETERS: UseLock - Mutex hw access. - * RegisterId - RegisterID + Offset. + * PARAMETERS: UseLock - Mutex hw access + * RegisterId - RegisterID + Offset + * ReturnValue - Value that was read from the register * - * RETURN: Value read or written. + * RETURN: Status and the value read. * * DESCRIPTION: Acpi register read function. Registers are read at the * given offset. @@ -681,10 +685,11 @@ UnlockAndExit: * * FUNCTION: AcpiHwRegisterWrite * - * PARAMETERS: UseLock - Mutex hw access. - * RegisterId - RegisterID + Offset. + * PARAMETERS: UseLock - Mutex hw access + * RegisterId - RegisterID + Offset + * Value - The value to write * - * RETURN: Value read or written. + * RETURN: Status * * DESCRIPTION: Acpi register Write function. Registers are written at the * given offset. @@ -807,11 +812,11 @@ UnlockAndExit: * * PARAMETERS: Width - 8, 16, or 32 * Value - Where the value is returned - * Register - GAS register structure + * Reg - GAS register structure * * RETURN: Status * - * DESCRIPTION: Read from either memory, IO, or PCI config space. + * DESCRIPTION: Read from either memory or IO space. * ******************************************************************************/ @@ -821,8 +826,7 @@ AcpiHwLowLevelRead ( UINT32 *Value, ACPI_GENERIC_ADDRESS *Reg) { - ACPI_PCI_ID PciId; - UINT16 PciRegister; + UINT64 Address; ACPI_STATUS Status; @@ -834,43 +838,37 @@ AcpiHwLowLevelRead ( * a non-zero address within. However, don't return an error * because the PM1A/B code must not fail if B isn't present. */ - if ((!Reg) || - (!ACPI_VALID_ADDRESS (Reg->Address))) + if (!Reg) + { + return (AE_OK); + } + + /* Get a local copy of the address. Handles possible alignment issues */ + + ACPI_MOVE_64_TO_64 (&Address, &Reg->Address); + if (!ACPI_VALID_ADDRESS (Address)) { return (AE_OK); } *Value = 0; /* - * Three address spaces supported: - * Memory, IO, or PCI_Config. + * Two address spaces supported: Memory or IO. + * PCI_Config is not supported here because the GAS struct is insufficient */ switch (Reg->AddressSpaceId) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: Status = AcpiOsReadMemory ( - (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), + (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Address), Value, Width); break; case ACPI_ADR_SPACE_SYSTEM_IO: - Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), - Value, Width); - break; - - - case ACPI_ADR_SPACE_PCI_CONFIG: - - PciId.Segment = 0; - PciId.Bus = 0; - PciId.Device = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (Reg->Address)); - PciId.Function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (Reg->Address)); - PciRegister = (UINT16) ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (Reg->Address)); - - Status = AcpiOsReadPciConfiguration (&PciId, PciRegister, + Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Address), Value, Width); break; @@ -883,7 +881,7 @@ AcpiHwLowLevelRead ( ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", *Value, Width, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Reg->Address)), + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Address)), AcpiUtGetRegionName (Reg->AddressSpaceId))); return (Status); @@ -896,11 +894,11 @@ AcpiHwLowLevelRead ( * * PARAMETERS: Width - 8, 16, or 32 * Value - To be written - * Register - GAS register structure + * Reg - GAS register structure * * RETURN: Status * - * DESCRIPTION: Write to either memory, IO, or PCI config space. + * DESCRIPTION: Write to either memory or IO space. * ******************************************************************************/ @@ -910,8 +908,7 @@ AcpiHwLowLevelWrite ( UINT32 Value, ACPI_GENERIC_ADDRESS *Reg) { - ACPI_PCI_ID PciId; - UINT16 PciRegister; + UINT64 Address; ACPI_STATUS Status; @@ -923,46 +920,40 @@ AcpiHwLowLevelWrite ( * a non-zero address within. However, don't return an error * because the PM1A/B code must not fail if B isn't present. */ - if ((!Reg) || - (!ACPI_VALID_ADDRESS (Reg->Address))) + if (!Reg) + { + return (AE_OK); + } + + /* Get a local copy of the address. Handles possible alignment issues */ + + ACPI_MOVE_64_TO_64 (&Address, &Reg->Address); + if (!ACPI_VALID_ADDRESS (Address)) { return (AE_OK); } /* - * Three address spaces supported: - * Memory, IO, or PCI_Config. + * Two address spaces supported: Memory or IO. + * PCI_Config is not supported here because the GAS struct is insufficient */ switch (Reg->AddressSpaceId) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: Status = AcpiOsWriteMemory ( - (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), + (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Address), Value, Width); break; case ACPI_ADR_SPACE_SYSTEM_IO: - Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), + Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Address), Value, Width); break; - case ACPI_ADR_SPACE_PCI_CONFIG: - - PciId.Segment = 0; - PciId.Bus = 0; - PciId.Device = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (Reg->Address)); - PciId.Function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (Reg->Address)); - PciRegister = (UINT16) ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (Reg->Address)); - - Status = AcpiOsWritePciConfiguration (&PciId, PciRegister, - (ACPI_INTEGER) Value, Width); - break; - - default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported address space: %X\n", Reg->AddressSpaceId)); @@ -971,7 +962,7 @@ AcpiHwLowLevelWrite ( ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", Value, Width, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Reg->Address)), + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Address)), AcpiUtGetRegionName (Reg->AddressSpaceId))); return (Status); diff --git a/sys/contrib/dev/acpica/hwsleep.c b/sys/contrib/dev/acpica/hwsleep.c index c8ade38349f4..def2e970c5db 100644 --- a/sys/contrib/dev/acpica/hwsleep.c +++ b/sys/contrib/dev/acpica/hwsleep.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface - * $Revision: 69 $ + * $Revision: 70 $ * *****************************************************************************/ @@ -380,14 +380,14 @@ AcpiEnterSleepState ( * 1) Disable/Clear all GPEs * 2) Enable all wakeup GPEs */ - Status = AcpiHwDisableAllGpes (); + Status = AcpiHwDisableAllGpes (ACPI_ISR); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } AcpiGbl_SystemAwakeAndRunning = FALSE; - Status = AcpiHwEnableAllWakeupGpes (); + Status = AcpiHwEnableAllWakeupGpes (ACPI_ISR); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -532,14 +532,14 @@ AcpiEnterSleepStateS4bios ( * 1) Disable/Clear all GPEs * 2) Enable all wakeup GPEs */ - Status = AcpiHwDisableAllGpes (); + Status = AcpiHwDisableAllGpes (ACPI_ISR); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } AcpiGbl_SystemAwakeAndRunning = FALSE; - Status = AcpiHwEnableAllWakeupGpes (); + Status = AcpiHwEnableAllWakeupGpes (ACPI_ISR); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -571,6 +571,7 @@ AcpiEnterSleepStateS4bios ( * RETURN: Status * * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep + * Called with interrupts ENABLED. * ******************************************************************************/ @@ -666,14 +667,14 @@ AcpiLeaveSleepState ( * 1) Disable/Clear all GPEs * 2) Enable all runtime GPEs */ - Status = AcpiHwDisableAllGpes (); + Status = AcpiHwDisableAllGpes (ACPI_NOT_ISR); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } AcpiGbl_SystemAwakeAndRunning = TRUE; - Status = AcpiHwEnableAllRuntimeGpes (); + Status = AcpiHwEnableAllRuntimeGpes (ACPI_NOT_ISR); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/hwtimer.c b/sys/contrib/dev/acpica/hwtimer.c index fa037ff00418..c08abf350036 100644 --- a/sys/contrib/dev/acpica/hwtimer.c +++ b/sys/contrib/dev/acpica/hwtimer.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Name: hwtimer.c - ACPI Power Management Timer Interface - * $Revision: 26 $ + * $Revision: 28 $ * *****************************************************************************/ @@ -125,11 +125,11 @@ * * FUNCTION: AcpiGetTimerResolution * - * PARAMETERS: none + * PARAMETERS: Resolution - Where the resolution is returned * - * RETURN: Number of bits of resolution in the PM Timer (24 or 32). + * RETURN: Status and timer resolution * - * DESCRIPTION: Obtains resolution of the ACPI PM Timer. + * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits). * ******************************************************************************/ @@ -162,11 +162,11 @@ AcpiGetTimerResolution ( * * FUNCTION: AcpiGetTimer * - * PARAMETERS: none + * PARAMETERS: Ticks - Where the timer value is returned * - * RETURN: Current value of the ACPI PM Timer (in ticks). + * RETURN: Status and current ticks * - * DESCRIPTION: Obtains current value of ACPI PM Timer. + * DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks). * ******************************************************************************/ @@ -195,11 +195,11 @@ AcpiGetTimer ( * * FUNCTION: AcpiGetTimerDuration * - * PARAMETERS: StartTicks - * EndTicks - * TimeElapsed + * PARAMETERS: StartTicks - Starting timestamp + * EndTicks - End timestamp + * TimeElapsed - Where the elapsed time is returned * - * RETURN: TimeElapsed + * RETURN: Status and TimeElapsed * * DESCRIPTION: Computes the time elapsed (in microseconds) between two * PM Timer time stamps, taking into account the possibility of @@ -213,7 +213,7 @@ AcpiGetTimer ( * Note that this function accommodates only a single timer * rollover. Thus for 24-bit timers, this function should only * be used for calculating durations less than ~4.6 seconds - * (~20 minutes for 32-bit timers) -- calculations below + * (~20 minutes for 32-bit timers) -- calculations below: * * 2**24 Ticks / 3,600,000 Ticks/Sec = 4.66 sec * 2**32 Ticks / 3,600,000 Ticks/Sec = 1193 sec or 19.88 minutes @@ -226,10 +226,9 @@ AcpiGetTimerDuration ( UINT32 EndTicks, UINT32 *TimeElapsed) { - UINT32 DeltaTicks = 0; - UINT64_OVERLAY NormalizedTicks; ACPI_STATUS Status; - ACPI_INTEGER OutQuotient; + UINT32 DeltaTicks; + ACPI_INTEGER Quotient; ACPI_FUNCTION_TRACE ("AcpiGetTimerDuration"); @@ -242,8 +241,7 @@ AcpiGetTimerDuration ( /* * Compute Tick Delta: - * ------------------- - * Handle (max one) timer rollovers on 24- versus 32-bit timers. + * Handle (max one) timer rollovers on 24-bit versus 32-bit timers. */ if (StartTicks < EndTicks) { @@ -264,26 +262,21 @@ AcpiGetTimerDuration ( DeltaTicks = (0xFFFFFFFF - StartTicks) + EndTicks; } } - else + else /* StartTicks == EndTicks */ { *TimeElapsed = 0; return_ACPI_STATUS (AE_OK); } /* - * Compute Duration: - * ----------------- - * - * Requires a 64-bit divide: + * Compute Duration (Requires a 64-bit multiply and divide): * * TimeElapsed = (DeltaTicks * 1000000) / PM_TIMER_FREQUENCY; */ - NormalizedTicks.Full = ((UINT64) DeltaTicks) * 1000000; - - Status = AcpiUtShortDivide (&NormalizedTicks.Full, PM_TIMER_FREQUENCY, - &OutQuotient, NULL); + Status = AcpiUtShortDivide (((UINT64) DeltaTicks) * 1000000, + PM_TIMER_FREQUENCY, &Quotient, NULL); - *TimeElapsed = (UINT32) OutQuotient; + *TimeElapsed = (UINT32) Quotient; return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/nsaccess.c b/sys/contrib/dev/acpica/nsaccess.c index 5abee9ecfe3a..f8829b53a856 100644 --- a/sys/contrib/dev/acpica/nsaccess.c +++ b/sys/contrib/dev/acpica/nsaccess.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nsaccess - Top-level functions for accessing ACPI namespace - * $Revision: 182 $ + * $Revision: 184 $ * ******************************************************************************/ @@ -245,8 +245,10 @@ AcpiNsRootInitialize (void) #if defined (_ACPI_ASL_COMPILER) || defined (_ACPI_DUMP_APP) - /* iASL Compiler cheats by putting parameter count in the OwnerID */ - + /* + * iASL Compiler cheats by putting parameter count + * in the OwnerID + */ NewNode->OwnerId = ObjDesc->Method.ParamCount; #else /* Mark this as a very SPECIAL method */ @@ -290,6 +292,7 @@ AcpiNsRootInitialize (void) 1, &ObjDesc->Mutex.Semaphore); if (ACPI_FAILURE (Status)) { + AcpiUtRemoveReference (ObjDesc); goto UnlockAndExit; } @@ -307,6 +310,7 @@ AcpiNsRootInitialize (void) &ObjDesc->Mutex.Semaphore); if (ACPI_FAILURE (Status)) { + AcpiUtRemoveReference (ObjDesc); goto UnlockAndExit; } } @@ -324,7 +328,8 @@ AcpiNsRootInitialize (void) /* Store pointer to value descriptor in the Node */ - Status = AcpiNsAttachObject (NewNode, ObjDesc, ACPI_GET_OBJECT_TYPE (ObjDesc)); + Status = AcpiNsAttachObject (NewNode, ObjDesc, + ACPI_GET_OBJECT_TYPE (ObjDesc)); /* Remove local reference to the object */ @@ -565,7 +570,8 @@ AcpiNsLookup ( Type = ThisNode->Type; ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Prefix-only Pathname (Zero name segments), Flags=%X\n", Flags)); + "Prefix-only Pathname (Zero name segments), Flags=%X\n", + Flags)); break; case AML_DUAL_NAME_PREFIX: @@ -661,7 +667,7 @@ AcpiNsLookup ( /* Try to find the single (4 character) ACPI name */ Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode, - InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); + InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) diff --git a/sys/contrib/dev/acpica/nsalloc.c b/sys/contrib/dev/acpica/nsalloc.c index 5ab596ad689e..7b0a7045c382 100644 --- a/sys/contrib/dev/acpica/nsalloc.c +++ b/sys/contrib/dev/acpica/nsalloc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nsalloc - Namespace allocation and deletion utilities - * $Revision: 87 $ + * $Revision: 88 $ * ******************************************************************************/ @@ -600,15 +600,15 @@ AcpiNsDeleteNamespaceSubtree ( /* Check if this node has any children */ - if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, 0)) + if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, NULL)) { /* * There is at least one child of this node, * visit the node */ Level++; - ParentNode = ChildNode; - ChildNode = 0; + ParentNode = ChildNode; + ChildNode = NULL; } } else @@ -763,8 +763,8 @@ AcpiNsDeleteNamespaceByOwner ( * visit the node */ Level++; - ParentNode = ChildNode; - ChildNode = NULL; + ParentNode = ChildNode; + ChildNode = NULL; } else if (ChildNode->OwnerId == OwnerId) { diff --git a/sys/contrib/dev/acpica/nsdump.c b/sys/contrib/dev/acpica/nsdump.c index 2a01996099bc..f81865953eab 100644 --- a/sys/contrib/dev/acpica/nsdump.c +++ b/sys/contrib/dev/acpica/nsdump.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsdump - table dumping routines for debug - * $Revision: 158 $ + * $Revision: 160 $ * *****************************************************************************/ @@ -282,7 +282,8 @@ AcpiNsDumpOneObject ( if (!AcpiUtValidAcpiName (ThisNode->Name.Integer)) { - ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", ThisNode->Name.Integer)); + ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", + ThisNode->Name.Integer)); } /* @@ -313,9 +314,8 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_PROCESSOR: AcpiOsPrintf ("ID %X Len %.4X Addr %p\n", - ObjDesc->Processor.ProcId, - ObjDesc->Processor.Length, - (char *) ObjDesc->Processor.Address); + ObjDesc->Processor.ProcId, ObjDesc->Processor.Length, + (char *) ObjDesc->Processor.Address); break; @@ -328,16 +328,15 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_METHOD: AcpiOsPrintf ("Args %X Len %.4X Aml %p\n", - (UINT32) ObjDesc->Method.ParamCount, - ObjDesc->Method.AmlLength, - ObjDesc->Method.AmlStart); + (UINT32) ObjDesc->Method.ParamCount, + ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart); break; case ACPI_TYPE_INTEGER: AcpiOsPrintf ("= %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); break; @@ -346,7 +345,7 @@ AcpiNsDumpOneObject ( if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) { AcpiOsPrintf ("Elements %.2X\n", - ObjDesc->Package.Count); + ObjDesc->Package.Count); } else { @@ -391,12 +390,13 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_REGION: - AcpiOsPrintf ("[%s]", AcpiUtGetRegionName (ObjDesc->Region.SpaceId)); + AcpiOsPrintf ("[%s]", + AcpiUtGetRegionName (ObjDesc->Region.SpaceId)); if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) { AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n", - ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), - ObjDesc->Region.Length); + ACPI_FORMAT_UINT64 (ObjDesc->Region.Address), + ObjDesc->Region.Length); } else { @@ -408,7 +408,7 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_LOCAL_REFERENCE: AcpiOsPrintf ("[%s]\n", - AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode)); + AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode)); break; @@ -418,7 +418,7 @@ AcpiNsDumpOneObject ( ObjDesc->BufferField.BufferObj->Buffer.Node) { AcpiOsPrintf ("Buf [%4.4s]", - AcpiUtGetNodeName (ObjDesc->BufferField.BufferObj->Buffer.Node)); + AcpiUtGetNodeName (ObjDesc->BufferField.BufferObj->Buffer.Node)); } break; @@ -426,30 +426,31 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_LOCAL_REGION_FIELD: AcpiOsPrintf ("Rgn [%4.4s]", - AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node)); + AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node)); break; case ACPI_TYPE_LOCAL_BANK_FIELD: AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]", - AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node), - AcpiUtGetNodeName (ObjDesc->BankField.BankObj->CommonField.Node)); + AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node), + AcpiUtGetNodeName (ObjDesc->BankField.BankObj->CommonField.Node)); break; case ACPI_TYPE_LOCAL_INDEX_FIELD: AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]", - AcpiUtGetNodeName (ObjDesc->IndexField.IndexObj->CommonField.Node), - AcpiUtGetNodeName (ObjDesc->IndexField.DataObj->CommonField.Node)); + AcpiUtGetNodeName (ObjDesc->IndexField.IndexObj->CommonField.Node), + AcpiUtGetNodeName (ObjDesc->IndexField.DataObj->CommonField.Node)); break; case ACPI_TYPE_LOCAL_ALIAS: case ACPI_TYPE_LOCAL_METHOD_ALIAS: - AcpiOsPrintf ("Target %4.4s (%p)\n", AcpiUtGetNodeName (ObjDesc), ObjDesc); + AcpiOsPrintf ("Target %4.4s (%p)\n", + AcpiUtGetNodeName (ObjDesc), ObjDesc); break; default: @@ -468,10 +469,10 @@ AcpiNsDumpOneObject ( case ACPI_TYPE_LOCAL_INDEX_FIELD: AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n", - (ObjDesc->CommonField.BaseByteOffset * 8) - + ObjDesc->CommonField.StartFieldBitOffset, - ObjDesc->CommonField.BitLength, - ObjDesc->CommonField.AccessByteWidth); + (ObjDesc->CommonField.BaseByteOffset * 8) + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessByteWidth); break; default: @@ -574,13 +575,14 @@ AcpiNsDumpOneObject ( if (ObjType > ACPI_TYPE_LOCAL_MAX) { - AcpiOsPrintf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", ObjType); + AcpiOsPrintf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", + ObjType); BytesToDump = 32; } else { AcpiOsPrintf ("(Ptr to ACPI Object type %s, %X)\n", - AcpiUtGetTypeName (ObjType), ObjType); + AcpiUtGetTypeName (ObjType), ObjType); BytesToDump = sizeof (ACPI_OPERAND_OBJECT); } break; @@ -588,8 +590,9 @@ AcpiNsDumpOneObject ( default: - AcpiOsPrintf ("(String or Buffer ptr - not an object descriptor) [%s]\n", - AcpiUtGetDescriptorName (ObjDesc)); + AcpiOsPrintf ( + "(String or Buffer ptr - not an object descriptor) [%s]\n", + AcpiUtGetDescriptorName (ObjDesc)); BytesToDump = 16; break; } @@ -658,7 +661,7 @@ Cleanup: * FUNCTION: AcpiNsDumpObjects * * PARAMETERS: Type - Object type to be dumped - * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX + * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX * for an effectively unlimited depth. * OwnerId - Dump only objects owned by this ID. Use * ACPI_UINT32_MAX to match all owners. diff --git a/sys/contrib/dev/acpica/nsdumpdv.c b/sys/contrib/dev/acpica/nsdumpdv.c index 0ea37d3bf1dd..5e9110715e86 100644 --- a/sys/contrib/dev/acpica/nsdumpdv.c +++ b/sys/contrib/dev/acpica/nsdumpdv.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsdump - table dumping routines for debug - * $Revision: 10 $ + * $Revision: 12 $ * *****************************************************************************/ @@ -168,10 +168,10 @@ AcpiNsDumpOneDevice ( ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " ")); } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", - Info->HardwareId.Value, - ACPI_FORMAT_UINT64 (Info->Address), - Info->CurrentStatus)); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, + " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", + Info->HardwareId.Value, ACPI_FORMAT_UINT64 (Info->Address), + Info->CurrentStatus)); ACPI_MEM_FREE (Info); } @@ -206,13 +206,14 @@ AcpiNsDumpRootDevices (void) return; } - Status = AcpiGetHandle (0, ACPI_NS_SYSTEM_BUS, &SysBusHandle); + Status = AcpiGetHandle (NULL, ACPI_NS_SYSTEM_BUS, &SysBusHandle); if (ACPI_FAILURE (Status)) { return; } - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Display of all devices in the namespace:\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, + "Display of all devices in the namespace:\n")); Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, diff --git a/sys/contrib/dev/acpica/nseval.c b/sys/contrib/dev/acpica/nseval.c index 93cf067d9c4f..b5bba60d4d86 100644 --- a/sys/contrib/dev/acpica/nseval.c +++ b/sys/contrib/dev/acpica/nseval.c @@ -2,7 +2,7 @@ * * Module Name: nseval - Object evaluation interfaces -- includes control * method lookup and execution. - * $Revision: 127 $ + * $Revision: 129 $ * ******************************************************************************/ @@ -132,14 +132,9 @@ * * FUNCTION: AcpiNsEvaluateRelative * - * PARAMETERS: Handle - The relative containing object - * Pathname - Name of method to execute, If NULL, the + * PARAMETERS: Pathname - Name of method to execute, If NULL, the * handle is the object to execute - * Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. + * Info - Method info block * * RETURN: Status * @@ -219,8 +214,7 @@ AcpiNsEvaluateRelative ( } /* - * Now that we have a handle to the object, we can attempt - * to evaluate it. + * Now that we have a handle to the object, we can attempt to evaluate it. */ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Pathname, Node, AcpiNsGetAttachedObject (Node))); @@ -246,9 +240,9 @@ Cleanup1: * * PARAMETERS: Pathname - Fully qualified pathname to the object * Info - Contains: - * ReturnObject - Where to put method's return value (if + * ReturnObject - Where to put method's return value (if * any). If NULL, no value is returned. - * Params - List of parameters to pass to the method, + * Params - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. * @@ -297,14 +291,14 @@ AcpiNsEvaluateByName ( if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object at [%s] was not found, status=%.4X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Object at [%s] was not found, status=%.4X\n", Pathname, Status)); goto Cleanup; } /* - * Now that we have a handle to the object, we can attempt - * to evaluate it. + * Now that we have a handle to the object, we can attempt to evaluate it. */ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Pathname, Info->Node, AcpiNsGetAttachedObject (Info->Node))); @@ -392,9 +386,8 @@ AcpiNsEvaluateByHandle ( } /* - * For a method alias, we must grab the actual method node - * so that proper scoping context will be established - * before execution. + * For a method alias, we must grab the actual method node so that proper + * scoping context will be established before execution. */ if (AcpiNsGetType (Info->Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) { @@ -404,11 +397,9 @@ AcpiNsEvaluateByHandle ( /* * Two major cases here: * 1) The object is an actual control method -- execute it. - * 2) The object is not a method -- just return it's current - * value + * 2) The object is not a method -- just return it's current value * - * In both cases, the namespace is unlocked by the - * AcpiNs* procedure + * In both cases, the namespace is unlocked by the AcpiNs* procedure */ if (AcpiNsGetType (Info->Node) == ACPI_TYPE_METHOD) { @@ -420,15 +411,13 @@ AcpiNsEvaluateByHandle ( else { /* - * Case 2) Object is NOT a method, just return its - * current value + * Case 2) Object is NOT a method, just return its current value */ Status = AcpiNsGetObjectValue (Info); } /* - * Check if there is a return value on the stack that must - * be dealt with + * Check if there is a return value on the stack that must be dealt with */ if (Status == AE_CTRL_RETURN_VALUE) { @@ -438,8 +427,8 @@ AcpiNsEvaluateByHandle ( } /* - * Namespace was unlocked by the handling AcpiNs* function, - * so we just return + * Namespace was unlocked by the handling AcpiNs* function, so we + * just return */ return_ACPI_STATUS (Status); } @@ -449,12 +438,7 @@ AcpiNsEvaluateByHandle ( * * FUNCTION: AcpiNsExecuteControlMethod * - * PARAMETERS: MethodNode - The method to execute - * Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * ReturnObjDesc - List of result objects to be returned - * from the method. + * PARAMETERS: Info - Method info block (w/params) * * RETURN: Status * @@ -526,8 +510,7 @@ AcpiNsExecuteControlMethod ( * * FUNCTION: AcpiNsGetObjectValue * - * PARAMETERS: Node - The object - * ReturnObjDesc - Where the objects value is returned + * PARAMETERS: Info - Method info block (w/params) * * RETURN: Status * @@ -549,28 +532,25 @@ AcpiNsGetObjectValue ( /* - * Objects require additional resolution steps (e.g., the - * Node may be a field that must be read, etc.) -- we can't just grab - * the object out of the node. + * Objects require additional resolution steps (e.g., the Node may be a + * field that must be read, etc.) -- we can't just grab the object out of + * the node. */ /* - * Use ResolveNodeToValue() to get the associated value. This call - * always deletes ObjDesc (allocated above). + * Use ResolveNodeToValue() to get the associated value. This call always + * deletes ObjDesc (allocated above). * - * NOTE: we can get away with passing in NULL for a walk state - * because ObjDesc is guaranteed to not be a reference to either - * a method local or a method argument (because this interface can only be - * called from the AcpiEvaluate external interface, never called from - * a running control method.) + * NOTE: we can get away with passing in NULL for a walk state because + * ObjDesc is guaranteed to not be a reference to either a method local or + * a method argument (because this interface can only be called from the + * AcpiEvaluate external interface, never called from a running method.) * - * Even though we do not directly invoke the interpreter - * for this, we must enter it because we could access an opregion. - * The opregion access code assumes that the interpreter - * is locked. + * Even though we do not directly invoke the interpreter for this, we must + * enter it because we could access an opregion. The opregion access code + * assumes that the interpreter is locked. * - * We must release the namespace lock before entering the - * intepreter. + * We must release the namespace lock before entering the intepreter. */ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) @@ -583,17 +563,19 @@ AcpiNsGetObjectValue ( { Status = AcpiExResolveNodeToValue (&ResolvedNode, NULL); /* - * If AcpiExResolveNodeToValue() succeeded, the return value was - * placed in ResolvedNode. + * If AcpiExResolveNodeToValue() succeeded, the return value was placed + * in ResolvedNode. */ AcpiExExitInterpreter (); if (ACPI_SUCCESS (Status)) { Status = AE_CTRL_RETURN_VALUE; - Info->ReturnObject = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ResolvedNode); + Info->ReturnObject = ACPI_CAST_PTR + (ACPI_OPERAND_OBJECT, ResolvedNode); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", - Info->ReturnObject, AcpiUtGetObjectTypeName (Info->ReturnObject))); + Info->ReturnObject, + AcpiUtGetObjectTypeName (Info->ReturnObject))); } } diff --git a/sys/contrib/dev/acpica/nsinit.c b/sys/contrib/dev/acpica/nsinit.c index c370af874f77..207365c0bddd 100644 --- a/sys/contrib/dev/acpica/nsinit.c +++ b/sys/contrib/dev/acpica/nsinit.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsinit - namespace initialization - * $Revision: 60 $ + * $Revision: 62 $ * *****************************************************************************/ @@ -152,7 +152,8 @@ AcpiNsInitializeObjects ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "**** Starting initialization of namespace objects ****\n")); - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Completing Region/Field/Buffer/Package initialization:")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "Completing Region/Field/Buffer/Package initialization:")); /* Set all init info to zero */ @@ -218,7 +219,8 @@ AcpiNsInitializeDevices ( Info.Num_STA = 0; Info.Num_INI = 0; - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Executing all Device _STA and_INI methods:")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "Executing all Device _STA and_INI methods:")); Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) @@ -339,8 +341,8 @@ AcpiNsInitOneObject ( } /* - * Each of these types can contain executable AML code within - * the declaration. + * Each of these types can contain executable AML code within the + * declaration. */ switch (Type) { @@ -350,21 +352,18 @@ AcpiNsInitOneObject ( Status = AcpiDsGetRegionArguments (ObjDesc); break; - case ACPI_TYPE_BUFFER_FIELD: Info->FieldInit++; Status = AcpiDsGetBufferFieldArguments (ObjDesc); break; - case ACPI_TYPE_BUFFER: Info->BufferInit++; Status = AcpiDsGetBufferArguments (ObjDesc); break; - case ACPI_TYPE_PACKAGE: Info->PackageInit++; @@ -385,16 +384,18 @@ AcpiNsInitOneObject ( AcpiFormatException (Status))); } - /* Print a dot for each object unless we are going to print the entire pathname */ - + /* + * Print a dot for each object unless we are going to print the entire + * pathname + */ if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); } /* - * We ignore errors from above, and always return OK, since - * we don't want to abort the walk on any single error. + * We ignore errors from above, and always return OK, since we don't want + * to abort the walk on any single error. */ AcpiExExitInterpreter (); return (AE_OK); @@ -450,7 +451,8 @@ AcpiNsInitOneDevice ( return_ACPI_STATUS (AE_OK); } - if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) && (!(AcpiDbgLevel & ACPI_LV_INFO))) + if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) && + (!(AcpiDbgLevel & ACPI_LV_INFO))) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); } @@ -525,6 +527,5 @@ AcpiNsInitOneDevice ( Status = AcpiGbl_InitHandler (Pinfo.Node, ACPI_INIT_DEVICE_INI); } - return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/nsload.c b/sys/contrib/dev/acpica/nsload.c index 766706ce8223..1f84b686fb60 100644 --- a/sys/contrib/dev/acpica/nsload.c +++ b/sys/contrib/dev/acpica/nsload.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsload - namespace loading/expanding/contracting procedures - * $Revision: 67 $ + * $Revision: 69 $ * *****************************************************************************/ @@ -168,13 +168,15 @@ AcpiNsLoadTable ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n", TableDesc->AmlStart)); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n", + TableDesc->AmlStart)); /* Ignore table if there is no AML contained within */ if (!TableDesc->AmlLength) { - ACPI_REPORT_WARNING (("Zero-length AML block in table [%4.4s]\n", TableDesc->Pointer->Signature)); + ACPI_REPORT_WARNING (("Zero-length AML block in table [%4.4s]\n", + TableDesc->Pointer->Signature)); return_ACPI_STATUS (AE_OK); } @@ -187,7 +189,8 @@ AcpiNsLoadTable ( * to another control method, we can't continue parsing * because we don't know how many arguments to parse next! */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Loading table into namespace ****\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "**** Loading table into namespace ****\n")); Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) @@ -279,7 +282,6 @@ AcpiNsLoadTableByType ( { TableDesc->LoadedIntoNamespace = TRUE; } - break; @@ -341,7 +343,6 @@ AcpiNsLoadTableByType ( TableDesc = TableDesc->Next; } - break; @@ -443,7 +444,7 @@ AcpiNsDeleteSubtree ( ParentHandle = StartHandle; - ChildHandle = 0; + ChildHandle = NULL; Level = 1; /* @@ -466,7 +467,7 @@ AcpiNsDeleteSubtree ( /* Check if this object has any children */ if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, ChildHandle, - 0, &Dummy))) + NULL, &Dummy))) { /* * There is at least one child of this object, @@ -474,7 +475,7 @@ AcpiNsDeleteSubtree ( */ Level++; ParentHandle = ChildHandle; - ChildHandle = 0; + ChildHandle = NULL; } } else diff --git a/sys/contrib/dev/acpica/nsnames.c b/sys/contrib/dev/acpica/nsnames.c index 0696b16da19d..0680d3bfe18d 100644 --- a/sys/contrib/dev/acpica/nsnames.c +++ b/sys/contrib/dev/acpica/nsnames.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nsnames - Name manipulation and search - * $Revision: 84 $ + * $Revision: 86 $ * ******************************************************************************/ @@ -281,7 +281,12 @@ AcpiNsGetPathnameLength ( NextNode = AcpiNsGetParentNode (NextNode); } - return (Size + 1); + if (!Size) + { + Size = 1; /* Root node case */ + } + + return (Size + 1); /* +1 for null string terminator */ } @@ -334,7 +339,8 @@ AcpiNsHandleToPathname ( AcpiNsBuildExternalPath (Node, RequiredSize, Buffer->Pointer); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n", (char *) Buffer->Pointer, (UINT32) RequiredSize)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n", + (char *) Buffer->Pointer, (UINT32) RequiredSize)); return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/nssearch.c b/sys/contrib/dev/acpica/nssearch.c index 03f6cc435ca0..cdef414c7b1d 100644 --- a/sys/contrib/dev/acpica/nssearch.c +++ b/sys/contrib/dev/acpica/nssearch.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: nssearch - Namespace search - * $Revision: 101 $ + * $Revision: 103 $ * ******************************************************************************/ @@ -172,8 +172,10 @@ AcpiNsSearchNode ( ScopeName = AcpiNsGetExternalPathname (Node); if (ScopeName) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching %s (%p) For [%4.4s] (%s)\n", - ScopeName, Node, (char *) &TargetName, AcpiUtGetTypeName (Type))); + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Searching %s (%p) For [%4.4s] (%s)\n", + ScopeName, Node, (char *) &TargetName, + AcpiUtGetTypeName (Type))); ACPI_MEM_FREE (ScopeName); } @@ -244,7 +246,7 @@ AcpiNsSearchNode ( * PARAMETERS: *TargetName - Ascii ACPI name to search for * *Node - Starting node where search will begin * Type - Object type to match - * **ReturnNode - Where the matched Named Obj is returned + * **ReturnNode - Where the matched Node is returned * * RETURN: Status * @@ -279,14 +281,14 @@ AcpiNsSearchParentTree ( ParentNode = AcpiNsGetParentNode (Node); /* - * If there is no parent (i.e., we are at the root) or - * type is "local", we won't be searching the parent tree. + * If there is no parent (i.e., we are at the root) or type is "local", + * we won't be searching the parent tree. */ if (!ParentNode) { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n", (char *) &TargetName)); - return_ACPI_STATUS (AE_NOT_FOUND); + return_ACPI_STATUS (AE_NOT_FOUND); } if (AcpiNsLocal (Type)) @@ -299,11 +301,12 @@ AcpiNsSearchParentTree ( /* Search the parent tree */ - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching parent for %4.4s\n", (char *) &TargetName)); + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Searching parent [%4.4s] for [%4.4s]\n", + AcpiUtGetNodeName (ParentNode), (char *) &TargetName)); /* - * Search parents until found the target or we have backed up to - * the root + * Search parents until target is found or we have backed up to the root */ while (ParentNode) { @@ -313,7 +316,7 @@ AcpiNsSearchParentTree ( * the actual name we are searching for. Typechecking comes later. */ Status = AcpiNsSearchNode (TargetName, ParentNode, - ACPI_TYPE_ANY, ReturnNode); + ACPI_TYPE_ANY, ReturnNode); if (ACPI_SUCCESS (Status)) { return_ACPI_STATUS (Status); @@ -378,7 +381,8 @@ AcpiNsSearchAndEnter ( if (!Node || !TargetName || !ReturnNode) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null param: Node %p Name %X ReturnNode %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Null param: Node %p Name %X ReturnNode %p\n", Node, TargetName, ReturnNode)); ACPI_REPORT_ERROR (("NsSearchAndEnter: Null parameter\n")); @@ -418,23 +422,21 @@ AcpiNsSearchAndEnter ( } /* - * The name was not found. If we are NOT performing the - * first pass (name entry) of loading the namespace, search - * the parent tree (all the way to the root if necessary.) - * We don't want to perform the parent search when the - * namespace is actually being loaded. We want to perform - * the search when namespace references are being resolved - * (load pass 2) and during the execution phase. + * The name was not found. If we are NOT performing the first pass + * (name entry) of loading the namespace, search the parent tree (all the + * way to the root if necessary.) We don't want to perform the parent + * search when the namespace is actually being loaded. We want to perform + * the search when namespace references are being resolved (load pass 2) + * and during the execution phase. */ if ((InterpreterMode != ACPI_IMODE_LOAD_PASS1) && (Flags & ACPI_NS_SEARCH_PARENT)) { /* - * Not found at this level - search parent tree according - * to ACPI specification + * Not found at this level - search parent tree according to the + * ACPI specification */ - Status = AcpiNsSearchParentTree (TargetName, Node, - Type, ReturnNode); + Status = AcpiNsSearchParentTree (TargetName, Node, Type, ReturnNode); if (ACPI_SUCCESS (Status)) { return_ACPI_STATUS (Status); @@ -446,7 +448,8 @@ AcpiNsSearchAndEnter ( */ if (InterpreterMode == ACPI_IMODE_EXECUTE) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s Not found in %p [Not adding]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "%4.4s Not found in %p [Not adding]\n", (char *) &TargetName, Node)); return_ACPI_STATUS (AE_NOT_FOUND); diff --git a/sys/contrib/dev/acpica/nsutils.c b/sys/contrib/dev/acpica/nsutils.c index e8eb69101f33..58e8c88603bf 100644 --- a/sys/contrib/dev/acpica/nsutils.c +++ b/sys/contrib/dev/acpica/nsutils.c @@ -2,7 +2,7 @@ * * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing * parents and siblings and Scope manipulation - * $Revision: 134 $ + * $Revision: 136 $ * *****************************************************************************/ @@ -160,13 +160,15 @@ AcpiNsReportError ( { /* There is a non-ascii character in the name */ - AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)\n", *(ACPI_CAST_PTR (UINT32, InternalName))); + AcpiOsPrintf ("[0x%4.4X] (NON-ASCII)\n", + *(ACPI_CAST_PTR (UINT32, InternalName))); } else { /* Convert path to external format */ - Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, InternalName, NULL, &Name); + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, + InternalName, NULL, &Name); /* Print target name */ @@ -221,7 +223,8 @@ AcpiNsReportMethodError ( if (Path) { - Status = AcpiNsGetNodeByPath (Path, PrefixNode, ACPI_NS_NO_UPSEARCH, &Node); + Status = AcpiNsGetNodeByPath (Path, PrefixNode, + ACPI_NS_NO_UPSEARCH, &Node); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("ReportMethodError: Could not get node\n"); @@ -262,7 +265,7 @@ AcpiNsPrintNodePathname ( return; } - /* Convert handle to a full pathname and print it (with supplied message) */ + /* Convert handle to full pathname and print it (with supplied message) */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; @@ -410,13 +413,11 @@ AcpiNsGetInternalNameLength ( Info->FullyQualified = FALSE; /* - * For the internal name, the required length is 4 bytes - * per segment, plus 1 each for RootPrefix, MultiNamePrefixOp, - * segment count, trailing null (which is not really needed, - * but no there's harm in putting it there) + * For the internal name, the required length is 4 bytes per segment, plus + * 1 each for RootPrefix, MultiNamePrefixOp, segment count, trailing null + * (which is not really needed, but no there's harm in putting it there) * - * strlen() + 1 covers the first NameSeg, which has no - * path separator + * strlen() + 1 covers the first NameSeg, which has no path separator */ if (AcpiNsValidRootPrefix (NextExternalChar[0])) { @@ -436,10 +437,9 @@ AcpiNsGetInternalNameLength ( } /* - * Determine the number of ACPI name "segments" by counting - * the number of path separators within the string. Start - * with one segment since the segment count is (# separators) - * + 1, and zero separators is ok. + * Determine the number of ACPI name "segments" by counting the number of + * path separators within the string. Start with one segment since the + * segment count is [(# separators) + 1], and zero separators is ok. */ if (*NextExternalChar) { @@ -745,7 +745,8 @@ AcpiNsExternalizeName ( /* <count> 4-byte names */ NamesIndex = PrefixLength + 2; - NumSegments = (ACPI_NATIVE_UINT) (UINT8) InternalName[(ACPI_NATIVE_UINT) (PrefixLength + 1)]; + NumSegments = (ACPI_NATIVE_UINT) (UINT8) + InternalName[(ACPI_NATIVE_UINT) (PrefixLength + 1)]; break; case AML_DUAL_NAME_PREFIX: @@ -793,7 +794,7 @@ AcpiNsExternalizeName ( } /* - * Build ConvertedName... + * Build ConvertedName */ *ConvertedName = ACPI_MEM_CALLOCATE (RequiredLength); if (!(*ConvertedName)) @@ -886,7 +887,7 @@ AcpiNsMapHandleToNode ( * * PARAMETERS: Node - Node to be converted to a Handle * - * RETURN: An USER ACPI_HANDLE + * RETURN: A user handle * * DESCRIPTION: Convert a real Node to a namespace handle * @@ -1115,7 +1116,8 @@ AcpiNsFindParentName ( ParentNode = AcpiNsGetParentNode (ChildNode); if (ParentNode) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Parent of %p [%4.4s] is %p [%4.4s]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Parent of %p [%4.4s] is %p [%4.4s]\n", ChildNode, AcpiUtGetNodeName (ChildNode), ParentNode, AcpiUtGetNodeName (ParentNode))); @@ -1125,7 +1127,8 @@ AcpiNsFindParentName ( } } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "unable to find parent of %p (%4.4s)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Unable to find parent of %p (%4.4s)\n", ChildNode, AcpiUtGetNodeName (ChildNode))); } @@ -1159,11 +1162,9 @@ AcpiNsGetParentNode ( } /* - * Walk to the end of this peer list. - * The last entry is marked with a flag and the peer - * pointer is really a pointer back to the parent. - * This saves putting a parent back pointer in each and - * every named object! + * Walk to the end of this peer list. The last entry is marked with a flag + * and the peer pointer is really a pointer back to the parent. This saves + * putting a parent back pointer in each and every named object! */ while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST)) { @@ -1181,8 +1182,8 @@ AcpiNsGetParentNode ( * * PARAMETERS: Node - Current table entry * - * RETURN: Next valid Node in the linked node list. NULL if no more valid - * nodess + * RETURN: Next valid Node in the linked node list. NULL if no more valid + * nodes. * * DESCRIPTION: Find the next valid node within a name table. * Useful for implementing NULL-end-of-list loops. diff --git a/sys/contrib/dev/acpica/nswalk.c b/sys/contrib/dev/acpica/nswalk.c index dab326424558..39d948f82acb 100644 --- a/sys/contrib/dev/acpica/nswalk.c +++ b/sys/contrib/dev/acpica/nswalk.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nswalk - Functions for walking the ACPI namespace - * $Revision: 36 $ + * $Revision: 37 $ * *****************************************************************************/ @@ -265,7 +265,7 @@ AcpiNsWalkNamespace ( /* Null child means "get first node" */ ParentNode = StartNode; - ChildNode = 0; + ChildNode = NULL; ChildType = ACPI_TYPE_ANY; Level = 1; @@ -350,15 +350,15 @@ AcpiNsWalkNamespace ( */ if ((Level < MaxDepth) && (Status != AE_CTRL_DEPTH)) { - if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, 0)) + if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, NULL)) { /* * There is at least one child of this * node, visit the onde */ Level++; - ParentNode = ChildNode; - ChildNode = 0; + ParentNode = ChildNode; + ChildNode = NULL; } } } diff --git a/sys/contrib/dev/acpica/osunixxf.c b/sys/contrib/dev/acpica/osunixxf.c index d536f8f5d750..f5ce08f8cac6 100644 --- a/sys/contrib/dev/acpica/osunixxf.c +++ b/sys/contrib/dev/acpica/osunixxf.c @@ -185,7 +185,7 @@ AcpiOsGetRootPointer ( ACPI_POINTER *Address) { - return (AE_OK); + return (AeLocalGetRootPointer(Flags, Address)); } @@ -238,14 +238,28 @@ AcpiOsTableOverride ( ACPI_TABLE_HEADER *ExistingTable, ACPI_TABLE_HEADER **NewTable) { + if (!ExistingTable || !NewTable) { return (AE_BAD_PARAMETER); } - /* TODO: Add table-getting code here */ *NewTable = NULL; - return (AE_NO_ACPI_TABLES); + +#ifdef _ACPI_EXEC_APP + + /* This code exercises the table override mechanism in the core */ + + if (!ACPI_STRNCMP (ExistingTable->Signature, DSDT_SIG, ACPI_NAME_SIZE)) + { + /* override DSDT with itself */ + + *NewTable = AcpiGbl_DbTablePtr; + } + return (AE_OK); +#else + return AE_NO_ACPI_TABLES; +#endif } @@ -686,7 +700,7 @@ AcpiOsReleaseLock ( UINT32 AcpiOsInstallInterruptHandler ( UINT32 InterruptNumber, - OSD_HANDLER ServiceRoutine, + ACPI_OSD_HANDLER ServiceRoutine, void *Context) { @@ -710,7 +724,7 @@ AcpiOsInstallInterruptHandler ( ACPI_STATUS AcpiOsRemoveInterruptHandler ( UINT32 InterruptNumber, - OSD_HANDLER ServiceRoutine) + ACPI_OSD_HANDLER ServiceRoutine) { return AE_OK; @@ -734,7 +748,7 @@ AcpiOsRemoveInterruptHandler ( ACPI_STATUS AcpiOsQueueForExecution ( UINT32 Priority, - OSD_EXECUTION_CALLBACK Function, + ACPI_OSD_EXEC_CALLBACK Function, void *Context) { @@ -778,7 +792,7 @@ AcpiOsBreakpoint ( /****************************************************************************** * - * FUNCTION: AcpiOsSleepUsec + * FUNCTION: AcpiOsStall * * PARAMETERS: microseconds To sleep * @@ -805,22 +819,20 @@ AcpiOsStall ( * * FUNCTION: AcpiOsSleep * - * PARAMETERS: seconds To sleep - * milliseconds To sleep + * PARAMETERS: milliseconds To sleep * * RETURN: Blocks until sleep is completed. * - * DESCRIPTION: Sleep at second/millisecond granularity + * DESCRIPTION: Sleep at millisecond granularity * *****************************************************************************/ void AcpiOsSleep ( - UINT32 seconds, - UINT32 milliseconds) + ACPI_INTEGER milliseconds) { - sleep (seconds + (milliseconds / 1000)); /* Sleep for whole seconds */ + sleep (milliseconds / 1000); /* Sleep for whole seconds */ /* * Arg to usleep() must be less than 1,000,000 (1 second) @@ -836,20 +848,22 @@ AcpiOsSleep ( * * PARAMETERS: None * - * RETURN: Current time in milliseconds + * RETURN: Current time in 100 nanosecond units * - * DESCRIPTION: Get the current system time (in milliseconds). + * DESCRIPTION: Get the current system time * *****************************************************************************/ -UINT32 +UINT64 AcpiOsGetTimer (void) { struct timeval time; gettimeofday(&time, NULL); - return ((time.tv_sec/1000) + (time.tv_usec*1000)); + /* Seconds * 10^7 = 100ns(10^-7), Microseconds(10^-6) * 10^1 = 100ns */ + + return (((UINT64) time.tv_sec * 10000000) + ((UINT64) time.tv_usec * 10)); } diff --git a/sys/contrib/dev/acpica/psopcode.c b/sys/contrib/dev/acpica/psopcode.c index 8debf2e78cd5..d2332f2388cb 100644 --- a/sys/contrib/dev/acpica/psopcode.c +++ b/sys/contrib/dev/acpica/psopcode.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psopcode - Parser/Interpreter opcode information table - * $Revision: 78 $ + * $Revision: 83 $ * *****************************************************************************/ @@ -267,6 +267,7 @@ #define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST) #define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) #define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_TIMER_OP ARG_NONE #define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) #define ARGP_TO_BUFFER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) #define ARGP_TO_DEC_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) @@ -324,7 +325,7 @@ #define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_INTEGER, ARGI_INTEGER, ARGI_REFERENCE) #define ARGI_CREATE_QWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) #define ARGI_CREATE_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING) +#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING) #define ARGI_DEBUG_OP ARG_NONE #define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF) #define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING) @@ -343,10 +344,10 @@ #define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE #define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA) +#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA) #define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE -#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA) #define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE #define ARGI_LNOT_OP ARGI_LIST1 (ARGI_INTEGER) #define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE @@ -390,7 +391,7 @@ #define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT) -#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT) +#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_REFERENCE) /* Force delay of operand resolution */ #define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER) #define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER) #define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE @@ -398,13 +399,14 @@ #define ARGI_STRING_OP ARGI_INVALID_OPCODE #define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) #define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE +#define ARGI_TIMER_OP ARG_NONE #define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) #define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) #define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) #define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) #define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) #define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET) -#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE) +#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_REFERENCE) /* Force delay of operand resolution */ #define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) #define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) #define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER) @@ -600,8 +602,8 @@ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = /* 35 */ ACPI_OP ("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), /* 36 */ ACPI_OP ("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, ARGI_CREATE_BIT_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), /* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), -/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), -/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), +/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), /* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), /* 3B */ ACPI_OP ("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), /* 3C */ ACPI_OP ("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), @@ -661,7 +663,6 @@ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = /* 6C */ ACPI_OP ("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS), /* 6D */ ACPI_OP ("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS), - /* ACPI 2.0 opcodes */ /* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), @@ -679,7 +680,11 @@ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = /* 7A */ ACPI_OP ("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), /* 7B */ ACPI_OP ("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R), /* 7C */ ACPI_OP ("DataTableRegion", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE) +/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE), + +/* ACPI 3.0 opcodes */ + +/* 7E */ ACPI_OP ("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, AML_FLAGS_EXEC_0A_0T_1R) /*! [End] no source code translation !*/ }; @@ -688,7 +693,6 @@ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = * This table is directly indexed by the opcodes, and returns an * index into the table above */ - static const UINT8 AcpiGbl_ShortOpIndex[256] = { /* 0 1 2 3 4 5 6 7 */ @@ -727,7 +731,10 @@ static const UINT8 AcpiGbl_ShortOpIndex[256] = /* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, }; - +/* + * This table is indexed by the second opcode of the extended opcode + * pair. It returns an index into the opcode table (AcpiGbl_AmlOpInfo) + */ static const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] = { /* 0 1 2 3 4 5 6 7 */ @@ -738,7 +745,7 @@ static const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] = /* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, /* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, /* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, -/* 0x30 */ 0x55, 0x56, 0x57, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK, /* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, @@ -799,7 +806,7 @@ AcpiPsGetOpcodeInfo ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown extended opcode [%X]\n", Opcode)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown AML opcode [%4.4X]\n", Opcode)); break; } diff --git a/sys/contrib/dev/acpica/psparse.c b/sys/contrib/dev/acpica/psparse.c index 5783fa6313fc..fc980192016c 100644 --- a/sys/contrib/dev/acpica/psparse.c +++ b/sys/contrib/dev/acpica/psparse.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psparse - Parser top level AML parse routines - * $Revision: 144 $ + * $Revision: 146 $ * *****************************************************************************/ @@ -240,141 +240,143 @@ AcpiPsCompleteThisOp ( /* Delete this op and the subtree below it if asked to */ - if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) == ACPI_PARSE_DELETE_TREE) && - (WalkState->OpInfo->Class != AML_CLASS_ARGUMENT)) + if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) || + (WalkState->OpInfo->Class == AML_CLASS_ARGUMENT)) { - /* Make sure that we only delete this subtree */ + return_VOID; + } + + /* Make sure that we only delete this subtree */ - if (Op->Common.Parent) + if (Op->Common.Parent) + { + /* + * Check if we need to replace the operator and its subtree + * with a return value op (placeholder op) + */ + ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); + + switch (ParentInfo->Class) { + case AML_CLASS_CONTROL: + break; + + case AML_CLASS_CREATE: + /* - * Check if we need to replace the operator and its subtree - * with a return value op (placeholder op) + * These opcodes contain TermArg operands. The current + * op must be replaced by a placeholder return op */ - ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); - - switch (ParentInfo->Class) + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + if (!ReplacementOp) { - case AML_CLASS_CONTROL: - break; + goto Cleanup; + } + break; - case AML_CLASS_CREATE: + case AML_CLASS_NAMED_OBJECT: - /* - * These opcodes contain TermArg operands. The current - * op must be replaced by a placeholder return op - */ + /* + * These opcodes contain TermArg operands. The current + * op must be replaced by a placeholder return op + */ + if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); if (!ReplacementOp) { - return_VOID; + goto Cleanup; } - break; + } - case AML_CLASS_NAMED_OBJECT: + if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && + (WalkState->DescendingCallback != AcpiDsExecBeginOp)) - /* - * These opcodes contain TermArg operands. The current - * op must be replaced by a placeholder return op - */ - if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) || - (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) || - (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) || - (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || - (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + if ((Op->Common.AmlOpcode == AML_BUFFER_OP) || + (Op->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) { - ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode); if (!ReplacementOp) { - return_VOID; + goto Cleanup; } + + ReplacementOp->Named.Data = Op->Named.Data; + ReplacementOp->Named.Length = Op->Named.Length; } + } + break; - if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && - (WalkState->DescendingCallback != AcpiDsExecBeginOp)) + default: + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + if (!ReplacementOp) + { + goto Cleanup; + } + } - { - if ((Op->Common.AmlOpcode == AML_BUFFER_OP) || - (Op->Common.AmlOpcode == AML_PACKAGE_OP) || - (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) - { - ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode); - if (!ReplacementOp) - { - return_VOID; - } + /* We must unlink this op from the parent tree */ - ReplacementOp->Named.Data = Op->Named.Data; - ReplacementOp->Named.Length = Op->Named.Length; - } - } - break; + Prev = Op->Common.Parent->Common.Value.Arg; + if (Prev == Op) + { + /* This op is the first in the list */ - default: - ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); - if (!ReplacementOp) - { - return_VOID; - } + if (ReplacementOp) + { + ReplacementOp->Common.Parent = Op->Common.Parent; + ReplacementOp->Common.Value.Arg = NULL; + ReplacementOp->Common.Node = Op->Common.Node; + Op->Common.Parent->Common.Value.Arg = ReplacementOp; + ReplacementOp->Common.Next = Op->Common.Next; } + else + { + Op->Common.Parent->Common.Value.Arg = Op->Common.Next; + } + } - /* We must unlink this op from the parent tree */ + /* Search the parent list */ - Prev = Op->Common.Parent->Common.Value.Arg; - if (Prev == Op) - { - /* This op is the first in the list */ + else while (Prev) + { + /* Traverse all siblings in the parent's argument list */ + Next = Prev->Common.Next; + if (Next == Op) + { if (ReplacementOp) { - ReplacementOp->Common.Parent = Op->Common.Parent; - ReplacementOp->Common.Value.Arg = NULL; - ReplacementOp->Common.Node = Op->Common.Node; - Op->Common.Parent->Common.Value.Arg = ReplacementOp; - ReplacementOp->Common.Next = Op->Common.Next; + ReplacementOp->Common.Parent = Op->Common.Parent; + ReplacementOp->Common.Value.Arg = NULL; + ReplacementOp->Common.Node = Op->Common.Node; + Prev->Common.Next = ReplacementOp; + ReplacementOp->Common.Next = Op->Common.Next; + Next = NULL; } else { - Op->Common.Parent->Common.Value.Arg = Op->Common.Next; + Prev->Common.Next = Op->Common.Next; + Next = NULL; } } - /* Search the parent list */ - - else while (Prev) - { - /* Traverse all siblings in the parent's argument list */ - - Next = Prev->Common.Next; - if (Next == Op) - { - if (ReplacementOp) - { - ReplacementOp->Common.Parent = Op->Common.Parent; - ReplacementOp->Common.Value.Arg = NULL; - ReplacementOp->Common.Node = Op->Common.Node; - Prev->Common.Next = ReplacementOp; - ReplacementOp->Common.Next = Op->Common.Next; - Next = NULL; - } - else - { - Prev->Common.Next = Op->Common.Next; - Next = NULL; - } - } - - Prev = Next; - } + Prev = Next; } + } - /* Now we can actually delete the subtree rooted at op */ - AcpiPsDeleteParseTree (Op); +Cleanup: - return_VOID; - } + /* Now we can actually delete the subtree rooted at op */ + AcpiPsDeleteParseTree (Op); return_VOID; } @@ -661,7 +663,8 @@ AcpiPsParseLoop ( PreOp = AcpiPsAllocOp (WalkState->Opcode); if (!PreOp) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto CloseThisOp; } } @@ -690,7 +693,8 @@ AcpiPsParseLoop ( if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes)) { - return_ACPI_STATUS (AE_AML_NO_OPERAND); + Status = AE_AML_NO_OPERAND; + goto CloseThisOp; } /* We know that this arg is a name, move to next arg */ @@ -757,7 +761,8 @@ AcpiPsParseLoop ( Op = AcpiPsAllocOp (WalkState->Opcode); if (!Op) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto CloseThisOp; } if (WalkState->OpInfo->Flags & AML_CREATE) @@ -936,7 +941,7 @@ AcpiPsParseLoop ( WalkState->ArgTypes, WalkState->ArgCount); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto CloseThisOp; } Op = NULL; continue; @@ -1293,7 +1298,7 @@ AcpiPsParseAml ( { Status = AE_OK; } - else if (Status != AE_OK) + else if ((Status != AE_OK) && (WalkState->MethodDesc)) { ACPI_REPORT_METHOD_ERROR ("Method execution failed", WalkState->MethodNode, NULL, Status); diff --git a/sys/contrib/dev/acpica/psutils.c b/sys/contrib/dev/acpica/psutils.c index 6c9e2b4de084..424e69f17752 100644 --- a/sys/contrib/dev/acpica/psutils.c +++ b/sys/contrib/dev/acpica/psutils.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psutils - Parser miscellaneous utilities (Parser only) - * $Revision: 56 $ + * $Revision: 58 $ * *****************************************************************************/ @@ -203,10 +203,9 @@ ACPI_PARSE_OBJECT* AcpiPsAllocOp ( UINT16 Opcode) { - ACPI_PARSE_OBJECT *Op = NULL; - UINT32 Size; - UINT8 Flags; + ACPI_PARSE_OBJECT *Op; const ACPI_OPCODE_INFO *OpInfo; + UINT8 Flags = ACPI_PARSEOP_GENERIC; ACPI_FUNCTION_ENTRY (); @@ -214,38 +213,33 @@ AcpiPsAllocOp ( OpInfo = AcpiPsGetOpcodeInfo (Opcode); - /* Allocate the minimum required size object */ + /* Determine type of ParseOp required */ if (OpInfo->Flags & AML_DEFER) { - Size = sizeof (ACPI_PARSE_OBJ_NAMED); Flags = ACPI_PARSEOP_DEFERRED; } else if (OpInfo->Flags & AML_NAMED) { - Size = sizeof (ACPI_PARSE_OBJ_NAMED); Flags = ACPI_PARSEOP_NAMED; } else if (Opcode == AML_INT_BYTELIST_OP) { - Size = sizeof (ACPI_PARSE_OBJ_NAMED); Flags = ACPI_PARSEOP_BYTELIST; } - else - { - Size = sizeof (ACPI_PARSE_OBJ_COMMON); - Flags = ACPI_PARSEOP_GENERIC; - } - if (Size == sizeof (ACPI_PARSE_OBJ_COMMON)) + /* Allocate the minimum required size object */ + + if (Flags == ACPI_PARSEOP_GENERIC) { - /* - * The generic op is by far the most common (16 to 1) - */ + /* The generic op (default) is by far the most common (16 to 1) */ + Op = AcpiUtAcquireFromCache (ACPI_MEM_LIST_PSNODE); } else { + /* Extended parseop */ + Op = AcpiUtAcquireFromCache (ACPI_MEM_LIST_PSNODE_EXT); } diff --git a/sys/contrib/dev/acpica/rscalc.c b/sys/contrib/dev/acpica/rscalc.c index 1b36dbd973a3..be27c94b8d73 100644 --- a/sys/contrib/dev/acpica/rscalc.c +++ b/sys/contrib/dev/acpica/rscalc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rscalc - Calculate stream and list lengths - * $Revision: 50 $ + * $Revision: 52 $ * ******************************************************************************/ @@ -148,7 +148,6 @@ AcpiRsGetByteStreamLength ( { ACPI_SIZE ByteStreamSizeNeeded = 0; ACPI_SIZE SegmentSize; - ACPI_RESOURCE_EXT_IRQ *ExIrq = NULL; BOOLEAN Done = FALSE; @@ -167,8 +166,8 @@ AcpiRsGetByteStreamLength ( case ACPI_RSTYPE_IRQ: /* * IRQ Resource - * For an IRQ Resource, Byte 3, although optional, will - * always be created - it holds IRQ information. + * For an IRQ Resource, Byte 3, although optional, will always be + * created - it holds IRQ information. */ SegmentSize = 4; break; @@ -184,8 +183,8 @@ AcpiRsGetByteStreamLength ( case ACPI_RSTYPE_START_DPF: /* * Start Dependent Functions Resource - * For a StartDependentFunctions Resource, Byte 1, - * although optional, will always be created. + * For a StartDependentFunctions Resource, Byte 1, although + * optional, will always be created. */ SegmentSize = 2; break; @@ -217,10 +216,9 @@ AcpiRsGetByteStreamLength ( case ACPI_RSTYPE_VENDOR: /* * Vendor Defined Resource - * For a Vendor Specific resource, if the Length is - * between 1 and 7 it will be created as a Small - * Resource data type, otherwise it is a Large - * Resource data type. + * For a Vendor Specific resource, if the Length is between 1 and 7 + * it will be created as a Small Resource data type, otherwise it + * is a Large Resource data type. */ if (LinkedList->Data.VendorSpecific.Length > 7) { @@ -269,10 +267,9 @@ AcpiRsGetByteStreamLength ( case ACPI_RSTYPE_ADDRESS16: /* * 16-Bit Address Resource - * The base size of this byte stream is 16. If a - * Resource Source string is not NULL, add 1 for - * the Index + the length of the null terminated - * string Resource Source + 1 for the null. + * The base size of this byte stream is 16. If a Resource Source + * string is not NULL, add 1 for the Index + the length of the null + * terminated string Resource Source + 1 for the null. */ SegmentSize = 16; @@ -303,10 +300,9 @@ AcpiRsGetByteStreamLength ( case ACPI_RSTYPE_ADDRESS64: /* * 64-Bit Address Resource - * The base size of this byte stream is 46. If a Resource - * Source string is not NULL, add 1 for the Index + the - * length of the null terminated string Resource Source + - * 1 for the null. + * The base size of this byte stream is 46. If a ResourceSource + * string is not NULL, add 1 for the Index + the length of the null + * terminated string Resource Source + 1 for the null. */ SegmentSize = 46; @@ -320,9 +316,8 @@ AcpiRsGetByteStreamLength ( case ACPI_RSTYPE_EXT_IRQ: /* * Extended IRQ Resource - * The base size of this byte stream is 9. This is for an - * Interrupt table length of 1. For each additional - * interrupt, add 4. + * The base size of this byte stream is 9. This is for an Interrupt + * table length of 1. For each additional interrupt, add 4. * If a Resource Source string is not NULL, add 1 for the * Index + the length of the null terminated string * Resource Source + 1 for the null. @@ -330,7 +325,7 @@ AcpiRsGetByteStreamLength ( SegmentSize = 9 + (((ACPI_SIZE) LinkedList->Data.ExtendedIrq.NumberOfInterrupts - 1) * 4); - if (ExIrq && ExIrq->ResourceSource.StringPtr) + if (LinkedList->Data.ExtendedIrq.ResourceSource.StringPtr) { SegmentSize += LinkedList->Data.ExtendedIrq.ResourceSource.StringLength; SegmentSize++; @@ -339,8 +334,7 @@ AcpiRsGetByteStreamLength ( default: /* - * If we get here, everything is out of sync, - * so exit with an error + * If we get here, everything is out of sync, exit with error */ return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); @@ -450,7 +444,6 @@ AcpiRsGetListLength ( /* * 32-Bit Memory Range Resource */ - BytesConsumed = 20; StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_MEM32); @@ -479,14 +472,12 @@ AcpiRsGetListLength ( BytesConsumed = Temp16 + 3; /* - * Resource Source Index and Resource Source are - * optional elements. Check the length of the - * Bytestream. If it is greater than 43, that - * means that an Index exists and is followed by - * a null termininated string. Therefore, set - * the temp variable to the length minus the minimum - * byte stream length plus the byte for the Index to - * determine the size of the NULL terminiated string. + * Resource Source Index and Resource Source are optional elements. + * Check the length of the Bytestream. If it is greater than 43, + * that means that an Index exists and is followed by a null + * terminated string. Therefore, set the temp variable to the + * length minus the minimum byte stream length plus the byte for + * the Index to determine the size of the NULL terminated string. */ if (43 < Temp16) { @@ -519,14 +510,12 @@ AcpiRsGetListLength ( BytesConsumed = Temp16 + 3; /* - * Resource Source Index and Resource Source are - * optional elements. Check the length of the - * Bytestream. If it is greater than 23, that - * means that an Index exists and is followed by - * a null termininated string. Therefore, set - * the temp variable to the length minus the minimum - * byte stream length plus the byte for the Index to - * determine the size of the NULL terminiated string. + * Resource Source Index and Resource Source are optional elements. + * Check the length of the Bytestream. If it is greater than 23, + * that means that an Index exists and is followed by a null + * terminated string. Therefore, set the temp variable to the + * length minus the minimum byte stream length plus the byte for + * the Index to determine the size of the NULL terminated string. */ if (23 < Temp16) { @@ -559,14 +548,12 @@ AcpiRsGetListLength ( BytesConsumed = Temp16 + 3; /* - * Resource Source Index and Resource Source are - * optional elements. Check the length of the - * Bytestream. If it is greater than 13, that - * means that an Index exists and is followed by - * a null termininated string. Therefore, set - * the temp variable to the length minus the minimum - * byte stream length plus the byte for the Index to - * determine the size of the NULL terminiated string. + * Resource Source Index and Resource Source are optional elements. + * Check the length of the Bytestream. If it is greater than 13, + * that means that an Index exists and is followed by a null + * terminated string. Therefore, set the temp variable to the + * length minus the minimum byte stream length plus the byte for + * the Index to determine the size of the NULL terminated string. */ if (13 < Temp16) { @@ -599,9 +586,8 @@ AcpiRsGetListLength ( BytesConsumed = Temp16 + 3; /* - * Point past the length field and the - * Interrupt vector flags to save off the - * Interrupt table length to the Temp8 variable. + * Point past the length field and the Interrupt vector flags to + * save off the Interrupt table length to the Temp8 variable. */ Buffer += 3; Temp8 = *Buffer; @@ -613,14 +599,12 @@ AcpiRsGetListLength ( AdditionalBytes = (UINT8) ((Temp8 - 1) * 4); /* - * Resource Source Index and Resource Source are - * optional elements. Check the length of the - * Bytestream. If it is greater than 9, that - * means that an Index exists and is followed by - * a null termininated string. Therefore, set - * the temp variable to the length minus the minimum - * byte stream length plus the byte for the Index to - * determine the size of the NULL terminiated string. + * Resource Source Index and Resource Source are optional elements. + * Check the length of the Bytestream. If it is greater than 9, + * that means that an Index exists and is followed by a null + * terminated string. Therefore, set the temp variable to the + * length minus the minimum byte stream length plus the byte for + * the Index to determine the size of the NULL terminated string. */ if (9 + AdditionalBytes < Temp16) { @@ -659,9 +643,8 @@ AcpiRsGetListLength ( BytesConsumed = 3; } - /* - * Point past the descriptor - */ + /* Point past the descriptor */ + ++Buffer; /* @@ -691,9 +674,8 @@ AcpiRsGetListLength ( Buffer = ByteStreamBuffer; BytesConsumed = 3; - /* - * Point past the descriptor - */ + /* Point past the descriptor */ + ++Buffer; /* diff --git a/sys/contrib/dev/acpica/rsxface.c b/sys/contrib/dev/acpica/rsxface.c index cf55799c805d..530dbb934d2c 100644 --- a/sys/contrib/dev/acpica/rsxface.c +++ b/sys/contrib/dev/acpica/rsxface.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsxface - Public interfaces to the resource manager - * $Revision: 30 $ + * $Revision: 31 $ * ******************************************************************************/ @@ -342,7 +342,7 @@ AcpiWalkResources ( /* Setup pointers */ Resource = (ACPI_RESOURCE *) Buffer.Pointer; - BufferEnd = ACPI_CAST_PTR (ACPI_RESOURCE, + BufferEnd = ACPI_CAST_PTR (ACPI_RESOURCE, ((UINT8 *) Buffer.Pointer + Buffer.Length)); /* Walk the resource list */ diff --git a/sys/contrib/dev/acpica/tbconvrt.c b/sys/contrib/dev/acpica/tbconvrt.c index 7b6fb0b2111d..750643f9c1ca 100644 --- a/sys/contrib/dev/acpica/tbconvrt.c +++ b/sys/contrib/dev/acpica/tbconvrt.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbconvrt - ACPI Table conversion utilities - * $Revision: 56 $ + * $Revision: 57 $ * *****************************************************************************/ @@ -331,10 +331,28 @@ AcpiTbConvertFadt1 ( LocalFadt->CstCnt = 0; /* - * Since there isn't any equivalence in 1.0 and since it highly likely - * that a 1.0 system has legacy support. + * FADT Rev 2 was an interim FADT released between ACPI 1.0 and ACPI 2.0. + * It primarily adds the FADT reset mechanism. */ - LocalFadt->IapcBootArch = BAF_LEGACY_DEVICES; + if ((OriginalFadt->Revision == 2) && + (OriginalFadt->Length == sizeof (FADT_DESCRIPTOR_REV2_MINUS))) + { + /* + * Grab the entire generic address struct, plus the 1-byte reset value + * that immediately follows. + */ + ACPI_MEMCPY (&LocalFadt->ResetRegister, + &((FADT_DESCRIPTOR_REV2_MINUS *) OriginalFadt)->ResetRegister, + sizeof (ACPI_GENERIC_ADDRESS) + 1); + } + else + { + /* + * Since there isn't any equivalence in 1.0 and since it is highly + * likely that a 1.0 system has legacy support. + */ + LocalFadt->IapcBootArch = BAF_LEGACY_DEVICES; + } /* * Convert the V1.0 block addresses to V2.0 GAS structures @@ -510,23 +528,21 @@ AcpiTbConvertTableFadt (void) /* - * AcpiGbl_FADT is valid - * Allocate and zero the 2.0 FADT buffer + * AcpiGbl_FADT is valid. Validate the FADT length. The table must be + * at least as long as the version 1.0 FADT */ - LocalFadt = ACPI_MEM_CALLOCATE (sizeof (FADT_DESCRIPTOR_REV2)); - if (LocalFadt == NULL) + if (AcpiGbl_FADT->Length < sizeof (FADT_DESCRIPTOR_REV1)) { - return_ACPI_STATUS (AE_NO_MEMORY); + ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n", AcpiGbl_FADT->Length)); + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); } - /* - * FADT length and version validation. The table must be at least as - * long as the version 1.0 FADT - */ - if (AcpiGbl_FADT->Length < sizeof (FADT_DESCRIPTOR_REV1)) + /* Allocate buffer for the ACPI 2.0(+) FADT */ + + LocalFadt = ACPI_MEM_CALLOCATE (sizeof (FADT_DESCRIPTOR_REV2)); + if (!LocalFadt) { - ACPI_REPORT_ERROR (("Invalid FADT table length: 0x%X\n", AcpiGbl_FADT->Length)); - return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + return_ACPI_STATUS (AE_NO_MEMORY); } if (AcpiGbl_FADT->Revision >= FADT2_REVISION_ID) diff --git a/sys/contrib/dev/acpica/tbget.c b/sys/contrib/dev/acpica/tbget.c index d270334768ad..4cb75bbbd187 100644 --- a/sys/contrib/dev/acpica/tbget.c +++ b/sys/contrib/dev/acpica/tbget.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbget - ACPI Table get* routines - * $Revision: 88 $ + * $Revision: 90 $ * *****************************************************************************/ @@ -245,6 +245,9 @@ AcpiTbGetTableHeader ( return_ACPI_STATUS (AE_BAD_PARAMETER); } + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Table Signature: [%4.4s]\n", + ReturnHeader->Signature)); + return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/tbinstal.c b/sys/contrib/dev/acpica/tbinstal.c index ab13c765a8b4..647f2513f11e 100644 --- a/sys/contrib/dev/acpica/tbinstal.c +++ b/sys/contrib/dev/acpica/tbinstal.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbinstal - ACPI table installation and removal - * $Revision: 73 $ + * $Revision: 74 $ * *****************************************************************************/ @@ -352,10 +352,11 @@ AcpiTbInitTableDescriptor ( { /* * Only one table allowed, and a table has alread been installed - * at this location, so return an error. + * at this location, so return an error. */ if (ListHead->Next) { + ACPI_MEM_FREE (TableDesc); return_ACPI_STATUS (AE_ALREADY_EXISTS); } diff --git a/sys/contrib/dev/acpica/tbrsdt.c b/sys/contrib/dev/acpica/tbrsdt.c index 47e5f866c3f0..be6ebcfbd8b8 100644 --- a/sys/contrib/dev/acpica/tbrsdt.c +++ b/sys/contrib/dev/acpica/tbrsdt.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbrsdt - ACPI RSDT table utilities - * $Revision: 12 $ + * $Revision: 13 $ * *****************************************************************************/ @@ -366,6 +366,7 @@ AcpiTbGetTableRsdt ( AcpiTbGetRsdtAddress (&Address); + TableInfo.Type = ACPI_TABLE_XSDT; Status = AcpiTbGetTable (&Address, &TableInfo); if (ACPI_FAILURE (Status)) { diff --git a/sys/contrib/dev/acpica/tbxfroot.c b/sys/contrib/dev/acpica/tbxfroot.c index 43566024aecc..077c258894a1 100644 --- a/sys/contrib/dev/acpica/tbxfroot.c +++ b/sys/contrib/dev/acpica/tbxfroot.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbxfroot - Find the root ACPI table (RSDT) - * $Revision: 73 $ + * $Revision: 79 $ * *****************************************************************************/ @@ -162,13 +162,32 @@ AcpiTbFindTable ( return_ACPI_STATUS (AE_AML_STRING_LIMIT); } - /* Find the table */ + if (!ACPI_STRNCMP (Signature, DSDT_SIG, ACPI_NAME_SIZE)) + { + /* + * The DSDT pointer is contained in the FADT, not the RSDT. + * This code should suffice, because the only code that would perform + * a "find" on the DSDT is the DataTableRegion() AML opcode -- in + * which case, the DSDT is guaranteed to be already loaded. + * If this becomes insufficient, the FADT will have to be found first. + */ + if (!AcpiGbl_DSDT) + { + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } - Status = AcpiGetFirmwareTable (Signature, 1, - ACPI_LOGICAL_ADDRESSING, &Table); - if (ACPI_FAILURE (Status)) + Table = AcpiGbl_DSDT; + } + else { - return_ACPI_STATUS (Status); + /* Find the table */ + + Status = AcpiGetFirmwareTable (Signature, 1, + ACPI_LOGICAL_ADDRESSING, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } } /* Check OemId and OemTableId */ @@ -179,6 +198,7 @@ AcpiTbFindTable ( return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND); } + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", Table->Signature)); *TablePtr = Table; return_ACPI_STATUS (AE_OK); } @@ -192,17 +212,14 @@ AcpiTbFindTable ( * Instance - the non zero instance of the table, allows * support for multiple tables of the same type * Flags - Physical/Virtual support - * RetBuffer - pointer to a structure containing a buffer to - * receive the table + * TablePointer - Where a buffer containing the table is + * returned * * RETURN: Status * - * DESCRIPTION: This function is called to get an ACPI table. The caller - * supplies an OutBuffer large enough to contain the entire ACPI - * table. Upon completion - * the OutBuffer->Length field will indicate the number of bytes - * copied into the OutBuffer->BufPtr buffer. This table will be - * a complete table including the header. + * DESCRIPTION: This function is called to get an ACPI table. A buffer is + * allocated for the table and returned in TablePointer. + * This table will be a complete table including the header. * ******************************************************************************/ @@ -213,12 +230,11 @@ AcpiGetFirmwareTable ( UINT32 Flags, ACPI_TABLE_HEADER **TablePointer) { - ACPI_POINTER RsdpAddress; - ACPI_POINTER Address; ACPI_STATUS Status; - ACPI_TABLE_HEADER Header; - ACPI_TABLE_DESC TableInfo; - ACPI_TABLE_DESC RsdtInfo; + ACPI_POINTER Address; + ACPI_TABLE_HEADER *Header = NULL; + ACPI_TABLE_DESC *TableInfo = NULL; + ACPI_TABLE_DESC *RsdtInfo; UINT32 TableCount; UINT32 i; UINT32 j; @@ -229,29 +245,26 @@ AcpiGetFirmwareTable ( /* * Ensure that at least the table manager is initialized. We don't - * require that the entire ACPI subsystem is up for this interface - */ - - /* - * If we have a buffer, we must have a length too + * require that the entire ACPI subsystem is up for this interface. + * If we have a buffer, we must have a length too */ - if ((Instance == 0) || - (!Signature) || + if ((Instance == 0) || + (!Signature) || (!TablePointer)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - RsdtInfo.Pointer = NULL; + /* Ensure that we have a RSDP */ if (!AcpiGbl_RSDP) { /* Get the RSDP */ - Status = AcpiOsGetRootPointer (Flags, &RsdpAddress); + Status = AcpiOsGetRootPointer (Flags, &Address); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP not found\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP not found\n")); return_ACPI_STATUS (AE_NO_ACPI_TABLES); } @@ -259,7 +272,7 @@ AcpiGetFirmwareTable ( if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { - Status = AcpiOsMapMemory (RsdpAddress.Pointer.Physical, sizeof (RSDP_DESCRIPTOR), + Status = AcpiOsMapMemory (Address.Pointer.Physical, sizeof (RSDP_DESCRIPTOR), (void *) &AcpiGbl_RSDP); if (ACPI_FAILURE (Status)) { @@ -268,12 +281,11 @@ AcpiGetFirmwareTable ( } else { - AcpiGbl_RSDP = RsdpAddress.Pointer.Logical; + AcpiGbl_RSDP = Address.Pointer.Logical; } - /* - * The signature and checksum must both be correct - */ + /* The signature and checksum must both be correct */ + if (ACPI_STRNCMP ((char *) AcpiGbl_RSDP, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { /* Nope, BAD Signature */ @@ -289,10 +301,9 @@ AcpiGetFirmwareTable ( } } - /* Get the RSDT and validate it */ + /* Get the RSDT address via the RSDP */ AcpiTbGetRsdtAddress (&Address); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", AcpiGbl_RSDP, @@ -302,22 +313,45 @@ AcpiGetFirmwareTable ( Address.PointerType |= Flags; - Status = AcpiTbGetTable (&Address, &RsdtInfo); + /* Get and validate the RSDT */ + + RsdtInfo = ACPI_MEM_CALLOCATE (sizeof (ACPI_TABLE_DESC)); + if (!RsdtInfo) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiTbGetTable (&Address, RsdtInfo); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto Cleanup; } - Status = AcpiTbValidateRsdt (RsdtInfo.Pointer); + Status = AcpiTbValidateRsdt (RsdtInfo->Pointer); if (ACPI_FAILURE (Status)) { goto Cleanup; } - /* Get the number of table pointers within the RSDT */ + /* Allocate a scratch table header and table descriptor */ - TableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, RsdtInfo.Pointer); + Header = ACPI_MEM_ALLOCATE (sizeof (ACPI_TABLE_HEADER)); + if (!Header) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + TableInfo = ACPI_MEM_ALLOCATE (sizeof (ACPI_TABLE_DESC)); + if (!TableInfo) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Get the number of table pointers within the RSDT */ + TableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, RsdtInfo->Pointer); Address.PointerType = AcpiGbl_TableFlags | Flags; /* @@ -330,17 +364,18 @@ AcpiGetFirmwareTable ( if (AcpiGbl_RSDP->Revision < 2) { - Address.Pointer.Value = (ACPI_CAST_PTR (RSDT_DESCRIPTOR, RsdtInfo.Pointer))->TableOffsetEntry[i]; + Address.Pointer.Value = (ACPI_CAST_PTR ( + RSDT_DESCRIPTOR, RsdtInfo->Pointer))->TableOffsetEntry[i]; } else { - Address.Pointer.Value = ACPI_GET_ADDRESS ( - (ACPI_CAST_PTR (XSDT_DESCRIPTOR, RsdtInfo.Pointer))->TableOffsetEntry[i]); + Address.Pointer.Value = ACPI_GET_ADDRESS ((ACPI_CAST_PTR ( + XSDT_DESCRIPTOR, RsdtInfo->Pointer))->TableOffsetEntry[i]); } /* Get the table header */ - Status = AcpiTbGetTableHeader (&Address, &Header); + Status = AcpiTbGetTableHeader (&Address, Header); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -348,7 +383,7 @@ AcpiGetFirmwareTable ( /* Compare table signatures and table instance */ - if (!ACPI_STRNCMP (Header.Signature, Signature, ACPI_NAME_SIZE)) + if (!ACPI_STRNCMP (Header->Signature, Signature, ACPI_NAME_SIZE)) { /* An instance of the table was found */ @@ -357,13 +392,13 @@ AcpiGetFirmwareTable ( { /* Found the correct instance, get the entire table */ - Status = AcpiTbGetTableBody (&Address, &Header, &TableInfo); + Status = AcpiTbGetTableBody (&Address, Header, TableInfo); if (ACPI_FAILURE (Status)) { goto Cleanup; } - *TablePointer = TableInfo.Pointer; + *TablePointer = TableInfo->Pointer; goto Cleanup; } } @@ -375,7 +410,17 @@ AcpiGetFirmwareTable ( Cleanup: - AcpiOsUnmapMemory (RsdtInfo.Pointer, (ACPI_SIZE) RsdtInfo.Pointer->Length); + AcpiOsUnmapMemory (RsdtInfo->Pointer, (ACPI_SIZE) RsdtInfo->Pointer->Length); + ACPI_MEM_FREE (RsdtInfo); + + if (Header) + { + ACPI_MEM_FREE (Header); + } + if (TableInfo) + { + ACPI_MEM_FREE (TableInfo); + } return_ACPI_STATUS (Status); } @@ -443,37 +488,63 @@ AcpiTbScanMemoryForRsdp ( UINT8 *StartAddress, UINT32 Length) { - UINT32 Offset; UINT8 *MemRover; + UINT8 *EndAddress; + UINT8 Checksum; ACPI_FUNCTION_TRACE ("TbScanMemoryForRsdp"); - /* Search from given start addr for the requested length */ + EndAddress = StartAddress + Length; - for (Offset = 0, MemRover = StartAddress; - Offset < Length; - Offset += ACPI_RSDP_SCAN_STEP, MemRover += ACPI_RSDP_SCAN_STEP) - { + /* Search from given start address for the requested length */ + for (MemRover = StartAddress; MemRover < EndAddress; + MemRover += ACPI_RSDP_SCAN_STEP) + { /* The signature and checksum must both be correct */ - if (ACPI_STRNCMP ((char *) MemRover, - RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 && - AcpiTbChecksum (MemRover, ACPI_RSDP_CHECKSUM_LENGTH) == 0) + if (ACPI_STRNCMP ((char *) MemRover, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { - /* If so, we have found the RSDP */ + /* No signature match, keep looking */ + + continue; + } + + /* Signature matches, check the appropriate checksum */ + + if (((RSDP_DESCRIPTOR *) MemRover)->Revision < 2) + { + /* ACPI version 1.0 */ + + Checksum = AcpiTbChecksum (MemRover, ACPI_RSDP_CHECKSUM_LENGTH); + } + else + { + /* Post ACPI 1.0, use ExtendedChecksum */ + + Checksum = AcpiTbChecksum (MemRover, ACPI_RSDP_XCHECKSUM_LENGTH); + } + + if (Checksum == 0) + { + /* Checksum valid, we have found a valid RSDP */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "RSDP located at physical address %p\n",MemRover)); + "RSDP located at physical address %p\n", MemRover)); return_PTR (MemRover); } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Found an RSDP at physical address %p, but it has a bad checksum\n", + MemRover)); } /* Searched entire block, no RSDP was found */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO,"Searched entire block, no RSDP was found.\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Searched entire block, no valid RSDP was found.\n")); return_PTR (NULL); } diff --git a/sys/contrib/dev/acpica/utalloc.c b/sys/contrib/dev/acpica/utalloc.c index ce036fed619d..b96cd5a17e5e 100644 --- a/sys/contrib/dev/acpica/utalloc.c +++ b/sys/contrib/dev/acpica/utalloc.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utalloc - local cache and memory allocation routines - * $Revision: 135 $ + * $Revision: 138 $ * *****************************************************************************/ @@ -345,13 +345,13 @@ AcpiUtValidateBuffer ( * * FUNCTION: AcpiUtInitializeBuffer * - * PARAMETERS: RequiredLength - Length needed - * Buffer - Buffer to be validated + * PARAMETERS: Buffer - Buffer to be validated + * RequiredLength - Length needed * * RETURN: Status * * DESCRIPTION: Validate that the buffer is of the required length or - * allocate a new buffer. + * allocate a new buffer. Returned buffer is always zeroed. * ******************************************************************************/ @@ -393,26 +393,27 @@ AcpiUtInitializeBuffer ( /* Allocate a new buffer with local interface to allow tracking */ - Buffer->Pointer = ACPI_MEM_ALLOCATE (RequiredLength); + Buffer->Pointer = ACPI_MEM_CALLOCATE (RequiredLength); if (!Buffer->Pointer) { return (AE_NO_MEMORY); } - - /* Clear the buffer */ - - ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength); break; default: - /* Validate the size of the buffer */ + /* Existing buffer: Validate the size of the buffer */ if (Buffer->Length < RequiredLength) { Status = AE_BUFFER_OVERFLOW; + break; } + + /* Clear the buffer */ + + ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength); break; } @@ -566,7 +567,7 @@ AcpiUtAllocateAndTrack ( ACPI_STATUS Status; - Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component, + Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), Component, Module, Line); if (!Allocation) { @@ -614,7 +615,7 @@ AcpiUtCallocateAndTrack ( ACPI_STATUS Status; - Allocation = AcpiUtCallocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component, + Allocation = AcpiUtCallocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), Component, Module, Line); if (!Allocation) { @@ -703,7 +704,8 @@ AcpiUtFreeAndTrack ( * * FUNCTION: AcpiUtFindAllocation * - * PARAMETERS: Allocation - Address of allocated memory + * PARAMETERS: ListId - Memory list to search + * Allocation - Address of allocated memory * * RETURN: A list element if found; NULL otherwise. * @@ -749,7 +751,8 @@ AcpiUtFindAllocation ( * * FUNCTION: AcpiUtTrackAllocation * - * PARAMETERS: Allocation - Address of allocated memory + * PARAMETERS: ListId - Memory list to search + * Allocation - Address of allocated memory * Size - Size of the allocation * AllocType - MEM_MALLOC or MEM_CALLOC * Component - Component type of caller @@ -816,6 +819,7 @@ AcpiUtTrackAllocation ( Allocation->Line = Line; ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME); + Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0; /* Insert at list head */ @@ -840,7 +844,8 @@ UnlockAndExit: * * FUNCTION: AcpiUtRemoveAllocation * - * PARAMETERS: Allocation - Address of allocated memory + * PARAMETERS: ListId - Memory list to search + * Allocation - Address of allocated memory * Component - Component type of caller * Module - Source file name of caller * Line - Line number of caller diff --git a/sys/contrib/dev/acpica/utclib.c b/sys/contrib/dev/acpica/utclib.c index 338a08bde498..5be62a5a50cf 100644 --- a/sys/contrib/dev/acpica/utclib.c +++ b/sys/contrib/dev/acpica/utclib.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: cmclib - Local implementation of C library functions - * $Revision: 52 $ + * $Revision: 53 $ * *****************************************************************************/ @@ -278,6 +278,36 @@ AcpiUtStrcmp ( /******************************************************************************* * + * FUNCTION: memcmp + * + * PARAMETERS: Buffer1 - First Buffer + * Buffer2 - Second Buffer + * Count - Maximum # of bytes to compare + * + * RETURN: Index where Buffers mismatched, or 0 if Buffers matched + * + * DESCRIPTION: Compare two Buffers, with a maximum length + * + ******************************************************************************/ + +int +AcpiUtMemcmp ( + const char *Buffer1, + const char *Buffer2, + ACPI_SIZE Count) +{ + + for ( ; Count-- && (*Buffer1 == *Buffer2); Buffer1++, Buffer2++) + { + } + + return ((Count == ACPI_SIZE_MAX) ? 0 : ((unsigned char) *Buffer1 - + (unsigned char) *Buffer2)); +} + + +/******************************************************************************* + * * FUNCTION: strncmp * * PARAMETERS: String1 - First string diff --git a/sys/contrib/dev/acpica/utcopy.c b/sys/contrib/dev/acpica/utcopy.c index 370f22cfc0f0..8d296de4e303 100644 --- a/sys/contrib/dev/acpica/utcopy.c +++ b/sys/contrib/dev/acpica/utcopy.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utcopy - Internal to external object translation utilities - * $Revision: 114 $ + * $Revision: 115 $ * *****************************************************************************/ @@ -507,25 +507,23 @@ AcpiUtCopyEsimpleToIsimple ( break; default: - /* - * Whatever other type -- it is not supported - */ + /* All other types are not supported */ + return_ACPI_STATUS (AE_SUPPORT); } - switch (ExternalObject->Type) - { - /* Must COPY string and buffer contents */ + switch (ExternalObject->Type) + { case ACPI_TYPE_STRING: InternalObject->String.Pointer = ACPI_MEM_CALLOCATE ((ACPI_SIZE) ExternalObject->String.Length + 1); if (!InternalObject->String.Pointer) { - return_ACPI_STATUS (AE_NO_MEMORY); + goto ErrorExit; } ACPI_MEMCPY (InternalObject->String.Pointer, @@ -542,7 +540,7 @@ AcpiUtCopyEsimpleToIsimple ( ACPI_MEM_CALLOCATE (ExternalObject->Buffer.Length); if (!InternalObject->Buffer.Pointer) { - return_ACPI_STATUS (AE_NO_MEMORY); + goto ErrorExit; } ACPI_MEMCPY (InternalObject->Buffer.Pointer, @@ -565,6 +563,11 @@ AcpiUtCopyEsimpleToIsimple ( *RetInternalObject = InternalObject; return_ACPI_STATUS (AE_OK); + + +ErrorExit: + AcpiUtRemoveReference (InternalObject); + return_ACPI_STATUS (AE_NO_MEMORY); } @@ -845,7 +848,7 @@ AcpiUtCopyIelementToIelement ( Status = AcpiUtCopySimpleObject (SourceObject, TargetObject); if (ACPI_FAILURE (Status)) { - return (Status); + goto ErrorExit; } *ThisTargetPtr = TargetObject; @@ -882,8 +885,8 @@ AcpiUtCopyIelementToIelement ( sizeof (void *)); if (!TargetObject->Package.Elements) { - ACPI_MEM_FREE (TargetObject); - return (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto ErrorExit; } /* @@ -903,6 +906,10 @@ AcpiUtCopyIelementToIelement ( } return (Status); + +ErrorExit: + AcpiUtRemoveReference (TargetObject); + return (Status); } diff --git a/sys/contrib/dev/acpica/utdelete.c b/sys/contrib/dev/acpica/utdelete.c index 39c5bd2024bc..49a1a690001e 100644 --- a/sys/contrib/dev/acpica/utdelete.c +++ b/sys/contrib/dev/acpica/utdelete.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: utdelete - object deletion and reference count utilities - * $Revision: 99 $ + * $Revision: 100 $ * ******************************************************************************/ @@ -692,6 +692,10 @@ AcpiUtAddReference ( return_VOID; } + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Incremented]\n", + Object, Object->Common.ReferenceCount)); + /* Increment the reference count */ (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT); @@ -738,8 +742,9 @@ AcpiUtRemoveReference ( return_VOID; } - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X\n", - Object, Object->Common.ReferenceCount)); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Decremented]\n", + Object, Object->Common.ReferenceCount)); /* * Decrement the reference count, and only actually delete the object diff --git a/sys/contrib/dev/acpica/utglobal.c b/sys/contrib/dev/acpica/utglobal.c index 0825d2159b5d..dcf3dfe06e3b 100644 --- a/sys/contrib/dev/acpica/utglobal.c +++ b/sys/contrib/dev/acpica/utglobal.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utglobal - Global variables for the ACPI subsystem - * $Revision: 201 $ + * $Revision: 202 $ * *****************************************************************************/ @@ -947,6 +947,7 @@ AcpiUtInitGlobals ( AcpiGbl_SystemNotify.Handler = NULL; AcpiGbl_DeviceNotify.Handler = NULL; + AcpiGbl_ExceptionHandler = NULL; AcpiGbl_InitHandler = NULL; /* Global "typed" ACPI table pointers */ diff --git a/sys/contrib/dev/acpica/utmath.c b/sys/contrib/dev/acpica/utmath.c index 5d81a98990ec..9c9cd621b176 100644 --- a/sys/contrib/dev/acpica/utmath.c +++ b/sys/contrib/dev/acpica/utmath.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: utmath - Integer math support routines - * $Revision: 13 $ + * $Revision: 14 $ * ******************************************************************************/ @@ -134,7 +134,7 @@ * * FUNCTION: AcpiUtShortDivide * - * PARAMETERS: InDividend - Pointer to the dividend + * PARAMETERS: Dividend - 64-bit dividend * Divisor - 32-bit divisor * OutQuotient - Pointer to where the quotient is returned * OutRemainder - Pointer to where the remainder is returned @@ -149,19 +149,18 @@ ACPI_STATUS AcpiUtShortDivide ( - ACPI_INTEGER *InDividend, + ACPI_INTEGER Dividend, UINT32 Divisor, ACPI_INTEGER *OutQuotient, UINT32 *OutRemainder) { - UINT64_OVERLAY Dividend; + UINT64_OVERLAY DividendOvl; UINT64_OVERLAY Quotient; UINT32 Remainder32; ACPI_FUNCTION_TRACE ("UtShortDivide"); - Dividend.Full = *InDividend; /* Always check for a zero divisor */ @@ -171,13 +170,15 @@ AcpiUtShortDivide ( return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); } + DividendOvl.Full = Dividend; + /* * The quotient is 64 bits, the remainder is always 32 bits, * and is generated by the second divide. */ - ACPI_DIV_64_BY_32 (0, Dividend.Part.Hi, Divisor, + ACPI_DIV_64_BY_32 (0, DividendOvl.Part.Hi, Divisor, Quotient.Part.Hi, Remainder32); - ACPI_DIV_64_BY_32 (Remainder32, Dividend.Part.Lo, Divisor, + ACPI_DIV_64_BY_32 (Remainder32, DividendOvl.Part.Lo, Divisor, Quotient.Part.Lo, Remainder32); /* Return only what was requested */ @@ -199,8 +200,8 @@ AcpiUtShortDivide ( * * FUNCTION: AcpiUtDivide * - * PARAMETERS: InDividend - Pointer to the dividend - * InDivisor - Pointer to the divisor + * PARAMETERS: InDividend - Dividend + * InDivisor - Divisor * OutQuotient - Pointer to where the quotient is returned * OutRemainder - Pointer to where the remainder is returned * @@ -212,8 +213,8 @@ AcpiUtShortDivide ( ACPI_STATUS AcpiUtDivide ( - ACPI_INTEGER *InDividend, - ACPI_INTEGER *InDivisor, + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, ACPI_INTEGER *OutQuotient, ACPI_INTEGER *OutRemainder) { @@ -233,14 +234,14 @@ AcpiUtDivide ( /* Always check for a zero divisor */ - if (*InDivisor == 0) + if (InDivisor == 0) { ACPI_REPORT_ERROR (("AcpiUtDivide: Divide by zero\n")); return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); } - Divisor.Full = *InDivisor; - Dividend.Full = *InDividend; + Divisor.Full = InDivisor; + Dividend.Full = InDividend; if (Divisor.Part.Hi == 0) { /* @@ -359,7 +360,7 @@ AcpiUtDivide ( ACPI_STATUS AcpiUtShortDivide ( - ACPI_INTEGER *InDividend, + ACPI_INTEGER InDividend, UINT32 Divisor, ACPI_INTEGER *OutQuotient, UINT32 *OutRemainder) @@ -380,11 +381,11 @@ AcpiUtShortDivide ( if (OutQuotient) { - *OutQuotient = *InDividend / Divisor; + *OutQuotient = InDividend / Divisor; } if (OutRemainder) { - *OutRemainder = (UINT32) *InDividend % Divisor; + *OutRemainder = (UINT32) InDividend % Divisor; } return_ACPI_STATUS (AE_OK); @@ -392,8 +393,8 @@ AcpiUtShortDivide ( ACPI_STATUS AcpiUtDivide ( - ACPI_INTEGER *InDividend, - ACPI_INTEGER *InDivisor, + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, ACPI_INTEGER *OutQuotient, ACPI_INTEGER *OutRemainder) { @@ -402,7 +403,7 @@ AcpiUtDivide ( /* Always check for a zero divisor */ - if (*InDivisor == 0) + if (InDivisor == 0) { ACPI_REPORT_ERROR (("AcpiUtDivide: Divide by zero\n")); return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); @@ -413,11 +414,11 @@ AcpiUtDivide ( if (OutQuotient) { - *OutQuotient = *InDividend / *InDivisor; + *OutQuotient = InDividend / InDivisor; } if (OutRemainder) { - *OutRemainder = *InDividend % *InDivisor; + *OutRemainder = InDividend % InDivisor; } return_ACPI_STATUS (AE_OK); diff --git a/sys/contrib/dev/acpica/utmisc.c b/sys/contrib/dev/acpica/utmisc.c index 3727002e25eb..0e5354042783 100644 --- a/sys/contrib/dev/acpica/utmisc.c +++ b/sys/contrib/dev/acpica/utmisc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: utmisc - common utility procedures - * $Revision: 100 $ + * $Revision: 101 $ * ******************************************************************************/ @@ -445,16 +445,15 @@ AcpiUtValidAcpiCharacter ( * FUNCTION: AcpiUtStrtoul64 * * PARAMETERS: String - Null terminated string - * Terminater - Where a pointer to the terminating byte is returned - * Base - Radix of the string + * Base - Radix of the string: 10, 16, or ACPI_ANY_BASE + * RetInteger - Where the converted integer is returned * - * RETURN: Converted value + * RETURN: Status and Converted value * * DESCRIPTION: Convert a string into an unsigned value. + * NOTE: Does not support Octal strings, not needed. * ******************************************************************************/ -#define NEGATIVE 1 -#define POSITIVE 0 ACPI_STATUS AcpiUtStrtoul64 ( @@ -462,34 +461,28 @@ AcpiUtStrtoul64 ( UINT32 Base, ACPI_INTEGER *RetInteger) { - UINT32 Index; + UINT32 ThisDigit; ACPI_INTEGER ReturnValue = 0; - ACPI_STATUS Status = AE_OK; - ACPI_INTEGER Dividend; ACPI_INTEGER Quotient; - *RetInteger = 0; + ACPI_FUNCTION_TRACE ("UtStroul64"); + switch (Base) { - case 0: - case 8: + case ACPI_ANY_BASE: case 10: case 16: break; default: - /* - * The specified Base parameter is not in the domain of - * this function: - */ - return (AE_BAD_PARAMETER); + /* Invalid Base */ + return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * skip over any white space in the buffer: - */ + /* Skip over any white space in the buffer */ + while (ACPI_IS_SPACE (*String) || *String == '\t') { ++String; @@ -497,21 +490,15 @@ AcpiUtStrtoul64 ( /* * If the input parameter Base is zero, then we need to - * determine if it is octal, decimal, or hexadecimal: + * determine if it is decimal or hexadecimal: */ if (Base == 0) { - if (*String == '0') + if ((*String == '0') && + (ACPI_TOLOWER (*(++String)) == 'x')) { - if (ACPI_TOLOWER (*(++String)) == 'x') - { - Base = 16; - ++String; - } - else - { - Base = 8; - } + Base = 16; + ++String; } else { @@ -520,14 +507,9 @@ AcpiUtStrtoul64 ( } /* - * For octal and hexadecimal bases, skip over the leading + * For hexadecimal base, skip over the leading * 0 or 0x, if they are present. */ - if (Base == 8 && *String == '0') - { - String++; - } - if (Base == 16 && *String == '0' && ACPI_TOLOWER (*(++String)) == 'x') @@ -535,20 +517,24 @@ AcpiUtStrtoul64 ( String++; } - /* Main loop: convert the string to an unsigned long */ + /* Main loop: convert the string to a 64-bit integer */ while (*String) { if (ACPI_IS_DIGIT (*String)) { - Index = ((UINT8) *String) - '0'; + /* Convert ASCII 0-9 to Decimal value */ + + ThisDigit = ((UINT8) *String) - '0'; } else { - Index = (UINT8) ACPI_TOUPPER (*String); - if (ACPI_IS_UPPER ((char) Index)) + ThisDigit = (UINT8) ACPI_TOUPPER (*String); + if (ACPI_IS_UPPER ((char) ThisDigit)) { - Index = Index - 'A' + 10; + /* Convert ASCII Hex char to value */ + + ThisDigit = ThisDigit - 'A' + 10; } else { @@ -556,50 +542,42 @@ AcpiUtStrtoul64 ( } } - if (Index >= Base) + /* Check to see if digit is out of range */ + + if (ThisDigit >= Base) { goto ErrorExit; } - /* Check to see if value is out of range: */ + /* Divide the digit into the correct position */ - Dividend = ACPI_INTEGER_MAX - (ACPI_INTEGER) Index; - (void) AcpiUtShortDivide (&Dividend, Base, &Quotient, NULL); + (void) AcpiUtShortDivide ((ACPI_INTEGER_MAX - (ACPI_INTEGER) ThisDigit), + Base, &Quotient, NULL); if (ReturnValue > Quotient) { goto ErrorExit; } ReturnValue *= Base; - ReturnValue += Index; + ReturnValue += ThisDigit; ++String; } *RetInteger = ReturnValue; - return (Status); + return_ACPI_STATUS (AE_OK); ErrorExit: - switch (Base) - { - case 8: - Status = AE_BAD_OCTAL_CONSTANT; - break; + /* Base was set/validated above */ - case 10: - Status = AE_BAD_DECIMAL_CONSTANT; - break; - - case 16: - Status = AE_BAD_HEX_CONSTANT; - break; - - default: - /* Base validated above */ - break; + if (Base == 10) + { + return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); + } + else + { + return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); } - - return (Status); } diff --git a/sys/contrib/dev/acpica/utobject.c b/sys/contrib/dev/acpica/utobject.c index f9e42833b5b2..596589130429 100644 --- a/sys/contrib/dev/acpica/utobject.c +++ b/sys/contrib/dev/acpica/utobject.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utobject - ACPI object create/delete/size/cache routines - * $Revision: 86 $ + * $Revision: 90 $ * *****************************************************************************/ @@ -232,9 +232,8 @@ AcpiUtCreateBufferObject ( ACPI_FUNCTION_TRACE_U32 ("UtCreateBufferObject", BufferSize); - /* - * Create a new Buffer object - */ + /* Create a new Buffer object */ + BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); if (!BufferDesc) { @@ -271,6 +270,63 @@ AcpiUtCreateBufferObject ( /******************************************************************************* * + * FUNCTION: AcpiUtCreateStringObject + * + * PARAMETERS: StringSize - Size of string to be created. Does not + * include NULL terminator, this is added + * automatically. + * + * RETURN: Pointer to a new String object + * + * DESCRIPTION: Create a fully initialized string object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateStringObject ( + ACPI_SIZE StringSize) +{ + ACPI_OPERAND_OBJECT *StringDesc; + char *String; + + + ACPI_FUNCTION_TRACE_U32 ("UtCreateStringObject", StringSize); + + + /* Create a new String object */ + + StringDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); + if (!StringDesc) + { + return_PTR (NULL); + } + + /* + * Allocate the actual string buffer -- (Size + 1) for NULL terminator. + * NOTE: Zero-length strings are NULL terminated + */ + String = ACPI_MEM_CALLOCATE (StringSize + 1); + if (!String) + { + ACPI_REPORT_ERROR (("CreateString: could not allocate size %X\n", + (UINT32) StringSize)); + AcpiUtRemoveReference (StringDesc); + return_PTR (NULL); + } + + /* Complete string object initialization */ + + StringDesc->String.Pointer = String; + StringDesc->String.Length = (UINT32) StringSize; + + /* Return the new string descriptor */ + + return_PTR (StringDesc); +} + + +/******************************************************************************* + * * FUNCTION: AcpiUtValidInternalObject * * PARAMETERS: Object - Object to be validated |