diff options
author | jkim <jkim@FreeBSD.org> | 2005-11-01 22:11:18 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2005-11-01 22:11:18 +0000 |
commit | 5f6a2493ddea1cf36a4dcd58b865c4148427e0a2 (patch) | |
tree | 4450b2c84d749dd8a8425a8feb88b084809f6ef0 /sys/contrib | |
parent | 50133a977cb75b3f52603d4b351a8cf45bb556c8 (diff) | |
download | FreeBSD-src-5f6a2493ddea1cf36a4dcd58b865c4148427e0a2.zip FreeBSD-src-5f6a2493ddea1cf36a4dcd58b865c4148427e0a2.tar.gz |
Vendor import of Intel ACPI-CA 20051021
Diffstat (limited to 'sys/contrib')
196 files changed, 24058 insertions, 16596 deletions
diff --git a/sys/contrib/dev/acpica/CHANGES.txt b/sys/contrib/dev/acpica/CHANGES.txt index 112d62d..e18b8f1 100644 --- a/sys/contrib/dev/acpica/CHANGES.txt +++ b/sys/contrib/dev/acpica/CHANGES.txt @@ -1,41 +1,1407 @@ ---------------------------------------- +21 October 2005. Summary of changes for version 20051021: + +1) ACPI CA Core Subsystem: + +Implemented support for the EM64T and other x86-64 processors. +This essentially entails recognizing that these processors +support non-aligned memory transfers. Previously, all 64-bit +processors were assumed to lack hardware support for non-aligned +transfers. + +Completed conversion of the Resource Manager to nearly full table- +driven operation. Specifically, the resource conversion code +(convert AML to internal format and the reverse) and the debug +code to dump internal resource descriptors are fully table- +driven, reducing code and data size and improving +maintainability. + +The OSL interfaces for Acquire and Release Lock now use a 64-bit +flag word on 64-bit processors instead of a fixed 32-bit word. +(With assistance from Alexey Starikovskiy) + +Implemented support within the resource conversion code for the +Type-Specific byte within the various ACPI 3.0 *WordSpace macros. + +Fixed some issues within the resource conversion code for the +type-specific flags for both Memory and I/O address resource +descriptors. For Memory, implemented support for the MTP and TTP +flags. For I/O, split the TRS and TTP flags into two separate +fields. + +Code and Data Size: The current and previous library sizes for +the core subsystem are shown below. These are the code and data +sizes for the acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. 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.1K Code, 12.1K Data, 89.2K Total + Debug Version: 168.0K Code, 68.3K Data, 236.3K Total + Current Release: + Non-Debug Version: 76.1K Code, 12.2K Data, 88.3K Total + Debug Version: 163.5K Code, 67.0K Data, 230.5K Total + + +2) iASL Compiler/Disassembler: + +Relaxed a compiler restriction that disallowed a ResourceIndex +byte if the corresponding ResourceSource string was not also +present in a resource descriptor declaration. This restriction +caused problems with existing AML/ASL code that includes the +Index byte without the string. When such AML was disassembled, it +could not be compiled without modification. Further, the modified +code created a resource template with a different size than the +original, breaking code that used fixed offsets into the resource +template buffer. + +Removed a recent feature of the disassembler to ignore a lone +ResourceIndex byte. This byte is now emitted if present so that +the exact AML can be reproduced when the disassembled code is +recompiled. + +Improved comments and text alignment for the resource descriptor +code emitted by the disassembler. + +Implemented disassembler support for the ACPI 3.0 AccessSize +field within a Register() resource descriptor. + +---------------------------------------- +30 September 2005. Summary of changes for version 20050930: + +1) ACPI CA Core Subsystem: + +Completed a major overhaul of the Resource Manager code - +specifically, optimizations in the area of the AML/internal +resource conversion code. The code has been optimized to simplify +and eliminate duplicated code, CPU stack use has been decreased +by optimizing function parameters and local variables, and naming +conventions across the manager have been standardized for clarity +and ease of maintenance (this includes function, parameter, +variable, and struct/typedef names.) The update may force changes +in some driver code, depending on how resources are handled by +the host OS. + +All Resource Manager dispatch and information tables have been +moved to a single location for clarity and ease of maintenance. +One new file was created, named "rsinfo.c". + +The ACPI return macros (return_ACPI_STATUS, etc.) have been +modified to guarantee that the argument is not evaluated twice, +making them less prone to macro side-effects. However, since +there exists the possibility of additional stack use if a +particular compiler cannot optimize them (such as in the debug +generation case), the original macros are optionally available. +Note that some invocations of the return_VALUE macro may now +cause size mismatch warnings; the return_UINT8 and return_UINT32 +macros are provided to eliminate these. (From Randy Dunlap) + +Implemented a new mechanism to enable debug tracing for +individual control methods. A new external interface, +AcpiDebugTrace, is provided to enable this mechanism. The intent +is to allow the host OS to easily enable and disable tracing for +problematic control methods. This interface can be easily exposed +to a user or debugger interface if desired. See the file +psxface.c for details. + +AcpiUtCallocate will now return a valid pointer if a length of +zero is specified - a length of one is used and a warning is +issued. This matches the behavior of AcpiUtAllocate. + +Code and Data Size: The current and previous library sizes for +the core subsystem are shown below. These are the code and data +sizes for the acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. 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.5K Code, 12.0K Data, 89.5K Total + Debug Version: 168.1K Code, 68.4K Data, 236.5K Total + Current Release: + Non-Debug Version: 77.1K Code, 12.1K Data, 89.2K Total + Debug Version: 168.0K Code, 68.3K Data, 236.3K Total + + +2) iASL Compiler/Disassembler: + +A remark is issued if the effective compile-time length of a +package or buffer is zero. Previously, this was a warning. + +---------------------------------------- +16 September 2005. Summary of changes for version 20050916: + +1) ACPI CA Core Subsystem: + +Fixed a problem within the Resource Manager where support for the +Generic Register descriptor was not fully implemented. This +descriptor is now fully recognized, parsed, disassembled, and +displayed. + +Completely restructured the Resource Manager code to utilize +table-driven dispatch and lookup, eliminating many of the large +switch() statements. This reduces overall subsystem code size and +code complexity. Affects the resource parsing and construction, +disassembly, and debug dump output. + +Cleaned up and restructured the debug dump output for all +resource descriptors. Improved readability of the output and +reduced code size. + +Fixed a problem where changes to internal data structures caused +the optional ACPI_MUTEX_DEBUG code to fail compilation if +specified. + +Code and Data Size: The current and previous library sizes for +the core subsystem are shown below. These are the code and data +sizes for the acpica.lib produced by the Microsoft Visual C++ 6.0 +32-bit compiler. 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.4K Code, 11.8K Data, 90.2K Total + Debug Version: 169.6K Code, 69.9K Data, 239.5K Total + Current Release: + Non-Debug Version: 77.5K Code, 12.0K Data, 89.5K Total + Debug Version: 168.1K Code, 68.4K Data, 236.5K Total + + +2) iASL Compiler/Disassembler: + +Updated the disassembler to automatically insert an +EndDependentFn() macro into the ASL stream if this macro is +missing in the original AML code, simplifying compilation of the +resulting ASL module. + +Fixed a problem in the disassembler where a disassembled +ResourceSource string (within a large resource descriptor) was +not surrounded by quotes and not followed by a comma, causing +errors when the resulting ASL module was compiled. Also, escape +sequences within a ResourceSource string are now handled +correctly (especially "\\") + +---------------------------------------- +02 September 2005. Summary of changes for version 20050902: + +1) ACPI CA Core Subsystem: + +Fixed a problem with the internal Owner ID allocation and +deallocation mechanisms for control method execution and +recursive method invocation. This should eliminate the +OWNER_ID_LIMIT exceptions and "Invalid OwnerId" messages seen on +some systems. Recursive method invocation depth is currently +limited to 255. (Alexey Starikovskiy) + +Completely eliminated all vestiges of support for the "module- +level executable code" until this support is fully implemented +and debugged. This should eliminate the NO_RETURN_VALUE +exceptions seen during table load on some systems that invoke +this support. + +Fixed a problem within the resource manager code where the +transaction flags for a 64-bit address descriptor were handled +incorrectly in the type-specific flag byte. + +Consolidated duplicate code within the address descriptor +resource manager code, reducing overall subsystem code size. + +Fixed a fault when using the AML debugger "disassemble" command +to disassemble individual control methods. + +Removed references to the "release_current" directory within the +Unix release package. + +Code and Data Size: The 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. 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.6K Code, 11.7K Data, 90.3K Total + Debug Version: 170.0K Code, 69.9K Data, 239.9K Total + Current Release: + Non-Debug Version: 78.4K Code, 11.8K Data, 90.2K Total + Debug Version: 169.6K Code, 69.9K Data, 239.5K Total + + +2) iASL Compiler/Disassembler: + +Implemented an error check for illegal duplicate values in the +interrupt and dma lists for the following ASL macros: Dma(), +Irq(), IrqNoFlags(), and Interrupt(). + +Implemented error checking for the Irq() and IrqNoFlags() macros +to detect too many values in the interrupt list (16 max) and +invalid values in the list (range 0 - 15) + +The maximum length string literal within an ASL file is now +restricted to 200 characters as per the ACPI specification. + +Fixed a fault when using the -ln option (generate namespace +listing). + +Implemented an error check to determine if a DescriptorName +within a resource descriptor has already been used within the +current scope. + +---------------------------------------- +15 August 2005. Summary of changes for version 20050815: + +1) ACPI CA Core Subsystem: + +Implemented a full bytewise compare to determine if a table load +request is attempting to load a duplicate table. The compare is +performed if the table signatures and table lengths match. This +will allow different tables with the same OEM Table ID and +revision to be loaded - probably against the ACPI specification, +but discovered in the field nonetheless. + +Added the changes.txt logfile to each of the zipped release +packages. + +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.6K Code, 11.7K Data, 90.3K Total + Debug Version: 167.0K Code, 69.9K Data, 236.9K Total + Current Release: + Non-Debug Version: 78.6K Code, 11.7K Data, 90.3K Total + Debug Version: 170.0K Code, 69.9K Data, 239.9K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem where incorrect AML code could be generated for +Package objects if optimization is disabled (via the -oa switch). + +Fixed a problem with where incorrect AML code is generated for +variable-length packages when the package length is not specified +and the number of initializer values is greater than 255. + +---------------------------------------- +29 July 2005. Summary of changes for version 20050729: + +1) ACPI CA Core Subsystem: + +Implemented support to ignore an attempt to install/load a +particular ACPI table more than once. Apparently there exists +BIOS code that repeatedly attempts to load the same SSDT upon +certain events. With assistance from Venkatesh Pallipadi. + +Restructured the main interface to the AML parser in order to +correctly handle all exceptional conditions. This will prevent +leakage of the OwnerId resource and should eliminate the +AE_OWNER_ID_LIMIT exceptions seen on some machines. With +assistance from Alexey Starikovskiy. + +Support for "module level code" has been disabled in this version +due to a number of issues that have appeared on various machines. +The support can be enabled by defining +ACPI_ENABLE_MODULE_LEVEL_CODE during subsystem compilation. When +the issues are fully resolved, the code will be enabled by +default again. + +Modified the internal functions for debug print support to define +the FunctionName parameter as a (const char *) for compatibility +with compiler built-in macros such as __FUNCTION__, etc. + +Linted the entire ACPICA source tree for both 32-bit and 64-bit. + +Implemented support to display an object count summary for the +AML Debugger commands Object and Methods. + +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.6K Code, 11.6K Data, 90.2K Total + Debug Version: 170.0K Code, 69.7K Data, 239.7K Total + Current Release: + Non-Debug Version: 78.6K Code, 11.7K Data, 90.3K Total + Debug Version: 167.0K Code, 69.9K Data, 236.9K Total + + +2) iASL Compiler/Disassembler: + +Fixed a regression that appeared in the 20050708 version of the +compiler where an error message was inadvertently emitted for +invocations of the _OSI reserved control method. + +---------------------------------------- +08 July 2005. Summary of changes for version 20050708: + +1) ACPI CA Core Subsystem: + +The use of the CPU stack in the debug version of the subsystem +has been considerably reduced. Previously, a debug structure was +declared in every function that used the debug macros. This +structure has been removed in favor of declaring the individual +elements as parameters to the debug functions. This reduces the +cumulative stack use during nested execution of ACPI function +calls at the cost of a small increase in the code size of the +debug version of the subsystem. With assistance from Alexey +Starikovskiy and Len Brown. + +Added the ACPI_GET_FUNCTION_NAME macro to enable the compiler- +dependent headers to define a macro that will return the current +function name at runtime (such as __FUNCTION__ or _func_, etc.) +The function name is used by the debug trace output. If +ACPI_GET_FUNCTION_NAME is not defined in the compiler-dependent +header, the function name is saved on the CPU stack (one pointer +per function.) This mechanism is used because apparently there +exists no standard ANSI-C defined macro that that returns the +function name. + +Redesigned and reimplemented the "Owner ID" mechanism used to +track namespace objects created/deleted by ACPI tables and +control method execution. A bitmap is now used to allocate and +free the IDs, thus solving the wraparound problem present in the +previous implementation. The size of the namespace node +descriptor was reduced by 2 bytes as a result (Alexey +Starikovskiy). + +Removed the UINT32_BIT and UINT16_BIT types that were used for +the bitfield flag definitions within the headers for the +predefined ACPI tables. These have been replaced by UINT8_BIT in +order to increase the code portability of the subsystem. If the +use of UINT8 remains a problem, we may be forced to eliminate +bitfields entirely because of a lack of portability. + +Enhanced the performance of the AcpiUtUpdateObjectReference +procedure. This is a frequently used function and this +improvement increases the performance of the entire subsystem +(Alexey Starikovskiy). + +Fixed several possible memory leaks and the inverse - premature +object deletion (Alexey Starikovskiy). + +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.6K Code, 11.5K Data, 90.1K Total + Debug Version: 165.2K Code, 69.6K Data, 234.8K Total + Current Release: + Non-Debug Version: 78.6K Code, 11.6K Data, 90.2K Total + Debug Version: 170.0K Code, 69.7K Data, 239.7K Total + +---------------------------------------- +24 June 2005. Summary of changes for version 20050624: + +1) ACPI CA Core Subsystem: + +Modified the new OSL cache interfaces to use ACPI_CACHE_T as the +type for the host-defined cache object. This allows the OSL +implementation to define and type this object in any manner +desired, simplifying the OSL implementation. For example, +ACPI_CACHE_T is defined as kmem_cache_t for Linux, and should be +defined in the OS-specific header file for other operating +systems as required. + +Changed the interface to AcpiOsAcquireObject to directly return +the requested object as the function return (instead of +ACPI_STATUS.) This change was made for performance reasons, since +this is the purpose of the interface in the first place. +AcpiOsAcquireObject is now similar to the AcpiOsAllocate +interface. + +Implemented a new AML debugger command named Businfo. This +command displays information about all devices that have an +associate _PRT object. The _ADR, _HID, _UID, and _CID are +displayed for these devices. + +Modified the initialization sequence in AcpiInitializeSubsystem +to call the OSL interface AcpiOslInitialize first, before any +local initialization. This change was required because the global +initialization now calls OSL interfaces. + +Enhanced the Dump command to display the entire contents of +Package objects (including all sub-objects and their values.) + +Restructured the code base to split some files because of size +and/or because the code logically belonged in a separate file. +New files are listed below. All makefiles and project files +included in the ACPI CA release have been updated. + utilities/utcache.c /* Local cache interfaces */ + utilities/utmutex.c /* Local mutex support */ + utilities/utstate.c /* State object support */ + interpreter/parser/psloop.c /* Main AML parse loop */ + +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.3K Code, 11.6K Data, 89.9K Total + Debug Version: 164.0K Code, 69.1K Data, 233.1K Total + Current Release: + Non-Debug Version: 78.6K Code, 11.5K Data, 90.1K Total + Debug Version: 165.2K Code, 69.6K Data, 234.8K Total + + +2) iASL Compiler/Disassembler: + +Fixed a regression introduced in version 20050513 where the use +of a Package object within a Case() statement caused a compile +time exception. The original behavior has been restored (a +Match() operator is emitted.) + +---------------------------------------- +17 June 2005. Summary of changes for version 20050617: + +1) ACPI CA Core Subsystem: + +Moved the object cache operations into the OS interface layer +(OSL) to allow the host OS to handle these operations if desired +(for example, the Linux OSL will invoke the slab allocator). This +support is optional; the compile time define ACPI_USE_LOCAL_CACHE +may be used to utilize the original cache code in the ACPI CA +core. The new OSL interfaces are shown below. See utalloc.c for +an example implementation, and acpiosxf.h for the exact interface +definitions. With assistance from Alexey Starikovskiy. + AcpiOsCreateCache + AcpiOsDeleteCache + AcpiOsPurgeCache + AcpiOsAcquireObject + AcpiOsReleaseObject + +Modified the interfaces to AcpiOsAcquireLock and +AcpiOsReleaseLock to return and restore a flags parameter. This +fits better with many OS lock models. Note: the current execution +state (interrupt handler or not) is no longer passed to these +interfaces. If necessary, the OSL must determine this state by +itself, a simple and fast operation. With assistance from Alexey +Starikovskiy. + +Fixed a problem in the ACPI table handling where a valid XSDT was +assumed present if the revision of the RSDP was 2 or greater. +According to the ACPI specification, the XSDT is optional in all +cases, and the table manager therefore now checks for both an +RSDP >=2 and a valid XSDT pointer. Otherwise, the RSDT pointer is +used. Some ACPI 2.0 compliant BIOSs contain only the RSDT. + +Fixed an interpreter problem with the Mid() operator in the case +of an input string where the resulting output string is of zero +length. It now correctly returns a valid, null terminated string +object instead of a string object with a null pointer. + +Fixed a problem with the control method argument handling to +allow a store to an Arg object that already contains an object of +type Device. The Device object is now correctly overwritten. +Previously, an error was returned. + +Enhanced the debugger Find command to emit object values in +addition to the found object pathnames. The output format is the +same as the dump namespace command. + +Enhanced the debugger Set command. It now has the ability to set +the value of any Named integer object in the namespace +(Previously, only method locals and args could be set.) + +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.1K Code, 11.6K Data, 89.7K Total + Debug Version: 164.0K Code, 69.3K Data, 233.3K Total + Current Release: + Non-Debug Version: 78.3K Code, 11.6K Data, 89.9K Total + Debug Version: 164.0K Code, 69.1K Data, 233.1K Total + + +2) iASL Compiler/Disassembler: + +Fixed a regression in the disassembler where if/else/while +constructs were output incorrectly. This problem was introduced +in the previous release (20050526). This problem also affected +the single-step disassembly in the debugger. + +Fixed a problem where compiling the reserved _OSI method would +randomly (but rarely) produce compile errors. + +Enhanced the disassembler to emit compilable code in the face of +incorrect AML resource descriptors. If the optional +ResourceSourceIndex is present, but the ResourceSource is not, do +not emit the ResourceSourceIndex in the disassembly. Otherwise, +the resulting code cannot be compiled without errors. + +---------------------------------------- +26 May 2005. Summary of changes for version 20050526: + +1) ACPI CA Core Subsystem: + +Implemented support to execute Type 1 and Type 2 AML opcodes +appearing at the module level (not within a control method.) +These opcodes are executed exactly once at the time the table is +loaded. This type of code was legal up until the release of ACPI +2.0B (2002) and is now supported within ACPI CA in order to +provide backwards compatibility with earlier BIOS +implementations. This eliminates the "Encountered executable code +at module level" warning that was previously generated upon +detection of such code. + +Fixed a problem in the interpreter where an AE_NOT_FOUND +exception could inadvertently be generated during the lookup of +namespace objects in the second pass parse of ACPI tables and +control methods. It appears that this problem could occur during +the resolution of forward references to namespace objects. + +Added the ACPI_MUTEX_DEBUG #ifdef to the AcpiUtReleaseMutex +function, corresponding to the same #ifdef in the +AcpiUtAcquireMutex function. This allows the deadlock detection +debug code to be compiled out in the normal case, improving mutex +performance (and overall subsystem performance) considerably. + +Implemented a handful of miscellaneous fixes for possible memory +leaks on error conditions and error handling control paths. These +fixes were suggested by FreeBSD and the Coverity Prevent source +code analysis tool. + +Added a check for a null RSDT pointer in AcpiGetFirmwareTable +(tbxfroot.c) to prevent a fault in this error case. + +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.2K Code, 11.6K Data, 89.8K Total + Debug Version: 163.7K Code, 69.3K Data, 233.0K Total + Current Release: + Non-Debug Version: 78.1K Code, 11.6K Data, 89.7K Total + Debug Version: 164.0K Code, 69.3K Data, 233.3K Total + + +2) iASL Compiler/Disassembler: + +Implemented support to allow Type 1 and Type 2 ASL operators to +appear at the module level (not within a control method.) These +operators will be executed once at the time the table is loaded. +This type of code was legal up until the release of ACPI 2.0B +(2002) and is now supported by the iASL compiler in order to +provide backwards compatibility with earlier BIOS ASL code. + +The ACPI integer width (specified via the table revision ID or +the -r override, 32 or 64 bits) is now used internally during +compile-time constant folding to ensure that constants are +truncated to 32 bits if necessary. Previously, the revision ID +value was only emitted in the AML table header. + +An error message is now generated for the Mutex and Method +operators if the SyncLevel parameter is outside the legal range +of 0 through 15. + +Fixed a problem with the Method operator ParameterTypes list +handling (ACPI 3.0). Previously, more than 2 types or 2 arguments +generated a syntax error. The actual underlying implementation +of method argument typechecking is still under development, +however. + +---------------------------------------- +13 May 2005. Summary of changes for version 20050513: + +1) ACPI CA Core Subsystem: + +Implemented support for PCI Express root bridges -- added support +for device PNP0A08 in the root bridge search within +AcpiEvPciConfigRegionSetup. + +The interpreter now automatically truncates incoming 64-bit +constants to 32 bits if currently executing out of a 32-bit ACPI +table (Revision < 2). This also affects the iASL compiler +constant folding. (Note: as per below, the iASL compiler no +longer allows 64-bit constants within 32-bit tables.) + +Fixed a problem where string and buffer objects with "static" +pointers (pointers to initialization data within an ACPI table) +were not handled consistently. The internal object copy operation +now always copies the data to a newly allocated buffer, +regardless of whether the source object is static or not. + +Fixed a problem with the FromBCD operator where an implicit +result conversion was improperly performed while storing the +result to the target operand. Since this is an "explicit +conversion" operator, the implicit conversion should never be +performed on the output. + +Fixed a problem with the CopyObject operator where a copy to an +existing named object did not always completely overwrite the +existing object stored at name. Specifically, a buffer-to-buffer +copy did not delete the existing buffer. + +Replaced "InterruptLevel" with "InterruptNumber" in all GPE +interfaces and structs for consistency. + +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.2K Code, 11.6K Data, 89.8K Total + Debug Version: 163.7K Code, 69.3K Data, 233.0K Total + Current Release: (Same sizes) + Non-Debug Version: 78.2K Code, 11.6K Data, 89.8K Total + Debug Version: 163.7K Code, 69.3K Data, 233.0K Total + + +2) iASL Compiler/Disassembler: + +The compiler now emits a warning if an attempt is made to +generate a 64-bit integer constant from within a 32-bit ACPI +table (Revision < 2). The integer is truncated to 32 bits. + +Fixed a problem with large package objects: if the static length +of the package is greater than 255, the "variable length package" +opcode is emitted. Previously, this caused an error. This +requires an update to the ACPI spec, since it currently +(incorrectly) states that packages larger than 255 elements are +not allowed. + +The disassembler now correctly handles variable length packages +and packages larger than 255 elements. + +---------------------------------------- +08 April 2005. Summary of changes for version 20050408: + +1) ACPI CA Core Subsystem: + +Fixed three cases in the interpreter where an "index" argument to +an ASL function was still (internally) 32 bits instead of the +required 64 bits. This was the Index argument to the Index, Mid, +and Match operators. + +The "strupr" function is now permanently local (AcpiUtStrupr), +since this is not a POSIX-defined function and not present in +most kernel-level C libraries. All references to the C library +strupr function have been removed from the headers. + +Completed the deployment of static functions/prototypes. All +prototypes with the static attribute have been moved from the +headers to the owning C file. + +Implemented an extract option (-e) for the AcpiBin utility (AML +binary utility). This option allows the utility to extract +individual ACPI tables from the output of AcpiDmp. It provides +the same functionality of the acpixtract.pl perl script without +the worry of setting the correct perl options. AcpiBin runs on +Windows and has not yet been generated/validated in the +Linux/Unix environment (but should be soon). + +Updated and fixed the table dump option for AcpiBin (-d). This +option converts a single ACPI table to a hex/ascii file, similar +to the output of AcpiDmp. + +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.6K Data, 89.6K Total + Debug Version: 163.5K Code, 69.3K Data, 232.8K Total + Current Release: + Non-Debug Version: 78.2K Code, 11.6K Data, 89.8K Total + Debug Version: 163.7K Code, 69.3K Data, 233.0K Total + + +2) iASL Compiler/Disassembler: + +Disassembler fix: Added a check to ensure that the table length +found in the ACPI table header within the input file is not +longer than the actual input file size. This indicates some kind +of file or table corruption. + +---------------------------------------- +29 March 2005. Summary of changes for version 20050329: + +1) ACPI CA Core Subsystem: + +An error is now generated if an attempt is made to create a +Buffer Field of length zero (A CreateField with a length operand +of zero.) + +The interpreter now issues a warning whenever executable code at +the module level is detected during ACPI table load. This will +give some idea of the prevalence of this type of code. + +Implemented support for references to named objects (other than +control methods) within package objects. + +Enhanced package object output for the debug object. Package +objects are now completely dumped, showing all elements. + +Enhanced miscellaneous object output for the debug object. Any +object can now be written to the debug object (for example, a +device object can be written, and the type of the object will be +displayed.) + +The "static" qualifier has been added to all local functions +across both the core subsystem and the iASL compiler. + +The number of "long" lines (> 80 chars) within the source has +been significantly reduced, by about 1/3. + +Cleaned up all header files to ensure that all CA/iASL functions +are prototyped (even static functions) and the formatting is +consistent. + +Two new header files have been added, acopcode.h and acnames.h. + +Removed several obsolete functions that were no longer used. + +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.3K Code, 11.5K Data, 89.8K Total + Debug Version: 165.4K Code, 69.7K Data, 236.1K Total + Current Release: + Non-Debug Version: 78.0K Code, 11.6K Data, 89.6K Total + Debug Version: 163.5K Code, 69.3K Data, 232.8K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem with the resource descriptor generation/support. +For the ResourceSourceIndex and the ResourceSource fields, both +must be present, or both must be not present - can't have one +without the other. + +The compiler now returns non-zero from the main procedure if any +errors have occurred during the compilation. + + +---------------------------------------- +09 March 2005. Summary of changes for version 20050309: + +1) ACPI CA Core Subsystem: + +The string-to-buffer implicit conversion code has been modified +again after a change to the ACPI specification. In order to +match the behavior of the other major ACPI implementation, the +target buffer is no longer truncated if the source string is +smaller than an existing target buffer. This change requires an +update to the ACPI spec, and should eliminate the recent +AE_AML_BUFFER_LIMIT issues. + +The "implicit return" support was rewritten to a new algorithm +that solves the general case. Rather than attempt to determine +when a method is about to exit, the result of every ASL operator +is saved momentarily until the very next ASL operator is +executed. Therefore, no matter how the method exits, there will +always be a saved implicit return value. This feature is only +enabled with the AcpiGbl_EnableInterpreterSlack flag, and should +eliminate AE_AML_NO_RETURN_VALUE errors when enabled. + +Implemented implicit conversion support for the predicate +(operand) of the If, Else, and While operators. String and Buffer +arguments are automatically converted to Integers. + +Changed the string-to-integer conversion behavior to match the +new ACPI errata: "If no integer object exists, a new integer is +created. The ASCII string is interpreted as a hexadecimal +constant. Each string character is interpreted as a hexadecimal +value (`0'-`9', `A'-`F', `a', `f'), starting with the first +character as the most significant digit, and ending with the +first non-hexadecimal character or end-of-string." This means +that the first non-hex character terminates the conversion and +this is the code that was changed. + +Fixed a problem where the ObjectType operator would fail (fault) +when used on an Index of a Package which pointed to a null +package element. The operator now properly returns zero +(Uninitialized) in this case. + +Fixed a problem where the While operator used excessive memory by +not properly popping the result stack during execution. There was +no memory leak after execution, however. (Code provided by Valery +Podrezov.) + +Fixed a problem where references to control methods within +Package objects caused the method to be invoked, instead of +producing a reference object pointing to the method. + +Restructured and simplified the pswalk.c module +(AcpiPsDeleteParseTree) to improve performance and reduce code +size. (Code provided by Alexey Starikovskiy.) + +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.3K Code, 11.5K Data, 89.8K Total + Debug Version: 165.4K Code, 69.6K Data, 236.0K Total + Current Release: + Non-Debug Version: 78.3K Code, 11.5K Data, 89.8K Total + Debug Version: 165.4K Code, 69.7K Data, 236.1K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem with the Return operator with no arguments. Since +the AML grammar for the byte encoding requires an operand for the +Return opcode, the compiler now emits a Return(Zero) for this +case. An ACPI specification update has been written for this +case. + +For tables other than the DSDT, namepath optimization is +automatically disabled. This is because SSDTs can be loaded +anywhere in the namespace, the compiler has no knowledge of +where, and thus cannot optimize namepaths. + +Added "ProcessorObj" to the ObjectTypeKeyword list. This object +type was inadvertently omitted from the ACPI specification, and +will require an update to the spec. + +The source file scan for ASCII characters is now optional (-a). +This change was made because some vendors place non-ascii +characters within comments. However, the scan is simply a brute- +force byte compare to ensure all characters in the file are in +the range 0x00 to 0x7F. + +Fixed a problem with the CondRefOf operator where the compiler +was inappropriately checking for the existence of the target. +Since the point of the operator is to check for the existence of +the target at run-time, the compiler no longer checks for the +target existence. + +Fixed a problem where errors generated from the internal AML +interpreter during constant folding were not handled properly, +causing a fault. + +Fixed a problem with overly aggressive range checking for the +Stall operator. The valid range (max 255) is now only checked if +the operand is of type Integer. All other operand types cannot be +statically checked. + +Fixed a problem where control method references within the RefOf, +DeRefOf, and ObjectType operators were not treated properly. They +are now treated as actual references, not method invocations. + +Fixed and enhanced the "list namespace" option (-ln). This option +was broken a number of releases ago. + +Improved error handling for the Field, IndexField, and BankField +operators. The compiler now cleanly reports and recovers from +errors in the field component (FieldUnit) list. + +Fixed a disassembler problem where the optional +ResourceDescriptor fields TRS and TTP were not always handled +correctly. + +Disassembler - Comments in output now use "//" instead of "/*" + +---------------------------------------- +28 February 2005. Summary of changes for version 20050228: + +1) ACPI CA Core Subsystem: + +Fixed a problem where the result of an Index() operator (an +object reference) must increment the reference count on the +target object for the life of the object reference. + +Implemented AML Interpreter and Debugger support for the new ACPI +3.0 Extended Address (IO, Memory, Space), QwordSpace, DwordSpace, +and WordSpace resource descriptors. + +Implemented support in the _OSI method for the ACPI 3.0 "Extended +Address Space Descriptor" string, indicating interpreter support +for the descriptors above. + +Implemented header support for the new ACPI 3.0 FADT flag bits. + +Implemented header support for the new ACPI 3.0 PCI Express bits +for the PM1 status/enable registers. + +Updated header support for the MADT processor local Apic struct +and MADT platform interrupt source struct for new ACPI 3.0 +fields. + +Implemented header support for the SRAT and SLIT ACPI tables. + +Implemented the -s switch in AcpiExec to enable the +"InterpeterSlack" flag at runtime. + +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.2K Code, 11.5K Data, 89.7K Total + Debug Version: 164.9K Code, 69.2K Data, 234.1K Total + Current Release: + Non-Debug Version: 78.3K Code, 11.5K Data, 89.8K Total + Debug Version: 165.4K Code, 69.6K Data, 236.0K Total + + +2) iASL Compiler/Disassembler: + +Fixed a problem with the internal 64-bit String-to-integer +conversion with strings less than two characters long. + +Fixed a problem with constant folding where the result of the +Index() operator can not be considered a constant. This means +that Index() cannot be a type3 opcode and this will require an +update to the ACPI specification. + +Disassembler: Implemented support for the TTP, MTP, and TRS +resource descriptor fields. These fields were inadvertently +ignored and not output in the disassembly of the resource +descriptor. + + + ---------------------------------------- +11 February 2005. Summary of changes for version 20050211: + +1) ACPI CA Core Subsystem: + +Implemented ACPI 3.0 support for implicit conversion within the +Match() operator. MatchObjects can now be of type integer, +buffer, or string instead of just type integer. Package elements +are implicitly converted to the type of the MatchObject. This +change aligns the behavior of Match() with the behavior of the +other logical operators (LLess(), etc.) It also requires an +errata change to the ACPI specification as this support was +intended for ACPI 3.0, but was inadvertently omitted. + +Fixed a problem with the internal implicit "to buffer" +conversion. Strings that are converted to buffers will cause +buffer truncation if the string is smaller than the target +buffer. Integers that are converted to buffers will not cause +buffer truncation, only zero extension (both as per the ACPI +spec.) The problem was introduced when code was added to truncate +the buffer, but this should not be performed in all cases, only +the string case. + +Fixed a problem with the Buffer and Package operators where the +interpreter would get confused if two such operators were used as +operands to an ASL operator (such as +LLess(Buffer(1){0},Buffer(1){1}). The internal result stack was +not being popped after the execution of these operators, +resulting in an AE_NO_RETURN_VALUE exception. + +Fixed a problem with constructs of the form +Store(Index(...),...). The reference object returned from Index +was inadvertently resolved to an actual value. This problem was +introduced in version 20050114 when the behavior of Store() was +modified to restrict the object types that can be used as the +source operand (to match the ACPI specification.) + +Reduced excessive stack use within the AcpiGetObjectInfo +procedure. + +Added a fix to aclinux.h to allow generation of AcpiExec on +Linux. + +Updated the AcpiSrc utility to add the FADT_DESCRIPTOR_REV2_MINUS +struct. + +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.1K Code, 11.5K Data, 89.6K Total + Debug Version: 164.8K Code, 69.2K Data, 234.0K Total + Current Release: + Non-Debug Version: 78.2K Code, 11.5K Data, 89.7K Total + Debug Version: 164.9K Code, 69.2K Data, 234.1K Total + + +2) iASL Compiler/Disassembler: + +Fixed a code generation problem in the constant folding +optimization code where incorrect code was generated if a +constant was reduced to a buffer object (i.e., a reduced type 5 +opcode.) + +Fixed a typechecking problem for the ToBuffer operator. Caused by +an incorrect return type in the internal opcode information +table. + +---------------------------------------- +25 January 2005. Summary of changes for version 20050125: + +1) ACPI CA Core Subsystem: + +Fixed a recently introduced problem with the Global Lock where +the underlying semaphore was not created. This problem was +introduced in version 20050114, and caused an AE_AML_NO_OPERAND +exception during an Acquire() operation on _GL. + +The local object cache is now optional, and is disabled by +default. Both AcpiExec and the iASL compiler enable the cache +because they run in user mode and this enhances their +performance. #define ACPI_ENABLE_OBJECT_CACHE to enable the local +cache. + +Fixed an issue in the internal function AcpiUtEvaluateObject +concerning the optional "implicit return" support where an error +was returned if no return object was expected, but one was +implicitly returned. AE_OK is now returned in this case and the +implicitly returned object is deleted. AcpiUtEvaluateObject is +only occasionally used, and only to execute reserved methods such +as _STA and _INI where the return type is known up front. + +Fixed a few issues with the internal convert-to-integer code. It +now returns an error if an attempt is made to convert a null +string, a string of only blanks/tabs, or a zero-length buffer. +This affects both implicit conversion and explicit conversion via +the ToInteger() operator. + +The internal debug code in AcpiUtAcquireMutex has been commented +out. It is not needed for normal operation and should increase +the performance of the entire subsystem. The code remains in case +it is needed for debug purposes again. + +The AcpiExec source and makefile are included in the Unix/Linux +package for the first time. + +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.4K Code, 11.5K Data, 89.9K Total + Debug Version: 165.4K Code, 69.4K Data, 234.8K Total + Current Release: + Non-Debug Version: 78.1K Code, 11.5K Data, 89.6K Total + Debug Version: 164.8K Code, 69.2K Data, 234.0K Total + +2) iASL Compiler/Disassembler: + +Switch/Case support: A warning is now issued if the type of the +Switch value cannot be determined at compile time. For example, +Switch(Arg0) will generate the warning, and the type is assumed +to be an integer. As per the ACPI spec, use a construct such as +Switch(ToInteger(Arg0)) to eliminate the warning. + +Switch/Case support: Implemented support for buffer and string +objects as the switch value. This is an ACPI 3.0 feature, now +that LEqual supports buffers and strings. + +Switch/Case support: The emitted code for the LEqual() +comparisons now uses the switch value as the first operand, not +the second. The case value is now the second operand, and this +allows the case value to be implicitly converted to the type of +the switch value, not the other way around. + +Switch/Case support: Temporary variables are now emitted +immediately within the control method, not at the global level. +This means that there are now 36 temps available per-method, not +36 temps per-module as was the case with the earlier +implementation (_T_0 through _T_9 and _T_A through _T_Z.) + +---------------------------------------- +14 January 2005. Summary of changes for version 20050114: + +Added 2005 copyright to all module headers. This affects every +module in the core subsystem, iASL compiler, and the utilities. + +1) ACPI CA Core Subsystem: + +Fixed an issue with the String-to-Buffer conversion code where +the string null terminator was not included in the buffer after +conversion, but there is existing ASL that assumes the string +null terminator is included. This is the root of the +ACPI_AML_BUFFER_LIMIT regression. This problem was introduced in +the previous version when the code was updated to correctly set +the converted buffer size as per the ACPI specification. The ACPI +spec is ambiguous and will be updated to specify that the null +terminator must be included in the converted buffer. This also +affects the ToBuffer() ASL operator. + +Fixed a problem with the Mid() ASL/AML operator where it did not +work correctly on Buffer objects. Newly created sub-buffers were +not being marked as initialized. + +Fixed a problem in AcpiTbFindTable where incorrect string +compares were performed on the OemId and OemTableId table header +fields. These fields are not null terminated, so strncmp is now +used instead of strcmp. + +Implemented a restriction on the Store() ASL/AML operator to +align the behavior with the ACPI specification. Previously, any +object could be used as the source operand. Now, the only +objects that may be used are Integers, Buffers, Strings, +Packages, Object References, and DDB Handles. If necessary, the +original behavior can be restored by enabling the +EnableInterpreterSlack flag. + +Enhanced the optional "implicit return" support to allow an +implicit return value from methods that are invoked externally +via the AcpiEvaluateObject interface. This enables implicit +returns from the _STA and _INI methods, for example. + +Changed the Revision() ASL/AML operator to return the current +version of the AML interpreter, in the YYYYMMDD format. +Previously, it incorrectly returned the supported ACPI version +(This is the function of the _REV method). + +Updated the _REV predefined method to return the currently +supported version of ACPI, now 3. + +Implemented batch mode option for the AcpiExec utility (-b). + +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.3K Code, 11.5K Data, 89.8K Total + Debug Version: 165.3K Code, 69.4K Data, 234.7K Total + Current Release: + Non-Debug Version: 78.4K Code, 11.5K Data, 89.9K Total + Debug Version: 165.4K Code, 69.4K Data, 234.8K Total + +---------------------------------------- +10 December 2004. Summary of changes for version 20041210: + +ACPI 3.0 support is nearing completion in both the iASL compiler +and the ACPI CA core subsystem. + +1) ACPI CA Core Subsystem: + +Fixed a problem in the ToDecimalString operator where the +resulting string length was incorrectly calculated. The length is +now calculated exactly, eliminating incorrect AE_STRING_LIMIT +exceptions. + +Fixed a problem in the ToHexString operator to allow a maximum +200 character string to be produced. + +Fixed a problem in the internal string-to-buffer and buffer-to- +buffer copy routine where the length of the resulting buffer was +not truncated to the new size (if the target buffer already +existed). + +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.3K Code, 11.5K Data, 89.8K Total + Debug Version: 164.7K Code, 68.5K Data, 233.2K Total + Current Release: + Non-Debug Version: 78.3K Code, 11.5K Data, 89.8K Total + Debug Version: 165.3K Code, 69.4K Data, 234.7K Total + + +2) iASL Compiler/Disassembler: + +Implemented the new ACPI 3.0 resource template macros - +DWordSpace, ExtendedIO, ExtendedMemory, ExtendedSpace, +QWordSpace, and WordSpace. Includes support in the disassembler. + +Implemented support for the new (ACPI 3.0) parameter to the +Register macro, AccessSize. + +Fixed a problem where the _HE resource name for the Interrupt +macro was referencing bit 0 instead of bit 1. + +Implemented check for maximum 255 interrupts in the Interrupt +macro. + +Fixed a problem with the predefined resource descriptor names +where incorrect AML code was generated if the offset within the +resource buffer was 0 or 1. The optimizer shortened the AML code +to a single byte opcode but did not update the surrounding +package lengths. + +Changes to the Dma macro: All channels within the channel list +must be in the range 0-7. Maximum 8 channels can be specified. +BusMaster operand is optional (default is BusMaster). + +Implemented check for maximum 7 data bytes for the VendorShort +macro. + +The ReadWrite parameter is now optional for the Memory32 and +similar macros. + +---------------------------------------- +03 December 2004. Summary of changes for version 20041203: + +1) ACPI CA Core Subsystem: + +The low-level field insertion/extraction code (exfldio) has been +completely rewritten to eliminate unnecessary complexity, bugs, +and boundary conditions. + +Fixed a problem in the ToInteger, ToBuffer, ToHexString, and +ToDecimalString operators where the input operand could be +inadvertently deleted if no conversion was necessary (e.g., if +the input to ToInteger was an Integer object.) + +Fixed a problem with the ToDecimalString and ToHexString where an +incorrect exception code was returned if the resulting string +would be > 200 chars. AE_STRING_LIMIT is now returned. + +Fixed a problem with the Concatenate operator where AE_OK was +always returned, even if the operation failed. + +Fixed a problem in oswinxf (used by AcpiExec and iASL) to allow > +128 semaphores to be allocated. + +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.3K Code, 11.5K Data, 89.8K Total + Debug Version: 164.7K Code, 68.5K Data, 233.2K Total + + +2) iASL Compiler/Disassembler: + +Fixed typechecking for the ObjectType and SizeOf operators. +Problem was recently introduced in 20041119. + +Fixed a problem with the ToUUID macro where the upper nybble of +each buffer byte was inadvertently set to zero. + +---------------------------------------- 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 +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: diff --git a/sys/contrib/dev/acpica/acapps.h b/sys/contrib/dev/acpica/acapps.h index 8e5b854..c93fa9a 100644 --- a/sys/contrib/dev/acpica/acapps.h +++ b/sys/contrib/dev/acpica/acapps.h @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/acconfig.h b/sys/contrib/dev/acpica/acconfig.h index f5b994a..d3ff2a9 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: 169 $ + * $Revision: 1.194 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -135,9 +135,9 @@ * */ -/* Version string */ +/* Current ACPICA subsystem version in YYYYMMDD format */ -#define ACPI_CA_VERSION 0x20041119 +#define ACPI_CA_VERSION 0x20051021 /* * OS name, used for the _OS object. The _OS object is essentially obsolete, @@ -151,11 +151,10 @@ /* Maximum objects in the various object caches */ -#define ACPI_MAX_STATE_CACHE_DEPTH 64 /* State objects */ +#define ACPI_MAX_STATE_CACHE_DEPTH 96 /* State objects */ #define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ -#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 64 /* Parse tree objects */ -#define ACPI_MAX_OBJECT_CACHE_DEPTH 64 /* Interpreter operand objects */ -#define ACPI_MAX_WALK_CACHE_DEPTH 4 /* Objects for parse tree walks */ +#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */ +#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */ /* * Should the subystem abort the loading of an ACPI table if the @@ -172,7 +171,7 @@ /* Version of ACPI supported */ -#define ACPI_CA_SUPPORT_LEVEL 2 +#define ACPI_CA_SUPPORT_LEVEL 3 /* String size constants */ @@ -203,9 +202,8 @@ #define ACPI_MAX_GPE_BLOCKS 2 #define ACPI_GPE_REGISTER_WIDTH 8 -/* - * Method info (in WALK_STATE), containing local variables and argumetns - */ +/* Method info (in WALK_STATE), containing local variables and argumetns */ + #define ACPI_METHOD_NUM_LOCALS 8 #define ACPI_METHOD_MAX_LOCAL 7 @@ -271,7 +269,7 @@ /* Number of strings associated with the _OSI reserved method */ -#define ACPI_NUM_OSI_STRINGS 9 +#define ACPI_NUM_OSI_STRINGS 10 /****************************************************************************** diff --git a/sys/contrib/dev/acpica/acdebug.h b/sys/contrib/dev/acpica/acdebug.h index 2ea965c..7222fed 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: 75 $ + * $Revision: 1.80 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -136,9 +136,7 @@ typedef struct ArgumentInfo #define PARAM_LIST(pl) pl - #define DBTEST_OUTPUT_LEVEL(lvl) if (AcpiGbl_DbOpt_verbose) - #define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ AcpiOsPrintf PARAM_LIST(fp);} @@ -146,13 +144,9 @@ typedef struct ArgumentInfo #define EX_SINGLE_STEP 2 -/* Prototypes */ - - /* * dbxface - external debugger interfaces */ - ACPI_STATUS AcpiDbInitialize ( void); @@ -167,20 +161,10 @@ AcpiDbSingleStep ( ACPI_PARSE_OBJECT *Op, UINT32 OpType); -ACPI_STATUS -AcpiDbStartCommand ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op); - -void -AcpiDbMethodEnd ( - ACPI_WALK_STATE *WalkState); - /* * dbcmds - debug commands and output routines */ - ACPI_STATUS AcpiDbDisassembleMethod ( char *Name); @@ -205,6 +189,10 @@ AcpiDbSetMethodCallBreakpoint ( ACPI_PARSE_OBJECT *Op); void +AcpiDbGetBusInfo ( + void); + +void AcpiDbDisassembleAml ( char *Statements, ACPI_PARSE_OBJECT *Op); @@ -252,57 +240,30 @@ AcpiDbFindReferences ( char *ObjectArg); void -AcpiDbDisplayLocks (void); - +AcpiDbDisplayLocks ( + void); void AcpiDbDisplayResources ( char *ObjectArg); void -AcpiDbDisplayGpes (void); +AcpiDbDisplayGpes ( + void); void AcpiDbCheckIntegrity ( void); -ACPI_STATUS -AcpiDbIntegrityWalk ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - -ACPI_STATUS -AcpiDbWalkAndMatchName ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - -ACPI_STATUS -AcpiDbWalkForReferences ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - -ACPI_STATUS -AcpiDbWalkForSpecificObjects ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - void AcpiDbGenerateGpe ( char *GpeArg, char *BlockArg); + /* * dbdisply - debug display commands */ - void AcpiDbDisplayMethodInfo ( ACPI_PARSE_OBJECT *Op); @@ -346,19 +307,10 @@ AcpiDbDisplayArgumentObject ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState); -void -AcpiDbDumpParserDescriptor ( - ACPI_PARSE_OBJECT *Op); - -void * -AcpiDbGetPointer ( - void *Target); - /* * dbexec - debugger control method execution */ - void AcpiDbExecute ( char *Name, @@ -371,44 +323,15 @@ AcpiDbCreateExecutionThreads ( char *NumLoopsArg, char *MethodNameArg); -ACPI_STATUS -AcpiDbExecuteMethod ( - ACPI_DB_METHOD_INFO *Info, - ACPI_BUFFER *ReturnObj); - -void -AcpiDbExecuteSetup ( - ACPI_DB_METHOD_INFO *Info); - -UINT32 -AcpiDbGetOutstandingAllocations ( - void); - -void ACPI_SYSTEM_XFACE -AcpiDbMethodThread ( - void *Context); - -ACPI_STATUS -AcpiDbExecutionWalk ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - /* * dbfileio - Debugger file I/O commands */ - ACPI_OBJECT_TYPE AcpiDbMatchArgument ( char *UserArgument, ARGUMENT_INFO *Arguments); -ACPI_STATUS -AeLocalLoadTable ( - ACPI_TABLE_HEADER *TablePtr); - void AcpiDbCloseDebugFile ( void); @@ -431,16 +354,17 @@ AcpiDbReadTableFromFile ( char *Filename, ACPI_TABLE_HEADER **Table); + /* * dbhistry - debugger HISTORY command */ - void AcpiDbAddToHistory ( char *CommandLine); void -AcpiDbDisplayHistory (void); +AcpiDbDisplayHistory ( + void); char * AcpiDbGetFromHistory ( @@ -450,7 +374,6 @@ AcpiDbGetFromHistory ( /* * dbinput - user front-end to the AML debugger */ - ACPI_STATUS AcpiDbCommandDispatch ( char *InputBuffer, @@ -466,72 +389,29 @@ AcpiDbUserCommands ( char Prompt, ACPI_PARSE_OBJECT *Op); -void -AcpiDbDisplayHelp ( - char *HelpType); - -char * -AcpiDbGetNextToken ( - char *String, - char **Next); - -UINT32 -AcpiDbGetLine ( - char *InputBuffer); - -UINT32 -AcpiDbMatchCommand ( - char *UserCommand); - -void -AcpiDbSingleThread ( - void); - /* * dbstats - Generation and display of ACPI table statistics */ - void AcpiDbGenerateStatistics ( ACPI_PARSE_OBJECT *Root, BOOLEAN IsMethod); - ACPI_STATUS AcpiDbDisplayStatistics ( char *TypeArg); -ACPI_STATUS -AcpiDbClassifyOneObject ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); - -void -AcpiDbCountNamespaceObjects ( - void); - -void -AcpiDbEnumerateObject ( - ACPI_OPERAND_OBJECT *ObjDesc); - /* * dbutils - AML debugger utilities */ - void AcpiDbSetOutputDestination ( UINT32 Where); void -AcpiDbDumpBuffer ( - UINT32 Address); - -void -AcpiDbDumpObject ( +AcpiDbDumpExternalObject ( ACPI_OBJECT *ObjDesc, UINT32 Level); @@ -539,14 +419,8 @@ void AcpiDbPrepNamestring ( char *Name); - -ACPI_STATUS -AcpiDbSecondPassParse ( - ACPI_PARSE_OBJECT *Root); - ACPI_NAMESPACE_NODE * AcpiDbLocalNsLookup ( char *Name); - #endif /* __ACDEBUG_H__ */ diff --git a/sys/contrib/dev/acpica/acdisasm.h b/sys/contrib/dev/acpica/acdisasm.h index 721c34b..718f376 100644 --- a/sys/contrib/dev/acpica/acdisasm.h +++ b/sys/contrib/dev/acpica/acdisasm.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acdisasm.h - AML disassembler - * $Revision: 12 $ + * $Revision: 1.25 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -136,6 +136,7 @@ extern ACPI_EXTERNAL_LIST *AcpiGbl_ExternalList; extern const char *AcpiGbl_IoDecode[2]; extern const char *AcpiGbl_WordDecode[4]; extern const char *AcpiGbl_ConsumeDecode[2]; +extern const char *AcpiGbl_ConfigDecode[4]; extern const char *AcpiGbl_MinDecode[2]; extern const char *AcpiGbl_MaxDecode[2]; extern const char *AcpiGbl_DECDecode[2]; @@ -149,6 +150,10 @@ extern const char *AcpiGbl_SHRDecode[2]; extern const char *AcpiGbl_TYPDecode[4]; extern const char *AcpiGbl_BMDecode[2]; extern const char *AcpiGbl_SIZDecode[4]; +extern const char *AcpiGbl_TTPDecode[2]; +extern const char *AcpiGbl_MTPDecode[4]; +extern const char *AcpiGbl_TRSDecode[2]; + extern const char *AcpiGbl_LockRule[ACPI_NUM_LOCK_RULES]; extern const char *AcpiGbl_AccessTypes[ACPI_NUM_ACCESS_TYPES]; extern const char *AcpiGbl_UpdateRules[ACPI_NUM_UPDATE_RULES]; @@ -159,6 +164,7 @@ typedef struct acpi_op_walk_info { UINT32 Level; UINT32 BitOffset; + ACPI_WALK_STATE *WalkState; } ACPI_OP_WALK_INFO; @@ -172,58 +178,16 @@ ACPI_STATUS (*ASL_WALK_CALLBACK) ( /* * dmwalk */ - -void -AcpiDmWalkParseTree ( - ACPI_PARSE_OBJECT *Op, - ASL_WALK_CALLBACK DescendingCallback, - ASL_WALK_CALLBACK AscendingCallback, - void *Context); - -ACPI_STATUS -AcpiDmDescendingOp ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -ACPI_STATUS -AcpiDmAscendingOp ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - - -/* - * dmopcode - */ - -void -AcpiDmValidateName ( - char *Name, - ACPI_PARSE_OBJECT *Op); - -UINT32 -AcpiDmDumpName ( - char *Name); - -void -AcpiDmUnicode ( - ACPI_PARSE_OBJECT *Op); - void AcpiDmDisassemble ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Origin, UINT32 NumOpcodes); -void -AcpiDmNamestring ( - char *Name); - -void -AcpiDmDisplayPath ( - ACPI_PARSE_OBJECT *Op); +/* + * dmopcode + */ void AcpiDmDisassembleOneOp ( ACPI_WALK_STATE *WalkState, @@ -235,18 +199,9 @@ AcpiDmDecodeInternalObject ( ACPI_OPERAND_OBJECT *ObjDesc); UINT32 -AcpiDmBlockType ( - ACPI_PARSE_OBJECT *Op); - -UINT32 AcpiDmListType ( ACPI_PARSE_OBJECT *Op); -ACPI_STATUS -AcpiPsDisplayObjectPathname ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op); - void AcpiDmMethodFlags ( ACPI_PARSE_OBJECT *Op); @@ -267,10 +222,6 @@ void AcpiDmMatchOp ( ACPI_PARSE_OBJECT *Op); -void -AcpiDmMatchKeyword ( - ACPI_PARSE_OBJECT *Op); - BOOLEAN AcpiDmCommaIfListMember ( ACPI_PARSE_OBJECT *Op); @@ -281,13 +232,25 @@ AcpiDmCommaIfFieldMember ( /* - * dmobject + * dmnames */ +UINT32 +AcpiDmDumpName ( + char *Name); + +ACPI_STATUS +AcpiPsDisplayObjectPathname ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); void -AcpiDmDecodeNode ( - ACPI_NAMESPACE_NODE *Node); +AcpiDmNamestring ( + char *Name); + +/* + * dmobject + */ void AcpiDmDisplayInternalObject ( ACPI_OPERAND_OBJECT *ObjDesc, @@ -311,9 +274,19 @@ AcpiDmDumpMethodInfo ( /* * dmbuffer */ +void +AcpiDmDisasmByteList ( + UINT32 Level, + UINT8 *ByteData, + UINT32 ByteCount); void -AcpiIsEisaId ( +AcpiDmByteList ( + ACPI_OP_WALK_INFO *Info, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmIsEisaId ( ACPI_PARSE_OBJECT *Op); void @@ -332,26 +305,34 @@ AcpiDmIsStringBuffer ( /* * dmresrc */ +void +AcpiDmDumpInteger8 ( + UINT8 Value, + char *Name); void -AcpiDmDisasmByteList ( - UINT32 Level, - UINT8 *ByteData, - UINT32 ByteCount); +AcpiDmDumpInteger16 ( + UINT16 Value, + char *Name); void -AcpiDmByteList ( - ACPI_OP_WALK_INFO *Info, - ACPI_PARSE_OBJECT *Op); +AcpiDmDumpInteger32 ( + UINT32 Value, + char *Name); + +void +AcpiDmDumpInteger64 ( + UINT64 Value, + char *Name); void -AcpiDmResourceDescriptor ( +AcpiDmResourceTemplate ( ACPI_OP_WALK_INFO *Info, UINT8 *ByteData, UINT32 ByteCount); BOOLEAN -AcpiDmIsResourceDescriptor ( +AcpiDmIsResourceTemplate ( ACPI_PARSE_OBJECT *Op); void @@ -366,70 +347,74 @@ void AcpiDmDecodeAttribute ( UINT8 Attribute); + /* * dmresrcl */ - -void -AcpiDmIoFlags ( - UINT8 Flags); - -void -AcpiDmMemoryFlags ( - UINT8 Flags, - UINT8 SpecificFlags); - void AcpiDmWordDescriptor ( - ASL_WORD_ADDRESS_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmDwordDescriptor ( - ASL_DWORD_ADDRESS_DESC *Resource, + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmExtendedDescriptor ( + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmQwordDescriptor ( - ASL_QWORD_ADDRESS_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmMemory24Descriptor ( - ASL_MEMORY_24_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmMemory32Descriptor ( - ASL_MEMORY_32_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void -AcpiDmFixedMem32Descriptor ( - ASL_FIXED_MEMORY_32_DESC *Resource, +AcpiDmFixedMemory32Descriptor ( + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmGenericRegisterDescriptor ( - ASL_GENERAL_REGISTER_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmInterruptDescriptor ( - ASL_EXTENDED_XRUPT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmVendorLargeDescriptor ( - ASL_LARGE_VENDOR_DESC *Resource, + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmVendorCommon ( + char *Name, + UINT8 *ByteData, UINT32 Length, UINT32 Level); @@ -437,46 +422,45 @@ AcpiDmVendorLargeDescriptor ( /* * dmresrcs */ - void AcpiDmIrqDescriptor ( - ASL_IRQ_FORMAT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmDmaDescriptor ( - ASL_DMA_FORMAT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmIoDescriptor ( - ASL_IO_PORT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmFixedIoDescriptor ( - ASL_FIXED_IO_PORT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmStartDependentDescriptor ( - ASL_START_DEPENDENT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmEndDependentDescriptor ( - ASL_START_DEPENDENT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); void AcpiDmVendorSmallDescriptor ( - ASL_SMALL_VENDOR_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level); @@ -484,7 +468,6 @@ AcpiDmVendorSmallDescriptor ( /* * dmutils */ - void AcpiDmAddToExternalList ( char *Path); diff --git a/sys/contrib/dev/acpica/acdispat.h b/sys/contrib/dev/acpica/acdispat.h index 906cdb7..f7cedf4 100644 --- a/sys/contrib/dev/acpica/acdispat.h +++ b/sys/contrib/dev/acpica/acdispat.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acdispat.h - dispatcher (parser to interpreter interface) - * $Revision: 58 $ + * $Revision: 1.67 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,38 +123,9 @@ #define NAMEOF_ARG_NTE "__A0" -/* Common interfaces */ - -ACPI_STATUS -AcpiDsObjStackPush ( - void *Object, - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS -AcpiDsObjStackPop ( - UINT32 PopCount, - ACPI_WALK_STATE *WalkState); - -void * -AcpiDsObjStackGetValue ( - UINT32 Index, - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS -AcpiDsObjStackPopObject ( - ACPI_OPERAND_OBJECT **Object, - ACPI_WALK_STATE *WalkState); - - -/* dsopcode - support for late evaluation */ - -ACPI_STATUS -AcpiDsExecuteArguments ( - ACPI_NAMESPACE_NODE *Node, - ACPI_NAMESPACE_NODE *ScopeNode, - UINT32 AmlLength, - UINT8 *AmlStart); - +/* + * dsopcode - support for late evaluation + */ ACPI_STATUS AcpiDsGetBufferFieldArguments ( ACPI_OPERAND_OBJECT *ObjDesc); @@ -172,15 +143,6 @@ AcpiDsGetPackageArguments ( ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS -AcpiDsInitBufferField ( - UINT16 AmlOpcode, - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_OPERAND_OBJECT *BufferDesc, - ACPI_OPERAND_OBJECT *OffsetDesc, - ACPI_OPERAND_OBJECT *LengthDesc, - ACPI_OPERAND_OBJECT *ResultDesc); - -ACPI_STATUS AcpiDsEvalBufferFieldOperands ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op); @@ -201,9 +163,9 @@ AcpiDsInitializeRegion ( ACPI_HANDLE ObjHandle); -/* dsctrl - Parser/Interpreter interface, control stack routines */ - - +/* + * dsctrl - Parser/Interpreter interface, control stack routines + */ ACPI_STATUS AcpiDsExecBeginControlOp ( ACPI_WALK_STATE *WalkState, @@ -215,9 +177,9 @@ AcpiDsExecEndControlOp ( ACPI_PARSE_OBJECT *Op); -/* dsexec - Parser/Interpreter interface, method execution callbacks */ - - +/* + * dsexec - Parser/Interpreter interface, method execution callbacks + */ ACPI_STATUS AcpiDsGetPredicateValue ( ACPI_WALK_STATE *WalkState, @@ -233,14 +195,9 @@ AcpiDsExecEndOp ( ACPI_WALK_STATE *State); -/* dsfield - Parser/Interpreter interface for AML fields */ - -ACPI_STATUS -AcpiDsGetFieldNames ( - ACPI_CREATE_FIELD_INFO *Info, - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Arg); - +/* + * dsfield - Parser/Interpreter interface for AML fields + */ ACPI_STATUS AcpiDsCreateField ( ACPI_PARSE_OBJECT *Op, @@ -270,8 +227,9 @@ AcpiDsInitFieldObjects ( ACPI_WALK_STATE *WalkState); -/* dsload - Parser/Interpreter interface, namespace load callbacks */ - +/* + * dsload - Parser/Interpreter interface, namespace load callbacks + */ ACPI_STATUS AcpiDsLoad1BeginOp ( ACPI_WALK_STATE *WalkState, @@ -296,9 +254,9 @@ AcpiDsInitCallbacks ( UINT32 PassNumber); -/* dsmthdat - method data (locals/args) */ - - +/* + * dsmthdat - method data (locals/args) + */ ACPI_STATUS AcpiDsStoreObjectToLocal ( UINT16 Opcode, @@ -321,12 +279,6 @@ BOOLEAN AcpiDsIsMethodValue ( ACPI_OPERAND_OBJECT *ObjDesc); -ACPI_OBJECT_TYPE -AcpiDsMethodDataGetType ( - UINT16 Opcode, - UINT32 Index, - ACPI_WALK_STATE *WalkState); - ACPI_STATUS AcpiDsMethodDataGetValue ( UINT16 Opcode, @@ -334,12 +286,6 @@ AcpiDsMethodDataGetValue ( ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **DestDesc); -void -AcpiDsMethodDataDeleteValue ( - UINT16 Opcode, - UINT32 Index, - ACPI_WALK_STATE *WalkState); - ACPI_STATUS AcpiDsMethodDataInitArgs ( ACPI_OPERAND_OBJECT **Params, @@ -357,19 +303,13 @@ void AcpiDsMethodDataInit ( ACPI_WALK_STATE *WalkState); -ACPI_STATUS -AcpiDsMethodDataSetValue ( - UINT16 Opcode, - UINT32 Index, - ACPI_OPERAND_OBJECT *Object, - ACPI_WALK_STATE *WalkState); - - -/* dsmethod - Parser/Interpreter interface - control method parsing */ +/* + * dsmethod - Parser/Interpreter interface - control method parsing + */ ACPI_STATUS AcpiDsParseMethod ( - ACPI_HANDLE ObjHandle); + ACPI_NAMESPACE_NODE *Node); ACPI_STATUS AcpiDsCallControlMethod ( @@ -382,7 +322,7 @@ AcpiDsRestartControlMethod ( ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ReturnDesc); -ACPI_STATUS +void AcpiDsTerminateControlMethod ( ACPI_WALK_STATE *WalkState); @@ -393,20 +333,18 @@ AcpiDsBeginMethodExecution ( ACPI_NAMESPACE_NODE *CallingMethodNode); -/* dsobj - Parser/Interpreter interface - object initialization and conversion */ - -ACPI_STATUS -AcpiDsInitOneObject ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); - +/* + * dsinit + */ ACPI_STATUS AcpiDsInitializeObjects ( ACPI_TABLE_DESC *TableDesc, ACPI_NAMESPACE_NODE *StartNode); + +/* + * dsobject - Parser/Interpreter interface - object initialization and conversion + */ ACPI_STATUS AcpiDsBuildInternalBufferObj ( ACPI_WALK_STATE *WalkState, @@ -422,12 +360,6 @@ AcpiDsBuildInternalPackageObj ( ACPI_OPERAND_OBJECT **ObjDesc); ACPI_STATUS -AcpiDsBuildInternalObject ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op, - ACPI_OPERAND_OBJECT **ObjDescPtr); - -ACPI_STATUS AcpiDsInitObjectFromOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, @@ -441,7 +373,18 @@ AcpiDsCreateNode ( ACPI_PARSE_OBJECT *Op); -/* dsutils - Parser/Interpreter interface utility routines */ +/* + * dsutils - Parser/Interpreter interface utility routines + */ +void +AcpiDsClearImplicitReturn ( + ACPI_WALK_STATE *WalkState); + +BOOLEAN +AcpiDsDoImplicitReturn ( + ACPI_OPERAND_OBJECT *ReturnDesc, + ACPI_WALK_STATE *WalkState, + BOOLEAN AddReference); BOOLEAN AcpiDsIsResultUsed ( @@ -477,7 +420,6 @@ AcpiDsClearOperands ( /* * dswscope - Scope Stack manipulation */ - ACPI_STATUS AcpiDsScopeStackPush ( ACPI_NAMESPACE_NODE *Node, @@ -494,7 +436,18 @@ AcpiDsScopeStackClear ( ACPI_WALK_STATE *WalkState); -/* dswstate - parser WALK_STATE management routines */ +/* + * dswstate - parser WALK_STATE management routines + */ +ACPI_STATUS +AcpiDsObjStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsObjStackPop ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState); ACPI_WALK_STATE * AcpiDsCreateWalkState ( @@ -511,11 +464,7 @@ AcpiDsInitAmlWalk ( UINT8 *AmlStart, UINT32 AmlLength, ACPI_PARAMETER_INFO *Info, - UINT32 PassNumber); - -ACPI_STATUS -AcpiDsObjStackDeleteAll ( - ACPI_WALK_STATE *WalkState); + UINT8 PassNumber); ACPI_STATUS AcpiDsObjStackPopAndDelete ( @@ -551,16 +500,6 @@ ACPI_WALK_STATE * AcpiDsGetCurrentWalkState ( ACPI_THREAD_STATE *Thread); -void -AcpiDsDeleteWalkStateCache ( - void); - -ACPI_STATUS -AcpiDsResultInsert ( - void *Object, - UINT32 Index, - ACPI_WALK_STATE *WalkState); - ACPI_STATUS AcpiDsResultRemove ( ACPI_OPERAND_OBJECT **Object, diff --git a/sys/contrib/dev/acpica/acefi.h b/sys/contrib/dev/acpica/acefi.h index 15c3f42..7dde203 100644 --- a/sys/contrib/dev/acpica/acefi.h +++ b/sys/contrib/dev/acpica/acefi.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acefi.h - OS specific defines, etc. - * $Revision: 15 $ + * $Revision: 1.16 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/acenv.h b/sys/contrib/dev/acpica/acenv.h index 09dc5bc..ab7b529 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: 109 $ + * $Revision: 1.119 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -122,32 +122,39 @@ * Configuration for ACPI tools and utilities */ -#ifdef _ACPI_DUMP_APP +#ifdef ACPI_LIBRARY +#define ACPI_USE_LOCAL_CACHE +#endif + +#ifdef ACPI_DUMP_APP #ifndef MSDOS #define ACPI_DEBUG_OUTPUT #endif #define ACPI_APPLICATION #define ACPI_DISASSEMBLER #define ACPI_NO_METHOD_EXECUTION -#define ACPI_USE_SYSTEM_CLIBRARY #endif -#ifdef _ACPI_EXEC_APP +#ifdef ACPI_EXEC_APP #undef DEBUGGER_THREADING #define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED #define ACPI_DEBUG_OUTPUT #define ACPI_APPLICATION #define ACPI_DEBUGGER #define ACPI_DISASSEMBLER -#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_MUTEX_DEBUG #endif -#ifdef _ACPI_ASL_COMPILER +#ifdef ACPI_ASL_COMPILER #define ACPI_DEBUG_OUTPUT #define ACPI_APPLICATION #define ACPI_DISASSEMBLER #define ACPI_CONSTANT_EVAL_ONLY +#endif + +#ifdef ACPI_APPLICATION #define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_LOCAL_CACHE #endif /* @@ -268,18 +275,20 @@ #endif #endif /* !DEBUGGER_THREADING */ + /****************************************************************************** * * C library configuration * *****************************************************************************/ +#define ACPI_IS_ASCII(c) ((c) < 0x80) + #ifdef ACPI_USE_SYSTEM_CLIBRARY /* * Use the standard C library headers. * We want to keep these to a minimum. */ - #ifdef ACPI_USE_STANDARD_HEADERS /* * Use the standard headers from the standard locations @@ -294,9 +303,8 @@ /* * We will be linking to the standard Clib functions */ - #define ACPI_STRSTR(s1,s2) strstr((s1), (s2)) -#define ACPI_STRUPR(s) (void) AcpiUtStrupr ((s)) +#define ACPI_STRCHR(s1,c) strchr((s1), (c)) #define ACPI_STRLEN(s) (ACPI_SIZE) strlen((s)) #define ACPI_STRCPY(d,s) (void) strcpy((d), (s)) #define ACPI_STRNCPY(d,s,n) (void) strncpy((d), (s), (ACPI_SIZE)(n)) @@ -305,28 +313,28 @@ #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_MEMCMP(s1,s2,n) memcmp((const char *)(s1), (const char *)(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)) -#define ACPI_TOUPPER toupper -#define ACPI_TOLOWER tolower -#define ACPI_IS_XDIGIT isxdigit -#define ACPI_IS_DIGIT isdigit -#define ACPI_IS_SPACE isspace -#define ACPI_IS_UPPER isupper -#define ACPI_IS_PRINT isprint -#define ACPI_IS_ALPHA isalpha -#define ACPI_IS_ASCII isascii +#define ACPI_TOUPPER(i) toupper((int) (i)) +#define ACPI_TOLOWER(i) tolower((int) (i)) +#define ACPI_IS_XDIGIT(i) isxdigit((int) (i)) +#define ACPI_IS_DIGIT(i) isdigit((int) (i)) +#define ACPI_IS_SPACE(i) isspace((int) (i)) +#define ACPI_IS_UPPER(i) isupper((int) (i)) +#define ACPI_IS_PRINT(i) isprint((int) (i)) +#define ACPI_IS_ALPHA(i) isalpha((int) (i)) + +#else /****************************************************************************** * * Not using native C library, use local implementations * *****************************************************************************/ -#else -/* + /* * Use local definitions of C library macros and functions * NOTE: The function implementations may not be as efficient * as an inline or assembly code implementation provided by a @@ -343,14 +351,12 @@ typedef char *va_list; /* * Storage alignment properties */ - #define _AUPBND (sizeof (ACPI_NATIVE_INT) - 1) #define _ADNBND (sizeof (ACPI_NATIVE_INT) - 1) /* * Variable argument list macro definitions */ - #define _Bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd))) #define va_arg(ap, T) (*(T *)(((ap) += (_Bnd (T, _AUPBND))) - (_Bnd (T,_ADNBND)))) #define va_end(ap) (void) 0 @@ -359,19 +365,19 @@ typedef char *va_list; #endif /* va_arg */ -#define ACPI_STRSTR(s1,s2) AcpiUtStrstr ((s1), (s2)) -#define ACPI_STRUPR(s) (void) AcpiUtStrupr ((s)) -#define ACPI_STRLEN(s) (ACPI_SIZE) AcpiUtStrlen ((s)) -#define ACPI_STRCPY(d,s) (void) AcpiUtStrcpy ((d), (s)) +#define ACPI_STRSTR(s1,s2) AcpiUtStrstr ((s1), (s2)) +#define ACPI_STRCHR(s1,c) AcpiUtStrchr ((s1), (c)) +#define ACPI_STRLEN(s) (ACPI_SIZE) AcpiUtStrlen ((s)) +#define ACPI_STRCPY(d,s) (void) AcpiUtStrcpy ((d), (s)) #define ACPI_STRNCPY(d,s,n) (void) AcpiUtStrncpy ((d), (s), (ACPI_SIZE)(n)) #define ACPI_STRNCMP(d,s,n) AcpiUtStrncmp ((d), (s), (ACPI_SIZE)(n)) -#define ACPI_STRCMP(d,s) AcpiUtStrcmp ((d), (s)) -#define ACPI_STRCAT(d,s) (void) AcpiUtStrcat ((d), (s)) +#define ACPI_STRCMP(d,s) AcpiUtStrcmp ((d), (s)) +#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_MEMCMP(s1,s2,n) AcpiUtMemcmp((const char *)(s1), (const char *)(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 #define ACPI_TOLOWER AcpiUtToLower diff --git a/sys/contrib/dev/acpica/acevents.h b/sys/contrib/dev/acpica/acevents.h index d029d73..58dc9a1 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: 96 $ + * $Revision: 1.103 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -118,6 +118,9 @@ #define __ACEVENTS_H__ +/* + * evevent + */ ACPI_STATUS AcpiEvInitializeEvents ( void); @@ -126,28 +129,14 @@ ACPI_STATUS AcpiEvInstallXruptHandlers ( void); - -/* - * Evfixed - Fixed event handling - */ - -ACPI_STATUS -AcpiEvFixedEventInitialize ( - void); - UINT32 AcpiEvFixedEventDetect ( void); -UINT32 -AcpiEvFixedEventDispatch ( - UINT32 Event); - /* - * Evmisc + * evmisc */ - BOOLEAN AcpiEvIsNotifyObject ( ACPI_NAMESPACE_NODE *Node); @@ -173,24 +162,10 @@ AcpiEvQueueNotifyRequest ( ACPI_NAMESPACE_NODE *Node, UINT32 NotifyValue); -void ACPI_SYSTEM_XFACE -AcpiEvNotifyDispatch ( - void *Context); - /* - * Evgpe - GPE handling and dispatch + * evgpe - GPE handling and dispatch */ - -ACPI_STATUS -AcpiEvWalkGpeList ( - ACPI_GPE_CALLBACK GpeWalkCallback, - UINT32 Flags); - -BOOLEAN -AcpiEvValidGpeEvent ( - ACPI_GPE_EVENT_INFO *GpeEventInfo); - ACPI_STATUS AcpiEvUpdateGpeEnableMasks ( ACPI_GPE_EVENT_INFO *GpeEventInfo, @@ -210,9 +185,22 @@ AcpiEvGetGpeEventInfo ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber); + +/* + * evgpeblk + */ +BOOLEAN +AcpiEvValidGpeEvent ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + ACPI_STATUS -AcpiEvGpeInitialize ( - void); +AcpiEvWalkGpeList ( + ACPI_GPE_CALLBACK GpeWalkCallback); + +ACPI_STATUS +AcpiEvDeleteGpeHandlers ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock); ACPI_STATUS AcpiEvCreateGpeBlock ( @@ -220,18 +208,13 @@ AcpiEvCreateGpeBlock ( ACPI_GENERIC_ADDRESS *GpeBlockAddress, UINT32 RegisterCount, UINT8 GpeBlockBaseNumber, - UINT32 InterruptLevel, + UINT32 InterruptNumber, ACPI_GPE_BLOCK_INFO **ReturnGpeBlock); ACPI_STATUS AcpiEvDeleteGpeBlock ( ACPI_GPE_BLOCK_INFO *GpeBlock); -ACPI_STATUS -AcpiEvDeleteGpeHandlers ( - ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock); - UINT32 AcpiEvGpeDispatch ( ACPI_GPE_EVENT_INFO *GpeEventInfo, @@ -250,10 +233,14 @@ ACPI_STATUS AcpiEvCheckForWakeOnlyGpe ( ACPI_GPE_EVENT_INFO *GpeEventInfo); +ACPI_STATUS +AcpiEvGpeInitialize ( + void); + + /* - * Evregion - Address Space handling + * evregion - Address Space handling */ - ACPI_STATUS AcpiEvInstallRegionHandlers ( void); @@ -271,13 +258,6 @@ AcpiEvAddressSpaceDispatch ( void *Value); ACPI_STATUS -AcpiEvInstallHandler ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); - -ACPI_STATUS AcpiEvAttachRegion ( ACPI_OPERAND_OBJECT *HandlerObj, ACPI_OPERAND_OBJECT *RegionObj, @@ -306,17 +286,10 @@ AcpiEvExecuteRegMethod ( ACPI_OPERAND_OBJECT *RegionObj, UINT32 Function); -ACPI_STATUS -AcpiEvRegRun ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); /* - * Evregini - Region initialization and setup + * evregini - Region initialization and setup */ - ACPI_STATUS AcpiEvSystemMemoryRegionSetup ( ACPI_HANDLE Handle, @@ -366,9 +339,8 @@ AcpiEvInitializeRegion ( /* - * Evsci - SCI (System Control Interrupt) handling/dispatch + * evsci - SCI (System Control Interrupt) handling/dispatch */ - UINT32 ACPI_SYSTEM_XFACE AcpiEvGpeXruptHandler ( void *Context); diff --git a/sys/contrib/dev/acpica/acexcep.h b/sys/contrib/dev/acpica/acexcep.h index 07bd4ca..cf5d0ba 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: 72 $ + * $Revision: 1.75 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -121,7 +121,6 @@ /* * Exceptions returned by external ACPI interfaces */ - #define AE_CODE_ENVIRONMENTAL 0x0000 #define AE_CODE_PROGRAMMER 0x1000 #define AE_CODE_ACPI_TABLES 0x2000 @@ -169,8 +168,10 @@ #define AE_ABORT_METHOD (ACPI_STATUS) (0x001C | AE_CODE_ENVIRONMENTAL) #define AE_SAME_HANDLER (ACPI_STATUS) (0x001D | AE_CODE_ENVIRONMENTAL) #define AE_WAKE_ONLY_GPE (ACPI_STATUS) (0x001E | AE_CODE_ENVIRONMENTAL) +#define AE_OWNER_ID_LIMIT (ACPI_STATUS) (0x001F | AE_CODE_ENVIRONMENTAL) + +#define AE_CODE_ENV_MAX 0x001F -#define AE_CODE_ENV_MAX 0x001E /* * Programmer exceptions @@ -241,6 +242,7 @@ #define AE_CODE_AML_MAX 0x0021 + /* * Internal exceptions used for control */ @@ -261,6 +263,7 @@ #ifdef DEFINE_ACPI_GLOBALS + /* * String versions of the exception codes above * These strings must match the corresponding defines exactly @@ -297,7 +300,8 @@ char const *AcpiGbl_ExceptionNames_Env[] = "AE_LOGICAL_ADDRESS", "AE_ABORT_METHOD", "AE_SAME_HANDLER", - "AE_WAKE_ONLY_GPE" + "AE_WAKE_ONLY_GPE", + "AE_OWNER_ID_LIMIT" }; char const *AcpiGbl_ExceptionNames_Pgm[] = @@ -377,5 +381,4 @@ char const *AcpiGbl_ExceptionNames_Ctrl[] = #endif /* ACPI GLOBALS */ - #endif /* __ACEXCEP_H__ */ diff --git a/sys/contrib/dev/acpica/acfreebsd.h b/sys/contrib/dev/acpica/acfreebsd.h index 5b5cd17..9284579 100644 --- a/sys/contrib/dev/acpica/acfreebsd.h +++ b/sys/contrib/dev/acpica/acfreebsd.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acfreebsd.h - OS specific defines, etc. - * $Revision: 17 $ + * $Revision: 1.19 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -169,18 +169,6 @@ /* Always use FreeBSD code over our local versions */ #define ACPI_USE_SYSTEM_CLIBRARY -/* FreeBSD doesn't have strupr, should be fixed. (move to libkern) */ -static __inline char * -strupr(char *str) -{ - char *c = str; - while(*c) { - *c = toupper(*c); - c++; - } - return(str); -} - #ifdef _KERNEL /* Or strstr (used in debugging mode, also move to libkern) */ static __inline char * diff --git a/sys/contrib/dev/acpica/acgcc.h b/sys/contrib/dev/acpica/acgcc.h index 35bb951..4902729 100644 --- a/sys/contrib/dev/acpica/acgcc.h +++ b/sys/contrib/dev/acpica/acgcc.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acgcc.h - GCC specific defines, etc. - * $Revision: 26 $ + * $Revision: 1.29 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,13 +117,17 @@ #ifndef __ACGCC_H__ #define __ACGCC_H__ +/* Function name is used for debug output. Non-ANSI, compiler-dependent */ + +#define ACPI_GET_FUNCTION_NAME __FUNCTION__ + /* This macro is used to tag functions as "printf-like" because * some compilers (like GCC) can catch printf format string problems. */ -#define ACPI_PRINTF_LIKE_FUNC __attribute__ ((__format__ (__printf__, 4, 5))) +#define ACPI_PRINTF_LIKE_FUNC __attribute__ ((__format__ (__printf__, 6, 7))) /* Some compilers complain about unused variables. Sometimes we don't want to - * use all the variables (most specifically for _THIS_MODULE). This allow us + * use all the variables (for example, _AcpiModuleName). This allows us * to to tell the compiler warning in a per-variable manner that a variable * is unused. */ diff --git a/sys/contrib/dev/acpica/acglobal.h b/sys/contrib/dev/acpica/acglobal.h index 70c93f1..0046ae1 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: 159 $ + * $Revision: 1.168 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -155,6 +155,14 @@ extern UINT32 AcpiDbgLayer; extern UINT32 AcpiGbl_NestingLevel; +/* Support for dynamic control method tracing mechanism */ + +ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLevel; +ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLayer; +ACPI_EXTERN ACPI_NAME AcpiGbl_TraceMethodName; +ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLevel; +ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLayer; +ACPI_EXTERN UINT32 AcpiGbl_TraceFlags; /***************************************************************************** * @@ -169,6 +177,7 @@ extern UINT32 AcpiGbl_NestingLevel; * 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) + * 4) Allow ANY object type to be a source operand for the Store() operator */ ACPI_EXTERN UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE); @@ -218,15 +227,22 @@ ACPI_EXTERN ACPI_TABLE_HEADER *AcpiGbl_DSDT; ACPI_EXTERN FACS_DESCRIPTOR *AcpiGbl_FACS; ACPI_EXTERN ACPI_COMMON_FACS AcpiGbl_CommonFACS; /* - * Since there may be multiple SSDTs and PSDTS, a single pointer is not + * Since there may be multiple SSDTs and PSDTs, a single pointer is not * sufficient; Therefore, there isn't one! */ +/* The root table can be either an RSDT or an XSDT */ + +ACPI_EXTERN UINT8 AcpiGbl_RootTableType; +#define ACPI_TABLE_TYPE_RSDT 'R' +#define ACPI_TABLE_TYPE_XSDT 'X' + + /* - * Handle both ACPI 1.0 and ACPI 2.0 Integer widths - * If we are running a method that exists in a 32-bit ACPI table. - * Use only 32 bits of the Integer for conversion. + * Handle both ACPI 1.0 and ACPI 2.0 Integer widths: + * If we are executing a method that exists in a 32-bit ACPI table, + * use only the lower 32 bits of the (internal) 64-bit Integer. */ ACPI_EXTERN UINT8 AcpiGbl_IntegerBitWidth; ACPI_EXTERN UINT8 AcpiGbl_IntegerByteWidth; @@ -252,8 +268,23 @@ ACPI_EXTERN ACPI_MUTEX_INFO AcpiGbl_MutexInfo[NUM_MUTEX]; * ****************************************************************************/ +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + +/* Lists for tracking memory allocations */ + +ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_GlobalList; +ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_NsNodeList; +#endif + +/* Object caches */ + +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_StateCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_PsNodeCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_PsNodeExtCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_OperandCache; + +/* Global handlers */ -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; @@ -261,14 +292,15 @@ ACPI_EXTERN ACPI_INIT_HANDLER AcpiGbl_InitHandler; ACPI_EXTERN ACPI_WALK_STATE *AcpiGbl_BreakpointWalk; ACPI_EXTERN ACPI_HANDLE AcpiGbl_GlobalLockSemaphore; +/* Misc */ + ACPI_EXTERN UINT32 AcpiGbl_GlobalLockThreadCount; ACPI_EXTERN UINT32 AcpiGbl_OriginalMode; ACPI_EXTERN UINT32 AcpiGbl_RsdpOriginalLocation; ACPI_EXTERN UINT32 AcpiGbl_NsLookupCount; ACPI_EXTERN UINT32 AcpiGbl_PsFindCount; +ACPI_EXTERN UINT32 AcpiGbl_OwnerIdMask; ACPI_EXTERN UINT16 AcpiGbl_Pm1EnableRegisterSave; -ACPI_EXTERN UINT16 AcpiGbl_NextTableOwnerId; -ACPI_EXTERN UINT16 AcpiGbl_NextMethodOwnerId; ACPI_EXTERN UINT16 AcpiGbl_GlobalLockHandle; ACPI_EXTERN UINT8 AcpiGbl_DebuggerConfiguration; ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockAcquired; @@ -318,6 +350,7 @@ ACPI_EXTERN ACPI_SIZE AcpiGbl_LowestStackPointer; ACPI_EXTERN UINT32 AcpiGbl_DeepestNesting; #endif + /***************************************************************************** * * Interpreter globals @@ -340,6 +373,7 @@ ACPI_EXTERN UINT8 AcpiGbl_CmSingleStep; ACPI_EXTERN ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot; + /***************************************************************************** * * Hardware globals @@ -370,7 +404,6 @@ ACPI_EXTERN ACPI_HANDLE AcpiGbl_GpeLock; * ****************************************************************************/ - ACPI_EXTERN UINT8 AcpiGbl_DbOutputFlags; #ifdef ACPI_DISASSEMBLER @@ -425,5 +458,4 @@ ACPI_EXTERN UINT32 AcpiGbl_SizeOfAcpiObjects; #endif /* ACPI_DEBUGGER */ - #endif /* __ACGLOBAL_H__ */ diff --git a/sys/contrib/dev/acpica/achware.h b/sys/contrib/dev/acpica/achware.h index 0d0d008..76916b5 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: 73 $ + * $Revision: 1.79 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -119,22 +119,26 @@ /* PM Timer ticks per second (HZ) */ + #define PM_TIMER_FREQUENCY 3579545 +/* Values for the _SST reserved method */ -/* Prototypes */ +#define ACPI_SST_INDICATOR_OFF 0 +#define ACPI_SST_WORKING 1 +#define ACPI_SST_WAKING 2 +#define ACPI_SST_SLEEPING 3 +#define ACPI_SST_SLEEP_CONTEXT 4 -ACPI_STATUS -AcpiHwInitialize ( - void); +/* Prototypes */ -ACPI_STATUS -AcpiHwShutdown ( - void); +/* + * hwacpi - high level functions + */ ACPI_STATUS -AcpiHwInitializeSystemInfo ( +AcpiHwInitialize ( void); ACPI_STATUS @@ -145,12 +149,10 @@ UINT32 AcpiHwGetMode ( void); -UINT32 -AcpiHwGetModeCapabilities ( - void); - -/* Register I/O Prototypes */ +/* + * hwregs - ACPI Register I/O + */ ACPI_BIT_REGISTER_INFO * AcpiHwGetBitRegisterInfo ( UINT32 RegisterId); @@ -184,8 +186,9 @@ AcpiHwClearAcpiStatus ( UINT32 Flags); -/* GPE support */ - +/* + * hwgpe - GPE support + */ ACPI_STATUS AcpiHwWriteGpeEnableReg ( ACPI_GPE_EVENT_INFO *GpeEventInfo); @@ -211,29 +214,25 @@ AcpiHwGetGpeStatus ( ACPI_STATUS AcpiHwDisableAllGpes ( - UINT32 Flags); + void); ACPI_STATUS AcpiHwEnableAllRuntimeGpes ( - UINT32 Flags); + void); ACPI_STATUS AcpiHwEnableAllWakeupGpes ( - UINT32 Flags); + void); ACPI_STATUS AcpiHwEnableRuntimeGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock); -ACPI_STATUS -AcpiHwEnableWakeupGpeBlock ( - ACPI_GPE_XRUPT_INFO *GpeXruptInfo, - ACPI_GPE_BLOCK_INFO *GpeBlock); - - -/* ACPI Timer prototypes */ +/* + * hwtimer - ACPI Timer prototypes + */ ACPI_STATUS AcpiGetTimerResolution ( UINT32 *Resolution); diff --git a/sys/contrib/dev/acpica/acinterp.h b/sys/contrib/dev/acpica/acinterp.h index e5bfc82..470eef6 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: 155 $ + * $Revision: 1.162 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -121,37 +121,9 @@ #define ACPI_WALK_OPERANDS (&(WalkState->Operands [WalkState->NumOperands -1])) -ACPI_STATUS -AcpiExResolveOperands ( - UINT16 Opcode, - ACPI_OPERAND_OBJECT **StackPtr, - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS -AcpiExCheckObjectType ( - ACPI_OBJECT_TYPE TypeNeeded, - ACPI_OBJECT_TYPE ThisType, - void *Object); - -/* - * exxface - External interpreter interfaces - */ - -ACPI_STATUS -AcpiExLoadTable ( - ACPI_TABLE_TYPE TableId); - -ACPI_STATUS -AcpiExExecuteMethod ( - ACPI_NAMESPACE_NODE *MethodNode, - ACPI_OPERAND_OBJECT **Params, - ACPI_OPERAND_OBJECT **ReturnObjDesc); - - /* * exconvrt - object conversion */ - ACPI_STATUS AcpiExConvertToInteger ( ACPI_OPERAND_OBJECT *ObjDesc, @@ -183,17 +155,10 @@ AcpiExConvertToTargetType ( ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState); -UINT32 -AcpiExConvertToAscii ( - ACPI_INTEGER Integer, - UINT16 Base, - UINT8 *String, - UINT8 MaxLength); /* * exfield - ACPI AML (p-code) execution - field manipulation */ - ACPI_STATUS AcpiExCommonBufferSetup ( ACPI_OPERAND_OBJECT *ObjDesc, @@ -201,42 +166,6 @@ AcpiExCommonBufferSetup ( UINT32 *DatumCount); ACPI_STATUS -AcpiExExtractFromField ( - ACPI_OPERAND_OBJECT *ObjDesc, - void *Buffer, - UINT32 BufferLength); - -ACPI_STATUS -AcpiExInsertIntoField ( - ACPI_OPERAND_OBJECT *ObjDesc, - void *Buffer, - UINT32 BufferLength); - -ACPI_STATUS -AcpiExSetupRegion ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 FieldDatumByteOffset); - -ACPI_STATUS -AcpiExAccessRegion ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 FieldDatumByteOffset, - ACPI_INTEGER *Value, - UINT32 ReadWrite); - -BOOLEAN -AcpiExRegisterOverflow ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_INTEGER Value); - -ACPI_STATUS -AcpiExFieldDatumIo ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 FieldDatumByteOffset, - ACPI_INTEGER *Value, - UINT32 ReadWrite); - -ACPI_STATUS AcpiExWriteWithUpdateRule ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_INTEGER Mask, @@ -271,28 +200,33 @@ AcpiExWriteDataToField ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc); + /* - * exmisc - ACPI AML (p-code) execution - specific opcodes + * exfldio - low level field I/O */ - ACPI_STATUS -AcpiExOpcode_3A_0T_0R ( - ACPI_WALK_STATE *WalkState); +AcpiExExtractFromField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength); ACPI_STATUS -AcpiExOpcode_3A_1T_1R ( - ACPI_WALK_STATE *WalkState); +AcpiExInsertIntoField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength); ACPI_STATUS -AcpiExOpcode_6A_0T_1R ( - ACPI_WALK_STATE *WalkState); +AcpiExAccessRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 ReadWrite); -BOOLEAN -AcpiExDoMatch ( - UINT32 MatchOp, - ACPI_INTEGER PackageValue, - ACPI_INTEGER MatchValue); +/* + * exmisc - misc support routines + */ ACPI_STATUS AcpiExGetObjectReference ( ACPI_OPERAND_OBJECT *ObjDesc, @@ -300,13 +234,6 @@ AcpiExGetObjectReference ( ACPI_WALK_STATE *WalkState); ACPI_STATUS -AcpiExResolveMultiple ( - ACPI_WALK_STATE *WalkState, - ACPI_OPERAND_OBJECT *Operand, - ACPI_OBJECT_TYPE *ReturnType, - ACPI_OPERAND_OBJECT **ReturnDesc); - -ACPI_STATUS AcpiExConcatTemplate ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT *ObjDesc2, @@ -381,13 +308,6 @@ AcpiExCreateMethod ( /* * exconfig - dynamic table load/unload */ - -ACPI_STATUS -AcpiExAddTable ( - ACPI_TABLE_HEADER *Table, - ACPI_NAMESPACE_NODE *ParentNode, - ACPI_OPERAND_OBJECT **DdbHandle); - ACPI_STATUS AcpiExLoadOp ( ACPI_OPERAND_OBJECT *ObjDesc, @@ -407,7 +327,6 @@ AcpiExUnloadTable ( /* * exmutex - mutex support */ - ACPI_STATUS AcpiExAcquireMutex ( ACPI_OPERAND_OBJECT *TimeDesc, @@ -427,15 +346,10 @@ void AcpiExUnlinkMutex ( ACPI_OPERAND_OBJECT *ObjDesc); -void -AcpiExLinkMutex ( - ACPI_OPERAND_OBJECT *ObjDesc, - ACPI_THREAD_STATE *Thread); /* - * exprep - ACPI AML (p-code) execution - prep utilities + * exprep - ACPI AML execution - prep utilities */ - ACPI_STATUS AcpiExPrepCommonFieldObject ( ACPI_OPERAND_OBJECT *ObjDesc, @@ -448,10 +362,10 @@ ACPI_STATUS AcpiExPrepFieldValue ( ACPI_CREATE_FIELD_INFO *Info); + /* * exsystem - Interface to OS services */ - ACPI_STATUS AcpiExSystemDoNotifyOp ( ACPI_OPERAND_OBJECT *Value, @@ -494,9 +408,8 @@ AcpiExSystemWaitSemaphore ( /* - * exmonadic - ACPI AML (p-code) execution, monadic operators + * exoparg1 - ACPI AML execution, 1 operand */ - ACPI_STATUS AcpiExOpcode_0A_0T_1R ( ACPI_WALK_STATE *WalkState); @@ -518,9 +431,8 @@ AcpiExOpcode_1A_1T_0R ( ACPI_WALK_STATE *WalkState); /* - * exdyadic - ACPI AML (p-code) execution, dyadic operators + * exoparg2 - ACPI AML execution, 2 operands */ - ACPI_STATUS AcpiExOpcode_2A_0T_0R ( ACPI_WALK_STATE *WalkState); @@ -539,21 +451,56 @@ AcpiExOpcode_2A_2T_1R ( /* - * exresolv - Object resolution and get value functions + * exoparg3 - ACPI AML execution, 3 operands + */ +ACPI_STATUS +AcpiExOpcode_3A_0T_0R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_3A_1T_1R ( + ACPI_WALK_STATE *WalkState); + + +/* + * exoparg6 - ACPI AML execution, 6 operands */ +ACPI_STATUS +AcpiExOpcode_6A_0T_1R ( + ACPI_WALK_STATE *WalkState); + +/* + * exresolv - Object resolution and get value functions + */ ACPI_STATUS AcpiExResolveToValue ( ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState); ACPI_STATUS +AcpiExResolveMultiple ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *Operand, + ACPI_OBJECT_TYPE *ReturnType, + ACPI_OPERAND_OBJECT **ReturnDesc); + + +/* + * exresnte - resolve namespace node + */ +ACPI_STATUS AcpiExResolveNodeToValue ( ACPI_NAMESPACE_NODE **StackPtr, ACPI_WALK_STATE *WalkState); + +/* + * exresop - resolve operand to value + */ ACPI_STATUS -AcpiExResolveObjectToValue ( +AcpiExResolveOperands ( + UINT16 Opcode, ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState); @@ -561,7 +508,6 @@ AcpiExResolveObjectToValue ( /* * exdump - Interpreter debug output routines */ - void AcpiExDumpOperand ( ACPI_OPERAND_OBJECT *ObjDesc, @@ -587,45 +533,10 @@ AcpiExDumpNode ( ACPI_NAMESPACE_NODE *Node, UINT32 Flags); -void -AcpiExOutString ( - char *Title, - char *Value); - -void -AcpiExOutPointer ( - char *Title, - void *Value); - -void -AcpiExOutInteger ( - char *Title, - UINT32 Value); - -void -AcpiExOutAddress ( - char *Title, - ACPI_PHYSICAL_ADDRESS Value); - /* - * exnames - interpreter/scanner name load/execute + * exnames - AML namestring support */ - -char * -AcpiExAllocateNameString ( - UINT32 PrefixCount, - UINT32 NumNameSegs); - -UINT32 -AcpiExGoodChar ( - UINT32 Character); - -ACPI_STATUS -AcpiExNameSegment ( - UINT8 **InAmlAddress, - char *NameString); - ACPI_STATUS AcpiExGetNameString ( ACPI_OBJECT_TYPE DataType, @@ -633,16 +544,10 @@ AcpiExGetNameString ( char **OutNameString, UINT32 *OutNameLength); -ACPI_STATUS -AcpiExDoName ( - ACPI_OBJECT_TYPE DataType, - ACPI_INTERPRETER_MODE LoadExecMode); - /* * exstore - Object store support */ - ACPI_STATUS AcpiExStore ( ACPI_OPERAND_OBJECT *ValDesc, @@ -650,12 +555,6 @@ AcpiExStore ( ACPI_WALK_STATE *WalkState); ACPI_STATUS -AcpiExStoreObjectToIndex ( - ACPI_OPERAND_OBJECT *ValDesc, - ACPI_OPERAND_OBJECT *DestDesc, - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS AcpiExStoreObjectToNode ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_NAMESPACE_NODE *Node, @@ -665,10 +564,10 @@ AcpiExStoreObjectToNode ( #define ACPI_IMPLICIT_CONVERSION TRUE #define ACPI_NO_IMPLICIT_CONVERSION FALSE + /* - * exstoren + * exstoren - resolve/store object */ - ACPI_STATUS AcpiExResolveObject ( ACPI_OPERAND_OBJECT **SourceDescPtr, @@ -684,9 +583,8 @@ AcpiExStoreObjectToObject ( /* - * excopy - object copy + * exstorob - store object - buffer/string */ - ACPI_STATUS AcpiExStoreBufferToBuffer ( ACPI_OPERAND_OBJECT *SourceDesc, @@ -697,6 +595,10 @@ AcpiExStoreStringToString ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc); + +/* + * excopy - object copy + */ ACPI_STATUS AcpiExCopyIntegerToIndexField ( ACPI_OPERAND_OBJECT *SourceDesc, @@ -717,10 +619,10 @@ AcpiExCopyIntegerToBufferField ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc); + /* * exutils - interpreter/scanner utilities */ - ACPI_STATUS AcpiExEnterInterpreter ( void); @@ -741,11 +643,6 @@ void AcpiExReleaseGlobalLock ( BOOLEAN Locked); -UINT32 -AcpiExDigitsNeeded ( - ACPI_INTEGER Value, - UINT32 Base); - void AcpiExEisaIdToString ( UINT32 NumericId, @@ -760,7 +657,6 @@ AcpiExUnsignedIntegerToString ( /* * exregion - default OpRegion handlers */ - ACPI_STATUS AcpiExSystemMemorySpaceHandler ( UINT32 Function, diff --git a/sys/contrib/dev/acpica/aclocal.h b/sys/contrib/dev/acpica/aclocal.h index 87bfc4c..314d69b 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: 202 $ + * $Revision: 1.215 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -129,6 +129,13 @@ typedef UINT32 ACPI_MUTEX_HANDLE; #define AML_NUM_OPCODES 0x7F +/* Forward declarations */ + +struct acpi_walk_state; +struct acpi_obj_mutex; +union acpi_parse_object; + + /***************************************************************************** * * Mutex typedefs and structs @@ -145,7 +152,6 @@ typedef UINT32 ACPI_MUTEX_HANDLE; * * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames table also! */ - #define ACPI_MTX_EXECUTE 0 #define ACPI_MTX_INTERPRETER 1 #define ACPI_MTX_PARSER 2 @@ -190,20 +196,25 @@ static char *AcpiGbl_MutexNames[] = #endif +/* Owner IDs are used to track namespace nodes for selective deletion */ + +typedef UINT8 ACPI_OWNER_ID; +#define ACPI_OWNER_ID_MAX 0xFF + +/* This Thread ID means that the mutex is not in use (unlocked) */ + +#define ACPI_MUTEX_NOT_ACQUIRED (UINT32) -1 + /* Table for the global mutexes */ typedef struct acpi_mutex_info { ACPI_MUTEX Mutex; UINT32 UseCount; - UINT32 OwnerId; + UINT32 ThreadId; } ACPI_MUTEX_INFO; -/* This owner ID means that the mutex is not in use (unlocked) */ - -#define ACPI_MUTEX_NOT_ACQUIRED (UINT32) (-1) - /* Lock flag parameter for various interfaces */ @@ -211,13 +222,6 @@ typedef struct acpi_mutex_info #define ACPI_MTX_LOCK 1 -typedef UINT16 ACPI_OWNER_ID; -#define ACPI_OWNER_TYPE_TABLE 0x0 -#define ACPI_OWNER_TYPE_METHOD 0x1 -#define ACPI_FIRST_METHOD_ID 0x0001 -#define ACPI_FIRST_TABLE_ID 0xF000 - - /* Field access granularities */ #define ACPI_FIELD_BYTE_GRANULARITY 1 @@ -225,13 +229,13 @@ typedef UINT16 ACPI_OWNER_ID; #define ACPI_FIELD_DWORD_GRANULARITY 4 #define ACPI_FIELD_QWORD_GRANULARITY 8 + /***************************************************************************** * * Namespace typedefs and structs * ****************************************************************************/ - /* Operational modes of the AML interpreter/scanner */ typedef enum @@ -250,7 +254,6 @@ typedef enum * DataType is used to differentiate between internal descriptors, and MUST * be the first byte in this structure. */ - typedef union acpi_name_union { UINT32 Integer; @@ -262,14 +265,21 @@ typedef struct acpi_namespace_node { UINT8 Descriptor; /* Used to differentiate object descriptor types */ UINT8 Type; /* Type associated with this name */ - UINT16 OwnerId; + UINT16 ReferenceCount; /* Current count of references and children */ ACPI_NAME_UNION Name; /* ACPI Name, always 4 chars per ACPI spec */ union acpi_operand_object *Object; /* Pointer to attached ACPI object (optional) */ struct acpi_namespace_node *Child; /* First child */ struct acpi_namespace_node *Peer; /* Next peer*/ - UINT16 ReferenceCount; /* Current count of references and children */ + UINT8 OwnerId; /* Who created this node */ UINT8 Flags; + /* Fields used by the ASL compiler only */ + +#ifdef ACPI_ASL_COMPILER + UINT32 Value; + union acpi_parse_object *Op; +#endif + } ACPI_NAMESPACE_NODE; @@ -300,7 +310,7 @@ typedef struct acpi_table_desc UINT64 PhysicalAddress; UINT32 AmlLength; ACPI_SIZE Length; - ACPI_OWNER_ID TableId; + ACPI_OWNER_ID OwnerId; UINT8 Type; UINT8 Allocation; BOOLEAN LoadedIntoNamespace; @@ -455,7 +465,7 @@ typedef struct acpi_gpe_xrupt_info struct acpi_gpe_xrupt_info *Previous; struct acpi_gpe_xrupt_info *Next; ACPI_GPE_BLOCK_INFO *GpeBlockListHead; /* List of GPE blocks for this xrupt */ - UINT32 InterruptLevel; /* System interrupt level */ + UINT32 InterruptNumber; /* System interrupt number */ } ACPI_GPE_XRUPT_INFO; @@ -508,7 +518,6 @@ typedef struct acpi_field_info * ****************************************************************************/ - #define ACPI_CONTROL_NORMAL 0xC0 #define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1 #define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2 @@ -516,12 +525,6 @@ typedef struct acpi_field_info #define ACPI_CONTROL_PREDICATE_TRUE 0xC4 -/* Forward declarations */ -struct acpi_walk_state; -struct acpi_obj_mutex; -union acpi_parse_object; - - #define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ UINT8 DataType; /* To differentiate various internal objs */\ UINT8 Flags; \ @@ -704,7 +707,6 @@ typedef struct acpi_opcode_info } ACPI_OPCODE_INFO; - typedef union acpi_parse_value { ACPI_INTEGER Integer; /* Integer constant (Up to 64 bits) */ @@ -717,7 +719,6 @@ typedef union acpi_parse_value } ACPI_PARSE_VALUE; - #define ACPI_PARSE_COMMON \ UINT8 DataType; /* To differentiate various internal objs */\ UINT8 Flags; /* Type of Op */\ @@ -797,7 +798,6 @@ typedef struct acpi_parse_obj_asl } ACPI_PARSE_OBJ_ASL; - typedef union acpi_parse_object { ACPI_PARSE_OBJ_COMMON Common; @@ -850,6 +850,7 @@ typedef struct acpi_parse_state ****************************************************************************/ #define PCI_ROOT_HID_STRING "PNP0A03" +#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" typedef struct acpi_bit_register_info { @@ -883,6 +884,7 @@ typedef struct acpi_bit_register_info #define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100 #define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200 #define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400 +#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */ #define ACPI_BITMASK_WAKE_STATUS 0x8000 #define ACPI_BITMASK_ALL_FIXED_STATUS (ACPI_BITMASK_TIMER_STATUS | \ @@ -898,6 +900,7 @@ typedef struct acpi_bit_register_info #define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100 #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200 #define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400 +#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */ #define ACPI_BITMASK_SCI_ENABLE 0x0001 #define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 @@ -916,6 +919,7 @@ typedef struct acpi_bit_register_info #define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08 #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09 #define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A +#define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */ #define ACPI_BITPOSITION_WAKE_STATUS 0x0F #define ACPI_BITPOSITION_TIMER_ENABLE 0x00 @@ -923,6 +927,7 @@ typedef struct acpi_bit_register_info #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08 #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09 #define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A +#define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */ #define ACPI_BITPOSITION_SCI_ENABLE 0x00 #define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 @@ -939,48 +944,55 @@ typedef struct acpi_bit_register_info * ****************************************************************************/ - /* ResourceType values */ -#define ACPI_RESOURCE_TYPE_MEMORY_RANGE 0 -#define ACPI_RESOURCE_TYPE_IO_RANGE 1 -#define ACPI_RESOURCE_TYPE_BUS_NUMBER_RANGE 2 +#define ACPI_ADDRESS_TYPE_MEMORY_RANGE 0 +#define ACPI_ADDRESS_TYPE_IO_RANGE 1 +#define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE 2 /* Resource descriptor types and masks */ -#define ACPI_RDESC_TYPE_LARGE 0x80 -#define ACPI_RDESC_TYPE_SMALL 0x00 +#define ACPI_RESOURCE_NAME_LARGE 0x80 +#define ACPI_RESOURCE_NAME_SMALL 0x00 -#define ACPI_RDESC_TYPE_MASK 0x80 -#define ACPI_RDESC_SMALL_MASK 0x78 /* Only bits 6:3 contain the type */ +#define ACPI_RESOURCE_NAME_SMALL_MASK 0x78 /* Bits 6:3 contain the type */ +#define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */ +#define ACPI_RESOURCE_NAME_LARGE_MASK 0x7F /* Bits 6:0 contain the type */ /* - * Small resource descriptor types - * Note: The 3 length bits (2:0) must be zero + * Small resource descriptor "names" as defined by the ACPI specification. + * Note: Bits 2:0 are used for the descriptor length */ -#define ACPI_RDESC_TYPE_IRQ_FORMAT 0x20 -#define ACPI_RDESC_TYPE_DMA_FORMAT 0x28 -#define ACPI_RDESC_TYPE_START_DEPENDENT 0x30 -#define ACPI_RDESC_TYPE_END_DEPENDENT 0x38 -#define ACPI_RDESC_TYPE_IO_PORT 0x40 -#define ACPI_RDESC_TYPE_FIXED_IO_PORT 0x48 -#define ACPI_RDESC_TYPE_SMALL_VENDOR 0x70 -#define ACPI_RDESC_TYPE_END_TAG 0x78 +#define ACPI_RESOURCE_NAME_IRQ 0x20 +#define ACPI_RESOURCE_NAME_DMA 0x28 +#define ACPI_RESOURCE_NAME_START_DEPENDENT 0x30 +#define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38 +#define ACPI_RESOURCE_NAME_IO 0x40 +#define ACPI_RESOURCE_NAME_FIXED_IO 0x48 +#define ACPI_RESOURCE_NAME_RESERVED_S1 0x50 +#define ACPI_RESOURCE_NAME_RESERVED_S2 0x58 +#define ACPI_RESOURCE_NAME_RESERVED_S3 0x60 +#define ACPI_RESOURCE_NAME_RESERVED_S4 0x68 +#define ACPI_RESOURCE_NAME_VENDOR_SMALL 0x70 +#define ACPI_RESOURCE_NAME_END_TAG 0x78 /* - * Large resource descriptor types + * Large resource descriptor "names" as defined by the ACPI specification. + * Note: includes the Large Descriptor bit in bit[7] */ - -#define ACPI_RDESC_TYPE_MEMORY_24 0x81 -#define ACPI_RDESC_TYPE_GENERAL_REGISTER 0x82 -#define ACPI_RDESC_TYPE_LARGE_VENDOR 0x84 -#define ACPI_RDESC_TYPE_MEMORY_32 0x85 -#define ACPI_RDESC_TYPE_FIXED_MEMORY_32 0x86 -#define ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE 0x87 -#define ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE 0x88 -#define ACPI_RDESC_TYPE_EXTENDED_XRUPT 0x89 -#define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE 0x8A +#define ACPI_RESOURCE_NAME_MEMORY24 0x81 +#define ACPI_RESOURCE_NAME_GENERIC_REGISTER 0x82 +#define ACPI_RESOURCE_NAME_RESERVED_L1 0x83 +#define ACPI_RESOURCE_NAME_VENDOR_LARGE 0x84 +#define ACPI_RESOURCE_NAME_MEMORY32 0x85 +#define ACPI_RESOURCE_NAME_FIXED_MEMORY32 0x86 +#define ACPI_RESOURCE_NAME_ADDRESS32 0x87 +#define ACPI_RESOURCE_NAME_ADDRESS16 0x88 +#define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89 +#define ACPI_RESOURCE_NAME_ADDRESS64 0x8A +#define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B +#define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B /***************************************************************************** @@ -989,7 +1001,7 @@ typedef struct acpi_bit_register_info * ****************************************************************************/ -#define ACPI_ASCII_ZERO 0x30 +#define ACPI_ASCII_ZERO 0x30 /***************************************************************************** @@ -1028,15 +1040,6 @@ typedef struct acpi_integrity_info * ****************************************************************************/ -typedef struct acpi_debug_print_info -{ - UINT32 ComponentId; - char *ProcName; - char *ModuleName; - -} ACPI_DEBUG_PRINT_INFO; - - /* Entry for a memory allocation (debug only) */ #define ACPI_MEM_MALLOC 0 @@ -1068,24 +1071,18 @@ typedef struct acpi_debug_mem_block #define ACPI_MEM_LIST_GLOBAL 0 #define ACPI_MEM_LIST_NSNODE 1 - -#define ACPI_MEM_LIST_FIRST_CACHE_LIST 2 -#define ACPI_MEM_LIST_STATE 2 -#define ACPI_MEM_LIST_PSNODE 3 -#define ACPI_MEM_LIST_PSNODE_EXT 4 -#define ACPI_MEM_LIST_OPERAND 5 -#define ACPI_MEM_LIST_WALK 6 -#define ACPI_MEM_LIST_MAX 6 -#define ACPI_NUM_MEM_LISTS 7 +#define ACPI_MEM_LIST_MAX 1 +#define ACPI_NUM_MEM_LISTS 2 typedef struct acpi_memory_list { + char *ListName; void *ListHead; - UINT16 LinkOffset; - UINT16 MaxCacheDepth; - UINT16 CacheDepth; UINT16 ObjectSize; + UINT16 MaxDepth; + UINT16 CurrentDepth; + UINT16 LinkOffset; #ifdef ACPI_DBG_TRACK_ALLOCATIONS @@ -1094,9 +1091,8 @@ typedef struct acpi_memory_list UINT32 TotalAllocated; UINT32 TotalFreed; UINT32 CurrentTotalSize; - UINT32 CacheRequests; - UINT32 CacheHits; - char *ListName; + UINT32 Requests; + UINT32 Hits; #endif } ACPI_MEMORY_LIST; diff --git a/sys/contrib/dev/acpica/acmacros.h b/sys/contrib/dev/acpica/acmacros.h index 2925e2f..039641c 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: 154 $ + * $Revision: 1.165 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -128,6 +128,7 @@ #define ACPI_SET_BIT(target,bit) ((target) |= (bit)) #define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) +#define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) #if ACPI_MACHINE_WIDTH == 16 @@ -276,7 +277,7 @@ #define ACPI_BUFFER_INDEX(BufLen,BufOffset,ByteGran) (BufOffset) -#ifdef ACPI_MISALIGNED_TRANSFERS +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED /* The hardware supports unaligned transfers, just do the little-endian move */ @@ -509,21 +510,22 @@ #define ACPI_PARAM_LIST(pl) pl /* - * Error reporting. These versions add callers module and line#. Since - * _THIS_MODULE gets compiled out when ACPI_DEBUG_OUTPUT isn't defined, only - * use it in debug mode. + * Error reporting. These versions add callers module and line#. + * + * Since _AcpiModuleName gets compiled out when ACPI_DEBUG_OUTPUT + * isn't defined, only use it in debug mode. */ #ifdef ACPI_DEBUG_OUTPUT -#define ACPI_REPORT_INFO(fp) {AcpiUtReportInfo(_THIS_MODULE,__LINE__,_COMPONENT); \ +#define ACPI_REPORT_INFO(fp) {AcpiUtReportInfo(_AcpiModuleName,__LINE__,_COMPONENT); \ AcpiOsPrintf ACPI_PARAM_LIST(fp);} -#define ACPI_REPORT_ERROR(fp) {AcpiUtReportError(_THIS_MODULE,__LINE__,_COMPONENT); \ +#define ACPI_REPORT_ERROR(fp) {AcpiUtReportError(_AcpiModuleName,__LINE__,_COMPONENT); \ AcpiOsPrintf ACPI_PARAM_LIST(fp);} -#define ACPI_REPORT_WARNING(fp) {AcpiUtReportWarning(_THIS_MODULE,__LINE__,_COMPONENT); \ +#define ACPI_REPORT_WARNING(fp) {AcpiUtReportWarning(_AcpiModuleName,__LINE__,_COMPONENT); \ AcpiOsPrintf ACPI_PARAM_LIST(fp);} -#define ACPI_REPORT_NSERROR(s,e) AcpiNsReportError(_THIS_MODULE,__LINE__,_COMPONENT, s, e); +#define ACPI_REPORT_NSERROR(s,e) AcpiNsReportError(_AcpiModuleName,__LINE__,_COMPONENT, s, e); -#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) AcpiNsReportMethodError(_THIS_MODULE,__LINE__,_COMPONENT, s, n, p, e); +#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) AcpiNsReportMethodError(_AcpiModuleName,__LINE__,_COMPONENT, s, n, p, e); #else @@ -552,36 +554,61 @@ * Debug macros that are conditionally compiled */ #ifdef ACPI_DEBUG_OUTPUT +#define ACPI_MODULE_NAME(Name) static char ACPI_UNUSED_VAR *_AcpiModuleName = Name; -#define ACPI_MODULE_NAME(name) static char ACPI_UNUSED_VAR *_THIS_MODULE = name; +/* + * Common parameters used for debug output functions: + * line number, function name, module(file) name, component ID + */ +#define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _AcpiModuleName, _COMPONENT + +/* + * Function entry tracing + */ /* - * Function entry tracing. - * 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. + * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header, + * define it now. This is the case where there the compiler does not support + * a __FUNCTION__ macro or equivalent. We save the function name on the + * local stack. + */ +#ifndef ACPI_GET_FUNCTION_NAME +#define ACPI_GET_FUNCTION_NAME _AcpiFunctionName +/* + * The Name parameter should be the procedure name as a quoted string. + * This is declared as a local string ("MyFunctionName") so that it can + * be also used by the function exit macros below. + * Note: (const char) is used to be compatible with the debug interfaces + * and macros such as __FUNCTION__. */ -#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__,&_DebugInfo) -#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ - AcpiUtTracePtr(__LINE__,&_DebugInfo,(void *)b) -#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ - AcpiUtTraceU32(__LINE__,&_DebugInfo,(UINT32)b) -#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \ - AcpiUtTraceStr(__LINE__,&_DebugInfo,(char *)b) - -#define ACPI_FUNCTION_ENTRY() AcpiUtTrackStackPtr() +#define ACPI_FUNCTION_NAME(Name) const char *_AcpiFunctionName = Name; + +#else +/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ + +#define ACPI_FUNCTION_NAME(Name) +#endif + +#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ + AcpiUtTrace(ACPI_DEBUG_PARAMETERS) +#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ + AcpiUtTracePtr(ACPI_DEBUG_PARAMETERS,(void *)b) +#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a) \ + AcpiUtTraceU32(ACPI_DEBUG_PARAMETERS,(UINT32)b) +#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a) \ + AcpiUtTraceStr(ACPI_DEBUG_PARAMETERS,(char *)b) + +#define ACPI_FUNCTION_ENTRY() AcpiUtTrackStackPtr() /* * Function exit tracing. * WARNING: These macros include a return statement. This is usually considered * bad form, but having a separate exit macro is very ugly and difficult to maintain. * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros - * so that "_ProcName" is defined. + * so that "_AcpiFunctionName" is defined. + * + * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining + * about these constructs. */ #ifdef ACPI_USE_DO_WHILE_0 #define ACPI_DO_WHILE0(a) do a while(0) @@ -589,10 +616,56 @@ #define ACPI_DO_WHILE0(a) a #endif -#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));}) +#define return_VOID ACPI_DO_WHILE0 ({ \ + AcpiUtExit (ACPI_DEBUG_PARAMETERS); \ + return;}) +/* + * There are two versions of most of the return macros. The default version is + * safer, since it avoids side-effects by guaranteeing that the argument will + * not be evaluated twice. + * + * A less-safe version of the macros is provided for optional use if the + * compiler uses excessive CPU stack (for example, this may happen in the + * debug case if code optimzation is disabled.) + */ +#ifndef ACPI_SIMPLE_RETURN_MACROS + +#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ + register ACPI_STATUS _s = (s); \ + AcpiUtStatusExit (ACPI_DEBUG_PARAMETERS, _s); \ + return (_s); }) +#define return_PTR(s) ACPI_DO_WHILE0 ({ \ + register void *_s = (void *) (s); \ + AcpiUtPtrExit (ACPI_DEBUG_PARAMETERS, (UINT8 *) _s); \ + return (_s); }) +#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ + register ACPI_INTEGER _s = (s); \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, _s); \ + return (_s); }) +#define return_UINT8(s) ACPI_DO_WHILE0 ({ \ + register UINT8 _s = (UINT8) (s); \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) _s); \ + return (_s); }) +#define return_UINT32(s) ACPI_DO_WHILE0 ({ \ + register UINT32 _s = (UINT32) (s); \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) _s); \ + return (_s); }) +#else /* Use original less-safe macros */ + +#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ + AcpiUtStatusExit (ACPI_DEBUG_PARAMETERS, (s)); \ + return((s)); }) +#define return_PTR(s) ACPI_DO_WHILE0 ({ \ + AcpiUtPtrExit (ACPI_DEBUG_PARAMETERS, (UINT8 *) (s)); \ + return((s)); }) +#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) (s)); \ + return((s)); }) +#define return_UINT8(s) return_VALUE(s) +#define return_UINT32(s) return_VALUE(s) + +#endif /* ACPI_SIMPLE_RETURN_MACROS */ + /* Conditional execution */ @@ -607,11 +680,10 @@ /* Stack and buffer dumping */ #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__) +#define ACPI_DUMP_OPERANDS(a,b,c,d,e) AcpiExDumpOperands(a,b,c,d,e,_AcpiModuleName,__LINE__) #define ACPI_DUMP_ENTRY(a,b) AcpiNsDumpEntry (a,b) -#define ACPI_DUMP_TABLES(a,b) AcpiNsDumpTables(a,b) #define ACPI_DUMP_PATHNAME(a,b,c,d) AcpiNsDumpPathname(a,b,c,d) #define ACPI_DUMP_RESOURCE_LIST(a) AcpiRsDumpResourceList(a) #define ACPI_DUMP_BUFFER(a,b) AcpiUtDumpBuffer((UINT8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT) @@ -644,8 +716,8 @@ * This is the non-debug case -- make everything go away, * leaving no executable debug code! */ -#define ACPI_MODULE_NAME(name) -#define _THIS_MODULE "" +#define ACPI_MODULE_NAME(Name) +#define _AcpiModuleName "" #define ACPI_DEBUG_EXEC(a) #define ACPI_NORMAL_EXEC(a) a; @@ -675,6 +747,8 @@ #define return_VOID return #define return_ACPI_STATUS(s) return(s) #define return_VALUE(s) return(s) +#define return_UINT8(s) return(s) +#define return_UINT32(s) return(s) #define return_PTR(s) return(s) #endif @@ -722,19 +796,18 @@ /* Memory allocation */ -#define ACPI_MEM_ALLOCATE(a) AcpiUtAllocate((ACPI_SIZE)(a),_COMPONENT,_THIS_MODULE,__LINE__) -#define ACPI_MEM_CALLOCATE(a) AcpiUtCallocate((ACPI_SIZE)(a), _COMPONENT,_THIS_MODULE,__LINE__) +#define ACPI_MEM_ALLOCATE(a) AcpiUtAllocate((ACPI_SIZE)(a),_COMPONENT,_AcpiModuleName,__LINE__) +#define ACPI_MEM_CALLOCATE(a) AcpiUtCallocate((ACPI_SIZE)(a), _COMPONENT,_AcpiModuleName,__LINE__) #define ACPI_MEM_FREE(a) AcpiOsFree(a) #define ACPI_MEM_TRACKING(a) - #else /* Memory allocation */ -#define ACPI_MEM_ALLOCATE(a) AcpiUtAllocateAndTrack((ACPI_SIZE)(a),_COMPONENT,_THIS_MODULE,__LINE__) -#define ACPI_MEM_CALLOCATE(a) AcpiUtCallocateAndTrack((ACPI_SIZE)(a), _COMPONENT,_THIS_MODULE,__LINE__) -#define ACPI_MEM_FREE(a) AcpiUtFreeAndTrack(a,_COMPONENT,_THIS_MODULE,__LINE__) +#define ACPI_MEM_ALLOCATE(a) AcpiUtAllocateAndTrack((ACPI_SIZE)(a),_COMPONENT,_AcpiModuleName,__LINE__) +#define ACPI_MEM_CALLOCATE(a) AcpiUtCallocateAndTrack((ACPI_SIZE)(a), _COMPONENT,_AcpiModuleName,__LINE__) +#define ACPI_MEM_FREE(a) AcpiUtFreeAndTrack(a,_COMPONENT,_AcpiModuleName,__LINE__) #define ACPI_MEM_TRACKING(a) a #endif /* ACPI_DBG_TRACK_ALLOCATIONS */ diff --git a/sys/contrib/dev/acpica/acnames.h b/sys/contrib/dev/acpica/acnames.h new file mode 100644 index 0000000..243cc34 --- /dev/null +++ b/sys/contrib/dev/acpica/acnames.h @@ -0,0 +1,158 @@ +/****************************************************************************** + * + * Name: acnames.h - Global names and strings + * $Revision: 1.5 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACNAMES_H__ +#define __ACNAMES_H__ + +/* Method names - these methods can appear anywhere in the namespace */ + +#define METHOD_NAME__HID "_HID" +#define METHOD_NAME__CID "_CID" +#define METHOD_NAME__UID "_UID" +#define METHOD_NAME__ADR "_ADR" +#define METHOD_NAME__INI "_INI" +#define METHOD_NAME__STA "_STA" +#define METHOD_NAME__REG "_REG" +#define METHOD_NAME__SEG "_SEG" +#define METHOD_NAME__BBN "_BBN" +#define METHOD_NAME__PRT "_PRT" +#define METHOD_NAME__CRS "_CRS" +#define METHOD_NAME__PRS "_PRS" +#define METHOD_NAME__PRW "_PRW" +#define METHOD_NAME__SRS "_SRS" + +/* Method names - these methods must appear at the namespace root */ + +#define METHOD_NAME__BFS "\\_BFS" +#define METHOD_NAME__GTS "\\_GTS" +#define METHOD_NAME__PTS "\\_PTS" +#define METHOD_NAME__SST "\\_SI._SST" +#define METHOD_NAME__WAK "\\_WAK" + +/* Definitions of the predefined namespace names */ + +#define ACPI_UNKNOWN_NAME (UINT32) 0x3F3F3F3F /* Unknown name is "????" */ +#define ACPI_ROOT_NAME (UINT32) 0x5F5F5F5C /* Root name is "\___" */ + +#define ACPI_PREFIX_MIXED (UINT32) 0x69706341 /* "Acpi" */ +#define ACPI_PREFIX_LOWER (UINT32) 0x69706361 /* "acpi" */ + +#define ACPI_NS_ROOT_PATH "\\" +#define ACPI_NS_SYSTEM_BUS "_SB_" + +#endif /* __ACNAMES_H__ */ + + diff --git a/sys/contrib/dev/acpica/acnamesp.h b/sys/contrib/dev/acpica/acnamesp.h index 290ebc1..abf3e12 100644 --- a/sys/contrib/dev/acpica/acnamesp.h +++ b/sys/contrib/dev/acpica/acnamesp.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acnamesp.h - Namespace subcomponent prototypes and defines - * $Revision: 136 $ + * $Revision: 1.142 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -130,17 +130,6 @@ #define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */ #define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */ - -/* Definitions of the predefined namespace names */ - -#define ACPI_UNKNOWN_NAME (UINT32) 0x3F3F3F3F /* Unknown name is "????" */ -#define ACPI_ROOT_NAME (UINT32) 0x5F5F5F5C /* Root name is "\___" */ -#define ACPI_SYS_BUS_NAME (UINT32) 0x5F53425F /* Sys bus name is "_SB_" */ - -#define ACPI_NS_ROOT_PATH "\\" -#define ACPI_NS_SYSTEM_BUS "_SB_" - - /* Flags for AcpiNsLookup, AcpiNsSearchAndEnter */ #define ACPI_NS_NO_UPSEARCH 0 @@ -153,10 +142,9 @@ #define ACPI_NS_WALK_NO_UNLOCK FALSE -ACPI_STATUS -AcpiNsLoadNamespace ( - void); - +/* + * nsinit - Namespace initialization + */ ACPI_STATUS AcpiNsInitializeObjects ( void); @@ -166,23 +154,22 @@ AcpiNsInitializeDevices ( void); -/* Namespace init - nsxfinit */ - +/* + * nsload - Namespace loading + */ ACPI_STATUS -AcpiNsInitOneDevice ( - ACPI_HANDLE ObjHandle, - UINT32 NestingLevel, - void *Context, - void **ReturnValue); +AcpiNsLoadNamespace ( + void); ACPI_STATUS -AcpiNsInitOneObject ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); +AcpiNsLoadTable ( + ACPI_TABLE_DESC *TableDesc, + ACPI_NAMESPACE_NODE *Node); +/* + * nswalk - walk the namespace + */ ACPI_STATUS AcpiNsWalkNamespace ( ACPI_OBJECT_TYPE Type, @@ -199,37 +186,24 @@ AcpiNsGetNextNode ( ACPI_NAMESPACE_NODE *Parent, ACPI_NAMESPACE_NODE *Child); -void -AcpiNsDeleteNamespaceByOwner ( - UINT16 TableId); - - -/* Namespace loading - nsload */ - -ACPI_STATUS -AcpiNsOneCompleteParse ( - UINT32 PassNumber, - ACPI_TABLE_DESC *TableDesc); +/* + * nsparse - table parsing + */ ACPI_STATUS AcpiNsParseTable ( ACPI_TABLE_DESC *TableDesc, ACPI_NAMESPACE_NODE *Scope); ACPI_STATUS -AcpiNsLoadTable ( - ACPI_TABLE_DESC *TableDesc, - ACPI_NAMESPACE_NODE *Node); - -ACPI_STATUS -AcpiNsLoadTableByType ( - ACPI_TABLE_TYPE TableType); +AcpiNsOneCompleteParse ( + UINT8 PassNumber, + ACPI_TABLE_DESC *TableDesc); /* - * Top-level namespace access - nsaccess + * nsaccess - Top-level namespace access */ - ACPI_STATUS AcpiNsRootInitialize ( void); @@ -246,9 +220,8 @@ AcpiNsLookup ( /* - * Named object allocation/deallocation - nsalloc + * nsalloc - Named object allocation/deallocation */ - ACPI_NAMESPACE_NODE * AcpiNsCreateNode ( UINT32 Name); @@ -262,6 +235,10 @@ AcpiNsDeleteNamespaceSubtree ( ACPI_NAMESPACE_NODE *ParentHandle); void +AcpiNsDeleteNamespaceByOwner ( + ACPI_OWNER_ID OwnerId); + +void AcpiNsDetachObject ( ACPI_NAMESPACE_NODE *Node); @@ -274,28 +251,10 @@ AcpiNsCompareNames ( char *Name1, char *Name2); -void -AcpiNsRemoveReference ( - ACPI_NAMESPACE_NODE *Node); - - -/* - * Namespace modification - nsmodify - */ - -ACPI_STATUS -AcpiNsUnloadNamespace ( - ACPI_HANDLE Handle); - -ACPI_STATUS -AcpiNsDeleteSubtree ( - ACPI_HANDLE StartHandle); - /* - * Namespace dump/print utilities - nsdump + * nsdump - Namespace dump/print utilities */ - void AcpiNsDumpTables ( ACPI_HANDLE SearchBase, @@ -319,17 +278,6 @@ AcpiNsPrintPathname ( char *Pathname); ACPI_STATUS -AcpiNsDumpOneDevice ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); - -void -AcpiNsDumpRootDevices ( - void); - -ACPI_STATUS AcpiNsDumpOneObject ( ACPI_HANDLE ObjHandle, UINT32 Level, @@ -341,14 +289,13 @@ AcpiNsDumpObjects ( ACPI_OBJECT_TYPE Type, UINT8 DisplayType, UINT32 MaxDepth, - UINT32 OwnderId, + ACPI_OWNER_ID OwnerId, ACPI_HANDLE StartHandle); /* - * Namespace evaluation functions - nseval + * nseval - Namespace evaluation functions */ - ACPI_STATUS AcpiNsEvaluateByHandle ( ACPI_PARAMETER_INFO *Info); @@ -363,38 +310,14 @@ AcpiNsEvaluateRelative ( char *Pathname, ACPI_PARAMETER_INFO *Info); -ACPI_STATUS -AcpiNsExecuteControlMethod ( - ACPI_PARAMETER_INFO *Info); - -ACPI_STATUS -AcpiNsGetObjectValue ( - ACPI_PARAMETER_INFO *Info); - /* - * Parent/Child/Peer utility functions + * nsnames - Name and Scope manipulation */ - -ACPI_NAME -AcpiNsFindParentName ( - ACPI_NAMESPACE_NODE *NodeToSearch); - - -/* - * Name and Scope manipulation - nsnames - */ - UINT32 AcpiNsOpensScope ( ACPI_OBJECT_TYPE Type); -void -AcpiNsBuildExternalPath ( - ACPI_NAMESPACE_NODE *Node, - ACPI_SIZE Size, - char *NameBuffer); - char * AcpiNsGetExternalPathname ( ACPI_NAMESPACE_NODE *Node); @@ -426,9 +349,8 @@ AcpiNsGetPathnameLength ( /* - * Object management for namespace nodes - nsobject + * nsobject - Object management for namespace nodes */ - ACPI_STATUS AcpiNsAttachObject ( ACPI_NAMESPACE_NODE *Node, @@ -462,9 +384,8 @@ AcpiNsGetAttachedData ( /* - * Namespace searching and entry - nssearch + * nssearch - Namespace searching and entry */ - ACPI_STATUS AcpiNsSearchAndEnter ( UINT32 EntryName, @@ -491,17 +412,12 @@ AcpiNsInstallNode ( /* - * Utility functions - nsutils + * nsutils - Utility functions */ - BOOLEAN AcpiNsValidRootPrefix ( char Prefix); -BOOLEAN -AcpiNsValidPathSeparator ( - char Sep); - ACPI_OBJECT_TYPE AcpiNsGetType ( ACPI_NAMESPACE_NODE *Node); @@ -574,5 +490,4 @@ ACPI_NAMESPACE_NODE * AcpiNsGetNextValidNode ( ACPI_NAMESPACE_NODE *Node); - #endif /* __ACNAMESP_H__ */ diff --git a/sys/contrib/dev/acpica/acobject.h b/sys/contrib/dev/acpica/acobject.h index 40db575..b56d4c1 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: 126 $ + * $Revision: 1.130 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -167,9 +167,7 @@ UINT32 BitLength; /* Length of field in bits */\ UINT32 BaseByteOffset; /* Byte offset within containing object */\ UINT8 StartFieldBitOffset;/* Bit offset within first field datum (0-63) */\ - UINT8 DatumValidBits; /* Valid bit in first "Field datum" */\ - UINT8 EndFieldValidBits; /* Valid bits in the last "field datum" */\ - UINT8 EndBufferValidBits; /* Valid bits in the last "buffer datum" */\ + UINT8 AccessBitWidth; /* Read/Write size in bits (8-64) */\ UINT32 Value; /* Value to store into the Bank or Index register */\ ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ @@ -210,6 +208,7 @@ 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. @@ -279,7 +278,7 @@ typedef struct acpi_object_method ACPI_INTERNAL_METHOD Implementation; UINT8 Concurrency; UINT8 ThreadCount; - ACPI_OWNER_ID OwningId; + ACPI_OWNER_ID OwnerId; } ACPI_OBJECT_METHOD; @@ -568,7 +567,6 @@ typedef union acpi_operand_object * *****************************************************************************/ - /* Object descriptor types */ #define ACPI_DESC_TYPE_CACHED 0x01 /* Used only when object is cached */ diff --git a/sys/contrib/dev/acpica/acopcode.h b/sys/contrib/dev/acpica/acopcode.h new file mode 100644 index 0000000..f7c329b --- /dev/null +++ b/sys/contrib/dev/acpica/acopcode.h @@ -0,0 +1,398 @@ +/****************************************************************************** + * + * Name: acopcode.h - AML opcode information for the AML parser and interpreter + * $Revision: 1.3 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACOPCODE_H__ +#define __ACOPCODE_H__ + +#define MAX_EXTENDED_OPCODE 0x88 +#define NUM_EXTENDED_OPCODE (MAX_EXTENDED_OPCODE + 1) +#define MAX_INTERNAL_OPCODE +#define NUM_INTERNAL_OPCODE (MAX_INTERNAL_OPCODE + 1) + +/* Used for non-assigned opcodes */ + +#define _UNK 0x6B + +/* + * Reserved ASCII characters. Do not use any of these for + * internal opcodes, since they are used to differentiate + * name strings from AML opcodes + */ +#define _ASC 0x6C +#define _NAM 0x6C +#define _PFX 0x6D + + +/* + * All AML opcodes and the parse-time arguments for each. Used by the AML + * parser Each list is compressed into a 32-bit number and stored in the + * master opcode table (in psopcode.c). + */ +#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA) +#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME) +#define ARGP_ARG0 ARG_NONE +#define ARGP_ARG1 ARG_NONE +#define ARGP_ARG2 ARG_NONE +#define ARGP_ARG3 ARG_NONE +#define ARGP_ARG4 ARG_NONE +#define ARGP_ARG5 ARG_NONE +#define ARGP_ARG6 ARG_NONE +#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BREAK_OP ARG_NONE +#define ARGP_BREAK_POINT_OP ARG_NONE +#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST) +#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA) +#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME) +#define ARGP_CONTINUE_OP ARG_NONE +#define ARGP_COPY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SIMPLENAME) +#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_QWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_DEBUG_OP ARG_NONE +#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET) +#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA) +#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST) +#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME) +#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG) +#define ARGP_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME) +#define ARGP_LOAD_TABLE_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LOCAL0 ARG_NONE +#define ARGP_LOCAL1 ARG_NONE +#define ARGP_LOCAL2 ARG_NONE +#define ARGP_LOCAL3 ARG_NONE +#define ARGP_LOCAL4 ARG_NONE +#define ARGP_LOCAL5 ARG_NONE +#define ARGP_LOCAL6 ARG_NONE +#define ARGP_LOCAL7 ARG_NONE +#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST) +#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_MID_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MOD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA) +#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ) +#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_NOOP_OP ARG_NONE +#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_ONE_OP ARG_NONE +#define ARGP_ONES_OP ARG_NONE +#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) +#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST) +#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST) +#define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA) +#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_REVISION_OP ARG_NONE +#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST) +#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME) +#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) +#define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_DATAOBJLIST) +#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA) +#define ARGP_ZERO_OP ARG_NONE + + +/* + * All AML opcodes and the runtime arguments for each. Used by the AML + * interpreter Each list is compressed into a 32-bit number and stored + * in the master opcode table (in psopcode.c). + * + * (Used by PrepOperands procedure and the ASL Compiler) + */ +#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_INTEGER) +#define ARGI_ADD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE +#define ARGI_ARG0 ARG_NONE +#define ARGI_ARG1 ARG_NONE +#define ARGI_ARG2 ARG_NONE +#define ARGI_ARG3 ARG_NONE +#define ARGI_ARG4 ARG_NONE +#define ARGI_ARG5 ARG_NONE +#define ARGI_ARG6 ARG_NONE +#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BREAK_OP ARG_NONE +#define ARGI_BREAK_POINT_OP ARG_NONE +#define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_BYTE_OP ARGI_INVALID_OPCODE +#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE +#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF) +#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF) +#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF) +#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE +#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET) +#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#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_DEBUG_OP ARG_NONE +#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF) +#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING) +#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE +#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF) +#define ARGI_DWORD_OP ARGI_INVALID_OPCODE +#define ARGI_ELSE_OP ARGI_INVALID_OPCODE +#define ARGI_EVENT_OP ARGI_INVALID_OPCODE +#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_IF_OP ARGI_INVALID_OPCODE +#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF) +#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_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_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 +#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_FIELD,ARGI_TARGETREF) +#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE) +#define ARGI_LOCAL0 ARG_NONE +#define ARGI_LOCAL1 ARG_NONE +#define ARGI_LOCAL2 ARG_NONE +#define ARGI_LOCAL3 ARG_NONE +#define ARGI_LOCAL4 ARG_NONE +#define ARGI_LOCAL5 ARG_NONE +#define ARGI_LOCAL6 ARG_NONE +#define ARGI_LOCAL7 ARG_NONE +#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_COMPUTEDATA, ARGI_INTEGER,ARGI_COMPUTEDATA,ARGI_INTEGER) +#define ARGI_METHOD_OP ARGI_INVALID_OPCODE +#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE +#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE +#define ARGI_NAME_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE +#define ARGI_NOOP_OP ARG_NONE +#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER) +#define ARGI_ONE_OP ARG_NONE +#define ARGI_ONES_OP ARG_NONE +#define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE +#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE +#define ARGI_QWORD_OP ARGI_INVALID_OPCODE +#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF) +#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX) +#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT) +#define ARGI_RETURN_OP ARGI_INVALID_OPCODE +#define ARGI_REVISION_OP ARG_NONE +#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE +#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_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE +#define ARGI_STORE_OP ARGI_LIST2 (ARGI_DATAREFOBJ, ARGI_TARGETREF) +#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_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) +#define ARGI_WHILE_OP ARGI_INVALID_OPCODE +#define ARGI_WORD_OP ARGI_INVALID_OPCODE +#define ARGI_ZERO_OP ARG_NONE + +#endif /* __ACOPCODE_H__ */ diff --git a/sys/contrib/dev/acpica/acoutput.h b/sys/contrib/dev/acpica/acoutput.h index 4811b5c..8988f32 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: 95 $ + * $Revision: 1.97 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -209,7 +209,7 @@ /* * Debug level macros that are used in the DEBUG_PRINT macros */ -#define ACPI_DEBUG_LEVEL(dl) (UINT32) dl,__LINE__,&_DebugInfo +#define ACPI_DEBUG_LEVEL(dl) (UINT32) dl,ACPI_DEBUG_PARAMETERS /* Exception level -- used in the global "DebugLevel" */ diff --git a/sys/contrib/dev/acpica/acparser.h b/sys/contrib/dev/acpica/acparser.h index 32a2ae6..05bc566 100644 --- a/sys/contrib/dev/acpica/acparser.h +++ b/sys/contrib/dev/acpica/acparser.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: acparser.h - AML Parser subcomponent prototypes and defines - * $Revision: 67 $ + * $Revision: 1.77 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -136,17 +136,7 @@ #define ACPI_PARSE_MODE_MASK 0x0030 #define ACPI_PARSE_DEFERRED_OP 0x0100 - -/* Parser external interfaces */ - -ACPI_STATUS -AcpiPsxLoadTable ( - UINT8 *PcodeAddr, - UINT32 PcodeLength); - -ACPI_STATUS -AcpiPsxExecute ( - ACPI_PARAMETER_INFO *Info); +#define ACPI_PARSE_DISASSEMBLE 0x0200 /****************************************************************************** @@ -156,16 +146,21 @@ AcpiPsxExecute ( *****************************************************************************/ -/* psargs - Parse AML opcode arguments */ +/* + * psxface - Parser external interfaces + */ +ACPI_STATUS +AcpiPsExecuteMethod ( + ACPI_PARAMETER_INFO *Info); + +/* + * psargs - Parse AML opcode arguments + */ UINT8 * AcpiPsGetNextPackageEnd ( ACPI_PARSE_STATE *ParserState); -UINT32 -AcpiPsGetNextPackageLength ( - ACPI_PARSE_STATE *ParserState); - char * AcpiPsGetNextNamestring ( ACPI_PARSE_STATE *ParserState); @@ -183,10 +178,6 @@ AcpiPsGetNextNamepath ( ACPI_PARSE_OBJECT *Arg, BOOLEAN MethodCall); -ACPI_PARSE_OBJECT * -AcpiPsGetNextField ( - ACPI_PARSE_STATE *ParserState); - ACPI_STATUS AcpiPsGetNextArg ( ACPI_WALK_STATE *WalkState, @@ -195,8 +186,9 @@ AcpiPsGetNextArg ( ACPI_PARSE_OBJECT **ReturnArg); -/* psfind */ - +/* + * psfind + */ ACPI_PARSE_OBJECT * AcpiPsFindName ( ACPI_PARSE_OBJECT *Scope, @@ -208,8 +200,9 @@ AcpiPsGetParent ( ACPI_PARSE_OBJECT *Op); -/* psopcode - AML Opcode information */ - +/* + * psopcode - AML Opcode information + */ const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo ( UINT16 Opcode); @@ -219,13 +212,22 @@ AcpiPsGetOpcodeName ( UINT16 Opcode); -/* psparse - top level parsing routines */ +/* + * psparse - top level parsing routines + */ +ACPI_STATUS +AcpiPsParseAml ( + ACPI_WALK_STATE *WalkState); UINT32 AcpiPsGetOpcodeSize ( UINT32 Opcode); -void +UINT16 +AcpiPsPeekOpcode ( + ACPI_PARSE_STATE *state); + +ACPI_STATUS AcpiPsCompleteThisOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op); @@ -236,39 +238,18 @@ AcpiPsNextParseState ( ACPI_PARSE_OBJECT *Op, ACPI_STATUS CallbackStatus); -ACPI_STATUS -AcpiPsFindObject ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT **OutOp); - -void -AcpiPsDeleteParseTree ( - ACPI_PARSE_OBJECT *root); +/* + * psloop - main parse loop + */ ACPI_STATUS AcpiPsParseLoop ( ACPI_WALK_STATE *WalkState); -ACPI_STATUS -AcpiPsParseAml ( - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS -AcpiPsParseTable ( - UINT8 *aml, - UINT32 amlSize, - ACPI_PARSE_DOWNWARDS DescendingCallback, - ACPI_PARSE_UPWARDS AscendingCallback, - ACPI_PARSE_OBJECT **RootObject); - -UINT16 -AcpiPsPeekOpcode ( - ACPI_PARSE_STATE *state); - - -/* psscope - Scope stack management routines */ - +/* + * psscope - Scope stack management routines + */ ACPI_STATUS AcpiPsInitScope ( ACPI_PARSE_STATE *ParserState, @@ -301,8 +282,9 @@ AcpiPsCleanupScope ( ACPI_PARSE_STATE *state); -/* pstree - parse tree manipulation routines */ - +/* + * pstree - parse tree manipulation routines + */ void AcpiPsAppendArg( ACPI_PARSE_OBJECT *op, @@ -321,17 +303,14 @@ AcpiPsGetArg( UINT32 argn); ACPI_PARSE_OBJECT * -AcpiPsGetChild ( - ACPI_PARSE_OBJECT *op); - -ACPI_PARSE_OBJECT * AcpiPsGetDepthNext ( ACPI_PARSE_OBJECT *Origin, ACPI_PARSE_OBJECT *Op); -/* pswalk - parse tree walk routines */ - +/* + * pswalk - parse tree walk routines + */ ACPI_STATUS AcpiPsWalkParsedAml ( ACPI_PARSE_OBJECT *StartOp, @@ -354,9 +333,14 @@ ACPI_STATUS AcpiPsDeleteCompletedOp ( ACPI_WALK_STATE *WalkState); +void +AcpiPsDeleteParseTree ( + ACPI_PARSE_OBJECT *root); -/* psutils - parser utilities */ +/* + * psutils - parser utilities + */ ACPI_PARSE_OBJECT * AcpiPsCreateScopeOp ( void); @@ -374,10 +358,6 @@ void AcpiPsFreeOp ( ACPI_PARSE_OBJECT *Op); -void -AcpiPsDeleteParseCache ( - void); - BOOLEAN AcpiPsIsLeadingChar ( UINT32 c); @@ -396,8 +376,9 @@ AcpiPsSetName( UINT32 name); -/* psdump - display parser tree */ - +/* + * psdump - display parser tree + */ UINT32 AcpiPsSprintPath ( char *BufferStart, diff --git a/sys/contrib/dev/acpica/acpi.h b/sys/contrib/dev/acpica/acpi.h index c3477e1..260d81c 100644 --- a/sys/contrib/dev/acpica/acpi.h +++ b/sys/contrib/dev/acpica/acpi.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acpi.h - Master include file, Publics and external data. - * $Revision: 57 $ + * $Revision: 1.59 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -122,6 +122,7 @@ * We put them here because we don't want to duplicate them * in the rest of the source code again and again. */ +#include <contrib/dev/acpica/acnames.h> /* Global ACPI names and strings */ #include <contrib/dev/acpica/acconfig.h> /* Configuration constants */ #include <contrib/dev/acpica/acenv.h> /* Target environment specific items */ #include <contrib/dev/acpica/actypes.h> /* Fundamental common data types */ diff --git a/sys/contrib/dev/acpica/acpiosxf.h b/sys/contrib/dev/acpica/acpiosxf.h index f12db21..7f219ef 100644 --- a/sys/contrib/dev/acpica/acpiosxf.h +++ b/sys/contrib/dev/acpica/acpiosxf.h @@ -12,7 +12,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -153,7 +153,6 @@ typedef struct acpi_signal_fatal_info /* * OSL Initialization and shutdown primitives */ - ACPI_STATUS AcpiOsInitialize ( void); @@ -166,7 +165,6 @@ AcpiOsTerminate ( /* * ACPI Table interfaces */ - ACPI_STATUS AcpiOsGetRootPointer ( UINT32 Flags, @@ -186,7 +184,6 @@ AcpiOsTableOverride ( /* * Synchronization primitives */ - ACPI_STATUS AcpiOsCreateSemaphore ( UINT32 MaxUnits, @@ -216,21 +213,19 @@ void AcpiOsDeleteLock ( ACPI_HANDLE Handle); -void +ACPI_NATIVE_UINT AcpiOsAcquireLock ( - ACPI_HANDLE Handle, - UINT32 Flags); + ACPI_HANDLE Handle); void AcpiOsReleaseLock ( ACPI_HANDLE Handle, - UINT32 Flags); + ACPI_NATIVE_UINT Flags); /* * Memory allocation and mapping */ - void * AcpiOsAllocate ( ACPI_SIZE Size); @@ -257,9 +252,36 @@ AcpiOsGetPhysicalAddress ( /* - * Interrupt handlers + * Memory/Object Cache */ +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_CACHE_T **ReturnCache); + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_CACHE_T *Cache); + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_CACHE_T *Cache); + +void * +AcpiOsAcquireObject ( + ACPI_CACHE_T *Cache); + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_CACHE_T *Cache, + void *Object); + +/* + * Interrupt handlers + */ ACPI_STATUS AcpiOsInstallInterruptHandler ( UINT32 InterruptNumber, @@ -275,7 +297,6 @@ AcpiOsRemoveInterruptHandler ( /* * Threads and Scheduling */ - UINT32 AcpiOsGetThreadId ( void); @@ -302,7 +323,6 @@ AcpiOsStall ( /* * Platform and hardware-independent I/O interfaces */ - ACPI_STATUS AcpiOsReadPort ( ACPI_IO_ADDRESS Address, @@ -319,7 +339,6 @@ AcpiOsWritePort ( /* * Platform and hardware-independent physical memory interfaces */ - ACPI_STATUS AcpiOsReadMemory ( ACPI_PHYSICAL_ADDRESS Address, @@ -338,7 +357,6 @@ AcpiOsWriteMemory ( * Note: Can't use "Register" as a parameter, changed to "Reg" -- * certain compilers complain. */ - ACPI_STATUS AcpiOsReadPciConfiguration ( ACPI_PCI_ID *PciId, @@ -356,7 +374,6 @@ AcpiOsWritePciConfiguration ( /* * Interim function needed for PCI IRQ routing */ - void AcpiOsDerivePciId( ACPI_HANDLE Rhandle, @@ -366,7 +383,6 @@ AcpiOsDerivePciId( /* * Miscellaneous */ - BOOLEAN AcpiOsReadable ( void *Pointer, @@ -389,7 +405,6 @@ AcpiOsSignal ( /* * Debug print routines */ - void ACPI_INTERNAL_VAR_XFACE AcpiOsPrintf ( const char *Format, @@ -408,7 +423,6 @@ AcpiOsRedirectOutput ( /* * Debug input */ - UINT32 AcpiOsGetLine ( char *Buffer); @@ -417,7 +431,6 @@ AcpiOsGetLine ( /* * Directory manipulation */ - void * AcpiOsOpenDirectory ( char *Pathname, @@ -441,7 +454,6 @@ AcpiOsCloseDirectory ( /* * Debug */ - void AcpiOsDbgAssert( void *FailedAssertion, @@ -449,5 +461,4 @@ AcpiOsDbgAssert( UINT32 LineNumber, char *Message); - #endif /* __ACPIOSXF_H__ */ diff --git a/sys/contrib/dev/acpica/acpixf.h b/sys/contrib/dev/acpica/acpixf.h index a5cf76c..f895cc2 100644 --- a/sys/contrib/dev/acpica/acpixf.h +++ b/sys/contrib/dev/acpica/acpixf.h @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -122,10 +122,9 @@ #include <contrib/dev/acpica/actbl.h> - /* +/* * Global interfaces */ - ACPI_STATUS AcpiInitializeSubsystem ( void); @@ -172,9 +171,8 @@ AcpiInstallInitializationHandler ( UINT32 Function); /* - * ACPI Memory manager + * ACPI Memory managment */ - void * AcpiAllocate ( UINT32 Size); @@ -191,7 +189,6 @@ AcpiFree ( /* * ACPI table manipulation interfaces */ - ACPI_STATUS AcpiFindRootPointer ( UINT32 Flags, @@ -232,7 +229,6 @@ AcpiGetFirmwareTable ( /* * Namespace and name interfaces */ - ACPI_STATUS AcpiWalkNamespace ( ACPI_OBJECT_TYPE Type, @@ -278,11 +274,17 @@ AcpiGetData ( ACPI_OBJECT_HANDLER Handler, void **Data); +ACPI_STATUS +AcpiDebugTrace ( + char *Name, + UINT32 DebugLevel, + UINT32 DebugLayer, + UINT32 Flags); + /* * Object manipulation and enumeration */ - ACPI_STATUS AcpiEvaluateObject ( ACPI_HANDLE Object, @@ -324,7 +326,6 @@ AcpiGetParent ( /* * Event handler interfaces */ - ACPI_STATUS AcpiInstallFixedEventHandler ( UINT32 AcpiEvent, @@ -379,7 +380,6 @@ AcpiInstallExceptionHandler ( /* * Event interfaces */ - ACPI_STATUS AcpiAcquireGlobalLock ( UINT16 Timeout, @@ -450,7 +450,7 @@ AcpiInstallGpeBlock ( ACPI_HANDLE GpeDevice, ACPI_GENERIC_ADDRESS *GpeBlockAddress, UINT32 RegisterCount, - UINT32 InterruptLevel); + UINT32 InterruptNumber); ACPI_STATUS AcpiRemoveGpeBlock ( @@ -460,7 +460,6 @@ AcpiRemoveGpeBlock ( /* * Resource interfaces */ - typedef ACPI_STATUS (*ACPI_WALK_RESOURCE_CALLBACK) ( ACPI_RESOURCE *Resource, @@ -502,7 +501,6 @@ AcpiResourceToAddress64 ( /* * Hardware (ACPI device) interfaces */ - ACPI_STATUS AcpiGetRegister ( UINT32 RegisterId, diff --git a/sys/contrib/dev/acpica/acresrc.h b/sys/contrib/dev/acpica/acresrc.h index 369452b..f0f5a40 100644 --- a/sys/contrib/dev/acpica/acresrc.h +++ b/sys/contrib/dev/acpica/acresrc.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acresrc.h - Resource Manager function prototypes - * $Revision: 38 $ + * $Revision: 1.51 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -118,348 +118,356 @@ #ifndef __ACRESRC_H__ #define __ACRESRC_H__ +/* Need the AML resource descriptor structs */ -/* - * Function prototypes called from Acpi* APIs - */ - -ACPI_STATUS -AcpiRsGetPrtMethodData ( - ACPI_HANDLE Handle, - ACPI_BUFFER *RetBuffer); - - -ACPI_STATUS -AcpiRsGetCrsMethodData ( - ACPI_HANDLE Handle, - ACPI_BUFFER *RetBuffer); +#include <contrib/dev/acpica/amlresrc.h> -ACPI_STATUS -AcpiRsGetPrsMethodData ( - ACPI_HANDLE Handle, - ACPI_BUFFER *RetBuffer); -ACPI_STATUS -AcpiRsGetMethodData ( - ACPI_HANDLE Handle, - char *Path, - ACPI_BUFFER *RetBuffer); - -ACPI_STATUS -AcpiRsSetSrsMethodData ( - ACPI_HANDLE Handle, - ACPI_BUFFER *RetBuffer); - -ACPI_STATUS -AcpiRsCreateResourceList ( - ACPI_OPERAND_OBJECT *ByteStreamBuffer, - ACPI_BUFFER *OutputBuffer); - -ACPI_STATUS -AcpiRsCreateByteStream ( - ACPI_RESOURCE *LinkedListBuffer, - ACPI_BUFFER *OutputBuffer); +/* + * If possible, pack the following structures to byte alignment, since we + * don't care about performance for debug output + */ +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#pragma pack(1) +#endif -ACPI_STATUS -AcpiRsCreatePciRoutingTable ( - ACPI_OPERAND_OBJECT *PackageObject, - ACPI_BUFFER *OutputBuffer); +/* + * Individual entry for the resource conversion tables + */ +typedef const struct acpi_rsconvert_info +{ + UINT8 Opcode; + UINT8 ResourceOffset; + UINT8 AmlOffset; + UINT8 Value; + +} ACPI_RSCONVERT_INFO; + +/* Resource conversion opcodes */ + +#define ACPI_RSC_INITGET 0 +#define ACPI_RSC_INITSET 1 +#define ACPI_RSC_FLAGINIT 2 +#define ACPI_RSC_1BITFLAG 3 +#define ACPI_RSC_2BITFLAG 4 +#define ACPI_RSC_COUNT 5 +#define ACPI_RSC_COUNT16 6 +#define ACPI_RSC_LENGTH 7 +#define ACPI_RSC_MOVE8 8 +#define ACPI_RSC_MOVE16 9 +#define ACPI_RSC_MOVE32 10 +#define ACPI_RSC_MOVE64 11 +#define ACPI_RSC_SET8 12 +#define ACPI_RSC_DATA8 13 +#define ACPI_RSC_ADDRESS 14 +#define ACPI_RSC_SOURCE 15 +#define ACPI_RSC_SOURCEX 16 +#define ACPI_RSC_BITMASK 17 +#define ACPI_RSC_BITMASK16 18 +#define ACPI_RSC_EXIT_NE 19 +#define ACPI_RSC_EXIT_LE 20 + +/* Resource Conversion sub-opcodes */ + +#define ACPI_RSC_COMPARE_AML_LENGTH 0 +#define ACPI_RSC_COMPARE_VALUE 1 + +#define ACPI_RSC_TABLE_SIZE(d) (sizeof (d) / sizeof (ACPI_RSCONVERT_INFO)) + +#define ACPI_RS_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE,f) +#define AML_OFFSET(f) (UINT8) ACPI_OFFSET (AML_RESOURCE,f) /* - * Function prototypes called from AcpiRsCreate* + * Resource dispatch and info tables */ -void -AcpiRsDumpIrq ( - ACPI_RESOURCE_DATA *Data); +typedef const struct acpi_resource_info +{ + UINT8 LengthType; + UINT8 MinimumAmlResourceLength; + UINT8 MinimumInternalStructLength; -void -AcpiRsDumpAddress16 ( - ACPI_RESOURCE_DATA *Data); +} ACPI_RESOURCE_INFO; -void -AcpiRsDumpAddress32 ( - ACPI_RESOURCE_DATA *Data); +/* Types for LengthType above */ -void -AcpiRsDumpAddress64 ( - ACPI_RESOURCE_DATA *Data); +#define ACPI_FIXED_LENGTH 0 +#define ACPI_VARIABLE_LENGTH 1 +#define ACPI_SMALL_VARIABLE_LENGTH 2 -void -AcpiRsDumpDma ( - ACPI_RESOURCE_DATA *Data); +typedef const struct acpi_rsdump_info +{ + UINT8 Opcode; + UINT8 Offset; + char *Name; + const void *Pointer; -void -AcpiRsDumpIo ( - ACPI_RESOURCE_DATA *Data); +} ACPI_RSDUMP_INFO; -void -AcpiRsDumpExtendedIrq ( - ACPI_RESOURCE_DATA *Data); +/* Values for the Opcode field above */ -void -AcpiRsDumpFixedIo ( - ACPI_RESOURCE_DATA *Data); +#define ACPI_RSD_TITLE 0 +#define ACPI_RSD_LITERAL 1 +#define ACPI_RSD_STRING 2 +#define ACPI_RSD_UINT8 3 +#define ACPI_RSD_UINT16 4 +#define ACPI_RSD_UINT32 5 +#define ACPI_RSD_UINT64 6 +#define ACPI_RSD_1BITFLAG 7 +#define ACPI_RSD_2BITFLAG 8 +#define ACPI_RSD_SHORTLIST 9 +#define ACPI_RSD_LONGLIST 10 +#define ACPI_RSD_DWORDLIST 11 +#define ACPI_RSD_ADDRESS 12 +#define ACPI_RSD_SOURCE 13 -void -AcpiRsDumpFixedMemory32 ( - ACPI_RESOURCE_DATA *Data); +/* restore default alignment */ -void -AcpiRsDumpMemory24 ( - ACPI_RESOURCE_DATA *Data); +#pragma pack() -void -AcpiRsDumpMemory32 ( - ACPI_RESOURCE_DATA *Data); -void -AcpiRsDumpStartDependFns ( - ACPI_RESOURCE_DATA *Data); +/* Resource tables indexed by internal resource type */ -void -AcpiRsDumpVendorSpecific ( - ACPI_RESOURCE_DATA *Data); +extern const UINT8 AcpiGbl_AmlResourceSizes[]; +extern ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[]; -void -AcpiRsDumpResourceList ( - ACPI_RESOURCE *Resource); +/* Resource tables indexed by raw AML resource descriptor type */ -void -AcpiRsDumpIrqList ( - UINT8 *RouteTable); +extern ACPI_RESOURCE_INFO AcpiGbl_SmResourceInfo[]; +extern ACPI_RESOURCE_INFO AcpiGbl_LgResourceInfo[]; +extern ACPI_RSCONVERT_INFO *AcpiGbl_SmGetResourceDispatch[]; +extern ACPI_RSCONVERT_INFO *AcpiGbl_LgGetResourceDispatch[]; -ACPI_STATUS -AcpiRsGetByteStreamStart ( - UINT8 *ByteStreamBuffer, - UINT8 **ByteStreamStart, - UINT32 *Size); +/* + * rscreate + */ ACPI_STATUS -AcpiRsGetListLength ( - UINT8 *ByteStreamBuffer, - UINT32 ByteStreamBufferLength, - ACPI_SIZE *SizeNeeded); +AcpiRsCreateResourceList ( + ACPI_OPERAND_OBJECT *AmlBuffer, + ACPI_BUFFER *OutputBuffer); ACPI_STATUS -AcpiRsGetByteStreamLength ( +AcpiRsCreateAmlResources ( ACPI_RESOURCE *LinkedListBuffer, - ACPI_SIZE *SizeNeeded); + ACPI_BUFFER *OutputBuffer); ACPI_STATUS -AcpiRsGetPciRoutingTableLength ( +AcpiRsCreatePciRoutingTable ( ACPI_OPERAND_OBJECT *PackageObject, - ACPI_SIZE *BufferSizeNeeded); - -ACPI_STATUS -AcpiRsByteStreamToList ( - UINT8 *ByteStreamBuffer, - UINT32 ByteStreamBufferLength, - UINT8 *OutputBuffer); - -ACPI_STATUS -AcpiRsListToByteStream ( - ACPI_RESOURCE *LinkedList, - ACPI_SIZE ByteStreamSizeNeeded, - UINT8 *OutputBuffer); - -ACPI_STATUS -AcpiRsIoResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); + ACPI_BUFFER *OutputBuffer); -ACPI_STATUS -AcpiRsFixedIoResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); +/* + * rsutils + */ ACPI_STATUS -AcpiRsIoStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); +AcpiRsGetPrtMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer); ACPI_STATUS -AcpiRsFixedIoStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); +AcpiRsGetCrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer); ACPI_STATUS -AcpiRsIrqResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); +AcpiRsGetPrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer); ACPI_STATUS -AcpiRsIrqStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); +AcpiRsGetMethodData ( + ACPI_HANDLE Handle, + char *Path, + ACPI_BUFFER *RetBuffer); ACPI_STATUS -AcpiRsDmaResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); +AcpiRsSetSrsMethodData ( + ACPI_HANDLE Handle, + ACPI_BUFFER *RetBuffer); -ACPI_STATUS -AcpiRsDmaStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); +/* + * rscalc + */ ACPI_STATUS -AcpiRsAddress16Resource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); +AcpiRsGetListLength ( + UINT8 *AmlBuffer, + UINT32 AmlBufferLength, + ACPI_SIZE *SizeNeeded); ACPI_STATUS -AcpiRsAddress16Stream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); +AcpiRsGetAmlLength ( + ACPI_RESOURCE *LinkedListBuffer, + ACPI_SIZE *SizeNeeded); ACPI_STATUS -AcpiRsAddress32Resource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); +AcpiRsGetPciRoutingTableLength ( + ACPI_OPERAND_OBJECT *PackageObject, + ACPI_SIZE *BufferSizeNeeded); ACPI_STATUS -AcpiRsAddress32Stream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); +AcpiRsConvertAmlToResources ( + UINT8 *AmlBuffer, + UINT32 AmlBufferLength, + UINT8 *OutputBuffer); ACPI_STATUS -AcpiRsAddress64Resource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); +AcpiRsConvertResourcesToAml ( + ACPI_RESOURCE *Resource, + ACPI_SIZE AmlSizeNeeded, + UINT8 *OutputBuffer); -ACPI_STATUS -AcpiRsAddress64Stream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); -ACPI_STATUS -AcpiRsStartDependFnsResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); +/* + * rsaddr + */ +void +AcpiRsSetAddressCommon ( + AML_RESOURCE *Aml, + ACPI_RESOURCE *Resource); -ACPI_STATUS -AcpiRsEndDependFnsResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); +BOOLEAN +AcpiRsGetAddressCommon ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml); -ACPI_STATUS -AcpiRsStartDependFnsStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); +/* + * rsmisc + */ ACPI_STATUS -AcpiRsEndDependFnsStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); +AcpiRsConvertAmlToResource ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info); ACPI_STATUS -AcpiRsMemory24Resource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); +AcpiRsConvertResourceToAml ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info); -ACPI_STATUS -AcpiRsMemory24Stream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); -ACPI_STATUS -AcpiRsMemory32RangeResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); +/* + * rsutils + */ +void +AcpiRsMoveData ( + void *Destination, + void *Source, + UINT16 ItemCount, + UINT8 MoveType); -ACPI_STATUS -AcpiRsFixedMemory32Resource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); +UINT8 +AcpiRsDecodeBitmask ( + UINT16 Mask, + UINT8 *List); + +UINT16 +AcpiRsEncodeBitmask ( + UINT8 *List, + UINT8 Count); + +ACPI_RS_LENGTH +AcpiRsGetResourceSource ( + ACPI_RS_LENGTH ResourceLength, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource, + AML_RESOURCE *Aml, + char *StringPtr); + +ACPI_RSDESC_SIZE +AcpiRsSetResourceSource ( + AML_RESOURCE *Aml, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource); -ACPI_STATUS -AcpiRsMemory32RangeStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); +void +AcpiRsSetResourceHeader ( + UINT8 DescriptorType, + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml); -ACPI_STATUS -AcpiRsFixedMemory32Stream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); +void +AcpiRsSetResourceLength ( + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml); -ACPI_STATUS -AcpiRsExtendedIrqResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); +ACPI_RESOURCE_INFO * +AcpiRsGetResourceInfo ( + UINT8 ResourceType); -ACPI_STATUS -AcpiRsExtendedIrqStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); -ACPI_STATUS -AcpiRsEndTagResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); +/* + * rsdump + */ +void +AcpiRsDumpResourceList ( + ACPI_RESOURCE *Resource); -ACPI_STATUS -AcpiRsEndTagStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); +void +AcpiRsDumpIrqList ( + UINT8 *RouteTable); -ACPI_STATUS -AcpiRsVendorResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize); -ACPI_STATUS -AcpiRsVendorStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed); +/* + * Resource conversion tables + */ +extern ACPI_RSCONVERT_INFO AcpiRsConvertDma[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertIo[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[]; + +/* These resources require separate get/set tables */ + +extern ACPI_RSCONVERT_INFO AcpiRsGetIrq[]; +extern ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[]; +extern ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[]; +extern ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[]; + +extern ACPI_RSCONVERT_INFO AcpiRsSetIrq[]; +extern ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[]; +extern ACPI_RSCONVERT_INFO AcpiRsSetVendor[]; + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +/* + * rsinfo + */ +extern ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[]; -UINT8 -AcpiRsGetResourceType ( - UINT8 ResourceStartByte); +/* + * rsdump + */ +extern ACPI_RSDUMP_INFO AcpiRsDumpIrq[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpDma[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpIo[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpVendor[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpEndTag[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpMemory24[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpMemory32[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpAddress16[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpAddress32[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpAddress64[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[]; +#endif #endif /* __ACRESRC_H__ */ diff --git a/sys/contrib/dev/acpica/acstruct.h b/sys/contrib/dev/acpica/acstruct.h index 1852650..b45e9f4 100644 --- a/sys/contrib/dev/acpica/acstruct.h +++ b/sys/contrib/dev/acpica/acstruct.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: acstruct.h - Internal structs - * $Revision: 28 $ + * $Revision: 1.37 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -129,7 +129,6 @@ * Walk state - current state of a parse tree walk. Used for both a leisurely stroll through * the tree (for whatever reason), and for control method execution. */ - #define ACPI_NEXT_OP_DOWNWARD 1 #define ACPI_NEXT_OP_UPWARD 2 @@ -145,14 +144,13 @@ typedef struct acpi_walk_state UINT8 WalkType; ACPI_OWNER_ID OwnerId; /* Owner of objects created during the walk */ BOOLEAN LastPredicate; /* Result of last predicate */ - UINT8 Reserved; /* For alignment */ UINT8 CurrentResult; /* */ UINT8 NextOpInfo; /* Info about NextOp */ UINT8 NumOperands; /* Stack pointer for Operands[] array */ UINT8 ReturnUsed; UINT16 Opcode; /* Current AML opcode */ UINT8 ScopeDepth; - UINT8 Reserved1; + UINT8 PassNumber; /* Parse pass during table load */ UINT32 ArgCount; /* push for fixed or var args */ UINT32 AmlOffset; UINT32 ArgTypes; @@ -167,6 +165,7 @@ typedef struct acpi_walk_state ACPI_GENERIC_STATE *ControlState; /* List of control states (nested IFs) */ struct acpi_namespace_node *DeferredNode; /* Used when executing deferred opcodes */ struct acpi_gpe_event_info *GpeEventInfo; /* Info for GPE (_Lxx/_Exx methods only */ + union acpi_operand_object *ImplicitReturnObj; struct acpi_namespace_node LocalVariables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */ struct acpi_namespace_node *MethodCallNode; /* Called method Node*/ ACPI_PARSE_OBJECT *MethodCallOp; /* MethodCall Op if running a method */ @@ -230,15 +229,19 @@ typedef struct acpi_device_walk_info typedef struct acpi_walk_info { UINT32 DebugLevel; - UINT32 OwnerId; + UINT32 Count; + ACPI_OWNER_ID OwnerId; UINT8 DisplayType; } ACPI_WALK_INFO; /* Display Types */ -#define ACPI_DISPLAY_SUMMARY 0 -#define ACPI_DISPLAY_OBJECTS 1 +#define ACPI_DISPLAY_SUMMARY (UINT8) 0 +#define ACPI_DISPLAY_OBJECTS (UINT8) 1 +#define ACPI_DISPLAY_MASK (UINT8) 1 + +#define ACPI_DISPLAY_SHORT (UINT8) 2 typedef struct acpi_get_devices_info { @@ -286,8 +289,10 @@ typedef union acpi_aml_operands typedef struct acpi_parameter_info { ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT **Parameters; ACPI_OPERAND_OBJECT *ReturnObject; + UINT8 PassNumber; UINT8 ParameterType; UINT8 ReturnObjectType; diff --git a/sys/contrib/dev/acpica/actables.h b/sys/contrib/dev/acpica/actables.h index c7acca0..f3163d9 100644 --- a/sys/contrib/dev/acpica/actables.h +++ b/sys/contrib/dev/acpica/actables.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actables.h - ACPI table management - * $Revision: 46 $ + * $Revision: 1.53 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,15 +123,9 @@ #define SIZE_IN_HEADER 0 -ACPI_STATUS -AcpiTbHandleToObject ( - UINT16 TableId, - ACPI_TABLE_DESC **TableDesc); - /* * tbconvrt - Table conversion routines */ - ACPI_STATUS AcpiTbConvertToXsdt ( ACPI_TABLE_DESC *TableInfo); @@ -149,10 +143,10 @@ AcpiTbGetTableCount ( RSDP_DESCRIPTOR *RSDP, ACPI_TABLE_HEADER *RSDT); + /* * tbget - Table "get" routines */ - ACPI_STATUS AcpiTbGetTable ( ACPI_POINTER *Address, @@ -170,17 +164,6 @@ AcpiTbGetTableBody ( ACPI_TABLE_DESC *TableInfo); ACPI_STATUS -AcpiTbGetThisTable ( - ACPI_POINTER *Address, - ACPI_TABLE_HEADER *Header, - ACPI_TABLE_DESC *TableInfo); - -ACPI_STATUS -AcpiTbTableOverride ( - ACPI_TABLE_HEADER *Header, - ACPI_TABLE_DESC *TableInfo); - -ACPI_STATUS AcpiTbGetTablePtr ( ACPI_TABLE_TYPE TableType, UINT32 Instance, @@ -198,36 +181,23 @@ ACPI_STATUS AcpiTbValidateRsdt ( ACPI_TABLE_HEADER *TablePtr); + +/* + * tbgetall - get multiple required tables + */ ACPI_STATUS AcpiTbGetRequiredTables ( void); -ACPI_STATUS -AcpiTbGetPrimaryTable ( - ACPI_POINTER *Address, - ACPI_TABLE_DESC *TableInfo); - -ACPI_STATUS -AcpiTbGetSecondaryTable ( - ACPI_POINTER *Address, - ACPI_STRING Signature, - ACPI_TABLE_DESC *TableInfo); /* * tbinstall - Table installation */ - ACPI_STATUS AcpiTbInstallTable ( ACPI_TABLE_DESC *TableInfo); ACPI_STATUS -AcpiTbMatchSignature ( - char *Signature, - ACPI_TABLE_DESC *TableInfo, - UINT8 SearchType); - -ACPI_STATUS AcpiTbRecognizeTable ( ACPI_TABLE_DESC *TableInfo, UINT8 SearchType); @@ -241,7 +211,6 @@ AcpiTbInitTableDescriptor ( /* * tbremove - Table removal and deletion */ - void AcpiTbDeleteAllTables ( void); @@ -260,41 +229,37 @@ AcpiTbUninstallTable ( /* - * tbrsd - RSDP, RSDT utilities + * tbxfroot - RSDP, RSDT utilities */ +ACPI_STATUS +AcpiTbFindTable ( + char *Signature, + char *OemId, + char *OemTableId, + ACPI_TABLE_HEADER **TablePtr); ACPI_STATUS AcpiTbGetTableRsdt ( void); -UINT8 * -AcpiTbScanMemoryForRsdp ( - UINT8 *StartAddress, - UINT32 Length); - ACPI_STATUS -AcpiTbFindRsdp ( - ACPI_TABLE_DESC *TableInfo, - UINT32 Flags); +AcpiTbValidateRsdp ( + RSDP_DESCRIPTOR *Rsdp); /* * tbutils - common table utilities */ - ACPI_STATUS -AcpiTbFindTable ( - char *Signature, - char *OemId, - char *OemTableId, - ACPI_TABLE_HEADER **TablePtr); +AcpiTbIsTableInstalled ( + ACPI_TABLE_DESC *NewTableDesc); ACPI_STATUS AcpiTbVerifyTableChecksum ( ACPI_TABLE_HEADER *TableHeader); UINT8 -AcpiTbChecksum ( +AcpiTbGenerateChecksum ( void *Buffer, UINT32 Length); @@ -302,5 +267,4 @@ ACPI_STATUS AcpiTbValidateTableHeader ( ACPI_TABLE_HEADER *TableHeader); - #endif /* __ACTABLES_H__ */ diff --git a/sys/contrib/dev/acpica/actbl.h b/sys/contrib/dev/acpica/actbl.h index 9606f9b..1c8b9a6 100644 --- a/sys/contrib/dev/acpica/actbl.h +++ b/sys/contrib/dev/acpica/actbl.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actbl.h - Table data structures defined in ACPI specification - * $Revision: 66 $ + * $Revision: 1.72 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -159,15 +159,15 @@ */ typedef struct rsdp_descriptor /* Root System Descriptor Pointer */ { - char Signature [8]; /* ACPI signature, contains "RSD PTR " */ - UINT8 Checksum; /* To make sum of struct == 0 */ - char OemId [6]; /* OEM identification */ - UINT8 Revision; /* Must be 0 for 1.0, 2 for 2.0 */ - UINT32 RsdtPhysicalAddress; /* 32-bit physical address of RSDT */ - UINT32 Length; /* XSDT Length in bytes including hdr */ - UINT64 XsdtPhysicalAddress; /* 64-bit physical address of XSDT */ - UINT8 ExtendedChecksum; /* Checksum of entire table */ - char Reserved [3]; /* Reserved field must be 0 */ + char Signature[8]; /* ACPI signature, contains "RSD PTR " */ + UINT8 Checksum; /* ACPI 1.0 checksum */ + char OemId[6]; /* OEM identification */ + UINT8 Revision; /* Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+ */ + UINT32 RsdtPhysicalAddress; /* 32-bit physical address of the RSDT */ + UINT32 Length; /* XSDT Length in bytes, including header */ + UINT64 XsdtPhysicalAddress; /* 64-bit physical address of the XSDT */ + UINT8 ExtendedChecksum; /* Checksum of entire table (ACPI 2.0) */ + char Reserved[3]; /* Reserved, must be zero */ } RSDP_DESCRIPTOR; @@ -182,15 +182,15 @@ typedef struct acpi_common_facs /* Common FACS for internal use */ #define ACPI_TABLE_HEADER_DEF /* ACPI common table header */ \ - char Signature [4]; /* ACPI signature (4 ASCII characters) */\ - UINT32 Length; /* Length of table, in bytes, including header */\ + char Signature[4]; /* ASCII table signature */\ + UINT32 Length; /* Length of table in bytes, including this header */\ UINT8 Revision; /* ACPI Specification minor version # */\ UINT8 Checksum; /* To make sum of entire table == 0 */\ - char OemId [6]; /* OEM identification */\ - char OemTableId [8]; /* OEM table identification */\ + char OemId[6]; /* ASCII OEM identification */\ + char OemTableId[8]; /* ASCII OEM table identification */\ UINT32 OemRevision; /* OEM revision number */\ - char AslCompilerId [4]; /* ASL compiler vendor ID */\ - UINT32 AslCompilerRevision; /* ASL compiler revision number */ + char AslCompilerId [4]; /* ASCII ASL compiler vendor ID */\ + UINT32 AslCompilerRevision; /* ASL compiler version */ typedef struct acpi_table_header /* ACPI common table header */ @@ -209,18 +209,20 @@ typedef struct acpi_table_header /* ACPI common table header */ #define DUAL_PIC 0 #define MULTIPLE_APIC 1 - /* Master MADT */ typedef struct multiple_apic_table { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ UINT32 LocalApicAddress; /* Physical address of local APIC */ - UINT32_BIT PCATCompat : 1; /* A one indicates system also has dual 8259s */ - UINT32_BIT Reserved1 : 31; -} MULTIPLE_APIC_TABLE; + /* Flags (32 bits) */ + UINT8_BIT PCATCompat : 1; /* 00: System also has dual 8259s */ + UINT8_BIT : 7; /* 01-07: Reserved, must be zero */ + UINT8 Reserved1[3]; /* 08-31: Reserved, must be zero */ + +} MULTIPLE_APIC_TABLE; /* Values for Type in APIC_HEADER_DEF */ @@ -260,16 +262,18 @@ typedef struct apic_header #define TRIGGER_RESERVED 2 #define TRIGGER_LEVEL 3 -/* Common flag definitions */ +/* Common flag definitions (16 bits each) */ #define MPS_INTI_FLAGS \ - UINT16_BIT Polarity : 2; /* Polarity of APIC I/O input signals */\ - UINT16_BIT TriggerMode : 2; /* Trigger mode of APIC input signals */\ - UINT16_BIT Reserved1 : 12; /* Reserved, must be zero */ + UINT8_BIT Polarity : 2; /* 00-01: Polarity of APIC I/O input signals */\ + UINT8_BIT TriggerMode : 2; /* 02-03: Trigger mode of APIC input signals */\ + UINT8_BIT : 4; /* 04-07: Reserved, must be zero */\ + UINT8 Reserved1; /* 08-15: Reserved, must be zero */ #define LOCAL_APIC_FLAGS \ - UINT32_BIT ProcessorEnabled: 1; /* Processor is usable if set */\ - UINT32_BIT Reserved2 : 31; /* Reserved, must be zero */ + UINT8_BIT ProcessorEnabled: 1; /* 00: Processor is usable if set */\ + UINT8_BIT : 7; /* 01-07: Reserved, must be zero */\ + UINT8 Reserved2; /* 08-15: Reserved, must be zero */ /* Sub-structures for MADT */ @@ -322,7 +326,7 @@ typedef struct madt_local_apic_nmi typedef struct madt_address_override { APIC_HEADER_DEF - UINT16 Reserved; /* Reserved - must be zero */ + UINT16 Reserved; /* Reserved, must be zero */ UINT64 Address; /* APIC physical address */ } MADT_ADDRESS_OVERRIDE; @@ -331,7 +335,7 @@ typedef struct madt_io_sapic { APIC_HEADER_DEF UINT8 IoSapicId; /* I/O SAPIC ID */ - UINT8 Reserved; /* Reserved - must be zero */ + UINT8 Reserved; /* Reserved, must be zero */ UINT32 InterruptBase; /* Glocal interrupt for SAPIC start */ UINT64 Address; /* SAPIC physical address */ @@ -343,8 +347,10 @@ typedef struct madt_local_sapic UINT8 ProcessorId; /* ACPI processor id */ UINT8 LocalSapicId; /* SAPIC ID */ UINT8 LocalSapicEid; /* SAPIC EID */ - UINT8 Reserved [3]; /* Reserved - must be zero */ + UINT8 Reserved[3]; /* Reserved, must be zero */ LOCAL_APIC_FLAGS + UINT32 ProcessorUID; /* Numeric UID - ACPI 3.0 */ + char ProcessorUIDString[1]; /* String UID - ACPI 3.0 */ } MADT_LOCAL_SAPIC; @@ -357,7 +363,7 @@ typedef struct madt_interrupt_source UINT8 ProcessorEid; /* Processor EID */ UINT8 IoSapicVector; /* Vector value for PMI interrupts */ UINT32 Interrupt; /* Global system interrupt */ - UINT32 Reserved; /* Reserved - must be zero */ + UINT32 Flags; /* Interrupt Source Flags */ } MADT_INTERRUPT_SOURCE; diff --git a/sys/contrib/dev/acpica/actbl1.h b/sys/contrib/dev/acpica/actbl1.h index bbb3170..51ea92a 100644 --- a/sys/contrib/dev/acpica/actbl1.h +++ b/sys/contrib/dev/acpica/actbl1.h @@ -1,7 +1,7 @@ /****************************************************************************** * * Name: actbl1.h - ACPI 1.0 tables - * $Revision: 28 $ + * $Revision: 1.32 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,8 +125,8 @@ typedef struct rsdt_descriptor_rev1 { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - UINT32 TableOffsetEntry [1]; /* Array of pointers to other */ - /* ACPI tables */ + UINT32 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ + } RSDT_DESCRIPTOR_REV1; @@ -135,14 +135,19 @@ typedef struct rsdt_descriptor_rev1 */ typedef struct facs_descriptor_rev1 { - char Signature[4]; /* ACPI Signature */ - UINT32 Length; /* Length of structure, in bytes */ + char Signature[4]; /* ASCII table signature */ + UINT32 Length; /* Length of structure in bytes */ UINT32 HardwareSignature; /* Hardware configuration signature */ UINT32 FirmwareWakingVector; /* ACPI OS waking vector */ UINT32 GlobalLock; /* Global Lock */ - UINT32_BIT S4Bios_f : 1; /* Indicates if S4BIOS support is present */ - UINT32_BIT Reserved1 : 31; /* Must be 0 */ - UINT8 Resverved3 [40]; /* Reserved - must be zero */ + + /* Flags (32 bits) */ + + UINT8_BIT S4Bios_f : 1; /* 00: S4BIOS support is present */ + UINT8_BIT : 7; /* 01-07: Reserved, must be zero */ + UINT8 Reserved1[3]; /* 08-31: Reserved, must be zero */ + + UINT8 Reserved2[40]; /* Reserved, must be zero */ } FACS_DESCRIPTOR_REV1; @@ -156,13 +161,13 @@ typedef struct fadt_descriptor_rev1 UINT32 FirmwareCtrl; /* Physical address of FACS */ UINT32 Dsdt; /* Physical address of DSDT */ UINT8 Model; /* System Interrupt Model */ - UINT8 Reserved1; /* Reserved */ + UINT8 Reserved1; /* Reserved, must be zero */ 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 Reserved2; /* Reserved - must be zero */ + UINT8 Reserved2; /* Reserved, must be zero */ UINT32 Pm1aEvtBlk; /* Port address of Power Mgt 1a AcpiEvent Reg Blk */ UINT32 Pm1bEvtBlk; /* Port address of Power Mgt 1b AcpiEvent Reg Blk */ UINT32 Pm1aCntBlk; /* Port address of Power Mgt 1a Control Reg Blk */ @@ -178,7 +183,7 @@ typedef struct fadt_descriptor_rev1 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 Reserved3; /* Reserved */ + UINT8 Reserved3; /* Reserved, must be zero */ UINT16 Plvl2Lat; /* Worst case HW latency to enter/exit C2 state */ UINT16 Plvl3Lat; /* Worst case HW latency to enter/exit C3 state */ UINT16 FlushSize; /* Size of area read to flush caches */ @@ -188,19 +193,21 @@ typedef struct fadt_descriptor_rev1 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 */ - UINT8 Reserved4; /* Reserved */ - UINT8 Reserved4a; /* Reserved */ - UINT8 Reserved4b; /* Reserved */ - UINT32_BIT WbInvd : 1; /* The wbinvd instruction works properly */ - UINT32_BIT WbInvdFlush : 1; /* The wbinvd flushes but does not invalidate */ - UINT32_BIT ProcC1 : 1; /* All processors support C1 state */ - UINT32_BIT Plvl2Up : 1; /* C2 state works on MP system */ - UINT32_BIT PwrButton : 1; /* Power button is handled as a generic feature */ - UINT32_BIT SleepButton : 1; /* Sleep button is handled as a generic feature, or not present */ - UINT32_BIT FixedRTC : 1; /* RTC wakeup stat not in fixed register space */ - UINT32_BIT Rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ - UINT32_BIT TmrValExt : 1; /* The tmr_val width is 32 bits (0 = 24 bits) */ - UINT32_BIT Reserved5 : 23; /* Reserved - must be zero */ + UINT8 Reserved4[3]; /* Reserved, must be zero */ + + /* Flags (32 bits) */ + + UINT8_BIT WbInvd : 1; /* 00: The wbinvd instruction works properly */ + UINT8_BIT WbInvdFlush : 1; /* 01: The wbinvd flushes but does not invalidate */ + UINT8_BIT ProcC1 : 1; /* 02: All processors support C1 state */ + UINT8_BIT Plvl2Up : 1; /* 03: C2 state works on MP system */ + UINT8_BIT PwrButton : 1; /* 04: Power button is handled as a generic feature */ + UINT8_BIT SleepButton : 1; /* 05: Sleep button is handled as a generic feature, or not present */ + UINT8_BIT FixedRTC : 1; /* 06: RTC wakeup stat not in fixed register space */ + UINT8_BIT Rtcs4 : 1; /* 07: RTC wakeup stat not possible from S4 */ + UINT8_BIT TmrValExt : 1; /* 08: tmr_val width is 32 bits (0 = 24 bits) */ + UINT8_BIT : 7; /* 09-15: Reserved, must be zero */ + UINT8 Reserved5[2]; /* 16-31: Reserved, must be zero */ } FADT_DESCRIPTOR_REV1; diff --git a/sys/contrib/dev/acpica/actbl2.h b/sys/contrib/dev/acpica/actbl2.h index 1e5b62a..4b65d26 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: 37 $ + * $Revision: 1.45 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -146,8 +146,8 @@ typedef struct rsdt_descriptor_rev2 { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - UINT32 TableOffsetEntry [1]; /* Array of pointers to */ - /* ACPI table headers */ + UINT32 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ + } RSDT_DESCRIPTOR_REV2; @@ -157,8 +157,8 @@ typedef struct rsdt_descriptor_rev2 typedef struct xsdt_descriptor_rev2 { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ - UINT64 TableOffsetEntry [1]; /* Array of pointers to */ - /* ACPI table headers */ + UINT64 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ + } XSDT_DESCRIPTOR_REV2; @@ -167,29 +167,34 @@ typedef struct xsdt_descriptor_rev2 */ typedef struct facs_descriptor_rev2 { - char Signature[4]; /* ACPI signature */ + char Signature[4]; /* ASCII table signature */ UINT32 Length; /* Length of structure, in bytes */ UINT32 HardwareSignature; /* Hardware configuration signature */ - UINT32 FirmwareWakingVector; /* 32bit physical address of the Firmware Waking Vector. */ + UINT32 FirmwareWakingVector; /* 32-bit physical address of the Firmware Waking Vector. */ UINT32 GlobalLock; /* Global Lock used to synchronize access to shared hardware resources */ - UINT32_BIT S4Bios_f : 1; /* S4Bios_f - Indicates if S4BIOS support is present */ - UINT32_BIT Reserved1 : 31; /* Must be 0 */ - UINT64 XFirmwareWakingVector; /* 64bit physical address of the Firmware Waking Vector. */ + + /* Flags (32 bits) */ + + UINT8_BIT S4Bios_f : 1; /* 00: S4BIOS support is present */ + UINT8_BIT : 7; /* 01-07: Reserved, must be zero */ + UINT8 Reserved1[3]; /* 08-31: Reserved, must be zero */ + + UINT64 XFirmwareWakingVector; /* 64-bit physical address of the Firmware Waking Vector. */ UINT8 Version; /* Version of this table */ - UINT8 Reserved3 [31]; /* Reserved - must be zero */ + UINT8 Reserved3[31]; /* Reserved, must be zero */ } FACS_DESCRIPTOR_REV2; /* - * ACPI 2.0 Generic Address Structure (GAS) + * ACPI 2.0+ Generic Address Structure (GAS) */ typedef struct acpi_generic_address { UINT8 AddressSpaceId; /* Address space where struct or register exists. */ UINT8 RegisterBitWidth; /* Size in bits of given register */ UINT8 RegisterBitOffset; /* Bit offset within the register */ - UINT8 Reserved; /* Must be 0 */ + UINT8 AccessWidth; /* Minimum Access size (ACPI 3.0) */ UINT64 Address; /* 64-bit address of struct or register */ } ACPI_GENERIC_ADDRESS; @@ -234,33 +239,43 @@ typedef struct acpi_generic_address UINT16 IapcBootArch; /* IA-PC Boot Architecture Flags. See Table 5-10 for description*/ /* - * ACPI 2.0 Fixed ACPI Description Table (FADT) + * ACPI 2.0+ Fixed ACPI Description Table (FADT) */ typedef struct fadt_descriptor_rev2 { ACPI_TABLE_HEADER_DEF /* ACPI common table header */ 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 */ - UINT32_BIT ProcC1 : 1; /* All processors support C1 state */ - UINT32_BIT Plvl2Up : 1; /* C2 state works on MP system */ - UINT32_BIT PwrButton : 1; /* Power button is handled as a generic feature */ - UINT32_BIT SleepButton : 1; /* Sleep button is handled as a generic feature, or not present */ - UINT32_BIT FixedRTC : 1; /* RTC wakeup stat not in fixed register space */ - UINT32_BIT Rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ - UINT32_BIT TmrValExt : 1; /* Indicates tmr_val is 32 bits 0=24-bits*/ - UINT32_BIT DockCap : 1; /* Supports Docking */ - UINT32_BIT ResetRegSup : 1; /* Indicates system supports system reset via the FADT RESET_REG*/ - UINT32_BIT SealedCase : 1; /* Indicates system has no internal expansion capabilities and case is sealed. */ - UINT32_BIT Headless : 1; /* Indicates system does not have local video capabilities or local input devices.*/ - UINT32_BIT CpuSwSleep : 1; /* Indicates to OSPM that a processor native instruction */ - /* Must be executed after writing the SLP_TYPx register. */ - UINT32_BIT Reserved6 : 18; /* Reserved - must be zero */ + UINT8 Reserved2; /* Reserved, must be zero */ + + /* Flags (32 bits) */ + + UINT8_BIT WbInvd : 1; /* 00: The wbinvd instruction works properly */ + UINT8_BIT WbInvdFlush : 1; /* 01: The wbinvd flushes but does not invalidate */ + UINT8_BIT ProcC1 : 1; /* 02: All processors support C1 state */ + UINT8_BIT Plvl2Up : 1; /* 03: C2 state works on MP system */ + UINT8_BIT PwrButton : 1; /* 04: Power button is handled as a generic feature */ + UINT8_BIT SleepButton : 1; /* 05: Sleep button is handled as a generic feature, or not present */ + UINT8_BIT FixedRTC : 1; /* 06: RTC wakeup stat not in fixed register space */ + UINT8_BIT Rtcs4 : 1; /* 07: RTC wakeup stat not possible from S4 */ + UINT8_BIT TmrValExt : 1; /* 08: tmr_val is 32 bits 0=24-bits */ + UINT8_BIT DockCap : 1; /* 09: Docking supported */ + UINT8_BIT ResetRegSup : 1; /* 10: System reset via the FADT RESET_REG supported */ + UINT8_BIT SealedCase : 1; /* 11: No internal expansion capabilities and case is sealed */ + UINT8_BIT Headless : 1; /* 12: No local video capabilities or local input devices */ + UINT8_BIT CpuSwSleep : 1; /* 13: Must execute native instruction after writing SLP_TYPx register */ + + UINT8_BIT PciExpWak : 1; /* 14: System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */ + UINT8_BIT UsePlatformClock : 1; /* 15: OSPM should use platform-provided timer (ACPI 3.0) */ + UINT8_BIT S4RtcStsValid : 1; /* 16: Contents of RTC_STS valid after S4 wake (ACPI 3.0) */ + UINT8_BIT RemotePowerOnCapable : 1; /* 17: System is compatible with remote power on (ACPI 3.0) */ + UINT8_BIT ForceApicClusterModel : 1; /* 18: All local APICs must use cluster model (ACPI 3.0) */ + UINT8_BIT ForceApicPhysicalDestinationMode : 1; /* 19: All local xAPICs must use physical dest mode (ACPI 3.0) */ + UINT8_BIT : 4; /* 20-23: Reserved, must be zero */ + UINT8 Reserved3; /* 24-31: Reserved, must be zero */ 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 */ + UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system */ + UINT8 Reserved4[3]; /* These three bytes must be zero */ UINT64 XFirmwareCtrl; /* 64-bit physical address of FACS */ UINT64 XDsdt; /* 64-bit physical address of DSDT */ ACPI_GENERIC_ADDRESS XPm1aEvtBlk; /* Extended Power Mgt 1a AcpiEvent Reg Blk address */ @@ -275,23 +290,22 @@ typedef struct fadt_descriptor_rev2 } FADT_DESCRIPTOR_REV2; -/* "Downrevved" ACPI 2.0 FADT descriptor */ +/* "Down-revved" 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 */ + UINT8 Reserved2; /* Reserved, must be zero */ 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 */ + UINT8 Reserved7[3]; /* Reserved, must be zero */ } FADT_DESCRIPTOR_REV2_MINUS; - -/* Embedded Controller */ +/* ECDT - Embedded Controller Boot Resources Table */ typedef struct ec_boot_resources { @@ -305,6 +319,69 @@ typedef struct ec_boot_resources } EC_BOOT_RESOURCES; +/* SRAT - System Resource Affinity Table */ + +typedef struct static_resource_alloc +{ + UINT8 Type; + UINT8 Length; + UINT8 ProximityDomainLo; + UINT8 ApicId; + + /* Flags (32 bits) */ + + UINT8_BIT Enabled :1; /* 00: Use affinity structure */ + UINT8_BIT :7; /* 01-07: Reserved, must be zero */ + UINT8 Reserved3[3]; /* 08-31: Reserved, must be zero */ + + UINT8 LocalSapicEid; + UINT8 ProximityDomainHi[3]; + UINT32 Reserved4; /* Reserved, must be zero */ + +} STATIC_RESOURCE_ALLOC; + +typedef struct memory_affinity +{ + UINT8 Type; + UINT8 Length; + UINT32 ProximityDomain; + UINT16 Reserved3; + UINT64 BaseAddress; + UINT64 AddressLength; + UINT32 Reserved4; + + /* Flags (32 bits) */ + + UINT8_BIT Enabled :1; /* 00: Use affinity structure */ + UINT8_BIT HotPluggable :1; /* 01: Memory region is hot pluggable */ + UINT8_BIT NonVolatile :1; /* 02: Memory is non-volatile */ + UINT8_BIT :5; /* 03-07: Reserved, must be zero */ + UINT8 Reserved5[3]; /* 08-31: Reserved, must be zero */ + + UINT64 Reserved6; /* Reserved, must be zero */ + +} MEMORY_AFFINITY; + +typedef struct system_resource_affinity +{ + ACPI_TABLE_HEADER_DEF + UINT32 Reserved1; /* Must be value '1' */ + UINT64 Reserved2; /* Reserved, must be zero */ + +} SYSTEM_RESOURCE_AFFINITY; + + +/* SLIT - System Locality Distance Information Table */ + +typedef struct system_locality_info +{ + ACPI_TABLE_HEADER_DEF + UINT64 LocalityCount; + UINT8 Entry[1][1]; + +} SYSTEM_LOCALITY_INFO; + + #pragma pack() #endif /* __ACTBL2_H__ */ diff --git a/sys/contrib/dev/acpica/actypes.h b/sys/contrib/dev/acpica/actypes.h index 8890790..067a02a 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: 274 $ + * $Revision: 1.288 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -198,10 +198,22 @@ typedef UINT64 ACPI_SIZE; #define ACPI_MAX_PTR ACPI_UINT64_MAX #define ACPI_SIZE_MAX ACPI_UINT64_MAX +/* + * In the case of the Itanium Processor Family (IPF), the hardware does not + * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag + * to indicate that special precautions must be taken to avoid alignment faults. + * (IA64 or ia64 is currently used by existing compilers to indicate IPF.) + * + * Note: EM64T and other X86-64 processors do support misaligned transfers, + * so there is no need to define this flag. + */ +#if defined (__IA64__) || defined (__ia64__) +#define ACPI_MISALIGNMENT_NOT_SUPPORTED +#endif #elif ACPI_MACHINE_WIDTH == 16 -/*! [Begin] no source code translation (keep the typedefs) */ +/*! [Begin] no source code translation (keep the typedefs as-is) */ /* * 16-bit type definitions @@ -231,7 +243,6 @@ typedef char *ACPI_PHYSICAL_ADDRESS; typedef UINT16 ACPI_SIZE; #define ALIGNED_ADDRESS_BOUNDARY 0x00000002 -#define ACPI_MISALIGNED_TRANSFERS #define ACPI_USE_NATIVE_DIVIDE /* No 64-bit integers, ok to use native divide */ #define ACPI_MAX_PTR ACPI_UINT16_MAX #define ACPI_SIZE_MAX ACPI_UINT16_MAX @@ -269,7 +280,6 @@ typedef UINT64 ACPI_PHYSICAL_ADDRESS; typedef UINT32 ACPI_SIZE; #define ALIGNED_ADDRESS_BOUNDARY 0x00000004 -#define ACPI_MISALIGNED_TRANSFERS #define ACPI_MAX_PTR ACPI_UINT32_MAX #define ACPI_SIZE_MAX ACPI_UINT32_MAX @@ -279,10 +289,11 @@ typedef UINT32 ACPI_SIZE; /* - * Miscellaneous common types + * This type is used for bitfields in ACPI tables. The only type that is + * even remotely portable is UINT8. Anything else is not portable, so + * do not add any more bitfield types. */ -typedef UINT16 UINT16_BIT; -typedef UINT32 UINT32_BIT; +typedef UINT8 UINT8_BIT; typedef ACPI_NATIVE_UINT ACPI_PTRDIFF; /* @@ -319,6 +330,14 @@ typedef struct acpi_pointer #define ACPI_LOGMODE_PHYSPTR ACPI_LOGICAL_ADDRESSING | ACPI_PHYSICAL_POINTER #define ACPI_LOGMODE_LOGPTR ACPI_LOGICAL_ADDRESSING | ACPI_LOGICAL_POINTER +/* + * If ACPI_CACHE_T was not defined in the OS-dependent header, + * define it now. This is typically the case where the local cache + * manager implementation is to be used (ACPI_USE_LOCAL_CACHE) + */ +#ifndef ACPI_CACHE_T +#define ACPI_CACHE_T ACPI_MEMORY_LIST +#endif /* * Useful defines @@ -557,7 +576,6 @@ typedef UINT32 ACPI_OBJECT_TYPE; #define ACPI_TYPE_INVALID 0x1E #define ACPI_TYPE_NOT_FOUND 0xFF - /* * Bitmapped ACPI types. Used internally only */ @@ -732,24 +750,26 @@ typedef UINT8 ACPI_ADR_SPACE_TYPE; #define ACPI_BITREG_SLEEP_BUTTON_STATUS 0x04 #define ACPI_BITREG_RT_CLOCK_STATUS 0x05 #define ACPI_BITREG_WAKE_STATUS 0x06 - -#define ACPI_BITREG_TIMER_ENABLE 0x07 -#define ACPI_BITREG_GLOBAL_LOCK_ENABLE 0x08 -#define ACPI_BITREG_POWER_BUTTON_ENABLE 0x09 -#define ACPI_BITREG_SLEEP_BUTTON_ENABLE 0x0A -#define ACPI_BITREG_RT_CLOCK_ENABLE 0x0B -#define ACPI_BITREG_WAKE_ENABLE 0x0C - -#define ACPI_BITREG_SCI_ENABLE 0x0D -#define ACPI_BITREG_BUS_MASTER_RLD 0x0E -#define ACPI_BITREG_GLOBAL_LOCK_RELEASE 0x0F -#define ACPI_BITREG_SLEEP_TYPE_A 0x10 -#define ACPI_BITREG_SLEEP_TYPE_B 0x11 -#define ACPI_BITREG_SLEEP_ENABLE 0x12 - -#define ACPI_BITREG_ARB_DISABLE 0x13 - -#define ACPI_BITREG_MAX 0x13 +#define ACPI_BITREG_PCIEXP_WAKE_STATUS 0x07 + +#define ACPI_BITREG_TIMER_ENABLE 0x08 +#define ACPI_BITREG_GLOBAL_LOCK_ENABLE 0x09 +#define ACPI_BITREG_POWER_BUTTON_ENABLE 0x0A +#define ACPI_BITREG_SLEEP_BUTTON_ENABLE 0x0B +#define ACPI_BITREG_RT_CLOCK_ENABLE 0x0C +#define ACPI_BITREG_WAKE_ENABLE 0x0D +#define ACPI_BITREG_PCIEXP_WAKE_DISABLE 0x0E + +#define ACPI_BITREG_SCI_ENABLE 0x0F +#define ACPI_BITREG_BUS_MASTER_RLD 0x10 +#define ACPI_BITREG_GLOBAL_LOCK_RELEASE 0x11 +#define ACPI_BITREG_SLEEP_TYPE_A 0x12 +#define ACPI_BITREG_SLEEP_TYPE_B 0x13 +#define ACPI_BITREG_SLEEP_ENABLE 0x14 + +#define ACPI_BITREG_ARB_DISABLE 0x15 + +#define ACPI_BITREG_MAX 0x15 #define ACPI_NUM_BITREG ACPI_BITREG_MAX + 1 @@ -885,7 +905,6 @@ typedef struct acpi_system_info /* * Types specific to the OS service interfaces */ - typedef UINT32 (ACPI_SYSTEM_XFACE *ACPI_OSD_HANDLER) ( void *Context); @@ -1057,6 +1076,8 @@ typedef struct acpi_mem_space_context /* * Definitions for Resource Attributes */ +typedef UINT16 ACPI_RS_LENGTH; /* Resource Length field is fixed at 16 bits */ +typedef UINT32 ACPI_RSDESC_SIZE; /* Max Resource Descriptor size is (Length+3) = (64K-1)+3 */ /* * Memory Attributes @@ -1089,8 +1110,8 @@ typedef struct acpi_mem_space_context /* * IRQ Attributes */ -#define ACPI_EDGE_SENSITIVE (UINT8) 0x00 -#define ACPI_LEVEL_SENSITIVE (UINT8) 0x01 +#define ACPI_LEVEL_SENSITIVE (UINT8) 0x00 +#define ACPI_EDGE_SENSITIVE (UINT8) 0x01 #define ACPI_ACTIVE_HIGH (UINT8) 0x00 #define ACPI_ACTIVE_LOW (UINT8) 0x01 @@ -1138,61 +1159,72 @@ typedef struct acpi_mem_space_context /* + * If possible, pack the following structures to byte alignment + */ +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#pragma pack(1) +#endif + +/* * Structures used to describe device resources */ typedef struct acpi_resource_irq { - UINT32 EdgeLevel; - UINT32 ActiveHighLow; - UINT32 SharedExclusive; - UINT32 NumberOfInterrupts; - UINT32 Interrupts[1]; + UINT8 Triggering; + UINT8 Polarity; + UINT8 Sharable; + UINT8 InterruptCount; + UINT8 Interrupts[1]; } ACPI_RESOURCE_IRQ; + typedef struct ACPI_RESOURCE_DMA { - UINT32 Type; - UINT32 BusMaster; - UINT32 Transfer; - UINT32 NumberOfChannels; - UINT32 Channels[1]; + UINT8 Type; + UINT8 BusMaster; + UINT8 Transfer; + UINT8 ChannelCount; + UINT8 Channels[1]; } ACPI_RESOURCE_DMA; -typedef struct acpi_resource_start_dpf + +typedef struct acpi_resource_start_dependent { - UINT32 CompatibilityPriority; - UINT32 PerformanceRobustness; + UINT8 CompatibilityPriority; + UINT8 PerformanceRobustness; + +} ACPI_RESOURCE_START_DEPENDENT; -} ACPI_RESOURCE_START_DPF; /* * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not * needed because it has no fields */ + typedef struct acpi_resource_io { - UINT32 IoDecode; - UINT32 MinBaseAddress; - UINT32 MaxBaseAddress; - UINT32 Alignment; - UINT32 RangeLength; + UINT8 IoDecode; + UINT8 Alignment; + UINT8 AddressLength; + UINT16 Minimum; + UINT16 Maximum; } ACPI_RESOURCE_IO; typedef struct acpi_resource_fixed_io { - UINT32 BaseAddress; - UINT32 RangeLength; + UINT16 Address; + UINT8 AddressLength; } ACPI_RESOURCE_FIXED_IO; typedef struct acpi_resource_vendor { - UINT32 Length; - UINT8 Reserved[1]; + UINT16 ByteLength; + UINT8 ByteData[1]; } ACPI_RESOURCE_VENDOR; @@ -1202,100 +1234,106 @@ typedef struct acpi_resource_end_tag } ACPI_RESOURCE_END_TAG; -typedef struct acpi_resource_mem24 +typedef struct acpi_resource_memory24 { - UINT32 ReadWriteAttribute; - UINT32 MinBaseAddress; - UINT32 MaxBaseAddress; - UINT32 Alignment; - UINT32 RangeLength; + UINT8 WriteProtect; + UINT16 Minimum; + UINT16 Maximum; + UINT16 Alignment; + UINT16 AddressLength; -} ACPI_RESOURCE_MEM24; +} ACPI_RESOURCE_MEMORY24; -typedef struct acpi_resource_mem32 +typedef struct acpi_resource_memory32 { - UINT32 ReadWriteAttribute; - UINT32 MinBaseAddress; - UINT32 MaxBaseAddress; + UINT8 WriteProtect; + UINT32 Minimum; + UINT32 Maximum; UINT32 Alignment; - UINT32 RangeLength; + UINT32 AddressLength; -} ACPI_RESOURCE_MEM32; +} ACPI_RESOURCE_MEMORY32; -typedef struct acpi_resource_fixed_mem32 +typedef struct acpi_resource_fixed_memory32 { - UINT32 ReadWriteAttribute; - UINT32 RangeBaseAddress; - UINT32 RangeLength; + UINT8 WriteProtect; + UINT32 Address; + UINT32 AddressLength; -} ACPI_RESOURCE_FIXED_MEM32; +} ACPI_RESOURCE_FIXED_MEMORY32; typedef struct acpi_memory_attribute { - UINT16 CacheAttribute; - UINT16 ReadWriteAttribute; + UINT8 WriteProtect; + UINT8 Caching; + UINT8 RangeType; + UINT8 Translation; } ACPI_MEMORY_ATTRIBUTE; typedef struct acpi_io_attribute { - UINT16 RangeAttribute; - UINT16 TranslationAttribute; + UINT8 RangeType; + UINT8 Translation; + UINT8 TranslationType; + UINT8 Reserved1; } ACPI_IO_ATTRIBUTE; -typedef struct acpi_bus_attribute -{ - UINT16 Reserved1; - UINT16 Reserved2; - -} ACPI_BUS_ATTRIBUTE; - typedef union acpi_resource_attribute { - ACPI_MEMORY_ATTRIBUTE Memory; + ACPI_MEMORY_ATTRIBUTE Mem; ACPI_IO_ATTRIBUTE Io; - ACPI_BUS_ATTRIBUTE Bus; + + /* Used for the *WordSpace macros */ + + UINT8 TypeSpecific; } ACPI_RESOURCE_ATTRIBUTE; typedef struct acpi_resource_source { - UINT32 Index; - UINT32 StringLength; + UINT8 Index; + UINT16 StringLength; char *StringPtr; } ACPI_RESOURCE_SOURCE; +/* Fields common to all address descriptors, 16/32/64 bit */ + +#define ACPI_RESOURCE_ADDRESS_COMMON \ + UINT8 ResourceType; \ + UINT8 ProducerConsumer; \ + UINT8 Decode; \ + UINT8 MinAddressFixed; \ + UINT8 MaxAddressFixed; \ + ACPI_RESOURCE_ATTRIBUTE Info; + +typedef struct acpi_resource_address +{ + ACPI_RESOURCE_ADDRESS_COMMON + +} ACPI_RESOURCE_ADDRESS; + typedef struct acpi_resource_address16 { - UINT32 ResourceType; - UINT32 ProducerConsumer; - UINT32 Decode; - UINT32 MinAddressFixed; - UINT32 MaxAddressFixed; - ACPI_RESOURCE_ATTRIBUTE Attribute; - UINT32 Granularity; - UINT32 MinAddressRange; - UINT32 MaxAddressRange; - UINT32 AddressTranslationOffset; - UINT32 AddressLength; + ACPI_RESOURCE_ADDRESS_COMMON + UINT16 Granularity; + UINT16 Minimum; + UINT16 Maximum; + UINT16 TranslationOffset; + UINT16 AddressLength; ACPI_RESOURCE_SOURCE ResourceSource; } ACPI_RESOURCE_ADDRESS16; typedef struct acpi_resource_address32 { - UINT32 ResourceType; - UINT32 ProducerConsumer; - UINT32 Decode; - UINT32 MinAddressFixed; - UINT32 MaxAddressFixed; - ACPI_RESOURCE_ATTRIBUTE Attribute; + ACPI_RESOURCE_ADDRESS_COMMON UINT32 Granularity; - UINT32 MinAddressRange; - UINT32 MaxAddressRange; - UINT32 AddressTranslationOffset; + UINT32 Minimum; + UINT32 Maximum; + UINT32 TranslationOffset; UINT32 AddressLength; ACPI_RESOURCE_SOURCE ResourceSource; @@ -1303,89 +1341,120 @@ typedef struct acpi_resource_address32 typedef struct acpi_resource_address64 { - UINT32 ResourceType; - UINT32 ProducerConsumer; - UINT32 Decode; - UINT32 MinAddressFixed; - UINT32 MaxAddressFixed; - ACPI_RESOURCE_ATTRIBUTE Attribute; + ACPI_RESOURCE_ADDRESS_COMMON UINT64 Granularity; - UINT64 MinAddressRange; - UINT64 MaxAddressRange; - UINT64 AddressTranslationOffset; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; UINT64 AddressLength; ACPI_RESOURCE_SOURCE ResourceSource; } ACPI_RESOURCE_ADDRESS64; -typedef struct acpi_resource_ext_irq +typedef struct acpi_resource_extended_address64 { - UINT32 ProducerConsumer; - UINT32 EdgeLevel; - UINT32 ActiveHighLow; - UINT32 SharedExclusive; - UINT32 NumberOfInterrupts; + ACPI_RESOURCE_ADDRESS_COMMON + UINT8 RevisionID; + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + UINT64 TypeSpecific; + +} ACPI_RESOURCE_EXTENDED_ADDRESS64; + +typedef struct acpi_resource_extended_irq +{ + UINT8 ProducerConsumer; + UINT8 Triggering; + UINT8 Polarity; + UINT8 Sharable; + UINT8 InterruptCount; ACPI_RESOURCE_SOURCE ResourceSource; UINT32 Interrupts[1]; -} ACPI_RESOURCE_EXT_IRQ; +} ACPI_RESOURCE_EXTENDED_IRQ; + +typedef struct acpi_resource_generic_register +{ + UINT8 SpaceId; + UINT8 BitWidth; + UINT8 BitOffset; + UINT8 AccessSize; + UINT64 Address; + +} ACPI_RESOURCE_GENERIC_REGISTER; /* ACPI_RESOURCE_TYPEs */ -#define ACPI_RSTYPE_IRQ 0 -#define ACPI_RSTYPE_DMA 1 -#define ACPI_RSTYPE_START_DPF 2 -#define ACPI_RSTYPE_END_DPF 3 -#define ACPI_RSTYPE_IO 4 -#define ACPI_RSTYPE_FIXED_IO 5 -#define ACPI_RSTYPE_VENDOR 6 -#define ACPI_RSTYPE_END_TAG 7 -#define ACPI_RSTYPE_MEM24 8 -#define ACPI_RSTYPE_MEM32 9 -#define ACPI_RSTYPE_FIXED_MEM32 10 -#define ACPI_RSTYPE_ADDRESS16 11 -#define ACPI_RSTYPE_ADDRESS32 12 -#define ACPI_RSTYPE_ADDRESS64 13 -#define ACPI_RSTYPE_EXT_IRQ 14 - -typedef UINT32 ACPI_RESOURCE_TYPE; +#define ACPI_RESOURCE_TYPE_IRQ 0 +#define ACPI_RESOURCE_TYPE_DMA 1 +#define ACPI_RESOURCE_TYPE_START_DEPENDENT 2 +#define ACPI_RESOURCE_TYPE_END_DEPENDENT 3 +#define ACPI_RESOURCE_TYPE_IO 4 +#define ACPI_RESOURCE_TYPE_FIXED_IO 5 +#define ACPI_RESOURCE_TYPE_VENDOR 6 +#define ACPI_RESOURCE_TYPE_END_TAG 7 +#define ACPI_RESOURCE_TYPE_MEMORY24 8 +#define ACPI_RESOURCE_TYPE_MEMORY32 9 +#define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10 +#define ACPI_RESOURCE_TYPE_ADDRESS16 11 +#define ACPI_RESOURCE_TYPE_ADDRESS32 12 +#define ACPI_RESOURCE_TYPE_ADDRESS64 13 +#define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */ +#define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15 +#define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16 +#define ACPI_RESOURCE_TYPE_MAX 16 + typedef union acpi_resource_data { - ACPI_RESOURCE_IRQ Irq; - ACPI_RESOURCE_DMA Dma; - ACPI_RESOURCE_START_DPF StartDpf; - ACPI_RESOURCE_IO Io; - ACPI_RESOURCE_FIXED_IO FixedIo; - ACPI_RESOURCE_VENDOR VendorSpecific; - ACPI_RESOURCE_END_TAG EndTag; - ACPI_RESOURCE_MEM24 Memory24; - ACPI_RESOURCE_MEM32 Memory32; - ACPI_RESOURCE_FIXED_MEM32 FixedMemory32; - ACPI_RESOURCE_ADDRESS16 Address16; - ACPI_RESOURCE_ADDRESS32 Address32; - ACPI_RESOURCE_ADDRESS64 Address64; - ACPI_RESOURCE_EXT_IRQ ExtendedIrq; + ACPI_RESOURCE_IRQ Irq; + ACPI_RESOURCE_DMA Dma; + ACPI_RESOURCE_START_DEPENDENT StartDpf; + ACPI_RESOURCE_IO Io; + ACPI_RESOURCE_FIXED_IO FixedIo; + ACPI_RESOURCE_VENDOR Vendor; + ACPI_RESOURCE_END_TAG EndTag; + ACPI_RESOURCE_MEMORY24 Memory24; + ACPI_RESOURCE_MEMORY32 Memory32; + ACPI_RESOURCE_FIXED_MEMORY32 FixedMemory32; + ACPI_RESOURCE_ADDRESS16 Address16; + ACPI_RESOURCE_ADDRESS32 Address32; + ACPI_RESOURCE_ADDRESS64 Address64; + ACPI_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; + ACPI_RESOURCE_EXTENDED_IRQ ExtendedIrq; + ACPI_RESOURCE_GENERIC_REGISTER GenericReg; + + /* Common fields */ + + ACPI_RESOURCE_ADDRESS Address; /* Common 16/32/64 address fields */ } ACPI_RESOURCE_DATA; + typedef struct acpi_resource { - ACPI_RESOURCE_TYPE Id; + UINT32 Type; UINT32 Length; ACPI_RESOURCE_DATA Data; } ACPI_RESOURCE; -#define ACPI_RESOURCE_LENGTH 12 -#define ACPI_RESOURCE_LENGTH_NO_DATA 8 /* Id + Length fields */ +/* restore default alignment */ + +#pragma pack() + -#define ACPI_SIZEOF_RESOURCE(Type) (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (Type)) +#define ACPI_RS_SIZE_MIN 12 +#define ACPI_RS_SIZE_NO_DATA 8 /* Id + Length fields */ +#define ACPI_RS_SIZE(Type) (UINT32) (ACPI_RS_SIZE_NO_DATA + sizeof (Type)) #define ACPI_NEXT_RESOURCE(Res) (ACPI_RESOURCE *)((UINT8 *) Res + Res->Length) -#ifdef ACPI_MISALIGNED_TRANSFERS +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED #define ACPI_ALIGN_RESOURCE_SIZE(Length) (Length) #else #define ACPI_ALIGN_RESOURCE_SIZE(Length) ACPI_ROUND_UP_TO_NATIVE_WORD(Length) diff --git a/sys/contrib/dev/acpica/acutils.h b/sys/contrib/dev/acpica/acutils.h index 749e015..c1726f1 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: 164 $ + * $Revision: 1.182 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,13 +125,6 @@ ACPI_STATUS (*ACPI_PKG_CALLBACK) ( ACPI_GENERIC_STATE *State, void *Context); -ACPI_STATUS -AcpiUtWalkPackageTree ( - ACPI_OPERAND_OBJECT *SourceObject, - void *TargetObject, - ACPI_PKG_CALLBACK WalkCallback, - void *Context); - typedef struct acpi_pkg_info { UINT8 *FreeSpace; @@ -153,37 +146,13 @@ typedef struct acpi_pkg_info #define DB_QWORD_DISPLAY 8 -/* Global initialization interfaces */ - -void -AcpiUtInitGlobals ( - void); - -void -AcpiUtTerminate ( - void); - - /* - * UtInit - miscellaneous initialization and shutdown + * utglobal - Global data structures and procedures */ - -ACPI_STATUS -AcpiUtHardwareInitialize ( - void); - void -AcpiUtSubsystemShutdown ( - void); - -ACPI_STATUS -AcpiUtValidateFadt ( +AcpiUtInitGlobals ( void); -/* - * UtGlobal - Global data structures and procedures - */ - #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) char * @@ -225,15 +194,26 @@ BOOLEAN AcpiUtValidObjectType ( ACPI_OBJECT_TYPE Type); -ACPI_OWNER_ID -AcpiUtAllocateOwnerId ( - UINT32 IdType); - /* - * UtClib - Local implementations of C library functions + * utinit - miscellaneous initialization and shutdown */ +ACPI_STATUS +AcpiUtHardwareInitialize ( + void); + +void +AcpiUtSubsystemShutdown ( + void); +ACPI_STATUS +AcpiUtValidateFadt ( + void); + + +/* + * utclib - Local implementations of C library functions + */ #ifndef ACPI_USE_SYSTEM_CLIBRARY ACPI_SIZE @@ -330,14 +310,13 @@ extern const UINT8 _acpi_ctype[]; #define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) #define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) #define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) -#define ACPI_IS_ASCII(c) ((c) < 0x80) #endif /* ACPI_USE_SYSTEM_CLIBRARY */ + /* - * UtCopy - Object construction and conversion interfaces + * utcopy - Object construction and conversion interfaces */ - ACPI_STATUS AcpiUtBuildSimpleObject( ACPI_OPERAND_OBJECT *Obj, @@ -352,30 +331,11 @@ AcpiUtBuildPackageObject ( UINT32 *SpaceUsed); ACPI_STATUS -AcpiUtCopyIelementToEelement ( - UINT8 ObjectType, - ACPI_OPERAND_OBJECT *SourceObject, - ACPI_GENERIC_STATE *State, - void *Context); - -ACPI_STATUS -AcpiUtCopyIelementToIelement ( - UINT8 ObjectType, - ACPI_OPERAND_OBJECT *SourceObject, - ACPI_GENERIC_STATE *State, - void *Context); - -ACPI_STATUS AcpiUtCopyIobjectToEobject ( ACPI_OPERAND_OBJECT *Obj, ACPI_BUFFER *RetBuffer); ACPI_STATUS -AcpiUtCopyEsimpleToIsimple( - ACPI_OBJECT *UserObj, - ACPI_OPERAND_OBJECT **ReturnObj); - -ACPI_STATUS AcpiUtCopyEobjectToIobject ( ACPI_OBJECT *Obj, ACPI_OPERAND_OBJECT **InternalObj); @@ -386,17 +346,6 @@ AcpiUtCopyISimpleToIsimple ( ACPI_OPERAND_OBJECT *DestObj); ACPI_STATUS -AcpiUtCopyIpackageToIpackage ( - ACPI_OPERAND_OBJECT *SourceObj, - ACPI_OPERAND_OBJECT *DestObj, - ACPI_WALK_STATE *WalkState); - -ACPI_STATUS -AcpiUtCopySimpleObject ( - ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *DestDesc); - -ACPI_STATUS AcpiUtCopyIobjectToIobject ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT **DestDesc, @@ -404,9 +353,8 @@ AcpiUtCopyIobjectToIobject ( /* - * UtCreate - Object creation + * utcreate - Object creation */ - ACPI_STATUS AcpiUtUpdateObjectReference ( ACPI_OPERAND_OBJECT *Object, @@ -414,9 +362,8 @@ AcpiUtUpdateObjectReference ( /* - * UtDebug - Debug interfaces + * utdebug - Debug interfaces */ - void AcpiUtInitStackPtrTrace ( void); @@ -428,47 +375,63 @@ AcpiUtTrackStackPtr ( void AcpiUtTrace ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo); + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId); void AcpiUtTracePtr ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, void *Pointer); void AcpiUtTraceU32 ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, UINT32 Integer); void AcpiUtTraceStr ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, char *String); void AcpiUtExit ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo); + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId); void AcpiUtStatusExit ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, ACPI_STATUS Status); void AcpiUtValueExit ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, ACPI_INTEGER Value); void AcpiUtPtrExit ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, UINT8 *Ptr); void @@ -500,7 +463,9 @@ void ACPI_INTERNAL_VAR_XFACE AcpiUtDebugPrint ( UINT32 RequestedDebugLevel, UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, char *Format, ...) ACPI_PRINTF_LIKE_FUNC; @@ -508,17 +473,22 @@ void ACPI_INTERNAL_VAR_XFACE AcpiUtDebugPrintRaw ( UINT32 RequestedDebugLevel, UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, char *Format, ...) ACPI_PRINTF_LIKE_FUNC; /* - * UtDelete - Object deletion + * utdelete - Object deletion and reference counts */ +void +AcpiUtAddReference ( + ACPI_OPERAND_OBJECT *Object); void -AcpiUtDeleteInternalObj ( +AcpiUtRemoveReference ( ACPI_OPERAND_OBJECT *Object); void @@ -535,25 +505,8 @@ AcpiUtDeleteInternalObjectList ( /* - * UtEval - object evaluation + * uteval - object evaluation */ - -/* Method name strings */ - -#define METHOD_NAME__HID "_HID" -#define METHOD_NAME__CID "_CID" -#define METHOD_NAME__UID "_UID" -#define METHOD_NAME__ADR "_ADR" -#define METHOD_NAME__STA "_STA" -#define METHOD_NAME__REG "_REG" -#define METHOD_NAME__SEG "_SEG" -#define METHOD_NAME__BBN "_BBN" -#define METHOD_NAME__PRT "_PRT" -#define METHOD_NAME__CRS "_CRS" -#define METHOD_NAME__PRS "_PRS" -#define METHOD_NAME__PRW "_PRW" - - ACPI_STATUS AcpiUtOsiImplementation ( ACPI_WALK_STATE *WalkState); @@ -596,39 +549,10 @@ AcpiUtExecute_Sxds ( ACPI_NAMESPACE_NODE *DeviceNode, UINT8 *Highest); -/* - * UtMutex - mutual exclusion interfaces - */ - -ACPI_STATUS -AcpiUtMutexInitialize ( - void); - -void -AcpiUtMutexTerminate ( - void); - -ACPI_STATUS -AcpiUtCreateMutex ( - ACPI_MUTEX_HANDLE MutexId); - -ACPI_STATUS -AcpiUtDeleteMutex ( - ACPI_MUTEX_HANDLE MutexId); - -ACPI_STATUS -AcpiUtAcquireMutex ( - ACPI_MUTEX_HANDLE MutexId); - -ACPI_STATUS -AcpiUtReleaseMutex ( - ACPI_MUTEX_HANDLE MutexId); - /* - * UtObject - internal object create/delete/cache routines + * utobject - internal object create/delete/cache routines */ - ACPI_OPERAND_OBJECT * AcpiUtCreateInternalObjectDbg ( char *ModuleName, @@ -642,8 +566,8 @@ AcpiUtAllocateObjectDescDbg ( UINT32 LineNumber, UINT32 ComponentId); -#define AcpiUtCreateInternalObject(t) AcpiUtCreateInternalObjectDbg (_THIS_MODULE,__LINE__,_COMPONENT,t) -#define AcpiUtAllocateObjectDesc() AcpiUtAllocateObjectDescDbg (_THIS_MODULE,__LINE__,_COMPONENT) +#define AcpiUtCreateInternalObject(t) AcpiUtCreateInternalObjectDbg (_AcpiModuleName,__LINE__,_COMPONENT,t) +#define AcpiUtAllocateObjectDesc() AcpiUtAllocateObjectDescDbg (_AcpiModuleName,__LINE__,_COMPONENT) void AcpiUtDeleteObjectDesc ( @@ -661,50 +585,15 @@ ACPI_OPERAND_OBJECT * AcpiUtCreateStringObject ( ACPI_SIZE StringSize); - -/* - * UtRefCnt - Object reference count management - */ - -void -AcpiUtAddReference ( - ACPI_OPERAND_OBJECT *Object); - -void -AcpiUtRemoveReference ( - ACPI_OPERAND_OBJECT *Object); - -/* - * UtSize - Object size routines - */ - -ACPI_STATUS -AcpiUtGetSimpleObjectSize ( - ACPI_OPERAND_OBJECT *Obj, - ACPI_SIZE *ObjLength); - -ACPI_STATUS -AcpiUtGetPackageObjectSize ( - ACPI_OPERAND_OBJECT *Obj, - ACPI_SIZE *ObjLength); - ACPI_STATUS AcpiUtGetObjectSize( ACPI_OPERAND_OBJECT *Obj, ACPI_SIZE *ObjLength); -ACPI_STATUS -AcpiUtGetElementLength ( - UINT8 ObjectType, - ACPI_OPERAND_OBJECT *SourceObject, - ACPI_GENERIC_STATE *State, - void *Context); - /* - * UtState - Generic state creation/cache routines + * utstate - Generic state creation/cache routines */ - void AcpiUtPushGenericState ( ACPI_GENERIC_STATE **ListHead, @@ -755,23 +644,10 @@ void AcpiUtDeleteGenericState ( ACPI_GENERIC_STATE *State); -void -AcpiUtDeleteGenericStateCache ( - void); - -void -AcpiUtDeleteObjectCache ( - void); /* - * utmisc + * utmath */ - -void -AcpiUtPrintString ( - char *String, - UINT8 MaxLength); - ACPI_STATUS AcpiUtDivide ( ACPI_INTEGER InDividend, @@ -786,6 +662,33 @@ AcpiUtShortDivide ( ACPI_INTEGER *OutQuotient, UINT32 *OutRemainder); +/* + * utmisc + */ +ACPI_STATUS +AcpiUtAllocateOwnerId ( + ACPI_OWNER_ID *OwnerId); + +void +AcpiUtReleaseOwnerId ( + ACPI_OWNER_ID *OwnerId); + +ACPI_STATUS +AcpiUtWalkPackageTree ( + ACPI_OPERAND_OBJECT *SourceObject, + void *TargetObject, + ACPI_PKG_CALLBACK WalkCallback, + void *Context); + +void +AcpiUtStrupr ( + char *SrcString); + +void +AcpiUtPrintString ( + char *String, + UINT8 MaxLength); + BOOLEAN AcpiUtValidAcpiName ( UINT32 Name); @@ -804,9 +707,17 @@ AcpiUtStrtoul64 ( #define ACPI_ANY_BASE 0 -char * -AcpiUtStrupr ( - char *SrcString); +UINT32 +AcpiUtGetDescriptorLength ( + void *Aml); + +UINT16 +AcpiUtGetResourceLength ( + void *Aml); + +UINT8 +AcpiUtGetResourceType ( + void *Aml); UINT8 * AcpiUtGetResourceEndTag ( @@ -836,21 +747,35 @@ AcpiUtDisplayInitPathname ( /* - * Utalloc - memory allocation and object caching + * utmutex - mutex support */ - -void * -AcpiUtAcquireFromCache ( - UINT32 ListId); +ACPI_STATUS +AcpiUtMutexInitialize ( + void); void -AcpiUtReleaseToCache ( - UINT32 ListId, - void *Object); +AcpiUtMutexTerminate ( + void); -void -AcpiUtDeleteGenericCache ( - UINT32 ListId); +ACPI_STATUS +AcpiUtAcquireMutex ( + ACPI_MUTEX_HANDLE MutexId); + +ACPI_STATUS +AcpiUtReleaseMutex ( + ACPI_MUTEX_HANDLE MutexId); + + +/* + * utalloc - memory allocation and object caching + */ +ACPI_STATUS +AcpiUtCreateCaches ( + void); + +ACPI_STATUS +AcpiUtDeleteCaches ( + void); ACPI_STATUS AcpiUtValidateBuffer ( @@ -861,9 +786,6 @@ AcpiUtInitializeBuffer ( ACPI_BUFFER *Buffer, ACPI_SIZE RequiredLength); - -/* Memory allocation functions */ - void * AcpiUtAllocate ( ACPI_SIZE Size, @@ -878,9 +800,7 @@ AcpiUtCallocate ( char *Module, UINT32 Line); - #ifdef ACPI_DBG_TRACK_ALLOCATIONS - void * AcpiUtAllocateAndTrack ( ACPI_SIZE Size, @@ -902,29 +822,6 @@ AcpiUtFreeAndTrack ( char *Module, UINT32 Line); -ACPI_DEBUG_MEM_BLOCK * -AcpiUtFindAllocation ( - UINT32 ListId, - void *Allocation); - -ACPI_STATUS -AcpiUtTrackAllocation ( - UINT32 ListId, - ACPI_DEBUG_MEM_BLOCK *Address, - ACPI_SIZE Size, - UINT8 AllocType, - UINT32 Component, - char *Module, - UINT32 Line); - -ACPI_STATUS -AcpiUtRemoveAllocation ( - UINT32 ListId, - ACPI_DEBUG_MEM_BLOCK *Address, - UINT32 Component, - char *Module, - UINT32 Line); - void AcpiUtDumpAllocationInfo ( void); @@ -935,5 +832,4 @@ AcpiUtDumpAllocations ( char *Module); #endif - #endif /* _ACUTILS_H */ diff --git a/sys/contrib/dev/acpica/aecommon.h b/sys/contrib/dev/acpica/aecommon.h new file mode 100644 index 0000000..b9f4659 --- /dev/null +++ b/sys/contrib/dev/acpica/aecommon.h @@ -0,0 +1,236 @@ +/****************************************************************************** + * + * Module Name: aecommon - common include for the AcpiExec utility + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef _AECOMMON +#define _AECOMMON + +#ifdef _MSC_VER /* disable some level-4 warnings */ +#pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */ +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <signal.h> + +#include <contrib/dev/acpica/acpi.h> +#include <contrib/dev/acpica/acparser.h> +#include <contrib/dev/acpica/amlcode.h> +#include <contrib/dev/acpica/acnamesp.h> +#include <contrib/dev/acpica/acdebug.h> +#include <contrib/dev/acpica/actables.h> +#include <contrib/dev/acpica/acinterp.h> +#include <contrib/dev/acpica/acapps.h> + +extern FILE *AcpiGbl_DebugFile; + +/* + * Debug Regions + */ +typedef struct Region +{ + ACPI_PHYSICAL_ADDRESS Address; + UINT32 Length; + void *Buffer; + void *NextRegion; + +} REGION; + +typedef struct DebugRegions +{ + UINT32 NumberOfRegions; + REGION *RegionList; + +} DEBUG_REGIONS; + + +/* + * Pointer overlay for 16-bit code + */ +typedef union ptr_ovl +{ + void *ptr; + UINT32 dword; + struct + { + UINT16 offset; + UINT16 base; + } ovl; + +} PTR_OVL; + + +#define GET_SEGMENT(ptr) ((UINT16)(_segment)(ptr)) +#define GET_OFFSET(ptr) ((UINT16)(UINT32) (ptr)) +#define GET_PHYSICAL_ADDRESS(ptr) (((((UINT32)GET_SEGMENT(ptr)) << 4)) + GET_OFFSET(ptr)) +#define PTR_OVL_BUILD_PTR(p,b,o) {p.ovl.base=b;p.ovl.offset=o;} + + +#define TEST_OUTPUT_LEVEL(lvl) if ((lvl) & OutputLevel) + +#define OSD_PRINT(lvl,fp) TEST_OUTPUT_LEVEL(lvl) {\ + AcpiOsPrintf PARAM_LIST(fp);} + +void __cdecl +AeCtrlCHandler ( + int Sig); + +ACPI_STATUS +AeBuildLocalTables ( + ACPI_TABLE_HEADER *UserTable); + +ACPI_STATUS +AeInstallTables ( + void); + +void +AeDumpNamespace ( + void); + +void +AeDumpObject ( + char *MethodName, + ACPI_BUFFER *ReturnObj); + +void +AeDumpBuffer ( + UINT32 Address); + +void +AeExecute ( + char *Name); + +void +AeSetScope ( + char *Name); + +void +AeCloseDebugFile ( + void); + +void +AeOpenDebugFile ( + char *Name); + +ACPI_STATUS +AeDisplayAllMethods ( + UINT32 DisplayCount); + +ACPI_STATUS +AeInstallHandlers (void); + + +#endif /* _AECOMMON */ + diff --git a/sys/contrib/dev/acpica/aeexec.c b/sys/contrib/dev/acpica/aeexec.c new file mode 100644 index 0000000..899dead --- /dev/null +++ b/sys/contrib/dev/acpica/aeexec.c @@ -0,0 +1,947 @@ +/****************************************************************************** + * + * Module Name: aeexec - Support routines for AcpiExec utility + * $Revision: 1.88 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#include <contrib/dev/acpica/aecommon.h> + +#define _COMPONENT ACPI_TOOLS + ACPI_MODULE_NAME ("aeexec") + + +ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot; +ACPI_PARSE_OBJECT *root; +UINT8 *AmlStart; +UINT32 AmlLength; +UINT8 *DsdtPtr; +UINT32 AcpiDsdtLength; + +DEBUG_REGIONS AeRegions; +RSDP_DESCRIPTOR LocalRsdp; + +/* + * Misc ACPI tables to be installed + */ +unsigned char Ssdt1Code[] = +{ + 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */ + 0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ + 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */ + 0x39,0x38,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "98.p..`." */ +}; + +unsigned char Ssdt2Code[] = +{ + 0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */ + 0x01,0xB7,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */ + 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */ + 0x39,0x39,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "99.p..`." */ +}; + +unsigned char Oem1Code[] = +{ + 0x4F,0x45,0x4D,0x31,0x38,0x00,0x00,0x00, /* 00000000 "OEM18..." */ + 0x01,0x4B,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 ".KIntel." */ + 0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */ + 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */ + 0x18,0x09,0x03,0x20,0x08,0x5F,0x58,0x54, /* 00000020 "... ._XT" */ + 0x32,0x0A,0x04,0x14,0x0C,0x5F,0x58,0x54, /* 00000028 "2...._XT" */ + 0x31,0x00,0x70,0x01,0x5F,0x58,0x54,0x32, /* 00000030 "1.p._XT2" */ + +}; + +/* + * We need a local FADT so that the hardware subcomponent will function, + * even though the underlying OSD HW access functions don't do + * anything. + */ +RSDP_DESCRIPTOR LocalRSDP; +FADT_DESCRIPTOR_REV1 LocalFADT; +FACS_DESCRIPTOR_REV1 LocalFACS; +ACPI_TABLE_HEADER LocalDSDT; +ACPI_TABLE_HEADER LocalTEST; +ACPI_TABLE_HEADER LocalBADTABLE; + +RSDT_DESCRIPTOR_REV1 *LocalRSDT; + +#define RSDT_TABLES 7 +#define RSDT_SIZE (sizeof (RSDT_DESCRIPTOR_REV1) + ((RSDT_TABLES -1) * sizeof (UINT32))) + + +/****************************************************************************** + * + * FUNCTION: AeCtrlCHandler + * + * PARAMETERS: Sig + * + * RETURN: none + * + * DESCRIPTION: Control-C handler. Abort running control method if any. + * + *****************************************************************************/ + +void __cdecl +AeCtrlCHandler ( + int Sig) +{ + + signal (SIGINT, SIG_IGN); + + AcpiOsPrintf ("Caught a ctrl-c\n\n"); + + if (AcpiGbl_MethodExecuting) + { + AcpiGbl_AbortMethod = TRUE; + signal (SIGINT, AeCtrlCHandler); + } + else + { + exit (0); + } +} + + +/****************************************************************************** + * + * FUNCTION: AeBuildLocalTables + * + * PARAMETERS: + * + * RETURN: Status + * + * DESCRIPTION: + * + *****************************************************************************/ + +ACPI_STATUS +AeBuildLocalTables ( + ACPI_TABLE_HEADER *UserTable) +{ + + + /* Build an RSDT */ + + LocalRSDT = AcpiOsAllocate (RSDT_SIZE); + if (!LocalRSDT) + { + return AE_NO_MEMORY; + } + + ACPI_MEMSET (LocalRSDT, 0, RSDT_SIZE); + ACPI_STRNCPY (LocalRSDT->Signature, RSDT_SIG, 4); + LocalRSDT->Length = RSDT_SIZE; + + LocalRSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (&LocalTEST); + LocalRSDT->TableOffsetEntry[1] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE); + LocalRSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (&LocalFADT); + LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (&LocalTEST); /* Just a placeholder for a user SSDT */ + + /* Install two SSDTs to test multiple table support */ + + LocalRSDT->TableOffsetEntry[4] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code); + LocalRSDT->TableOffsetEntry[5] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code); + + /* Install the OEM1 table to test LoadTable */ + + LocalRSDT->TableOffsetEntry[6] = ACPI_PTR_TO_PHYSADDR (&Oem1Code); + + /* Build an RSDP */ + + ACPI_MEMSET (&LocalRSDP, 0, sizeof (RSDP_DESCRIPTOR)); + ACPI_STRNCPY (LocalRSDP.Signature, RSDP_SIG, 8); + LocalRSDP.Revision = 1; + LocalRSDP.RsdtPhysicalAddress = ACPI_PTR_TO_PHYSADDR (LocalRSDT); + + AcpiGbl_RSDP = &LocalRSDP; + + /* + * Examine the incoming user table. At this point, it has been verified + * to be either a DSDT, SSDT, or a PSDT, but they must be handled differently + */ + if (!ACPI_STRNCMP ((char *) UserTable->Signature, DSDT_SIG, 4)) + { + /* User DSDT is installed directly into the FADT */ + + AcpiGbl_DSDT = UserTable; + } + else + { + /* Build a local DSDT because incoming table is an SSDT or PSDT */ + + ACPI_MEMSET (&LocalDSDT, 0, sizeof (ACPI_TABLE_HEADER)); + ACPI_STRNCPY (LocalDSDT.Signature, DSDT_SIG, 4); + LocalDSDT.Revision = 1; + LocalDSDT.Length = sizeof (ACPI_TABLE_HEADER); + LocalDSDT.Checksum = (UINT8) (0 - AcpiTbGenerateChecksum (&LocalDSDT, LocalDSDT.Length)); + + AcpiGbl_DSDT = &LocalDSDT; + + /* Install incoming table (SSDT or PSDT) directly into the RSDT */ + + LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (UserTable); + } + + /* Set checksums for both RSDT and RSDP */ + + LocalRSDT->Checksum = (UINT8) (0 - AcpiTbGenerateChecksum (LocalRSDT, LocalRSDT->Length)); + LocalRSDP.Checksum = (UINT8) (0 - AcpiTbGenerateChecksum (&LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH)); + + /* Build a FADT so we can test the hardware/event init */ + + ACPI_MEMSET (&LocalFADT, 0, sizeof (FADT_DESCRIPTOR_REV1)); + ACPI_STRNCPY (LocalFADT.Signature, FADT_SIG, 4); + + LocalFADT.FirmwareCtrl = ACPI_PTR_TO_PHYSADDR (&LocalFACS); + LocalFADT.Dsdt = ACPI_PTR_TO_PHYSADDR (AcpiGbl_DSDT); + LocalFADT.Revision = 1; + LocalFADT.Length = sizeof (FADT_DESCRIPTOR_REV1); + LocalFADT.Gpe0BlkLen = 16; + LocalFADT.Gpe1BlkLen = 6; + LocalFADT.Gpe1Base = 96; + + LocalFADT.Pm1EvtLen = 4; + LocalFADT.Pm1CntLen = 4; + LocalFADT.PmTmLen = 8; + + LocalFADT.Gpe0Blk = 0x12340000; + LocalFADT.Gpe1Blk = 0x56780000; + + LocalFADT.Pm1aEvtBlk = 0x1aaa0000; + LocalFADT.Pm1bEvtBlk = 0; + LocalFADT.PmTmrBlk = 0xA0; + LocalFADT.Pm1aCntBlk = 0xB0; + + /* Complete the FADT with the checksum */ + + LocalFADT.Checksum = (UINT8) (0 - AcpiTbGenerateChecksum (&LocalFADT, LocalFADT.Length)); + + /* Build a FACS */ + + ACPI_MEMSET (&LocalFACS, 0, sizeof (FACS_DESCRIPTOR_REV1)); + ACPI_STRNCPY (LocalFACS.Signature, FACS_SIG, 4); + LocalFACS.Length = sizeof (FACS_DESCRIPTOR_REV1); + LocalFACS.GlobalLock = 0x11AA0011; + + /* Build a fake table so that we make sure that the CA core ignores it */ + + ACPI_MEMSET (&LocalTEST, 0, sizeof (ACPI_TABLE_HEADER)); + ACPI_STRNCPY (LocalTEST.Signature, "TEST", 4); + + LocalTEST.Revision = 1; + LocalTEST.Length = sizeof (ACPI_TABLE_HEADER); + + /* Build a fake table with a bad signature so that we make sure that the CA core ignores it */ + + ACPI_MEMSET (&LocalBADTABLE, 0, sizeof (ACPI_TABLE_HEADER)); + ACPI_STRNCPY (LocalBADTABLE.Signature, "BAD!", 4); + + LocalBADTABLE.Revision = 1; + LocalBADTABLE.Length = sizeof (ACPI_TABLE_HEADER); + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AeInstallTables + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Install the various ACPI tables + * + *****************************************************************************/ + +ACPI_STATUS +AeInstallTables (void) +{ + ACPI_STATUS Status; + + + Status = AcpiLoadTables (); + + /* Test the code that ignores multiple loads of same SSDT */ + + (void) AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt1Code); + +#if 0 + Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) &LocalFADT); + if (ACPI_FAILURE (Status)) + { + printf ("**** Could not load local FADT, %s\n", AcpiFormatException (Status)); + return (Status); + } + + Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) &LocalFACS); + if (ACPI_FAILURE (Status)) + { + printf ("**** Could not load local FACS, %s\n", AcpiFormatException (Status)); + return (Status); + } +#endif + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AeLocalGetRootPointer + * + * PARAMETERS: Flags - not used + * Address - Where the root pointer is returned + * + * RETURN: Status + * + * DESCRIPTION: Return a local RSDP, used to dynamically load tables via the + * standard ACPI mechanism. + * + *****************************************************************************/ + +ACPI_STATUS +AeLocalGetRootPointer ( + UINT32 Flags, + ACPI_POINTER *Address) +{ + + Address->PointerType = ACPI_LOGICAL_POINTER; + Address->Pointer.Logical = &LocalRSDP; + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AeRegionHandler + * + * PARAMETERS: Standard region handler parameters + * + * RETURN: Status + * + * DESCRIPTION: Test handler - Handles some dummy regions via memory that can + * be manipulated in Ring 3. + * + *****************************************************************************/ + +ACPI_STATUS +AeRegionHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + + ACPI_OPERAND_OBJECT *RegionObject = (ACPI_OPERAND_OBJECT*) RegionContext; + ACPI_PHYSICAL_ADDRESS BaseAddress; + ACPI_SIZE Length; + BOOLEAN BufferExists; + REGION *RegionElement; + void *BufferValue; + UINT32 ByteWidth; + UINT32 i; + + + ACPI_FUNCTION_NAME ("AeRegionHandler"); + + /* + * If the object is not a region, simply return + */ + if (RegionObject->Region.Type != ACPI_TYPE_REGION) + { + return AE_OK; + } + + /* + * Find the region's address space and length before searching + * the linked list. + */ + BaseAddress = RegionObject->Region.Address; + Length = (ACPI_SIZE) RegionObject->Region.Length; + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "Operation Region request on %s at 0x%X\n", + AcpiUtGetRegionName (RegionObject->Region.SpaceId), + (UINT32) Address)); + + if (RegionObject->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + { + Length = 0; + + switch (Function & ACPI_IO_MASK) + { + case ACPI_READ: + switch (Function >> 16) + { + case AML_FIELD_ATTRIB_SMB_QUICK: + case AML_FIELD_ATTRIB_SMB_SEND_RCV: + case AML_FIELD_ATTRIB_SMB_BYTE: + Length = 1; + break; + + case AML_FIELD_ATTRIB_SMB_WORD: + case AML_FIELD_ATTRIB_SMB_WORD_CALL: + Length = 2; + break; + + case AML_FIELD_ATTRIB_SMB_BLOCK: + case AML_FIELD_ATTRIB_SMB_BLOCK_CALL: + Length = 32; + break; + + default: + break; + } + break; + + case ACPI_WRITE: + switch (Function >> 16) + { + case AML_FIELD_ATTRIB_SMB_QUICK: + case AML_FIELD_ATTRIB_SMB_SEND_RCV: + case AML_FIELD_ATTRIB_SMB_BYTE: + case AML_FIELD_ATTRIB_SMB_WORD: + case AML_FIELD_ATTRIB_SMB_BLOCK: + Length = 0; + break; + + case AML_FIELD_ATTRIB_SMB_WORD_CALL: + Length = 2; + break; + + case AML_FIELD_ATTRIB_SMB_BLOCK_CALL: + Length = 32; + break; + + default: + break; + } + break; + + default: + break; + } + + for (i = 0; i < Length; i++) + { + ((UINT8 *) Value)[i+2] = (UINT8) (0xA0 + i); + } + + ((UINT8 *) Value)[0] = 0x7A; + ((UINT8 *) Value)[1] = (UINT8) Length; + + return AE_OK; + } + + /* + * Search through the linked list for this region's buffer + */ + BufferExists = FALSE; + RegionElement = AeRegions.RegionList; + + if (AeRegions.NumberOfRegions) + { + while (!BufferExists && RegionElement) + { + if (RegionElement->Address == BaseAddress && + RegionElement->Length == Length) + { + BufferExists = TRUE; + } + else + { + RegionElement = RegionElement->NextRegion; + } + } + } + + /* + * If the Region buffer does not exist, create it now + */ + if (!BufferExists) + { + /* + * Do the memory allocations first + */ + RegionElement = AcpiOsAllocate (sizeof (REGION)); + if (!RegionElement) + { + return AE_NO_MEMORY; + } + + RegionElement->Buffer = AcpiOsAllocate (Length); + if (!RegionElement->Buffer) + { + AcpiOsFree (RegionElement); + return AE_NO_MEMORY; + } + + ACPI_MEMSET (RegionElement->Buffer, 0, Length); + RegionElement->Address = BaseAddress; + RegionElement->Length = Length; + RegionElement->NextRegion = NULL; + + /* + * Increment the number of regions and put this one + * at the head of the list as it will probably get accessed + * more often anyway. + */ + AeRegions.NumberOfRegions += 1; + + if (NULL != AeRegions.RegionList) + { + RegionElement->NextRegion = AeRegions.RegionList->NextRegion; + } + + AeRegions.RegionList = RegionElement; + } + + /* + * Calculate the size of the memory copy + */ + ByteWidth = (BitWidth / 8); + + if (BitWidth % 8) + { + ByteWidth += 1; + } + + /* + * The buffer exists and is pointed to by RegionElement. + * We now need to verify the request is valid and perform the operation. + * + * NOTE: RegionElement->Length is in bytes, therefore it we compare against + * ByteWidth (see above) + */ + if (((ACPI_INTEGER) Address + ByteWidth) > + ((ACPI_INTEGER)(RegionElement->Address) + RegionElement->Length)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_WARN, + "Request on [%4.4s] is beyond region limit Req-%X+%X, Base=%X, Len-%X\n", + (RegionObject->Region.Node)->Name.Ascii, (UINT32) Address, + ByteWidth, (UINT32)(RegionElement->Address), + RegionElement->Length)); + + return AE_AML_REGION_LIMIT; + } + + /* + * Get BufferValue to point to the "address" in the buffer + */ + BufferValue = ((UINT8 *) RegionElement->Buffer + + ((ACPI_INTEGER) Address - (ACPI_INTEGER) RegionElement->Address)); + + /* + * Perform a read or write to the buffer space + */ + switch (Function) + { + case ACPI_READ: + /* + * Set the pointer Value to whatever is in the buffer + */ + ACPI_MEMCPY (Value, BufferValue, ByteWidth); + break; + + case ACPI_WRITE: + /* + * Write the contents of Value to the buffer + */ + ACPI_MEMCPY (BufferValue, Value, ByteWidth); + break; + + default: + return AE_BAD_PARAMETER; + } + return AE_OK; +} + + +/****************************************************************************** + * + * FUNCTION: AeRegionInit + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Opregion init function. + * + *****************************************************************************/ + +ACPI_STATUS +AeRegionInit ( + ACPI_HANDLE RegionHandle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + /* + * Real simple, set the RegionContext to the RegionHandle + */ + *RegionContext = RegionHandle; + + return AE_OK; +} + + +/****************************************************************************** + * + * FUNCTION: AeNotifyHandler + * + * PARAMETERS: Standard notify handler parameters + * + * RETURN: Status + * + * DESCRIPTION: System notify handler for AcpiExec utility. Used by the ASL + * test suite(s) to communicate errors and other information to + * this utility via the Notify() operator. + * + *****************************************************************************/ + +void +AeNotifyHandler ( + ACPI_HANDLE Device, + UINT32 Value, + void *Context) +{ + + switch (Value) + { +#if 0 + case 0: + printf ("**** Method Error 0x%X: Results not equal\n", Value); + if (AcpiGbl_DebugFile) + { + AcpiOsPrintf ("**** Method Error: Results not equal\n"); + } + break; + + + case 1: + printf ("**** Method Error: Incorrect numeric result\n"); + if (AcpiGbl_DebugFile) + { + AcpiOsPrintf ("**** Method Error: Incorrect numeric result\n"); + } + break; + + + case 2: + printf ("**** Method Error: An operand was overwritten\n"); + if (AcpiGbl_DebugFile) + { + AcpiOsPrintf ("**** Method Error: An operand was overwritten\n"); + } + break; + +#endif + + default: + printf ("**** Received a Notify on Device [%4.4s] %p value 0x%X\n", + AcpiUtGetNodeName (Device), Device, Value); + if (AcpiGbl_DebugFile) + { + AcpiOsPrintf ("**** Received a notify, value 0x%X\n", Value); + } + break; + } + +} + + +/****************************************************************************** + * + * FUNCTION: AeExceptionHandler + * + * PARAMETERS: Standard exception handler parameters + * + * RETURN: Status + * + * DESCRIPTION: System exception handler for AcpiExec utility. + * + *****************************************************************************/ + +ACPI_STATUS +AeExceptionHandler ( + ACPI_STATUS AmlStatus, + ACPI_NAME Name, + UINT16 Opcode, + UINT32 AmlOffset, + void *Context) +{ + ACPI_STATUS Status; + ACPI_BUFFER ReturnObj; + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg[2]; + const char *Exception; + + + Exception = AcpiFormatException (AmlStatus); + AcpiOsPrintf ( + "**** AcpiExec Exception: %s during execution of method [%4.4s] Opcode [%s] @%X\n", + Exception, (char *) &Name, AcpiPsGetOpcodeName (Opcode), AmlOffset); + + /* + * Invoke the _ERR method if present + * + * Setup parameter object + */ + ArgList.Count = 2; + ArgList.Pointer = Arg; + + Arg[0].Type = ACPI_TYPE_INTEGER; + Arg[0].Integer.Value = AmlStatus; + + Arg[1].Type = ACPI_TYPE_STRING; + Arg[1].String.Pointer = (char *) Exception; + Arg[1].String.Length = ACPI_STRLEN (Exception); + + /* Setup return buffer */ + + ReturnObj.Pointer = NULL; + ReturnObj.Length = ACPI_ALLOCATE_BUFFER; + + Status = AcpiEvaluateObject (NULL, "\\_ERR", &ArgList, &ReturnObj); + if (ACPI_SUCCESS (Status) && + ReturnObj.Pointer) + { + /* Override original status */ + + AmlStatus = (ACPI_STATUS) + ((ACPI_OBJECT *) ReturnObj.Pointer)->Integer.Value; + + AcpiOsFree (ReturnObj.Pointer); + } + return (AmlStatus); +} + + +/****************************************************************************** + * + * FUNCTION: AeInstallHandlers + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Install handlers for the AcpiExec utility. + * NOTE: Currently only a system notify handler is installed. + * + *****************************************************************************/ + +ACPI_ADR_SPACE_TYPE SpaceId[] = {0, 1, 2, 3, 4, 0x80}; +#define AEXEC_NUM_REGIONS 6 + +ACPI_STATUS +AeInstallHandlers (void) +{ + ACPI_STATUS Status; + UINT32 i; + ACPI_HANDLE Handle; + + + ACPI_FUNCTION_NAME ("AeInstallHandlers"); + + + Status = AcpiInstallExceptionHandler (AeExceptionHandler); + if (ACPI_FAILURE (Status)) + { + printf ("Could not install exception handler, %s\n", + AcpiFormatException (Status)); + } + + Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, + AeNotifyHandler, NULL); + if (ACPI_FAILURE (Status)) + { + printf ("Could not install a global notify handler, %s\n", + AcpiFormatException (Status)); + } + + Status = AcpiGetHandle (NULL, "\\_SB_", &Handle); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, + AeNotifyHandler, NULL); + if (ACPI_FAILURE (Status)) + { + printf ("Could not install a notify handler, %s\n", + AcpiFormatException (Status)); + } + + Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, + AeNotifyHandler); + if (ACPI_FAILURE (Status)) + { + printf ("Could not remove a notify handler, %s\n", + AcpiFormatException (Status)); + } + + Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, + AeNotifyHandler, NULL); + Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY, + AeNotifyHandler); + Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, + AeNotifyHandler, NULL); + if (ACPI_FAILURE (Status)) + { + printf ("Could not install a notify handler, %s\n", + AcpiFormatException (Status)); + } + + } + + for (i = 0; i < AEXEC_NUM_REGIONS; i++) + { + if (i == 2) + { + continue; + } + + Status = AcpiRemoveAddressSpaceHandler (AcpiGbl_RootNode, + SpaceId[i], AeRegionHandler); + + /* Install handler at the root object. + * TBD: all default handlers should be installed here! + */ + Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode, + SpaceId[i], AeRegionHandler, AeRegionInit, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not install an OpRegion handler for %s space(%d), %s\n", + AcpiUtGetRegionName((UINT8) SpaceId[i]), SpaceId[i], + AcpiFormatException (Status))); + return (Status); + } + } + + /* + * Initialize the global Region Handler space + * MCW 3/23/00 + */ + AeRegions.NumberOfRegions = 0; + AeRegions.RegionList = NULL; + + return Status; +} + + diff --git a/sys/contrib/dev/acpica/amlcode.h b/sys/contrib/dev/acpica/amlcode.h index ec6b03b..a48f1eb 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: 77 $ + * $Revision: 1.82 $ * *****************************************************************************/ @@ -11,7 +11,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -142,7 +142,7 @@ #define AML_MULTI_NAME_PREFIX_OP (UINT16) 0x2f #define AML_NAME_CHAR_SUBSEQ (UINT16) 0x30 #define AML_NAME_CHAR_FIRST (UINT16) 0x41 -#define AML_OP_PREFIX (UINT16) 0x5b +#define AML_EXTENDED_OP_PREFIX (UINT16) 0x5b #define AML_ROOT_PREFIX (UINT16) 0x5c #define AML_PARENT_PREFIX (UINT16) 0x5e #define AML_LOCAL_OP (UINT16) 0x60 @@ -219,8 +219,7 @@ /* prefixed opcodes */ -#define AML_EXTOP (UINT16) 0x005b - +#define AML_EXTENDED_OPCODE (UINT16) 0x5b00 /* prefix for 2-byte opcodes */ #define AML_MUTEX_OP (UINT16) 0x5b01 #define AML_EVENT_OP (UINT16) 0x5b02 @@ -267,7 +266,6 @@ * Use only "Unknown" AML opcodes, don't attempt to use * any valid ACPI ASCII values (A-Z, 0-9, '-') */ - #define AML_INT_NAMEPATH_OP (UINT16) 0x002d #define AML_INT_NAMEDFIELD_OP (UINT16) 0x0030 #define AML_INT_RESERVEDFIELD_OP (UINT16) 0x0031 @@ -287,7 +285,6 @@ * There can be up to 31 unique argument types * Zero is reserved as end-of-list indicator */ - #define ARGP_BYTEDATA 0x01 #define ARGP_BYTELIST 0x02 #define ARGP_CHARLIST 0x03 @@ -351,6 +348,7 @@ #define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */ #define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */ #define ARGI_REGION_OR_FIELD 0x15 /* Used by LOAD op only */ +#define ARGI_DATAREFOBJ 0x16 /* Note: types above can expand to 0x1F maximum */ @@ -367,7 +365,6 @@ /* * opcode groups and types */ - #define OPGRP_NAMED 0x01 #define OPGRP_FIELD 0x02 #define OPGRP_BYTELIST 0x04 @@ -393,6 +390,7 @@ #define AML_HAS_TARGET 0x0800 #define AML_HAS_ARGS 0x1000 #define AML_CONSTANT 0x2000 +#define AML_NO_OPERAND_RESOLVE 0x4000 /* Convenient flag groupings */ @@ -452,6 +450,12 @@ #define AML_TYPE_UNDEFINED 0x19 #define AML_TYPE_BOGUS 0x1A +/* AML Package Length encodings */ + +#define ACPI_AML_PACKAGE_TYPE1 0x40 +#define ACPI_AML_PACKAGE_TYPE2 0x4000 +#define ACPI_AML_PACKAGE_TYPE3 0x400000 +#define ACPI_AML_PACKAGE_TYPE4 0x40000000 /* * Opcode classes diff --git a/sys/contrib/dev/acpica/amlresrc.h b/sys/contrib/dev/acpica/amlresrc.h index 1ac74a8..b934a1c 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: 25 $ + * $Revision: 1.33 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,6 +123,8 @@ #define ASL_RESNAME_ADDRESS "_ADR" #define ASL_RESNAME_ALIGNMENT "_ALN" #define ASL_RESNAME_ADDRESSSPACE "_ASI" +#define ASL_RESNAME_ACCESSSIZE "_ASZ" +#define ASL_RESNAME_TYPESPECIFICATTRIBUTES "_ATT" #define ASL_RESNAME_BASEADDRESS "_BAS" #define ASL_RESNAME_BUSMASTER "_BM_" /* Master(1), Slave(0) */ #define ASL_RESNAME_DECODE "_DEC" @@ -174,217 +176,254 @@ typedef struct asl_resource_node * Resource descriptors defined in the ACPI specification. * * Packing/alignment must be BYTE because these descriptors - * are used to overlay the AML byte stream. + * are used to overlay the raw AML byte stream. */ #pragma pack(1) -typedef struct asl_irq_format_desc -{ +/* + * SMALL descriptors + */ +#define AML_RESOURCE_SMALL_HEADER_COMMON \ UINT8 DescriptorType; + +typedef struct aml_resource_small_header +{ + AML_RESOURCE_SMALL_HEADER_COMMON + +} AML_RESOURCE_SMALL_HEADER; + + +typedef struct aml_resource_irq +{ + AML_RESOURCE_SMALL_HEADER_COMMON UINT16 IrqMask; UINT8 Flags; -} ASL_IRQ_FORMAT_DESC; +} AML_RESOURCE_IRQ; -typedef struct asl_irq_noflags_desc +typedef struct aml_resource_irq_noflags { - UINT8 DescriptorType; + AML_RESOURCE_SMALL_HEADER_COMMON UINT16 IrqMask; -} ASL_IRQ_NOFLAGS_DESC; +} AML_RESOURCE_IRQ_NOFLAGS; -typedef struct asl_dma_format_desc +typedef struct aml_resource_dma { - UINT8 DescriptorType; + AML_RESOURCE_SMALL_HEADER_COMMON UINT8 DmaChannelMask; UINT8 Flags; -} ASL_DMA_FORMAT_DESC; +} AML_RESOURCE_DMA; -typedef struct asl_start_dependent_desc +typedef struct aml_resource_start_dependent { - UINT8 DescriptorType; + AML_RESOURCE_SMALL_HEADER_COMMON UINT8 Flags; -} ASL_START_DEPENDENT_DESC; +} AML_RESOURCE_START_DEPENDENT; -typedef struct asl_start_dependent_noprio_desc +typedef struct aml_resource_start_dependent_noprio { - UINT8 DescriptorType; + AML_RESOURCE_SMALL_HEADER_COMMON -} ASL_START_DEPENDENT_NOPRIO_DESC; +} AML_RESOURCE_START_DEPENDENT_NOPRIO; -typedef struct asl_end_dependent_desc +typedef struct aml_resource_end_dependent { - UINT8 DescriptorType; + AML_RESOURCE_SMALL_HEADER_COMMON -} ASL_END_DEPENDENT_DESC; +} AML_RESOURCE_END_DEPENDENT; -typedef struct asl_io_port_desc +typedef struct aml_resource_io { - UINT8 DescriptorType; - UINT8 Information; - UINT16 AddressMin; - UINT16 AddressMax; + AML_RESOURCE_SMALL_HEADER_COMMON + UINT8 Flags; + UINT16 Minimum; + UINT16 Maximum; UINT8 Alignment; - UINT8 Length; + UINT8 AddressLength; -} ASL_IO_PORT_DESC; +} AML_RESOURCE_IO; -typedef struct asl_fixed_io_port_desc +typedef struct aml_resource_fixed_io { - UINT8 DescriptorType; - UINT16 BaseAddress; - UINT8 Length; + AML_RESOURCE_SMALL_HEADER_COMMON + UINT16 Address; + UINT8 AddressLength; -} ASL_FIXED_IO_PORT_DESC; +} AML_RESOURCE_FIXED_IO; -typedef struct asl_small_vendor_desc +typedef struct aml_resource_vendor_small { - UINT8 DescriptorType; - UINT8 VendorDefined[7]; + AML_RESOURCE_SMALL_HEADER_COMMON -} ASL_SMALL_VENDOR_DESC; +} AML_RESOURCE_VENDOR_SMALL; -typedef struct asl_end_tag_desc +typedef struct aml_resource_end_tag { - UINT8 DescriptorType; + AML_RESOURCE_SMALL_HEADER_COMMON UINT8 Checksum; -} ASL_END_TAG_DESC; +} AML_RESOURCE_END_TAG; -/* LARGE descriptors */ +/* + * LARGE descriptors + */ +#define AML_RESOURCE_LARGE_HEADER_COMMON \ + UINT8 DescriptorType;\ + UINT16 ResourceLength; -typedef struct asl_memory_24_desc +typedef struct aml_resource_large_header { - UINT8 DescriptorType; - UINT16 Length; - UINT8 Information; - UINT16 AddressMin; - UINT16 AddressMax; - UINT16 Alignment; - UINT16 RangeLength; + AML_RESOURCE_LARGE_HEADER_COMMON -} ASL_MEMORY_24_DESC; +} AML_RESOURCE_LARGE_HEADER; -typedef struct asl_large_vendor_desc +typedef struct aml_resource_memory24 { - UINT8 DescriptorType; - UINT16 Length; - UINT8 VendorDefined[1]; + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT16 Minimum; + UINT16 Maximum; + UINT16 Alignment; + UINT16 AddressLength; -} ASL_LARGE_VENDOR_DESC; +} AML_RESOURCE_MEMORY24; -typedef struct asl_memory_32_desc +typedef struct aml_resource_vendor_large { - UINT8 DescriptorType; - UINT16 Length; - UINT8 Information; - UINT32 AddressMin; - UINT32 AddressMax; - UINT32 Alignment; - UINT32 RangeLength; + AML_RESOURCE_LARGE_HEADER_COMMON -} ASL_MEMORY_32_DESC; +} AML_RESOURCE_VENDOR_LARGE; -typedef struct asl_fixed_memory_32_desc +typedef struct aml_resource_memory32 { - UINT8 DescriptorType; - UINT16 Length; - UINT8 Information; - UINT32 BaseAddress; - UINT32 RangeLength; + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT32 Minimum; + UINT32 Maximum; + UINT32 Alignment; + UINT32 AddressLength; -} ASL_FIXED_MEMORY_32_DESC; +} AML_RESOURCE_MEMORY32; -typedef struct asl_qword_address_desc +typedef struct aml_resource_fixed_memory32 { - UINT8 DescriptorType; - UINT16 Length; - UINT8 ResourceType; + AML_RESOURCE_LARGE_HEADER_COMMON UINT8 Flags; + UINT32 Address; + UINT32 AddressLength; + +} AML_RESOURCE_FIXED_MEMORY32; + + +#define AML_RESOURCE_ADDRESS_COMMON \ + UINT8 ResourceType; \ + UINT8 Flags; \ UINT8 SpecificFlags; + + +typedef struct aml_resource_address +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + +} AML_RESOURCE_ADDRESS; + + +typedef struct aml_resource_extended_address64 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT8 RevisionID; + UINT8 Reserved; UINT64 Granularity; - UINT64 AddressMin; - UINT64 AddressMax; + UINT64 Minimum; + UINT64 Maximum; UINT64 TranslationOffset; UINT64 AddressLength; - UINT8 OptionalFields[2]; + UINT64 TypeSpecific; -} ASL_QWORD_ADDRESS_DESC; +} AML_RESOURCE_EXTENDED_ADDRESS64; +#define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */ -typedef struct asl_dword_address_desc + +typedef struct aml_resource_address64 { - UINT8 DescriptorType; - UINT16 Length; - UINT8 ResourceType; - UINT8 Flags; - UINT8 SpecificFlags; + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + +} AML_RESOURCE_ADDRESS64; + + +typedef struct aml_resource_address32 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON UINT32 Granularity; - UINT32 AddressMin; - UINT32 AddressMax; + UINT32 Minimum; + UINT32 Maximum; UINT32 TranslationOffset; UINT32 AddressLength; - UINT8 OptionalFields[2]; -} ASL_DWORD_ADDRESS_DESC; +} AML_RESOURCE_ADDRESS32; -typedef struct asl_word_address_desc +typedef struct aml_resource_address16 { - UINT8 DescriptorType; - UINT16 Length; - UINT8 ResourceType; - UINT8 Flags; - UINT8 SpecificFlags; + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON UINT16 Granularity; - UINT16 AddressMin; - UINT16 AddressMax; + UINT16 Minimum; + UINT16 Maximum; UINT16 TranslationOffset; UINT16 AddressLength; - UINT8 OptionalFields[2]; -} ASL_WORD_ADDRESS_DESC; +} AML_RESOURCE_ADDRESS16; -typedef struct asl_extended_xrupt_desc +typedef struct aml_resource_extended_irq { - UINT8 DescriptorType; - UINT16 Length; + AML_RESOURCE_LARGE_HEADER_COMMON UINT8 Flags; - UINT8 TableLength; - UINT32 InterruptNumber[1]; + UINT8 InterruptCount; + UINT32 Interrupts[1]; /* ResSourceIndex, ResSource optional fields follow */ -} ASL_EXTENDED_XRUPT_DESC; +} AML_RESOURCE_EXTENDED_IRQ; -typedef struct asl_general_register_desc +typedef struct aml_resource_generic_register { - UINT8 DescriptorType; - UINT16 Length; + AML_RESOURCE_LARGE_HEADER_COMMON UINT8 AddressSpaceId; UINT8 BitWidth; UINT8 BitOffset; - UINT8 Reserved; + UINT8 AccessSize; /* ACPI 3.0, was previously Reserved */ UINT64 Address; -} ASL_GENERAL_REGISTER_DESC; +} AML_RESOURCE_GENERIC_REGISTER; /* restore default alignment */ @@ -392,31 +431,45 @@ typedef struct asl_general_register_desc /* Union of all resource descriptors, so we can allocate the worst case */ -typedef union asl_resource_desc +typedef union aml_resource { - ASL_IRQ_FORMAT_DESC Irq; - ASL_DMA_FORMAT_DESC Dma; - ASL_START_DEPENDENT_DESC Std; - ASL_END_DEPENDENT_DESC End; - ASL_IO_PORT_DESC Iop; - ASL_FIXED_IO_PORT_DESC Fio; - ASL_SMALL_VENDOR_DESC Smv; - ASL_END_TAG_DESC Et; - - ASL_MEMORY_24_DESC M24; - ASL_LARGE_VENDOR_DESC Lgv; - ASL_MEMORY_32_DESC M32; - ASL_FIXED_MEMORY_32_DESC F32; - ASL_QWORD_ADDRESS_DESC Qas; - ASL_DWORD_ADDRESS_DESC Das; - ASL_WORD_ADDRESS_DESC Was; - ASL_EXTENDED_XRUPT_DESC Exx; - ASL_GENERAL_REGISTER_DESC Grg; - UINT32 U32Item; - UINT16 U16Item; - UINT8 U8Item; - -} ASL_RESOURCE_DESC; + /* Descriptor headers */ + + AML_RESOURCE_SMALL_HEADER SmallHeader; + AML_RESOURCE_LARGE_HEADER LargeHeader; + + /* Small resource descriptors */ + + AML_RESOURCE_IRQ Irq; + AML_RESOURCE_DMA Dma; + AML_RESOURCE_START_DEPENDENT StartDpf; + AML_RESOURCE_END_DEPENDENT EndDpf; + AML_RESOURCE_IO Io; + AML_RESOURCE_FIXED_IO FixedIo; + AML_RESOURCE_VENDOR_SMALL VendorSmall; + AML_RESOURCE_END_TAG EndTag; + + /* Large resource descriptors */ + + AML_RESOURCE_MEMORY24 Memory24; + AML_RESOURCE_GENERIC_REGISTER GenericReg; + AML_RESOURCE_VENDOR_LARGE VendorLarge; + AML_RESOURCE_MEMORY32 Memory32; + AML_RESOURCE_FIXED_MEMORY32 FixedMemory32; + AML_RESOURCE_ADDRESS16 Address16; + AML_RESOURCE_ADDRESS32 Address32; + AML_RESOURCE_ADDRESS64 Address64; + AML_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; + AML_RESOURCE_EXTENDED_IRQ ExtendedIrq; + + /* Utility overlays */ + + AML_RESOURCE_ADDRESS Address; + UINT32 U32Item; + UINT16 U16Item; + UINT8 U8Item; + +} AML_RESOURCE; #endif diff --git a/sys/contrib/dev/acpica/common/adisasm.c b/sys/contrib/dev/acpica/common/adisasm.c index a1d1411..472f1ba 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: 69 $ + * $Revision: 1.77 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,14 +115,14 @@ *****************************************************************************/ -#include "acpi.h" -#include "acparser.h" -#include "amlcode.h" -#include "acdebug.h" -#include "acdisasm.h" -#include "acdispat.h" -#include "acnamesp.h" -#include "acapps.h" +#include <contrib/dev/acpica/acpi.h> +#include <contrib/dev/acpica/acparser.h> +#include <contrib/dev/acpica/amlcode.h> +#include <contrib/dev/acpica/acdebug.h> +#include <contrib/dev/acpica/acdisasm.h> +#include <contrib/dev/acpica/acdispat.h> +#include <contrib/dev/acpica/acnamesp.h> +#include <contrib/dev/acpica/acapps.h> #include <stdio.h> #include <string.h> @@ -136,7 +136,7 @@ ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot; -#ifndef _ACPI_ASL_COMPILER +#ifndef ACPI_ASL_COMPILER BOOLEAN AcpiDsIsResultUsed ( ACPI_PARSE_OBJECT *Op, @@ -154,11 +154,11 @@ AcpiDsRestartControlMethod ( return (AE_OK); } -ACPI_STATUS +void AcpiDsTerminateControlMethod ( ACPI_WALK_STATE *WalkState) { - return (AE_OK); + return; } ACPI_STATUS @@ -188,9 +188,10 @@ char FilenameBuf[20]; * * FUNCTION: AfGenerateFilename * - * PARAMETERS: + * PARAMETERS: Prefix - prefix string + * TableId - The table ID * - * RETURN: + * RETURN: Pointer to the completed string * * DESCRIPTION: Build an output filename from an ACPI table ID string * @@ -228,9 +229,11 @@ AdGenerateFilename ( * * FUNCTION: AfWriteBuffer * - * PARAMETERS: + * PARAMETERS: Filename - name of file + * Buffer - data to write + * Length - length of data * - * RETURN: + * RETURN: Actual number of bytes written * * DESCRIPTION: Open a file and write out a single buffer * @@ -263,9 +266,12 @@ AdWriteBuffer ( * * FUNCTION: AfWriteTable * - * PARAMETERS: + * PARAMETERS: Table - pointer to the ACPI table + * Length - length of the table + * TableName - the table signature + * OemTableID - from the table header * - * RETURN: + * RETURN: None * * DESCRIPTION: Dump the loaded tables to a file (or files) * @@ -378,6 +384,9 @@ FlGenerateFilename ( * * PARAMETERS: InputFilename - The user-specified ASL source file to be * compiled + * OutDirectoryPath - Where the directory path prefix is + * returned + * OutFilename - Where the filename part is returned * * RETURN: Status * @@ -451,8 +460,11 @@ FlSplitInputPathname ( * * FUNCTION: AdAmlDisassemble * - * PARAMETERS: OutToFile - TRUE if output should go to a file - * Filename - AML input filename + * PARAMETERS: Filename - AML input filename + * OutToFile - TRUE if output should go to a file + * Prefix - Path prefix for output + * OutFilename - where the filename is returned + * GetAllTables - TRUE if all tables are desired * * RETURN: Status * @@ -608,7 +620,7 @@ AdCreateTableHeader ( AcpiOsPrintf (" *\n * Disassembly of %s, %s */\n", Filename, ctime (&Timer)); AcpiOsPrintf ( - "DefinitionBlock (\"%4.4s.aml\", \"%4.4s\", %hd, \"%.6s\", \"%.8s\", %u)\n", + "DefinitionBlock (\"%4.4s.aml\", \"%4.4s\", %hd, \"%.6s\", \"%.8s\", 0x%8.8X)\n", Table->Signature, Table->Signature, Table->Revision, Table->OemId, Table->OemTableId, Table->OemRevision); } @@ -619,6 +631,7 @@ AdCreateTableHeader ( * FUNCTION: AdDisplayTables * * PARAMETERS: Filename - Input file for the table + * Table - Pointer to the raw table * * RETURN: Status * @@ -718,6 +731,7 @@ AdDeferredParse ( /* Parse the method */ WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; + WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; Status = AcpiPsParseAml (WalkState); /* @@ -750,12 +764,12 @@ AdDeferredParse ( switch (Op->Common.AmlOpcode) { case AML_PACKAGE_OP: - case AML_VAR_PACKAGE_OP: ExtraOp = Op->Common.Value.Arg; ExtraOp = ExtraOp->Common.Next; Op->Common.Value.Arg = ExtraOp->Common.Value.Arg; break; + case AML_VAR_PACKAGE_OP: case AML_BUFFER_OP: default: ExtraOp = Op->Common.Value.Arg; @@ -862,9 +876,10 @@ AdParseDeferredOps ( * * FUNCTION: AdGetLocalTables * - * PARAMETERS: + * PARAMETERS: Filename - Not used + * GetAllTables - TRUE if all tables are desired * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Get the ACPI tables from either memory or a file * @@ -982,7 +997,7 @@ AdGetLocalTables ( * * FUNCTION: AdParseTable * - * PARAMETERS: None + * PARAMETERS: Table - Pointer to the raw table * * RETURN: Status * @@ -1038,6 +1053,7 @@ AdParseTable ( } WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; + WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; Status = AcpiPsParseAml (WalkState); if (ACPI_FAILURE (Status)) @@ -1050,6 +1066,7 @@ AdParseTable ( TableDesc.AmlStart = AmlStart; TableDesc.AmlLength = AmlLength; fprintf (stderr, "Pass 2 parse of [%4.4s]\n", (char *) Table->Signature); + WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; Status = AcpiNsOneCompleteParse (2, &TableDesc); if (ACPI_FAILURE (Status)) diff --git a/sys/contrib/dev/acpica/common/getopt.c b/sys/contrib/dev/acpica/common/getopt.c index 36ab4cd..cdad6e1 100644 --- a/sys/contrib/dev/acpica/common/getopt.c +++ b/sys/contrib/dev/acpica/common/getopt.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: getopt - * $Revision: 7 $ + * $Revision: 1.8 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/compiler/aslanalyze.c b/sys/contrib/dev/acpica/compiler/aslanalyze.c index 93bcca1..42f2247 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: 84 $ + * $Revision: 1.96 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,16 +116,61 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" -#include "acparser.h" -#include "amlcode.h" +#include <contrib/dev/acpica/acparser.h> +#include <contrib/dev/acpica/amlcode.h> #include <ctype.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslanalyze") +/* Local prototypes */ + +static UINT32 +AnMapArgTypeToBtype ( + UINT32 ArgType); + +static UINT32 +AnMapEtypeToBtype ( + UINT32 Etype); + +static void +AnFormatBtype ( + char *Buffer, + UINT32 Btype); + +static UINT32 +AnGetBtype ( + ACPI_PARSE_OBJECT *Op); + +static UINT32 +AnCheckForReservedName ( + ACPI_PARSE_OBJECT *Op, + char *Name); + +static void +AnCheckForReservedMethod ( + ACPI_PARSE_OBJECT *Op, + ASL_METHOD_INFO *MethodInfo); + +static UINT32 +AnMapObjTypeToBtype ( + ACPI_PARSE_OBJECT *Op); + +static BOOLEAN +AnLastStatementIsReturn ( + ACPI_PARSE_OBJECT *Op); + +static void +AnCheckMethodReturnValue ( + ACPI_PARSE_OBJECT *Op, + const ACPI_OPCODE_INFO *OpInfo, + ACPI_PARSE_OBJECT *ArgOp, + UINT32 RequiredBtypes, + UINT32 ThisNodeBtype); + /******************************************************************************* * @@ -142,7 +187,7 @@ * ******************************************************************************/ -UINT32 +static UINT32 AnMapArgTypeToBtype ( UINT32 ArgType) { @@ -202,9 +247,12 @@ AnMapArgTypeToBtype ( case ARGI_DATAOBJECT: - /* Buffer, string, package or reference to a Op - Used only by SizeOf operator*/ - - return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE); + /* + * Buffer, string, package or reference to a Op - + * Used only by SizeOf operator + */ + return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | + ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE); case ARGI_COMPLEXOBJ: @@ -218,6 +266,10 @@ AnMapArgTypeToBtype ( case ARGI_REGION_OR_FIELD: return (ACPI_BTYPE_REGION | ACPI_BTYPE_FIELD_UNIT); + case ARGI_DATAREFOBJ: + return (ACPI_BTYPE_INTEGER |ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER | + ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE); + default: break; } @@ -240,9 +292,9 @@ AnMapArgTypeToBtype ( * ******************************************************************************/ -UINT32 +static UINT32 AnMapEtypeToBtype ( - UINT32 Etype) + UINT32 Etype) { @@ -323,41 +375,6 @@ AnMapEtypeToBtype ( /******************************************************************************* * - * FUNCTION: AnMapBtypeToEtype - * - * PARAMETERS: Btype - Bitfield of ACPI types - * - * RETURN: The Etype corresponding the the Btype - * - * DESCRIPTION: Convert a bitfield type to an encoded type - * - ******************************************************************************/ - -UINT32 -AnMapBtypeToEtype ( - UINT32 Btype) -{ - UINT32 i; - UINT32 Etype; - - - if (Btype == 0) - { - return 0; - } - - Etype = 1; - for (i = 1; i < Btype; i *= 2) - { - Etype++; - } - - return (Etype); -} - - -/******************************************************************************* - * * FUNCTION: AnFormatBtype * * PARAMETERS: Btype - Bitfield of ACPI types @@ -369,13 +386,13 @@ AnMapBtypeToEtype ( * ******************************************************************************/ -void +static void AnFormatBtype ( - char *Buffer, - UINT32 Btype) + char *Buffer, + UINT32 Btype) { - UINT32 Type; - BOOLEAN First = TRUE; + UINT32 Type; + BOOLEAN First = TRUE; *Buffer = 0; @@ -386,7 +403,7 @@ AnFormatBtype ( return; } - for (Type = 1; Type < ACPI_TYPE_EXTERNAL_MAX; Type++) + for (Type = 1; Type <= ACPI_TYPE_EXTERNAL_MAX; Type++) { if (Btype & 0x00000001) { @@ -437,7 +454,7 @@ AnFormatBtype ( * ******************************************************************************/ -UINT32 +static UINT32 AnGetBtype ( ACPI_PARSE_OBJECT *Op) { @@ -461,6 +478,10 @@ AnGetBtype ( } ThisNodeBtype = AnMapEtypeToBtype (Node->Type); + if (!ThisNodeBtype) + { + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, NULL); + } /* * Since it was a named reference, enable the @@ -470,7 +491,7 @@ AnGetBtype ( if (Op->Asl.ParseOpcode == PARSEOP_METHODCALL) { - ReferencedNode = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object); + ReferencedNode = Node->Op; if (!ReferencedNode) { printf ("No back ptr to Op: type %X\n", Node->Type); @@ -509,13 +530,7 @@ AnGetBtype ( * ******************************************************************************/ -#define ACPI_VALID_RESERVED_NAME_MAX 0x80000000 -#define ACPI_NOT_RESERVED_NAME ACPI_UINT32_MAX -#define ACPI_PREDEFINED_NAME (ACPI_UINT32_MAX - 1) -#define ACPI_EVENT_RESERVED_NAME (ACPI_UINT32_MAX - 2) -#define ACPI_COMPILER_RESERVED_NAME (ACPI_UINT32_MAX - 3) - -UINT32 +static UINT32 AnCheckForReservedName ( ACPI_PARSE_OBJECT *Op, char *Name) @@ -525,7 +540,8 @@ AnCheckForReservedName ( if (Name[0] == 0) { - AcpiOsPrintf ("Found a null name, external = %s\n", Op->Asl.ExternalName); + AcpiOsPrintf ("Found a null name, external = %s\n", + Op->Asl.ExternalName); } /* All reserved names are prefixed with a single underscore */ @@ -543,12 +559,14 @@ AnCheckForReservedName ( { if (ReservedMethods[i].Flags & ASL_RSVD_SCOPE) { - AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, Op->Asl.ExternalName); + AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, + Op->Asl.ExternalName); return (ACPI_PREDEFINED_NAME); } else if (ReservedMethods[i].Flags & ASL_RSVD_RESOURCE_NAME) { - AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, Op->Asl.ExternalName); + AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, + Op->Asl.ExternalName); return (ACPI_PREDEFINED_NAME); } @@ -599,7 +617,8 @@ AnCheckForReservedName ( * warning, since the entire namespace starting with an underscore is * reserved by the ACPI spec. */ - AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op, Op->Asl.ExternalName); + AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op, + Op->Asl.ExternalName); return (ACPI_NOT_RESERVED_NAME); } @@ -619,7 +638,7 @@ AnCheckForReservedName ( * ******************************************************************************/ -void +static void AnCheckForReservedMethod ( ACPI_PARSE_OBJECT *Op, ASL_METHOD_INFO *MethodInfo) @@ -671,11 +690,13 @@ AnCheckForReservedMethod ( if (MethodInfo->NumArguments > ReservedMethods[Index].NumArguments) { - AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, MsgBuffer); + AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, + MsgBuffer); } else { - AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op, MsgBuffer); + AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op, + MsgBuffer); } } @@ -691,7 +712,19 @@ AnCheckForReservedMethod ( } -UINT32 +/******************************************************************************* + * + * FUNCTION: AnMapObjTypeToBtype + * + * PARAMETERS: Op - A parse node + * + * RETURN: A Btype + * + * DESCRIPTION: Map object to the associated "Btype" + * + ******************************************************************************/ + +static UINT32 AnMapObjTypeToBtype ( ACPI_PARSE_OBJECT *Op) { @@ -780,7 +813,7 @@ AnMethodAnalysisWalkBegin ( ACPI_PARSE_OBJECT *ArgNode; ACPI_PARSE_OBJECT *NextType; ACPI_PARSE_OBJECT *NextParamType; - char ActualArgs = 0; + UINT8 ActualArgs = 0; ACPI_FUNCTION_NAME ("AnMethodAnalysisWalkBegin"); @@ -792,9 +825,8 @@ AnMethodAnalysisWalkBegin ( TotalMethods++; - /* - * Create and init method info - */ + /* Create and init method info */ + MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO)); MethodInfo->Next = WalkInfo->MethodStack; MethodInfo->Op = Op; @@ -808,7 +840,8 @@ AnMethodAnalysisWalkBegin ( /* Get the NumArguments node */ Next = Next->Asl.Next; - MethodInfo->NumArguments = (UINT8) (((UINT8) Next->Asl.Value.Integer) & 0x07); + MethodInfo->NumArguments = (UINT8) + (((UINT8) Next->Asl.Value.Integer) & 0x07); /* Get the SerializeRule and SyncLevel nodes, ignored here */ @@ -849,7 +882,8 @@ AnMethodAnalysisWalkBegin ( } else { - MethodInfo->ValidArgTypes[ActualArgs] = AnMapObjTypeToBtype (NextType); + MethodInfo->ValidArgTypes[ActualArgs] = + AnMapObjTypeToBtype (NextType); NextType->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; } @@ -904,8 +938,10 @@ AnMethodAnalysisWalkBegin ( if (!MethodInfo) { - /* Probably was an error in the method declaration, no additional error here */ - + /* + * Probably was an error in the method declaration, + * no additional error here + */ ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%p, No parent method\n", Op)); return (AE_ERROR); } @@ -946,8 +982,10 @@ AnMethodAnalysisWalkBegin ( if (!MethodInfo) { - /* Probably was an error in the method declaration, no additional error here */ - + /* + * Probably was an error in the method declaration, + * no additional error here + */ ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%p, No parent method\n", Op)); return (AE_ERROR); } @@ -989,8 +1027,10 @@ AnMethodAnalysisWalkBegin ( if (!MethodInfo) { - /* Probably was an error in the method declaration, no additional error here */ - + /* + * Probably was an error in the method declaration, + * no additional error here + */ ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%p, No parent method\n", Op)); return (AE_ERROR); } @@ -1031,7 +1071,10 @@ AnMethodAnalysisWalkBegin ( case PARSEOP_STALL: - if (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX) + /* We can range check if the argument is an integer */ + + if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) && + (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX)) { AslError (ASL_ERROR, ASL_MSG_INVALID_TIME, Op, NULL); } @@ -1069,12 +1112,12 @@ AnMethodAnalysisWalkBegin ( * This reserved name must be a control method because * it must have arguments */ - AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, "with arguments"); + AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, + "with arguments"); } - /* - * Typechecking for _HID - */ + /* Typechecking for _HID */ + else if (!ACPI_STRCMP (METHOD_NAME__HID, ReservedMethods[i].Name)) { /* Examine the second operand to typecheck it */ @@ -1086,7 +1129,8 @@ AnMethodAnalysisWalkBegin ( { /* _HID must be a string or an integer */ - AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Next, "String or Integer"); + AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Next, + "String or Integer"); } if (Next->Asl.ParseOpcode == PARSEOP_STRING_LITERAL) @@ -1100,7 +1144,8 @@ AnMethodAnalysisWalkBegin ( { if (!isalnum (Next->Asl.Value.String[i])) { - AslError (ASL_ERROR, ASL_MSG_ALPHANUMERIC_STRING, Next, Next->Asl.Value.String); + AslError (ASL_ERROR, ASL_MSG_ALPHANUMERIC_STRING, + Next, Next->Asl.Value.String); break; } } @@ -1133,7 +1178,7 @@ AnMethodAnalysisWalkBegin ( * ******************************************************************************/ -BOOLEAN +static BOOLEAN AnLastStatementIsReturn ( ACPI_PARSE_OBJECT *Op) { @@ -1189,7 +1234,8 @@ AnMethodAnalysisWalkEnd ( if (!MethodInfo) { printf ("No method info for method! [%s]\n", Op->Asl.Namepath); - AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, "No method info for this method"); + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, + "No method info for this method"); CmCleanupAndExit (); return (AE_AML_INTERNAL); } @@ -1228,7 +1274,8 @@ AnMethodAnalysisWalkEnd ( if (MethodInfo->NumReturnNoValue && MethodInfo->NumReturnWithValue) { - AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op, Op->Asl.ExternalName); + AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op, + Op->Asl.ExternalName); } /* @@ -1266,12 +1313,15 @@ AnMethodAnalysisWalkEnd ( * method is terminated here with the Return() statement. */ Op->Asl.Parent->Asl.CompileFlags |= NODE_HAS_NO_EXIT; - Op->Asl.ParentMethod = MethodInfo->Op; /* Used in the "typing" pass later */ + + /* Used in the "typing" pass later */ + + Op->Asl.ParentMethod = MethodInfo->Op; /* * If there is a peer node after the return statement, then this - * node is unreachable code -- i.e., it won't be executed because of the - * preceeding Return() statement. + * node is unreachable code -- i.e., it won't be executed because of + * thepreceeding Return() statement. */ if (Op->Asl.Next) { @@ -1392,12 +1442,12 @@ AnMethodTypingWalkEnd ( (ThisNodeBtype == (ACPI_UINT32_MAX -1))) { /* - * The method is untyped at this time (typically a forward reference). - * We must recursively type the method here + * The method is untyped at this time (typically a forward + * reference). We must recursively type the method here */ - TrWalkParseTree (ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Op->Asl.Child->Asl.Node->Object), - ASL_WALK_VISIT_TWICE, AnMethodTypingWalkBegin, - AnMethodTypingWalkEnd, NULL); + TrWalkParseTree (Op->Asl.Child->Asl.Node->Op, + ASL_WALK_VISIT_TWICE, AnMethodTypingWalkBegin, + AnMethodTypingWalkEnd, NULL); ThisNodeBtype = AnGetBtype (Op->Asl.Child); } @@ -1436,7 +1486,7 @@ AnMethodTypingWalkEnd ( * ******************************************************************************/ -void +static void AnCheckMethodReturnValue ( ACPI_PARSE_OBJECT *Op, const ACPI_OPCODE_INFO *OpInfo, @@ -1453,26 +1503,23 @@ AnCheckMethodReturnValue ( /* Examine the parent op of this method */ - OwningOp = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object); + OwningOp = Node->Op; if (OwningOp->Asl.CompileFlags & NODE_METHOD_NO_RETVAL) { - /* - * Method NEVER returns a value - */ + /* Method NEVER returns a value */ + AslError (ASL_ERROR, ASL_MSG_NO_RETVAL, Op, Op->Asl.ExternalName); } else if (OwningOp->Asl.CompileFlags & NODE_METHOD_SOME_NO_RETVAL) { - /* - * Method SOMETIMES returns a value, SOMETIMES not - */ + /* Method SOMETIMES returns a value, SOMETIMES not */ + AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, Op, Op->Asl.ExternalName); } else if (!(ThisNodeBtype & RequiredBtypes)) { - /* - * Method returns a value, but the type is wrong - */ + /* Method returns a value, but the type is wrong */ + AnFormatBtype (StringBuffer, ThisNodeBtype); AnFormatBtype (StringBuffer2, RequiredBtypes); @@ -1485,8 +1532,9 @@ AnCheckMethodReturnValue ( */ if (ThisNodeBtype != 0) { - sprintf (MsgBuffer, "Method returns [%s], %s operator requires [%s]", - StringBuffer, OpInfo->Name, StringBuffer2); + sprintf (MsgBuffer, + "Method returns [%s], %s operator requires [%s]", + StringBuffer, OpInfo->Name, StringBuffer2); AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer); } @@ -1502,7 +1550,7 @@ AnCheckMethodReturnValue ( * * RETURN: Status * - * DESCRIPTION: Descending callback for the analysis walk. Check methods for : + * DESCRIPTION: Descending callback for the analysis walk. Check methods for: * 1) Initialized local variables * 2) Valid arguments * 3) Return types @@ -1593,6 +1641,11 @@ AnOperandTypecheckWalkEnd ( if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) { + if (!ACPI_STRCMP (ArgOp->Asl.ExternalName, "\\_OSI")) + { + return (AE_OK); + } + /* The lone arg is a method call, check it */ RequiredBtypes = AnMapArgTypeToBtype (ARGI_INTEGER); @@ -1606,7 +1659,8 @@ AnOperandTypecheckWalkEnd ( { return (AE_OK); } - AnCheckMethodReturnValue (Op, OpInfo, ArgOp, RequiredBtypes, ThisNodeBtype); + AnCheckMethodReturnValue (Op, OpInfo, ArgOp, + RequiredBtypes, ThisNodeBtype); } return (AE_OK); @@ -1760,7 +1814,8 @@ AnOperandTypecheckWalkEnd ( { /* Check a method call for a valid return value */ - AnCheckMethodReturnValue (Op, OpInfo, ArgOp, RequiredBtypes, ThisNodeBtype); + AnCheckMethodReturnValue (Op, OpInfo, ArgOp, + RequiredBtypes, ThisNodeBtype); } /* @@ -1843,3 +1898,41 @@ AnOtherSemanticAnalysisWalkEnd ( return AE_OK; } + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AnMapBtypeToEtype + * + * PARAMETERS: Btype - Bitfield of ACPI types + * + * RETURN: The Etype corresponding the the Btype + * + * DESCRIPTION: Convert a bitfield type to an encoded type + * + ******************************************************************************/ + +UINT32 +AnMapBtypeToEtype ( + UINT32 Btype) +{ + UINT32 i; + UINT32 Etype; + + + if (Btype == 0) + { + return 0; + } + + Etype = 1; + for (i = 1; i < Btype; i *= 2) + { + Etype++; + } + + return (Etype); +} +#endif + diff --git a/sys/contrib/dev/acpica/compiler/aslcodegen.c b/sys/contrib/dev/acpica/compiler/aslcodegen.c index 6087bfb..234b17a 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: 51 $ + * $Revision: 1.57 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,13 +116,43 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" -#include "amlcode.h" +#include <contrib/dev/acpica/amlcode.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslcodegen") +/* Local prototypes */ + +static ACPI_STATUS +CgAmlWriteWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static void +CgLocalWriteAmlData ( + ACPI_PARSE_OBJECT *Op, + void *Buffer, + UINT32 Length); + +static void +CgWriteAmlOpcode ( + ACPI_PARSE_OBJECT *Op); + +static void +CgWriteTableHeader ( + ACPI_PARSE_OBJECT *Op); + +static void +CgCloseTable ( + void); + +static void +CgWriteNode ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -138,7 +168,8 @@ ******************************************************************************/ void -CgGenerateAmlOutput (void) +CgGenerateAmlOutput ( + void) { DbgPrint (ASL_DEBUG_OUTPUT, "\nWriting AML\n\n"); @@ -149,7 +180,8 @@ CgGenerateAmlOutput (void) Gbl_SourceLine = 0; Gbl_NextError = Gbl_ErrorLog; - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, CgAmlWriteWalk, NULL, NULL); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + CgAmlWriteWalk, NULL, NULL); CgCloseTable (); } @@ -166,16 +198,15 @@ CgGenerateAmlOutput (void) * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS CgAmlWriteWalk ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context) { - /* - * Debug output - */ + /* Debug output */ + DbgPrint (ASL_TREE_OUTPUT, "%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level); UtPrintFormattedName (Op->Asl.ParseOpcode, Level); @@ -210,9 +241,8 @@ CgAmlWriteWalk ( Op->Asl.Column, Op->Asl.LineNumber); - /* - * Generate the AML for this node - */ + /* Generate the AML for this node */ + CgWriteNode (Op); return (AE_OK); } @@ -222,7 +252,8 @@ CgAmlWriteWalk ( * * FUNCTION: CgLocalWriteAmlData * - * PARAMETERS: Buffer - Buffer to write + * PARAMETERS: Op - Current parse op + * Buffer - Buffer to write * Length - Size of data in buffer * * RETURN: None @@ -231,14 +262,13 @@ CgAmlWriteWalk ( * ******************************************************************************/ -void +static void CgLocalWriteAmlData ( ACPI_PARSE_OBJECT *Op, void *Buffer, UINT32 Length) { - /* Write the raw data to the AML file */ FlWriteFile (ASL_FILE_AML_OUTPUT, Buffer, Length); @@ -264,22 +294,21 @@ CgLocalWriteAmlData ( * ******************************************************************************/ -void +static void CgWriteAmlOpcode ( - ACPI_PARSE_OBJECT *Op) + ACPI_PARSE_OBJECT *Op) { + UINT8 PkgLenFirstByte; + UINT32 i; union { - UINT16 Opcode; - UINT8 OpcodeBytes[2]; + UINT16 Opcode; + UINT8 OpcodeBytes[2]; } Aml; union { - UINT32 Len; - UINT8 LenBytes[4]; + UINT32 Len; + UINT8 LenBytes[4]; } PkgLen; - UINT8 PkgLenFirstByte; - UINT32 i; - /* We expect some DEFAULT_ARGs, just ignore them */ @@ -360,13 +389,16 @@ CgWriteAmlOpcode ( * Encode the "bytes to follow" in the first byte, top two bits. * The low-order nybble of the length is in the bottom 4 bits */ - PkgLenFirstByte = (UINT8) (((UINT32) (Op->Asl.AmlPkgLenBytes - 1) << 6) | - (PkgLen.LenBytes[0] & 0x0F)); + PkgLenFirstByte = (UINT8) + (((UINT32) (Op->Asl.AmlPkgLenBytes - 1) << 6) | + (PkgLen.LenBytes[0] & 0x0F)); CgLocalWriteAmlData (Op, &PkgLenFirstByte, 1); - /* Shift the length over by the 4 bits we just stuffed in the first byte */ - + /* + * Shift the length over by the 4 bits we just stuffed + * in the first byte + */ PkgLen.Len >>= 4; /* Now we can write the remaining bytes - either 1, 2, or 3 bytes */ @@ -382,17 +414,17 @@ CgWriteAmlOpcode ( { case AML_BYTE_OP: - CgLocalWriteAmlData (Op, (UINT8 *) &Op->Asl.Value.Integer, 1); + CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 1); break; case AML_WORD_OP: - CgLocalWriteAmlData (Op, (UINT16 *) &Op->Asl.Value.Integer, 2); + CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 2); break; case AML_DWORD_OP: - CgLocalWriteAmlData (Op, (UINT32 *) &Op->Asl.Value.Integer, 4); + CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 4); break; case AML_QWORD_OP: @@ -418,17 +450,17 @@ CgWriteAmlOpcode ( * * PARAMETERS: Op - The DEFINITIONBLOCK node * - * RETURN: None. + * RETURN: None * * DESCRIPTION: Write a table header corresponding to the DEFINITIONBLOCK * ******************************************************************************/ -void +static void CgWriteTableHeader ( - ACPI_PARSE_OBJECT *Op) + ACPI_PARSE_OBJECT *Op) { - ACPI_PARSE_OBJECT *Child; + ACPI_PARSE_OBJECT *Child; /* AML filename */ @@ -475,7 +507,7 @@ CgWriteTableHeader ( TableHeader.AslCompilerRevision = CompilerCreatorRevision; - /* Table length. Checksum zero for now, will rewrite later */ + /* Table length. Checksum zero for now, will rewrite later */ TableHeader.Length = Gbl_TableLength; TableHeader.Checksum = 0; @@ -497,8 +529,9 @@ CgWriteTableHeader ( * ******************************************************************************/ -void -CgCloseTable (void) +static void +CgCloseTable ( + void) { signed char Sum; UINT8 FileByte; @@ -535,7 +568,7 @@ CgCloseTable (void) * ******************************************************************************/ -void +static void CgWriteNode ( ACPI_PARSE_OBJECT *Op) { diff --git a/sys/contrib/dev/acpica/compiler/aslcompile.c b/sys/contrib/dev/acpica/compiler/aslcompile.c index 73bcfcb..e6c2149 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompile.c +++ b/sys/contrib/dev/acpica/compiler/aslcompile.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslcompile - top level compile module - * $Revision: 73 $ + * $Revision: 1.88 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,11 +116,22 @@ *****************************************************************************/ #include <stdio.h> -#include "aslcompiler.h" +#include <time.h> +#include <contrib/dev/acpica/compiler/aslcompiler.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslcompile") +/* Local prototypes */ + +static void +CmFlushSourceCode ( + void); + +static ACPI_STATUS +FlCheckForAscii ( + ASL_FILE_INFO *FileInfo); + /******************************************************************************* * @@ -141,9 +152,8 @@ AslCompilerSignon ( char *Prefix = ""; - /* - * Set line prefix depending on the destination file type - */ + /* Set line prefix depending on the destination file type */ + switch (FileId) { case ASL_FILE_ASM_SOURCE_OUTPUT: @@ -176,15 +186,35 @@ AslCompilerSignon ( break; } - /* Compiler signon with copyright */ - + /* + * Compiler signon with copyright + */ FlPrintFile (FileId, - "%s\n%s%s\n%s%s version %X [%s]\n%s%s\n%sSupports ACPI Specification Revision 2.0c\n%s\n", + "%s\n%s%s\n%s", Prefix, Prefix, IntelAcpiCA, - Prefix, CompilerId, ACPI_CA_VERSION, __DATE__, + Prefix); + + /* Running compiler or disassembler? */ + + if (Gbl_DisasmFlag) + { + FlPrintFile (FileId, + "%s", DisassemblerId); + } + else + { + FlPrintFile (FileId, + "%s", CompilerId); + } + + /* Version, build date, copyright, compliance */ + + FlPrintFile (FileId, + " version %X [%s]\n%s%s\n%s%s\n%s\n", + (UINT32) ACPI_CA_VERSION, __DATE__, Prefix, CompilerCopyright, - Prefix, + Prefix, CompilerCompliance, Prefix); } @@ -210,9 +240,8 @@ AslCompilerFileHeader ( char *Prefix = ""; - /* - * Set line prefix depending on the destination file type - */ + /* Set line prefix depending on the destination file type */ + switch (FileId) { case ASL_FILE_ASM_SOURCE_OUTPUT: @@ -281,8 +310,9 @@ AslCompilerFileHeader ( * ******************************************************************************/ -void -CmFlushSourceCode (void) +static void +CmFlushSourceCode ( + void) { char Buffer; @@ -302,13 +332,13 @@ CmFlushSourceCode (void) * * PARAMETERS: FileInfo - Points to an open input file * - * RETURN: Status (0 = OK) + * RETURN: Status * * DESCRIPTION: Verify that the input file is entirely ASCII. * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS FlCheckForAscii ( ASL_FILE_INFO *FileInfo) { @@ -327,25 +357,32 @@ FlCheckForAscii ( { if (BadBytes < 10) { - AcpiOsPrintf ("Non-ASCII character: 0x%2.2X at offset 0x%X\n", Byte, Offset); + AcpiOsPrintf ( + "Non-ASCII character [0x%2.2X] found at file offset 0x%8.8X\n", + Byte, Offset); } BadBytes++; } Offset++; } + /* Seek back to the beginning of the source file */ + + fseek (FileInfo->Handle, 0, SEEK_SET); + /* Were there any non-ASCII characters in the file? */ if (BadBytes) { - AcpiOsPrintf ("%d non-ASCII characters found in input file, appears to be binary\n", BadBytes); - AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, FileInfo->Filename); + AcpiOsPrintf ( + "%d non-ASCII characters found in input file, could be a binary file\n", + BadBytes); + AslError (ASL_WARNING, ASL_MSG_NON_ASCII, NULL, FileInfo->Filename); return (AE_BAD_CHARACTER); } - /* File is OK, seek back to the beginning */ + /* File is OK */ - fseek (FileInfo->Handle, 0, SEEK_SET); return (AE_OK); } @@ -363,14 +400,16 @@ FlCheckForAscii ( ******************************************************************************/ int -CmDoCompile (void) +CmDoCompile ( + void) { ACPI_STATUS Status; - UINT32 i = 0; + UINT8 FullCompile; + UINT8 Event; - UtBeginEvent (12, "Total Compile time"); - UtBeginEvent (i, "Initialize"); + FullCompile = UtBeginEvent ("*** Total Compile time ***"); + Event = UtBeginEvent ("Open input and output files"); /* Open the required input and output files */ @@ -381,13 +420,19 @@ CmDoCompile (void) return -1; } - /* Ensure that the input file is 100% ASCII text */ + /* Optional check for 100% ASCII source file */ - Status = FlCheckForAscii (&Gbl_Files[ASL_FILE_INPUT]); - if (ACPI_FAILURE (Status)) + if (Gbl_CheckForAscii) { - AePrintErrorLog (ASL_FILE_STDERR); - return -1; + /* + * NOTE: This code is optional because there can be "special" characters + * embedded in comments (such as the "copyright" symbol, 0xA9). + * Just emit a warning if there are non-ascii characters present. + */ + + /* Check if the input file is 100% ASCII text */ + + Status = FlCheckForAscii (&Gbl_Files[ASL_FILE_INPUT]); } Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix); @@ -396,17 +441,17 @@ CmDoCompile (void) AePrintErrorLog (ASL_FILE_STDERR); return -1; } - - UtEndEvent (i++); + UtEndEvent (Event); /* Build the parse tree */ - UtBeginEvent (i, "Parse source code and build parse tree"); + Event = UtBeginEvent ("Parse source code and build parse tree"); AslCompilerparse(); - UtEndEvent (i++); + UtEndEvent (Event); /* Flush out any remaining source after parse tree is complete */ + Event = UtBeginEvent ("Flush source input"); CmFlushSourceCode (); /* Did the parse tree get successfully constructed? */ @@ -418,44 +463,63 @@ CmDoCompile (void) } OpcGetIntegerWidth (RootNode); + UtEndEvent (Event); /* Pre-process parse tree for any operator transforms */ - UtBeginEvent (i, "Generate AML opcodes"); + Event = UtBeginEvent ("Parse tree transforms"); DbgPrint (ASL_DEBUG_OUTPUT, "\nParse tree transforms\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, TrAmlTransformWalk, NULL, NULL); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + TrAmlTransformWalk, NULL, NULL); + UtEndEvent (Event); /* Generate AML opcodes corresponding to the parse tokens */ + Event = UtBeginEvent ("Generate AML opcodes"); DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating AML opcodes\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, OpcAmlOpcodeWalk, NULL); - UtEndEvent (i++); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + OpcAmlOpcodeWalk, NULL); + UtEndEvent (Event); /* * Now that the input is parsed, we can open the AML output file. * Note: by default, the name of this file comes from the table descriptor * within the input file. */ + Event = UtBeginEvent ("Open AML output file"); Status = FlOpenAmlOutputFile (Gbl_OutputFilenamePrefix); if (ACPI_FAILURE (Status)) { AePrintErrorLog (ASL_FILE_STDERR); return -1; } + UtEndEvent (Event); /* Interpret and generate all compile-time constants */ - UtBeginEvent (i, "Constant folding via AML interpreter"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nInterpreting compile-time constant expressions\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, OpcAmlConstantWalk, NULL, NULL); - UtEndEvent (i++); + Event = UtBeginEvent ("Constant folding via AML interpreter"); + DbgPrint (ASL_DEBUG_OUTPUT, + "\nInterpreting compile-time constant expressions\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_DOWNWARD, + OpcAmlConstantWalk, NULL, NULL); + UtEndEvent (Event); + + /* Update AML opcodes if necessary, after constant folding */ + + Event = UtBeginEvent ("Updating AML opcodes after constant folding"); + DbgPrint (ASL_DEBUG_OUTPUT, + "\nUpdating AML opcodes after constant folding\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, + NULL, OpcAmlOpcodeUpdateWalk, NULL); + UtEndEvent (Event); /* Calculate all AML package lengths */ - UtBeginEvent (i, "Generate AML package lengths"); + Event = UtBeginEvent ("Generate AML package lengths"); DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL); - UtEndEvent (i++); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + LnPackageLengthWalk, NULL); + UtEndEvent (Event); if (Gbl_ParseOnlyFlag) { @@ -477,9 +541,9 @@ CmDoCompile (void) /* Namespace loading */ - UtBeginEvent (i, "Create ACPI Namespace"); + Event = UtBeginEvent ("Create ACPI Namespace"); Status = LdLoadNamespace (RootNode); - UtEndEvent (i++); + UtEndEvent (Event); if (ACPI_FAILURE (Status)) { return -1; @@ -487,10 +551,9 @@ CmDoCompile (void) /* Namespace lookup */ - UtBeginEvent (i, "Cross reference parse tree and Namespace"); + AslGbl_NamespaceEvent = UtBeginEvent ("Cross reference parse tree and Namespace"); Status = LkCrossReferenceNamespace (); - UtEndEvent (i++); - UtEndEvent (i++); + UtEndEvent (AslGbl_NamespaceEvent); if (ACPI_FAILURE (Status)) { return -1; @@ -502,64 +565,83 @@ CmDoCompile (void) * * part one - check control methods */ - UtBeginEvent (i, "Analyze control method return types"); + Event = UtBeginEvent ("Analyze control method return types"); AnalysisWalkInfo.MethodStack = NULL; DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method analysis\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnMethodAnalysisWalkBegin, - AnMethodAnalysisWalkEnd, &AnalysisWalkInfo); - UtEndEvent (i++); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, + AnMethodAnalysisWalkBegin, + AnMethodAnalysisWalkEnd, &AnalysisWalkInfo); + UtEndEvent (Event); /* Semantic error checking part two - typing of method returns */ - UtBeginEvent (i, "Determine object types returned by methods"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing \n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnMethodTypingWalkBegin, - AnMethodTypingWalkEnd, NULL); - UtEndEvent (i++); + Event = UtBeginEvent ("Determine object types returned by methods"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Method typing\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, + AnMethodTypingWalkBegin, + AnMethodTypingWalkEnd, NULL); + UtEndEvent (Event); /* Semantic error checking part three - operand type checking */ - UtBeginEvent (i, "Analyze AML operand types"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking \n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnOperandTypecheckWalkBegin, - AnOperandTypecheckWalkEnd, &AnalysisWalkInfo); - UtEndEvent (i++); + Event = UtBeginEvent ("Analyze AML operand types"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - Operand type checking\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, + AnOperandTypecheckWalkBegin, + AnOperandTypecheckWalkEnd, &AnalysisWalkInfo); + UtEndEvent (Event); /* Semantic error checking part four - other miscellaneous checks */ - UtBeginEvent (i, "Miscellaneous analysis"); - DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous \n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, AnOtherSemanticAnalysisWalkBegin, - AnOtherSemanticAnalysisWalkEnd, &AnalysisWalkInfo); - UtEndEvent (i++); + Event = UtBeginEvent ("Miscellaneous analysis"); + DbgPrint (ASL_DEBUG_OUTPUT, "\nSemantic analysis - miscellaneous\n\n"); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_TWICE, + AnOtherSemanticAnalysisWalkBegin, + AnOtherSemanticAnalysisWalkEnd, &AnalysisWalkInfo); + UtEndEvent (Event); /* Calculate all AML package lengths */ - UtBeginEvent (i, "Finish AML package length generation"); + Event = UtBeginEvent ("Finish AML package length generation"); DbgPrint (ASL_DEBUG_OUTPUT, "\nGenerating Package lengths\n\n"); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnInitLengthsWalk, NULL); - TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, LnPackageLengthWalk, NULL); - UtEndEvent (i++); - + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + LnInitLengthsWalk, NULL); + TrWalkParseTree (RootNode, ASL_WALK_VISIT_UPWARD, NULL, + LnPackageLengthWalk, NULL); + UtEndEvent (Event); /* Code generation - emit the AML */ - UtBeginEvent (i, "Generate AML code and write output files"); + Event = UtBeginEvent ("Generate AML code and write output files"); CgGenerateAmlOutput (); - UtEndEvent (i++); + UtEndEvent (Event); - UtBeginEvent (i, "Write optional output files"); + Event = UtBeginEvent ("Write optional output files"); CmDoOutputFiles (); - UtEndEvent (i++); + UtEndEvent (Event); - UtEndEvent (13); + UtEndEvent (FullCompile); CmCleanupAndExit (); return 0; } + +/******************************************************************************* + * + * FUNCTION: CmDoOutputFiles + * + * PARAMETERS: None + * + * RETURN: None. + * + * DESCRIPTION: Create all "listing" type files + * + ******************************************************************************/ + void -CmDoOutputFiles (void) +CmDoOutputFiles ( + void) { /* Create listings and hex files */ @@ -569,7 +651,51 @@ CmDoOutputFiles (void) /* Dump the namespace to the .nsp file if requested */ - LsDisplayNamespace (); + (void) LsDisplayNamespace (); +} + + +/******************************************************************************* + * + * FUNCTION: CmDumpEvent + * + * PARAMETERS: Event - A compiler event struct + * + * RETURN: None. + * + * DESCRIPTION: Dump a compiler event struct + * + ******************************************************************************/ + +static void +CmDumpEvent ( + ASL_EVENT_INFO *Event) +{ + UINT32 Delta; + UINT32 USec; + UINT32 MSec; + + if (!Event->Valid) + { + return; + } + + /* Delta will be in 100-nanosecond units */ + + Delta = (UINT32) (Event->EndTime - Event->StartTime); + + USec = Delta / 10; + MSec = Delta / 10000; + + /* Round milliseconds up */ + + if ((USec - (MSec * 1000)) >= 500) + { + MSec++; + } + + DbgPrint (ASL_DEBUG_OUTPUT, "%8u usec %8u msec - %s\n", + USec, MSec, Event->EventName); } @@ -586,7 +712,8 @@ CmDoOutputFiles (void) ******************************************************************************/ void -CmCleanupAndExit (void) +CmCleanupAndExit ( + void) { UINT32 i; @@ -600,30 +727,19 @@ CmCleanupAndExit (void) } DbgPrint (ASL_DEBUG_OUTPUT, "\n\nElapsed time for major events\n\n"); - for (i = 0; i < 13; i++) + for (i = 0; i < AslGbl_NextEvent; i++) { - if (AslGbl_Events[i].Valid) - { - DbgPrint (ASL_DEBUG_OUTPUT, "%8lu ms - %s\n", - AslGbl_Events[i].EndTime - - AslGbl_Events[i].StartTime, - AslGbl_Events[i].EventName); - } + CmDumpEvent (&AslGbl_Events[i]); } if (Gbl_CompileTimesFlag) { printf ("\nElapsed time for major events\n\n"); - for (i = 0; i < 13; i++) + for (i = 0; i < AslGbl_NextEvent; i++) { - if (AslGbl_Events[i].Valid) - { - printf ("%8lu ms : %s\n", - AslGbl_Events[i].EndTime - - AslGbl_Events[i].StartTime, - AslGbl_Events[i].EventName); - } + CmDumpEvent (&AslGbl_Events[i]); } + printf ("\nMiscellaneous compile statistics\n\n"); printf ("%11u : %s\n", TotalParseNodes, "Parse nodes"); printf ("%11u : %s\n", Gbl_NsLookupCount, "Namespace searches"); @@ -638,10 +754,12 @@ CmCleanupAndExit (void) if (Gbl_NsLookupCount) { DbgPrint (ASL_DEBUG_OUTPUT, "\n\nMiscellaneous compile statistics\n\n"); - DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d\n", "Total Namespace searches", Gbl_NsLookupCount); - DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d\n", "Time per search", - ((UINT32) (AslGbl_Events[7].EndTime - AslGbl_Events[7].StartTime) * 1000) / - Gbl_NsLookupCount); + DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d\n", "Total Namespace searches", + Gbl_NsLookupCount); + DbgPrint (ASL_DEBUG_OUTPUT, "%32s : %d usec\n", "Time per search", + ((UINT32) (AslGbl_Events[AslGbl_NamespaceEvent].EndTime - + AslGbl_Events[AslGbl_NamespaceEvent].StartTime) / + 10) / Gbl_NsLookupCount); } /* Close all open files */ @@ -672,6 +790,11 @@ CmCleanupAndExit (void) } UtDisplaySummary (ASL_FILE_STDOUT); + + if (Gbl_ExceptionCount[ASL_ERROR] > 0) + { + exit (1); + } exit (0); } diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.h b/sys/contrib/dev/acpica/compiler/aslcompiler.h index 3da39af..d3216a6 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.h +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.h @@ -1,8 +1,8 @@ /****************************************************************************** * - * Module Name: aslcompiler.h - common include file - * $Revision: 130 $ + * Module Name: aslcompiler.h - common include file for iASL + * $Revision: 1.142 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -139,84 +139,15 @@ #include <ctype.h> -#include "acpi.h" -#include "amlresrc.h" -#include "acdebug.h" -#include "asltypes.h" -#include "aslglobal.h" +#include <contrib/dev/acpica/acpi.h> +#include <contrib/dev/acpica/amlresrc.h> +#include <contrib/dev/acpica/acdebug.h> +/* Compiler headers */ -/* - * Compiler versions and names - */ - -#define CompilerCreatorRevision ACPI_CA_VERSION - -#define IntelAcpiCA "Intel ACPI Component Architecture" -#define CompilerId "ASL Optimizing Compiler / AML Disassembler" -#define CompilerCopyright "Copyright (C) 2000 - 2004 Intel Corporation" -#define CompilerCompliance "ACPI 2.0c" -#define CompilerName "iasl" -#define CompilerCreatorId "INTL" - - -/* Configuration constants */ - -#define ASL_MAX_ERROR_COUNT 200 -#define ASL_NODE_CACHE_SIZE 1024 -#define ASL_STRING_CACHE_SIZE 32768 - -#define ASL_FIRST_PARSE_OPCODE PARSEOP_ACCESSAS -#define ASL_YYTNAME_START 3 - -/* - * Macros - */ - -#define ASL_RESDESC_OFFSET(m) ACPI_OFFSET (ASL_RESOURCE_DESC, m) -#define ASL_PTR_DIFF(a,b) ((UINT8 *)(b) - (UINT8 *)(a)) -#define ASL_PTR_ADD(a,b) ((UINT8 *)(a) = ((UINT8 *)(a) + (b))) -#define ASL_GET_CHILD_NODE(a) (a)->Asl.Child -#define ASL_GET_PEER_NODE(a) (a)->Asl.Next -#define OP_TABLE_ENTRY(a,b,c,d) {b,d,a,c} - - -#define ASL_PARSE_OPCODE_BASE PARSEOP_ACCESSAS /* First Lex type */ - - -/* Internal AML opcodes */ - -#define AML_RAW_DATA_BYTE (UINT16) 0xAA01 /* write one raw byte */ -#define AML_RAW_DATA_WORD (UINT16) 0xAA02 /* write 2 raw bytes */ -#define AML_RAW_DATA_DWORD (UINT16) 0xAA04 /* write 4 raw bytes */ -#define AML_RAW_DATA_QWORD (UINT16) 0xAA08 /* write 8 raw bytes */ -#define AML_RAW_DATA_BUFFER (UINT16) 0xAA0B /* raw buffer with length */ -#define AML_RAW_DATA_CHAIN (UINT16) 0xAA0C /* chain of raw buffers */ -#define AML_PACKAGE_LENGTH (UINT16) 0xAA10 -#define AML_UNASSIGNED_OPCODE (UINT16) 0xEEEE -#define AML_DEFAULT_ARG_OP (UINT16) 0xDDDD - - -/* filename suffixes for output files */ - -#define FILE_SUFFIX_AML_CODE "aml" -#define FILE_SUFFIX_LISTING "lst" -#define FILE_SUFFIX_HEX_DUMP "hex" -#define FILE_SUFFIX_DEBUG "txt" -#define FILE_SUFFIX_SOURCE "src" -#define FILE_SUFFIX_NAMESPACE "nsp" -#define FILE_SUFFIX_ASM_SOURCE "asm" -#define FILE_SUFFIX_C_SOURCE "c" -#define FILE_SUFFIX_DISASSEMBLY "dsl" -#define FILE_SUFFIX_ASM_INCLUDE "inc" -#define FILE_SUFFIX_C_INCLUDE "h" - - -/* Misc */ - -#define ASL_EXTERNAL_METHOD 255 -#define ASL_ABORT TRUE -#define ASL_NO_ABORT FALSE +#include <contrib/dev/acpica/compiler/asldefine.h> +#include <contrib/dev/acpica/compiler/asltypes.h> +#include <contrib/dev/acpica/compiler/aslglobal.h> /******************************************************************************* @@ -225,13 +156,9 @@ * ******************************************************************************/ - -void -end_stmt (void); - - -/* parser */ - +/* + * parser - generated from flex/bison, lex/yacc, etc. + */ int AslCompilerparse( void); @@ -241,10 +168,6 @@ AslDoError ( void); int -AslCompilererror( - char *s); - -int AslCompilerlex( void); @@ -265,8 +188,10 @@ AslPushInputFileStack ( FILE *InputFile, char *Filename); -/* aslmain */ +/* + * aslcompile - compile mainline + */ void AslCompilerSignon ( UINT32 FileId); @@ -275,38 +200,74 @@ void AslCompilerFileHeader ( UINT32 FileId); +int +CmDoCompile ( + void); + void -AslDoSourceOutputFile ( - char *Buffer); +CmDoOutputFiles ( + void); -#define ASL_DEBUG_OUTPUT 0 -#define ASL_PARSE_OUTPUT 1 -#define ASL_TREE_OUTPUT 2 +void +CmCleanupAndExit ( + void); -void -DbgPrint ( - UINT32 Type, - char *Format, - ...); +/* + * aslanalyze - semantic analysis + */ +ACPI_STATUS +AnOtherSemanticAnalysisWalkBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); -void -ErrorContext (void); +ACPI_STATUS +AnOtherSemanticAnalysisWalkEnd ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); -/* aslcompile */ +ACPI_STATUS +AnOperandTypecheckWalkBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); -int -CmDoCompile (void); +ACPI_STATUS +AnOperandTypecheckWalkEnd ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); -void -CmDoOutputFiles (void); +ACPI_STATUS +AnMethodAnalysisWalkBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); -void -CmCleanupAndExit (void); +ACPI_STATUS +AnMethodAnalysisWalkEnd ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); +ACPI_STATUS +AnMethodTypingWalkBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +ACPI_STATUS +AnMethodTypingWalkEnd ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); -/* aslerror */ +/* + * aslerror - error handling/reporting + */ void AslError ( UINT8 Level, @@ -321,6 +282,10 @@ AslCoreSubsystemError ( char *ExtraMessage, BOOLEAN Abort); +int +AslCompilererror( + char *s); + void AslCommonError ( UINT8 Level, @@ -348,18 +313,12 @@ AeLocalGetRootPointer ( ACPI_PHYSICAL_ADDRESS *RsdpPhysicalAddress); -/* asllisting */ - -void -LsWriteListingHexBytes ( - UINT8 *Buffer, - UINT32 Length, - UINT32 FileId); - +/* + * asllisting - generate all "listing" type files + */ void -LsWriteNodeToListing ( - ACPI_PARSE_OBJECT *Op, - UINT32 FileId); +LsDoListings ( + void); void LsWriteNodeToAsmListing ( @@ -371,38 +330,23 @@ LsWriteNode ( UINT32 FileId); void -LsFinishSourceListing ( - UINT32 FileId); - -void -LsFlushListingBuffer ( - UINT32 FileId); - -void LsDoHexOutput ( void); -void -LsDoHexOutputC ( - void); -void -LsDoHexOutputAsm ( - void); - -void -LsPushNode ( - char *Filename); - -ASL_LISTING_NODE * -LsPopNode ( - void); +/* + * aslfold - constant folding + */ +ACPI_STATUS +OpcAmlConstantWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); /* * aslopcodes - generate AML opcodes */ - ACPI_STATUS OpcAmlOpcodeWalk ( ACPI_PARSE_OBJECT *Op, @@ -410,7 +354,7 @@ OpcAmlOpcodeWalk ( void *Context); ACPI_STATUS -OpcAmlConstantWalk ( +OpcAmlOpcodeUpdateWalk ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context); @@ -427,59 +371,27 @@ void OpcGetIntegerWidth ( ACPI_PARSE_OBJECT *Op); + /* * asloperands - generate AML operands for the AML opcodes */ +ACPI_PARSE_OBJECT * +UtGetArg ( + ACPI_PARSE_OBJECT *Op, + UINT32 Argn); void OpnGenerateAmlOperands ( ACPI_PARSE_OBJECT *Op); void -OpnDoField ( - ACPI_PARSE_OBJECT *Op); - -void -OpnDoBankField ( - ACPI_PARSE_OBJECT *Op); - -void -OpnDoBuffer ( - ACPI_PARSE_OBJECT *Op); - -void -OpnDoDefinitionBlock ( - ACPI_PARSE_OBJECT *Op); - -void -OpnDoFieldCommon ( - ACPI_PARSE_OBJECT *FieldOp, - ACPI_PARSE_OBJECT *Op); - -void -OpnDoIndexField ( - ACPI_PARSE_OBJECT *Op); - -void -OpnDoLoadTable ( - ACPI_PARSE_OBJECT *Op); - -void -OpnDoMethod ( - ACPI_PARSE_OBJECT *Op); - -void OpnDoPackage ( ACPI_PARSE_OBJECT *Op); -void -OpnDoRegion ( - ACPI_PARSE_OBJECT *Op); /* * aslopt - optmization */ - void OptOptimizeNamePath ( ACPI_PARSE_OBJECT *Op, @@ -490,35 +402,16 @@ OptOptimizeNamePath ( /* - * aslresource - resource template generation + * aslcodegen - code generation */ - -void -RsDoResourceTemplate ( - ACPI_PARSE_OBJECT *Op); - - -void -CgGenerateAmlOutput (void); - -void -CgGenerateListing ( - UINT32 FileId); - void -LsDoListings (void); - -void -CgGenerateAmlLengths ( - ACPI_PARSE_OBJECT *Op); - -ACPI_STATUS -CgOpenOutputFile ( - char *InputFilename); - +CgGenerateAmlOutput ( + void); -/* asllength */ +/* + * asllength - calculate/adjust AML package lengths + */ ACPI_STATUS LnPackageLengthWalk ( ACPI_PARSE_OBJECT *Op, @@ -531,37 +424,26 @@ LnInitLengthsWalk ( UINT32 Level, void *Context); - -ACPI_STATUS -CgAmlWriteWalk ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -void -CgGenerateOutput( - void); - -void -CgCloseTable (void); - - void -CgWriteNode ( +CgGenerateAmlLengths ( ACPI_PARSE_OBJECT *Op); + /* - * aslmap + * aslmap - opcode mappings and reserved method names */ - ACPI_OBJECT_TYPE AslMapNamedOpcodeToDataType ( UINT16 Opcode); +void +MpDisplayReservedNames ( + void); + + /* * asltransform - parse tree transformations */ - ACPI_STATUS TrAmlTransformWalk ( ACPI_PARSE_OBJECT *Op, @@ -569,22 +451,9 @@ TrAmlTransformWalk ( void *Context); -void -TrTransformSubtree ( - ACPI_PARSE_OBJECT *Op); - -void -TrDoSwitch ( - ACPI_PARSE_OBJECT *Op); - -void -TrDoDefinitionBlock ( - ACPI_PARSE_OBJECT *Op); - /* * asltree - parse tree support */ - ACPI_STATUS TrWalkParseTree ( ACPI_PARSE_OBJECT *Op, @@ -593,11 +462,6 @@ TrWalkParseTree ( ASL_WALK_CALLBACK AscendingCallback, void *Context); -ACPI_PARSE_OBJECT * -TrAllocateNode ( - UINT32 ParseOpcode); - - /* Values for "Visitation" parameter above */ #define ASL_WALK_VISIT_DOWNWARD 0x01 @@ -605,9 +469,13 @@ TrAllocateNode ( #define ASL_WALK_VISIT_TWICE (ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_UPWARD) -char * -TrAddNode ( - void *Thing); +ACPI_PARSE_OBJECT * +TrAllocateNode ( + UINT32 ParseOpcode); + +void +TrReleaseNode ( + ACPI_PARSE_OBJECT *Op); ACPI_PARSE_OBJECT * TrUpdateNode ( @@ -640,7 +508,8 @@ TrSetEndLineNumber ( ACPI_PARSE_OBJECT *Op); void -TrWalkTree (void); +TrWalkTree ( + void); ACPI_PARSE_OBJECT * TrLinkPeerNode ( @@ -662,72 +531,13 @@ TrLinkPeerNodes ( UINT32 NumPeers, ...); -void -TrReleaseNode ( - ACPI_PARSE_OBJECT *Op); - -/* Analyze */ - -ACPI_STATUS -AnOtherSemanticAnalysisWalkBegin ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -ACPI_STATUS -AnOtherSemanticAnalysisWalkEnd ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -ACPI_STATUS -AnOperandTypecheckWalkBegin ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -ACPI_STATUS -AnOperandTypecheckWalkEnd ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -ACPI_STATUS -AnMethodAnalysisWalkBegin ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -ACPI_STATUS -AnMethodAnalysisWalkEnd ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -ACPI_STATUS -AnMethodTypingWalkBegin ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -ACPI_STATUS -AnMethodTypingWalkEnd ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - /* * aslfiles - File I/O support */ - void -AslAbort (void); - -FILE * -FlOpenLocalFile ( - char *LocalName, - char *Mode); +AslAbort ( + void); void FlOpenIncludeFile ( @@ -738,12 +548,6 @@ FlFileError ( UINT32 FileId, UINT8 ErrorId); -void -FlOpenFile ( - UINT32 FileId, - char *Filename, - char *Mode); - ACPI_STATUS FlReadFile ( UINT32 FileId, @@ -776,10 +580,6 @@ FlSetLineNumber ( ACPI_PARSE_OBJECT *Op); ACPI_STATUS -FlParseInputPathname ( - char *InputFilename); - -ACPI_STATUS FlOpenInputFile ( char *InputFilename); @@ -791,74 +591,53 @@ ACPI_STATUS FlOpenMiscOutputFiles ( char *InputFilename); -void -MpDisplayReservedNames ( - void); - - -/* Load */ +/* + * asload - load namespace in prep for cross reference + */ ACPI_STATUS LdLoadNamespace ( ACPI_PARSE_OBJECT *RootOp); +/* + * asllookup - namespace cross reference + */ ACPI_STATUS -LdNamespace1Begin ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -ACPI_STATUS -LdNamespace1End ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - - -/* Lookup */ - -ACPI_STATUS -LkCrossReferenceNamespace (void); - -ACPI_STATUS -LkNamespaceLocateBegin ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); - -ACPI_STATUS -LkNamespaceLocateEnd ( - ACPI_PARSE_OBJECT *Op, - UINT32 Level, - void *Context); +LkCrossReferenceNamespace ( + void); ACPI_STATUS LsDisplayNamespace ( void); -ACPI_STATUS -LsCompareOneNamespaceObject ( - ACPI_HANDLE ObjHandle, - UINT32 Level, - void *Context, - void **ReturnValue); +/* + * aslutils - common compiler utilites + */ +void +DbgPrint ( + UINT32 Type, + char *Format, + ...); -/* Utils */ +/* Type values for above */ + +#define ASL_DEBUG_OUTPUT 0 +#define ASL_PARSE_OUTPUT 1 +#define ASL_TREE_OUTPUT 2 void UtDisplayConstantOpcodes ( void); -void +UINT8 UtBeginEvent ( - UINT32 Event, char *Name); void UtEndEvent ( - UINT32 Event); + UINT8 Event); void * UtLocalCalloc ( @@ -875,7 +654,7 @@ UtDisplaySummary ( UINT8 UtHexCharToValue ( - int hc); + int HexChar); void UtConvertByteToHex ( @@ -895,11 +674,6 @@ void UtSetParseOpName ( ACPI_PARSE_OBJECT *Op); -ACPI_PARSE_OBJECT * -UtGetArg ( - ACPI_PARSE_OBJECT *Op, - UINT32 Argn); - char * UtGetStringBuffer ( UINT32 Length); @@ -920,39 +694,19 @@ UtCheckIntegerRange ( UINT32 LowValue, UINT32 HighValue); -ACPI_STATUS -UtStrtoul64 ( - char *String, - UINT32 Base, - ACPI_INTEGER *RetInteger); - ACPI_INTEGER UtDoConstant ( char *String); -/* Find */ - -void -LnAdjustLengthToRoot ( - ACPI_PARSE_OBJECT *Op, - UINT32 LengthDelta); - - -#define NEXT_RESOURCE_DESC(a,b) (ASL_RESOURCE_DESC *) (((char *) (a)) + sizeof(b)) - -#define DEFAULT_RESOURCE_DESC_SIZE (sizeof (ASL_RESOURCE_DESC) + sizeof (ASL_END_TAG_DESC)) - - /* - * Resource utilities + * aslresource - Resource template generation utilities */ - ASL_RESOURCE_NODE * RsAllocateResourceNode ( UINT32 Size); - void +void RsCreateBitField ( ACPI_PARSE_OBJECT *Op, char *Name, @@ -976,12 +730,18 @@ ACPI_PARSE_OBJECT * RsCompleteNodeAndGetNext ( ACPI_PARSE_OBJECT *Op); +void +RsCheckListForDuplicates ( + ACPI_PARSE_OBJECT *Op); + ASL_RESOURCE_NODE * RsDoOneResourceDescriptor ( ACPI_PARSE_OBJECT *DescriptorTypeOp, UINT32 CurrentByteOffset, UINT8 *State); +/* Values for State above */ + #define ACPI_RSTATE_NORMAL 0 #define ACPI_RSTATE_START_DEPENDENT 1 #define ACPI_RSTATE_DEPENDENT_LIST 2 @@ -991,11 +751,14 @@ RsLinkDescriptorChain ( ASL_RESOURCE_NODE **PreviousRnode, ASL_RESOURCE_NODE *Rnode); +void +RsDoResourceTemplate ( + ACPI_PARSE_OBJECT *Op); + /* - * Small descriptors + * aslrestype1 - generate Small descriptors */ - ASL_RESOURCE_NODE * RsDoDmaDescriptor ( ACPI_PARSE_OBJECT *Op, @@ -1012,11 +775,6 @@ RsDoFixedIoDescriptor ( UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * -RsDoInterruptDescriptor ( - ACPI_PARSE_OBJECT *Op, - UINT32 CurrentByteOffset); - -ASL_RESOURCE_NODE * RsDoIoDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); @@ -1063,12 +821,12 @@ RsDoVendorSmallDescriptor ( /* - * Large descriptors + * aslrestype2 - generate Large descriptors */ - -UINT32 -RsGetStringDataLength ( - ACPI_PARSE_OBJECT *InitializerOp); +ASL_RESOURCE_NODE * +RsDoInterruptDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * RsDoDwordIoDescriptor ( @@ -1081,6 +839,26 @@ RsDoDwordMemoryDescriptor ( UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * +RsDoDwordSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + +ASL_RESOURCE_NODE * +RsDoExtendedIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + +ASL_RESOURCE_NODE * +RsDoExtendedMemoryDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + +ASL_RESOURCE_NODE * +RsDoExtendedSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + +ASL_RESOURCE_NODE * RsDoQwordIoDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); @@ -1091,11 +869,21 @@ RsDoQwordMemoryDescriptor ( UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * +RsDoQwordSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + +ASL_RESOURCE_NODE * RsDoWordIoDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); ASL_RESOURCE_NODE * +RsDoWordSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset); + +ASL_RESOURCE_NODE * RsDoWordBusNumberDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); @@ -1110,6 +898,5 @@ RsDoGeneralRegisterDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset); - #endif /* __ASLCOMPILER_H */ diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.l b/sys/contrib/dev/acpica/compiler/aslcompiler.l index dbef089..e5eb3c5 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.l +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.l @@ -3,7 +3,7 @@ /****************************************************************************** * * Module Name: aslcompiler.l - Flex input file - * $Revision: $ + * $Revision: 1.74 $ * *****************************************************************************/ @@ -11,7 +11,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -119,7 +119,7 @@ #include <stdlib.h> #include <string.h> -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" YYSTYPE AslCompilerlval; @@ -357,6 +357,7 @@ NamePathTail [.]{NameSeg} "MutexObj" { count (0); return (PARSEOP_OBJECTTYPE_MTX); } "OpRegionObj" { count (0); return (PARSEOP_OBJECTTYPE_OPR); } "PowerResObj" { count (0); return (PARSEOP_OBJECTTYPE_POW); } +"ProcessorObj" { count (0); return (PARSEOP_OBJECTTYPE_PRO); } "ThermalZoneObj" { count (0); return (PARSEOP_OBJECTTYPE_THZ); } "BuffFieldObj" { count (0); return (PARSEOP_OBJECTTYPE_BFF); } "DDBHandleObj" { count (0); return (PARSEOP_OBJECTTYPE_DDB); } @@ -476,7 +477,7 @@ NamePathTail [.]{NameSeg} if (strcmp (AslCompilertext, "\\")) { strcpy (s, "____"); - ACPI_STRUPR (AslCompilertext); + AcpiUtStrupr (AslCompilertext); } memcpy (s, AslCompilertext, strlen (AslCompilertext)); AslCompilerlval.s = s; @@ -486,7 +487,7 @@ NamePathTail [.]{NameSeg} {NameString} { char *s; count (0); s=malloc (strlen (AslCompilertext)+1); - ACPI_STRUPR (AslCompilertext); + AcpiUtStrupr (AslCompilertext); strcpy (s, AslCompilertext); s[strlen (AslCompilertext)] = 0; AslCompilerlval.s = s; @@ -931,6 +932,7 @@ literal (void) UINT32 State = ASL_NORMAL_CHAR; UINT32 i = 0; UINT8 Digit; + UINT8 StringLength = 0; char ConvertBuffer[4]; @@ -942,6 +944,17 @@ literal (void) InsertLineBuffer ('\"'); while ((StringChar = (char) input()) != EOF) { + StringLength++; + if (StringLength == ACPI_MAX_STRING_CONVERSION) + { + /* Emit error only once, but keep going */ + + AslCommonError (ASL_ERROR, ASL_MSG_STRING_LENGTH, + Gbl_CurrentLineNumber, Gbl_LogicalLineNumber, + Gbl_CurrentLineOffset, Gbl_CurrentColumn, + Gbl_Files[ASL_FILE_INPUT].Filename, NULL); + } + InsertLineBuffer (StringChar); DoCharacter: diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.y b/sys/contrib/dev/acpica/compiler/aslcompiler.y index dec6d33..d7d9773 100644 --- a/sys/contrib/dev/acpica/compiler/aslcompiler.y +++ b/sys/contrib/dev/acpica/compiler/aslcompiler.y @@ -3,7 +3,7 @@ /****************************************************************************** * * Module Name: aslcompiler.y - Bison input file (ASL grammar and actions) - * $Revision: $ + * $Revision: 1.92 $ * *****************************************************************************/ @@ -11,7 +11,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,11 +124,11 @@ */ #define YYINITDEPTH 600 -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "acpi.h" +#include <contrib/dev/acpica/acpi.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslparse") @@ -353,6 +353,7 @@ AslLocalAllocate (unsigned int Size); %token <i> PARSEOP_OBJECTTYPE_OPR %token <i> PARSEOP_OBJECTTYPE_PKG %token <i> PARSEOP_OBJECTTYPE_POW +%token <i> PARSEOP_OBJECTTYPE_PRO %token <i> PARSEOP_OBJECTTYPE_STR %token <i> PARSEOP_OBJECTTYPE_THZ %token <i> PARSEOP_OBJECTTYPE_UNK @@ -611,6 +612,7 @@ AslLocalAllocate (unsigned int Size); %type <n> XOrTerm %type <n> OptionalTermArg +%type <n> OptionalReturnArg %type <n> OptionalListString @@ -626,7 +628,7 @@ AslLocalAllocate (unsigned int Size); %type <n> MatchOpKeyword %type <n> SerializeRuleKeyword %type <n> DMATypeKeyword -%type <n> BusMasterKeyword +%type <n> OptionalBusMasterKeyword %type <n> XferTypeKeyword %type <n> ResourceTypeKeyword %type <n> MinKeyword @@ -634,7 +636,7 @@ AslLocalAllocate (unsigned int Size); %type <n> DecodeKeyword %type <n> RangeTypeKeyword %type <n> MemTypeKeyword -%type <n> ReadWriteKeyword +%type <n> OptionalReadWriteKeyword %type <n> InterruptTypeKeyword %type <n> InterruptLevel %type <n> ShareTypeKeyword @@ -679,7 +681,6 @@ AslLocalAllocate (unsigned int Size); %type <n> DWordListTail %type <n> PackageTerm -%type <n> PackageLengthTerm %type <n> PackageList %type <n> PackageListTail %type <n> PackageElement @@ -756,6 +757,7 @@ AslLocalAllocate (unsigned int Size); %type <n> OptionalParameterTypePackage %type <n> OptionalParameterTypesPackage %type <n> OptionalReference +%type <n> OptionalAccessSize %type <n> TermArgItem @@ -793,7 +795,7 @@ DefinitionBlockTerm String ',' DWordConst ')' {TrSetEndLineNumber ($<n>3);} - '{' ObjectList '}' {$$ = TrLinkChildren ($<n>3,7,$4,$6,$8,$10,$12,$14,$18);} + '{' TermList '}' {$$ = TrLinkChildren ($<n>3,7,$4,$6,$8,$10,$12,$14,$18);} ; /* ACPI 3.0 -- allow semicolons between terms */ @@ -938,19 +940,23 @@ SimpleTarget /* Rules for specifying the Return type for control methods */ -ParameterTypePackageList +ParameterTypePackage : {$$ = NULL;} | ObjectTypeKeyword {$$ = $1;} - | ObjectTypeKeyword ',' - ParameterTypePackageList {$$ = TrLinkPeerNodes (2,$1,$3);} + | '{''}' {$$ = NULL;} + | '{' + ObjectTypeKeyword + '}' {$$ = $2;} + | '{' + ParameterTypePackageList + '}' {$$ = $2;} ; -ParameterTypePackage +ParameterTypePackageList : {$$ = NULL;} | ObjectTypeKeyword {$$ = $1;} - | '{' - ParameterTypePackageList - '}' {$$ = $2;} + | ObjectTypeKeyword ',' + ParameterTypePackageList {$$ = TrLinkPeerNodes (2,$1,$3);} ; OptionalParameterTypePackage @@ -961,25 +967,32 @@ OptionalParameterTypePackage /* Rules for specifying the Argument types for control methods */ -ParameterTypesPackageList +ParameterTypesPackage : {$$ = NULL;} | ObjectTypeKeyword {$$ = $1;} - | ObjectTypeKeyword ',' - ParameterTypesPackage {$$ = TrLinkPeerNodes (2,$1,$3);} + | '{''}' {$$ = NULL;} + | '{' + ObjectTypeKeyword + '}' {$$ = $2;} + | '{' + ParameterTypesPackageList + '}' {$$ = $2;} ; -ParameterTypesPackage +ParameterTypesPackageList : {$$ = NULL;} | ObjectTypeKeyword {$$ = $1;} - | '{' - ParameterTypesPackageList - '}' {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} + | ParameterTypesPackage {$$ = $1;} + | ParameterTypesPackage ',' + ParameterTypesPackageList {$$ = TrLinkPeerNodes (2,$1,$3);} + | ParameterTypesPackage ',' + ParameterTypesPackage {$$ = TrLinkPeerNodes (2,$1,$3);} ; OptionalParameterTypesPackage : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} | ',' {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} - | ',' ParameterTypesPackage {$$ = $2;} + | ',' ParameterTypesPackage {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_DEFAULT_ARG),1,$2);} ; @@ -1153,7 +1166,7 @@ BankFieldTerm ')' '{' FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,7,$4,$5,$6,$8,$10,$12,$15);} | PARSEOP_BANKFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} + error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} ; FieldUnitList @@ -1296,7 +1309,7 @@ FieldTerm ')' '{' FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$8,$10,$13);} | PARSEOP_FIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} + error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} ; FunctionTerm @@ -1306,8 +1319,8 @@ FunctionTerm OptionalParameterTypesPackage ')' '{' TermList '}' {$$ = TrLinkChildren ($<n>3,7,TrSetNodeFlags ($4, NODE_IS_NAME_DECLARATION), - TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0), - TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL), + TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0), + TrCreateLeafNode (PARSEOP_SERIALIZERULE_NOTSERIAL), TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0),$5,$6,$9);} | PARSEOP_FUNCTION '(' error ')' {$$ = AslDoError(); yyclearin;} @@ -1323,7 +1336,7 @@ IndexFieldTerm ')' '{' FieldUnitList '}' {$$ = TrLinkChildren ($<n>3,6,$4,$5,$7,$9,$11,$14);} | PARSEOP_INDEXFIELD '(' - error ')' {$$ = AslDoError(); yyclearin;} + error ')' '{' error '}' {$$ = AslDoError(); yyclearin;} ; MethodTerm @@ -1526,9 +1539,9 @@ ResetTerm ReturnTerm : PARSEOP_RETURN '(' {$$ = TrCreateLeafNode (PARSEOP_RETURN);} - OptionalTermArg + OptionalReturnArg ')' {$$ = TrLinkChildren ($<n>3,1,$4);} - | PARSEOP_RETURN {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),0);} + | PARSEOP_RETURN {$$ = TrLinkChildren (TrCreateLeafNode (PARSEOP_RETURN),1,TrCreateLeafNode (PARSEOP_ZERO));} | PARSEOP_RETURN '(' error ')' {$$ = AslDoError(); yyclearin;} ; @@ -2107,6 +2120,7 @@ ObjectTypeKeyword | PARSEOP_OBJECTTYPE_MTX {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_MTX);} | PARSEOP_OBJECTTYPE_OPR {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_OPR);} | PARSEOP_OBJECTTYPE_POW {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_POW);} + | PARSEOP_OBJECTTYPE_PRO {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_PRO);} | PARSEOP_OBJECTTYPE_THZ {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_THZ);} | PARSEOP_OBJECTTYPE_BFF {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_BFF);} | PARSEOP_OBJECTTYPE_DDB {$$ = TrCreateLeafNode (PARSEOP_OBJECTTYPE_DDB);} @@ -2181,11 +2195,6 @@ DMATypeKeyword | PARSEOP_DMATYPE_F {$$ = TrCreateLeafNode (PARSEOP_DMATYPE_F);} ; -BusMasterKeyword - : PARSEOP_BUSMASTERTYPE_MASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} - | PARSEOP_BUSMASTERTYPE_NOTMASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_NOTMASTER);} - ; - XferTypeKeyword : PARSEOP_XFERTYPE_8 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8);} | PARSEOP_XFERTYPE_8_16 {$$ = TrCreateLeafNode (PARSEOP_XFERTYPE_8_16);} @@ -2225,8 +2234,9 @@ MemTypeKeyword | PARSEOP_MEMTYPE_NONCACHEABLE {$$ = TrCreateLeafNode (PARSEOP_MEMTYPE_NONCACHEABLE);} ; -ReadWriteKeyword - : PARSEOP_READWRITETYPE_BOTH {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} +OptionalReadWriteKeyword + : {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} + | PARSEOP_READWRITETYPE_BOTH {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_BOTH);} | PARSEOP_READWRITETYPE_READONLY {$$ = TrCreateLeafNode (PARSEOP_READWRITETYPE_READONLY);} ; @@ -2419,11 +2429,7 @@ DWordListTail ; PackageTerm - : PARSEOP_PACKAGE '(' {$$ = TrCreateLeafNode (PARSEOP_PACKAGE);} - PackageLengthTerm - ')' '{' - PackageList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} - | PARSEOP_PACKAGE '(' {$$ = TrCreateLeafNode (PARSEOP_VAR_PACKAGE);} + : PARSEOP_PACKAGE '(' {$$ = TrCreateLeafNode (PARSEOP_VAR_PACKAGE);} VarPackageLengthTerm ')' '{' PackageList '}' {$$ = TrLinkChildren ($<n>3,2,$4,$7);} @@ -2431,13 +2437,9 @@ PackageTerm error ')' {$$ = AslDoError(); yyclearin;} ; -PackageLengthTerm - : {$$ = NULL;} - | ByteConstExpr {} - ; - VarPackageLengthTerm - : TermArg {} + : {$$ = TrCreateLeafNode (PARSEOP_DEFAULT_ARG);} + | TermArg {$$ = $1;} ; PackageList @@ -2524,11 +2526,11 @@ ResourceMacroTerm DMATerm : PARSEOP_DMA '(' {$$ = TrCreateLeafNode (PARSEOP_DMA);} DMATypeKeyword - ',' BusMasterKeyword + OptionalBusMasterKeyword ',' XferTypeKeyword OptionalNameString_Last ')' '{' - ByteList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$8,$9,$12);} + ByteList '}' {$$ = TrLinkChildren ($<n>3,5,$4,$5,$7,$8,$11);} | PARSEOP_DMA '(' error ')' {$$ = AslDoError(); yyclearin;} ; @@ -2562,7 +2564,7 @@ DWordMemoryTerm OptionalMinType OptionalMaxType OptionalMemType - ',' ReadWriteKeyword + ',' OptionalReadWriteKeyword ',' DWordConstExpr ',' DWordConstExpr ',' DWordConstExpr @@ -2635,7 +2637,7 @@ ExtendedMemoryTerm OptionalMinType OptionalMaxType OptionalMemType - ',' ReadWriteKeyword + ',' OptionalReadWriteKeyword ',' QWordConstExpr ',' QWordConstExpr ',' QWordConstExpr @@ -2731,7 +2733,7 @@ IRQTerm Memory24Term : PARSEOP_MEMORY24 '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY24);} - ReadWriteKeyword + OptionalReadWriteKeyword ',' WordConstExpr ',' WordConstExpr ',' WordConstExpr @@ -2744,7 +2746,7 @@ Memory24Term Memory32FixedTerm : PARSEOP_MEMORY32FIXED '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY32FIXED);} - ReadWriteKeyword + OptionalReadWriteKeyword ',' DWordConstExpr ',' DWordConstExpr OptionalNameString_Last @@ -2755,7 +2757,7 @@ Memory32FixedTerm Memory32Term : PARSEOP_MEMORY32 '(' {$$ = TrCreateLeafNode (PARSEOP_MEMORY32);} - ReadWriteKeyword + OptionalReadWriteKeyword ',' DWordConstExpr ',' DWordConstExpr ',' DWordConstExpr @@ -2795,7 +2797,7 @@ QWordMemoryTerm OptionalMinType OptionalMaxType OptionalMemType - ',' ReadWriteKeyword + ',' OptionalReadWriteKeyword ',' QWordConstExpr ',' QWordConstExpr ',' QWordConstExpr @@ -2838,7 +2840,8 @@ RegisterTerm ',' ByteConstExpr ',' ByteConstExpr ',' QWordConstExpr - ')' {$$ = TrLinkChildren ($<n>3,4,$4,$6,$8,$10);} + OptionalAccessSize + ')' {$$ = TrLinkChildren ($<n>3,5,$4,$6,$8,$10,$11);} | PARSEOP_REGISTER '(' error ')' {$$ = AslDoError(); yyclearin;} ; @@ -2962,6 +2965,12 @@ AmlPackageLengthTerm : Integer {$$ = TrUpdateNode (PARSEOP_PACKAGE_LENGTH,(ACPI_PARSE_OBJECT *) $1);} ; +OptionalBusMasterKeyword + : ',' {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} + | ',' PARSEOP_BUSMASTERTYPE_MASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_MASTER);} + | ',' PARSEOP_BUSMASTERTYPE_NOTMASTER {$$ = TrCreateLeafNode (PARSEOP_BUSMASTERTYPE_NOTMASTER);} + ; + OptionalAccessAttribTerm : {$$ = NULL;} | ',' {$$ = NULL;} @@ -2969,6 +2978,12 @@ OptionalAccessAttribTerm | ',' AccessAttribKeyword {$$ = $2;} ; +OptionalAccessSize + : {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} + | ',' {$$ = TrCreateValuedLeafNode (PARSEOP_BYTECONST, 0);} + | ',' ByteConstExpr {$$ = $2;} + ; + OptionalAddressRange : {$$ = NULL;} | ',' {$$ = NULL;} @@ -3087,6 +3102,11 @@ OptionalTermArg | TermArg {$$ = $1;} ; +OptionalReturnArg + : {$$ = TrCreateLeafNode (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */ + | TermArg {$$ = $1;} + ; + OptionalType : {$$ = NULL;} | ',' {$$ = NULL;} diff --git a/sys/contrib/dev/acpica/compiler/asldefine.h b/sys/contrib/dev/acpica/compiler/asldefine.h new file mode 100644 index 0000000..0f3a2f4 --- /dev/null +++ b/sys/contrib/dev/acpica/compiler/asldefine.h @@ -0,0 +1,211 @@ + +/****************************************************************************** + * + * Module Name: asldefine.h - Common defines for the iASL compiler + * $Revision: 1.4 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#ifndef __ASLDEFINE_H +#define __ASLDEFINE_H + + +/* + * Compiler versions and names + */ +#define CompilerCreatorRevision ACPI_CA_VERSION + +#define IntelAcpiCA "Intel ACPI Component Architecture" +#define CompilerId "ASL Optimizing Compiler" +#define DisassemblerId "AML Disassembler" +#define CompilerCopyright "Copyright (C) 2000 - 2005 Intel Corporation" +#define CompilerCompliance "Supports ACPI Specification Revision 3.0" +#define CompilerName "iasl" +#define CompilerCreatorId "INTL" + + +/* Configuration constants */ + +#define ASL_MAX_ERROR_COUNT 200 +#define ASL_NODE_CACHE_SIZE 1024 +#define ASL_STRING_CACHE_SIZE 32768 + +#define ASL_FIRST_PARSE_OPCODE PARSEOP_ACCESSAS +#define ASL_YYTNAME_START 3 + +#define ASL_PARSE_OPCODE_BASE PARSEOP_ACCESSAS /* First Lex type */ + + +/* + * Macros + */ +#define ASL_RESDESC_OFFSET(m) ACPI_OFFSET (AML_RESOURCE, m) +#define ASL_PTR_DIFF(a,b) ((UINT8 *)(b) - (UINT8 *)(a)) +#define ASL_PTR_ADD(a,b) ((UINT8 *)(a) = ((UINT8 *)(a) + (b))) +#define ASL_GET_CHILD_NODE(a) (a)->Asl.Child +#define ASL_GET_PEER_NODE(a) (a)->Asl.Next +#define OP_TABLE_ENTRY(a,b,c,d) {b,d,a,c} + + +/* Internal AML opcodes */ + +#define AML_RAW_DATA_BYTE (UINT16) 0xAA01 /* write one raw byte */ +#define AML_RAW_DATA_WORD (UINT16) 0xAA02 /* write 2 raw bytes */ +#define AML_RAW_DATA_DWORD (UINT16) 0xAA04 /* write 4 raw bytes */ +#define AML_RAW_DATA_QWORD (UINT16) 0xAA08 /* write 8 raw bytes */ +#define AML_RAW_DATA_BUFFER (UINT16) 0xAA0B /* raw buffer with length */ +#define AML_RAW_DATA_CHAIN (UINT16) 0xAA0C /* chain of raw buffers */ +#define AML_PACKAGE_LENGTH (UINT16) 0xAA10 +#define AML_UNASSIGNED_OPCODE (UINT16) 0xEEEE +#define AML_DEFAULT_ARG_OP (UINT16) 0xDDDD + + +/* filename suffixes for output files */ + +#define FILE_SUFFIX_AML_CODE "aml" +#define FILE_SUFFIX_LISTING "lst" +#define FILE_SUFFIX_HEX_DUMP "hex" +#define FILE_SUFFIX_DEBUG "txt" +#define FILE_SUFFIX_SOURCE "src" +#define FILE_SUFFIX_NAMESPACE "nsp" +#define FILE_SUFFIX_ASM_SOURCE "asm" +#define FILE_SUFFIX_C_SOURCE "c" +#define FILE_SUFFIX_DISASSEMBLY "dsl" +#define FILE_SUFFIX_ASM_INCLUDE "inc" +#define FILE_SUFFIX_C_INCLUDE "h" + + +/* Misc */ + +#define ASL_EXTERNAL_METHOD 255 +#define ASL_ABORT TRUE +#define ASL_NO_ABORT FALSE + + +/* Support for reserved method names */ + +#define ACPI_VALID_RESERVED_NAME_MAX 0x80000000 +#define ACPI_NOT_RESERVED_NAME ACPI_UINT32_MAX +#define ACPI_PREDEFINED_NAME (ACPI_UINT32_MAX - 1) +#define ACPI_EVENT_RESERVED_NAME (ACPI_UINT32_MAX - 2) +#define ACPI_COMPILER_RESERVED_NAME (ACPI_UINT32_MAX - 3) + + +/* String to Integer conversion */ + +#define NEGATIVE 1 +#define POSITIVE 0 + + +#endif /* ASLDEFINE.H */ + diff --git a/sys/contrib/dev/acpica/compiler/aslerror.c b/sys/contrib/dev/acpica/compiler/aslerror.c index ebc622f..7031fde 100644 --- a/sys/contrib/dev/acpica/compiler/aslerror.c +++ b/sys/contrib/dev/acpica/compiler/aslerror.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslerror - Error handling and statistics - * $Revision: 83 $ + * $Revision: 1.88 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,11 +116,17 @@ *****************************************************************************/ #define ASL_EXCEPTIONS -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslerror") +/* Local prototypes */ + +static void +AeAddToErrorLog ( + ASL_ERROR_MSG *Enode); + /******************************************************************************* * @@ -136,7 +142,7 @@ * ******************************************************************************/ -void +static void AeAddToErrorLog ( ASL_ERROR_MSG *Enode) { @@ -189,7 +195,7 @@ AeAddToErrorLog ( * * FUNCTION: AePrintException * - * PARAMETERS: Where - Where to send the message + * PARAMETERS: FileId - ID of output file * Enode - Error node to print * Header - Additional text before each message * @@ -211,7 +217,8 @@ AePrintException ( char *Header) { UINT8 SourceByte; - UINT32 Actual; + int Actual; + size_t RActual; UINT32 MsgLength; char *MainMessage; char *ExtraMessage; @@ -221,8 +228,10 @@ AePrintException ( FILE *SourceFile; - /* Only listing files have a header, and remarks/optimizations are always output */ - + /* + * Only listing files have a header, and remarks/optimizations + * are always output + */ if (!Header) { /* Ignore remarks if requested */ @@ -274,23 +283,26 @@ AePrintException ( * Seek to the offset in the combined source file, read the source * line, and write it to the output. */ - Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset, SEEK_SET); + Actual = fseek (SourceFile, (long) Enode->LogicalByteOffset, + (int) SEEK_SET); if (Actual) { - fprintf (OutputFile, "[*** iASL: Seek error on source code temp file ***]"); + fprintf (OutputFile, + "[*** iASL: Seek error on source code temp file ***]"); } else { - Actual = fread (&SourceByte, 1, 1, SourceFile); - if (!Actual) + RActual = fread (&SourceByte, 1, 1, SourceFile); + if (!RActual) { - fprintf (OutputFile, "[*** iASL: Read error on source code temp file ***]"); + fprintf (OutputFile, + "[*** iASL: Read error on source code temp file ***]"); } - else while (Actual && SourceByte && (SourceByte != '\n')) + else while (RActual && SourceByte && (SourceByte != '\n')) { fwrite (&SourceByte, 1, 1, OutputFile); - Actual = fread (&SourceByte, 1, 1, SourceFile); + RActual = fread (&SourceByte, 1, 1, SourceFile); } } fprintf (OutputFile, "\n"); @@ -373,9 +385,7 @@ AePrintException ( } else { - fprintf (OutputFile, " %s %s\n\n", - MainMessage, - ExtraMessage); + fprintf (OutputFile, " %s %s\n\n", MainMessage, ExtraMessage); } } } @@ -423,7 +433,7 @@ AePrintErrorLog ( * Filename - source filename * ExtraMessage - additional error message * - * RETURN: New error node for this error + * RETURN: None * * DESCRIPTION: Create a new error node and add it to the error log * @@ -598,10 +608,11 @@ AslCoreSubsystemError ( * * PARAMETERS: CompilerMessage - Error message from the parser * - * RETURN: Status? + * RETURN: Status (0 for now) * * DESCRIPTION: Report an error situation discovered in a production - * NOTE: don't change the name of this function. + * NOTE: don't change the name of this function, it is called + * from the auto-generated parser. * ******************************************************************************/ diff --git a/sys/contrib/dev/acpica/compiler/aslfiles.c b/sys/contrib/dev/acpica/compiler/aslfiles.c index a8a7f05..7fd26f8 100644 --- a/sys/contrib/dev/acpica/compiler/aslfiles.c +++ b/sys/contrib/dev/acpica/compiler/aslfiles.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslfiles - file I/O suppoert - * $Revision: 47 $ + * $Revision: 1.52 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,12 +115,31 @@ * *****************************************************************************/ -#include "aslcompiler.h" -#include "acapps.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/acapps.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslfiles") +/* Local prototypes */ + +static void +FlOpenFile ( + UINT32 FileId, + char *Filename, + char *Mode); + +static FILE * +FlOpenLocalFile ( + char *LocalName, + char *Mode); + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_STATUS +FlParseInputPathname ( + char *InputFilename); +#endif + /******************************************************************************* * @@ -136,7 +155,8 @@ ******************************************************************************/ void -AslAbort (void) +AslAbort ( + void) { AePrintErrorLog (ASL_FILE_STDOUT); @@ -147,7 +167,7 @@ AslAbort (void) AePrintErrorLog (ASL_FILE_STDERR); } - exit (0); + exit (1); } @@ -165,7 +185,7 @@ AslAbort (void) * ******************************************************************************/ -FILE * +static FILE * FlOpenLocalFile ( char *LocalName, char *Mode) @@ -199,7 +219,8 @@ FlFileError ( UINT8 ErrorId) { - sprintf (MsgBuffer, "\"%s\" (%s)", Gbl_Files[FileId].Filename, strerror (errno)); + sprintf (MsgBuffer, "\"%s\" (%s)", Gbl_Files[FileId].Filename, + strerror (errno)); AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, MsgBuffer); } @@ -212,14 +233,14 @@ FlFileError ( * Filename - file pathname to open * Mode - Open mode for fopen * - * RETURN: File descriptor + * RETURN: None * * DESCRIPTION: Open a file. * NOTE: Aborts compiler on any error. * ******************************************************************************/ -void +static void FlOpenFile ( UINT32 FileId, char *Filename, @@ -293,7 +314,7 @@ FlReadFile ( * Buffer - Data to write * Length - Amount of data to write * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Write data to an open file. * NOTE: Aborts compiler on any error. @@ -363,7 +384,7 @@ FlPrintFile ( * PARAMETERS: FileId - Index into file info array * Offset - Absolute byte offset in file * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Seek to absolute offset * NOTE: Aborts compiler on any error. @@ -393,7 +414,7 @@ FlSeekFile ( * * PARAMETERS: FileId - Index into file info array * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Close an open file. Aborts compiler on error * @@ -487,7 +508,8 @@ FlOpenIncludeFile ( /* Prepend the directory pathname and open the include file */ - DbgPrint (ASL_PARSE_OUTPUT, "\nOpen include file: path %s\n\n", Op->Asl.Value.String); + DbgPrint (ASL_PARSE_OUTPUT, "\nOpen include file: path %s\n\n", + Op->Asl.Value.String); IncFile = FlOpenLocalFile (Op->Asl.Value.String, "r"); if (!IncFile) { @@ -504,72 +526,6 @@ FlOpenIncludeFile ( /******************************************************************************* * - * FUNCTION: FlParseInputPathname - * - * PARAMETERS: InputFilename - The user-specified ASL source file to be - * compiled - * - * RETURN: Status - * - * DESCRIPTION: Split the input path into a directory and filename part - * 1) Directory part used to open include files - * 2) Filename part used to generate output filenames - * - ******************************************************************************/ - -ACPI_STATUS -FlParseInputPathname ( - char *InputFilename) -{ - char *Substring; - - - if (!InputFilename) - { - return (AE_OK); - } - - /* Get the path to the input filename's directory */ - - Gbl_DirectoryPath = strdup (InputFilename); - if (!Gbl_DirectoryPath) - { - return (AE_NO_MEMORY); - } - - Substring = strrchr (Gbl_DirectoryPath, '\\'); - if (!Substring) - { - Substring = strrchr (Gbl_DirectoryPath, '/'); - if (!Substring) - { - Substring = strrchr (Gbl_DirectoryPath, ':'); - } - } - - if (!Substring) - { - Gbl_DirectoryPath[0] = 0; - if (Gbl_UseDefaultAmlFilename) - { - Gbl_OutputFilenamePrefix = strdup (InputFilename); - } - } - else - { - if (Gbl_UseDefaultAmlFilename) - { - Gbl_OutputFilenamePrefix = strdup (Substring + 1); - } - *(Substring+1) = 0; - } - - return (AE_OK); -} - - -/******************************************************************************* - * * FUNCTION: FlOpenInputFile * * PARAMETERS: InputFilename - The user-specified ASL source file to be @@ -588,7 +544,6 @@ FlOpenInputFile ( char *InputFilename) { - /* Open the input ASL file, text mode */ FlOpenFile (ASL_FILE_INPUT, InputFilename, "r"); @@ -628,7 +583,8 @@ FlOpenAmlOutputFile ( Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE); if (!Filename) { - AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME, 0, 0, 0, 0, NULL, NULL); + AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME, + 0, 0, 0, 0, NULL, NULL); return (AE_ERROR); } } @@ -665,7 +621,8 @@ FlOpenMiscOutputFiles ( Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_SOURCE); if (!Filename) { - AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL); + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); return (AE_ERROR); } @@ -683,7 +640,8 @@ FlOpenMiscOutputFiles ( Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_LISTING); if (!Filename) { - AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL); + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); return (AE_ERROR); } @@ -702,7 +660,8 @@ FlOpenMiscOutputFiles ( Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_SOURCE); if (!Filename) { - AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL); + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); return (AE_ERROR); } @@ -721,7 +680,8 @@ FlOpenMiscOutputFiles ( Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_SOURCE); if (!Filename) { - AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL); + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); return (AE_ERROR); } @@ -741,7 +701,8 @@ FlOpenMiscOutputFiles ( Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_ASM_INCLUDE); if (!Filename) { - AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL); + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); return (AE_ERROR); } @@ -760,7 +721,8 @@ FlOpenMiscOutputFiles ( Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_C_INCLUDE); if (!Filename) { - AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL); + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); return (AE_ERROR); } @@ -780,7 +742,8 @@ FlOpenMiscOutputFiles ( Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_HEX_DUMP); if (!Filename) { - AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL); + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); return (AE_ERROR); } @@ -799,7 +762,8 @@ FlOpenMiscOutputFiles ( Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_NAMESPACE); if (!Filename) { - AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, 0, 0, 0, 0, NULL, NULL); + AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME, + 0, 0, 0, 0, NULL, NULL); return (AE_ERROR); } @@ -818,7 +782,8 @@ FlOpenMiscOutputFiles ( Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_DEBUG); if (!Filename) { - AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME, 0, 0, 0, 0, NULL, NULL); + AslCommonError (ASL_ERROR, ASL_MSG_DEBUG_FILENAME, + 0, 0, 0, 0, NULL, NULL); return (AE_ERROR); } @@ -827,7 +792,8 @@ FlOpenMiscOutputFiles ( /* TBD: hide this behind a FlReopenFile function */ Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Filename = Filename; - Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle = freopen (Filename, "w+t", stderr); + Gbl_Files[ASL_FILE_DEBUG_OUTPUT].Handle = + freopen (Filename, "w+t", stderr); AslCompilerSignon (ASL_FILE_DEBUG_OUTPUT); AslCompilerFileHeader (ASL_FILE_DEBUG_OUTPUT); @@ -837,3 +803,71 @@ FlOpenMiscOutputFiles ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: FlParseInputPathname + * + * PARAMETERS: InputFilename - The user-specified ASL source file to be + * compiled + * + * RETURN: Status + * + * DESCRIPTION: Split the input path into a directory and filename part + * 1) Directory part used to open include files + * 2) Filename part used to generate output filenames + * + ******************************************************************************/ + +ACPI_STATUS +FlParseInputPathname ( + char *InputFilename) +{ + char *Substring; + + + if (!InputFilename) + { + return (AE_OK); + } + + /* Get the path to the input filename's directory */ + + Gbl_DirectoryPath = strdup (InputFilename); + if (!Gbl_DirectoryPath) + { + return (AE_NO_MEMORY); + } + + Substring = strrchr (Gbl_DirectoryPath, '\\'); + if (!Substring) + { + Substring = strrchr (Gbl_DirectoryPath, '/'); + if (!Substring) + { + Substring = strrchr (Gbl_DirectoryPath, ':'); + } + } + + if (!Substring) + { + Gbl_DirectoryPath[0] = 0; + if (Gbl_UseDefaultAmlFilename) + { + Gbl_OutputFilenamePrefix = strdup (InputFilename); + } + } + else + { + if (Gbl_UseDefaultAmlFilename) + { + Gbl_OutputFilenamePrefix = strdup (Substring + 1); + } + *(Substring+1) = 0; + } + + return (AE_OK); +} +#endif + + diff --git a/sys/contrib/dev/acpica/compiler/aslfold.c b/sys/contrib/dev/acpica/compiler/aslfold.c index 73d100e..8ee845f 100644 --- a/sys/contrib/dev/acpica/compiler/aslfold.c +++ b/sys/contrib/dev/acpica/compiler/aslfold.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslfold - Constant folding - * $Revision: 9 $ + * $Revision: 1.18 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,16 +116,36 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" -#include "amlcode.h" +#include <contrib/dev/acpica/amlcode.h> -#include "acdispat.h" -#include "acparser.h" +#include <contrib/dev/acpica/acdispat.h> +#include <contrib/dev/acpica/acparser.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslfold") +/* Local prototypes */ + +static ACPI_STATUS +OpcAmlEvaluationWalk1 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static ACPI_STATUS +OpcAmlEvaluationWalk2 ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static ACPI_STATUS +OpcAmlCheckForConstant ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + /******************************************************************************* * @@ -139,7 +159,7 @@ * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS OpcAmlEvaluationWalk1 ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -186,7 +206,7 @@ OpcAmlEvaluationWalk1 ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS OpcAmlEvaluationWalk2 ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -232,7 +252,7 @@ OpcAmlEvaluationWalk2 ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS OpcAmlCheckForConstant ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -254,11 +274,13 @@ OpcAmlCheckForConstant ( if (Op->Asl.CompileFlags & NODE_IS_TARGET) { - DbgPrint (ASL_PARSE_OUTPUT, "**** Valid Target, cannot reduce ****\n"); + DbgPrint (ASL_PARSE_OUTPUT, + "**** Valid Target, cannot reduce ****\n"); } else { - DbgPrint (ASL_PARSE_OUTPUT, "**** Not a Type 3/4/5 opcode ****\n"); + DbgPrint (ASL_PARSE_OUTPUT, + "**** Not a Type 3/4/5 opcode ****\n"); } if (WalkState->WalkType == ACPI_WALK_CONST_OPTIONAL) @@ -276,11 +298,13 @@ OpcAmlCheckForConstant ( */ if (Op->Asl.CompileFlags & NODE_IS_TARGET) { - AslError (ASL_ERROR, ASL_MSG_INVALID_TARGET, Op, Op->Asl.ParseOpName); + AslError (ASL_ERROR, ASL_MSG_INVALID_TARGET, Op, + Op->Asl.ParseOpName); } else { - AslError (ASL_ERROR, ASL_MSG_INVALID_CONSTANT_OP, Op, Op->Asl.ParseOpName); + AslError (ASL_ERROR, ASL_MSG_INVALID_CONSTANT_OP, Op, + Op->Asl.ParseOpName); } return (AE_TYPE); @@ -340,9 +364,8 @@ OpcAmlConstantWalk ( return (AE_OK); } - /* - * Set the walk type based on the reduction used for this op - */ + /* Set the walk type based on the reduction used for this op */ + if (Op->Asl.CompileFlags & NODE_IS_TERM_ARG) { /* Op is a TermArg, constant folding is merely optional */ @@ -374,8 +397,10 @@ OpcAmlConstantWalk ( WalkState->CallerReturnDesc = &ObjDesc; WalkState->WalkType = WalkType; - /* Examine the entire subtree -- all nodes must be constants or type 3/4/5 opcodes */ - + /* + * Examine the entire subtree -- all nodes must be constants + * or type 3/4/5 opcodes + */ Status = TrWalkParseTree (Op, ASL_WALK_VISIT_DOWNWARD, OpcAmlCheckForConstant, NULL, WalkState); @@ -414,10 +439,10 @@ OpcAmlConstantWalk ( OriginalParentOp = Op->Common.Parent; Op->Common.Parent = RootOp; - /* - * Hand off the subtree to the AML interpreter - */ - Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE, OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState); + /* Hand off the subtree to the AML interpreter */ + + Status = TrWalkParseTree (Op, ASL_WALK_VISIT_TWICE, + OpcAmlEvaluationWalk1, OpcAmlEvaluationWalk2, WalkState); Op->Common.Parent = OriginalParentOp; /* TBD: we really *should* release the RootOp node */ @@ -436,7 +461,10 @@ OpcAmlConstantWalk ( { /* We could not resolve the subtree for some reason */ - AslError (ASL_ERROR, ASL_MSG_CONSTANT_EVALUATION, Op, Op->Asl.ParseOpName); + AslCoreSubsystemError (Op, Status, + "Failure during constant evaluation", FALSE); + AslError (ASL_ERROR, ASL_MSG_CONSTANT_EVALUATION, Op, + Op->Asl.ParseOpName); /* Set the subtree value to ZERO anyway. Eliminates further errors */ @@ -446,7 +474,8 @@ OpcAmlConstantWalk ( } else { - AslError (ASL_OPTIMIZATION, ASL_MSG_CONSTANT_FOLDED, Op, Op->Asl.ParseOpName); + AslError (ASL_OPTIMIZATION, ASL_MSG_CONSTANT_FOLDED, Op, + Op->Asl.ParseOpName); /* * Because we know we executed type 3/4/5 opcodes above, we know that @@ -460,7 +489,8 @@ OpcAmlConstantWalk ( Op->Common.Value.Integer = ObjDesc->Integer.Value; OpcSetOptimalIntegerSize (Op); - DbgPrint (ASL_PARSE_OUTPUT, "Constant expression reduced to (INTEGER) %8.8X%8.8X\n", + DbgPrint (ASL_PARSE_OUTPUT, + "Constant expression reduced to (INTEGER) %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); break; @@ -472,7 +502,8 @@ OpcAmlConstantWalk ( Op->Asl.AmlLength = ACPI_STRLEN (ObjDesc->String.Pointer) + 1; Op->Common.Value.String = ObjDesc->String.Pointer; - DbgPrint (ASL_PARSE_OUTPUT, "Constant expression reduced to (STRING) %s\n", + DbgPrint (ASL_PARSE_OUTPUT, + "Constant expression reduced to (STRING) %s\n", Op->Common.Value.String); break; @@ -482,6 +513,7 @@ OpcAmlConstantWalk ( Op->Asl.ParseOpcode = PARSEOP_BUFFER; Op->Common.AmlOpcode = AML_BUFFER_OP; + Op->Asl.CompileFlags = NODE_AML_PACKAGE; UtSetParseOpName (Op); /* Child node is the buffer length */ @@ -509,7 +541,8 @@ OpcAmlConstantWalk ( Op->Asl.Next = RootOp; Op = RootOp; - DbgPrint (ASL_PARSE_OUTPUT, "Constant expression reduced to (BUFFER) length %X\n", + DbgPrint (ASL_PARSE_OUTPUT, + "Constant expression reduced to (BUFFER) length %X\n", ObjDesc->Buffer.Length); break; diff --git a/sys/contrib/dev/acpica/compiler/aslglobal.h b/sys/contrib/dev/acpica/compiler/aslglobal.h index 6dfe3cb..3b3306d 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: 44 $ + * $Revision: 1.50 $ * *****************************************************************************/ @@ -11,7 +11,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,6 +125,8 @@ * Global variables. Defined in aslmain.c only, externed in all other files */ +#undef ASL_EXTERN + #ifdef _DECLARE_GLOBALS #define ASL_EXTERN #define ASL_INIT_GLOBAL(a,b) (a)=(b) @@ -169,6 +171,8 @@ extern UINT32 Gbl_ExceptionCount[]; /* Option flags */ +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_Acpi2, FALSE); +ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_CheckForAscii, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_UseDefaultAmlFilename, TRUE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_NsOutputFlag, FALSE); ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (Gbl_DebugFlag, FALSE); @@ -226,6 +230,7 @@ ASL_EXTERN UINT32 ASL_INIT_GLOBAL (TotalFolds, 0); /* Misc */ ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_RevisionOverride, 0); +ASL_EXTERN UINT8 ASL_INIT_GLOBAL (Gbl_TempCount, 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); @@ -234,7 +239,6 @@ ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_NodeCacheNext, NULL); ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*Gbl_NodeCacheLast, NULL); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheNext, NULL); ASL_EXTERN char ASL_INIT_GLOBAL (*Gbl_StringCacheLast, NULL); -ASL_EXTERN UINT32 ASL_INIT_GLOBAL (Gbl_TempCount, 0); ASL_EXTERN ACPI_PARSE_OBJECT *Gbl_FirstLevelInsertionNode; @@ -254,8 +258,13 @@ ASL_EXTERN FILE *AcpiGbl_DebugFile; /* Placeholder for oswin ASL_EXTERN ASL_ANALYSIS_WALK_INFO AnalysisWalkInfo; ASL_EXTERN ACPI_TABLE_HEADER TableHeader; extern const ASL_RESERVED_INFO ReservedMethods[]; -ASL_EXTERN ASL_EVENT_INFO AslGbl_Events[21]; +/* Event timing */ + +#define ASL_NUM_EVENTS 19 +ASL_EXTERN ASL_EVENT_INFO AslGbl_Events[ASL_NUM_EVENTS]; +ASL_EXTERN UINT8 AslGbl_NextEvent; +ASL_EXTERN UINT8 AslGbl_NamespaceEvent; /* Scratch buffers */ diff --git a/sys/contrib/dev/acpica/compiler/asllength.c b/sys/contrib/dev/acpica/compiler/asllength.c index d624b88..7d44ff0 100644 --- a/sys/contrib/dev/acpica/compiler/asllength.c +++ b/sys/contrib/dev/acpica/compiler/asllength.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: asllength - Tree walk to determine package and opcode lengths - * $Revision: 31 $ + * $Revision: 1.35 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,14 +116,33 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" -#include "amlcode.h" +#include <contrib/dev/acpica/amlcode.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("asllength") +/* Local prototypes */ + +static UINT8 +CgGetPackageLenByteCount ( + ACPI_PARSE_OBJECT *Op, + UINT32 PackageLength); + +static void +CgGenerateAmlOpcodeLength ( + ACPI_PARSE_OBJECT *Op); + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +void +LnAdjustLengthToRoot ( + ACPI_PARSE_OBJECT *Op, + UINT32 LengthDelta); +#endif + /******************************************************************************* * @@ -199,47 +218,9 @@ LnPackageLengthWalk ( /******************************************************************************* * - * FUNCTION: LnAdjustLengthToRoot - * - * PARAMETERS: Op - Node whose Length was changed - * - * RETURN: None. - * - * DESCRIPTION: Change the Subtree length of the given node, and bubble the - * change all the way up to the root node. This allows for - * last second changes to a package length (for example, if the - * package length encoding gets shorter or longer.) - * - ******************************************************************************/ - -void -LnAdjustLengthToRoot ( - ACPI_PARSE_OBJECT *SubtreeOp, - UINT32 LengthDelta) -{ - ACPI_PARSE_OBJECT *Op; - - - /* Adjust all subtree lengths up to the root */ - - Op = SubtreeOp->Asl.Parent; - while (Op) - { - Op->Asl.AmlSubtreeLength -= LengthDelta; - Op = Op->Asl.Parent; - } - - /* Adjust the global table length */ - - Gbl_TableLength -= LengthDelta; -} - - -/******************************************************************************* - * * FUNCTION: CgGetPackageLenByteCount * - * PARAMETERS: Op - Parse node + * PARAMETERS: Op - Parse node * PackageLength - Length to be encoded * * RETURN: Required length of the package length encoding @@ -249,7 +230,7 @@ LnAdjustLengthToRoot ( * ******************************************************************************/ -UINT8 +static UINT8 CgGetPackageLenByteCount ( ACPI_PARSE_OBJECT *Op, UINT32 PackageLength) @@ -291,7 +272,7 @@ CgGetPackageLenByteCount ( * * FUNCTION: CgGenerateAmlOpcodeLength * - * PARAMETERS: Op - Parse node whose AML opcode lengths will be + * PARAMETERS: Op - Parse node whose AML opcode lengths will be * calculated * * RETURN: None. @@ -301,7 +282,7 @@ CgGetPackageLenByteCount ( * ******************************************************************************/ -void +static void CgGenerateAmlOpcodeLength ( ACPI_PARSE_OBJECT *Op) { @@ -322,7 +303,8 @@ CgGenerateAmlOpcodeLength ( Op->Asl.AmlPkgLenBytes = 0; if (Op->Asl.CompileFlags & NODE_AML_PACKAGE) { - Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount (Op, Op->Asl.AmlSubtreeLength); + Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount ( + Op, Op->Asl.AmlSubtreeLength); } /* Data opcode lengths are easy */ @@ -425,7 +407,8 @@ CgGenerateAmlLengths ( { case PARSEOP_DEFINITIONBLOCK: - Gbl_TableLength = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength; + Gbl_TableLength = sizeof (ACPI_TABLE_HEADER) + + Op->Asl.AmlSubtreeLength; break; case PARSEOP_NAMESEG: @@ -471,13 +454,17 @@ CgGenerateAmlLengths ( case PARSEOP_STRING_LITERAL: Op->Asl.AmlOpcodeLength = 1; - Op->Asl.AmlLength = strlen (Op->Asl.Value.String) + 1; /* Get null terminator */ + + /* Get null terminator */ + + Op->Asl.AmlLength = strlen (Op->Asl.Value.String) + 1; break; case PARSEOP_PACKAGE_LENGTH: Op->Asl.AmlOpcodeLength = 0; - Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount (Op, (UINT32) Op->Asl.Value.Integer); + Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount (Op, + (UINT32) Op->Asl.Value.Integer); break; case PARSEOP_RAW_DATA: @@ -502,3 +489,43 @@ CgGenerateAmlLengths ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: LnAdjustLengthToRoot + * + * PARAMETERS: Op - Node whose Length was changed + * + * RETURN: None. + * + * DESCRIPTION: Change the Subtree length of the given node, and bubble the + * change all the way up to the root node. This allows for + * last second changes to a package length (for example, if the + * package length encoding gets shorter or longer.) + * + ******************************************************************************/ + +void +LnAdjustLengthToRoot ( + ACPI_PARSE_OBJECT *SubtreeOp, + UINT32 LengthDelta) +{ + ACPI_PARSE_OBJECT *Op; + + + /* Adjust all subtree lengths up to the root */ + + Op = SubtreeOp->Asl.Parent; + while (Op) + { + Op->Asl.AmlSubtreeLength -= LengthDelta; + Op = Op->Asl.Parent; + } + + /* Adjust the global table length */ + + Gbl_TableLength -= LengthDelta; +} +#endif + + diff --git a/sys/contrib/dev/acpica/compiler/asllisting.c b/sys/contrib/dev/acpica/compiler/asllisting.c index 3410d8d..a83b18c 100644 --- a/sys/contrib/dev/acpica/compiler/asllisting.c +++ b/sys/contrib/dev/acpica/compiler/asllisting.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: asllisting - Listing file generation - * $Revision: 51 $ + * $Revision: 1.58 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,15 +116,89 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" -#include "amlcode.h" -#include "acparser.h" -#include "acnamesp.h" +#include <contrib/dev/acpica/amlcode.h> +#include <contrib/dev/acpica/acparser.h> +#include <contrib/dev/acpica/acnamesp.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslisting") +/* Local prototypes */ + +static void +LsDumpAscii ( + UINT32 FileId, + UINT32 Count, + UINT8 *Buffer); + +static void +LsDumpAsciiInComment ( + UINT32 FileId, + UINT32 Count, + UINT8 *Buffer); + +static ACPI_STATUS +LsAmlListingWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static void +LsGenerateListing ( + UINT32 FileId); + +static void +LsPushNode ( + char *Filename); + +static ASL_LISTING_NODE * +LsPopNode ( + void); + +static void +LsCheckException ( + UINT32 LineNumber, + UINT32 FileId); + +static void +LsFlushListingBuffer ( + UINT32 FileId); + +static void +LsWriteListingHexBytes ( + UINT8 *Buffer, + UINT32 Length, + UINT32 FileId); + +static UINT32 +LsWriteOneSourceLine ( + UINT32 FileId); + +static void +LsFinishSourceListing ( + UINT32 FileId); + +static void +LsWriteSourceLines ( + UINT32 ToLineNumber, + UINT32 ToLogicalLineNumber, + UINT32 FileId); + +static void +LsWriteNodeToListing ( + ACPI_PARSE_OBJECT *Op, + UINT32 FileId); + +static void +LsDoHexOutputC ( + void); + +static void +LsDoHexOutputAsm ( + void); + /******************************************************************************* * @@ -140,7 +214,7 @@ * ******************************************************************************/ -void +static void LsDumpAscii ( UINT32 FileId, UINT32 Count, @@ -183,7 +257,7 @@ LsDumpAscii ( * ******************************************************************************/ -void +static void LsDumpAsciiInComment ( UINT32 FileId, UINT32 Count, @@ -237,7 +311,7 @@ LsDumpAsciiInComment ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS LsAmlListingWalk ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -279,7 +353,7 @@ LsAmlListingWalk ( * ******************************************************************************/ -void +static void LsGenerateListing ( UINT32 FileId) { @@ -316,7 +390,8 @@ LsGenerateListing ( ******************************************************************************/ void -LsDoListings (void) +LsDoListings ( + void) { if (Gbl_C_OutputFlag) @@ -361,7 +436,7 @@ LsDoListings (void) * ******************************************************************************/ -void +static void LsPushNode ( char *Filename) { @@ -397,8 +472,9 @@ LsPushNode ( * ******************************************************************************/ -ASL_LISTING_NODE * -LsPopNode (void) +static ASL_LISTING_NODE * +LsPopNode ( + void) { ASL_LISTING_NODE *Lnode; @@ -409,7 +485,8 @@ LsPopNode (void) if ((!Lnode) || (!Lnode->Next)) { - AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL, "Could not pop empty listing stack"); + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL, + "Could not pop empty listing stack"); return Gbl_ListingNode; } @@ -438,7 +515,7 @@ LsPopNode (void) * ******************************************************************************/ -void +static void LsCheckException ( UINT32 LineNumber, UINT32 FileId) @@ -481,7 +558,7 @@ LsCheckException ( * ******************************************************************************/ -void +static void LsFlushListingBuffer ( UINT32 FileId) { @@ -531,7 +608,8 @@ LsFlushListingBuffer ( FlWriteFile (FileId, " ", 1); } - FlPrintFile (FileId, " ;%8.8X", Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE); + FlPrintFile (FileId, " ;%8.8X", + Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE); /* Write the ASCII character associated with each of the bytes */ @@ -551,7 +629,8 @@ LsFlushListingBuffer ( FlWriteFile (FileId, " ", 1); } - FlPrintFile (FileId, " /* %8.8X", Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE); + FlPrintFile (FileId, " /* %8.8X", + Gbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE); /* Write the ASCII character associated with each of the bytes */ @@ -587,7 +666,7 @@ LsFlushListingBuffer ( * ******************************************************************************/ -void +static void LsWriteListingHexBytes ( UINT8 *Buffer, UINT32 Length, @@ -663,7 +742,7 @@ LsWriteListingHexBytes ( * ******************************************************************************/ -UINT32 +static UINT32 LsWriteOneSourceLine ( UINT32 FileId) { @@ -742,7 +821,7 @@ LsWriteOneSourceLine ( * ******************************************************************************/ -void +static void LsFinishSourceListing ( UINT32 FileId) { @@ -804,7 +883,7 @@ LsFinishSourceListing ( * ******************************************************************************/ -void +static void LsWriteSourceLines ( UINT32 ToLineNumber, UINT32 ToLogicalLineNumber, @@ -823,9 +902,8 @@ LsWriteSourceLines ( LsFlushListingBuffer (FileId); - /* - * Read lines and write them as long as we are not caught up - */ + /* Read lines and write them as long as we are not caught up */ + if (Gbl_SourceLine < Gbl_CurrentLine) { /* @@ -843,9 +921,8 @@ LsWriteSourceLines ( FlPrintFile (FileId, " /*\n"); } - /* - * Write one line at a time until we have reached the target line # - */ + /* Write one line at a time until we have reached the target line # */ + while ((Gbl_SourceLine < Gbl_CurrentLine) && LsWriteOneSourceLine (FileId)) { ; } @@ -875,7 +952,7 @@ LsWriteSourceLines ( * ******************************************************************************/ -void +static void LsWriteNodeToListing ( ACPI_PARSE_OBJECT *Op, UINT32 FileId) @@ -890,8 +967,9 @@ LsWriteNodeToListing ( OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); OpClass = OpInfo->Class; - /* TBD: clean this up with a single flag that says: I start a named output block */ - + /* TBD: clean this up with a single flag that says: + * I start a named output block + */ if (FileId == ASL_FILE_C_SOURCE_OUTPUT) { switch (Op->Asl.ParseOpcode) @@ -932,7 +1010,6 @@ LsWriteNodeToListing ( } } - /* These cases do not have a corresponding AML opcode */ switch (Op->Asl.ParseOpcode) @@ -945,22 +1022,26 @@ LsWriteNodeToListing ( if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT) { - FlPrintFile (FileId, "%s_%s_Header \\\n", + FlPrintFile (FileId, + "%s_%s_Header \\\n", Gbl_TableSignature, Gbl_TableId); } if (FileId == ASL_FILE_C_SOURCE_OUTPUT) { - FlPrintFile (FileId, " unsigned char %s_%s_Header [] = \n {\n", + FlPrintFile (FileId, + " unsigned char %s_%s_Header [] =\n {\n", Gbl_TableSignature, Gbl_TableId); } if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) { - FlPrintFile (FileId, "extrn %s_%s_Header : byte\n", + FlPrintFile (FileId, + "extrn %s_%s_Header : byte\n", Gbl_TableSignature, Gbl_TableId); } if (FileId == ASL_FILE_C_INCLUDE_OUTPUT) { - FlPrintFile (FileId, "extern unsigned char %s_%s_Header [];\n", + FlPrintFile (FileId, + "extern unsigned char %s_%s_Header [];\n", Gbl_TableSignature, Gbl_TableId); } return; @@ -968,35 +1049,34 @@ LsWriteNodeToListing ( case PARSEOP_METHODCALL: - LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId); + LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, + FileId); return; case PARSEOP_INCLUDE: - /* - * Flush everything up to and including the include source line - */ - LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId); + /* Flush everything up to and including the include source line */ + + LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, + FileId); + + /* Create a new listing node and push it */ - /* - * Create a new listing node and push it - */ LsPushNode (Op->Asl.Child->Asl.Value.String); return; case PARSEOP_INCLUDE_END: - /* - * Flush out the rest of the include file - */ - LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId); + /* Flush out the rest of the include file */ - /* - * Pop off this listing node and go back to the parent file - */ - LsPopNode (); + LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, + FileId); + + /* Pop off this listing node and go back to the parent file */ + + (void) LsPopNode (); return; @@ -1031,13 +1111,17 @@ LsWriteNodeToListing ( case AML_BANK_FIELD_OP: case AML_NAME_OP: - /* For fields, we want to dump all the AML after the entire definition */ - - LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId); + /* + * For fields, we want to dump all the AML after the + * entire definition + */ + LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, + FileId); break; default: - LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId); + LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, + FileId); break; } @@ -1087,22 +1171,26 @@ LsWriteNodeToListing ( if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT) { - FlPrintFile (FileId, "%s_%s_%s \\\n", + FlPrintFile (FileId, + "%s_%s_%s \\\n", Gbl_TableSignature, Gbl_TableId, &Pathname[1]); } if (FileId == ASL_FILE_C_SOURCE_OUTPUT) { - FlPrintFile (FileId, " unsigned char %s_%s_%s [] = \n {\n", + FlPrintFile (FileId, + " unsigned char %s_%s_%s [] =\n {\n", Gbl_TableSignature, Gbl_TableId, &Pathname[1]); } if (FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) { - FlPrintFile (FileId, "extrn %s_%s_%s : byte\n", + FlPrintFile (FileId, + "extrn %s_%s_%s : byte\n", Gbl_TableSignature, Gbl_TableId, &Pathname[1]); } if (FileId == ASL_FILE_C_INCLUDE_OUTPUT) { - FlPrintFile (FileId, "extern unsigned char %s_%s_%s [];\n", + FlPrintFile (FileId, + "extern unsigned char %s_%s_%s [];\n", Gbl_TableSignature, Gbl_TableId, &Pathname[1]); } } @@ -1121,7 +1209,8 @@ LsWriteNodeToListing ( case AML_CLASS_CREATE: default: - LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, FileId); + LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber, + FileId); break; case AML_CLASS_UNKNOWN: @@ -1143,7 +1232,8 @@ LsWriteNodeToListing ( ******************************************************************************/ void -LsDoHexOutput (void) +LsDoHexOutput ( + void) { switch (Gbl_HexOutputFlag) @@ -1179,8 +1269,9 @@ LsDoHexOutput (void) * ******************************************************************************/ -void -LsDoHexOutputC (void) +static void +LsDoHexOutputC ( + void) { UINT32 j; UINT8 FileByte[HEX_TABLE_LINE_SIZE]; @@ -1189,7 +1280,7 @@ LsDoHexOutputC (void) FlPrintFile (ASL_FILE_HEX_OUTPUT, " * C source code output\n *\n */\n"); - FlPrintFile (ASL_FILE_HEX_OUTPUT, "unsigned char AmlCode[] = \n{\n"); + FlPrintFile (ASL_FILE_HEX_OUTPUT, "unsigned char AmlCode[] =\n{\n"); /* Start at the beginning of the AML file */ @@ -1205,9 +1296,8 @@ LsDoHexOutputC (void) FlPrintFile (ASL_FILE_HEX_OUTPUT, " "); } - /* - * Convert each AML byte to hex - */ + /* Convert each AML byte to hex */ + UtConvertByteToHex (FileByte[j], Buffer); FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4); FlPrintFile (ASL_FILE_HEX_OUTPUT, ","); @@ -1221,18 +1311,19 @@ LsDoHexOutputC (void) { /* End of line, emit the ascii dump of the entire line */ - FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset - HEX_TABLE_LINE_SIZE); + FlPrintFile (ASL_FILE_HEX_OUTPUT, + " /* %8.8X", Offset - HEX_TABLE_LINE_SIZE); /* Write the ASCII character associated with each of the bytes */ - LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, HEX_TABLE_LINE_SIZE, FileByte); + LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, + HEX_TABLE_LINE_SIZE, FileByte); FlPrintFile (ASL_FILE_HEX_OUTPUT, " */\n"); /* Start new line */ j = 0; } - } FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n};\n"); @@ -1254,7 +1345,7 @@ LsDoHexOutputC (void) * ******************************************************************************/ -void +static void LsDoHexOutputAsm ( void) { @@ -1286,9 +1377,8 @@ LsDoHexOutputAsm ( DoComma = FALSE; } - /* - * Convert each AML byte to hex - */ + /* Convert each AML byte to hex */ + UtConvertByteToAsmHex (FileByte[j], Buffer); FlWriteFile (ASL_FILE_HEX_OUTPUT, Buffer, 4); @@ -1298,7 +1388,8 @@ LsDoHexOutputAsm ( j++; if (j >= HEX_TABLE_LINE_SIZE) { - FlPrintFile (ASL_FILE_HEX_OUTPUT, " ;%8.8X", Offset - HEX_TABLE_LINE_SIZE); + FlPrintFile (ASL_FILE_HEX_OUTPUT, + " ;%8.8X", Offset - HEX_TABLE_LINE_SIZE); /* Write the ASCII character associated with each of the bytes */ diff --git a/sys/contrib/dev/acpica/compiler/aslload.c b/sys/contrib/dev/acpica/compiler/aslload.c index 45f292d..f3e75be 100644 --- a/sys/contrib/dev/acpica/compiler/aslload.c +++ b/sys/contrib/dev/acpica/compiler/aslload.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dswload - Dispatcher namespace load callbacks - * $Revision: 62 $ + * $Revision: 1.71 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,22 +116,46 @@ #define __ASLLOAD_C__ -#include "aslcompiler.h" -#include "amlcode.h" -#include "acdispat.h" -#include "acnamesp.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/amlcode.h> +#include <contrib/dev/acpica/acdispat.h> +#include <contrib/dev/acpica/acnamesp.h> #include "aslcompiler.y.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslload") +/* Local prototypes */ + +static ACPI_STATUS +LdLoadFieldElements ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +LdLoadResourceElements ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +LdNamespace1Begin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static ACPI_STATUS +LdNamespace1End ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + /******************************************************************************* * * FUNCTION: LdLoadNamespace * - * PARAMETERS: None + * PARAMETERS: RootOp - Root of the parse tree * * RETURN: Status * @@ -162,7 +186,7 @@ LdLoadNamespace ( /* Perform the walk of the parse tree */ TrWalkParseTree (RootOp, ASL_WALK_VISIT_TWICE, LdNamespace1Begin, - LdNamespace1End, WalkState); + LdNamespace1End, WalkState); /* Dump the namespace if debug is enabled */ @@ -175,7 +199,7 @@ LdLoadNamespace ( * * FUNCTION: LdLoadFieldElements * - * PARAMETERS: Op - Parent node (Field) + * PARAMETERS: Op - Parent node (Field) * WalkState - Current walk state * * RETURN: Status @@ -185,7 +209,7 @@ LdLoadNamespace ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS LdLoadFieldElements ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState) @@ -232,27 +256,33 @@ LdLoadFieldElements ( default: - Status = AcpiNsLookup (WalkState->ScopeInfo, Child->Asl.Value.String, - ACPI_TYPE_LOCAL_REGION_FIELD, ACPI_IMODE_LOAD_PASS1, - ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, - NULL, &Node); + Status = AcpiNsLookup (WalkState->ScopeInfo, + Child->Asl.Value.String, + ACPI_TYPE_LOCAL_REGION_FIELD, + ACPI_IMODE_LOAD_PASS1, + ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND, + NULL, &Node); if (ACPI_FAILURE (Status)) { if (Status != AE_ALREADY_EXISTS) { - return (Status); + AslError (ASL_ERROR, ASL_MSG_CORE_EXCEPTION, Child, + Child->Asl.Value.String); + return (Status); } /* * The name already exists in this scope * But continue processing the elements */ - AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Child, Child->Asl.Value.String); + AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Child, + Child->Asl.Value.String); } else { Child->Asl.Node = Node; - Node->Object = (ACPI_OPERAND_OBJECT *) Child; + Node->Op = Child; } break; } @@ -266,7 +296,7 @@ LdLoadFieldElements ( * * FUNCTION: LdLoadResourceElements * - * PARAMETERS: Op - Parent node (Resource Descriptor) + * PARAMETERS: Op - Parent node (Resource Descriptor) * WalkState - Current walk state * * RETURN: Status @@ -280,7 +310,7 @@ LdLoadFieldElements ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS LdLoadResourceElements ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState) @@ -291,14 +321,23 @@ LdLoadResourceElements ( /* - * Enter the resouce name into the namespace - * This opens a scope + * Enter the resource name into the namespace. Name must not already exist. + * This opens a scope, so later field names are guaranteed to be new/unique. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Asl.Namepath, - ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH, - WalkState, &Node); + ACPI_TYPE_LOCAL_RESOURCE, ACPI_IMODE_LOAD_PASS1, + ACPI_NS_NO_UPSEARCH | ACPI_NS_ERROR_IF_FOUND, + WalkState, &Node); if (ACPI_FAILURE (Status)) { + if (Status == AE_ALREADY_EXISTS) + { + /* Actual node causing the error was saved in ParentMethod */ + + AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, + (ACPI_PARSE_OBJECT *) Op->Asl.ParentMethod, Op->Asl.Namepath); + return (AE_OK); + } return (Status); } @@ -313,10 +352,11 @@ LdLoadResourceElements ( if (InitializerOp->Asl.ExternalName) { Status = AcpiNsLookup (WalkState->ScopeInfo, - InitializerOp->Asl.ExternalName, - ACPI_TYPE_LOCAL_RESOURCE_FIELD, - ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, - NULL, &Node); + InitializerOp->Asl.ExternalName, + ACPI_TYPE_LOCAL_RESOURCE_FIELD, + ACPI_IMODE_LOAD_PASS1, + ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, + NULL, &Node); if (ACPI_FAILURE (Status)) { return (Status); @@ -326,9 +366,9 @@ LdLoadResourceElements ( * Store the field offset in the namespace node so it * can be used when the field is referenced */ - Node->OwnerId = (UINT16) InitializerOp->Asl.Value.Integer; + Node->Value = (UINT32) InitializerOp->Asl.Value.Integer; InitializerOp->Asl.Node = Node; - Node->Object = (ACPI_OPERAND_OBJECT *) InitializerOp; + Node->Op = InitializerOp; /* Pass thru the field type (Bitfield or Bytefield) */ @@ -357,7 +397,7 @@ LdLoadResourceElements ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS LdNamespace1Begin ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -417,8 +457,8 @@ LdNamespace1Begin ( { case PARSEOP_NAME: - Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */ - Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */ + Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */ + Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */ /* Get the data type associated with the named object, not the name itself */ @@ -467,23 +507,28 @@ LdNamespace1Begin ( * handle this case. Perhaps someday this case can go away. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) { /* The name was not found, go ahead and create it */ - Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ACPI_TYPE_LOCAL_SCOPE, - ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node)); + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, + ACPI_TYPE_LOCAL_SCOPE, + ACPI_IMODE_LOAD_PASS1, Flags, + WalkState, &(Node)); /* * However, this is an error -- primarily because the MS * interpreter can't handle a forward reference from the * Scope() operator. */ - AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, Op->Asl.ExternalName); - AslError (ASL_ERROR, ASL_MSG_SCOPE_FWD_REF, Op, Op->Asl.ExternalName); + AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, + Op->Asl.ExternalName); + AslError (ASL_ERROR, ASL_MSG_SCOPE_FWD_REF, Op, + Op->Asl.ExternalName); goto FinishNode; } @@ -509,8 +554,8 @@ LdNamespace1Begin ( case ACPI_TYPE_BUFFER: /* - * These types we will allow, but we will change the type. This - * enables some existing code of the form: + * These types we will allow, but we will change the type. + * This enables some existing code of the form: * * Name (DEB, 0) * Scope (DEB) { ... } @@ -522,11 +567,11 @@ LdNamespace1Begin ( Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); AslError (ASL_REMARK, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); - /* - * Switch the type to scope, open the new scope - */ + /* Switch the type to scope, open the new scope */ + Node->Type = ACPI_TYPE_LOCAL_SCOPE; - Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, WalkState); + Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, + WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -535,10 +580,10 @@ LdNamespace1Begin ( default: - /* - * All other types are an error - */ - sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); + /* All other types are an error */ + + sprintf (MsgBuffer, "%s [%s]", Op->Asl.ExternalName, + AcpiUtGetTypeName (Node->Type)); AslError (ASL_ERROR, ASL_MSG_SCOPE_TYPE, Op, MsgBuffer); /* @@ -547,7 +592,8 @@ LdNamespace1Begin ( * cascade of additional errors. Open the new scope. */ Node->Type = ACPI_TYPE_LOCAL_SCOPE; - Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, WalkState); + Status = AcpiDsScopeStackPush (Node, ACPI_TYPE_LOCAL_SCOPE, + WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -575,8 +621,9 @@ LdNamespace1Begin ( /* * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that involve - * arguments to the opcode must be created as we go back up the parse tree later. + * as we go downward in the parse tree. Any necessary subobjects that + * involve arguments to the opcode must be created as we go back up the + * parse tree later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node)); @@ -593,14 +640,16 @@ LdNamespace1Begin ( } else { - AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Op, Op->Asl.ExternalName); + AslError (ASL_ERROR, ASL_MSG_NAME_EXISTS, Op, + Op->Asl.ExternalName); Status = AE_OK; goto Exit; } } else { - AslCoreSubsystemError (Op, Status, "Failure from lookup %s\n", FALSE); + AslCoreSubsystemError (Op, Status, + "Failure from lookup %s\n", FALSE); goto Exit; } } @@ -612,23 +661,23 @@ FinishNode: * the Node back to the original Parse node */ Op->Asl.Node = Node; - Node->Object = (ACPI_OPERAND_OBJECT *) Op; + Node->Op = Op; /* Set the actual data type if appropriate (EXTERNAL term only) */ if (ActualObjectType != ACPI_TYPE_ANY) { Node->Type = (UINT8) ActualObjectType; - Node->OwnerId = ASL_EXTERNAL_METHOD; + Node->Value = ASL_EXTERNAL_METHOD; } if (Op->Asl.ParseOpcode == PARSEOP_METHOD) { /* - * Get the method argument count from "Extra" and store - * it in the OwnerId field of the namespace node + * Get the method argument count from "Extra" and save + * it in the namespace node */ - Node->OwnerId = (UINT16) Op->Asl.Extra; + Node->Value = (UINT32) Op->Asl.Extra; } Exit: @@ -649,7 +698,7 @@ Exit: * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS LdNamespace1End ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -692,7 +741,7 @@ LdNamespace1End ( "(%s): Popping scope for Op [%s] %p\n", AcpiUtGetTypeName (ObjectType), Op->Asl.ParseOpName, Op)); - AcpiDsScopeStackPop (WalkState); + (void) AcpiDsScopeStackPop (WalkState); } return (AE_OK); diff --git a/sys/contrib/dev/acpica/compiler/asllookup.c b/sys/contrib/dev/acpica/compiler/asllookup.c index b9a0cfe..750d53b 100644 --- a/sys/contrib/dev/acpica/compiler/asllookup.c +++ b/sys/contrib/dev/acpica/compiler/asllookup.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: asllookup- Namespace lookup - * $Revision: 83 $ + * $Revision: 1.95 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,18 +115,58 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" -#include "acparser.h" -#include "amlcode.h" -#include "acnamesp.h" -#include "acdispat.h" +#include <contrib/dev/acpica/acparser.h> +#include <contrib/dev/acpica/amlcode.h> +#include <contrib/dev/acpica/acnamesp.h> +#include <contrib/dev/acpica/acdispat.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("asllookup") +/* Local prototypes */ + +static ACPI_STATUS +LsCompareOneNamespaceObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +LsDoOneNamespaceObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +static BOOLEAN +LkObjectExists ( + char *Name); + +static void +LkCheckFieldRange ( + ACPI_PARSE_OBJECT *Op, + UINT32 RegionBitLength, + UINT32 FieldBitOffset, + UINT32 FieldBitLength, + UINT32 AccessBitWidth); + +static ACPI_STATUS +LkNamespaceLocateBegin ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static ACPI_STATUS +LkNamespaceLocateEnd ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + /******************************************************************************* * @@ -141,7 +181,7 @@ * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS LsDoOneNamespaceObject ( ACPI_HANDLE ObjHandle, UINT32 Level, @@ -149,6 +189,7 @@ LsDoOneNamespaceObject ( void **ReturnValue) { ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ACPI_OPERAND_OBJECT *ObjDesc; ACPI_PARSE_OBJECT *Op; @@ -159,60 +200,178 @@ LsDoOneNamespaceObject ( &Node->Name, AcpiUtGetTypeName (Node->Type)); - Op = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object); + Op = Node->Op; + ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node->Object); + + if (!Op) + { + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n"); + return (AE_OK); + } + - if (Op) + if ((ObjDesc) && + (ObjDesc->Common.Descriptor == ACPI_DESC_TYPE_OPERAND)) { - if (Op->Asl.ParseOpcode == PARSEOP_NAME) + switch (Node->Type) { - Op = Op->Asl.Child; + case ACPI_TYPE_INTEGER: + + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, + " [Initial Value 0x%8.8X%8.8X]", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + + case ACPI_TYPE_STRING: + + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, + " [Initial Value \"%s\"]", + ObjDesc->String.Pointer); + break; + + default: + /* Nothing to do for other types */ + break; } + } + else + { switch (Node->Type) { case ACPI_TYPE_INTEGER: + if (Op->Asl.ParseOpcode == PARSEOP_NAME) + { + Op = Op->Asl.Child; + } if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) { Op = Op->Asl.Next; } + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, + " [Initial Value 0x%8.8X%8.8X]", + ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer)); + break; + - if (Op->Asl.Value.Integer > ACPI_UINT32_MAX) + case ACPI_TYPE_STRING: + + if (Op->Asl.ParseOpcode == PARSEOP_NAME) { - FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Initial Value = 0x%X%X]", - ACPI_HIDWORD (Op->Asl.Value.Integer64), (UINT32) Op->Asl.Value.Integer); + Op = Op->Asl.Child; } - else + if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || + (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) { - FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Initial Value = 0x%X]", - (UINT32) Op->Asl.Value.Integer); + Op = Op->Asl.Next; } + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, + " [Initial Value \"%s\"]", + Op->Asl.Value.String); break; - case ACPI_TYPE_STRING: + case ACPI_TYPE_LOCAL_REGION_FIELD: if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) { - Op = Op->Asl.Next; + Op = Op->Asl.Child; } + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, + " [Offset 0x%04X Length 0x%04X bits]", + Op->Asl.Parent->Asl.ExtraValue, (UINT32) Op->Asl.Value.Integer); + break; - FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Initial Value = \"%s\"]", - Op->Asl.Value.String); + + case ACPI_TYPE_BUFFER_FIELD: + + switch (Op->Asl.ParseOpcode) + { + case PARSEOP_CREATEBYTEFIELD: + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [BYTE ( 8 bit)]"); + break; + + case PARSEOP_CREATEDWORDFIELD: + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [DWORD (32 bit)]"); + break; + + case PARSEOP_CREATEQWORDFIELD: + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [QWORD (64 bit)]"); + break; + + case PARSEOP_CREATEWORDFIELD: + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [WORD (16 bit)]"); + break; + + case PARSEOP_CREATEBITFIELD: + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [BIT ( 1 bit)]"); + break; + + case PARSEOP_CREATEFIELD: + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Arbitrary Bit Field]"); + break; + + default: + break; + + } break; - case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_PACKAGE: + if (Op->Asl.ParseOpcode == PARSEOP_NAME) + { + Op = Op->Asl.Child; + } if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) { + Op = Op->Asl.Next; + } + Op = Op->Asl.Child; + + if ((Op->Asl.ParseOpcode == PARSEOP_BYTECONST) || + (Op->Asl.ParseOpcode == PARSEOP_RAW_DATA)) + { + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, + " [Initial Length 0x%.2X elements]", + Op->Asl.Value.Integer); + } + break; + + + case ACPI_TYPE_BUFFER: + + if (Op->Asl.ParseOpcode == PARSEOP_NAME) + { Op = Op->Asl.Child; } - FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Offset 0x%02X, Length 0x%02X]", - Op->Asl.Parent->Asl.ExtraValue, (UINT32) Op->Asl.Value.Integer); + if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) || + (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)) + { + Op = Op->Asl.Next; + } + Op = Op->Asl.Child; + + if (Op->Asl.ParseOpcode == PARSEOP_INTEGER) + { + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, + " [Initial Length 0x%.2X bytes]", + Op->Asl.Value.Integer); + } + break; + + + case ACPI_TYPE_METHOD: + + FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, + " [Code Length 0x%.4X bytes]", + Op->Asl.AmlSubtreeLength); break; @@ -233,7 +392,7 @@ LsDoOneNamespaceObject ( * * PARAMETERS: None * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Walk the namespace an display information about each node * in the tree. Information is written to the optional @@ -261,8 +420,8 @@ LsDisplayNamespace ( /* Walk entire namespace from the root */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, LsDoOneNamespaceObject, - NULL, NULL); + ACPI_UINT32_MAX, FALSE, LsDoOneNamespaceObject, + NULL, NULL); return (Status); } @@ -279,7 +438,7 @@ LsDisplayNamespace ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS LsCompareOneNamespaceObject ( ACPI_HANDLE ObjHandle, UINT32 Level, @@ -314,7 +473,7 @@ LsCompareOneNamespaceObject ( * ******************************************************************************/ -BOOLEAN +static BOOLEAN LkObjectExists ( char *Name) { @@ -324,8 +483,8 @@ LkObjectExists ( /* Walk entire namespace from the supplied root */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, - ACPI_UINT32_MAX, FALSE, LsCompareOneNamespaceObject, - Name, NULL); + ACPI_UINT32_MAX, FALSE, LsCompareOneNamespaceObject, + Name, NULL); if (Status == AE_CTRL_TRUE) { /* At least one instance of the name was found */ @@ -402,7 +561,7 @@ LkCrossReferenceNamespace ( * ******************************************************************************/ -void +static void LkCheckFieldRange ( ACPI_PARSE_OBJECT *Op, UINT32 RegionBitLength, @@ -412,6 +571,7 @@ LkCheckFieldRange ( { UINT32 FieldEndBitOffset; + /* * Check each field unit against the region size. The entire * field unit (start offset plus length) must fit within the @@ -460,7 +620,7 @@ LkCheckFieldRange ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS LkNamespaceLocateBegin ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -557,7 +717,8 @@ LkNamespaceLocateBegin ( } ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode); - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Type=%s\n", AcpiUtGetTypeName (ObjectType))); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Type=%s\n", AcpiUtGetTypeName (ObjectType))); /* * Lookup the name in the namespace. Name must exist at this point, or it @@ -569,7 +730,7 @@ LkNamespaceLocateBegin ( Gbl_NsLookupCount++; Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node)); + ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node)); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) @@ -584,15 +745,27 @@ LkNamespaceLocateBegin ( if (LkObjectExists (Path)) { - /* There exists such a name, but we couldn't get to it from this scope */ - - AslError (ASL_ERROR, ASL_MSG_NOT_REACHABLE, Op, Op->Asl.ExternalName); + /* + * There exists such a name, but we couldn't get to it + * from this scope + */ + AslError (ASL_ERROR, ASL_MSG_NOT_REACHABLE, Op, + Op->Asl.ExternalName); } else { /* The name doesn't exist, period */ - AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, Op->Asl.ExternalName); + if ((Op->Asl.Parent) && + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) + { + /* Ignore not found if parent is CondRefOf */ + + return (AE_OK); + } + + AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, + Op, Op->Asl.ExternalName); } } else @@ -603,13 +776,25 @@ LkNamespaceLocateBegin ( { /* Gave full path, the object does not exist */ - AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, Op->Asl.ExternalName); + if ((Op->Asl.Parent) && + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF)) + { + /* Ignore not found if parent is CondRefOf */ + + return (AE_OK); + } + + AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, + Op->Asl.ExternalName); } else { - /* We can't tell whether it doesn't exist or just can't be reached. */ - - AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, Op->Asl.ExternalName); + /* + * We can't tell whether it doesn't exist or just + * can't be reached. + */ + AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op, + Op->Asl.ExternalName); } } @@ -626,11 +811,12 @@ LkNamespaceLocateBegin ( * Dereference an alias. (A name reference that is an alias.) * Aliases are not nested; The alias always points to the final object */ - if ((Op->Asl.ParseOpcode != PARSEOP_ALIAS) && (Node->Type == ACPI_TYPE_LOCAL_ALIAS)) + if ((Op->Asl.ParseOpcode != PARSEOP_ALIAS) && + (Node->Type == ACPI_TYPE_LOCAL_ALIAS)) { /* This node points back to the original PARSEOP_ALIAS */ - NextOp = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object); + NextOp = Node->Op; /* The first child is the alias target op */ @@ -644,7 +830,8 @@ LkNamespaceLocateBegin ( } else { - AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, "Missing alias link"); + AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, + "Missing alias link"); } } @@ -659,7 +846,7 @@ LkNamespaceLocateBegin ( * the field type) and change the named reference into an integer for * AML code generation */ - Temp = (UINT32) Node->OwnerId; + Temp = Node->Value; if (Node->Flags & ANOBJ_IS_BIT_OFFSET) { Op->Asl.CompileFlags |= NODE_IS_BIT_OFFSET; @@ -715,12 +902,12 @@ LkNamespaceLocateBegin ( /* Now convert this node to an integer whose value is the field offset */ + Op->Asl.AmlLength = 0; Op->Asl.ParseOpcode = PARSEOP_INTEGER; Op->Asl.Value.Integer = (UINT64) Temp; Op->Asl.CompileFlags |= NODE_IS_RESOURCE_FIELD; OpcGenerateAmlOpcode (Op); - Op->Asl.AmlLength = OpcSetOptimalIntegerSize (Op); } /* 2) Check for a method invocation */ @@ -734,14 +921,28 @@ LkNamespaceLocateBegin ( { /* + * A reference to a method within one of these opcodes is not an + * invocation of the method, it is simply a reference to the method. + */ + if ((Op->Asl.Parent) && + ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEREFOF) || + (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE))) + { + return (AE_OK); + } + /* * There are two types of method invocation: - * 1) Invocation with arguments -- the parser recognizes this as a METHODCALL - * 2) Invocation with no arguments --the parser cannot determine that this is a method - * invocation, therefore we have to figure it out here. + * 1) Invocation with arguments -- the parser recognizes this + * as a METHODCALL. + * 2) Invocation with no arguments --the parser cannot determine that + * this is a method invocation, therefore we have to figure it out + * here. */ if (Node->Type != ACPI_TYPE_METHOD) { - sprintf (MsgBuffer, "%s is a %s", Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); + sprintf (MsgBuffer, "%s is a %s", + Op->Asl.ExternalName, AcpiUtGetTypeName (Node->Type)); AslError (ASL_ERROR, ASL_MSG_NOT_METHOD, Op, MsgBuffer); return (AE_OK); @@ -772,18 +973,18 @@ LkNamespaceLocateBegin ( NextOp = NextOp->Asl.Next; } - if (Node->OwnerId != ASL_EXTERNAL_METHOD) + if (Node->Value != ASL_EXTERNAL_METHOD) { /* * Check the parsed arguments with the number expected by the * method declaration itself */ - if (PassedArgs != Node->OwnerId) + if (PassedArgs != Node->Value) { sprintf (MsgBuffer, "%s requires %d", Op->Asl.ExternalName, - Node->OwnerId); + Node->Value); - if (PassedArgs < Node->OwnerId) + if (PassedArgs < Node->Value) { AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_LO, Op, MsgBuffer); } @@ -795,9 +996,8 @@ LkNamespaceLocateBegin ( } } - /* - * 3) Check for an ASL Field definition - */ + /* 3) Check for an ASL Field definition */ + else if ((Op->Asl.Parent) && ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_FIELD) || (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_BANKFIELD))) @@ -818,8 +1018,9 @@ LkNamespaceLocateBegin ( * the name of the region. Get the parse node for the * region -- which contains the length of the region. */ - OwningOp = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Node->Object); - Op->Asl.Parent->Asl.ExtraValue = ACPI_MUL_8 ((UINT32) OwningOp->Asl.Value.Integer); + OwningOp = Node->Op; + Op->Asl.Parent->Asl.ExtraValue = + ACPI_MUL_8 ((UINT32) OwningOp->Asl.Value.Integer); /* Examine the field access width */ @@ -926,7 +1127,7 @@ LkNamespaceLocateBegin ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS LkNamespaceLocateEnd ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -965,7 +1166,7 @@ LkNamespaceLocateEnd ( "%s: Popping scope for Op %p\n", AcpiUtGetTypeName (OpInfo->ObjectType), Op)); - AcpiDsScopeStackPop (WalkState); + (void) AcpiDsScopeStackPop (WalkState); } return (AE_OK); diff --git a/sys/contrib/dev/acpica/compiler/aslmain.c b/sys/contrib/dev/acpica/compiler/aslmain.c index 8d82026..3e8d2c6 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: 77 $ + * $Revision: 1.87 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -118,9 +118,9 @@ #define _DECLARE_GLOBALS -#include "aslcompiler.h" -#include "acnamesp.h" -#include "acapps.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/acnamesp.h> +#include <contrib/dev/acpica/acapps.h> #ifdef _DEBUG #include <crtdbg.h> @@ -133,9 +133,39 @@ BOOLEAN AslToFile = TRUE; BOOLEAN DoCompile = TRUE; BOOLEAN DoSignon = TRUE; -char hex[] = {'0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F'}; +char hex[] = +{ + '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' +}; + +/* Local prototypes */ + +static void +Options ( + void); + +static void +HelpMessage ( + void); + +static void +Usage ( + void); + +static void +AslInitialize ( + void); +static void +AslCommandLine ( + int argc, + char **argv); + +#ifdef _DEBUG +#if ACPI_MACHINE_WIDTH != 16 +#include <crtdbg.h> +#endif +#endif /******************************************************************************* * @@ -149,7 +179,7 @@ char hex[] = {'0','1','2','3','4','5','6','7', * ******************************************************************************/ -void +static void Options ( void) { @@ -182,9 +212,13 @@ Options ( printf (" -d [file] Disassemble AML to ASL source code file (*.dsl)\n"); printf (" -dc [file] Disassemble AML and immediately compile it\n"); printf (" (Obtain DSDT from current system if no input file)\n"); + printf (" -2 Emit ACPI 2.0 compatible ASL code\n"); printf (" -e Generate External() statements for unresolved symbols\n"); printf (" -g Get ACPI tables and write to files (*.dat)\n"); + printf ("\nMiscellaneous:\n"); + printf (" -a Verify source file is entirely ASCII text (0x00-0x7F)\n"); + printf ("\nHelp:\n"); printf (" -h Additional help and compiler debug options\n"); printf (" -hc Display operators allowed in constant expressions\n"); @@ -194,7 +228,7 @@ Options ( /******************************************************************************* * - * FUNCTION: Usage + * FUNCTION: HelpMessage * * PARAMETERS: None * @@ -204,7 +238,7 @@ Options ( * ******************************************************************************/ -void +static void HelpMessage ( void) { @@ -242,7 +276,7 @@ HelpMessage ( * ******************************************************************************/ -void +static void Usage ( void) { @@ -264,8 +298,9 @@ Usage ( * ******************************************************************************/ -void -AslInitialize (void) +static void +AslInitialize ( + void) { UINT32 i; @@ -302,13 +337,13 @@ AslInitialize (void) * ******************************************************************************/ -void +static void AslCommandLine ( int argc, char **argv) { BOOLEAN BadCommandLine = FALSE; - ACPI_NATIVE_UINT j; + ACPI_NATIVE_INT j; /* Minimum command line contains at least one option or an input file */ @@ -322,10 +357,15 @@ AslCommandLine ( /* Get the command line options */ - while ((j = AcpiGetopt (argc, argv, "ab:cd^efgh^i^l^o:p:r:s:t:v:x:")) != EOF) switch (j) + while ((j = AcpiGetopt (argc, argv, "2ab:cd^efgh^i^l^o:p:r:s:t:v:x:")) != EOF) switch (j) { + case '2': + Gbl_Acpi2 = TRUE; + break; + + case 'a': - AslToFile = FALSE; + Gbl_CheckForAscii = TRUE; break; @@ -647,7 +687,10 @@ AslCommandLine ( /* Next parameter must be the input filename */ Gbl_Files[ASL_FILE_INPUT].Filename = argv[AcpiGbl_Optind]; - if (!Gbl_Files[ASL_FILE_INPUT].Filename && !Gbl_DisasmFlag && !Gbl_GetAllTables) + + if (!Gbl_Files[ASL_FILE_INPUT].Filename && + !Gbl_DisasmFlag && + !Gbl_GetAllTables) { printf ("Missing input filename\n"); BadCommandLine = TRUE; @@ -697,6 +740,13 @@ main ( char *Prefix; +#ifdef _DEBUG +#if ACPI_MACHINE_WIDTH != 16 + _CrtSetDbgFlag (_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | + _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); +#endif +#endif + /* Init and command line */ AslInitialize (); @@ -706,17 +756,20 @@ main ( * If -p not specified, we will use the input filename as the * output filename prefix */ - FlSplitInputPathname (Gbl_Files[ASL_FILE_INPUT].Filename, + Status = FlSplitInputPathname (Gbl_Files[ASL_FILE_INPUT].Filename, &Gbl_DirectoryPath, &Prefix); + if (ACPI_FAILURE (Status)) + { + return -1; + } if (Gbl_UseDefaultAmlFilename) { Gbl_OutputFilenamePrefix = Prefix; } - /* - * AML Disassembly (Optional) - */ + /* AML Disassembly (Optional) */ + if (Gbl_DisasmFlag || Gbl_GetAllTables) { /* ACPI CA subsystem initialization */ @@ -768,8 +821,12 @@ main ( * If -p not specified, we will use the input filename as the * output filename prefix */ - FlSplitInputPathname (Gbl_Files[ASL_FILE_INPUT].Filename, + Status = FlSplitInputPathname (Gbl_Files[ASL_FILE_INPUT].Filename, &Gbl_DirectoryPath, &Prefix); + if (ACPI_FAILURE (Status)) + { + return -1; + } if (Gbl_UseDefaultAmlFilename) { diff --git a/sys/contrib/dev/acpica/compiler/aslmap.c b/sys/contrib/dev/acpica/compiler/aslmap.c index b0927f6..0969065 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: 76 $ + * $Revision: 1.80 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,9 +116,9 @@ *****************************************************************************/ -#include "aslcompiler.h" -#include "amlcode.h" -#include "acparser.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/amlcode.h> +#include <contrib/dev/acpica/acparser.h> #define _COMPONENT ACPI_COMPILER @@ -172,6 +172,56 @@ AslMapNamedOpcodeToDataType ( /******************************************************************************* * + * FUNCTION: MpDisplayReservedNames + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Print the table above + * + ******************************************************************************/ + +void +MpDisplayReservedNames ( + void) +{ + UINT32 i; + + printf ("Reserved name information\n\n"); + + for (i = 0; ReservedMethods[i].Name; i++) + { + printf ("%s ", ReservedMethods[i].Name); + + if (ReservedMethods[i].Flags & ASL_RSVD_SCOPE) + { + printf ("Reserved scope name\n"); + } + else if (ReservedMethods[i].Flags & ASL_RSVD_RESOURCE_NAME) + { + printf ("Resource data type reserved field name\n"); + } + else + { + printf ("Method with %d arguments, ", + ReservedMethods[i].NumArguments); + + if (ReservedMethods[i].Flags & ASL_RSVD_RETURN_VALUE) + { + printf ("must return a value\n"); + } + else + { + printf ("no return value\n"); + } + } + } +} + + +/******************************************************************************* + * * DATA STRUCTURE: ReservedMethods * * DESCRIPTION: Contains all reserved methods and names as defined in the @@ -401,54 +451,6 @@ const ASL_RESERVED_INFO ReservedMethods[] = { /******************************************************************************* * - * FUNCTION: MpDisplayReservedNames - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Print the table above - * - ******************************************************************************/ - -void -MpDisplayReservedNames ( - void) -{ - UINT32 i; - - printf ("Reserved name information\n\n"); - - for (i = 0; ReservedMethods[i].Name; i++) - { - printf ("%s ", ReservedMethods[i].Name); - - if (ReservedMethods[i].Flags & ASL_RSVD_SCOPE) - { - printf ("Reserved scope name\n"); - } - else if (ReservedMethods[i].Flags & ASL_RSVD_RESOURCE_NAME) - { - printf ("Resource data type reserved field name\n"); - } - else - { - printf ("Method with %d arguments, ", ReservedMethods[i].NumArguments); - if (ReservedMethods[i].Flags & ASL_RSVD_RETURN_VALUE) - { - printf ("must return a value\n"); - } - else - { - printf ("no return value\n"); - } - } - } -} - - -/******************************************************************************* - * * DATA STRUCTURE: AslKeywordMapping * * DESCRIPTION: Maps the ParseOpcode to the actual AML opcode. The parse @@ -647,6 +649,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* OBJECTTYPE_OPR */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_REGION, 0, 0), /* OBJECTTYPE_PKG */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_PACKAGE, 0, 0), /* OBJECTTYPE_POW */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_POWER, 0, 0), +/* OBJECTTYPE_PRO */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_PROCESSOR, 0, 0), /* OBJECTTYPE_STR */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_STRING, 0, 0), /* OBJECTTYPE_THZ */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_THERMAL, 0, 0), /* OBJECTTYPE_UNK */ OP_TABLE_ENTRY (AML_BYTE_OP, ACPI_TYPE_ANY, 0, 0), @@ -706,7 +709,7 @@ const ASL_MAPPING_ENTRY AslKeywordMapping [] = /* 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), +/* TOBUFFER */ OP_TABLE_ENTRY (AML_TO_BUFFER_OP, 0, 0, ACPI_BTYPE_BUFFER), /* 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), diff --git a/sys/contrib/dev/acpica/compiler/aslopcodes.c b/sys/contrib/dev/acpica/compiler/aslopcodes.c index 4f2033b..2191741 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: 60 $ + * $Revision: 1.71 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,14 +116,79 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" -#include "amlcode.h" +#include <contrib/dev/acpica/amlcode.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslopcodes") +/* UUID support */ + +static UINT8 OpcMapToUUID[16] = +{ + 6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34 +}; + +/* Local prototypes */ + +static void +OpcDoAccessAs ( + ACPI_PARSE_OBJECT *Op); + +static void +OpcDoUnicode ( + ACPI_PARSE_OBJECT *Op); + +static void +OpcDoEisaId ( + ACPI_PARSE_OBJECT *Op); + +static void +OpcDoUuId ( + ACPI_PARSE_OBJECT *Op); + + +/******************************************************************************* + * + * FUNCTION: OpcAmlOpcodeUpdateWalk + * + * PARAMETERS: ASL_WALK_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Opcode update walk, ascending callback + * + ******************************************************************************/ + +ACPI_STATUS +OpcAmlOpcodeUpdateWalk ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context) +{ + + /* + * Handle the Package() case where the actual opcode cannot be determined + * until the PackageLength operand has been folded and minimized. + * (PackageOp versus VarPackageOp) + * + * This is (as of ACPI 3.0) the only case where the AML opcode can change + * based upon the value of a parameter. + * + * The parser always inserts a VarPackage opcode, which can possibly be + * optimized to a Package opcode. + */ + if (Op->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE) + { + OpnDoPackage (Op); + } + + return (AE_OK); +} + + /******************************************************************************* * * FUNCTION: OpcAmlOpcodeWalk @@ -171,18 +236,26 @@ OpcGetIntegerWidth ( { ACPI_PARSE_OBJECT *Child; + if (!Op) { return; } - Child = Op->Asl.Child; - Child = Child->Asl.Next; - Child = Child->Asl.Next; + if (Gbl_RevisionOverride) + { + AcpiUtSetIntegerWidth (Gbl_RevisionOverride); + } + else + { + Child = Op->Asl.Child; + Child = Child->Asl.Next; + Child = Child->Asl.Next; - /* Use the revision to set the integer width */ + /* Use the revision to set the integer width */ - AcpiUtSetIntegerWidth ((UINT8) Child->Asl.Value.Integer); + AcpiUtSetIntegerWidth ((UINT8) Child->Asl.Value.Integer); + } } @@ -206,17 +279,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 0 + /* + * 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)) + (Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITIONBLOCK)) { return 0; } -*/ +#endif /* * Check for the special AML integers first - Zero, One, Ones. @@ -232,13 +306,15 @@ OpcSetOptimalIntegerSize ( case 0: Op->Asl.AmlOpcode = AML_ZERO_OP; - AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, Op, "Zero"); + AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, + Op, "Zero"); return 1; case 1: Op->Asl.AmlOpcode = AML_ONE_OP; - AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, Op, "One"); + AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, + Op, "One"); return 1; case ACPI_UINT32_MAX: @@ -248,7 +324,8 @@ OpcSetOptimalIntegerSize ( if (AcpiGbl_IntegerByteWidth == 4) { Op->Asl.AmlOpcode = AML_ONES_OP; - AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, Op, "Ones"); + AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, + Op, "Ones"); return 1; } break; @@ -260,7 +337,8 @@ OpcSetOptimalIntegerSize ( if (AcpiGbl_IntegerByteWidth == 8) { Op->Asl.AmlOpcode = AML_ONES_OP; - AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, Op, "Ones"); + AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION, + Op, "Ones"); return 1; } break; @@ -289,6 +367,19 @@ OpcSetOptimalIntegerSize ( } else { + if (AcpiGbl_IntegerByteWidth == 4) + { + AslError (ASL_WARNING, ASL_MSG_INTEGER_LENGTH, + Op, NULL); + + if (!Gbl_IgnoreErrors) + { + /* Truncate the integer to 32-bit */ + Op->Asl.AmlOpcode = AML_DWORD_OP; + return 4; + } + } + Op->Asl.AmlOpcode = AML_QWORD_OP; return 8; } @@ -307,11 +398,11 @@ OpcSetOptimalIntegerSize ( * ******************************************************************************/ -void +static void OpcDoAccessAs ( - ACPI_PARSE_OBJECT *Op) + ACPI_PARSE_OBJECT *Op) { - ACPI_PARSE_OBJECT *Next; + ACPI_PARSE_OBJECT *Next; Op->Asl.AmlOpcodeLength = 1; @@ -350,17 +441,17 @@ OpcDoAccessAs ( * ******************************************************************************/ -void +static void OpcDoUnicode ( - ACPI_PARSE_OBJECT *Op) + ACPI_PARSE_OBJECT *Op) { - ACPI_PARSE_OBJECT *InitializerOp; - UINT32 Length; - UINT32 Count; - UINT32 i; - UINT8 *AsciiString; - UINT16 *UnicodeString; - ACPI_PARSE_OBJECT *BufferLengthOp; + ACPI_PARSE_OBJECT *InitializerOp; + UINT32 Length; + UINT32 Count; + UINT32 i; + UINT8 *AsciiString; + UINT16 *UnicodeString; + ACPI_PARSE_OBJECT *BufferLengthOp; /* Change op into a buffer object */ @@ -448,7 +539,7 @@ OpcDoUnicode ( * ******************************************************************************/ -void +static void OpcDoEisaId ( ACPI_PARSE_OBJECT *Op) { @@ -463,7 +554,7 @@ OpcDoEisaId ( /* * The EISAID string must be exactly 7 characters and of the form - * "LLLXXXX" -- 3 letters and 4 hex digits (e.g., "PNP0001") + * "UUUXXXX" -- 3 uppercase letters and 4 hex digits (e.g., "PNP0001") */ if (ACPI_STRLEN (InString) != 7) { @@ -540,13 +631,11 @@ OpcDoEisaId ( * * RETURN: None * - * DESCRIPTION: + * DESCRIPTION: Convert UUID string to 16-byte buffer * ******************************************************************************/ -static UINT8 OpcMapToUUID[16] = {6,4,2,0,11,9,16,14,19,21,24,26,28,30,32,34}; - -void +static void OpcDoUuId ( ACPI_PARSE_OBJECT *Op) { @@ -594,15 +683,18 @@ OpcDoUuId ( } else for (i = 0; i < 16; i++) { - Buffer[i] = (char) (UtHexCharToValue (InString[OpcMapToUUID[i]]) << 4); - Buffer[i] = (char) UtHexCharToValue (InString[OpcMapToUUID[i] + 1]); + 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 */ + + /* Disable further optimization */ + + Op->Asl.CompileFlags &= ~NODE_COMPILE_TIME_CONST; UtSetParseOpName (Op); /* Child node is the buffer length */ @@ -709,18 +801,6 @@ OpcGenerateAmlOpcode ( Op->Asl.Child->Asl.Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; break; - case PARSEOP_PACKAGE: - /* - * The variable-length package has a different opcode - */ - if ((Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && - (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_INTEGER) && - (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_BYTECONST)) - { - Op->Asl.AmlOpcode = AML_VAR_PACKAGE_OP; - } - break; - default: /* Nothing to do for other opcodes */ break; diff --git a/sys/contrib/dev/acpica/compiler/asloperands.c b/sys/contrib/dev/acpica/compiler/asloperands.c index 71b879c..fb465e9 100644 --- a/sys/contrib/dev/acpica/compiler/asloperands.c +++ b/sys/contrib/dev/acpica/compiler/asloperands.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: asloperands - AML operand processing - * $Revision: 46 $ + * $Revision: 1.57 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,13 +116,90 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" -#include "amlcode.h" +#include <contrib/dev/acpica/amlcode.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("asloperands") +/* Local prototypes */ + +static void +OpnDoField ( + ACPI_PARSE_OBJECT *Op); + +static void +OpnDoBankField ( + ACPI_PARSE_OBJECT *Op); + +static void +OpnDoBuffer ( + ACPI_PARSE_OBJECT *Op); + +static void +OpnDoDefinitionBlock ( + ACPI_PARSE_OBJECT *Op); + +static void +OpnDoFieldCommon ( + ACPI_PARSE_OBJECT *FieldOp, + ACPI_PARSE_OBJECT *Op); + +static void +OpnDoIndexField ( + ACPI_PARSE_OBJECT *Op); + +static void +OpnDoLoadTable ( + ACPI_PARSE_OBJECT *Op); + +static void +OpnDoMethod ( + ACPI_PARSE_OBJECT *Op); + +static void +OpnDoMutex ( + ACPI_PARSE_OBJECT *Op); + +static void +OpnDoRegion ( + ACPI_PARSE_OBJECT *Op); + +static void +OpnAttachNameToNode ( + ACPI_PARSE_OBJECT *Op); + + +/******************************************************************************* + * + * FUNCTION: OpnDoMutex + * + * PARAMETERS: Op - The parent parse node + * + * RETURN: None + * + * DESCRIPTION: Construct the operands for the MUTEX ASL keyword. + * + ******************************************************************************/ + +static void +OpnDoMutex ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Next; + + + Next = Op->Asl.Child; + Next = Next->Asl.Next; + + if (Next->Asl.Value.Integer > 15) + { + AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL); + } + return; +} + /******************************************************************************* * @@ -136,7 +213,7 @@ * ******************************************************************************/ -void +static void OpnDoMethod ( ACPI_PARSE_OBJECT *Op) { @@ -173,11 +250,15 @@ OpnDoMethod ( Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; } - /* Concurrency value (0-15 valid) */ + /* Concurrency value (valid values are 0-15) */ Next = Next->Asl.Next; if (Next->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { + if (Next->Asl.Value.Integer > 15) + { + AslError (ASL_ERROR, ASL_MSG_SYNC_LEVEL, Next, NULL); + } Concurrency = (UINT8) Next->Asl.Value.Integer; } @@ -214,7 +295,7 @@ OpnDoMethod ( * ******************************************************************************/ -void +static void OpnDoFieldCommon ( ACPI_PARSE_OBJECT *FieldOp, ACPI_PARSE_OBJECT *Op) @@ -305,7 +386,8 @@ OpnDoFieldCommon ( * Not allowed to specify a backwards offset! * Issue error and ignore this node. */ - AslError (ASL_ERROR, ASL_MSG_BACKWARDS_OFFSET, PkgLengthNode, NULL); + AslError (ASL_ERROR, ASL_MSG_BACKWARDS_OFFSET, PkgLengthNode, + NULL); Next->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; PkgLengthNode->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; } @@ -324,7 +406,8 @@ OpnDoFieldCommon ( * Valid new offset - set the value to be inserted into the AML * and update the offset counter. */ - PkgLengthNode->Asl.Value.Integer = NewBitOffset - CurrentBitOffset; + PkgLengthNode->Asl.Value.Integer = + NewBitOffset - CurrentBitOffset; CurrentBitOffset = NewBitOffset; } break; @@ -390,7 +473,7 @@ OpnDoFieldCommon ( * ******************************************************************************/ -void +static void OpnDoField ( ACPI_PARSE_OBJECT *Op) { @@ -420,7 +503,7 @@ OpnDoField ( * ******************************************************************************/ -void +static void OpnDoIndexField ( ACPI_PARSE_OBJECT *Op) { @@ -454,7 +537,7 @@ OpnDoIndexField ( * ******************************************************************************/ -void +static void OpnDoBankField ( ACPI_PARSE_OBJECT *Op) { @@ -493,7 +576,7 @@ OpnDoBankField ( * ******************************************************************************/ -void +static void OpnDoRegion ( ACPI_PARSE_OBJECT *Op) { @@ -541,7 +624,7 @@ OpnDoRegion ( * ******************************************************************************/ -void +static void OpnDoBuffer ( ACPI_PARSE_OBJECT *Op) { @@ -639,9 +722,9 @@ OpnDoBuffer ( if (!BufferLength) { - /* No length AND no items -- issue a warning */ + /* No length AND no items -- issue notice */ - AslError (ASL_WARNING, ASL_MSG_BUFFER_LENGTH, BufferLengthOp, NULL); + AslError (ASL_REMARK, ASL_MSG_BUFFER_LENGTH, BufferLengthOp, NULL); /* But go ahead and put the buffer length of zero into the AML */ } @@ -668,7 +751,9 @@ OpnDoBuffer ( * * RETURN: None * - * DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword. + * DESCRIPTION: Construct the AML operands for the PACKAGE ASL keyword. NOTE: + * can only be called after constants have been folded, to ensure + * that the PackageLength operand has been fully reduced. * ******************************************************************************/ @@ -678,23 +763,16 @@ OpnDoPackage ( { ACPI_PARSE_OBJECT *InitializerOp; ACPI_PARSE_OBJECT *PackageLengthOp; + UINT32 PackageLength = 0; - /* Optional arguments for this opcode with defaults */ - - UINT32 PackageLength = 0; - - /* Opcode and package length first */ - /* Buffer Length is next, followed by the initializer list */ + /* Opcode and package length first, followed by the initializer list */ PackageLengthOp = Op->Asl.Child; InitializerOp = PackageLengthOp->Asl.Next; - /* - * We always count the number of items in the initializer list, because if - * it is larger than the buffer length, we will define the buffer size - * to be the size of the initializer list (Per ACPI Spec) - */ + /* Count the number of items in the initializer list */ + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { /* The peer list contains the byte list (if any...) */ @@ -706,43 +784,78 @@ OpnDoPackage ( } } - /* Check if initializer list is longer than the buffer length */ + /* If package length is a constant, compare to the initializer list */ if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) || - (PackageLengthOp->Asl.ParseOpcode == PARSEOP_BYTECONST)) + (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST)) { - if (PackageLengthOp->Asl.Value.Integer > PackageLength) + if (PackageLengthOp->Asl.Value.Integer >= PackageLength) { + /* Allow package to be longer than the initializer list */ + PackageLength = (UINT32) PackageLengthOp->Asl.Value.Integer; } + else + { + /* + * Initializer list is longer than the package length. This + * is an error as per the ACPI spec. + */ + AslError (ASL_ERROR, ASL_MSG_LIST_LENGTH, + PackageLengthOp->Asl.Next, NULL); + } } - /* - * If not a variable-length package, check for a zero - * package length - */ + if (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) + { + /* + * This is the case if the PackageLength was left empty - Package() + * The package length becomes the length of the initializer list + */ + Op->Asl.Child->Asl.ParseOpcode = PARSEOP_INTEGER; + Op->Asl.Child->Asl.Value.Integer = PackageLength; + + /* Set the AML opcode */ + + (void) OpcSetOptimalIntegerSize (Op->Asl.Child); + } + + /* If not a variable-length package, check for a zero package length */ + if ((PackageLengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) || - (PackageLengthOp->Asl.ParseOpcode == PARSEOP_BYTECONST) || + (PackageLengthOp->Asl.ParseOpcode == PARSEOP_QWORDCONST) || (PackageLengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)) { if (!PackageLength) { - /* No length AND no items -- issue a warning */ + /* No length AND no initializer list -- issue a remark */ - AslError (ASL_WARNING, ASL_MSG_PACKAGE_LENGTH, PackageLengthOp, NULL); + AslError (ASL_REMARK, ASL_MSG_PACKAGE_LENGTH, + PackageLengthOp, NULL); /* But go ahead and put the buffer length of zero into the AML */ } } /* - * Just set the buffer size node to be the buffer length, regardless - * of whether it was previously an integer or a default_arg placeholder + * If the PackageLength is a constant <= 255, we can change the + * AML opcode from VarPackage to a simple (ACPI 1.0) Package opcode. */ - PackageLengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; - PackageLengthOp->Asl.AmlLength = 1; - PackageLengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; - PackageLengthOp->Asl.Value.Integer = PackageLength; + if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) && + (Op->Asl.Child->Asl.Value.Integer <= 255)) + { + Op->Asl.AmlOpcode = AML_PACKAGE_OP; + Op->Asl.ParseOpcode = PARSEOP_PACKAGE; + + /* + * Just set the package size node to be the package length, regardless + * of whether it was previously an integer or a default_arg placeholder + */ + PackageLengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE; + PackageLengthOp->Asl.AmlLength = 1; + PackageLengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA; + PackageLengthOp->Asl.Value.Integer = PackageLength; + } /* Remaining nodes are handled via the tree walk */ } @@ -760,7 +873,7 @@ OpnDoPackage ( * ******************************************************************************/ -void +static void OpnDoLoadTable ( ACPI_PARSE_OBJECT *Op) { @@ -791,10 +904,12 @@ OpnDoLoadTable ( OpcGenerateAmlOpcode (Next); } +#ifdef ASL_FUTURE_IMPLEMENTATION + + /* TBD: NOT IMPLEMENTED */ /* Fifth child is the [optional] ParameterPathString */ /* Sixth child is the [optional] ParameterData */ -/* Next = Next->Asl.Next; if (Next->Asl.ParseOpcode == DEFAULT_ARG) { @@ -811,7 +926,7 @@ OpnDoLoadTable ( Next->Asl.ParseOpcode = ZERO; OpcGenerateAmlOpcode (Next); } - */ +#endif } @@ -827,7 +942,7 @@ OpnDoLoadTable ( * ******************************************************************************/ -void +static void OpnDoDefinitionBlock ( ACPI_PARSE_OBJECT *Op) { @@ -862,14 +977,16 @@ OpnDoDefinitionBlock ( Gbl_TableSignature = Child->Asl.Value.String; if (ACPI_STRLEN (Gbl_TableSignature) != 4) { - AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child, "Length not exactly 4"); + AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child, + "Length not exactly 4"); } for (i = 0; i < 4; i++) { if (!isalnum (Gbl_TableSignature[i])) { - AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child, "Contains non-alphanumeric characters"); + AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child, + "Contains non-alphanumeric characters"); } } } @@ -963,7 +1080,7 @@ UtGetArg ( * ******************************************************************************/ -void +static void OpnAttachNameToNode ( ACPI_PARSE_OBJECT *Op) { @@ -1062,6 +1179,10 @@ OpnGenerateAmlOperands ( OpnDoMethod (Op); break; + case PARSEOP_MUTEX: + OpnDoMutex (Op); + break; + case PARSEOP_FIELD: OpnDoField (Op); break; @@ -1082,10 +1203,6 @@ OpnGenerateAmlOperands ( OpnDoLoadTable (Op); break; - case PARSEOP_PACKAGE: - OpnDoPackage (Op); - break; - case PARSEOP_OPERATIONREGION: OpnDoRegion (Op); break; diff --git a/sys/contrib/dev/acpica/compiler/aslopt.c b/sys/contrib/dev/acpica/compiler/aslopt.c index f0416d8..e406abb 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: 16 $ + * $Revision: 1.21 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -115,19 +115,51 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" -#include "acparser.h" -#include "amlcode.h" -#include "acnamesp.h" +#include <contrib/dev/acpica/acparser.h> +#include <contrib/dev/acpica/amlcode.h> +#include <contrib/dev/acpica/acnamesp.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslopt") -UINT32 OptTotal = 0; +static UINT32 OptTotal = 0; + +/* Local prototypes */ + +static ACPI_STATUS +OptSearchToRoot ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *CurrentNode, + ACPI_NAMESPACE_NODE *TargetNode, + ACPI_BUFFER *TargetPath, + char **NewPath); + +static ACPI_STATUS +OptBuildShortestPath ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *CurrentNode, + ACPI_NAMESPACE_NODE *TargetNode, + ACPI_BUFFER *CurrentPath, + ACPI_BUFFER *TargetPath, + ACPI_SIZE AmlNameStringLength, + UINT8 IsDeclaration, + char **ReturnNewPath); + +static ACPI_STATUS +OptOptimizeNameDeclaration ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *CurrentNode, + ACPI_NAMESPACE_NODE *TargetNode, + char *AmlNameString, + char **NewPath); /******************************************************************************* @@ -149,7 +181,7 @@ UINT32 OptTotal = 0; * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS OptSearchToRoot ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState, @@ -174,7 +206,8 @@ OptSearchToRoot ( * name in the search path before the one we want, the nodes will * not match, and we cannot use this optimization. */ - Path = &(((char *) TargetPath->Pointer)[TargetPath->Length - ACPI_NAME_SIZE]), + Path = &(((char *) TargetPath->Pointer)[TargetPath->Length - + ACPI_NAME_SIZE]), ScopeInfo.Scope.Node = CurrentNode; /* Lookup the NameSeg using SEARCH_PARENT (search-to-root) */ @@ -241,7 +274,7 @@ OptSearchToRoot ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS OptBuildShortestPath ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState, @@ -295,8 +328,10 @@ OptBuildShortestPath ( /* Compare two single NameSegs */ if (ACPI_STRNCMP ( - &((char *) TargetPath->Pointer)[(NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1], - &((char *) CurrentPath->Pointer)[(NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1], + &((char *) TargetPath->Pointer)[(NumCommonSegments * + ACPI_PATH_SEGMENT_LENGTH) + 1], + &((char *) CurrentPath->Pointer)[(NumCommonSegments * + ACPI_PATH_SEGMENT_LENGTH) + 1], ACPI_NAME_SIZE)) { /* Mismatch */ @@ -305,7 +340,8 @@ OptBuildShortestPath ( } } - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " COMMON: %d", NumCommonSegments)); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " COMMON: %d", + NumCommonSegments)); /* There must be at least 1 common NameSeg in order to optimize */ @@ -330,12 +366,13 @@ OptBuildShortestPath ( /* Determine how many prefix Carats are required */ - NumCarats = (CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH) - NumCommonSegments; + NumCarats = (CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH) - + NumCommonSegments; /* * Construct a new target string */ - NewPathExternal = ACPI_MEM_CALLOCATE (TargetPath->Length + NumCarats); + NewPathExternal = ACPI_MEM_CALLOCATE (TargetPath->Length + NumCarats + 1); /* Insert the Carats into the Target string */ @@ -344,8 +381,10 @@ OptBuildShortestPath ( NewPathExternal[i] = '^'; } - /* Copy only the necessary (optimal) segments from the original target string */ - + /* + * Copy only the necessary (optimal) segments from the original + * target string + */ Index = (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1; /* Special handling for exact subpath in a name declaration */ @@ -353,8 +392,9 @@ OptBuildShortestPath ( if (IsDeclaration && SubPath && (CurrentPath->Length > TargetPath->Length)) { /* - * The current path is longer than the target, and the target is a subpath - * of the current path. We must include one more NameSeg of the target path + * The current path is longer than the target, and the target is a + * subpath of the current path. We must include one more NameSeg of + * the target path */ Index -= ACPI_PATH_SEGMENT_LENGTH; @@ -368,26 +408,36 @@ OptBuildShortestPath ( } } + /* Make sure we haven't gone off the end of the target path */ + + if (Index > TargetPath->Length) + { + Index = TargetPath->Length; + } + + ACPI_STRCPY (&NewPathExternal[i], &((char *) TargetPath->Pointer)[Index]); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal)); /* - * Internalize the new target string and check it against the original string - * to make sure that this is in fact an optimization. If the original string - * is already optimal, there is no point in continuing. + * Internalize the new target string and check it against the original + * string to make sure that this is in fact an optimization. If the + * original string is already optimal, there is no point in continuing. */ Status = AcpiNsInternalizeName (NewPathExternal, &NewPath); if (ACPI_FAILURE (Status)) { - AslCoreSubsystemError (Op, Status, "Internalizing new NamePath", ASL_NO_ABORT); + AslCoreSubsystemError (Op, Status, "Internalizing new NamePath", + ASL_NO_ABORT); ACPI_MEM_FREE (NewPathExternal); return (Status); } if (ACPI_STRLEN (NewPath) >= AmlNameStringLength) { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " NOT SHORTER (New %d old %d)", + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, + " NOT SHORTER (New %d old %d)", ACPI_STRLEN (NewPath), AmlNameStringLength)); ACPI_MEM_FREE (NewPathExternal); return (AE_NOT_FOUND); @@ -454,7 +504,7 @@ OptBuildShortestPath ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS OptOptimizeNameDeclaration ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState, @@ -488,7 +538,8 @@ OptOptimizeNameDeclaration ( NULL, &NewPathExternal); if (ACPI_FAILURE (Status)) { - AslCoreSubsystemError (Op, Status, "Externalizing NamePath", ASL_NO_ABORT); + AslCoreSubsystemError (Op, Status, "Externalizing NamePath", + ASL_NO_ABORT); return (Status); } @@ -520,7 +571,8 @@ OptOptimizeNameDeclaration ( /* Node is not correct, do not use this optimization */ Status = AE_NOT_FOUND; - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** WRONG NODE")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, + " ***** WRONG NODE")); AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op, "Not using optimized name - found wrong node"); } @@ -529,7 +581,8 @@ OptOptimizeNameDeclaration ( { /* The lookup failed, we obviously cannot use this optimization */ - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** NOT FOUND")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, + " ***** NOT FOUND")); AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op, "Not using optimized name - did not find node"); } @@ -644,8 +697,10 @@ OptOptimizeNamePath ( ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME")); - /* The node of interest is the parent of this node (the containing scope) */ - + /* + * The node of interest is the parent of this node + * (the containing scope) + */ CurrentNode = Op->Asl.Parent->Asl.Node; if (!CurrentNode) { @@ -668,7 +723,8 @@ OptOptimizeNamePath ( Status = AcpiNsHandleToPathname (TargetNode, &TargetPath); if (ACPI_FAILURE (Status)) { - AslCoreSubsystemError (Op, Status, "Getting Target NamePath", ASL_NO_ABORT); + AslCoreSubsystemError (Op, Status, "Getting Target NamePath", + ASL_NO_ABORT); return_VOID; } TargetPath.Length--; /* Subtract one for null terminator */ @@ -679,7 +735,8 @@ OptOptimizeNamePath ( Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath); if (ACPI_FAILURE (Status)) { - AslCoreSubsystemError (Op, Status, "Getting Current NamePath", ASL_NO_ABORT); + AslCoreSubsystemError (Op, Status, "Getting Current NamePath", + ASL_NO_ABORT); return_VOID; } CurrentPath.Length--; /* Subtract one for null terminator */ @@ -690,7 +747,8 @@ OptOptimizeNamePath ( NULL, &ExternalNameString); if (ACPI_FAILURE (Status)) { - AslCoreSubsystemError (Op, Status, "Externalizing NamePath", ASL_NO_ABORT); + AslCoreSubsystemError (Op, Status, "Externalizing NamePath", + ASL_NO_ABORT); return_VOID; } diff --git a/sys/contrib/dev/acpica/compiler/aslresource.c b/sys/contrib/dev/acpica/compiler/aslresource.c index 304d798..6623fbe 100644 --- a/sys/contrib/dev/acpica/compiler/aslresource.c +++ b/sys/contrib/dev/acpica/compiler/aslresource.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslresource - Resource templates and descriptors - * $Revision: 32 $ + * $Revision: 1.38 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,9 +116,9 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" -#include "amlcode.h" +#include <contrib/dev/acpica/amlcode.h> #define _COMPONENT ACPI_COMPILER @@ -162,7 +162,7 @@ RsAllocateResourceNode ( * * FUNCTION: RsCreateBitField * - * PARAMETERS: Op - Resource field node + * PARAMETERS: Op - Resource field node * Name - Name of the field (Used only to reference * the field in the ASL, not in the AML) * ByteOffset - Offset from the field start @@ -185,7 +185,7 @@ RsCreateBitField ( { Op->Asl.ExternalName = Name; - Op->Asl.Value.Integer = (ByteOffset * 8) + BitOffset; + Op->Asl.Value.Integer = ((ACPI_INTEGER) ByteOffset * 8) + BitOffset; Op->Asl.CompileFlags |= (NODE_IS_RESOURCE_FIELD | NODE_IS_BIT_OFFSET); } @@ -194,7 +194,7 @@ RsCreateBitField ( * * FUNCTION: RsCreateByteField * - * PARAMETERS: Op - Resource field node + * PARAMETERS: Op - Resource field node * Name - Name of the field (Used only to reference * the field in the ASL, not in the AML) * ByteOffset - Offset from the field start @@ -225,7 +225,7 @@ RsCreateByteField ( * FUNCTION: RsSetFlagBits * * PARAMETERS: *Flags - Pointer to the flag byte - * Op - Flag initialization node + * Op - Flag initialization node * Position - Bit position within the flag byte * Default - Used if the node is DEFAULT. * @@ -292,6 +292,69 @@ RsCompleteNodeAndGetNext ( /******************************************************************************* * + * FUNCTION: RsCheckListForDuplicates + * + * PARAMETERS: Op - First op in the initializer list + * + * RETURN: None + * + * DESCRIPTION: Check an initializer list for duplicate values. Emits an error + * if any duplicates are found. + * + ******************************************************************************/ + +void +RsCheckListForDuplicates ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *NextValueOp = Op; + ACPI_PARSE_OBJECT *NextOp; + UINT32 Value; + + + if (!Op) + { + return; + } + + /* Search list once for each value in the list */ + + while (NextValueOp) + { + Value = (UINT32) NextValueOp->Asl.Value.Integer; + + /* Compare this value to all remaining values in the list */ + + NextOp = ASL_GET_PEER_NODE (NextValueOp); + while (NextOp) + { + if (NextOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + /* Compare values */ + + if (Value == (UINT32) NextOp->Asl.Value.Integer) + { + /* Emit error only once per duplicate node */ + + if (!(NextOp->Asl.CompileFlags & NODE_IS_DUPLICATE)) + { + NextOp->Asl.CompileFlags |= NODE_IS_DUPLICATE; + AslError (ASL_ERROR, ASL_MSG_DUPLICATE_ITEM, + NextOp, NULL); + } + } + } + + NextOp = ASL_GET_PEER_NODE (NextOp); + } + + NextValueOp = ASL_GET_PEER_NODE (NextValueOp); + } +} + + +/******************************************************************************* + * * FUNCTION: RsDoOneResourceDescriptor * * PARAMETERS: DescriptorTypeOp - Parent parse node of the descriptor @@ -318,26 +381,36 @@ RsDoOneResourceDescriptor ( switch (DescriptorTypeOp->Asl.ParseOpcode) { case PARSEOP_DMA: - Rnode = RsDoDmaDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoDmaDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_DWORDIO: - Rnode = RsDoDwordIoDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoDwordIoDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_DWORDMEMORY: - Rnode = RsDoDwordMemoryDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoDwordMemoryDescriptor (DescriptorTypeOp, + CurrentByteOffset); + break; + + case PARSEOP_DWORDSPACE: + Rnode = RsDoDwordSpaceDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_ENDDEPENDENTFN: switch (*State) { case ACPI_RSTATE_NORMAL: - AslError (ASL_ERROR, ASL_MSG_MISSING_STARTDEPENDENT, DescriptorTypeOp, NULL); + AslError (ASL_ERROR, ASL_MSG_MISSING_STARTDEPENDENT, + DescriptorTypeOp, NULL); break; case ACPI_RSTATE_START_DEPENDENT: - AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, DescriptorTypeOp, NULL); + AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, + DescriptorTypeOp, NULL); break; case ACPI_RSTATE_DEPENDENT_LIST: @@ -346,58 +419,91 @@ RsDoOneResourceDescriptor ( } *State = ACPI_RSTATE_NORMAL; - Rnode = RsDoEndDependentDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoEndDependentDescriptor (DescriptorTypeOp, + CurrentByteOffset); + break; + + case PARSEOP_EXTENDEDIO: + Rnode = RsDoExtendedIoDescriptor (DescriptorTypeOp, + CurrentByteOffset); + break; + + case PARSEOP_EXTENDEDMEMORY: + Rnode = RsDoExtendedMemoryDescriptor (DescriptorTypeOp, + CurrentByteOffset); + break; + + case PARSEOP_EXTENDEDSPACE: + Rnode = RsDoExtendedSpaceDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_FIXEDIO: - Rnode = RsDoFixedIoDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoFixedIoDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_INTERRUPT: - Rnode = RsDoInterruptDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoInterruptDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_IO: - Rnode = RsDoIoDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoIoDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_IRQ: - Rnode = RsDoIrqDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoIrqDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_IRQNOFLAGS: - Rnode = RsDoIrqNoFlagsDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoIrqNoFlagsDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_MEMORY24: - Rnode = RsDoMemory24Descriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoMemory24Descriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_MEMORY32: - Rnode = RsDoMemory32Descriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoMemory32Descriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_MEMORY32FIXED: - Rnode = RsDoMemory32FixedDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoMemory32FixedDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_QWORDIO: - Rnode = RsDoQwordIoDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoQwordIoDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_QWORDMEMORY: - Rnode = RsDoQwordMemoryDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoQwordMemoryDescriptor (DescriptorTypeOp, + CurrentByteOffset); + break; + + case PARSEOP_QWORDSPACE: + Rnode = RsDoQwordSpaceDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_REGISTER: - Rnode = RsDoGeneralRegisterDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoGeneralRegisterDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_STARTDEPENDENTFN: switch (*State) { case ACPI_RSTATE_START_DEPENDENT: - AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, DescriptorTypeOp, NULL); + AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, + DescriptorTypeOp, NULL); break; case ACPI_RSTATE_NORMAL: @@ -407,7 +513,8 @@ RsDoOneResourceDescriptor ( } *State = ACPI_RSTATE_START_DEPENDENT; - Rnode = RsDoStartDependentDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoStartDependentDescriptor (DescriptorTypeOp, + CurrentByteOffset); *State = ACPI_RSTATE_DEPENDENT_LIST; break; @@ -415,7 +522,8 @@ RsDoOneResourceDescriptor ( switch (*State) { case ACPI_RSTATE_START_DEPENDENT: - AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, DescriptorTypeOp, NULL); + AslError (ASL_ERROR, ASL_MSG_DEPENDENT_NESTING, + DescriptorTypeOp, NULL); break; case ACPI_RSTATE_NORMAL: @@ -425,24 +533,34 @@ RsDoOneResourceDescriptor ( } *State = ACPI_RSTATE_START_DEPENDENT; - Rnode = RsDoStartDependentNoPriDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoStartDependentNoPriDescriptor (DescriptorTypeOp, + CurrentByteOffset); *State = ACPI_RSTATE_DEPENDENT_LIST; break; case PARSEOP_VENDORLONG: - Rnode = RsDoVendorLargeDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoVendorLargeDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_VENDORSHORT: - Rnode = RsDoVendorSmallDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoVendorSmallDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_WORDBUSNUMBER: - Rnode = RsDoWordBusNumberDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoWordBusNumberDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_WORDIO: - Rnode = RsDoWordIoDescriptor (DescriptorTypeOp, CurrentByteOffset); + Rnode = RsDoWordIoDescriptor (DescriptorTypeOp, + CurrentByteOffset); + break; + + case PARSEOP_WORDSPACE: + Rnode = RsDoWordSpaceDescriptor (DescriptorTypeOp, + CurrentByteOffset); break; case PARSEOP_DEFAULT_ARG: @@ -540,7 +658,7 @@ RsDoResourceTemplate ( ACPI_PARSE_OBJECT *BufferOp; ACPI_PARSE_OBJECT *DescriptorTypeOp; ACPI_PARSE_OBJECT *LastOp = NULL; - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; UINT32 CurrentByteOffset = 0; ASL_RESOURCE_NODE HeadRnode; ASL_RESOURCE_NODE *PreviousRnode; @@ -567,7 +685,8 @@ RsDoResourceTemplate ( PreviousRnode = &HeadRnode; while (DescriptorTypeOp) { - Rnode = RsDoOneResourceDescriptor (DescriptorTypeOp, CurrentByteOffset, &State); + Rnode = RsDoOneResourceDescriptor (DescriptorTypeOp, CurrentByteOffset, + &State); /* * Update current byte offset to indicate the number of bytes from the @@ -593,14 +712,15 @@ RsDoResourceTemplate ( } /* - * Insert the EndTag descriptor after all other descriptors have been processed + * Insert the EndTag descriptor after all other descriptors have + * been processed */ - Rnode = RsAllocateResourceNode (sizeof (ASL_END_TAG_DESC)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_TAG)); Descriptor = Rnode->Buffer; - Descriptor->Et.DescriptorType = ACPI_RDESC_TYPE_END_TAG | + Descriptor->EndTag.DescriptorType = ACPI_RESOURCE_NAME_END_TAG | ASL_RDESC_END_TAG_SIZE; - Descriptor->Et.Checksum = 0; + Descriptor->EndTag.Checksum = 0; CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, Rnode); diff --git a/sys/contrib/dev/acpica/compiler/aslrestype1.c b/sys/contrib/dev/acpica/compiler/aslrestype1.c index 975a8e5..e81bcdd 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype1.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype1.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslrestype1 - Short (type1) resource templates and descriptors - * $Revision: 26 $ + * $Revision: 1.35 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,7 +116,7 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #define _COMPONENT ACPI_COMPILER @@ -142,23 +142,23 @@ RsDoDmaDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; UINT32 i; UINT8 DmaChannelMask = 0; + UINT8 DmaChannels = 0; InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (ASL_DMA_FORMAT_DESC)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA)); Descriptor = Rnode->Buffer; - Descriptor->Dma.DescriptorType = ACPI_RDESC_TYPE_DMA_FORMAT | + Descriptor->Dma.DescriptorType = ACPI_RESOURCE_NAME_DMA | ASL_RDESC_DMA_SIZE; - /* - * Process all child initialization nodes - */ + /* Process all child initialization nodes */ + for (i = 0; InitializerOp; i++) { switch (i) @@ -167,21 +167,21 @@ RsDoDmaDescriptor ( RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 5, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_DMATYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5); + CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5); break; case 1: /* Bus Master */ RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 2, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_BUSMASTER, - CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2); + CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2); break; case 2: /* Xfer Type (transfer width) */ RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 0, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_XFERTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0); + CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0); break; case 3: /* Name */ @@ -191,17 +191,45 @@ RsDoDmaDescriptor ( default: - /* All DMA channel bytes are handled here, after the flags and name */ + /* All DMA channel bytes are handled here, after flags and name */ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - DmaChannelMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer)); + /* Up to 8 channels can be specified in the list */ + + DmaChannels++; + if (DmaChannels > 8) + { + AslError (ASL_ERROR, ASL_MSG_DMA_LIST, + InitializerOp, NULL); + return (Rnode); + } + + /* Only DMA channels 0-7 are allowed (mask is 8 bits) */ + + if (InitializerOp->Asl.Value.Integer > 7) + { + AslError (ASL_ERROR, ASL_MSG_DMA_CHANNEL, + InitializerOp, NULL); + } + + /* Build the mask */ + + DmaChannelMask |= + (1 << ((UINT8) InitializerOp->Asl.Value.Integer)); } if (i == 4) /* case 4: First DMA byte */ { + /* Check now for duplicates in list */ + + RsCheckListForDuplicates (InitializerOp); + + /* Create a named field at the start of the list */ + RsCreateByteField (InitializerOp, ASL_RESNAME_DMA, - CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.DmaChannelMask)); + CurrentByteOffset + + ASL_RESDESC_OFFSET (Dma.DmaChannelMask)); } break; } @@ -235,15 +263,15 @@ RsDoEndDependentDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ASL_RESOURCE_NODE *Rnode; - Rnode = RsAllocateResourceNode (sizeof (ASL_END_DEPENDENT_DESC)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_DEPENDENT)); Descriptor = Rnode->Buffer; - Descriptor->End.DescriptorType = ACPI_RDESC_TYPE_END_DEPENDENT | - ASL_RDESC_END_DEPEND_SIZE; + Descriptor->EndDpf.DescriptorType = ACPI_RESOURCE_NAME_END_DEPENDENT | + ASL_RDESC_END_DEPEND_SIZE; return (Rnode); } @@ -267,38 +295,39 @@ RsDoFixedIoDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; UINT32 i; InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (ASL_FIXED_IO_PORT_DESC)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO)); Descriptor = Rnode->Buffer; - Descriptor->Iop.DescriptorType = ACPI_RDESC_TYPE_FIXED_IO_PORT | - ASL_RDESC_FIXED_IO_SIZE; + Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_FIXED_IO | + ASL_RDESC_FIXED_IO_SIZE; + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { switch (i) { case 0: /* Base Address */ - Descriptor->Fio.BaseAddress = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->FixedIo.Address = + (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_BASEADDRESS, - CurrentByteOffset + ASL_RESDESC_OFFSET (Fio.BaseAddress)); + CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address)); break; case 1: /* Length */ - Descriptor->Fio.Length = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->FixedIo.AddressLength = + (UINT8) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Fio.Length)); + CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.AddressLength)); break; case 2: /* Name */ @@ -338,59 +367,62 @@ RsDoIoDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; UINT32 i; InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (ASL_IO_PORT_DESC)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO)); Descriptor = Rnode->Buffer; - Descriptor->Iop.DescriptorType = ACPI_RDESC_TYPE_IO_PORT | - ASL_RDESC_IO_SIZE; + Descriptor->Io.DescriptorType = ACPI_RESOURCE_NAME_IO | + ASL_RDESC_IO_SIZE; + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { switch (i) { case 0: /* Decode size */ - RsSetFlagBits (&Descriptor->Iop.Information, InitializerOp, 0, 1); + RsSetFlagBits (&Descriptor->Io.Flags, InitializerOp, 0, 1); RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.Information), 0); + CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Flags), 0); break; case 1: /* Min Address */ - Descriptor->Iop.AddressMin = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Io.Minimum = + (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.AddressMin)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum)); break; case 2: /* Max Address */ - Descriptor->Iop.AddressMax = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Io.Maximum = + (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.AddressMax)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum)); break; case 3: /* Alignment */ - Descriptor->Iop.Alignment = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->Io.Alignment = + (UINT8) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_ALIGNMENT, - CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.Alignment)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Alignment)); break; case 4: /* Length */ - Descriptor->Iop.Length = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->Io.AddressLength = + (UINT8) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Iop.Length)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Io.AddressLength)); break; case 5: /* Name */ @@ -430,25 +462,25 @@ RsDoIrqDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; - UINT32 i; + UINT32 Interrupts = 0; UINT16 IrqMask = 0; + UINT32 i; InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (ASL_IRQ_FORMAT_DESC)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ)); /* Length = 3 (with flag byte) */ Descriptor = Rnode->Buffer; - Descriptor->Irq.DescriptorType = ACPI_RDESC_TYPE_IRQ_FORMAT | - (ASL_RDESC_IRQ_SIZE + 0x01); + Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | + (ASL_RDESC_IRQ_SIZE + 0x01); + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { switch (i) @@ -457,21 +489,21 @@ RsDoIrqDescriptor ( RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 0, 1); RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0); + CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0); break; case 1: /* Interrupt Level (or Polarity - Active high/low) */ RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 3, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTLEVEL, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3); + CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3); break; case 2: /* Share Type - Default: exclusive (0) */ RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 4, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTSHARE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4); + CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4); break; case 3: /* Name */ @@ -485,13 +517,41 @@ RsDoIrqDescriptor ( if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer); + /* Up to 16 interrupts can be specified in the list */ + + Interrupts++; + if (Interrupts > 16) + { + AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST, + InitializerOp, NULL); + return (Rnode); + } + + /* Only interrupts 0-15 are allowed (mask is 16 bits) */ + + if (InitializerOp->Asl.Value.Integer > 15) + { + AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER, + InitializerOp, NULL); + } + else + { + IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer); + } } - if (i == 4) /* case 4: First IRQ byte */ + /* Case 4: First IRQ value in list */ + + if (i == 4) { + /* Check now for duplicates in list */ + + RsCheckListForDuplicates (InitializerOp); + + /* Create a named field at the start of the list */ + RsCreateByteField (InitializerOp, ASL_RESNAME_INTERRUPT, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask)); } break; } @@ -525,23 +585,23 @@ RsDoIrqNoFlagsDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; - UINT32 i; UINT16 IrqMask = 0; + UINT32 Interrupts = 0; + UINT32 i; InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (ASL_IRQ_NOFLAGS_DESC)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS)); Descriptor = Rnode->Buffer; - Descriptor->Irq.DescriptorType = ACPI_RDESC_TYPE_IRQ_FORMAT | - ASL_RDESC_IRQ_SIZE; + Descriptor->Irq.DescriptorType = ACPI_RESOURCE_NAME_IRQ | + ASL_RDESC_IRQ_SIZE; + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { switch (i) @@ -557,13 +617,41 @@ RsDoIrqNoFlagsDescriptor ( if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer)); + /* Up to 16 interrupts can be specified in the list */ + + Interrupts++; + if (Interrupts > 16) + { + AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST, + InitializerOp, NULL); + return (Rnode); + } + + /* Only interrupts 0-15 are allowed (mask is 16 bits) */ + + if (InitializerOp->Asl.Value.Integer > 15) + { + AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER, + InitializerOp, NULL); + } + else + { + IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer)); + } } - if (i == 1) /* case 1: First IRQ byte */ + /* Case 1: First IRQ value in list */ + + if (i == 1) { + /* Check now for duplicates in list */ + + RsCheckListForDuplicates (InitializerOp); + + /* Create a named field at the start of the list */ + RsCreateByteField (InitializerOp, ASL_RESNAME_INTERRUPT, - CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask)); } break; } @@ -597,59 +685,58 @@ RsDoMemory24Descriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; UINT32 i; InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (ASL_MEMORY_24_DESC)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24)); Descriptor = Rnode->Buffer; - Descriptor->M24.DescriptorType = ACPI_RDESC_TYPE_MEMORY_24; - Descriptor->M24.Length = 9; + Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24; + Descriptor->Memory24.ResourceLength = 9; + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { switch (i) { case 0: /* Read/Write type */ - RsSetFlagBits (&Descriptor->M24.Information, InitializerOp, 0, 1); + RsSetFlagBits (&Descriptor->Memory24.Flags, InitializerOp, 0, 1); RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (M24.Information), 0); + CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Flags), 0); break; case 1: /* Min Address */ - Descriptor->M24.AddressMin = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (M24.AddressMin)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum)); break; case 2: /* Max Address */ - Descriptor->M24.AddressMax = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (M24.AddressMax)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum)); break; case 3: /* Alignment */ - Descriptor->M24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_ALIGNMENT, - CurrentByteOffset + ASL_RESDESC_OFFSET (M24.Alignment)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment)); break; case 4: /* Length */ - Descriptor->M24.RangeLength = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (M24.RangeLength)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength)); break; case 5: /* Name */ @@ -689,59 +776,58 @@ RsDoMemory32Descriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; UINT32 i; InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (ASL_MEMORY_32_DESC)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32)); Descriptor = Rnode->Buffer; - Descriptor->M32.DescriptorType = ACPI_RDESC_TYPE_MEMORY_32; - Descriptor->M32.Length = 17; + Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32; + Descriptor->Memory32.ResourceLength = 17; + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { switch (i) { case 0: /* Read/Write type */ - RsSetFlagBits (&Descriptor->M32.Information, InitializerOp, 0, 1); + RsSetFlagBits (&Descriptor->Memory32.Flags, InitializerOp, 0, 1); RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (M32.Information), 0); + CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Flags), 0); break; case 1: /* Min Address */ - Descriptor->M32.AddressMin = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (M32.AddressMin)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum)); break; case 2: /* Max Address */ - Descriptor->M32.AddressMax = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (M32.AddressMax)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum)); break; case 3: /* Alignment */ - Descriptor->M32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_ALIGNMENT, - CurrentByteOffset + ASL_RESDESC_OFFSET (M32.Alignment)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment)); break; case 4: /* Length */ - Descriptor->M32.RangeLength = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (M32.RangeLength)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength)); break; case 5: /* Name */ @@ -781,45 +867,44 @@ RsDoMemory32FixedDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; UINT32 i; InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (ASL_FIXED_MEMORY_32_DESC)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32)); Descriptor = Rnode->Buffer; - Descriptor->F32.DescriptorType = ACPI_RDESC_TYPE_FIXED_MEMORY_32; - Descriptor->F32.Length = 9; + Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32; + Descriptor->FixedMemory32.ResourceLength = 9; + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { switch (i) { case 0: /* Read/Write type */ - RsSetFlagBits (&Descriptor->F32.Information, InitializerOp, 0, 1); + RsSetFlagBits (&Descriptor->FixedMemory32.Flags, InitializerOp, 0, 1); RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (F32.Information), 0); + CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Flags), 0); break; case 1: /* Address */ - Descriptor->F32.BaseAddress = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_BASEADDRESS, - CurrentByteOffset + ASL_RESDESC_OFFSET (F32.BaseAddress)); + CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address)); break; case 2: /* Length */ - Descriptor->F32.RangeLength = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (F32.RangeLength)); + CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength)); break; case 3: /* Name */ @@ -859,7 +944,7 @@ RsDoStartDependentDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; ASL_RESOURCE_NODE *PreviousRnode; @@ -869,19 +954,18 @@ RsDoStartDependentDescriptor ( InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (ASL_START_DEPENDENT_DESC)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT)); PreviousRnode = Rnode; Descriptor = Rnode->Buffer; /* Descriptor has priority byte */ - Descriptor->Std.DescriptorType = ACPI_RDESC_TYPE_START_DEPENDENT | - (ASL_RDESC_ST_DEPEND_SIZE + 0x01); + Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT | + (ASL_RDESC_ST_DEPEND_SIZE + 0x01); + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ State = ACPI_RSTATE_START_DEPENDENT; for (i = 0; InitializerOp; i++) { @@ -891,24 +975,27 @@ RsDoStartDependentDescriptor ( if ((UINT8) InitializerOp->Asl.Value.Integer > 2) { - AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY, InitializerOp, NULL); + AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY, + InitializerOp, NULL); } - RsSetFlagBits (&Descriptor->Std.Flags, InitializerOp, 0, 0); + RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 0, 0); break; case 1: /* Performance/Robustness Priority */ if ((UINT8) InitializerOp->Asl.Value.Integer > 2) { - AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE, InitializerOp, NULL); + AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE, + InitializerOp, NULL); } - RsSetFlagBits (&Descriptor->Std.Flags, InitializerOp, 2, 0); + RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 2, 0); break; default: - NextRnode = RsDoOneResourceDescriptor (InitializerOp, CurrentByteOffset, &State); + NextRnode = RsDoOneResourceDescriptor (InitializerOp, + CurrentByteOffset, &State); /* * Update current byte offset to indicate the number of bytes from the @@ -917,7 +1004,8 @@ RsDoStartDependentDescriptor ( * element (field) within each descriptor as well. */ - CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode); + CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, + NextRnode); break; } @@ -947,7 +1035,7 @@ RsDoStartDependentNoPriDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; ASL_RESOURCE_NODE *PreviousRnode; @@ -956,20 +1044,20 @@ RsDoStartDependentNoPriDescriptor ( InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (ASL_START_DEPENDENT_NOPRIO_DESC)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)); Descriptor = Rnode->Buffer; - Descriptor->Std.DescriptorType = ACPI_RDESC_TYPE_START_DEPENDENT | - ASL_RDESC_ST_DEPEND_SIZE; + Descriptor->StartDpf.DescriptorType = ACPI_RESOURCE_NAME_START_DEPENDENT | + ASL_RDESC_ST_DEPEND_SIZE; PreviousRnode = Rnode; - /* - * Process all child initialization nodes - */ + /* Process all child initialization nodes */ + State = ACPI_RSTATE_START_DEPENDENT; while (InitializerOp) { - NextRnode = RsDoOneResourceDescriptor (InitializerOp, CurrentByteOffset, &State); + NextRnode = RsDoOneResourceDescriptor (InitializerOp, + CurrentByteOffset, &State); /* * Update current byte offset to indicate the number of bytes from the @@ -977,7 +1065,6 @@ RsDoStartDependentNoPriDescriptor ( * must keep track of the offset of not only each descriptor, but each * element (field) within each descriptor as well. */ - CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode); InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); @@ -1006,25 +1093,44 @@ RsDoVendorSmallDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; + UINT8 *VendorData; UINT32 i; InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (ASL_SMALL_VENDOR_DESC)); + + /* Allocate worst case - 7 vendor bytes */ + + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_SMALL) + 7); Descriptor = Rnode->Buffer; - Descriptor->Smv.DescriptorType = ACPI_RDESC_TYPE_SMALL_VENDOR; + Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL; + VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_SMALL_HEADER); + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - for (i = 0; (InitializerOp && (i < 7)); i++) + for (i = 0; InitializerOp; i++) { - Descriptor->Smv.VendorDefined[i] = (UINT8) InitializerOp->Asl.Value.Integer; + /* Maximum 7 vendor data bytes allowed (0-6) */ + + if (i >= 7) + { + AslError (ASL_ERROR, ASL_MSG_VENDOR_LIST, InitializerOp, NULL); + + /* Eat the excess initializers */ + + while (InitializerOp) + { + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + break; + } + + VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer; InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } @@ -1034,7 +1140,7 @@ RsDoVendorSmallDescriptor ( /* Set the length in the Type Tag */ - Descriptor->Smv.DescriptorType |= (UINT8) i; + Descriptor->VendorSmall.DescriptorType |= (UINT8) i; return (Rnode); } diff --git a/sys/contrib/dev/acpica/compiler/aslrestype2.c b/sys/contrib/dev/acpica/compiler/aslrestype2.c index ef16150..02e0f30 100644 --- a/sys/contrib/dev/acpica/compiler/aslrestype2.c +++ b/sys/contrib/dev/acpica/compiler/aslrestype2.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslrestype2 - Long (type2) resource templates and descriptors - * $Revision: 26 $ + * $Revision: 1.42 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,12 +116,18 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslrestype2") +/* Local prototypes */ + +static UINT16 +RsGetStringDataLength ( + ACPI_PARSE_OBJECT *InitializerOp); + /******************************************************************************* * @@ -129,14 +135,14 @@ * * PARAMETERS: InitializerOp - Start of a subtree of init nodes * - * RETURN: Valid string length if a string node is found + * RETURN: Valid string length if a string node is found (otherwise 0) * * DESCRIPTION: In a list of peer nodes, find the first one that contains a * string and return the length of the string. * ******************************************************************************/ -UINT32 +static UINT16 RsGetStringDataLength ( ACPI_PARSE_OBJECT *InitializerOp) { @@ -145,7 +151,7 @@ RsGetStringDataLength ( { if (InitializerOp->Asl.ParseOpcode == PARSEOP_STRING_LITERAL) { - return (strlen (InitializerOp->Asl.Value.String) + 1); + return ((UINT16) (strlen (InitializerOp->Asl.Value.String) + 1)); } InitializerOp = ASL_GET_PEER_NODE (InitializerOp); } @@ -173,113 +179,124 @@ RsDoDwordIoDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; - UINT32 StringLength = 0; + UINT16 StringLength = 0; UINT32 OptionIndex = 0; + UINT8 *OptionalFields; UINT32 i; + BOOLEAN ResSourceIndex = FALSE; InitializerOp = Op->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); - Rnode = RsAllocateResourceNode (sizeof (ASL_DWORD_ADDRESS_DESC) + - StringLength); + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Das.DescriptorType = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE; - Descriptor->Das.ResourceType = ACPI_RESOURCE_TYPE_IO_RANGE; + Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; + Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; /* * Initial descriptor length -- may be enlarged if there are * optional fields present */ - Descriptor->Das.Length = (UINT16) (ASL_RESDESC_OFFSET (Das.OptionalFields[0]) - - ASL_RESDESC_OFFSET (Das.ResourceType)); + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); + Descriptor->Address32.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS32) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { switch (i) { - case 0: /* Resource Type */ + case 0: /* Resource Usage */ - RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 0, 1); + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); break; case 1: /* MinType */ - RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 2, 0); + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Flags), 2); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); break; case 2: /* MaxType */ - RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 3, 0); + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Flags), 3); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); break; case 3: /* DecodeType */ - RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 1, 0); + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Flags), 1); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); break; case 4: /* Range Type */ - RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 0, 3); + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 0, 3); RsCreateBitField (InitializerOp, ASL_RESNAME_RANGETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 0); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 0); break; case 5: /* Address Granularity */ - Descriptor->Das.Granularity = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Address32.Granularity = + (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Granularity)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); break; case 6: /* Address Min */ - Descriptor->Das.AddressMin = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Address32.Minimum = + (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.AddressMin)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); break; case 7: /* Address Max */ - Descriptor->Das.AddressMax = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Address32.Maximum = + (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.AddressMax)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); break; case 8: /* Translation Offset */ - Descriptor->Das.TranslationOffset = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Address32.TranslationOffset = + (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.TranslationOffset)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); break; case 9: /* Address Length */ - Descriptor->Das.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Address32.AddressLength = + (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.AddressLength)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); break; case 10: /* ResSourceIndex [Optional Field - BYTE] */ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->Das.OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + /* Found a valid ResourceSourceIndex */ + + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; OptionIndex++; - Descriptor->Das.Length++; + Descriptor->Address32.ResourceLength++; + ResSourceIndex = TRUE; } break; @@ -290,12 +307,36 @@ RsDoDwordIoDescriptor ( { if (StringLength) { - Descriptor->Das.Length = (UINT16) (Descriptor->Das.Length + StringLength); + /* Found a valid ResourceSource */ + + Descriptor->Address32.ResourceLength = (UINT16) + (Descriptor->Address32.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ - strcpy ((char *) &Descriptor->Das.OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } } } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif break; case 12: /* ResourceTag */ @@ -305,16 +346,16 @@ RsDoDwordIoDescriptor ( case 13: /* Type */ - RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 4, 0); + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 4, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 4); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 4); break; case 14: /* Translation Type */ - RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 5, 0); + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 5, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_TRANSTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 5); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 5); break; default: @@ -326,9 +367,8 @@ RsDoDwordIoDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - Rnode->BufferLength = (ASL_RESDESC_OFFSET (Das.OptionalFields[0]) - - ASL_RESDESC_OFFSET (Das.DescriptorType)) - + OptionIndex + StringLength; + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + + OptionIndex + StringLength; return (Rnode); } @@ -352,120 +392,130 @@ RsDoDwordMemoryDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; - UINT32 StringLength = 0; + UINT8 *OptionalFields; + UINT16 StringLength = 0; UINT32 OptionIndex = 0; UINT32 i; + BOOLEAN ResSourceIndex = FALSE; InitializerOp = Op->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); - Rnode = RsAllocateResourceNode (sizeof (ASL_DWORD_ADDRESS_DESC) + - StringLength); + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Das.DescriptorType = ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE; - Descriptor->Das.ResourceType = ACPI_RESOURCE_TYPE_MEMORY_RANGE; + Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; + Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; /* * Initial descriptor length -- may be enlarged if there are * optional fields present */ - Descriptor->Das.Length = (UINT16) (ASL_RESDESC_OFFSET (Das.OptionalFields[0]) - - ASL_RESDESC_OFFSET (Das.ResourceType)); + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); + Descriptor->Address32.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS32) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { switch (i) { - case 0: /* Resource Type */ + case 0: /* Resource Usage */ - RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 0, 1); + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); break; case 1: /* DecodeType */ - RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 1, 0); + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Flags), 1); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); break; case 2: /* MinType */ - RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 2, 0); + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Flags), 2); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); break; case 3: /* MaxType */ - RsSetFlagBits (&Descriptor->Das.Flags, InitializerOp, 3, 0); + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Flags), 3); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); break; case 4: /* Memory Type */ - RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 1, 0); + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 1, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MEMTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 1); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 1); break; case 5: /* Read/Write Type */ - RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 0, 1); + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 0, 1); RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 0); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 0); break; case 6: /* Address Granularity */ - Descriptor->Das.Granularity = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Address32.Granularity = + (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.Granularity)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); break; case 7: /* Min Address */ - Descriptor->Das.AddressMin = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Address32.Minimum = + (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.AddressMin)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); break; case 8: /* Max Address */ - Descriptor->Das.AddressMax = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Address32.Maximum = + (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.AddressMax)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); break; case 9: /* Translation Offset */ - Descriptor->Das.TranslationOffset = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Address32.TranslationOffset = + (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.TranslationOffset)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); break; case 10: /* Address Length */ - Descriptor->Das.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer; + Descriptor->Address32.AddressLength = + (UINT32) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.AddressLength)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); break; case 11: /* ResSourceIndex [Optional Field - BYTE] */ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->Das.OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; OptionIndex++; - Descriptor->Das.Length++; + Descriptor->Address32.ResourceLength++; + ResSourceIndex = TRUE; } break; @@ -476,12 +526,34 @@ RsDoDwordMemoryDescriptor ( { if (StringLength) { - Descriptor->Das.Length = (UINT16) (Descriptor->Das.Length + StringLength); + Descriptor->Address32.ResourceLength = (UINT16) + (Descriptor->Address32.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ - strcpy ((char *) &Descriptor->Das.OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } } } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif break; case 13: /* ResourceTag */ @@ -492,16 +564,16 @@ RsDoDwordMemoryDescriptor ( case 14: /* Address Range */ - RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 3, 0); + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 3, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MEMATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 3); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 3); break; case 15: /* Type */ - RsSetFlagBits (&Descriptor->Das.SpecificFlags, InitializerOp, 5, 0); + RsSetFlagBits (&Descriptor->Address32.SpecificFlags, InitializerOp, 5, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Das.SpecificFlags), 5); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.SpecificFlags), 5); break; default: @@ -513,9 +585,672 @@ RsDoDwordMemoryDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - Rnode->BufferLength = (ASL_RESDESC_OFFSET (Das.OptionalFields[0]) - - ASL_RESDESC_OFFSET (Das.DescriptorType)) - + OptionIndex + StringLength; + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoDwordSpaceDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "DwordSpace" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoDwordSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32); + Descriptor->Address32.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS32) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Type */ + + Descriptor->Address32.ResourceType = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 1: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 0, 1); + break; + + case 2: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 1); + break; + + case 3: /* MinType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 2); + break; + + case 4: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address32.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Flags), 3); + break; + + case 5: /* Type-Specific flags */ + + Descriptor->Address32.SpecificFlags = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 6: /* Address Granularity */ + + Descriptor->Address32.Granularity = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity)); + break; + + case 7: /* Min Address */ + + Descriptor->Address32.Minimum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum)); + break; + + case 8: /* Max Address */ + + Descriptor->Address32.Maximum = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum)); + break; + + case 9: /* Translation Offset */ + + Descriptor->Address32.TranslationOffset = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->Address32.AddressLength = + (UINT32) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength)); + break; + + case 11: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address32.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 12: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address32.ResourceLength = (UINT16) + (Descriptor->Address32.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 13: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, + InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoExtendedIoDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "ExtendedIO" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoExtendedIoDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + UINT16 StringLength = 0; +// UINT32 OptionIndex = 0; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + + Descriptor->ExtAddress64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); + break; + + case 1: /* MinType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); + break; + + case 2: /* MaxType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); + break; + + case 3: /* DecodeType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); + break; + + case 4: /* Range Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 0, 3); + RsCreateBitField (InitializerOp, ASL_RESNAME_RANGETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 0); + break; + + case 5: /* Address Granularity */ + + Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); + break; + + case 6: /* Address Min */ + + Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); + break; + + case 7: /* Address Max */ + + Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); + break; + + case 8: /* Translation Offset */ + + Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); + break; + + case 9: /* Address Length */ + + Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); + break; + + case 10: /* Type-Specific Attributes */ + + Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_TYPESPECIFICATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); + break; + + case 11: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + case 12: /* Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 4, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 4); + break; + + case 13: /* Translation Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_TRANSTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoExtendedMemoryDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "ExtendedMemory" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoExtendedMemoryDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + UINT16 StringLength = 0; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + + Descriptor->ExtAddress64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); + break; + + case 1: /* DecodeType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); + break; + + case 2: /* MinType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); + break; + + case 3: /* MaxType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); + break; + + case 4: /* Memory Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MEMTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 1); + break; + + case 5: /* Read/Write Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 0, 1); + RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 0); + break; + + case 6: /* Address Granularity */ + + Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); + break; + + case 7: /* Min Address */ + + Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); + break; + + case 8: /* Max Address */ + + Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); + break; + + case 9: /* Translation Offset */ + + Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); + break; + + case 11: /* Type-Specific Attributes */ + + Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_TYPESPECIFICATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); + break; + + case 12: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + + case 13: /* Address Range */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MEMATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 3); + break; + + case 14: /* Type */ + + RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 5, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 5); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoExtendedSpaceDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "ExtendedSpace" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoExtendedSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + UINT16 StringLength = 0; + UINT32 i; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64; + Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION; + + Descriptor->ExtAddress64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Type */ + + Descriptor->ExtAddress64.ResourceType = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 1: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1); + break; + + case 2: /* DecodeType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1); + break; + + case 3: /* MinType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2); + break; + + case 4: /* MaxType */ + + RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3); + break; + + case 5: /* Type-Specific flags */ + + Descriptor->ExtAddress64.SpecificFlags = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 6: /* Address Granularity */ + + Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity)); + break; + + case 7: /* Min Address */ + + Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum)); + break; + + case 8: /* Max Address */ + + Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum)); + break; + + case 9: /* Translation Offset */ + + Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength)); + break; + + case 11: /* Type-Specific Attributes */ + + Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_TYPESPECIFICATTRIBUTES, + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific)); + break; + + case 12: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + StringLength; return (Rnode); } @@ -539,112 +1274,117 @@ RsDoQwordIoDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; - UINT32 StringLength = 0; + UINT8 *OptionalFields; + UINT16 StringLength = 0; UINT32 OptionIndex = 0; UINT32 i; + BOOLEAN ResSourceIndex = FALSE; InitializerOp = Op->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); - Rnode = RsAllocateResourceNode (sizeof (ASL_QWORD_ADDRESS_DESC) + - StringLength); + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Qas.DescriptorType = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE; - Descriptor->Qas.ResourceType = ACPI_RESOURCE_TYPE_IO_RANGE; + Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; + Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; /* * Initial descriptor length -- may be enlarged if there are * optional fields present */ - Descriptor->Qas.Length = (UINT16) (ASL_RESDESC_OFFSET (Qas.OptionalFields[0]) - - ASL_RESDESC_OFFSET (Qas.ResourceType)); - /* - * Process all child initialization nodes - */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); + Descriptor->Address64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + for (i = 0; InitializerOp; i++) { switch (i) { - case 0: /* Resource Type */ + case 0: /* Resource Usage */ - RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 0, 1); + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); break; case 1: /* MinType */ - RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 2, 0); + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Flags), 2); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); break; case 2: /* MaxType */ - RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 3, 0); + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Flags), 3); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); break; case 3: /* DecodeType */ - RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 1, 0); + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Flags), 1); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); break; case 4: /* Range Type */ - RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 0, 3); + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 3); RsCreateBitField (InitializerOp, ASL_RESNAME_RANGETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 0); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0); break; case 5: /* Address Granularity */ - Descriptor->Qas.Granularity = InitializerOp->Asl.Value.Integer; - RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Granularity)); + Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); break; case 6: /* Address Min */ - Descriptor->Qas.AddressMin = InitializerOp->Asl.Value.Integer; + Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.AddressMin)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); break; case 7: /* Address Max */ - Descriptor->Qas.AddressMax = InitializerOp->Asl.Value.Integer; + Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.AddressMax)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); break; case 8: /* Translation Offset */ - Descriptor->Qas.TranslationOffset = InitializerOp->Asl.Value.Integer; + Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.TranslationOffset)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); break; case 9: /* Address Length */ - Descriptor->Qas.AddressLength = InitializerOp->Asl.Value.Integer; + Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.AddressLength)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); break; case 10: /* ResSourceIndex [Optional Field - BYTE] */ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->Qas.OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; OptionIndex++; - Descriptor->Qas.Length++; + Descriptor->Address64.ResourceLength++; + ResSourceIndex = TRUE; } break; @@ -655,12 +1395,34 @@ RsDoQwordIoDescriptor ( { if (StringLength) { - Descriptor->Qas.Length = (UINT16) (Descriptor->Qas.Length + StringLength); + Descriptor->Address64.ResourceLength = (UINT16) + (Descriptor->Address64.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ - strcpy ((char *) &Descriptor->Qas.OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } } } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif break; case 12: /* ResourceTag */ @@ -670,16 +1432,16 @@ RsDoQwordIoDescriptor ( case 13: /* Type */ - RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 4, 0); + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 4, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 4); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 4); break; case 14: /* Translation Type */ - RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 5, 0); + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_TRANSTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 5); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5); break; default: @@ -691,9 +1453,8 @@ RsDoQwordIoDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - Rnode->BufferLength = (ASL_RESDESC_OFFSET (Qas.OptionalFields[0]) - - ASL_RESDESC_OFFSET (Qas.DescriptorType)) - + OptionIndex + StringLength; + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + + OptionIndex + StringLength; return (Rnode); } @@ -717,119 +1478,124 @@ RsDoQwordMemoryDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; - UINT32 StringLength = 0; + UINT8 *OptionalFields; + UINT16 StringLength = 0; UINT32 OptionIndex = 0; UINT32 i; + BOOLEAN ResSourceIndex = FALSE; InitializerOp = Op->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); - Rnode = RsAllocateResourceNode (sizeof (ASL_QWORD_ADDRESS_DESC) + - StringLength); + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Qas.DescriptorType = ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE; - Descriptor->Qas.ResourceType = ACPI_RESOURCE_TYPE_MEMORY_RANGE; + Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64; + Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE; /* * Initial descriptor length -- may be enlarged if there are * optional fields present */ - Descriptor->Qas.Length = (UINT16) (ASL_RESDESC_OFFSET (Qas.OptionalFields[0]) - - ASL_RESDESC_OFFSET (Qas.ResourceType)); - /* - * Process all child initialization nodes - */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); + Descriptor->Address64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + for (i = 0; InitializerOp; i++) { switch (i) { - case 0: /* Resource Type */ + case 0: /* Resource Usage */ - RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 0, 1); + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); break; case 1: /* DecodeType */ - RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 1, 0); + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Flags), 1); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); break; case 2: /* MinType */ - RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 2, 0); + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Flags), 2); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); break; case 3: /* MaxType */ - RsSetFlagBits (&Descriptor->Qas.Flags, InitializerOp, 3, 0); + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Flags), 3); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); break; case 4: /* Memory Type */ - RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 1, 0); + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 1, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MEMTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 1); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 1); break; case 5: /* Read/Write Type */ - RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 0, 1); + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 1); RsCreateBitField (InitializerOp, ASL_RESNAME_READWRITETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 0); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0); break; case 6: /* Address Granularity */ - Descriptor->Qas.Granularity = InitializerOp->Asl.Value.Integer; + Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.Granularity)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); break; case 7: /* Min Address */ - Descriptor->Qas.AddressMin = InitializerOp->Asl.Value.Integer; + Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.AddressMin)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); break; case 8: /* Max Address */ - Descriptor->Qas.AddressMax = InitializerOp->Asl.Value.Integer; + Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.AddressMax)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); break; case 9: /* Translation Offset */ - Descriptor->Qas.TranslationOffset = InitializerOp->Asl.Value.Integer; + Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.TranslationOffset)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); break; case 10: /* Address Length */ - Descriptor->Qas.AddressLength = InitializerOp->Asl.Value.Integer; + Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.AddressLength)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); break; case 11: /* ResSourceIndex [Optional Field - BYTE] */ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->Qas.OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; OptionIndex++; - Descriptor->Qas.Length++; + Descriptor->Address64.ResourceLength++; + ResSourceIndex = TRUE; } break; @@ -840,12 +1606,34 @@ RsDoQwordMemoryDescriptor ( { if (StringLength) { - Descriptor->Qas.Length = (UINT16) (Descriptor->Qas.Length + StringLength); + Descriptor->Address64.ResourceLength = (UINT16) + (Descriptor->Address64.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ - strcpy ((char *) &Descriptor->Qas.OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } } } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif break; case 13: /* ResourceTag */ @@ -856,16 +1644,16 @@ RsDoQwordMemoryDescriptor ( case 14: /* Address Range */ - RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 3, 0); + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 3, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MEMATTRIBUTES, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 3); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 3); break; case 15: /* Type */ - RsSetFlagBits (&Descriptor->Qas.SpecificFlags, InitializerOp, 5, 0); + RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Qas.SpecificFlags), 5); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5); break; default: @@ -877,9 +1665,202 @@ RsDoQwordMemoryDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - Rnode->BufferLength = (ASL_RESDESC_OFFSET (Qas.OptionalFields[0]) - - ASL_RESDESC_OFFSET (Qas.DescriptorType)) - + OptionIndex + StringLength; + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoQwordSpaceDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "QwordSpace" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoQwordSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64); + Descriptor->Address64.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS64) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Type */ + + Descriptor->Address64.ResourceType = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 1: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1); + break; + + case 2: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1); + break; + + case 3: /* MinType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2); + break; + + case 4: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3); + break; + + case 5: /* Type-Specific flags */ + + Descriptor->Address64.SpecificFlags = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 6: /* Address Granularity */ + + Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity)); + break; + + case 7: /* Min Address */ + + Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum)); + break; + + case 8: /* Max Address */ + + Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum)); + break; + + case 9: /* Translation Offset */ + + Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength)); + break; + + case 11: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address64.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 12: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address64.ResourceLength = (UINT16) + (Descriptor->Address64.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 13: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) + + OptionIndex + StringLength; return (Rnode); } @@ -903,113 +1884,117 @@ RsDoWordIoDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; - UINT32 StringLength = 0; + UINT8 *OptionalFields; + UINT16 StringLength = 0; UINT32 OptionIndex = 0; UINT32 i; + BOOLEAN ResSourceIndex = FALSE; InitializerOp = Op->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); - Rnode = RsAllocateResourceNode (sizeof (ASL_WORD_ADDRESS_DESC) + - StringLength); + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Was.DescriptorType = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE; - Descriptor->Was.ResourceType = ACPI_RESOURCE_TYPE_IO_RANGE; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE; /* * Initial descriptor length -- may be enlarged if there are * optional fields present */ - Descriptor->Was.Length = (UINT16) (ASL_RESDESC_OFFSET (Was.OptionalFields[0]) - - ASL_RESDESC_OFFSET (Was.ResourceType)); + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); + Descriptor->Address16.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS16) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { switch (i) { - case 0: /* Resource Type */ + case 0: /* Resource Usage */ - RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 0, 1); + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); break; case 1: /* MinType */ - RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 2, 0); + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Flags), 2); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); break; case 2: /* MaxType */ - RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 3, 0); + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Flags), 3); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); break; case 3: /* DecodeType */ - RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 1, 0); + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Flags), 1); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); break; case 4: /* Range Type */ - RsSetFlagBits (&Descriptor->Was.SpecificFlags, InitializerOp, 0, 3); + RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 0, 3); RsCreateBitField (InitializerOp, ASL_RESNAME_RANGETYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.SpecificFlags), 0); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 0); break; case 5: /* Address Granularity */ - Descriptor->Was.Granularity = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Address16.Granularity = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Granularity)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); break; case 6: /* Address Min */ - Descriptor->Was.AddressMin = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Address16.Minimum = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.AddressMin)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); break; case 7: /* Address Max */ - Descriptor->Was.AddressMax = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Address16.Maximum = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.AddressMax)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); break; case 8: /* Translation Offset */ - Descriptor->Was.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Address16.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.TranslationOffset)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); break; case 9: /* Address Length */ - Descriptor->Was.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Address16.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.AddressLength)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); break; case 10: /* ResSourceIndex [Optional Field - BYTE] */ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->Was.OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; OptionIndex++; - Descriptor->Was.Length++; + Descriptor->Address16.ResourceLength++; + ResSourceIndex = TRUE; } break; @@ -1020,12 +2005,34 @@ RsDoWordIoDescriptor ( { if (StringLength) { - Descriptor->Was.Length = (UINT16) (Descriptor->Was.Length +StringLength); + Descriptor->Address16.ResourceLength = (UINT16) + (Descriptor->Address16.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ - strcpy ((char *) &Descriptor->Was.OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } } } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif break; case 12: /* ResourceTag */ @@ -1035,16 +2042,16 @@ RsDoWordIoDescriptor ( case 13: /* Type */ - RsSetFlagBits (&Descriptor->Was.SpecificFlags, InitializerOp, 4, 0); + RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 4, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_TYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.SpecificFlags), 4); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 4); break; case 14: /* Translation Type */ - RsSetFlagBits (&Descriptor->Was.SpecificFlags, InitializerOp, 5, 0); + RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 5, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_TRANSTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.SpecificFlags), 5); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 5); break; default: @@ -1056,9 +2063,8 @@ RsDoWordIoDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - Rnode->BufferLength = (ASL_RESDESC_OFFSET (Was.OptionalFields[0]) - - ASL_RESDESC_OFFSET (Was.DescriptorType)) - + OptionIndex + StringLength; + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + + OptionIndex + StringLength; return (Rnode); } @@ -1082,106 +2088,115 @@ RsDoWordBusNumberDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; - UINT32 StringLength = 0; + UINT8 *OptionalFields; + UINT16 StringLength = 0; UINT32 OptionIndex = 0; UINT32 i; + BOOLEAN ResSourceIndex = FALSE; InitializerOp = Op->Asl.Child; StringLength = RsGetStringDataLength (InitializerOp); - Rnode = RsAllocateResourceNode (sizeof (ASL_WORD_ADDRESS_DESC) + - StringLength); + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); Descriptor = Rnode->Buffer; - Descriptor->Was.DescriptorType = ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE; - Descriptor->Was.ResourceType = ACPI_RESOURCE_TYPE_BUS_NUMBER_RANGE; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE; /* * Initial descriptor length -- may be enlarged if there are * optional fields present */ - Descriptor->Was.Length = (UINT16) (ASL_RESDESC_OFFSET (Was.OptionalFields[0]) - - ASL_RESDESC_OFFSET (Was.ResourceType)); + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); + Descriptor->Address16.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS16) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { switch (i) { - case 0: /* Resource Type */ + case 0: /* Resource Usage */ - RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 0, 1); + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); break; case 1: /* MinType */ - RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 2, 0); + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Flags), 2); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); break; case 2: /* MaxType */ - RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 3, 0); + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Flags), 3); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); break; case 3: /* DecodeType */ - RsSetFlagBits (&Descriptor->Was.Flags, InitializerOp, 1, 0); + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Flags), 1); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); break; case 4: /* Address Granularity */ - Descriptor->Was.Granularity = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Address16.Granularity = + (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.Granularity)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); break; case 5: /* Min Address */ - Descriptor->Was.AddressMin = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Address16.Minimum = + (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.AddressMin)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); break; case 6: /* Max Address */ - Descriptor->Was.AddressMax = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Address16.Maximum = + (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.AddressMax)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); break; case 7: /* Translation Offset */ - Descriptor->Was.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Address16.TranslationOffset = + (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.TranslationOffset)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); break; case 8: /* Address Length */ - Descriptor->Was.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer; + Descriptor->Address16.AddressLength = + (UINT16) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Was.AddressLength)); + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); break; case 9: /* ResSourceIndex [Optional Field - BYTE] */ if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) { - Descriptor->Was.OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; OptionIndex++; - Descriptor->Was.Length++; + Descriptor->Address16.ResourceLength++; + ResSourceIndex = TRUE; } break; @@ -1192,12 +2207,34 @@ RsDoWordBusNumberDescriptor ( { if (StringLength) { - Descriptor->Was.Length = (UINT16) (Descriptor->Was.Length + StringLength); + Descriptor->Address16.ResourceLength = (UINT16) + (Descriptor->Address16.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); - strcpy ((char *) &Descriptor->Was.OptionalFields[OptionIndex], - InitializerOp->Asl.Value.String); + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } } } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif break; case 11: /* ResourceTag */ @@ -1214,9 +2251,207 @@ RsDoWordBusNumberDescriptor ( InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - Rnode->BufferLength = (ASL_RESDESC_OFFSET (Was.OptionalFields[0]) - - ASL_RESDESC_OFFSET (Was.DescriptorType)) - + OptionIndex + StringLength; + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + + OptionIndex + StringLength; + return (Rnode); +} + + +/******************************************************************************* + * + * FUNCTION: RsDoWordSpaceDescriptor + * + * PARAMETERS: Op - Parent resource descriptor parse node + * CurrentByteOffset - Offset into the resource template AML + * buffer (to track references to the desc) + * + * RETURN: Completed resource node + * + * DESCRIPTION: Construct a long "WordSpace" descriptor + * + ******************************************************************************/ + +ASL_RESOURCE_NODE * +RsDoWordSpaceDescriptor ( + ACPI_PARSE_OBJECT *Op, + UINT32 CurrentByteOffset) +{ + AML_RESOURCE *Descriptor; + ACPI_PARSE_OBJECT *InitializerOp; + ASL_RESOURCE_NODE *Rnode; + UINT8 *OptionalFields; + UINT16 StringLength = 0; + UINT32 OptionIndex = 0; + UINT32 i; + BOOLEAN ResSourceIndex = FALSE; + + + InitializerOp = Op->Asl.Child; + StringLength = RsGetStringDataLength (InitializerOp); + + Rnode = RsAllocateResourceNode ( + sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength); + + Descriptor = Rnode->Buffer; + Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16; + + /* + * Initial descriptor length -- may be enlarged if there are + * optional fields present + */ + OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16); + Descriptor->Address16.ResourceLength = (UINT16) + (sizeof (AML_RESOURCE_ADDRESS16) - + sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Process all child initialization nodes */ + + for (i = 0; InitializerOp; i++) + { + switch (i) + { + case 0: /* Resource Type */ + + Descriptor->Address16.ResourceType = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 1: /* Resource Usage */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1); + break; + + case 2: /* DecodeType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_DECODE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1); + break; + + case 3: /* MinType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MINTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2); + break; + + case 4: /* MaxType */ + + RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0); + RsCreateBitField (InitializerOp, ASL_RESNAME_MAXTYPE, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3); + break; + + case 5: /* Type-Specific flags */ + + Descriptor->Address16.SpecificFlags = + (UINT8) InitializerOp->Asl.Value.Integer; + break; + + case 6: /* Address Granularity */ + + Descriptor->Address16.Granularity = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_GRANULARITY, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity)); + break; + + case 7: /* Min Address */ + + Descriptor->Address16.Minimum = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_MINADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum)); + break; + + case 8: /* Max Address */ + + Descriptor->Address16.Maximum = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_MAXADDR, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum)); + break; + + case 9: /* Translation Offset */ + + Descriptor->Address16.TranslationOffset = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_TRANSLATION, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset)); + break; + + case 10: /* Address Length */ + + Descriptor->Address16.AddressLength = + (UINT16) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_LENGTH, + CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength)); + break; + + case 11: /* ResSourceIndex [Optional Field - BYTE] */ + + if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) + { + OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer; + OptionIndex++; + Descriptor->Address16.ResourceLength++; + ResSourceIndex = TRUE; + } + break; + + case 12: /* ResSource [Optional Field - STRING] */ + + if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && + (InitializerOp->Asl.Value.String)) + { + if (StringLength) + { + Descriptor->Address16.ResourceLength = (UINT16) + (Descriptor->Address16.ResourceLength + StringLength); + + strcpy ((char *) + &OptionalFields[OptionIndex], + InitializerOp->Asl.Value.String); + + /* ResourceSourceIndex must also be valid */ + + if (!ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } + } + } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (ResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif + break; + + case 13: /* ResourceTag */ + + UtAttachNamepathToOwner (Op, InitializerOp); + break; + + default: + + AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL); + break; + } + + InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); + } + + Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) + + OptionIndex + StringLength; return (Rnode); } @@ -1240,11 +2475,11 @@ RsDoInterruptDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; - ASL_RESOURCE_DESC *Rover = NULL; + AML_RESOURCE *Descriptor; + AML_RESOURCE *Rover = NULL; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; - UINT32 StringLength = 0; + UINT16 StringLength = 0; UINT32 OptionIndex = 0; UINT32 i; BOOLEAN HasResSourceIndex = FALSE; @@ -1275,51 +2510,52 @@ RsDoInterruptDescriptor ( } InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (ASL_EXTENDED_XRUPT_DESC) + - OptionIndex + StringLength); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_EXTENDED_IRQ) + + 1 + OptionIndex + StringLength); + Descriptor = Rnode->Buffer; - Descriptor->Exx.DescriptorType = ACPI_RDESC_TYPE_EXTENDED_XRUPT; + Descriptor->ExtendedIrq.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_IRQ; /* * Initial descriptor length -- may be enlarged if there are * optional fields present */ - Descriptor->Exx.Length = 2; /* Flags and table length byte */ - Descriptor->Exx.TableLength = 0; + Descriptor->ExtendedIrq.ResourceLength = 2; /* Flags and table length byte */ + Descriptor->ExtendedIrq.InterruptCount = 0; - Rover = ACPI_CAST_PTR (ASL_RESOURCE_DESC, (&(Descriptor->Exx.InterruptNumber[0]))); + Rover = ACPI_CAST_PTR (AML_RESOURCE, + (&(Descriptor->ExtendedIrq.Interrupts[0]))); + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { switch (i) { - case 0: /* Resource Type (Default: consumer (1) */ + case 0: /* Resource Usage (Default: consumer (1) */ - RsSetFlagBits (&Descriptor->Exx.Flags, InitializerOp, 0, 1); + RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 0, 1); break; case 1: /* Interrupt Type (or Mode - edge/level) */ - RsSetFlagBits (&Descriptor->Exx.Flags, InitializerOp, 1, 0); + RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 1, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTTYPE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Exx.Flags), 0); + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtendedIrq.Flags), 1); break; case 2: /* Interrupt Level (or Polarity - Active high/low) */ - RsSetFlagBits (&Descriptor->Exx.Flags, InitializerOp, 2, 0); + RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 2, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTLEVEL, - CurrentByteOffset + ASL_RESDESC_OFFSET (Exx.Flags), 2); + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtendedIrq.Flags), 2); break; case 3: /* Share Type - Default: exclusive (0) */ - RsSetFlagBits (&Descriptor->Exx.Flags, InitializerOp, 3, 0); + RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 3, 0); RsCreateBitField (InitializerOp, ASL_RESNAME_INTERRUPTSHARE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Exx.Flags), 3); + CurrentByteOffset + ASL_RESDESC_OFFSET (ExtendedIrq.Flags), 3); break; case 4: /* ResSourceIndex [Optional Field - BYTE] */ @@ -1340,7 +2576,27 @@ RsDoInterruptDescriptor ( { ResSourceString = (UINT8 *) InitializerOp->Asl.Value.String; } + + /* ResourceSourceIndex must also be valid */ + + if (!HasResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX, + InitializerOp, NULL); + } } + +#if 0 + /* + * Not a valid ResourceSource, ResourceSourceIndex must also + * be invalid + */ + else if (HasResSourceIndex) + { + AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE, + InitializerOp, NULL); + } +#endif break; case 6: /* ResourceTag */ @@ -1350,48 +2606,77 @@ RsDoInterruptDescriptor ( default: /* - * Interrupt Numbers come through here, repeatedly. - * Store the integer and move pointer to the next one. + * Interrupt Numbers come through here, repeatedly */ + + /* Maximum 255 interrupts allowed for this descriptor */ + + if (Descriptor->ExtendedIrq.InterruptCount == 255) + { + AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST, + InitializerOp, NULL); + return (Rnode); + } + + /* Each interrupt number must be a 32-bit value */ + + if (InitializerOp->Asl.Value.Integer > ACPI_UINT32_MAX) + { + AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_NUMBER, + InitializerOp, NULL); + } + + /* Save the integer and move pointer to the next one */ + Rover->U32Item = (UINT32) InitializerOp->Asl.Value.Integer; - Rover = ACPI_PTR_ADD (ASL_RESOURCE_DESC, &(Rover->U32Item), 4); + Rover = ACPI_PTR_ADD (AML_RESOURCE, &(Rover->U32Item), 4); + Descriptor->ExtendedIrq.InterruptCount++; + Descriptor->ExtendedIrq.ResourceLength += 4; - Descriptor->Exx.TableLength++; - Descriptor->Exx.Length += 4; + /* Case 7: First interrupt number in list */ - if (i == 7) /* case 7: First interrupt number */ + if (i == 7) { + /* Check now for duplicates in list */ + + RsCheckListForDuplicates (InitializerOp); + + /* Create a named field at the start of the list */ + RsCreateByteField (InitializerOp, ASL_RESNAME_INTERRUPT, - CurrentByteOffset + ASL_RESDESC_OFFSET (Exx.InterruptNumber[0])); + CurrentByteOffset + + ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0])); } } InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } - /* - * Add optional ResSourceIndex if present - */ + + /* Add optional ResSourceIndex if present */ + if (HasResSourceIndex) { Rover->U8Item = ResSourceIndex; - Rover = ACPI_PTR_ADD (ASL_RESOURCE_DESC, &(Rover->U8Item), 1); - Descriptor->Exx.Length += 1; + Rover = ACPI_PTR_ADD (AML_RESOURCE, &(Rover->U8Item), 1); + Descriptor->ExtendedIrq.ResourceLength += 1; } - /* - * Add optional ResSource string if present - */ + /* Add optional ResSource string if present */ + if (StringLength && ResSourceString) { strcpy ((char *) Rover, (char *) ResSourceString); - Rover = ACPI_PTR_ADD (ASL_RESOURCE_DESC, &(Rover->U8Item), StringLength); - Descriptor->Exx.Length = (UINT16) (Descriptor->Exx.Length + StringLength); + Rover = ACPI_PTR_ADD ( + AML_RESOURCE, &(Rover->U8Item), StringLength); + + Descriptor->ExtendedIrq.ResourceLength = (UINT16) + (Descriptor->ExtendedIrq.ResourceLength + StringLength); } - Rnode->BufferLength = (ASL_RESDESC_OFFSET (Exx.InterruptNumber[0]) - - ASL_RESDESC_OFFSET (Exx.DescriptorType)) + Rnode->BufferLength = (ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]) - + ASL_RESDESC_OFFSET (ExtendedIrq.DescriptorType)) + OptionIndex + StringLength; return (Rnode); } @@ -1416,9 +2701,10 @@ RsDoVendorLargeDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; + UINT8 *VendorData; UINT32 i; @@ -1434,18 +2720,21 @@ RsDoVendorLargeDescriptor ( InitializerOp = Op->Asl.Child; InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); - Rnode = RsAllocateResourceNode (sizeof (ASL_LARGE_VENDOR_DESC) + (i - 1)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_LARGE) + i); Descriptor = Rnode->Buffer; - Descriptor->Lgv.DescriptorType = ACPI_RDESC_TYPE_LARGE_VENDOR; - Descriptor->Lgv.Length = (UINT16) i; + Descriptor->VendorLarge.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_LARGE; + Descriptor->VendorLarge.ResourceLength = (UINT16) i; + + /* Point to end-of-descriptor for vendor data */ + + VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_LARGE_HEADER); + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { - Descriptor->Lgv.VendorDefined[i] = (UINT8) InitializerOp->Asl.Value.Integer; + VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer; InitializerOp = RsCompleteNodeAndGetNext (InitializerOp); } @@ -1473,54 +2762,59 @@ RsDoGeneralRegisterDescriptor ( ACPI_PARSE_OBJECT *Op, UINT32 CurrentByteOffset) { - ASL_RESOURCE_DESC *Descriptor; + AML_RESOURCE *Descriptor; ACPI_PARSE_OBJECT *InitializerOp; ASL_RESOURCE_NODE *Rnode; UINT32 i; InitializerOp = Op->Asl.Child; - Rnode = RsAllocateResourceNode (sizeof (ASL_GENERAL_REGISTER_DESC)); + Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_GENERIC_REGISTER)); Descriptor = Rnode->Buffer; - Descriptor->Grg.DescriptorType = ACPI_RDESC_TYPE_GENERAL_REGISTER; - Descriptor->Grg.Length = 12; + Descriptor->GenericReg.DescriptorType = ACPI_RESOURCE_NAME_GENERIC_REGISTER; + Descriptor->GenericReg.ResourceLength = 12; + + /* Process all child initialization nodes */ - /* - * Process all child initialization nodes - */ for (i = 0; InitializerOp; i++) { switch (i) { case 0: /* Address space */ - Descriptor->Grg.AddressSpaceId = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->GenericReg.AddressSpaceId = (UINT8) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_ADDRESSSPACE, - CurrentByteOffset + ASL_RESDESC_OFFSET (Grg.AddressSpaceId)); + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AddressSpaceId)); break; case 1: /* Register Bit Width */ - Descriptor->Grg.BitWidth = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->GenericReg.BitWidth = (UINT8) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_REGISTERBITWIDTH, - CurrentByteOffset + ASL_RESDESC_OFFSET (Grg.BitWidth)); + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitWidth)); break; case 2: /* Register Bit Offset */ - Descriptor->Grg.BitOffset = (UINT8) InitializerOp->Asl.Value.Integer; + Descriptor->GenericReg.BitOffset = (UINT8) InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_REGISTERBITOFFSET, - CurrentByteOffset + ASL_RESDESC_OFFSET (Grg.BitOffset)); + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitOffset)); break; case 3: /* Register Address */ - Descriptor->Grg.Address = InitializerOp->Asl.Value.Integer; + Descriptor->GenericReg.Address = InitializerOp->Asl.Value.Integer; RsCreateByteField (InitializerOp, ASL_RESNAME_ADDRESS, - CurrentByteOffset + ASL_RESDESC_OFFSET (Grg.Address)); + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.Address)); break; + case 4: /* Access Size (ACPI 3.0) */ + + Descriptor->GenericReg.AccessSize = (UINT8) InitializerOp->Asl.Value.Integer; + RsCreateByteField (InitializerOp, ASL_RESNAME_ACCESSSIZE, + CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AccessSize)); + break; default: diff --git a/sys/contrib/dev/acpica/compiler/aslstubs.c b/sys/contrib/dev/acpica/compiler/aslstubs.c index c1724ae..fa2b63f 100644 --- a/sys/contrib/dev/acpica/compiler/aslstubs.c +++ b/sys/contrib/dev/acpica/compiler/aslstubs.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslstubs - Stubs used to link to Aml interpreter - * $Revision: 13 $ + * $Revision: 1.14 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,9 +116,9 @@ *****************************************************************************/ #include <stdio.h> -#include "aslcompiler.h" -#include "acdispat.h" -#include "actables.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> +#include <contrib/dev/acpica/acdispat.h> +#include <contrib/dev/acpica/actables.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslstubs") diff --git a/sys/contrib/dev/acpica/compiler/asltransform.c b/sys/contrib/dev/acpica/compiler/asltransform.c index f05f2f7..9ff4925 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: 25 $ + * $Revision: 1.35 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,66 +116,103 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("asltransform") +/* Local prototypes */ + +static void +TrTransformSubtree ( + ACPI_PARSE_OBJECT *Op); + +static char * +TrAmlGetNextTempName ( + ACPI_PARSE_OBJECT *Op, + UINT8 *TempCount); + +static void +TrAmlInitLineNumbers ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *Neighbor); + +static void +TrAmlInitNode ( + ACPI_PARSE_OBJECT *Op, + UINT16 ParseOpcode); + +static void +TrAmlSetSubtreeParent ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *Parent); + +static void +TrAmlInsertPeer ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *NewPeer); + +static void +TrDoDefinitionBlock ( + ACPI_PARSE_OBJECT *Op); + +static void +TrDoSwitch ( + ACPI_PARSE_OBJECT *StartNode); + /******************************************************************************* * * FUNCTION: TrAmlGetNextTempName * - * PARAMETERS: NamePath - Where a pointer to the temp name is returned + * PARAMETERS: Op - Current parse op + * TempCount - Current temporary counter. Was originally + * per-module; Currently per method, could be + * expanded to per-scope. * - * RETURN: A pointer to the second character of the name + * RETURN: A pointer to name (allocated here). * * DESCRIPTION: Generate an ACPI name of the form _T_x. These names are - * reserved for use by the ASL compiler. + * reserved for use by the ASL compiler. (_T_0 through _T_Z) * ******************************************************************************/ -char * +static char * TrAmlGetNextTempName ( - char **NamePath) + ACPI_PARSE_OBJECT *Op, + UINT8 *TempCount) { char *TempName; - if (Gbl_TempCount > (9+26+26)) + if (*TempCount >= (10+26)) /* 0-35 valid: 0-9 and A-Z for TempName[3] */ { /* Too many temps */ - /* TBD: issue eror message */ - *NamePath = "ERROR"; - return ("Error"); + + AslError (ASL_ERROR, ASL_MSG_TOO_MANY_TEMPS, Op, NULL); + return (NULL); } - TempName = UtLocalCalloc (6); + TempName = UtLocalCalloc (5); - if (Gbl_TempCount < 9) - { - TempName[4] = (char) (Gbl_TempCount + 0x30); - } - else if (Gbl_TempCount < (9 + 26)) + if (*TempCount < 10) /* 0-9 */ { - TempName[4] = (char) (Gbl_TempCount + 0x41); + TempName[3] = (char) (*TempCount + '0'); } - else + else /* 10-35: A-Z */ { - TempName[4] = (char) (Gbl_TempCount + 0x61); + TempName[3] = (char) (*TempCount + ('A' - 10)); } - Gbl_TempCount++; + (*TempCount)++; - /* First four characters are always "\_T_" */ + /* First three characters are always "_T_" */ - TempName[0] = '\\'; - TempName[1] = '_'; - TempName[2] = 'T'; - TempName[3] = '_'; + TempName[0] = '_'; + TempName[1] = 'T'; + TempName[2] = '_'; - *NamePath = TempName; - return (&TempName[1]); + return (TempName); } @@ -183,7 +220,7 @@ TrAmlGetNextTempName ( * * FUNCTION: TrAmlInitLineNumbers * - * PARAMETERS: Op - Op to be initialized + * PARAMETERS: Op - Op to be initialized * Neighbor - Op used for initialization values * * RETURN: None @@ -192,7 +229,7 @@ TrAmlGetNextTempName ( * ******************************************************************************/ -void +static void TrAmlInitLineNumbers ( ACPI_PARSE_OBJECT *Op, ACPI_PARSE_OBJECT *Neighbor) @@ -210,7 +247,7 @@ TrAmlInitLineNumbers ( * * FUNCTION: TrAmlInitNode * - * PARAMETERS: Op - Op to be initialized + * PARAMETERS: Op - Op to be initialized * ParseOpcode - Opcode for this node * * RETURN: None @@ -219,7 +256,7 @@ TrAmlInitLineNumbers ( * ******************************************************************************/ -void +static void TrAmlInitNode ( ACPI_PARSE_OBJECT *Op, UINT16 ParseOpcode) @@ -234,7 +271,7 @@ TrAmlInitNode ( * * FUNCTION: TrAmlSetSubtreeParent * - * PARAMETERS: Op - First node in a list of peer nodes + * PARAMETERS: Op - First node in a list of peer nodes * Parent - Parent of the subtree * * RETURN: None @@ -243,7 +280,7 @@ TrAmlInitNode ( * ******************************************************************************/ -void +static void TrAmlSetSubtreeParent ( ACPI_PARSE_OBJECT *Op, ACPI_PARSE_OBJECT *Parent) @@ -264,7 +301,7 @@ TrAmlSetSubtreeParent ( * * FUNCTION: TrAmlInsertPeer * - * PARAMETERS: Op - First node in a list of peer nodes + * PARAMETERS: Op - First node in a list of peer nodes * NewPeer - Peer node to insert * * RETURN: None @@ -273,7 +310,7 @@ TrAmlSetSubtreeParent ( * ******************************************************************************/ -void +static void TrAmlInsertPeer ( ACPI_PARSE_OBJECT *Op, ACPI_PARSE_OBJECT *NewPeer) @@ -323,7 +360,7 @@ TrAmlTransformWalk ( * ******************************************************************************/ -void +static void TrTransformSubtree ( ACPI_PARSE_OBJECT *Op) { @@ -343,6 +380,15 @@ TrTransformSubtree ( TrDoSwitch (Op); break; + case PARSEOP_METHOD: + + /* + * TBD: Zero the tempname (_T_x) count. Probably shouldn't be a global, + * however + */ + Gbl_TempCount = 0; + break; + default: /* Nothing to do here for other opcodes */ break; @@ -364,7 +410,7 @@ TrTransformSubtree ( * ******************************************************************************/ -void +static void TrDoDefinitionBlock ( ACPI_PARSE_OBJECT *Op) { @@ -376,6 +422,18 @@ TrDoDefinitionBlock ( for (i = 0; i < 5; i++) { Next = Next->Asl.Next; + if (i == 0) + { + /* + * This is the table signature. Only the DSDT can be assumed + * to be at the root of the namespace; Therefore, namepath + * optimization can only be performed on the DSDT. + */ + if (ACPI_STRNCMP (Next->Asl.Value.String, "DSDT", 4)) + { + Gbl_ReferenceOptimizationFlag = FALSE; + } + } } Gbl_FirstLevelInsertionNode = Next; @@ -396,7 +454,7 @@ TrDoDefinitionBlock ( * ******************************************************************************/ -void +static void TrDoSwitch ( ACPI_PARSE_OBJECT *StartNode) { @@ -411,19 +469,43 @@ TrDoSwitch ( ACPI_PARSE_OBJECT *NewOp; ACPI_PARSE_OBJECT *NewOp2; char *PredicateValueName; - char *PredicateValuePath; + UINT16 Index; + UINT32 Btype; + /* Start node is the Switch() node */ + CurrentParentNode = StartNode; - PredicateValueName = TrAmlGetNextTempName (&PredicateValuePath); - /* First child is the predicate */ + /* Create a new temp name of the form _T_x */ + + PredicateValueName = TrAmlGetNextTempName (StartNode, &Gbl_TempCount); + if (!PredicateValueName) + { + return; + } + + /* First child is the Switch() predicate */ Next = StartNode->Asl.Child; - Peer = Next->Asl.Next; + + /* + * Examine the return type of the Switch Value - + * must be Integer/Buffer/String + */ + Index = (UINT16) (Next->Asl.ParseOpcode - ASL_PARSE_OPCODE_BASE); + Btype = AslKeywordMapping[Index].AcpiBtype; + if ((Btype != ACPI_BTYPE_INTEGER) && + (Btype != ACPI_BTYPE_STRING) && + (Btype != ACPI_BTYPE_BUFFER)) + { + AslError (ASL_WARNING, ASL_MSG_SWITCH_TYPE, Next, NULL); + Btype = ACPI_BTYPE_INTEGER; + } /* CASE statements start at next child */ + Peer = Next->Asl.Next; while (Peer) { Next = Peer; @@ -435,6 +517,10 @@ TrDoSwitch ( { /* Add an ELSE to complete the previous CASE */ + if (!Conditional) + { + return; + } NewOp = TrCreateLeafNode (PARSEOP_ELSE); NewOp->Asl.Parent = Conditional->Asl.Parent; TrAmlInitLineNumbers (NewOp, NewOp->Asl.Parent); @@ -451,14 +537,14 @@ TrDoSwitch ( Conditional->Asl.Child->Asl.Next = NULL; Predicate = CaseOp->Asl.Child; - if (Predicate->Asl.ParseOpcode == PARSEOP_PACKAGE) + if ((Predicate->Asl.ParseOpcode == PARSEOP_PACKAGE) || + (Predicate->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)) { - AcpiOsPrintf ("Package\n"); - /* * Convert the package declaration to this form: * - * If (LNotEqual (Match (Package(){4}, MEQ, _Txx, MTR, 0, 0), Ones)) + * If (LNotEqual (Match (Package(<size>){<data>}, + * MEQ, _T_x, MTR, Zero, Zero), Ones)) */ NewOp2 = TrCreateLeafNode (PARSEOP_MATCHTYPE_MEQ); Predicate->Asl.Next = NewOp2; @@ -466,7 +552,7 @@ TrDoSwitch ( NewOp = NewOp2; NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, - (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValuePath)); + (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName)); NewOp->Asl.Next = NewOp2; TrAmlInitLineNumbers (NewOp2, Predicate); @@ -514,21 +600,26 @@ TrDoSwitch ( else { /* - * Change CaseOp() to: If (PredicateValue == CaseValue) {...} + * Integer and Buffer case. + * + * Change CaseOp() to: If (LEqual (SwitchValue, CaseValue)) {...} + * Note: SwitchValue is first to allow the CaseValue to be implicitly + * converted to the type of SwitchValue if necessary. + * * 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; + (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName)); + NewOp->Asl.Next = Predicate; TrAmlInitLineNumbers (NewOp, Predicate); NewOp2 = TrCreateLeafNode (PARSEOP_LEQUAL); NewOp2->Asl.Parent = Conditional; - NewOp2->Asl.Child = Predicate; + NewOp2->Asl.Child = NewOp; TrAmlInitLineNumbers (NewOp2, Conditional); - TrAmlSetSubtreeParent (Predicate, NewOp2); + TrAmlSetSubtreeParent (NewOp, NewOp2); Predicate = NewOp2; Predicate->Asl.Next = CaseBlock; @@ -584,14 +675,13 @@ TrDoSwitch ( { /* Unknown peer opcode */ - printf ("Unknown parse opcode for switch statement: %s (%d)\n", + AcpiOsPrintf ("Unknown parse opcode for switch statement: %s (%d)\n", Next->Asl.ParseOpName, Next->Asl.ParseOpcode); } } - /* - * Add the default case 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 */ @@ -600,6 +690,10 @@ TrDoSwitch ( { /* Convert the DEFAULT node to an ELSE */ + if (!Conditional) + { + return; + } TrAmlInitNode (DefaultOp, PARSEOP_ELSE); DefaultOp->Asl.Parent = Conditional->Asl.Parent; @@ -615,35 +709,74 @@ TrDoSwitch ( } /* - * Add a NAME node for the temp integer + * Add a NAME node for the temp integer: + * Change the SWITCH node to a Name (_T_x, Type) */ - NewOp = TrCreateLeafNode (PARSEOP_NAME); - NewOp->Asl.Parent = Gbl_FirstLevelInsertionNode->Asl.Parent; + Predicate = StartNode->Asl.Child; + TrAmlInitNode (StartNode, PARSEOP_NAME); + + NewOp = StartNode; + NewOp->Asl.CompileFlags |= NODE_COMPILER_EMITTED; - NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, - (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName)); + NewOp2 = TrCreateValuedLeafNode (PARSEOP_NAMESEG, + (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName)); + NewOp2->Asl.CompileFlags |= NODE_IS_NAME_DECLARATION; NewOp->Asl.Child = NewOp2; - NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_INTEGER, (ACPI_INTEGER) 0); - TrAmlSetSubtreeParent (NewOp2, NewOp); + /* Btype was already validated above */ + + switch (Btype) + { + case ACPI_BTYPE_INTEGER: + NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_ZERO, + (ACPI_INTEGER) 0); + break; - /* Insert this node at the global level of the ASL */ + case ACPI_BTYPE_STRING: + NewOp2->Asl.Next = TrCreateValuedLeafNode (PARSEOP_STRING_LITERAL, + (ACPI_INTEGER) ""); + break; - TrAmlInsertPeer (Gbl_FirstLevelInsertionNode, NewOp); - TrAmlInitLineNumbers (NewOp, Gbl_FirstLevelInsertionNode); - TrAmlInitLineNumbers (NewOp2, Gbl_FirstLevelInsertionNode); - TrAmlInitLineNumbers (NewOp2->Asl.Next, Gbl_FirstLevelInsertionNode); + case ACPI_BTYPE_BUFFER: + (void) TrLinkPeerNode (NewOp2, TrCreateValuedLeafNode (PARSEOP_BUFFER, + (ACPI_INTEGER) 0)); + Next = NewOp2->Asl.Next; + (void) TrLinkChildren (Next, 1, TrCreateValuedLeafNode (PARSEOP_ZERO, + (ACPI_INTEGER) 1)); + (void) TrLinkPeerNode (Next->Asl.Child, + TrCreateValuedLeafNode (PARSEOP_DEFAULT_ARG, (ACPI_INTEGER) 0)); + + TrAmlSetSubtreeParent (Next->Asl.Child, Next); + break; + + default: + break; + } + + TrAmlSetSubtreeParent (NewOp2, NewOp); /* - * Change the SWITCH node to a STORE (predicate value, _Txx) + * Create and insert a new Store() node which will be used to save the + * Switch() value. The store is of the form: Store (Value, _T_x) + * where _T_x is the temp variable. */ - TrAmlInitNode (StartNode, PARSEOP_STORE); + Next = TrCreateLeafNode (PARSEOP_STORE); + TrAmlInsertPeer (StartNode, Next); + TrAmlSetSubtreeParent (Next, StartNode->Asl.Parent); + + TrAmlInitLineNumbers (Next, StartNode); + TrAmlInitLineNumbers (NewOp2, StartNode); + TrAmlInitLineNumbers (NewOp2->Asl.Next, StartNode); + + /* Complete the Store subtree */ + + Next->Asl.Child = Predicate; + Predicate->Asl.Parent = Next; - Predicate = StartNode->Asl.Child; - NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESTRING, - (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValuePath)); - NewOp->Asl.Parent = StartNode; + NewOp = TrCreateValuedLeafNode (PARSEOP_NAMESEG, + (ACPI_INTEGER) ACPI_TO_INTEGER (PredicateValueName)); + NewOp->Asl.Parent = Next; Predicate->Asl.Next = NewOp; } diff --git a/sys/contrib/dev/acpica/compiler/asltree.c b/sys/contrib/dev/acpica/compiler/asltree.c index 5ae7083..6092607 100644 --- a/sys/contrib/dev/acpica/compiler/asltree.c +++ b/sys/contrib/dev/acpica/compiler/asltree.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: asltree - parse tree management - * $Revision: 55 $ + * $Revision: 1.60 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,12 +116,22 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("asltree") +/* Local prototypes */ + +static ACPI_PARSE_OBJECT * +TrGetNextNode ( + void); + +static char * +TrGetNodeFlagName ( + UINT32 Flags); + /******************************************************************************* * @@ -137,13 +147,15 @@ * ******************************************************************************/ -ACPI_PARSE_OBJECT * -TrGetNextNode (void) +static ACPI_PARSE_OBJECT * +TrGetNextNode ( + void) { if (Gbl_NodeCacheNext >= Gbl_NodeCacheLast) { - Gbl_NodeCacheNext = UtLocalCalloc (sizeof (ACPI_PARSE_OBJECT) * ASL_NODE_CACHE_SIZE); + Gbl_NodeCacheNext = UtLocalCalloc (sizeof (ACPI_PARSE_OBJECT) * + ASL_NODE_CACHE_SIZE); Gbl_NodeCacheLast = Gbl_NodeCacheNext + ASL_NODE_CACHE_SIZE; } @@ -298,13 +310,13 @@ TrUpdateNode ( * * PARAMETERS: Flags - Flags word to be decoded * - * RETURN: Name string + * RETURN: Name string. Always returns a valid string pointer. * * DESCRIPTION: Decode a flags word * ******************************************************************************/ -char * +static char * TrGetNodeFlagName ( UINT32 Flags) { @@ -372,10 +384,10 @@ TrGetNodeFlagName ( * * FUNCTION: TrSetNodeFlags * - * PARAMETERS: Op - An existing parse node + * PARAMETERS: Op - An existing parse node * Flags - New flags word * - * RETURN: The updated node + * RETURN: The updated parser op * * DESCRIPTION: Set bits in the node flags word. Will not clear bits, only set * @@ -388,7 +400,8 @@ TrSetNodeFlags ( { DbgPrint (ASL_PARSE_OUTPUT, - "\nSetNodeFlags: Op %p, %8.8X %s\n\n", Op, Flags, TrGetNodeFlagName (Flags)); + "\nSetNodeFlags: Op %p, %8.8X %s\n\n", Op, Flags, + TrGetNodeFlagName (Flags)); if (!Op) { @@ -716,7 +729,8 @@ TrLinkChildren ( if ((Child == PrevChild) && (Child != NULL)) { - AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Child, "Child node list invalid"); + AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Child, + "Child node list invalid"); return Op; } @@ -818,8 +832,10 @@ TrLinkPeerNode ( if (Op1 == Op2) { DbgPrint (ASL_DEBUG_OUTPUT, - "\n\n************* Internal error, linking node to itself %p\n\n\n", Op1); - AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op1, "Linking node to itself"); + "\n\n************* Internal error, linking node to itself %p\n\n\n", + Op1); + AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op1, + "Linking node to itself"); return Op1; } @@ -995,9 +1011,8 @@ TrWalkParseTree ( { if (!NodePreviouslyVisited) { - /* - * Let the callback process the node. - */ + /* Let the callback process the node. */ + Status = DescendingCallback (Op, Level, Context); if (ACPI_SUCCESS (Status)) { @@ -1056,10 +1071,8 @@ TrWalkParseTree ( if ((!Op->Asl.Child) || (NodePreviouslyVisited)) { - /* - * Let the callback process the node. - * - */ + /* Let the callback process the node. */ + Status = AscendingCallback (Op, Level, Context); if (ACPI_FAILURE (Status)) { @@ -1118,9 +1131,8 @@ TrWalkParseTree ( } else { - /* - * Let the callback process the node. - */ + /* Let the callback process the node. */ + Status = DescendingCallback (Op, Level, Context); if (ACPI_SUCCESS (Status)) { diff --git a/sys/contrib/dev/acpica/compiler/asltypes.h b/sys/contrib/dev/acpica/compiler/asltypes.h index ae7876c..e681376 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: 65 $ + * $Revision: 1.78 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -120,9 +120,6 @@ #define __ASLTYPES_H -#include <time.h> - - /******************************************************************************* * * Structure definitions @@ -150,6 +147,7 @@ #define NODE_WAS_ONES_OP 0x00008000 #define NODE_IS_NAME_DECLARATION 0x00010000 #define NODE_COMPILER_EMITTED 0x00020000 +#define NODE_IS_DUPLICATE 0x00040000 /* Keeps information about individual control methods */ @@ -290,8 +288,8 @@ ACPI_STATUS (*ASL_WALK_CALLBACK) ( typedef struct asl_event_info { - time_t StartTime; - time_t EndTime; + UINT64 StartTime; + UINT64 EndTime; char *EventName; BOOLEAN Valid; @@ -307,188 +305,216 @@ typedef struct asl_event_info typedef enum { - ASL_MSG_NULL = 0, - ASL_MSG_MEMORY_ALLOCATION, - ASL_MSG_INPUT_FILE_OPEN, - ASL_MSG_OUTPUT_FILENAME, - ASL_MSG_OUTPUT_FILE_OPEN, - ASL_MSG_LISTING_FILENAME, - ASL_MSG_LISTING_FILE_OPEN, - ASL_MSG_DEBUG_FILENAME, + ASL_MSG_ALPHANUMERIC_STRING, + ASL_MSG_AML_NOT_IMPLEMENTED, + ASL_MSG_ARG_COUNT_HI, + ASL_MSG_ARG_COUNT_LO, + ASL_MSG_ARG_INIT, + ASL_MSG_BACKWARDS_OFFSET, + ASL_MSG_BITS_TO_BYTES, + ASL_MSG_BUFFER_LENGTH, + ASL_MSG_BYTES_TO_BITS, + ASL_MSG_CLOSE, + ASL_MSG_COMPILER_INTERNAL, + ASL_MSG_CONSTANT_EVALUATION, + ASL_MSG_CONSTANT_FOLDED, + ASL_MSG_CORE_EXCEPTION, ASL_MSG_DEBUG_FILE_OPEN, - ASL_MSG_INCLUDE_FILE_OPEN, + ASL_MSG_DEBUG_FILENAME, + ASL_MSG_DEPENDENT_NESTING, + ASL_MSG_DMA_CHANNEL, + ASL_MSG_DMA_LIST, + ASL_MSG_DUPLICATE_CASE, + ASL_MSG_DUPLICATE_ITEM, + ASL_MSG_EARLY_EOF, ASL_MSG_ENCODING_LENGTH, - ASL_MSG_INVALID_PRIORITY, + ASL_MSG_EX_INTERRUPT_LIST, + ASL_MSG_EX_INTERRUPT_NUMBER, + ASL_MSG_FIELD_ACCESS_WIDTH, + ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, + ASL_MSG_FIELD_UNIT_OFFSET, + ASL_MSG_INCLUDE_FILE_OPEN, + ASL_MSG_INPUT_FILE_OPEN, + ASL_MSG_INTEGER_LENGTH, + ASL_MSG_INTEGER_OPTIMIZATION, + ASL_MSG_INTERRUPT_LIST, + ASL_MSG_INTERRUPT_NUMBER, + ASL_MSG_INVALID_CONSTANT_OP, + ASL_MSG_INVALID_EISAID, + ASL_MSG_INVALID_ESCAPE, + ASL_MSG_INVALID_OPERAND, ASL_MSG_INVALID_PERFORMANCE, + ASL_MSG_INVALID_PRIORITY, + ASL_MSG_INVALID_STRING, + ASL_MSG_INVALID_TARGET, + ASL_MSG_INVALID_TIME, + ASL_MSG_INVALID_TYPE, + ASL_MSG_INVALID_UUID, + ASL_MSG_LIST_LENGTH, + ASL_MSG_LISTING_FILE_OPEN, + ASL_MSG_LISTING_FILENAME, ASL_MSG_LOCAL_INIT, - ASL_MSG_ARG_INIT, - ASL_MSG_UNSUPPORTED, - ASL_MSG_RESERVED_WORD, - ASL_MSG_BUFFER_LENGTH, - ASL_MSG_PACKAGE_LENGTH, - ASL_MSG_RETURN_TYPES, - ASL_MSG_NOT_FOUND, - ASL_MSG_NOT_REACHABLE, - ASL_MSG_NOT_EXIST, + ASL_MSG_LONG_LINE, + ASL_MSG_MEMORY_ALLOCATION, + ASL_MSG_MISSING_ENDDEPENDENT, + ASL_MSG_MISSING_STARTDEPENDENT, + ASL_MSG_MULTIPLE_TYPES, + ASL_MSG_NAME_EXISTS, + ASL_MSG_NAME_OPTIMIZATION, ASL_MSG_NESTED_COMMENT, - ASL_MSG_RESERVED_ARG_COUNT_HI, - ASL_MSG_RESERVED_ARG_COUNT_LO, - ASL_MSG_RESERVED_RETURN_VALUE, - ASL_MSG_ARG_COUNT_HI, - ASL_MSG_ARG_COUNT_LO, + ASL_MSG_NO_CASES, ASL_MSG_NO_RETVAL, - ASL_MSG_SOME_NO_RETVAL, - ASL_MSG_COMPILER_INTERNAL, - ASL_MSG_BACKWARDS_OFFSET, - ASL_MSG_UNKNOWN_RESERVED_NAME, - ASL_MSG_NAME_EXISTS, - ASL_MSG_INVALID_TYPE, - ASL_MSG_MULTIPLE_TYPES, - ASL_MSG_SYNTAX, + ASL_MSG_NO_WHILE, + ASL_MSG_NON_ASCII, + ASL_MSG_NOT_EXIST, + ASL_MSG_NOT_FOUND, ASL_MSG_NOT_METHOD, - ASL_MSG_LONG_LINE, - ASL_MSG_RECURSION, ASL_MSG_NOT_PARAMETER, + ASL_MSG_NOT_REACHABLE, ASL_MSG_OPEN, + ASL_MSG_OUTPUT_FILE_OPEN, + ASL_MSG_OUTPUT_FILENAME, + ASL_MSG_PACKAGE_LENGTH, ASL_MSG_READ, - ASL_MSG_WRITE, - ASL_MSG_SEEK, - ASL_MSG_CLOSE, - ASL_MSG_FIELD_ACCESS_WIDTH, - ASL_MSG_REGION_BYTE_ACCESS, + ASL_MSG_RECURSION, ASL_MSG_REGION_BUFFER_ACCESS, - ASL_MSG_FIELD_UNIT_OFFSET, - ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, - ASL_MSG_RESOURCE_FIELD, - ASL_MSG_BYTES_TO_BITS, - ASL_MSG_BITS_TO_BYTES, - ASL_MSG_AML_NOT_IMPLEMENTED, - ASL_MSG_NO_WHILE, - ASL_MSG_INVALID_ESCAPE, - ASL_MSG_INVALID_STRING, - ASL_MSG_TABLE_SIGNATURE, - ASL_MSG_RESOURCE_LIST, - ASL_MSG_INVALID_TARGET, - ASL_MSG_INVALID_CONSTANT_OP, - ASL_MSG_CONSTANT_EVALUATION, - ASL_MSG_CONSTANT_FOLDED, - ASL_MSG_INVALID_EISAID, - ASL_MSG_RESERVED_OPERAND_TYPE, + ASL_MSG_REGION_BYTE_ACCESS, + ASL_MSG_RESERVED_ARG_COUNT_HI, + ASL_MSG_RESERVED_ARG_COUNT_LO, ASL_MSG_RESERVED_METHOD, - ASL_MSG_ALPHANUMERIC_STRING, + ASL_MSG_RESERVED_OPERAND_TYPE, + ASL_MSG_RESERVED_RETURN_VALUE, ASL_MSG_RESERVED_USE, - ASL_MSG_INVALID_OPERAND, - ASL_MSG_MISSING_ENDDEPENDENT, - ASL_MSG_MISSING_STARTDEPENDENT, - ASL_MSG_DEPENDENT_NESTING, - ASL_MSG_NAME_OPTIMIZATION, - ASL_MSG_SINGLE_NAME_OPTIMIZATION, - ASL_MSG_INTEGER_OPTIMIZATION, + ASL_MSG_RESERVED_WORD, + ASL_MSG_RESOURCE_FIELD, + ASL_MSG_RESOURCE_INDEX, + ASL_MSG_RESOURCE_LIST, + ASL_MSG_RESOURCE_SOURCE, + ASL_MSG_RETURN_TYPES, + ASL_MSG_SCOPE_FWD_REF, ASL_MSG_SCOPE_TYPE, - ASL_MSG_CORE_EXCEPTION, + ASL_MSG_SEEK, + ASL_MSG_SINGLE_NAME_OPTIMIZATION, + ASL_MSG_SOME_NO_RETVAL, + ASL_MSG_STRING_LENGTH, + ASL_MSG_SWITCH_TYPE, + ASL_MSG_SYNC_LEVEL, + ASL_MSG_SYNTAX, + ASL_MSG_TABLE_SIGNATURE, + ASL_MSG_TOO_MANY_TEMPS, + ASL_MSG_UNKNOWN_RESERVED_NAME, ASL_MSG_UNREACHABLE_CODE, - ASL_MSG_EARLY_EOF, - ASL_MSG_SCOPE_FWD_REF, - ASL_MSG_NON_ASCII, - ASL_MSG_INVALID_TIME, - ASL_MSG_DUPLICATE_CASE, - ASL_MSG_NO_CASES, - ASL_MSG_INVALID_UUID + ASL_MSG_UNSUPPORTED, + ASL_MSG_VENDOR_LIST, + ASL_MSG_WRITE } ASL_MESSAGE_IDS; #ifdef ASL_EXCEPTIONS char *AslMessages [] = { -/* ASL_MSG_NULL */ NULL, -/* ASL_MSG_MEMORY_ALLOCATION, */ "Memory allocation failure", -/* ASL_MSG_INPUT_FILE_OPEN, */ "Could not open input file", -/* ASL_MSG_OUTPUT_FILENAME, */ "Could not create output filename", -/* ASL_MSG_OUTPUT_FILE_OPEN, */ "Could not open output AML file", -/* ASL_MSG_LISTING_FILENAME, */ "Could not create listing filename", -/* ASL_MSG_LISTING_FILE_OPEN, */ "Could not open listing file", -/* ASL_MSG_DEBUG_FILENAME, */ "Could not create debug filename", -/* ASL_MSG_DEBUG_FILE_OPEN, */ "Could not open debug file", -/* ASL_MSG_INCLUDE_FILE_OPEN, */ "Could not open include file", -/* ASL_MSG_ENCODING_LENGTH, */ "Package length too long to encode", -/* ASL_MSG_INVALID_PRIORITY, */ "Invalid priority value", -/* ASL_MSG_INVALID_PERFORMANCE, */ "Invalid performance/robustness value", -/* ASL_MSG_LOCAL_INIT, */ "Method local variable is not initialized", -/* ASL_MSG_ARG_INIT, */ "Method argument is not initialized", -/* ASL_MSG_UNSUPPORTED, */ "Unsupported feature", -/* ASL_MSG_RESERVED_WORD, */ "Use of reserved word", -/* ASL_MSG_BUFFER_LENGTH, */ "Effective AML buffer length is zero", -/* ASL_MSG_PACKAGE_LENGTH, */ "Effective AML package length is zero", -/* ASL_MSG_RETURN_TYPES, */ "Not all control paths return a value", -/* ASL_MSG_NOT_FOUND, */ "Object not found or not accessible from scope", -/* ASL_MSG_NOT_REACHABLE, */ "Object not accessible from this scope", -/* ASL_MSG_NOT_EXIST, */ "Object does not exist", -/* ASL_MSG_NESTED_COMMENT, */ "Nested comment found", -/* ASL_MSG_RESERVED_ARG_COUNT_HI, */ "Reserved method has too many arguments", -/* ASL_MSG_RESERVED_ARG_COUNT_LO, */ "Reserved method has too few arguments", -/* ASL_MSG_RESERVED_RETURN_VALUE, */ "Reserved method must return a value", -/* ASL_MSG_ARG_COUNT_HI, */ "Too many arguments", -/* ASL_MSG_ARG_COUNT_LO, */ "Too few arguments", -/* ASL_MSG_NO_RETVAL, */ "Called method returns no value", -/* ASL_MSG_SOME_NO_RETVAL, */ "Called method may not always return a value", -/* ASL_MSG_COMPILER_INTERNAL, */ "Internal compiler error", -/* ASL_MSG_BACKWARDS_OFFSET, */ "Invalid backwards offset", -/* ASL_MSG_UNKNOWN_RESERVED_NAME, */ "Unknown reserved name", -/* ASL_MSG_NAME_EXISTS, */ "Name already exists in scope", -/* ASL_MSG_INVALID_TYPE, */ "Invalid type", -/* ASL_MSG_MULTIPLE_TYPES, */ "Multiple types", -/* ASL_MSG_SYNTAX, */ "", -/* ASL_MSG_NOT_METHOD, */ "Not a control method, cannot invoke", -/* ASL_MSG_LONG_LINE, */ "Splitting long input line", -/* ASL_MSG_RECURSION, */ "Recursive method call", -/* ASL_MSG_NOT_PARAMETER, */ "Not a parameter, used as local only", -/* ASL_MSG_OPEN, */ "Could not open file", -/* ASL_MSG_READ, */ "Could not read file", -/* ASL_MSG_WRITE, */ "Could not write file", -/* ASL_MSG_SEEK, */ "Could not seek file", -/* ASL_MSG_CLOSE, */ "Could not close file", -/* ASL_MSG_FIELD_ACCESS_WIDTH, */ "Access width is greater than region size", -/* ASL_MSG_REGION_BYTE_ACCESS, */ "Host Operation Region requires ByteAcc access", -/* ASL_MSG_REGION_BUFFER_ACCESS, */ "Host Operation Region requires BufferAcc access", -/* ASL_MSG_FIELD_UNIT_OFFSET, */ "Field Unit extends beyond region limit", -/* ASL_MSG_FIELD_UNIT_ACCESS_WIDTH, */ "Access width of Field Unit extends beyond region limit", -/* ASL_MSG_RESOURCE_FIELD, */ "Resource field name cannot be used as a target", -/* ASL_MSG_BYTES_TO_BITS, */ "Field offset is in bytes, but a bit offset is required", -/* ASL_MSG_BITS_TO_BYTES, */ "Field offset is in bits, but a byte offset is required", -/* ASL_MSG_AML_NOT_IMPLEMENTED, */ "Opcode is not implemented in compiler AML code generator", -/* ASL_MSG_NO_WHILE, */ "No enclosing While statement", -/* ASL_MSG_INVALID_ESCAPE, */ "Invalid or unknown escape sequence", -/* ASL_MSG_INVALID_STRING, */ "Invalid Hex/Octal Escape - Non-ASCII or NULL", -/* ASL_MSG_TABLE_SIGNATURE, */ "Invalid Table Signature", -/* ASL_MSG_RESOURCE_LIST, */ "Too many resource items (internal error)", -/* ASL_MSG_INVALID_TARGET, */ "Target operand not allowed in constant expression", -/* ASL_MSG_INVALID_CONSTANT_OP, */ "Invalid operator in constant expression (not type 3/4/5)", -/* ASL_MSG_CONSTANT_EVALUATION, */ "Could not evaluate constant expression", -/* ASL_MSG_CONSTANT_FOLDED, */ "Constant expression evaluated and reduced", -/* ASL_MSG_INVALID_EISAID, */ "EISAID string must be of the form \"UUUXXXX\" (3 uppercase, 4 hex digits)", -/* ASL_MSG_RESERVED_OPERAND_TYPE, */ "Invalid operand type for reserved name, must be", -/* ASL_MSG_RESERVED_METHOD, */ "Reserved name must be a control method", -/* ASL_MSG_ALPHANUMERIC_STRING, */ "String must be entirely alphanumeric", -/* ASL_MSG_RESERVED_USE, */ "Invalid use of reserved name", -/* ASL_MSG_INVALID_OPERAND, */ "Invalid operand", -/* ASL_MSG_MISSING_ENDDEPENDENT, */ "Missing EndDependentFn() macro in dependent resource list", -/* ASL_MSG_MISSING_STARTDEPENDENT, */ "Missing StartDependentFn() macro in dependent resource list", -/* ASL_MSG_DEPENDENT_NESTING, */ "Dependent function macros cannot be nested",\ -/* ASL_MSG_NAME_OPTIMIZATION, */ "NamePath optimized", -/* ASL_MSG_SINGLE_NAME_OPTIMIZATION, */ "NamePath optimized to NameSeg (uses run-time search path)", -/* ASL_MSG_INTEGER_OPTIMIZATION, */ "Integer optimized to single-byte AML opcode", -/* ASL_MSG_SCOPE_TYPE, */ "Existing object has invalid type for Scope operator", -/* ASL_MSG_CORE_EXCEPTION, */ "From ACPI CA Subsystem", -/* ASL_MSG_UNREACHABLE_CODE, */ "Statement is unreachable", +/* ASL_MSG_ALPHANUMERIC_STRING */ "String must be entirely alphanumeric", +/* ASL_MSG_AML_NOT_IMPLEMENTED */ "Opcode is not implemented in compiler AML code generator", +/* ASL_MSG_ARG_COUNT_HI */ "Too many arguments", +/* ASL_MSG_ARG_COUNT_LO */ "Too few arguments", +/* ASL_MSG_ARG_INIT */ "Method argument is not initialized", +/* ASL_MSG_BACKWARDS_OFFSET */ "Invalid backwards offset", +/* ASL_MSG_BITS_TO_BYTES */ "Field offset is in bits, but a byte offset is required", +/* ASL_MSG_BUFFER_LENGTH */ "Effective AML buffer length is zero", +/* ASL_MSG_BYTES_TO_BITS */ "Field offset is in bytes, but a bit offset is required", +/* ASL_MSG_CLOSE */ "Could not close file", +/* ASL_MSG_COMPILER_INTERNAL */ "Internal compiler error", +/* ASL_MSG_CONSTANT_EVALUATION */ "Could not evaluate constant expression", +/* ASL_MSG_CONSTANT_FOLDED */ "Constant expression evaluated and reduced", +/* ASL_MSG_CORE_EXCEPTION */ "From ACPI CA Subsystem", +/* ASL_MSG_DEBUG_FILE_OPEN */ "Could not open debug file", +/* ASL_MSG_DEBUG_FILENAME */ "Could not create debug filename", +/* ASL_MSG_DEPENDENT_NESTING */ "Dependent function macros cannot be nested",\ +/* ASL_MSG_DMA_CHANNEL */ "Invalid DMA channel (must be 0-7)", +/* ASL_MSG_DMA_LIST */ "Too many DMA channels (8 max)", +/* ASL_MSG_DUPLICATE_CASE */ "Case value already specified", +/* ASL_MSG_DUPLICATE_ITEM */ "Duplicate value in list", /* 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_ENCODING_LENGTH */ "Package length too long to encode", +/* ASL_MSG_EX_INTERRUPT_LIST */ "Too many interrupts (255 max)", +/* ASL_MSG_EX_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 32 bits)", +/* ASL_MSG_FIELD_ACCESS_WIDTH */ "Access width is greater than region size", +/* ASL_MSG_FIELD_UNIT_ACCESS_WIDTH */ "Access width of Field Unit extends beyond region limit", +/* ASL_MSG_FIELD_UNIT_OFFSET */ "Field Unit extends beyond region limit", +/* ASL_MSG_INCLUDE_FILE_OPEN */ "Could not open include file", +/* ASL_MSG_INPUT_FILE_OPEN */ "Could not open input file", +/* ASL_MSG_INTEGER_LENGTH */ "64-bit integer in 32-bit table, truncating", +/* ASL_MSG_INTEGER_OPTIMIZATION */ "Integer optimized to single-byte AML opcode", +/* ASL_MSG_INTERRUPT_LIST */ "Too many interrupts (16 max)", +/* ASL_MSG_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 0-15)", +/* ASL_MSG_INVALID_CONSTANT_OP */ "Invalid operator in constant expression (not type 3/4/5)", +/* ASL_MSG_INVALID_EISAID */ "EISAID string must be of the form \"UUUXXXX\" (3 uppercase, 4 hex digits)", +/* ASL_MSG_INVALID_ESCAPE */ "Invalid or unknown escape sequence", +/* ASL_MSG_INVALID_OPERAND */ "Invalid operand", +/* ASL_MSG_INVALID_PERFORMANCE */ "Invalid performance/robustness value", +/* ASL_MSG_INVALID_PRIORITY */ "Invalid priority value", +/* ASL_MSG_INVALID_STRING */ "Invalid Hex/Octal Escape - Non-ASCII or NULL", +/* ASL_MSG_INVALID_TARGET */ "Target operand not allowed in constant expression", /* ASL_MSG_INVALID_TIME */ "Time parameter too long (255 max)", -/* ASL_MSG_DUPLICATE_CASE */ "Case value already specified", +/* ASL_MSG_INVALID_TYPE */ "Invalid type", +/* ASL_MSG_INVALID_UUID */ "UUID string must be of the form \"aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\"", +/* ASL_MSG_LIST_LENGTH */ "Initializer list too long", +/* ASL_MSG_LISTING_FILE_OPEN */ "Could not open listing file", +/* ASL_MSG_LISTING_FILENAME */ "Could not create listing filename", +/* ASL_MSG_LOCAL_INIT */ "Method local variable is not initialized", +/* ASL_MSG_LONG_LINE */ "Splitting long input line", +/* ASL_MSG_MEMORY_ALLOCATION */ "Memory allocation failure", +/* ASL_MSG_MISSING_ENDDEPENDENT */ "Missing EndDependentFn() macro in dependent resource list", +/* ASL_MSG_MISSING_STARTDEPENDENT */ "Missing StartDependentFn() macro in dependent resource list", +/* ASL_MSG_MULTIPLE_TYPES */ "Multiple types", +/* ASL_MSG_NAME_EXISTS */ "Name already exists in scope", +/* ASL_MSG_NAME_OPTIMIZATION */ "NamePath optimized", +/* ASL_MSG_NESTED_COMMENT */ "Nested comment found", /* 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\"" - - +/* ASL_MSG_NO_RETVAL */ "Called method returns no value", +/* ASL_MSG_NO_WHILE */ "No enclosing While statement", +/* ASL_MSG_NON_ASCII */ "Invalid characters found in file", +/* ASL_MSG_NOT_EXIST */ "Object does not exist", +/* ASL_MSG_NOT_FOUND */ "Object not found or not accessible from scope", +/* ASL_MSG_NOT_METHOD */ "Not a control method, cannot invoke", +/* ASL_MSG_NOT_PARAMETER */ "Not a parameter, used as local only", +/* ASL_MSG_NOT_REACHABLE */ "Object not accessible from this scope", +/* ASL_MSG_OPEN */ "Could not open file", +/* ASL_MSG_OUTPUT_FILE_OPEN */ "Could not open output AML file", +/* ASL_MSG_OUTPUT_FILENAME */ "Could not create output filename", +/* ASL_MSG_PACKAGE_LENGTH */ "Effective AML package length is zero", +/* ASL_MSG_READ */ "Could not read file", +/* ASL_MSG_RECURSION */ "Recursive method call", +/* ASL_MSG_REGION_BUFFER_ACCESS */ "Host Operation Region requires BufferAcc access", +/* ASL_MSG_REGION_BYTE_ACCESS */ "Host Operation Region requires ByteAcc access", +/* ASL_MSG_RESERVED_ARG_COUNT_HI */ "Reserved method has too many arguments", +/* ASL_MSG_RESERVED_ARG_COUNT_LO */ "Reserved method has too few arguments", +/* ASL_MSG_RESERVED_METHOD */ "Reserved name must be a control method", +/* ASL_MSG_RESERVED_OPERAND_TYPE */ "Invalid operand type for reserved name, must be", +/* ASL_MSG_RESERVED_RETURN_VALUE */ "Reserved method must return a value", +/* ASL_MSG_RESERVED_USE */ "Invalid use of reserved name", +/* ASL_MSG_RESERVED_WORD */ "Use of reserved word", +/* ASL_MSG_RESOURCE_FIELD */ "Resource field name cannot be used as a target", +/* ASL_MSG_RESOURCE_INDEX */ "Missing ResourceSourceIndex (required)", +/* ASL_MSG_RESOURCE_LIST */ "Too many resource items (internal error)", +/* ASL_MSG_RESOURCE_SOURCE */ "Missing ResourceSource string (required)", +/* ASL_MSG_RETURN_TYPES */ "Not all control paths return a value", +/* ASL_MSG_SCOPE_FWD_REF */ "Forward references from Scope() not allowed", +/* ASL_MSG_SCOPE_TYPE */ "Existing object has invalid type for Scope operator", +/* ASL_MSG_SEEK */ "Could not seek file", +/* ASL_MSG_SINGLE_NAME_OPTIMIZATION */ "NamePath optimized to NameSeg (uses run-time search path)", +/* ASL_MSG_SOME_NO_RETVAL */ "Called method may not always return a value", +/* ASL_MSG_STRING_LENGTH */ "String constant too long (200 max)", +/* ASL_MSG_SWITCH_TYPE */ "Switch expression is not a static Integer/Buffer/String data type, defaulting to Integer", +/* ASL_MSG_SYNC_LEVEL */ "SyncLevel must be in the range 0-15", +/* ASL_MSG_SYNTAX */ "", +/* ASL_MSG_TABLE_SIGNATURE */ "Invalid Table Signature", +/* ASL_MSG_TOO_MANY_TEMPS */ "Method requires too many temporary variables (_T_x)", +/* ASL_MSG_UNKNOWN_RESERVED_NAME */ "Unknown reserved name", +/* ASL_MSG_UNREACHABLE_CODE */ "Statement is unreachable", +/* ASL_MSG_UNSUPPORTED */ "Unsupported feature", +/* ASL_MSG_VENDOR_LIST */ "Too many vendor data bytes (7 max)", +/* ASL_MSG_WRITE */ "Could not write file" }; diff --git a/sys/contrib/dev/acpica/compiler/aslutils.c b/sys/contrib/dev/acpica/compiler/aslutils.c index b5e5051..1c9f48b 100644 --- a/sys/contrib/dev/acpica/compiler/aslutils.c +++ b/sys/contrib/dev/acpica/compiler/aslutils.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslutils -- compiler utilities - * $Revision: 58 $ + * $Revision: 1.66 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,10 +116,10 @@ *****************************************************************************/ -#include "aslcompiler.h" +#include <contrib/dev/acpica/compiler/aslcompiler.h> #include "aslcompiler.y.h" -#include "acnamesp.h" -#include "amlcode.h" +#include <contrib/dev/acpica/acnamesp.h> +#include <contrib/dev/acpica/amlcode.h> #define _COMPONENT ACPI_COMPILER ACPI_MODULE_NAME ("aslutils") @@ -131,13 +131,23 @@ static const char * const *yytname = &AslCompilername[254]; extern const char * const yytname[]; #endif +/* Local prototypes */ -void -AslOptimizeNamepath ( - char *Buffer) -{ - printf ("NamePath: %s\n", Buffer); -} +static ACPI_STATUS +UtStrtoul64 ( + char *String, + UINT32 Base, + ACPI_INTEGER *RetInteger); + +static void +UtPadNameWithUnderscores ( + char *NameSeg, + char *PaddedNameSeg); + +static void +UtAttachNameseg ( + ACPI_PARSE_OBJECT *Op, + char *Name); /******************************************************************************* @@ -158,6 +168,7 @@ UtDisplayConstantOpcodes ( { UINT32 i; + printf ("Constant expression opcode information\n\n"); for (i = 0; i < sizeof (AcpiGbl_AmlOpInfo) / sizeof (ACPI_OPCODE_INFO); i++) @@ -211,24 +222,32 @@ UtLocalCalloc ( * * FUNCTION: UtBeginEvent * - * PARAMETERS: Event - Event number (integer index) - * Name - Ascii name of this event + * PARAMETERS: Name - Ascii name of this event * - * RETURN: None + * RETURN: Event - Event number (integer index) * * DESCRIPTION: Saves the current time with this event * ******************************************************************************/ -void +UINT8 UtBeginEvent ( - UINT32 Event, char *Name) { - AslGbl_Events[Event].StartTime = (time_t) AcpiOsGetTimer(); - AslGbl_Events[Event].EventName = Name; - AslGbl_Events[Event].Valid = TRUE; + if (AslGbl_NextEvent >= ASL_NUM_EVENTS) + { + AcpiOsPrintf ("Ran out of compiler event structs!\n"); + return (AslGbl_NextEvent); + } + + /* Init event with current (start) time */ + + AslGbl_Events[AslGbl_NextEvent].StartTime = AcpiOsGetTimer (); + AslGbl_Events[AslGbl_NextEvent].EventName = Name; + AslGbl_Events[AslGbl_NextEvent].Valid = TRUE; + + return (AslGbl_NextEvent++); } @@ -246,10 +265,17 @@ UtBeginEvent ( void UtEndEvent ( - UINT32 Event) + UINT8 Event) { - AslGbl_Events[Event].EndTime = (time_t) AcpiOsGetTimer(); + if (Event >= ASL_NUM_EVENTS) + { + return; + } + + /* Insert end time for event */ + + AslGbl_Events[Event].EndTime = AcpiOsGetTimer (); } @@ -257,7 +283,7 @@ UtEndEvent ( * * FUNCTION: UtHexCharToValue * - * PARAMETERS: hc - Hex character in Ascii + * PARAMETERS: HexChar - Hex character in Ascii * * RETURN: The binary value of the hex character * @@ -267,20 +293,20 @@ UtEndEvent ( UINT8 UtHexCharToValue ( - int hc) + int HexChar) { - if (hc <= 0x39) + if (HexChar <= 0x39) { - return ((UINT8) (hc - 0x30)); + return ((UINT8) (HexChar - 0x30)); } - if (hc <= 0x46) + if (HexChar <= 0x46) { - return ((UINT8) (hc - 0x37)); + return ((UINT8) (HexChar - 0x37)); } - return ((UINT8) (hc - 0x57)); + return ((UINT8) (HexChar - 0x57)); } @@ -289,7 +315,7 @@ UtHexCharToValue ( * FUNCTION: UtConvertByteToHex * * PARAMETERS: RawByte - Binary data - * *Buffer - Pointer to where the hex bytes will be stored + * Buffer - Pointer to where the hex bytes will be stored * * RETURN: Ascii hex byte is stored in Buffer. * @@ -317,7 +343,7 @@ UtConvertByteToHex ( * FUNCTION: UtConvertByteToAsmHex * * PARAMETERS: RawByte - Binary data - * *Buffer - Pointer to where the hex bytes will be stored + * Buffer - Pointer to where the hex bytes will be stored * * RETURN: Ascii hex byte is stored in Buffer. * @@ -344,7 +370,8 @@ UtConvertByteToAsmHex ( * * FUNCTION: DbgPrint * - * PARAMETERS: Fmt - Printf format string + * PARAMETERS: Type - Type of output + * Fmt - Printf format string * ... - variable printf list * * RETURN: None @@ -431,6 +458,7 @@ void UtSetParseOpName ( ACPI_PARSE_OBJECT *Op) { + strncpy (Op->Asl.ParseOpName, UtGetOpName (Op->Asl.ParseOpcode), 12); } @@ -464,7 +492,7 @@ UtGetOpName ( * * FUNCTION: UtDisplaySummary * - * PARAMETERS: None + * PARAMETERS: FileID - ID of outpout file * * RETURN: None * @@ -590,7 +618,8 @@ UtGetStringBuffer ( if ((Gbl_StringCacheNext + Length) >= Gbl_StringCacheLast) { Gbl_StringCacheNext = UtLocalCalloc (ASL_STRING_CACHE_SIZE + Length); - Gbl_StringCacheLast = Gbl_StringCacheNext + ASL_STRING_CACHE_SIZE + Length; + Gbl_StringCacheLast = Gbl_StringCacheNext + ASL_STRING_CACHE_SIZE + + Length; } Buffer = Gbl_StringCacheNext; @@ -667,7 +696,7 @@ UtInternalizeName ( * ******************************************************************************/ -void +static void UtPadNameWithUnderscores ( char *NameSeg, char *PaddedNameSeg) @@ -698,14 +727,14 @@ UtPadNameWithUnderscores ( * PARAMETERS: Op - Parent parse node * Name - Full ExternalName * - * RETURN: Sets the NameSeg field in parent node + * RETURN: None; Sets the NameSeg field in parent node * * DESCRIPTION: Extract the last nameseg of the ExternalName and store it * in the NameSeg field of the Op. * ******************************************************************************/ -void +static void UtAttachNameseg ( ACPI_PARSE_OBJECT *Op, char *Name) @@ -775,6 +804,10 @@ UtAttachNamepathToOwner ( Op->Asl.ExternalName = NameOp->Asl.Value.String; + /* Save the NameOp for possible error reporting later */ + + Op->Asl.ParentMethod = (void *) NameOp; + /* Last nameseg of the path */ UtAttachNameseg (Op, Op->Asl.ExternalName); @@ -813,7 +846,8 @@ UtDoConstant ( Status = UtStrtoul64 (String, 0, &Converted); if (ACPI_FAILURE (Status)) { - sprintf (ErrBuf, "%s %s\n", "Conversion error:", AcpiFormatException (Status)); + sprintf (ErrBuf, "%s %s\n", "Conversion error:", + AcpiFormatException (Status)); AslCompilererror (ErrBuf); } @@ -821,12 +855,15 @@ UtDoConstant ( } +/* TBD: use version in ACPI CA main code base? */ + /******************************************************************************* * * FUNCTION: UtStrtoul64 * * PARAMETERS: String - Null terminated string - * Terminater - Where a pointer to the terminating byte is returned + * Terminater - Where a pointer to the terminating byte is + * returned * Base - Radix of the string * * RETURN: Converted value @@ -834,10 +871,8 @@ UtDoConstant ( * DESCRIPTION: Convert a string into an unsigned value. * ******************************************************************************/ -#define NEGATIVE 1 -#define POSITIVE 0 -ACPI_STATUS +static ACPI_STATUS UtStrtoul64 ( char *String, UINT32 Base, @@ -867,9 +902,8 @@ UtStrtoul64 ( return (AE_BAD_PARAMETER); } - /* - * skip over any white space in the buffer: - */ + /* Skip over any white space in the buffer: */ + while (isspace (*String) || *String == '\t') { ++String; @@ -977,9 +1011,8 @@ UtStrtoul64 ( } - /* - * If a minus sign was present, then "the conversion is negated": - */ + /* If a minus sign was present, then "the conversion is negated": */ + if (Sign == NEGATIVE) { ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; diff --git a/sys/contrib/dev/acpica/dbcmds.c b/sys/contrib/dev/acpica/dbcmds.c index b158657..65e8593 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: 115 $ + * $Revision: 1.132 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -132,16 +132,61 @@ #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbcmds") +/* Local prototypes */ + +static ACPI_STATUS +AcpiDbIntegrityWalk ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiDbWalkAndMatchName ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiDbWalkForReferences ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiDbWalkForSpecificObjects ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_NAMESPACE_NODE * +AcpiDbConvertToNode ( + char *InString); + +static void +AcpiDmCompareAmlResources ( + UINT8 *Aml1Buffer, + ACPI_RSDESC_SIZE Aml1BufferLength, + UINT8 *Aml2Buffer, + ACPI_RSDESC_SIZE Aml2BufferLength); + +static ACPI_STATUS +AcpiDmTestResourceConversion ( + ACPI_NAMESPACE_NODE *Node, + char *Name); + /* * Arguments for the Objects command * These object types map directly to the ACPI_TYPES */ - static ARGUMENT_INFO AcpiDbObjectTypes [] = { {"ANY"}, - {"NUMBERS"}, + {"INTEGERS"}, {"STRINGS"}, {"BUFFERS"}, {"PACKAGES"}, @@ -162,6 +207,64 @@ static ARGUMENT_INFO AcpiDbObjectTypes [] = /******************************************************************************* * + * FUNCTION: AcpiDbConvertToNode + * + * PARAMETERS: InString - String to convert + * + * RETURN: Pointer to a NS node + * + * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or + * alpha strings. + * + ******************************************************************************/ + +static ACPI_NAMESPACE_NODE * +AcpiDbConvertToNode ( + char *InString) +{ + ACPI_NAMESPACE_NODE *Node; + + + if ((*InString >= 0x30) && (*InString <= 0x39)) + { + /* Numeric argument, convert */ + + Node = ACPI_TO_POINTER (ACPI_STRTOUL (InString, NULL, 16)); + if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) + { + AcpiOsPrintf ("Address %p is invalid in this address space\n", + Node); + return (NULL); + } + + /* Make sure pointer is valid NS node */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) + { + AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n", + Node, AcpiUtGetDescriptorName (Node)); + return (NULL); + } + } + else + { + /* Alpha argument */ + /* The parameter is a name string that must be resolved to a + * Named obj + */ + Node = AcpiDbLocalNsLookup (InString); + if (!Node) + { + Node = AcpiGbl_RootNode; + } + } + + return (Node); +} + + +/******************************************************************************* + * * FUNCTION: AcpiDbSleep * * PARAMETERS: ObjectArg - Desired sleep state (0-5) @@ -222,7 +325,7 @@ AcpiDbSleep ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbWalkForReferences ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -296,7 +399,8 @@ AcpiDbFindReferences ( ******************************************************************************/ void -AcpiDbDisplayLocks (void) +AcpiDbDisplayLocks ( + void) { UINT32 i; @@ -304,7 +408,7 @@ AcpiDbDisplayLocks (void) for (i = 0; i < MAX_MUTEX; i++) { AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i), - AcpiGbl_MutexInfo[i].OwnerId == ACPI_MUTEX_NOT_ACQUIRED + AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED ? "Locked" : "Unlocked"); } } @@ -442,7 +546,8 @@ AcpiDbSetMethodBreakpoint ( Address = ACPI_STRTOUL (Location, NULL, 16); if (Address <= Op->Common.AmlOffset) { - AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", Address, Op->Common.AmlOffset); + AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", + Address, Op->Common.AmlOffset); } /* Save breakpoint in current walk */ @@ -522,7 +627,7 @@ AcpiDbDisassembleAml ( * * FUNCTION: AcpiDbDisassembleMethod * - * PARAMETERS: Method - Name of control method + * PARAMETERS: Name - Name of control method * * RETURN: None * @@ -542,7 +647,7 @@ AcpiDbDisassembleMethod ( ACPI_NAMESPACE_NODE *Method; - Method = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ACPI_STRTOUL (Name, NULL, 16)); + Method = AcpiDbConvertToNode (Name); if (!Method) { return (AE_BAD_PARAMETER); @@ -575,6 +680,7 @@ AcpiDbDisassembleMethod ( /* Parse the AML */ WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; + WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; Status = AcpiPsParseAml (WalkState); AcpiDmDisassemble (NULL, Op, 0); @@ -610,34 +716,10 @@ AcpiDbDumpNamespace ( if (StartArg) { - /* Check if numeric argument, must be a Node */ - - if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39)) - { - SubtreeEntry = ACPI_TO_POINTER (ACPI_STRTOUL (StartArg, NULL, 16)); - if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE))) - { - AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry); - return; - } - - if (ACPI_GET_DESCRIPTOR_TYPE (SubtreeEntry) != ACPI_DESC_TYPE_NAMED) - { - AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n", - SubtreeEntry, AcpiUtGetDescriptorName (SubtreeEntry)); - return; - } - } - else + SubtreeEntry = AcpiDbConvertToNode (StartArg); + if (!SubtreeEntry) { - /* Alpha argument */ - /* The parameter is a name string that must be resolved to a Named obj*/ - - SubtreeEntry = AcpiDbLocalNsLookup (StartArg); - if (!SubtreeEntry) - { - SubtreeEntry = AcpiGbl_RootNode; - } + return; } /* Now we can check for the depth argument */ @@ -649,12 +731,14 @@ AcpiDbDumpNamespace ( } AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); - AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry); + AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n", + ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry); /* Display the subtree */ AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); - AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry); + AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, + ACPI_OWNER_ID_MAX, SubtreeEntry); AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); } @@ -679,10 +763,10 @@ AcpiDbDumpNamespaceByOwner ( { ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; UINT32 MaxDepth = ACPI_UINT32_MAX; - UINT16 OwnerId; + ACPI_OWNER_ID OwnerId; - OwnerId = (UINT16) ACPI_STRTOUL (OwnerArg, NULL, 0); + OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0); /* Now we can check for the depth argument */ @@ -697,7 +781,8 @@ AcpiDbDumpNamespaceByOwner ( /* Display the subtree */ AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); - AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, SubtreeEntry); + AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, + SubtreeEntry); AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); } @@ -727,7 +812,7 @@ AcpiDbSendNotify ( /* Translate name to an Named object */ - Node = AcpiDbLocalNsLookup (Name); + Node = AcpiDbConvertToNode (Name); if (!Node) { return; @@ -783,23 +868,39 @@ AcpiDbSetMethodData ( ACPI_WALK_STATE *WalkState; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; /* Validate TypeArg */ - ACPI_STRUPR (TypeArg); + AcpiUtStrupr (TypeArg); Type = TypeArg[0]; if ((Type != 'L') && - (Type != 'A')) + (Type != 'A') && + (Type != 'N')) { AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); return; } + Value = ACPI_STRTOUL (ValueArg, NULL, 16); + + if (Type == 'N') + { + Node = AcpiDbConvertToNode (IndexArg); + if (Node->Type != ACPI_TYPE_INTEGER) + { + AcpiOsPrintf ("Can only set Integer nodes\n"); + return; + } + ObjDesc = Node->Object; + ObjDesc->Integer.Value = Value; + return; + } + /* Get the index and value */ Index = ACPI_STRTOUL (IndexArg, NULL, 16); - Value = ACPI_STRTOUL (ValueArg, NULL, 16); WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); if (!WalkState) @@ -833,7 +934,8 @@ AcpiDbSetMethodData ( return; } - Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, WalkState); + Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, + WalkState); if (ACPI_FAILURE (Status)) { return; @@ -855,7 +957,8 @@ AcpiDbSetMethodData ( return; } - Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, WalkState); + Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, + WalkState); if (ACPI_FAILURE (Status)) { return; @@ -885,19 +988,19 @@ AcpiDbSetMethodData ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbWalkForSpecificObjects ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue) { - ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status; + ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; ACPI_BUFFER Buffer; + ACPI_STATUS Status; - ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjHandle); + Info->Count++; /* Get and display the full pathname to this object */ @@ -912,50 +1015,9 @@ AcpiDbWalkForSpecificObjects ( AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); ACPI_MEM_FREE (Buffer.Pointer); - /* Display short information about the object */ - - if (ObjDesc) - { - AcpiOsPrintf (" %p/%p", ObjHandle, ObjDesc); + /* Dump short info about the object */ - switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) - { - case ACPI_TYPE_METHOD: - AcpiOsPrintf (" #Args %d Concurrency %X", - ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency); - break; - - case ACPI_TYPE_INTEGER: - AcpiOsPrintf (" Value %8.8X%8.8X", - ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); - break; - - case ACPI_TYPE_STRING: - AcpiOsPrintf (" \"%s\"", ObjDesc->String.Pointer); - break; - - case ACPI_TYPE_REGION: - AcpiOsPrintf (" SpaceId %X Length %X Address %8.8X%8.8X", - ObjDesc->Region.SpaceId, - ObjDesc->Region.Length, - ACPI_FORMAT_UINT64 (ObjDesc->Region.Address)); - break; - - case ACPI_TYPE_PACKAGE: - AcpiOsPrintf (" #Elements %X", ObjDesc->Package.Count); - break; - - case ACPI_TYPE_BUFFER: - AcpiOsPrintf (" Length %X", ObjDesc->Buffer.Length); - break; - - default: - /* Ignore other object types */ - break; - } - } - - AcpiOsPrintf ("\n"); + (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL); return (AE_OK); } @@ -978,6 +1040,7 @@ AcpiDbDisplayObjects ( char *ObjTypeArg, char *DisplayCountArg) { + ACPI_WALK_INFO Info; ACPI_OBJECT_TYPE Type; @@ -991,15 +1054,25 @@ AcpiDbDisplayObjects ( } AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); - AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n", + AcpiOsPrintf ( + "Objects of type [%s] defined in the current ACPI Namespace:\n", AcpiUtGetTypeName (Type)); AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); + Info.Count = 0; + Info.OwnerId = ACPI_OWNER_ID_MAX; + Info.DebugLevel = ACPI_UINT32_MAX; + Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; + /* Walk the namespace from the root */ (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbWalkForSpecificObjects, (void *) &Type, NULL); + AcpiDbWalkForSpecificObjects, (void *) &Info, NULL); + + AcpiOsPrintf ( + "\nFound %u objects of type [%s] in the current ACPI Namespace\n", + Info.Count, AcpiUtGetTypeName (Type)); AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); return (AE_OK); @@ -1019,7 +1092,7 @@ AcpiDbDisplayObjects ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbWalkAndMatchName ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -1030,6 +1103,7 @@ AcpiDbWalkAndMatchName ( char *RequestedName = (char *) Context; UINT32 i; ACPI_BUFFER Buffer; + ACPI_WALK_INFO Info; /* Check for a name match */ @@ -1057,8 +1131,12 @@ AcpiDbWalkAndMatchName ( } else { - AcpiOsPrintf ("%32s (%p) - %s\n", (char *) Buffer.Pointer, ObjHandle, - AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type)); + Info.OwnerId = ACPI_OWNER_ID_MAX; + Info.DebugLevel = ACPI_UINT32_MAX; + Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; + + AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); + (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL); ACPI_MEM_FREE (Buffer.Pointer); } @@ -1092,6 +1170,7 @@ AcpiDbFindNameInNamespace ( /* Walk the namespace from the root */ + AcpiUtStrupr (NameArg); (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, AcpiDbWalkAndMatchName, NameArg, NULL); @@ -1133,7 +1212,8 @@ AcpiDbSetScope ( { /* Validate new scope from the root */ - Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode, ACPI_NS_NO_UPSEARCH, &Node); + Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode, + ACPI_NS_NO_UPSEARCH, &Node); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -1146,7 +1226,8 @@ AcpiDbSetScope ( { /* Validate new scope relative to old scope */ - Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode, ACPI_NS_NO_UPSEARCH, &Node); + Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode, + ACPI_NS_NO_UPSEARCH, &Node); if (ACPI_FAILURE (Status)) { goto ErrorExit; @@ -1162,7 +1243,179 @@ AcpiDbSetScope ( ErrorExit: - AcpiOsPrintf ("Could not attach scope: %s, %s\n", Name, AcpiFormatException (Status)); + AcpiOsPrintf ("Could not attach scope: %s, %s\n", + Name, AcpiFormatException (Status)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmCompareAmlResources + * + * PARAMETERS: Aml1Buffer - Contains first resource list + * Aml1BufferLength - Length of first resource list + * Aml2Buffer - Contains second resource list + * Aml2BufferLength - Length of second resource list + * + * RETURN: None + * + * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in + * order to isolate a miscompare to an individual resource) + * + ******************************************************************************/ + +static void +AcpiDmCompareAmlResources ( + UINT8 *Aml1Buffer, + ACPI_RSDESC_SIZE Aml1BufferLength, + UINT8 *Aml2Buffer, + ACPI_RSDESC_SIZE Aml2BufferLength) +{ + UINT8 *Aml1; + UINT8 *Aml2; + ACPI_RSDESC_SIZE Aml1Length; + ACPI_RSDESC_SIZE Aml2Length; + ACPI_RSDESC_SIZE Offset = 0; + UINT8 ResourceType; + UINT32 Count = 0; + + + /* Compare overall buffer sizes (may be different due to size rounding) */ + + if (Aml1BufferLength != Aml2BufferLength) + { + AcpiOsPrintf ( + "**** Buffer length mismatch in converted AML: original %X new %X ****\n", + Aml1BufferLength, Aml2BufferLength); + } + + Aml1 = Aml1Buffer; + Aml2 = Aml2Buffer; + + /* Walk the descriptor lists, comparing each descriptor */ + + while (Aml1 < (Aml1Buffer + Aml1BufferLength)) + { + /* Get the lengths of each descriptor */ + + Aml1Length = AcpiUtGetDescriptorLength (Aml1); + Aml2Length = AcpiUtGetDescriptorLength (Aml2); + ResourceType = AcpiUtGetResourceType (Aml1); + + /* Check for descriptor length match */ + + if (Aml1Length != Aml2Length) + { + AcpiOsPrintf ( + "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X L1 %X L2 %X ****\n", + Count, ResourceType, Offset, Aml1Length, Aml2Length); + return; + } + + /* Check for descriptor byte match */ + + if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length)) + { + AcpiOsPrintf ( + "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n", + Count, ResourceType, Offset); + } + + /* Exit on EndTag descriptor */ + + if (ResourceType == ACPI_RESOURCE_NAME_END_TAG) + { + return; + } + + /* Point to next descriptor in each buffer */ + + Count++; + Offset += Aml1Length; + Aml1 += Aml1Length; + Aml2 += Aml1Length; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmTestResourceConversion + * + * PARAMETERS: Node - Parent device node + * Name - resource method name (_CRS) + * + * RETURN: Status + * + * DESCRIPTION: Compare the original AML with a conversion of the AML to + * internal resource list, then back to AML. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDmTestResourceConversion ( + ACPI_NAMESPACE_NODE *Node, + char *Name) +{ + ACPI_STATUS Status; + ACPI_BUFFER ReturnObj; + ACPI_BUFFER ResourceObj; + ACPI_BUFFER NewAml; + ACPI_OBJECT *OriginalAml; + + + AcpiOsPrintf ("Resource Conversion Comparison:\n"); + + NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + ReturnObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + ResourceObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + + /* Get the original _CRS AML resource template */ + + Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not obtain %s: %s\n", + Name, AcpiFormatException (Status)); + return (Status); + } + + /* Get the AML resource template, converted to internal resource structs */ + + Status = AcpiGetCurrentResources (Node, &ResourceObj); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", + AcpiFormatException (Status)); + goto Exit1; + } + + /* Convert internal resource list to external AML resource template */ + + Status = AcpiRsCreateAmlResources (ResourceObj.Pointer, &NewAml); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n", + AcpiFormatException (Status)); + goto Exit2; + } + + /* Compare original AML to the newly created AML resource list */ + + OriginalAml = ReturnObj.Pointer; + + AcpiDmCompareAmlResources ( + OriginalAml->Buffer.Pointer, OriginalAml->Buffer.Length, + NewAml.Pointer, NewAml.Length); + + /* Cleanup and exit */ + + ACPI_MEM_FREE (NewAml.Pointer); +Exit2: + ACPI_MEM_FREE (ResourceObj.Pointer); +Exit1: + ACPI_MEM_FREE (ReturnObj.Pointer); + return (Status); } @@ -1184,7 +1437,7 @@ AcpiDbDisplayResources ( { #if ACPI_MACHINE_WIDTH != 16 - ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_BUFFER ReturnObj; @@ -1194,71 +1447,94 @@ AcpiDbDisplayResources ( /* Convert string to object pointer */ - ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); + Node = AcpiDbConvertToNode (ObjectArg); + if (!Node) + { + return; + } /* Prepare for a return object of arbitrary size */ - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; /* _PRT */ AcpiOsPrintf ("Evaluating _PRT\n"); - Status = AcpiEvaluateObject (ObjDesc, "_PRT", NULL, &ReturnObj); + /* Check if _PRT exists */ + + Status = AcpiEvaluateObject (Node, METHOD_NAME__PRT, NULL, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("Could not obtain _PRT: %s\n", + AcpiFormatException (Status)); goto GetCrs; } - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; - Status = AcpiGetIrqRoutingTable (ObjDesc, &ReturnObj); + Status = AcpiGetIrqRoutingTable (Node, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiFormatException (Status)); - } - else - { - AcpiRsDumpIrqList ((UINT8 *) AcpiGbl_DbBuffer); + AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", + AcpiFormatException (Status)); + goto GetCrs; } + AcpiRsDumpIrqList ((UINT8 *) AcpiGbl_DbBuffer); + /* _CRS */ GetCrs: AcpiOsPrintf ("Evaluating _CRS\n"); - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + + /* Check if _CRS exists */ - Status = AcpiEvaluateObject (ObjDesc, "_CRS", NULL, &ReturnObj); + Status = AcpiEvaluateObject (Node, METHOD_NAME__CRS, NULL, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not obtain _CRS: %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("Could not obtain _CRS: %s\n", + AcpiFormatException (Status)); goto GetPrs; } - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + /* Get the _CRS resource list */ - Status = AcpiGetCurrentResources (ObjDesc, &ReturnObj); + ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + + Status = AcpiGetCurrentResources (Node, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", + AcpiFormatException (Status)); goto GetPrs; } - else - { - AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); - } - Status = AcpiSetCurrentResources (ObjDesc, &ReturnObj); + /* Dump the _CRS resource list */ + + AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, + ReturnObj.Pointer)); + + /* + * Perform comparison of original AML to newly created AML. This tests both + * the AML->Resource conversion and the Resource->Aml conversion. + */ + Status = AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS); + + /* Execute _SRS with the resource list */ + + Status = AcpiSetCurrentResources (Node, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", + AcpiFormatException (Status)); goto GetPrs; } @@ -1268,29 +1544,32 @@ GetCrs: GetPrs: AcpiOsPrintf ("Evaluating _PRS\n"); - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + + /* Check if _PRS exists */ - Status = AcpiEvaluateObject (ObjDesc, "_PRS", NULL, &ReturnObj); + Status = AcpiEvaluateObject (Node, METHOD_NAME__PRS, NULL, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not obtain _PRS: %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("Could not obtain _PRS: %s\n", + AcpiFormatException (Status)); goto Cleanup; } - ReturnObj.Pointer = AcpiGbl_DbBuffer; - ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnObj.Pointer = AcpiGbl_DbBuffer; + ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; - Status = AcpiGetPossibleResources (ObjDesc, &ReturnObj); + Status = AcpiGetPossibleResources (Node, &ReturnObj); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", AcpiFormatException (Status)); - } - else - { - AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); + AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", + AcpiFormatException (Status)); + goto Cleanup; } + AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); + Cleanup: AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); @@ -1311,7 +1590,7 @@ Cleanup: * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbIntegrityWalk ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -1369,7 +1648,8 @@ AcpiDbIntegrityWalk ( ******************************************************************************/ void -AcpiDbCheckIntegrity (void) +AcpiDbCheckIntegrity ( + void) { ACPI_INTEGRITY_INFO Info = {0,0}; @@ -1378,7 +1658,8 @@ AcpiDbCheckIntegrity (void) (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, AcpiDbIntegrityWalk, (void *) &Info, NULL); - AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", Info.Nodes, Info.Objects); + AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", + Info.Nodes, Info.Objects); } @@ -1386,7 +1667,9 @@ AcpiDbCheckIntegrity (void) * * FUNCTION: AcpiDbGenerateGpe * - * PARAMETERS: None + * PARAMETERS: GpeArg - Raw GPE number, ascii string + * BlockArg - GPE block number, ascii string + * 0 or 1 for FADT GPE blocks * * RETURN: None * @@ -1408,7 +1691,8 @@ AcpiDbGenerateGpe ( BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0); - GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber), GpeNumber); + GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber), + GpeNumber); if (!GpeEventInfo) { AcpiOsPrintf ("Invalid GPE\n"); @@ -1418,4 +1702,129 @@ AcpiDbGenerateGpe ( (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber); } + +/******************************************************************************* + * + * FUNCTION: AcpiDbBusWalk + * + * PARAMETERS: Callback from WalkNamespace + * + * RETURN: Status + * + * DESCRIPTION: Display info about device objects that have a corresponding + * _PRT method. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDbBusWalk ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ACPI_STATUS Status; + ACPI_BUFFER Buffer; + ACPI_INTEGER ADR; + ACPI_DEVICE_ID Id; + ACPI_COMPATIBLE_ID_LIST *Cid; + ACPI_NAMESPACE_NODE *TempNode; + + + /* Exit if there is no _PRT under this device */ + + Status = AcpiGetHandle (Node, METHOD_NAME__PRT, &TempNode); + if (ACPI_FAILURE (Status)) + { + return (AE_OK); + } + + /* Get the full path to this device object */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); + return (AE_OK); + } + + /* Display the full path */ + + AcpiOsPrintf ("%-32s", (char *) Buffer.Pointer); + ACPI_MEM_FREE (Buffer.Pointer); + + /* _PRT info */ + + AcpiOsPrintf ("_PRT=%p", TempNode); + + /* Get the _ADR value */ + + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, &ADR); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf (" No _ADR "); + } + else + { + AcpiOsPrintf (" _ADR=%8.8X", (UINT32) ADR); + } + + /* Get the _HID if present */ + + Status = AcpiUtExecute_HID (Node, &Id); + if (ACPI_SUCCESS (Status)) + { + AcpiOsPrintf (" _HID=%s", Id.Value); + } + else + { + AcpiOsPrintf (" "); + } + + /* Get the _UID if present */ + + Status = AcpiUtExecute_UID (Node, &Id); + if (ACPI_SUCCESS (Status)) + { + AcpiOsPrintf (" _UID=%s", Id.Value); + } + + /* Get the _CID if present */ + + Status = AcpiUtExecute_CID (Node, &Cid); + if (ACPI_SUCCESS (Status)) + { + AcpiOsPrintf (" _CID=%s", Cid->Id[0].Value); + ACPI_MEM_FREE (Cid); + } + + AcpiOsPrintf ("\n"); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDbGetBusInfo + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Display info about system busses. + * + ******************************************************************************/ + +void +AcpiDbGetBusInfo ( + void) +{ + /* Search all nodes in namespace */ + + (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, + AcpiDbBusWalk, NULL, NULL); +} + #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbdisply.c b/sys/contrib/dev/acpica/dbdisply.c index a6fcc2a..93fe8ef 100644 --- a/sys/contrib/dev/acpica/dbdisply.c +++ b/sys/contrib/dev/acpica/dbdisply.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbdisply - debug display commands - * $Revision: 106 $ + * $Revision: 1.112 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -127,12 +127,21 @@ #ifdef ACPI_DEBUGGER - #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbdisply") +/* Local prototypes */ -/****************************************************************************** +static void +AcpiDbDumpParserDescriptor ( + ACPI_PARSE_OBJECT *Op); + +static void * +AcpiDbGetPointer ( + void *Target); + + +/******************************************************************************* * * FUNCTION: AcpiDbGetPointer * @@ -142,9 +151,9 @@ * * DESCRIPTION: Convert an ascii pointer value to a real value * - *****************************************************************************/ + ******************************************************************************/ -void * +static void * AcpiDbGetPointer ( void *Target) { @@ -185,7 +194,7 @@ AcpiDbGetPointer ( * ******************************************************************************/ -void +static void AcpiDbDumpParserDescriptor ( ACPI_PARSE_OBJECT *Op) { @@ -197,7 +206,8 @@ AcpiDbDumpParserDescriptor ( AcpiOsPrintf ("Parser Op Descriptor:\n"); AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode); - ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", Info->Name)); + ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", + Info->Name)); AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg); AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent); @@ -243,7 +253,7 @@ AcpiDbDecodeAndDisplayObject ( if (OutputType) { - ACPI_STRUPR (OutputType); + AcpiUtStrupr (OutputType); if (OutputType[0] == 'W') { Display = DB_WORD_DISPLAY; @@ -268,7 +278,8 @@ AcpiDbDecodeAndDisplayObject ( ObjPtr = AcpiDbGetPointer (Target); if (!AcpiOsReadable (ObjPtr, 16)) { - AcpiOsPrintf ("Address %p is invalid in this address space\n", ObjPtr); + AcpiOsPrintf ("Address %p is invalid in this address space\n", + ObjPtr); return; } @@ -282,12 +293,13 @@ AcpiDbDecodeAndDisplayObject ( if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE))) { - AcpiOsPrintf ("Cannot read entire Named object at address %p\n", ObjPtr); + AcpiOsPrintf ( + "Cannot read entire Named object at address %p\n", ObjPtr); return; } Node = ObjPtr; - goto DumpNte; + goto DumpNode; case ACPI_DESC_TYPE_OPERAND: @@ -296,11 +308,13 @@ AcpiDbDecodeAndDisplayObject ( if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT))) { - AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", ObjPtr); + AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", + ObjPtr); return; } - AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); + AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, + ACPI_UINT32_MAX); AcpiExDumpObjectDescriptor (ObjPtr, 1); break; @@ -311,11 +325,13 @@ AcpiDbDecodeAndDisplayObject ( if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT))) { - AcpiOsPrintf ("Cannot read entire Parser object at address %p\n", ObjPtr); + AcpiOsPrintf ( + "Cannot read entire Parser object at address %p\n", ObjPtr); return; } - AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, ACPI_UINT32_MAX); + AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, + ACPI_UINT32_MAX); AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr); break; @@ -348,8 +364,8 @@ AcpiDbDecodeAndDisplayObject ( } -DumpNte: - /* Now dump the Named obj */ +DumpNode: + /* Now dump the NS node */ Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf); if (ACPI_FAILURE (Status)) @@ -359,7 +375,8 @@ DumpNte: else { - AcpiOsPrintf ("Object (%p) Pathname: %s\n", Node, (char *) RetBuf.Pointer); + AcpiOsPrintf ("Object (%p) Pathname: %s\n", + Node, (char *) RetBuf.Pointer); } if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) @@ -368,7 +385,8 @@ DumpNte: return; } - AcpiUtDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), Display, ACPI_UINT32_MAX); + AcpiUtDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), + Display, ACPI_UINT32_MAX); AcpiExDumpNode (Node, 1); ObjDesc = AcpiNsGetAttachedObject (Node); @@ -377,11 +395,13 @@ DumpNte: AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc); if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT))) { - AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", ObjDesc); + AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", + ObjDesc); return; } - AcpiUtDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); + AcpiUtDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT), + Display, ACPI_UINT32_MAX); AcpiExDumpObjectDescriptor (ObjDesc, 1); } } @@ -492,11 +512,13 @@ AcpiDbDisplayMethodInfo ( Op = AcpiPsGetDepthNext (StartOp, Op); } - AcpiOsPrintf ("Method contains: %X AML Opcodes - %X Operators, %X Operands\n", - NumOps, NumOperators, NumOperands); + AcpiOsPrintf ( + "Method contains: %X AML Opcodes - %X Operators, %X Operands\n", + NumOps, NumOperators, NumOperands); - AcpiOsPrintf ("Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n", - NumRemainingOps, NumRemainingOperators, NumRemainingOperands); + AcpiOsPrintf ( + "Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n", + NumRemainingOps, NumRemainingOperators, NumRemainingOperands); } @@ -513,7 +535,8 @@ AcpiDbDisplayMethodInfo ( ******************************************************************************/ void -AcpiDbDisplayLocals (void) +AcpiDbDisplayLocals ( + void) { ACPI_WALK_STATE *WalkState; @@ -542,7 +565,8 @@ AcpiDbDisplayLocals (void) ******************************************************************************/ void -AcpiDbDisplayArguments (void) +AcpiDbDisplayArguments ( + void) { ACPI_WALK_STATE *WalkState; @@ -571,7 +595,8 @@ AcpiDbDisplayArguments (void) ******************************************************************************/ void -AcpiDbDisplayResults (void) +AcpiDbDisplayResults ( + void) { UINT32 i; ACPI_WALK_STATE *WalkState; @@ -620,7 +645,8 @@ AcpiDbDisplayResults (void) ******************************************************************************/ void -AcpiDbDisplayCallingTree (void) +AcpiDbDisplayCallingTree ( + void) { ACPI_WALK_STATE *WalkState; ACPI_NAMESPACE_NODE *Node; @@ -677,18 +703,20 @@ AcpiDbDisplayObjectType ( if (ACPI_SUCCESS (Status)) { Info = Buffer.Pointer; - AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X HID: %s, ADR: %8.8X%8.8X, Status %8.8X\n", - Info->HighestDstates[0], Info->HighestDstates[1], - Info->HighestDstates[2], Info->HighestDstates[3], - Info->HardwareId.Value, - ACPI_FORMAT_UINT64 (Info->Address), - Info->CurrentStatus); + AcpiOsPrintf ( + "S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X HID: %s, ADR: %8.8X%8.8X, Status %8.8X\n", + Info->HighestDstates[0], Info->HighestDstates[1], + Info->HighestDstates[2], Info->HighestDstates[3], + Info->HardwareId.Value, + ACPI_FORMAT_UINT64 (Info->Address), + Info->CurrentStatus); if (Info->Valid & ACPI_VALID_CID) { for (i = 0; i < Info->CompatibilityId.Count; i++) { - AcpiOsPrintf ("CID #%d: %s\n", (UINT32) i, Info->CompatibilityId.Id[i].Value); + AcpiOsPrintf ("CID #%d: %s\n", (UINT32) i, + Info->CompatibilityId.Id[i].Value); } } @@ -779,7 +807,8 @@ AcpiDbDisplayArgumentObject ( ******************************************************************************/ void -AcpiDbDisplayGpes (void) +AcpiDbDisplayGpes ( + void) { ACPI_GPE_BLOCK_INFO *GpeBlock; ACPI_GPE_XRUPT_INFO *GpeXruptInfo; @@ -814,18 +843,23 @@ AcpiDbDisplayGpes (void) } AcpiOsPrintf ("\nBlock %d - Info %p DeviceNode %p [%s]\n", - Block, GpeBlock, GpeBlock->Node, Buffer); - AcpiOsPrintf (" Registers: %u (%u GPEs) \n", - GpeBlock->RegisterCount, - ACPI_MUL_8 (GpeBlock->RegisterCount)); + Block, GpeBlock, GpeBlock->Node, Buffer); + + AcpiOsPrintf (" Registers: %u (%u GPEs)\n", + GpeBlock->RegisterCount, + ACPI_MUL_8 (GpeBlock->RegisterCount)); + AcpiOsPrintf (" GPE range: 0x%X to 0x%X\n", - GpeBlock->BlockBaseNumber, - GpeBlock->BlockBaseNumber + - (GpeBlock->RegisterCount * 8) -1); - AcpiOsPrintf (" RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", - GpeBlock->RegisterInfo, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->RegisterInfo->StatusAddress.Address)), - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->RegisterInfo->EnableAddress.Address))); + GpeBlock->BlockBaseNumber, + GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8) -1); + + AcpiOsPrintf ( + " RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", + GpeBlock->RegisterInfo, + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->RegisterInfo->StatusAddress.Address)), + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeBlock->RegisterInfo->EnableAddress.Address))); + AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo); /* Examine each GPE Register within the block */ @@ -835,11 +869,11 @@ AcpiDbDisplayGpes (void) GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; AcpiOsPrintf ( - " Reg %u: WakeEnable %2.2X, RunEnable %2.2X Status %8.8X%8.8X Enable %8.8X%8.8X\n", - i, GpeRegisterInfo->EnableForWake, - GpeRegisterInfo->EnableForRun, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->StatusAddress.Address)), - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->EnableAddress.Address))); + " Reg %u: WakeEnable %2.2X, RunEnable %2.2X Status %8.8X%8.8X Enable %8.8X%8.8X\n", + i, GpeRegisterInfo->EnableForWake, + GpeRegisterInfo->EnableForRun, + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->StatusAddress.Address)), + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (GpeRegisterInfo->EnableAddress.Address))); /* Now look at the individual GPEs in this byte register */ @@ -856,10 +890,10 @@ AcpiDbDisplayGpes (void) } AcpiOsPrintf ( - " GPE %.3X: %p Bit %2.2X Flags %2.2X: ", - GpeBlock->BlockBaseNumber + GpeIndex, - GpeEventInfo, GpeEventInfo->RegisterBit, - GpeEventInfo->Flags); + " GPE %.3X: %p Bit %2.2X Flags %2.2X: ", + GpeBlock->BlockBaseNumber + GpeIndex, + GpeEventInfo, GpeEventInfo->RegisterBit, + GpeEventInfo->Flags); if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED) { @@ -931,6 +965,5 @@ AcpiDbDisplayGpes (void) } } - #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbexec.c b/sys/contrib/dev/acpica/dbexec.c index 463ac4a..12c03bc 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: 62 $ + * $Revision: 1.70 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -127,6 +127,38 @@ static ACPI_DB_METHOD_INFO AcpiGbl_DbMethodInfo; +/* Local prototypes */ + +static ACPI_STATUS +AcpiDbExecuteMethod ( + ACPI_DB_METHOD_INFO *Info, + ACPI_BUFFER *ReturnObj); + +static void +AcpiDbExecuteSetup ( + ACPI_DB_METHOD_INFO *Info); + +static UINT32 +AcpiDbGetOutstandingAllocations ( + void); + +static void ACPI_SYSTEM_XFACE +AcpiDbMethodThread ( + void *Context); + +static ACPI_STATUS +AcpiDbExecutionWalk ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +static UINT32 +AcpiDbGetCacheInfo ( + ACPI_MEMORY_LIST *Cache); +#endif + /******************************************************************************* * @@ -141,7 +173,7 @@ static ACPI_DB_METHOD_INFO AcpiGbl_DbMethodInfo; * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbExecuteMethod ( ACPI_DB_METHOD_INFO *Info, ACPI_BUFFER *ReturnObj) @@ -163,37 +195,38 @@ AcpiDbExecuteMethod ( { for (i = 0; Info->Args[i] && i < ACPI_METHOD_NUM_ARGS; i++) { - Params[i].Type = ACPI_TYPE_INTEGER; - Params[i].Integer.Value = ACPI_STRTOUL (Info->Args[i], NULL, 16); + Params[i].Type = ACPI_TYPE_INTEGER; + Params[i].Integer.Value = ACPI_STRTOUL (Info->Args[i], NULL, 16); } - ParamObjects.Pointer = Params; - ParamObjects.Count = i; + ParamObjects.Pointer = Params; + ParamObjects.Count = i; } else { /* Setup default parameters */ - Params[0].Type = ACPI_TYPE_INTEGER; - Params[0].Integer.Value = 0x01020304; + Params[0].Type = ACPI_TYPE_INTEGER; + Params[0].Integer.Value = 0x01020304; - Params[1].Type = ACPI_TYPE_STRING; - Params[1].String.Length = 12; - Params[1].String.Pointer = "AML Debugger"; + Params[1].Type = ACPI_TYPE_STRING; + Params[1].String.Length = 12; + Params[1].String.Pointer = "AML Debugger"; - ParamObjects.Pointer = Params; - ParamObjects.Count = 2; + ParamObjects.Pointer = Params; + ParamObjects.Count = 2; } /* Prepare for a return object of arbitrary size */ - ReturnObj->Pointer = AcpiGbl_DbBuffer; - ReturnObj->Length = ACPI_DEBUG_BUFFER_SIZE; + ReturnObj->Pointer = AcpiGbl_DbBuffer; + ReturnObj->Length = ACPI_DEBUG_BUFFER_SIZE; /* Do the actual method execution */ AcpiGbl_MethodExecuting = TRUE; - Status = AcpiEvaluateObject (NULL, Info->Pathname, &ParamObjects, ReturnObj); + Status = AcpiEvaluateObject (NULL, + Info->Pathname, &ParamObjects, ReturnObj); AcpiGbl_CmSingleStep = FALSE; AcpiGbl_MethodExecuting = FALSE; @@ -208,13 +241,13 @@ AcpiDbExecuteMethod ( * * PARAMETERS: Info - Valid method info * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Setup info segment prior to method execution * ******************************************************************************/ -void +static void AcpiDbExecuteSetup ( ACPI_DB_METHOD_INFO *Info) { @@ -249,6 +282,16 @@ AcpiDbExecuteSetup ( } +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +static UINT32 +AcpiDbGetCacheInfo ( + ACPI_MEMORY_LIST *Cache) +{ + + return (Cache->TotalAllocated - Cache->TotalFreed - Cache->CurrentDepth); +} +#endif + /******************************************************************************* * * FUNCTION: AcpiDbGetOutstandingAllocations @@ -263,22 +306,18 @@ AcpiDbExecuteSetup ( * ******************************************************************************/ -UINT32 +static UINT32 AcpiDbGetOutstandingAllocations ( void) { UINT32 Outstanding = 0; #ifdef ACPI_DBG_TRACK_ALLOCATIONS - UINT32 i; - - for (i = ACPI_MEM_LIST_FIRST_CACHE_LIST; i < ACPI_NUM_MEM_LISTS; i++) - { - Outstanding += (AcpiGbl_MemoryLists[i].TotalAllocated - - AcpiGbl_MemoryLists[i].TotalFreed - - AcpiGbl_MemoryLists[i].CacheDepth); - } + Outstanding += AcpiDbGetCacheInfo (AcpiGbl_StateCache); + Outstanding += AcpiDbGetCacheInfo (AcpiGbl_PsNodeCache); + Outstanding += AcpiDbGetCacheInfo (AcpiGbl_PsNodeExtCache); + Outstanding += AcpiDbGetCacheInfo (AcpiGbl_OperandCache); #endif return (Outstanding); @@ -298,7 +337,7 @@ AcpiDbGetOutstandingAllocations ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbExecutionWalk ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -345,7 +384,7 @@ AcpiDbExecutionWalk ( * Args - Parameters to the method * Flags - single step/no single step * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Execute a control method. Name is relative to the current * scope. @@ -374,12 +413,13 @@ AcpiDbExecute ( if (*Name == '*') { - (void) AcpiWalkNamespace (ACPI_TYPE_METHOD, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - AcpiDbExecutionWalk, NULL, NULL); + (void) AcpiWalkNamespace (ACPI_TYPE_METHOD, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL); return; } else { + AcpiUtStrupr (Name); AcpiGbl_DbMethodInfo.Name = Name; AcpiGbl_DbMethodInfo.Args = Args; AcpiGbl_DbMethodInfo.Flags = Flags; @@ -395,7 +435,7 @@ AcpiDbExecute ( * Allow any handlers in separate threads to complete. * (Such as Notify handlers invoked from AML executed above). */ - AcpiOsSleep (10); + AcpiOsSleep ((ACPI_INTEGER) 10); #ifdef ACPI_DEBUG_OUTPUT @@ -418,7 +458,6 @@ AcpiDbExecute ( AcpiOsPrintf ("Execution of %s failed with status %s\n", AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status)); } - else { /* Display a return object, if any */ @@ -428,7 +467,7 @@ AcpiDbExecute ( AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", AcpiGbl_DbMethodInfo.Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length); - AcpiDbDumpObject (ReturnObj.Pointer, 1); + AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); } else { @@ -454,7 +493,7 @@ AcpiDbExecute ( * ******************************************************************************/ -void ACPI_SYSTEM_XFACE +static void ACPI_SYSTEM_XFACE AcpiDbMethodThread ( void *Context) { @@ -494,7 +533,7 @@ AcpiDbMethodThread ( { AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", Info->Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length); - AcpiDbDumpObject (ReturnObj.Pointer, 1); + AcpiDbDumpExternalObject (ReturnObj.Pointer, 1); } #endif } @@ -543,7 +582,8 @@ AcpiDbCreateExecutionThreads ( if (!NumThreads || !NumLoops) { - AcpiOsPrintf ("Bad argument: Threads %X, Loops %X\n", NumThreads, NumLoops); + AcpiOsPrintf ("Bad argument: Threads %X, Loops %X\n", + NumThreads, NumLoops); return; } @@ -552,7 +592,8 @@ AcpiDbCreateExecutionThreads ( Status = AcpiOsCreateSemaphore (1, 0, &ThreadGate); if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Could not create semaphore, %s\n", AcpiFormatException (Status)); + AcpiOsPrintf ("Could not create semaphore, %s\n", + AcpiFormatException (Status)); return; } @@ -568,11 +609,13 @@ AcpiDbCreateExecutionThreads ( /* Create the threads */ - AcpiOsPrintf ("Creating %X threads to execute %X times each\n", NumThreads, NumLoops); + AcpiOsPrintf ("Creating %X threads to execute %X times each\n", + NumThreads, NumLoops); for (i = 0; i < (NumThreads); i++) { - Status = AcpiOsQueueForExecution (OSD_PRIORITY_MED, AcpiDbMethodThread, &AcpiGbl_DbMethodInfo); + Status = AcpiOsQueueForExecution (OSD_PRIORITY_MED, AcpiDbMethodThread, + &AcpiGbl_DbMethodInfo); if (ACPI_FAILURE (Status)) { break; @@ -582,7 +625,7 @@ AcpiDbCreateExecutionThreads ( /* Wait for all threads to complete */ i = NumThreads; - while (i) /* Brain damage for OSD implementations that only support wait of 1 unit */ + while (i) /* Brain damage for host OSs that only support wait of 1 unit */ { Status = AcpiOsWaitSemaphore (ThreadGate, 1, ACPI_WAIT_FOREVER); i--; @@ -597,7 +640,6 @@ AcpiDbCreateExecutionThreads ( AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); } - #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbfileio.c b/sys/contrib/dev/acpica/dbfileio.c index 3183760..f692a02 100644 --- a/sys/contrib/dev/acpica/dbfileio.c +++ b/sys/contrib/dev/acpica/dbfileio.c @@ -2,7 +2,7 @@ * * Module Name: dbfileio - Debugger file I/O commands. These can't usually * be used when running the debugger in Ring 0 (Kernel mode) - * $Revision: 76 $ + * $Revision: 1.84 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -126,7 +126,6 @@ #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbfileio") - /* * NOTE: this is here for lack of a better place. It is used in all * flavors of the debugger, need LCD file @@ -138,13 +137,27 @@ FILE *AcpiGbl_DebugFile = NULL; #ifdef ACPI_DEBUGGER + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDbCheckTextModeCorruption ( + UINT8 *Table, + UINT32 TableLength, + UINT32 FileLength); + +static ACPI_STATUS +AeLocalLoadTable ( + ACPI_TABLE_HEADER *TablePtr); + + /******************************************************************************* * * FUNCTION: AcpiDbCloseDebugFile * * PARAMETERS: None * - * RETURN: Status + * RETURN: None * * DESCRIPTION: If open, close the current debug output file * @@ -174,7 +187,7 @@ AcpiDbCloseDebugFile ( * * PARAMETERS: Name - Filename to open * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Open a file where debug output will be directed. * @@ -206,7 +219,6 @@ AcpiDbOpenDebugFile ( #ifdef ACPI_APPLICATION - /******************************************************************************* * * FUNCTION: AcpiDbCheckTextModeCorruption @@ -235,8 +247,9 @@ AcpiDbCheckTextModeCorruption ( if (TableLength != FileLength) { - ACPI_REPORT_WARNING (("File length (0x%X) is not the same as the table length (0x%X)\n", - FileLength, TableLength)); + ACPI_REPORT_WARNING (( + "File length (0x%X) is not the same as the table length (0x%X)\n", + FileLength, TableLength)); } /* Scan entire table to determine if each LF has been prefixed with a CR */ @@ -247,7 +260,7 @@ AcpiDbCheckTextModeCorruption ( { if (Table[i - 1] != 0x0D) { - /* the LF does not have a preceeding CR, table is not corrupted */ + /* The LF does not have a preceeding CR, table not corrupted */ return (AE_OK); } @@ -303,25 +316,35 @@ AcpiDbReadTable ( fseek (fp, 0, SEEK_END); - FileSize = ftell (fp); + FileSize = (UINT32) ftell (fp); fseek (fp, 0, SEEK_SET); /* Read the table header */ - if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != sizeof (ACPI_TABLE_HEADER)) + if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != + sizeof (ACPI_TABLE_HEADER)) { - AcpiOsPrintf ("Couldn't read the table header\n"); - return (AE_BAD_SIGNATURE); + AcpiOsPrintf ("Could not read the table header\n"); + return (AE_BAD_HEADER); } /* Validate the table header/length */ Status = AcpiTbValidateTableHeader (&TableHeader); - if ((ACPI_FAILURE (Status)) || - (TableHeader.Length > 0x800000)) /* 8 Mbyte should be enough */ + if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Table header is invalid!\n"); - return (AE_ERROR); + return (Status); + } + + /* File size must be at least as long as the Header-specified length */ + + if (TableHeader.Length > FileSize) + { + AcpiOsPrintf ( + "TableHeader length [0x%X] greater than the input file size [0x%X]\n", + TableHeader.Length, FileSize); + return (AE_BAD_HEADER); } /* We only support a limited number of table types */ @@ -330,7 +353,8 @@ AcpiDbReadTable ( ACPI_STRNCMP ((char *) TableHeader.Signature, PSDT_SIG, 4) && ACPI_STRNCMP ((char *) TableHeader.Signature, SSDT_SIG, 4)) { - AcpiOsPrintf ("Table signature is invalid\n"); + AcpiOsPrintf ("Table signature [%4.4s] is invalid or not supported\n", + (char *) TableHeader.Signature); ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER)); return (AE_ERROR); } @@ -341,8 +365,9 @@ AcpiDbReadTable ( *Table = AcpiOsAllocate ((size_t) (FileSize)); if (!*Table) { - AcpiOsPrintf ("Could not allocate memory for ACPI table %4.4s (size=%X)\n", - TableHeader.Signature, TableHeader.Length); + AcpiOsPrintf ( + "Could not allocate memory for ACPI table %4.4s (size=0x%X)\n", + TableHeader.Signature, TableHeader.Length); return (AE_NO_MEMORY); } @@ -379,7 +404,6 @@ AcpiDbReadTable ( return (AE_ERROR); } -#endif /******************************************************************************* @@ -398,7 +422,7 @@ AcpiDbReadTable ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AeLocalLoadTable ( ACPI_TABLE_HEADER *Table) { @@ -426,6 +450,13 @@ AeLocalLoadTable ( Status = AcpiTbInstallTable (&TableInfo); if (ACPI_FAILURE (Status)) { + if (Status == AE_ALREADY_EXISTS) + { + /* Table already exists, no error */ + + Status = AE_OK; + } + /* Free table allocated by AcpiTbGetTable */ AcpiTbDeleteSingleTable (&TableInfo); @@ -448,7 +479,6 @@ AeLocalLoadTable ( } -#ifdef ACPI_APPLICATION /******************************************************************************* * * FUNCTION: AcpiDbReadTableFromFile @@ -489,7 +519,7 @@ AcpiDbReadTableFromFile ( if (ACPI_FAILURE (Status)) { - AcpiOsPrintf ("Couldn't get table from the file\n"); + AcpiOsPrintf ("Could not get table from the file\n"); return (Status); } @@ -502,8 +532,8 @@ AcpiDbReadTableFromFile ( * * FUNCTION: AcpiDbGetTableFromFile * - * PARAMETERS: Filename - File where table is located - * Table - Where a pointer to the table is returned + * PARAMETERS: Filename - File where table is located + * ReturnTable - Where a pointer to the table is returned * * RETURN: Status * diff --git a/sys/contrib/dev/acpica/dbhistry.c b/sys/contrib/dev/acpica/dbhistry.c index 68b26b3..161d389 100644 --- a/sys/contrib/dev/acpica/dbhistry.c +++ b/sys/contrib/dev/acpica/dbhistry.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dbhistry - debugger HISTORY command - * $Revision: 29 $ + * $Revision: 1.32 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -163,7 +163,8 @@ AcpiDbAddToHistory ( /* Put command into the next available slot */ - ACPI_STRCPY (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command, CommandLine); + ACPI_STRCPY (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command, + CommandLine); AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].CmdNum = AcpiGbl_NextCmdNum; @@ -206,7 +207,8 @@ AcpiDbAddToHistory ( ******************************************************************************/ void -AcpiDbDisplayHistory (void) +AcpiDbDisplayHistory ( + void) { ACPI_NATIVE_UINT i; UINT16 HistoryIndex; @@ -237,7 +239,7 @@ AcpiDbDisplayHistory (void) * PARAMETERS: CommandNumArg - String containing the number of the * command to be retrieved * - * RETURN: None + * RETURN: Pointer to the retrieved command. Null on error. * * DESCRIPTION: Get a command from the history buffer * @@ -286,6 +288,5 @@ AcpiDbGetFromHistory ( return (NULL); } - #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbinput.c b/sys/contrib/dev/acpica/dbinput.c index 7f3a968..4b27946 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: 101 $ + * $Revision: 1.111 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,6 +124,29 @@ #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbinput") +/* Local prototypes */ + +static char * +AcpiDbGetNextToken ( + char *String, + char **Next); + +static UINT32 +AcpiDbGetLine ( + char *InputBuffer); + +static UINT32 +AcpiDbMatchCommand ( + char *UserCommand); + +static void +AcpiDbSingleThread ( + void); + +static void +AcpiDbDisplayHelp ( + char *HelpType); + /* * Top-level debugger commands. @@ -138,6 +161,7 @@ enum AcpiExDebuggerCommands CMD_ARGS, CMD_ARGUMENTS, CMD_BREAKPOINT, + CMD_BUSINFO, CMD_CALL, CMD_CLOSE, CMD_DEBUG, @@ -182,6 +206,7 @@ enum AcpiExDebuggerCommands CMD_TABLES, CMD_TERMINATE, CMD_THREADS, + CMD_TRACE, CMD_TREE, CMD_TYPE, CMD_UNLOAD @@ -189,7 +214,6 @@ enum AcpiExDebuggerCommands #define CMD_FIRST_VALID 2 - static const COMMAND_INFO AcpiGbl_DbCommands[] = { {"<NOT FOUND>", 0}, @@ -198,6 +222,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = {"ARGS", 0}, {"ARGUMENTS", 0}, {"BREAKPOINT", 1}, + {"BUSINFO", 0}, {"CALL", 0}, {"CLOSE", 0}, {"DEBUG", 1}, @@ -242,6 +267,7 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = {"TABLES", 0}, {"TERMINATE", 0}, {"THREADS", 3}, + {"TRACE", 1}, {"TREE", 0}, {"TYPE", 1}, {"UNLOAD", 1}, @@ -261,11 +287,12 @@ static const COMMAND_INFO AcpiGbl_DbCommands[] = * ******************************************************************************/ -void +static void AcpiDbDisplayHelp ( char *HelpType) { + AcpiUtStrupr (HelpType); /* No parameter, just give the overview */ @@ -321,20 +348,22 @@ AcpiDbDisplayHelp ( case 'N': AcpiOsPrintf ("\nNamespace Access Commands\n\n"); + AcpiOsPrintf ("Businfo Display system bus info\n"); AcpiOsPrintf ("Disassemble <Method> Disassemble a control method\n"); AcpiOsPrintf ("Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n"); - AcpiOsPrintf ("Find <Name> (? is wildcard) Find ACPI name(s) with wildcards\n"); + AcpiOsPrintf ("Find <AcpiName> (? is wildcard) Find ACPI name(s) with wildcards\n"); AcpiOsPrintf ("Gpe <GpeNum> <GpeBlock> Simulate a GPE\n"); AcpiOsPrintf ("Gpes Display info on all GPEs\n"); AcpiOsPrintf ("Integrity Validate namespace integrity\n"); - AcpiOsPrintf ("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"); + AcpiOsPrintf ("Methods Display list of loaded control methods\n"); + AcpiOsPrintf ("Namespace [Object] [Depth] Display loaded namespace tree/subtree\n"); + AcpiOsPrintf ("Notify <Object> <Value> Send a notification on Object\n"); AcpiOsPrintf ("Objects <ObjectType> Display all objects of the given type\n"); AcpiOsPrintf ("Owner <OwnerId> [Depth] Display loaded namespace by object owner\n"); AcpiOsPrintf ("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 ("Resources <Device> Get and display Device resources\n"); + AcpiOsPrintf ("Set N <NamedObject> <Value> Set value for named integer\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"); @@ -356,6 +385,7 @@ AcpiDbDisplayHelp ( AcpiOsPrintf ("Results Display method result stack\n"); AcpiOsPrintf ("Set <A|L> <#> <Value> Set method data (Arguments/Locals)\n"); AcpiOsPrintf ("Stop Terminate control method\n"); + AcpiOsPrintf ("Trace <method name> Trace method execution\n"); AcpiOsPrintf ("Tree Display control method calling tree\n"); AcpiOsPrintf ("<Enter> Single step next AML opcode (over calls)\n"); return; @@ -387,7 +417,7 @@ AcpiDbDisplayHelp ( * ******************************************************************************/ -char * +static char * AcpiDbGetNextToken ( char *String, char **Next) @@ -446,14 +476,14 @@ AcpiDbGetNextToken ( * * PARAMETERS: InputBuffer - Command line buffer * - * RETURN: None + * RETURN: Count of arguments to the command * * DESCRIPTION: Get the next command line from the user. Gets entire line * up to the next newline * ******************************************************************************/ -UINT32 +static UINT32 AcpiDbGetLine ( char *InputBuffer) { @@ -464,7 +494,6 @@ AcpiDbGetLine ( ACPI_STRCPY (AcpiGbl_DbParsedBuf, InputBuffer); - ACPI_STRUPR (AcpiGbl_DbParsedBuf); This = AcpiGbl_DbParsedBuf; for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++) @@ -482,7 +511,7 @@ AcpiDbGetLine ( if (AcpiGbl_DbArgs[0]) { - ACPI_STRUPR (AcpiGbl_DbArgs[0]); + AcpiUtStrupr (AcpiGbl_DbArgs[0]); } Count = i; @@ -507,7 +536,7 @@ AcpiDbGetLine ( * ******************************************************************************/ -UINT32 +static UINT32 AcpiDbMatchCommand ( char *UserCommand) { @@ -544,7 +573,7 @@ AcpiDbMatchCommand ( * * RETURN: Status * - * DESCRIPTION: Command dispatcher. Called from two places: + * DESCRIPTION: Command dispatcher. * ******************************************************************************/ @@ -577,7 +606,9 @@ AcpiDbCommandDispatch ( if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs) { AcpiOsPrintf ("%d parameters entered, [%s] requires %d parameters\n", - ParamCount, AcpiGbl_DbCommands[CommandIndex].Name, AcpiGbl_DbCommands[CommandIndex].MinArgs); + ParamCount, AcpiGbl_DbCommands[CommandIndex].Name, + AcpiGbl_DbCommands[CommandIndex].MinArgs); + return (AE_CTRL_TRUE); } @@ -608,6 +639,10 @@ AcpiDbCommandDispatch ( AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op); break; + case CMD_BUSINFO: + AcpiDbGetBusInfo (); + break; + case CMD_CALL: AcpiDbSetMethodCallBreakpoint (Op); Status = AE_OK; @@ -622,7 +657,7 @@ AcpiDbCommandDispatch ( break; case CMD_DISASSEMBLE: - AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]); + (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]); break; case CMD_DUMP: @@ -643,7 +678,8 @@ AcpiDbCommandDispatch ( break; case CMD_EXECUTE: - AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_NO_SINGLE_STEP); + AcpiDbExecute (AcpiGbl_DbArgs[1], + &AcpiGbl_DbArgs[2], EX_NO_SINGLE_STEP); break; case CMD_FIND: @@ -679,10 +715,6 @@ AcpiDbCommandDispatch ( } Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); - if (ACPI_SUCCESS (Status)) - { - Status = AE_CTRL_TRUE; - } return (Status); case CMD_HISTORY_LAST: @@ -693,10 +725,6 @@ AcpiDbCommandDispatch ( } Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op); - if (ACPI_SUCCESS (Status)) - { - Status = AE_CTRL_TRUE; - } return (Status); case CMD_INFORMATION: @@ -718,20 +746,27 @@ AcpiDbCommandDispatch ( case CMD_LEVEL: if (ParamCount == 0) { - AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n", AcpiGbl_DbDebugLevel); - AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n", AcpiGbl_DbConsoleDebugLevel); + AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n", + AcpiGbl_DbDebugLevel); + AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n", + AcpiGbl_DbConsoleDebugLevel); } else if (ParamCount == 2) { Temp = AcpiGbl_DbConsoleDebugLevel; - AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16); - AcpiOsPrintf ("Debug Level for console output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbConsoleDebugLevel); + AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], + NULL, 16); + AcpiOsPrintf ( + "Debug Level for console output was %8.8lX, now %8.8lX\n", + Temp, AcpiGbl_DbConsoleDebugLevel); } else { Temp = AcpiGbl_DbDebugLevel; AcpiGbl_DbDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16); - AcpiOsPrintf ("Debug Level for file output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbDebugLevel); + AcpiOsPrintf ( + "Debug Level for file output was %8.8lX, now %8.8lX\n", + Temp, AcpiGbl_DbDebugLevel); } break; @@ -741,10 +776,6 @@ AcpiDbCommandDispatch ( case CMD_LOAD: Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL); - if (ACPI_FAILURE (Status)) - { - return (Status); - } break; case CMD_LOCKS: @@ -769,7 +800,7 @@ AcpiDbCommandDispatch ( break; case CMD_OBJECT: - ACPI_STRUPR (AcpiGbl_DbArgs[1]); + AcpiUtStrupr (AcpiGbl_DbArgs[1]); Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]); break; @@ -798,7 +829,8 @@ AcpiDbCommandDispatch ( break; case CMD_SET: - AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]); + AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], + AcpiGbl_DbArgs[3]); break; case CMD_SLEEP: @@ -820,13 +852,21 @@ AcpiDbCommandDispatch ( AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); AcpiUtSubsystemShutdown (); - /* TBD: [Restructure] Need some way to re-initialize without re-creating the semaphores! */ + /* + * TBD: [Restructure] Need some way to re-initialize without + * re-creating the semaphores! + */ /* AcpiInitialize (NULL); */ break; case CMD_THREADS: - AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]); + AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], + AcpiGbl_DbArgs[3]); + break; + + case CMD_TRACE: + AcpiDebugTrace (AcpiGbl_DbArgs[1],0,0,1); break; case CMD_TREE: @@ -854,13 +894,8 @@ AcpiDbCommandDispatch ( AcpiDbgLevel = ACPI_DEBUG_DEFAULT; } - /* Shutdown */ - - /* AcpiUtSubsystemShutdown (); */ AcpiDbCloseDebugFile (); - AcpiGbl_DbTerminateThreads = TRUE; - return (AE_CTRL_TERMINATE); case CMD_NOT_FOUND: @@ -869,6 +904,10 @@ AcpiDbCommandDispatch ( return (AE_CTRL_TRUE); } + if (ACPI_SUCCESS (Status)) + { + Status = AE_CTRL_TRUE; + } /* Add all commands that come here to the history buffer */ @@ -933,7 +972,7 @@ AcpiDbExecuteThread ( * ******************************************************************************/ -void +static void AcpiDbSingleThread ( void) { @@ -1019,13 +1058,12 @@ AcpiDbUserCommands ( } /* - * Only this thread (the original thread) should actually terminate the subsystem, - * because all the semaphores are deleted during termination + * Only this thread (the original thread) should actually terminate the + * subsystem, because all the semaphores are deleted during termination */ Status = AcpiTerminate (); return (Status); } - #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbstats.c b/sys/contrib/dev/acpica/dbstats.c index e1c010f..a4c47e4 100644 --- a/sys/contrib/dev/acpica/dbstats.c +++ b/sys/contrib/dev/acpica/dbstats.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbstats - Generation and display of ACPI table statistics - * $Revision: 70 $ + * $Revision: 1.79 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,6 +124,28 @@ #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbstats") +/* Local prototypes */ + +static void +AcpiDbCountNamespaceObjects ( + void); + +static void +AcpiDbEnumerateObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +static ACPI_STATUS +AcpiDbClassifyOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static void +AcpiDbListInfo ( + ACPI_MEMORY_LIST *List); + + /* * Statistics subcommands */ @@ -150,6 +172,74 @@ static ARGUMENT_INFO AcpiDbStatTypes [] = /******************************************************************************* * + * FUNCTION: AcpiDbListInfo + * + * PARAMETERS: List - Memory list/cache to be displayed + * + * RETURN: None + * + * DESCRIPTION: Display information about the input memory list or cache. + * + ******************************************************************************/ + +static void +AcpiDbListInfo ( + ACPI_MEMORY_LIST *List) +{ +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + UINT32 Outstanding; + UINT32 Temp; +#endif + + AcpiOsPrintf ("\n%s\n", List->ListName); + + /* MaxDepth > 0 indicates a cache object */ + + if (List->MaxDepth > 0) + { + AcpiOsPrintf ( + " Cache: [Depth Max Avail Size] % 7d % 7d % 7d % 7d B\n", + List->CurrentDepth, + List->MaxDepth, + List->MaxDepth - List->CurrentDepth, + (List->CurrentDepth * List->ObjectSize)); + } + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + if (List->MaxDepth > 0) + { + AcpiOsPrintf ( + " Cache: [Requests Hits Misses ObjSize] % 7d % 7d % 7d % 7d B\n", + List->Requests, + List->Hits, + List->Requests - List->Hits, + List->ObjectSize); + } + + Outstanding = List->TotalAllocated - + List->TotalFreed - + List->CurrentDepth; + + if (List->ObjectSize) + { + Temp = ACPI_ROUND_UP_TO_1K (Outstanding * List->ObjectSize); + } + else + { + Temp = ACPI_ROUND_UP_TO_1K (List->CurrentTotalSize); + } + + AcpiOsPrintf ( + " Mem: [Alloc Free Outstanding Size] % 7d % 7d % 7d % 7d Kb\n", + List->TotalAllocated, + List->TotalFreed, + Outstanding, Temp); +#endif +} + + +/******************************************************************************* + * * FUNCTION: AcpiDbEnumerateObject * * PARAMETERS: ObjDesc - Object to be counted @@ -162,7 +252,7 @@ static ARGUMENT_INFO AcpiDbStatTypes [] = * ******************************************************************************/ -void +static void AcpiDbEnumerateObject ( ACPI_OPERAND_OBJECT *ObjDesc) { @@ -174,7 +264,6 @@ AcpiDbEnumerateObject ( return; } - /* Enumerate this object first */ AcpiGbl_NumObjects++; @@ -260,7 +349,7 @@ AcpiDbEnumerateObject ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbClassifyOneObject ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -284,7 +373,6 @@ AcpiDbClassifyOneObject ( { AcpiGbl_NodeTypeCountMisc++; } - else { AcpiGbl_NodeTypeCount [Type]++; @@ -293,8 +381,10 @@ AcpiDbClassifyOneObject ( return AE_OK; +#ifdef ACPI_FUTURE_IMPLEMENTATION + /* TBD: These need to be counted during the initial parsing phase */ - /* + if (AcpiPsIsNamedOp (Op->Opcode)) { NumNodes++; @@ -308,12 +398,12 @@ AcpiDbClassifyOneObject ( NumGrammarElements++; Op = AcpiPsGetDepthNext (Root, Op); - SizeOfParseTree = (NumGrammarElements - NumMethodElements) * (UINT32) sizeof (ACPI_PARSE_OBJECT); - SizeOfMethodTrees = NumMethodElements * (UINT32) sizeof (ACPI_PARSE_OBJECT); - SizeOfNodeEntries = NumNodes * (UINT32) sizeof (ACPI_NAMESPACE_NODE); - SizeOfAcpiObjects = NumNodes * (UINT32) sizeof (ACPI_OPERAND_OBJECT); - - */ + SizeOfParseTree = (NumGrammarElements - NumMethodElements) * + (UINT32) sizeof (ACPI_PARSE_OBJECT); + SizeOfMethodTrees = NumMethodElements * (UINT32) sizeof (ACPI_PARSE_OBJECT); + SizeOfNodeEntries = NumNodes * (UINT32) sizeof (ACPI_NAMESPACE_NODE); + SizeOfAcpiObjects = NumNodes * (UINT32) sizeof (ACPI_OPERAND_OBJECT); +#endif } @@ -323,14 +413,14 @@ AcpiDbClassifyOneObject ( * * PARAMETERS: None * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Count and classify the entire namespace, including all * namespace nodes and attached objects. * ******************************************************************************/ -void +static void AcpiDbCountNamespaceObjects ( void) { @@ -347,8 +437,8 @@ AcpiDbCountNamespaceObjects ( AcpiGbl_NodeTypeCount [i] = 0; } - (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, - FALSE, AcpiDbClassifyOneObject, NULL, NULL); + (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiDbClassifyOneObject, NULL, NULL); } @@ -369,11 +459,7 @@ AcpiDbDisplayStatistics ( char *TypeArg) { UINT32 i; - UINT32 Type; - UINT32 Size; -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - UINT32 Outstanding; -#endif + UINT32 Temp; if (!AcpiGbl_DSDT) @@ -387,18 +473,19 @@ AcpiDbDisplayStatistics ( return (AE_OK); } - ACPI_STRUPR (TypeArg); - Type = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes); - if (Type == (UINT32) -1) + AcpiUtStrupr (TypeArg); + Temp = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes); + if (Temp == (UINT32) -1) { AcpiOsPrintf ("Invalid or unsupported argument\n"); return (AE_OK); } - switch (Type) + switch (Temp) { case CMD_STAT_ALLOCATIONS: + #ifdef ACPI_DBG_TRACK_ALLOCATIONS AcpiUtDumpAllocationInfo (); #endif @@ -409,7 +496,8 @@ AcpiDbDisplayStatistics ( AcpiOsPrintf ("ACPI Table Information:\n\n"); if (AcpiGbl_DSDT) { - AcpiOsPrintf ("DSDT Length:................% 7ld (%X)\n", AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length); + AcpiOsPrintf ("DSDT Length:................% 7ld (%X)\n", + AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length); } break; @@ -419,7 +507,8 @@ AcpiDbDisplayStatistics ( AcpiOsPrintf ("\nObjects defined in the current namespace:\n\n"); - AcpiOsPrintf ("%16.16s %10.10s %10.10s\n", "ACPI_TYPE", "NODES", "OBJECTS"); + AcpiOsPrintf ("%16.16s %10.10s %10.10s\n", + "ACPI_TYPE", "NODES", "OBJECTS"); for (i = 0; i < ACPI_TYPE_NS_NODE_MAX; i++) { @@ -438,43 +527,15 @@ AcpiDbDisplayStatistics ( #ifdef ACPI_DBG_TRACK_ALLOCATIONS AcpiOsPrintf ("\n----Object and Cache Statistics---------------------------------------------\n"); - for (i = 0; i < ACPI_NUM_MEM_LISTS; i++) - { - AcpiOsPrintf ("\n%s\n", AcpiGbl_MemoryLists[i].ListName); - - if (AcpiGbl_MemoryLists[i].MaxCacheDepth > 0) - { - AcpiOsPrintf (" Cache: [Depth Max Avail Size] % 7d % 7d % 7d % 7d B\n", - AcpiGbl_MemoryLists[i].CacheDepth, - AcpiGbl_MemoryLists[i].MaxCacheDepth, - AcpiGbl_MemoryLists[i].MaxCacheDepth - AcpiGbl_MemoryLists[i].CacheDepth, - (AcpiGbl_MemoryLists[i].CacheDepth * AcpiGbl_MemoryLists[i].ObjectSize)); - - AcpiOsPrintf (" Cache: [Requests Hits Misses ObjSize] % 7d % 7d % 7d % 7d B\n", - AcpiGbl_MemoryLists[i].CacheRequests, - AcpiGbl_MemoryLists[i].CacheHits, - AcpiGbl_MemoryLists[i].CacheRequests - AcpiGbl_MemoryLists[i].CacheHits, - AcpiGbl_MemoryLists[i].ObjectSize); - } - - Outstanding = AcpiGbl_MemoryLists[i].TotalAllocated - - AcpiGbl_MemoryLists[i].TotalFreed - - AcpiGbl_MemoryLists[i].CacheDepth; - - if (AcpiGbl_MemoryLists[i].ObjectSize) - { - Size = ACPI_ROUND_UP_TO_1K (Outstanding * AcpiGbl_MemoryLists[i].ObjectSize); - } - else - { - Size = ACPI_ROUND_UP_TO_1K (AcpiGbl_MemoryLists[i].CurrentTotalSize); - } - - AcpiOsPrintf (" Mem: [Alloc Free Outstanding Size] % 7d % 7d % 7d % 7d Kb\n", - AcpiGbl_MemoryLists[i].TotalAllocated, - AcpiGbl_MemoryLists[i].TotalFreed, - Outstanding, Size); - } + AcpiDbListInfo (AcpiGbl_GlobalList); + AcpiDbListInfo (AcpiGbl_NsNodeList); + +#ifdef ACPI_USE_LOCAL_CACHE + AcpiDbListInfo (AcpiGbl_OperandCache); + AcpiDbListInfo (AcpiGbl_PsNodeCache); + AcpiDbListInfo (AcpiGbl_PsNodeExtCache); + AcpiDbListInfo (AcpiGbl_StateCache); +#endif #endif break; @@ -482,15 +543,18 @@ AcpiDbDisplayStatistics ( case CMD_STAT_MISC: AcpiOsPrintf ("\nMiscellaneous Statistics:\n\n"); - AcpiOsPrintf ("Calls to AcpiPsFind:.. ........% 7ld\n", AcpiGbl_PsFindCount); - AcpiOsPrintf ("Calls to AcpiNsLookup:..........% 7ld\n", AcpiGbl_NsLookupCount); + AcpiOsPrintf ("Calls to AcpiPsFind:.. ........% 7ld\n", + AcpiGbl_PsFindCount); + AcpiOsPrintf ("Calls to AcpiNsLookup:..........% 7ld\n", + AcpiGbl_NsLookupCount); AcpiOsPrintf ("\n"); AcpiOsPrintf ("Mutex usage:\n\n"); for (i = 0; i < NUM_MUTEX; i++) { - AcpiOsPrintf ("%-28s: % 7ld\n", AcpiUtGetMutexName (i), AcpiGbl_MutexInfo[i].UseCount); + AcpiOsPrintf ("%-28s: % 7ld\n", + AcpiUtGetMutexName (i), AcpiGbl_MutexInfo[i].UseCount); } break; @@ -536,12 +600,12 @@ AcpiDbDisplayStatistics ( case CMD_STAT_STACK: #if defined(ACPI_DEBUG_OUTPUT) - Size = (UINT32) (AcpiGbl_EntryStackPointer - AcpiGbl_LowestStackPointer); + Temp = (UINT32) (AcpiGbl_EntryStackPointer - AcpiGbl_LowestStackPointer); AcpiOsPrintf ("\nSubsystem Stack Usage:\n\n"); AcpiOsPrintf ("Entry Stack Pointer %X\n", AcpiGbl_EntryStackPointer); AcpiOsPrintf ("Lowest Stack Pointer %X\n", AcpiGbl_LowestStackPointer); - AcpiOsPrintf ("Stack Use %X (%d)\n", Size, Size); + AcpiOsPrintf ("Stack Use %X (%d)\n", Temp, Temp); AcpiOsPrintf ("Deepest Procedure Nesting %d\n", AcpiGbl_DeepestNesting); #endif break; @@ -554,5 +618,4 @@ AcpiDbDisplayStatistics ( return (AE_OK); } - #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbutils.c b/sys/contrib/dev/acpica/dbutils.c index a27b846..173e50e 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: 68 $ + * $Revision: 1.76 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -116,11 +116,8 @@ #include <contrib/dev/acpica/acpi.h> -#include <contrib/dev/acpica/acparser.h> -#include <contrib/dev/acpica/amlcode.h> #include <contrib/dev/acpica/acnamesp.h> #include <contrib/dev/acpica/acdebug.h> -#include <contrib/dev/acpica/acdispat.h> #include <contrib/dev/acpica/acdisasm.h> @@ -129,6 +126,18 @@ #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbutils") +/* Local prototypes */ + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_STATUS +AcpiDbSecondPassParse ( + ACPI_PARSE_OBJECT *Root); + +void +AcpiDbDumpBuffer ( + UINT32 Address); +#endif + /******************************************************************************* * @@ -178,7 +187,7 @@ AcpiDbMatchArgument ( * * RETURN: None * - * DESCRIPTION: Set the current destination for debugger output. Alos sets + * DESCRIPTION: Set the current destination for debugger output. Also sets * the debug output level accordingly. * ******************************************************************************/ @@ -203,32 +212,7 @@ AcpiDbSetOutputDestination ( /******************************************************************************* * - * FUNCTION: AcpiDbDumpBuffer - * - * PARAMETERS: Address - Pointer to the buffer - * - * RETURN: None - * - * DESCRIPTION: Print a portion of a buffer - * - ******************************************************************************/ - -void -AcpiDbDumpBuffer ( - UINT32 Address) -{ - - AcpiOsPrintf ("\nLocation %X:\n", Address); - - AcpiDbgLevel |= ACPI_LV_TABLES; - AcpiUtDumpBuffer (ACPI_TO_POINTER (Address), 64, DB_BYTE_DISPLAY, - ACPI_UINT32_MAX); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiDbDumpObject + * FUNCTION: AcpiDbDumpExternalObject * * PARAMETERS: ObjDesc - External ACPI object to dump * Level - Nesting level. @@ -240,7 +224,7 @@ AcpiDbDumpBuffer ( ******************************************************************************/ void -AcpiDbDumpObject ( +AcpiDbDumpExternalObject ( ACPI_OBJECT *ObjDesc, UINT32 Level) { @@ -262,7 +246,7 @@ AcpiDbDumpObject ( { case ACPI_TYPE_ANY: - AcpiOsPrintf ("[Object Reference] = ", ObjDesc->Reference.Handle); + AcpiOsPrintf ("[Object Reference] = %p", ObjDesc->Reference.Handle); AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL); break; @@ -302,19 +286,19 @@ AcpiDbDumpObject ( case ACPI_TYPE_PACKAGE: - AcpiOsPrintf ("[Package] Contains %d Elements: \n", + AcpiOsPrintf ("[Package] Contains %d Elements:\n", ObjDesc->Package.Count); for (i = 0; i < ObjDesc->Package.Count; i++) { - AcpiDbDumpObject (&ObjDesc->Package.Elements[i], Level+1); + AcpiDbDumpExternalObject (&ObjDesc->Package.Elements[i], Level+1); } break; case ACPI_TYPE_LOCAL_REFERENCE: - AcpiOsPrintf ("[Object Reference] = ", ObjDesc->Reference.Handle); + AcpiOsPrintf ("[Object Reference] = %p", ObjDesc->Reference.Handle); AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL); break; @@ -333,7 +317,7 @@ AcpiDbDumpObject ( default: - AcpiOsPrintf ("[Unknown Type] %X \n", ObjDesc->Type); + AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Type); break; } } @@ -356,13 +340,12 @@ AcpiDbPrepNamestring ( char *Name) { - if (!Name) { return; } - ACPI_STRUPR (Name); + AcpiUtStrupr (Name); /* Convert a leading forward slash to a backslash */ @@ -395,6 +378,59 @@ AcpiDbPrepNamestring ( /******************************************************************************* * + * FUNCTION: AcpiDbLocalNsLookup + * + * PARAMETERS: Name - Name to lookup + * + * RETURN: Pointer to a namespace node, null on failure + * + * DESCRIPTION: Lookup a name in the ACPI namespace + * + * Note: Currently begins search from the root. Could be enhanced to use + * the current prefix (scope) node as the search beginning point. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiDbLocalNsLookup ( + char *Name) +{ + char *InternalPath; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = NULL; + + + AcpiDbPrepNamestring (Name); + + /* Build an internal namestring */ + + Status = AcpiNsInternalizeName (Name, &InternalPath); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Invalid namestring: %s\n", Name); + return (NULL); + } + + /* + * Lookup the name. + * (Uses root node as the search starting point) + */ + Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not locate name: %s %s\n", + Name, AcpiFormatException (Status)); + } + + ACPI_MEM_FREE (InternalPath); + return (Node); +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * * FUNCTION: AcpiDbSecondPassParse * * PARAMETERS: Root - Root of the parse tree @@ -443,7 +479,8 @@ AcpiDbSecondPassParse ( WalkState->ParserState.Aml = WalkState->ParserState.AmlStart = Method->Named.Data; WalkState->ParserState.AmlEnd = - WalkState->ParserState.PkgEnd = Method->Named.Data + Method->Named.Length; + WalkState->ParserState.PkgEnd = Method->Named.Data + + Method->Named.Length; WalkState->ParserState.StartScope = Op; WalkState->DescendingCallback = AcpiDsLoad1BeginOp; @@ -488,55 +525,28 @@ AcpiDbSecondPassParse ( /******************************************************************************* * - * FUNCTION: AcpiDbLocalNsLookup - * - * PARAMETERS: Name - Name to lookup + * FUNCTION: AcpiDbDumpBuffer * - * RETURN: Pointer to a namespace node + * PARAMETERS: Address - Pointer to the buffer * - * DESCRIPTION: Lookup a name in the ACPI namespace + * RETURN: None * - * Note: Currently begins search from the root. Could be enhanced to use - * the current prefix (scope) node as the search beginning point. + * DESCRIPTION: Print a portion of a buffer * ******************************************************************************/ -ACPI_NAMESPACE_NODE * -AcpiDbLocalNsLookup ( - char *Name) +void +AcpiDbDumpBuffer ( + UINT32 Address) { - char *InternalPath; - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node = NULL; + AcpiOsPrintf ("\nLocation %X:\n", Address); - AcpiDbPrepNamestring (Name); - - /* Build an internal namestring */ - - Status = AcpiNsInternalizeName (Name, &InternalPath); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Invalid namestring: %s\n", Name); - return (NULL); - } - - /* - * Lookup the name. - * (Uses root node as the search starting point) - */ - Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); - if (ACPI_FAILURE (Status)) - { - AcpiOsPrintf ("Could not locate name: %s %s\n", - Name, AcpiFormatException (Status)); - } - - ACPI_MEM_FREE (InternalPath); - return (Node); + AcpiDbgLevel |= ACPI_LV_TABLES; + AcpiUtDumpBuffer (ACPI_TO_POINTER (Address), 64, DB_BYTE_DISPLAY, + ACPI_UINT32_MAX); } - +#endif #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbxface.c b/sys/contrib/dev/acpica/dbxface.c index e4af083..053315d 100644 --- a/sys/contrib/dev/acpica/dbxface.c +++ b/sys/contrib/dev/acpica/dbxface.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dbxface - AML Debugger external interfaces - * $Revision: 71 $ + * $Revision: 1.75 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -127,11 +127,26 @@ ACPI_MODULE_NAME ("dbxface") +/* Local prototypes */ + +static ACPI_STATUS +AcpiDbStartCommand ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +#ifdef ACPI_OBSOLETE_FUNCTIONS +void +AcpiDbMethodEnd ( + ACPI_WALK_STATE *WalkState); +#endif + + /******************************************************************************* * * FUNCTION: AcpiDbStartCommand * * PARAMETERS: WalkState - Current walk + * Op - Current executing Op, from AML interpreter * * RETURN: Status * @@ -139,7 +154,7 @@ * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDbStartCommand ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) @@ -147,7 +162,7 @@ AcpiDbStartCommand ( ACPI_STATUS Status; - /* TBD: [Investigate] what are the namespace locking issues here */ + /* TBD: [Investigate] are there namespace locking issues here? */ /* AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); */ @@ -208,38 +223,10 @@ AcpiDbStartCommand ( /******************************************************************************* * - * FUNCTION: AcpiDbMethodEnd - * - * PARAMETERS: WalkState - Current walk - * - * RETURN: Status - * - * DESCRIPTION: - * - ******************************************************************************/ - -void -AcpiDbMethodEnd ( - ACPI_WALK_STATE *WalkState) -{ - - if (!AcpiGbl_CmSingleStep) - { - return; - } - - AcpiOsPrintf ("<Method Terminating>\n"); - - AcpiDbStartCommand (WalkState, NULL); -} - - -/******************************************************************************* - * * FUNCTION: AcpiDbSingleStep * * PARAMETERS: WalkState - Current walk - * Op - Current executing op + * Op - Current executing op (from aml interpreter) * OpcodeClass - Class of the current AML Opcode * * RETURN: Status @@ -291,7 +278,8 @@ AcpiDbSingleStep ( else if (WalkState->UserBreakpoint && (WalkState->UserBreakpoint == Op->Common.AmlOffset)) { - AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n", Op->Common.AmlOffset); + AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n", + Op->Common.AmlOffset); AcpiGbl_CmSingleStep = TRUE; AcpiGbl_StepToNextCall = FALSE; WalkState->MethodBreakpoint = 0; @@ -331,9 +319,9 @@ AcpiDbSingleStep ( } /* - * Display this op (and only this op - zero out the NEXT field temporarily, - * and disable parser trace output for the duration of the display because - * we don't want the extraneous debug output) + * Display this op (and only this op - zero out the NEXT field + * temporarily, and disable parser trace output for the duration of + * the display because we don't want the extraneous debug output) */ OriginalDebugLevel = AcpiDbgLevel; AcpiDbgLevel &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS); @@ -346,7 +334,8 @@ AcpiDbSingleStep ( if (ParentOp) { if ((WalkState->ControlState) && - (WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING)) + (WalkState->ControlState->Common.State == + ACPI_CONTROL_PREDICATE_EXECUTING)) { /* * We are executing the predicate of an IF or WHILE statement @@ -446,10 +435,14 @@ AcpiDbSingleStep ( */ if (Op->Common.AmlOpcode == AML_INT_METHODCALL_OP) { - AcpiGbl_CmSingleStep = FALSE; /* No more single step while executing called method */ + /* Force no more single stepping while executing called method */ - /* Set the breakpoint on/before the call, it will stop execution as soon as we return */ + AcpiGbl_CmSingleStep = FALSE; + /* + * Set the breakpoint on/before the call, it will stop execution + * as soon as we return + */ WalkState->MethodBreakpoint = 1; /* Must be non-zero! */ } @@ -475,7 +468,8 @@ AcpiDbSingleStep ( ******************************************************************************/ ACPI_STATUS -AcpiDbInitialize (void) +AcpiDbInitialize ( + void) { ACPI_STATUS Status; @@ -558,14 +552,15 @@ AcpiDbInitialize (void) * * PARAMETERS: None * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Stop debugger * ******************************************************************************/ void -AcpiDbTerminate (void) +AcpiDbTerminate ( + void) { if (AcpiGbl_DbTablePtr) @@ -579,4 +574,33 @@ AcpiDbTerminate (void) } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiDbMethodEnd + * + * PARAMETERS: WalkState - Current walk + * + * RETURN: Status + * + * DESCRIPTION: Called at method termination + * + ******************************************************************************/ + +void +AcpiDbMethodEnd ( + ACPI_WALK_STATE *WalkState) +{ + + if (!AcpiGbl_CmSingleStep) + { + return; + } + + AcpiOsPrintf ("<Method Terminating>\n"); + + AcpiDbStartCommand (WalkState, NULL); +} +#endif + #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dmbuffer.c b/sys/contrib/dev/acpica/dmbuffer.c index 771e35b..cd6f1f0 100644 --- a/sys/contrib/dev/acpica/dmbuffer.c +++ b/sys/contrib/dev/acpica/dmbuffer.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmbuffer - AML disassembler, buffer and string support - * $Revision: 13 $ + * $Revision: 1.19 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -126,6 +126,12 @@ #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmbuffer") +/* Local prototypes */ + +static void +AcpiDmUnicode ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -137,7 +143,7 @@ * * RETURN: None * - * DESCRIPTION: Dump a list of bytes in Hex format + * DESCRIPTION: Dump an AML "ByteList" in Hex format * ******************************************************************************/ @@ -215,7 +221,7 @@ AcpiDmByteList ( { case ACPI_DASM_RESOURCE: - AcpiDmResourceDescriptor (Info, ByteData, ByteCount); + AcpiDmResourceTemplate (Info, ByteData, ByteCount); break; case ACPI_DASM_STRING: @@ -321,7 +327,7 @@ AcpiDmIsUnicodeBuffer ( * * PARAMETERS: Op - Buffer Object to be examined * - * RETURN: TRUE if buffer contains a ASCII string + * RETURN: TRUE if buffer contains a ASCII string, FALSE otherwise * * DESCRIPTION: Determine if a buffer Op contains a ASCII string * @@ -393,7 +399,7 @@ AcpiDmIsStringBuffer ( * ******************************************************************************/ -void +static void AcpiDmUnicode ( ACPI_PARSE_OBJECT *Op) { @@ -423,7 +429,7 @@ AcpiDmUnicode ( /******************************************************************************* * - * FUNCTION: AcpiIsEisaId + * FUNCTION: AcpiDmIsEisaId * * PARAMETERS: Op - Op to be examined * @@ -434,7 +440,7 @@ AcpiDmUnicode ( ******************************************************************************/ void -AcpiIsEisaId ( +AcpiDmIsEisaId ( ACPI_PARSE_OBJECT *Op) { UINT32 Name; diff --git a/sys/contrib/dev/acpica/dmnames.c b/sys/contrib/dev/acpica/dmnames.c index ed13533..2c8029f 100644 --- a/sys/contrib/dev/acpica/dmnames.c +++ b/sys/contrib/dev/acpica/dmnames.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmnames - AML disassembler, names, namestrings, pathnames - * $Revision: 7 $ + * $Revision: 1.11 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -127,61 +127,14 @@ #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmnames") +/* Local prototypes */ -/******************************************************************************* - * - * FUNCTION: AcpiDmValidateName - * - * PARAMETERS: Name - 4 character ACPI name - * - * RETURN: None - * - * DESCRIPTION: Lookup the name - * - ******************************************************************************/ - +#ifdef ACPI_OBSOLETE_FUNCTIONS void -AcpiDmValidateName ( - char *Name, - ACPI_PARSE_OBJECT *Op) -{ - -#if 0 - if ((!Name) || - (!Op->Common.Parent)) - { - return; - } - - if (!Op->Common.Node) - { - AcpiOsPrintf (" /**** Name not found or not accessible from this scope ****/ "); - } - - ACPI_PARSE_OBJECT *TargetOp; - - - if ((!Name) || - (!Op->Common.Parent)) - { - return; - } - - TargetOp = AcpiPsFind (Op, Name, 0, 0); - if (!TargetOp) - { - /* - * Didn't find the name in the parse tree. This may be - * a problem, or it may simply be one of the predefined names - * (such as _OS_). Rather than worry about looking up all - * the predefined names, just display the name as given - */ - AcpiOsPrintf (" /**** Name not found or not accessible from this scope ****/ "); - } +AcpiDmDisplayPath ( + ACPI_PARSE_OBJECT *Op); #endif -} - /******************************************************************************* * @@ -261,8 +214,9 @@ AcpiPsDisplayObjectPathname ( { /* Node not defined in this scope, look it up */ - Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String, ACPI_TYPE_ANY, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); + Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); if (ACPI_FAILURE (Status)) { @@ -310,7 +264,7 @@ Exit: * * RETURN: None * - * DESCRIPTION: Decode an ACPI namestring. Handles prefix characters + * DESCRIPTION: Decode and dump an ACPI namestring. Handles prefix characters * ******************************************************************************/ @@ -375,6 +329,7 @@ AcpiDmNamestring ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS /******************************************************************************* * * FUNCTION: AcpiDmDisplayPath @@ -494,6 +449,61 @@ AcpiDmDisplayPath ( } } + +/******************************************************************************* + * + * FUNCTION: AcpiDmValidateName + * + * PARAMETERS: Name - 4 character ACPI name + * + * RETURN: None + * + * DESCRIPTION: Lookup the name + * + ******************************************************************************/ + +void +AcpiDmValidateName ( + char *Name, + ACPI_PARSE_OBJECT *Op) +{ + + if ((!Name) || + (!Op->Common.Parent)) + { + return; + } + + if (!Op->Common.Node) + { + AcpiOsPrintf ( + " /**** Name not found or not accessible from this scope ****/ "); + } + + ACPI_PARSE_OBJECT *TargetOp; + + + if ((!Name) || + (!Op->Common.Parent)) + { + return; + } + + TargetOp = AcpiPsFind (Op, Name, 0, 0); + if (!TargetOp) + { + /* + * Didn't find the name in the parse tree. This may be + * a problem, or it may simply be one of the predefined names + * (such as _OS_). Rather than worry about looking up all + * the predefined names, just display the name as given + */ + AcpiOsPrintf ( + " /**** Name not found or not accessible from this scope ****/ "); + } +} +#endif + #endif diff --git a/sys/contrib/dev/acpica/dmobject.c b/sys/contrib/dev/acpica/dmobject.c index 35f1dee..f63d3ee 100644 --- a/sys/contrib/dev/acpica/dmobject.c +++ b/sys/contrib/dev/acpica/dmobject.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmobject - ACPI object decode and display - * $Revision: 11 $ + * $Revision: 1.17 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -127,8 +127,14 @@ #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmnames") +/* Local prototypes */ -/***************************************************************************** +static void +AcpiDmDecodeNode ( + ACPI_NAMESPACE_NODE *Node); + + +/******************************************************************************* * * FUNCTION: AcpiDmDumpMethodInfo * @@ -142,7 +148,7 @@ * Dumps the method execution stack, and the method locals/args, * and disassembles the AML opcode that failed. * - ****************************************************************************/ + ******************************************************************************/ void AcpiDmDumpMethodInfo ( @@ -171,6 +177,17 @@ AcpiDmDumpMethodInfo ( return; } + /* + * If there is no Thread, we are not actually executing a method. + * This can happen when the iASL compiler calls the interpreter + * to perform constant folding. + */ + Thread = WalkState->Thread; + if (!Thread) + { + return; + } + /* Display exception and method name */ AcpiOsPrintf ("\n**** Exception %s during execution of method ", @@ -180,7 +197,6 @@ AcpiDmDumpMethodInfo ( /* Display stack of executing methods */ AcpiOsPrintf ("\n\nMethod Execution Stack:\n"); - Thread = WalkState->Thread; NextWalkState = Thread->WalkStateList; /* Walk list of linked walk states */ @@ -236,7 +252,7 @@ AcpiDmDumpMethodInfo ( * * RETURN: None * - * DESCRIPTION: Short display of an internal object. Numbers and Strings. + * DESCRIPTION: Short display of an internal object. Numbers/Strings/Buffers. * ******************************************************************************/ @@ -316,12 +332,11 @@ AcpiDmDecodeInternalObject ( * ******************************************************************************/ -void +static void AcpiDmDecodeNode ( ACPI_NAMESPACE_NODE *Node) { - AcpiOsPrintf ("<Node> Name %4.4s", AcpiUtGetNodeName (Node)); @@ -405,7 +420,8 @@ AcpiDmDisplayInternalObject ( AcpiOsPrintf ("[Local%d] ", ObjDesc->Reference.Offset); if (WalkState) { - ObjDesc = WalkState->LocalVariables[ObjDesc->Reference.Offset].Object; + ObjDesc = WalkState->LocalVariables[ + ObjDesc->Reference.Offset].Object; AcpiOsPrintf ("%p", ObjDesc); AcpiDmDecodeInternalObject (ObjDesc); } @@ -417,7 +433,8 @@ AcpiDmDisplayInternalObject ( AcpiOsPrintf ("[Arg%d] ", ObjDesc->Reference.Offset); if (WalkState) { - ObjDesc = WalkState->Arguments[ObjDesc->Reference.Offset].Object; + ObjDesc = WalkState->Arguments[ + ObjDesc->Reference.Offset].Object; AcpiOsPrintf ("%p", ObjDesc); AcpiDmDecodeInternalObject (ObjDesc); } @@ -449,7 +466,8 @@ AcpiDmDisplayInternalObject ( } else { - AcpiDmDecodeInternalObject (*(ObjDesc->Reference.Where)); + AcpiDmDecodeInternalObject ( + *(ObjDesc->Reference.Where)); } break; @@ -493,6 +511,10 @@ AcpiDmDisplayInternalObject ( } break; + case AML_INT_NAMEPATH_OP: + + AcpiDmDecodeNode (ObjDesc->Reference.Node); + break; default: @@ -527,7 +549,7 @@ AcpiDmDisplayInternalObject ( * * FUNCTION: AcpiDmDisplayLocals * - * PARAMETERS: None + * PARAMETERS: WalkState - State for current method * * RETURN: None * @@ -548,7 +570,8 @@ AcpiDmDisplayLocals ( Node = WalkState->MethodNode; if (!Node) { - AcpiOsPrintf ("No method node (Executing subtree for buffer or opregion)\n"); + AcpiOsPrintf ( + "No method node (Executing subtree for buffer or opregion)\n"); return; } @@ -574,7 +597,7 @@ AcpiDmDisplayLocals ( * * FUNCTION: AcpiDmDisplayArguments * - * PARAMETERS: None + * PARAMETERS: WalkState - State for current method * * RETURN: None * @@ -597,7 +620,8 @@ AcpiDmDisplayArguments ( Node = WalkState->MethodNode; if (!Node) { - AcpiOsPrintf ("No method node (Executing subtree for buffer or opregion)\n"); + AcpiOsPrintf ( + "No method node (Executing subtree for buffer or opregion)\n"); return; } @@ -610,8 +634,9 @@ AcpiDmDisplayArguments ( NumArgs = ObjDesc->Method.ParamCount; Concurrency = ObjDesc->Method.Concurrency; - AcpiOsPrintf ("Arguments for Method [%4.4s]: (%X arguments defined, max concurrency = %X)\n", - AcpiUtGetNodeName (Node), NumArgs, Concurrency); + AcpiOsPrintf ( + "Arguments for Method [%4.4s]: (%X arguments defined, max concurrency = %X)\n", + AcpiUtGetNodeName (Node), NumArgs, Concurrency); for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) { diff --git a/sys/contrib/dev/acpica/dmopcode.c b/sys/contrib/dev/acpica/dmopcode.c index 8f5f36c..5e074b7 100644 --- a/sys/contrib/dev/acpica/dmopcode.c +++ b/sys/contrib/dev/acpica/dmopcode.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmopcode - AML disassembler, specific AML opcodes - * $Revision: 85 $ + * $Revision: 1.90 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,6 +124,12 @@ #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmopcode") +/* Local prototypes */ + +static void +AcpiDmMatchKeyword ( + ACPI_PARSE_OBJECT *Op); + /******************************************************************************* * @@ -328,7 +334,7 @@ AcpiDmMatchOp ( * ******************************************************************************/ -void +static void AcpiDmMatchKeyword ( ACPI_PARSE_OBJECT *Op) { @@ -340,7 +346,8 @@ AcpiDmMatchKeyword ( } else { - AcpiOsPrintf ("%s", (char *) AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer]); + AcpiOsPrintf ("%s", (char *) + AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer]); } } @@ -474,7 +481,7 @@ AcpiDmDisassembleOneOp ( * types of buffers, we have to closely look at the data in the * buffer to determine the type. */ - if (AcpiDmIsResourceDescriptor (Op)) + if (AcpiDmIsResourceTemplate (Op)) { Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE; AcpiOsPrintf ("ResourceTemplate"); @@ -513,14 +520,14 @@ AcpiDmDisassembleOneOp ( case AML_INT_NAMEPATH_OP: AcpiDmNamestring (Op->Common.Value.Name); - AcpiDmValidateName (Op->Common.Value.Name, Op); break; case AML_INT_NAMEDFIELD_OP: Length = AcpiDmDumpName ((char *) &Op->Named.Name); - AcpiOsPrintf (",%*.s %d", (int) (5 - Length), " ", (UINT32) Op->Common.Value.Integer); + AcpiOsPrintf (",%*.s %d", (int) (5 - Length), " ", + (UINT32) Op->Common.Value.Integer); AcpiDmCommaIfFieldMember (Op); Info->BitOffset += (UINT32) Op->Common.Value.Integer; @@ -590,7 +597,8 @@ AcpiDmDisassembleOneOp ( (WalkState->Results->Results.NumResults)) { AcpiDmDecodeInternalObject ( - WalkState->Results->Results.ObjDesc [WalkState->Results->Results.NumResults-1]); + WalkState->Results->Results.ObjDesc [ + WalkState->Results->Results.NumResults-1]); } #endif break; diff --git a/sys/contrib/dev/acpica/dmresrc.c b/sys/contrib/dev/acpica/dmresrc.c index ca4dec3..1bbea38 100644 --- a/sys/contrib/dev/acpica/dmresrc.c +++ b/sys/contrib/dev/acpica/dmresrc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmresrc.c - Resource Descriptor disassembly - * $Revision: 13 $ + * $Revision: 1.26 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,6 +125,150 @@ ACPI_MODULE_NAME ("dbresrc") +/* Dispatch tables for Resource disassembly functions */ + +typedef +void (*ACPI_RESOURCE_HANDLER) ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +static ACPI_RESOURCE_HANDLER AcpiGbl_SmResourceDispatch [] = +{ + NULL, /* 0x00, Reserved */ + NULL, /* 0x01, Reserved */ + NULL, /* 0x02, Reserved */ + NULL, /* 0x03, Reserved */ + AcpiDmIrqDescriptor, /* 0x04, ACPI_RESOURCE_NAME_IRQ_FORMAT */ + AcpiDmDmaDescriptor, /* 0x05, ACPI_RESOURCE_NAME_DMA_FORMAT */ + AcpiDmStartDependentDescriptor, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */ + AcpiDmEndDependentDescriptor, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */ + AcpiDmIoDescriptor, /* 0x08, ACPI_RESOURCE_NAME_IO_PORT */ + AcpiDmFixedIoDescriptor, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO_PORT */ + NULL, /* 0x0A, Reserved */ + NULL, /* 0x0B, Reserved */ + NULL, /* 0x0C, Reserved */ + NULL, /* 0x0D, Reserved */ + AcpiDmVendorSmallDescriptor, /* 0x0E, ACPI_RESOURCE_NAME_SMALL_VENDOR */ + NULL /* 0x0F, ACPI_RESOURCE_NAME_END_TAG (not used) */ +}; + +static ACPI_RESOURCE_HANDLER AcpiGbl_LgResourceDispatch [] = +{ + NULL, /* 0x00, Reserved */ + AcpiDmMemory24Descriptor, /* 0x01, ACPI_RESOURCE_NAME_MEMORY_24 */ + AcpiDmGenericRegisterDescriptor,/* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ + NULL, /* 0x03, Reserved */ + AcpiDmVendorLargeDescriptor, /* 0x04, ACPI_RESOURCE_NAME_LARGE_VENDOR */ + AcpiDmMemory32Descriptor, /* 0x05, ACPI_RESOURCE_NAME_MEMORY_32 */ + AcpiDmFixedMemory32Descriptor, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY_32 */ + AcpiDmDwordDescriptor, /* 0x07, ACPI_RESOURCE_NAME_DWORD_ADDRESS_SPACE */ + AcpiDmWordDescriptor, /* 0x08, ACPI_RESOURCE_NAME_WORD_ADDRESS_SPACE */ + AcpiDmInterruptDescriptor, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_XRUPT */ + AcpiDmQwordDescriptor, /* 0x0A, ACPI_RESOURCE_NAME_QWORD_ADDRESS_SPACE */ + AcpiDmExtendedDescriptor /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS_SPACE */ +}; + + +/* Local prototypes */ + +static ACPI_RESOURCE_HANDLER +AcpiDmGetResourceHandler ( + UINT8 ResourceType); + + +/******************************************************************************* + * + * FUNCTION: AcpiDmDumpInteger* + * + * PARAMETERS: Value - Value to emit + * Name - Associated name (emitted as a comment) + * + * RETURN: None + * + * DESCRIPTION: Integer output helper functions + * + ******************************************************************************/ + +void +AcpiDmDumpInteger8 ( + UINT8 Value, + char *Name) +{ + AcpiOsPrintf ("0x%2.2X, // %s\n", Value, Name); +} + +void +AcpiDmDumpInteger16 ( + UINT16 Value, + char *Name) +{ + AcpiOsPrintf ("0x%4.4X, // %s\n", Value, Name); +} + +void +AcpiDmDumpInteger32 ( + UINT32 Value, + char *Name) +{ + AcpiOsPrintf ("0x%8.8X, // %s\n", Value, Name); +} + +void +AcpiDmDumpInteger64 ( + UINT64 Value, + char *Name) +{ + AcpiOsPrintf ("0x%8.8X%8.8X, // %s\n", + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Value)), Name); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmGetResourceHandler + * + * PARAMETERS: ResourceType - Byte 0 of a resource descriptor + * + * RETURN: Pointer to the resource conversion handler. NULL is returned + * if the ResourceType is invalid. + * + * DESCRIPTION: Return the handler associated with this resource type. + * May also be used to validate a ResourceType. + * + ******************************************************************************/ + +static ACPI_RESOURCE_HANDLER +AcpiDmGetResourceHandler ( + UINT8 ResourceType) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Determine if this is a small or large resource */ + + if (ResourceType & ACPI_RESOURCE_NAME_LARGE) + { + /* Large Resource Type -- bits 6:0 contain the name */ + + if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX) + { + return (NULL); + } + + return (AcpiGbl_LgResourceDispatch [ + (ResourceType & ACPI_RESOURCE_NAME_LARGE_MASK)]); + } + else + { + /* Small Resource Type -- bits 6:3 contain the name */ + + return (AcpiGbl_SmResourceDispatch [ + ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3)]); + } +} + + /******************************************************************************* * * FUNCTION: AcpiDmBitList @@ -148,7 +292,7 @@ AcpiDmBitList ( /* Open the initializer list */ - AcpiOsPrintf (") {"); + AcpiOsPrintf ("{"); /* Examine each bit */ @@ -177,7 +321,7 @@ AcpiDmBitList ( /******************************************************************************* * - * FUNCTION: AcpiDmResourceDescriptor + * FUNCTION: AcpiDmResourceTemplate * * PARAMETERS: Info - Curent parse tree walk info * ByteData - Pointer to the byte list data @@ -185,67 +329,46 @@ AcpiDmBitList ( * * RETURN: None * - * DESCRIPTION: Dump the contents of one ResourceTemplate descriptor. + * DESCRIPTION: Dump the contents of a Resource Template containing a set of + * Resource Descriptors. * ******************************************************************************/ void -AcpiDmResourceDescriptor ( +AcpiDmResourceTemplate ( ACPI_OP_WALK_INFO *Info, UINT8 *ByteData, UINT32 ByteCount) { ACPI_NATIVE_UINT CurrentByteOffset; - UINT8 CurrentByte; - UINT8 DescriptorId; - UINT32 Length; + UINT8 ResourceType; + UINT32 ResourceLength; void *DescriptorBody; UINT32 Level; BOOLEAN DependentFns = FALSE; + ACPI_RESOURCE_HANDLER Handler; Level = Info->Level; for (CurrentByteOffset = 0; CurrentByteOffset < ByteCount; ) { - CurrentByte = ByteData[CurrentByteOffset]; - DescriptorBody = &ByteData[CurrentByteOffset]; - - if (CurrentByte & ACPI_RDESC_TYPE_LARGE) - { - DescriptorId = CurrentByte; - Length = (* (ACPI_CAST_PTR (UINT16, &ByteData[CurrentByteOffset + 1]))); - CurrentByteOffset += 3; - } - else - { - DescriptorId = (UINT8) (CurrentByte & 0xF8); - Length = (ByteData[CurrentByteOffset] & 0x7); - CurrentByteOffset += 1; - } - - CurrentByteOffset += (ACPI_NATIVE_UINT) Length; + /* Get the descriptor type and length */ - /* Determine type of resource */ - - switch (DescriptorId) - { - /* - * "Small" type descriptors - */ - case ACPI_RDESC_TYPE_IRQ_FORMAT: - - AcpiDmIrqDescriptor (DescriptorBody, Length, Level); - break; + DescriptorBody = &ByteData[CurrentByteOffset]; + ResourceType = AcpiUtGetResourceType (DescriptorBody); + ResourceLength = AcpiUtGetResourceLength (DescriptorBody); - case ACPI_RDESC_TYPE_DMA_FORMAT: + /* Point to next descriptor */ - AcpiDmDmaDescriptor (DescriptorBody, Length, Level); - break; + CurrentByteOffset += AcpiUtGetDescriptorLength (DescriptorBody); + /* Descriptor pre-processing */ - case ACPI_RDESC_TYPE_START_DEPENDENT: + switch (ResourceType) + { + case ACPI_RESOURCE_NAME_START_DEPENDENT: /* Finish a previous StartDependentFns */ @@ -255,139 +378,75 @@ AcpiDmResourceDescriptor ( AcpiDmIndent (Level); AcpiOsPrintf ("}\n"); } - - AcpiDmStartDependentDescriptor (DescriptorBody, Length, Level); - DependentFns = TRUE; - Level++; break; - - case ACPI_RDESC_TYPE_END_DEPENDENT: + case ACPI_RESOURCE_NAME_END_DEPENDENT: Level--; DependentFns = FALSE; - AcpiDmEndDependentDescriptor (DescriptorBody, Length, Level); - break; - - - case ACPI_RDESC_TYPE_IO_PORT: - - AcpiDmIoDescriptor (DescriptorBody, Length, Level); - break; - - - case ACPI_RDESC_TYPE_FIXED_IO_PORT: - - AcpiDmFixedIoDescriptor (DescriptorBody, Length, Level); - break; - - - case ACPI_RDESC_TYPE_SMALL_VENDOR: - - AcpiDmVendorSmallDescriptor (DescriptorBody, Length, Level); break; + case ACPI_RESOURCE_NAME_END_TAG: - case ACPI_RDESC_TYPE_END_TAG: + /* Normal exit, the resource list is finished */ if (DependentFns) { /* - * Close an open StartDependentDescriptor. This indicates a missing - * EndDependentDescriptor. + * Close an open StartDependentDescriptor. This indicates a + * missing EndDependentDescriptor. */ Level--; DependentFns = FALSE; - AcpiDmIndent (Level); - AcpiOsPrintf ("}\n"); - AcpiDmIndent (Level); - AcpiOsPrintf ("/*** Missing EndDependentFunctions descriptor */"); + /* Go ahead and insert EndDependentFn() */ - /* - * We could fix the problem, but then the ASL would not match the AML - * So, we don't do this: - * AcpiDmEndDependentDescriptor (DescriptorBody, Length, Level); - */ + AcpiDmEndDependentDescriptor (DescriptorBody, ResourceLength, Level); + + AcpiDmIndent (Level); + AcpiOsPrintf ( + "/*** Disassembler: inserted missing EndDependentFn () ***/\n"); } return; - - /* - * "Large" type descriptors - */ - case ACPI_RDESC_TYPE_MEMORY_24: - - AcpiDmMemory24Descriptor (DescriptorBody, Length, Level); - break; - - - case ACPI_RDESC_TYPE_GENERAL_REGISTER: - - AcpiDmGenericRegisterDescriptor (DescriptorBody, Length, Level); - break; - - - case ACPI_RDESC_TYPE_LARGE_VENDOR: - - AcpiDmVendorLargeDescriptor (DescriptorBody, Length, Level); - break; - - - case ACPI_RDESC_TYPE_MEMORY_32: - - AcpiDmMemory32Descriptor (DescriptorBody, Length, Level); - break; - - - case ACPI_RDESC_TYPE_FIXED_MEMORY_32: - - AcpiDmFixedMem32Descriptor (DescriptorBody, Length, Level); - break; - - - case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: - - AcpiDmDwordDescriptor (DescriptorBody, Length, Level); - break; - - - case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: - - AcpiDmWordDescriptor (DescriptorBody, Length, Level); - break; - - - case ACPI_RDESC_TYPE_EXTENDED_XRUPT: - - AcpiDmInterruptDescriptor (DescriptorBody, Length, Level); - break; - - - case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: - - AcpiDmQwordDescriptor (DescriptorBody, Length, Level); + default: break; + } + /* Get the handler associated with this Descriptor Type */ - default: + Handler = AcpiDmGetResourceHandler (ResourceType); + if (!Handler) + { /* - * Anything else is unrecognized. + * Invalid Descriptor Type. * - * Since the entire resource buffer has been already walked and + * Since the entire resource buffer has been previously walked and * validated, this is a very serious error indicating that someone * overwrote the buffer. */ - AcpiOsPrintf ("/* Unknown Resource type (%X) */\n", DescriptorId); + AcpiOsPrintf ("/*** Unknown Resource type (%X) ***/\n", ResourceType); return; } + + /* Disassemble the resource structure */ + + Handler (DescriptorBody, ResourceLength, Level); + + /* Descriptor post-processing */ + + if (ResourceType == ACPI_RESOURCE_NAME_START_DEPENDENT) + { + DependentFns = TRUE; + Level++; + } } } /******************************************************************************* * - * FUNCTION: AcpiDmIsResourceDescriptor + * FUNCTION: AcpiDmIsResourceTemplate * * PARAMETERS: Op - Buffer Op to be examined * @@ -400,16 +459,15 @@ AcpiDmResourceDescriptor ( ******************************************************************************/ BOOLEAN -AcpiDmIsResourceDescriptor ( +AcpiDmIsResourceTemplate ( ACPI_PARSE_OBJECT *Op) { UINT8 *ByteData; UINT32 ByteCount; ACPI_PARSE_OBJECT *NextOp; ACPI_NATIVE_UINT CurrentByteOffset; - UINT8 CurrentByte; - UINT8 DescriptorId; - UINT32 Length; + UINT8 ResourceType; + void *DescriptorBody; /* This op must be a buffer */ @@ -433,96 +491,53 @@ AcpiDmIsResourceDescriptor ( ByteCount = (UINT32) NextOp->Common.Value.Integer; ByteData = NextOp->Named.Data; - /* Absolute minimum descriptor is an END_TAG (2 bytes) */ - - if (ByteCount < 2) + /* + * The absolute minimum resource template is an END_TAG (2 bytes), + * and the list must be terminated by a valid 2-byte END_TAG + */ + if ((ByteCount < 2) || + (ByteData[ByteCount - 2] != (ACPI_RESOURCE_NAME_END_TAG | 1))) { return (FALSE); } - /* The list must have a valid 2-byte END_TAG */ + /* Walk the byte list, abort on any invalid descriptor ID or length */ - if (ByteData[ByteCount-2] != (ACPI_RDESC_TYPE_END_TAG | 1)) - { - return FALSE; - } - - /* - * Walk the byte list. Abort on any invalid descriptor ID or - * or length - */ for (CurrentByteOffset = 0; CurrentByteOffset < ByteCount;) { - CurrentByte = ByteData[CurrentByteOffset]; + /* Get the descriptor type and length */ - /* Large or small resource? */ + DescriptorBody = &ByteData[CurrentByteOffset]; + ResourceType = AcpiUtGetResourceType (DescriptorBody); - if (CurrentByte & ACPI_RDESC_TYPE_LARGE) - { - DescriptorId = CurrentByte; - Length = (* (ACPI_CAST_PTR (UINT16, (&ByteData[CurrentByteOffset + 1])))); - CurrentByteOffset += 3; - } - else - { - DescriptorId = (UINT8) (CurrentByte & 0xF8); - Length = (ByteData[CurrentByteOffset] & 0x7); - CurrentByteOffset += 1; - } + /* Point to next descriptor */ - CurrentByteOffset += (ACPI_NATIVE_UINT) Length; + CurrentByteOffset += AcpiUtGetDescriptorLength (DescriptorBody); - /* Determine type of resource */ + /* END_TAG terminates the descriptor list */ - switch (DescriptorId) + if (ResourceType == ACPI_RESOURCE_NAME_END_TAG) { - /* - * "Small" type descriptors - */ - case ACPI_RDESC_TYPE_IRQ_FORMAT: - case ACPI_RDESC_TYPE_DMA_FORMAT: - case ACPI_RDESC_TYPE_START_DEPENDENT: - case ACPI_RDESC_TYPE_END_DEPENDENT: - case ACPI_RDESC_TYPE_IO_PORT: - case ACPI_RDESC_TYPE_FIXED_IO_PORT: - case ACPI_RDESC_TYPE_SMALL_VENDOR: - - /* - * "Large" type descriptors - */ - case ACPI_RDESC_TYPE_MEMORY_24: - case ACPI_RDESC_TYPE_GENERAL_REGISTER: - case ACPI_RDESC_TYPE_LARGE_VENDOR: - case ACPI_RDESC_TYPE_MEMORY_32: - case ACPI_RDESC_TYPE_FIXED_MEMORY_32: - case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: - case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: - case ACPI_RDESC_TYPE_EXTENDED_XRUPT: - case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: - - /* Valid descriptor ID, keep going */ - - break; - - - case ACPI_RDESC_TYPE_END_TAG: - - /* We must be at the end of the ByteList */ - + /* + * For the resource template to be valid, one END_TAG must appear + * at the very end of the ByteList, not before + */ if (CurrentByteOffset != ByteCount) { return (FALSE); } - /* All descriptors/lengths valid, this is a valid descriptor */ - + /* + * All resource descriptor types and lengths are valid, + * this list appears to be a valid resource template + */ return (TRUE); + } + /* Validate the resource name (must be after check for END_TAG) */ - default: - - /* Bad descriptor, abort */ - + if (!AcpiDmGetResourceHandler (ResourceType)) + { return (FALSE); } } @@ -532,5 +547,4 @@ AcpiDmIsResourceDescriptor ( return (FALSE); } - #endif diff --git a/sys/contrib/dev/acpica/dmresrcl.c b/sys/contrib/dev/acpica/dmresrcl.c index d7e3227..ca8b780 100644 --- a/sys/contrib/dev/acpica/dmresrcl.c +++ b/sys/contrib/dev/acpica/dmresrcl.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmresrcl.c - "Large" Resource Descriptor disassembly - * $Revision: 12 $ + * $Revision: 1.29 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,6 +125,338 @@ ACPI_MODULE_NAME ("dbresrcl") +/* Common names for address and memory descriptors */ + +static char *AcpiDmAddressNames[] = +{ + "Address Space Granularity", + "Address Range Minimum", + "Address Range Maximum", + "Address Translation Offset", + "Address Length" +}; + +static char *AcpiDmMemoryNames[] = +{ + "Address Range Minimum", + "Address Range Maximum", + "Address Alignment", + "Address Length" +}; + + +/* Local prototypes */ + +static void +AcpiDmSpaceFlags ( + UINT8 Flags); + +static void +AcpiDmIoFlags ( + UINT8 Flags); + +static void +AcpiDmIoFlags2 ( + UINT8 SpecificFlags); + +static void +AcpiDmMemoryFlags ( + UINT8 Flags, + UINT8 SpecificFlags); + +static void +AcpiDmMemoryFlags2 ( + UINT8 SpecificFlags); + +static void +AcpiDmResourceSource ( + AML_RESOURCE *Resource, + ACPI_SIZE MinimumLength, + UINT32 Length); + +static void +AcpiDmAddressFields ( + void *Source, + UINT8 Type, + UINT32 Level); + +static void +AcpiDmAddressPrefix ( + UINT8 Type); + +static void +AcpiDmAddressCommon ( + AML_RESOURCE *Resource, + UINT8 Type, + UINT32 Level); + +static void +AcpiDmAddressFlags ( + AML_RESOURCE *Resource); + + +/******************************************************************************* + * + * FUNCTION: AcpiDmMemoryFields + * + * PARAMETERS: Source - Pointer to the contiguous data fields + * Type - 16 or 32 (bit) + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Decode fields common to Memory24 and Memory32 descriptors + * + ******************************************************************************/ + +static void +AcpiDmMemoryFields ( + void *Source, + UINT8 Type, + UINT32 Level) +{ + ACPI_NATIVE_UINT i; + + + for (i = 0; i < 4; i++) + { + AcpiDmIndent (Level + 1); + + switch (Type) + { + case 16: + AcpiDmDumpInteger16 (((UINT16 *) Source)[i], AcpiDmMemoryNames[i]); + break; + + case 32: + AcpiDmDumpInteger32 (((UINT32 *) Source)[i], AcpiDmMemoryNames[i]); + break; + + default: + return; + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDm + * + * PARAMETERS: Source - Pointer to the contiguous data fields + * Type - 16, 32, or 64 (bit) + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Decode fields common to address descriptors + * + ******************************************************************************/ + +static void +AcpiDmAddressFields ( + void *Source, + UINT8 Type, + UINT32 Level) +{ + ACPI_NATIVE_UINT i; + + + AcpiOsPrintf ("\n"); + + for (i = 0; i < 5; i++) + { + AcpiDmIndent (Level + 1); + + switch (Type) + { + case 16: + AcpiDmDumpInteger16 (((UINT16 *) Source)[i], AcpiDmAddressNames[i]); + break; + + case 32: + AcpiDmDumpInteger32 (((UINT32 *) Source)[i], AcpiDmAddressNames[i]); + break; + + case 64: + AcpiDmDumpInteger64 (((UINT64 *) Source)[i], AcpiDmAddressNames[i]); + break; + + default: + return; + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmAddressPrefix + * + * PARAMETERS: Type - Descriptor type + * + * RETURN: None + * + * DESCRIPTION: Emit name prefix representing the address descriptor type + * + ******************************************************************************/ + +static void +AcpiDmAddressPrefix ( + UINT8 Type) +{ + + switch (Type) + { + case ACPI_RESOURCE_TYPE_ADDRESS16: + AcpiOsPrintf ("Word"); + break; + + case ACPI_RESOURCE_TYPE_ADDRESS32: + AcpiOsPrintf ("DWord"); + break; + + case ACPI_RESOURCE_TYPE_ADDRESS64: + AcpiOsPrintf ("QWord"); + break; + + case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: + AcpiOsPrintf ("Extended"); + break; + + default: + return; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmAddressCommon + * + * PARAMETERS: Resource - Raw AML descriptor + * Type - Descriptor type + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Emit common name and flag fields common to address descriptors + * + ******************************************************************************/ + +static void +AcpiDmAddressCommon ( + AML_RESOURCE *Resource, + UINT8 Type, + UINT32 Level) +{ + UINT8 ResourceType; + UINT8 SpecificFlags; + UINT8 Flags; + + + ResourceType = Resource->Address.ResourceType; + SpecificFlags = Resource->Address.SpecificFlags; + Flags = Resource->Address.Flags; + + AcpiDmIndent (Level); + + /* Validate ResourceType */ + + if ((ResourceType > 2) && (ResourceType < 0xC0)) + { + AcpiOsPrintf ("/**** Invalid Resource Type: 0x%X ****/", ResourceType); + return; + } + + /* Prefix is either Word, DWord, QWord, or Extended */ + + AcpiDmAddressPrefix (Type); + + /* Resource Types above 0xC0 are vendor-defined */ + + if (ResourceType > 2) + { + AcpiOsPrintf ("Space (0x%2.2X, ", ResourceType); + AcpiDmSpaceFlags (Flags); + AcpiOsPrintf (" 0x%2.2X,", SpecificFlags); + return; + } + + /* This is either a Memory, IO, or BusNumber descriptor (0,1,2) */ + + AcpiOsPrintf ("%s (", AcpiGbl_WordDecode [ResourceType]); + + /* Decode the general and type-specific flags */ + + if (ResourceType == ACPI_MEMORY_RANGE) + { + AcpiDmMemoryFlags (Flags, SpecificFlags); + } + else /* IO range or BusNumberRange */ + { + AcpiDmIoFlags (Flags); + if (ResourceType == ACPI_IO_RANGE) + { + AcpiOsPrintf (" %s,", AcpiGbl_RNGDecode [SpecificFlags & 0x3]); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmAddressFlags + * + * PARAMETERS: Resource - Raw AML descriptor + * + * RETURN: None + * + * DESCRIPTION: Emit flags common to address descriptors + * + ******************************************************************************/ + +static void +AcpiDmAddressFlags ( + AML_RESOURCE *Resource) +{ + + if (Resource->Address.ResourceType == ACPI_IO_RANGE) + { + AcpiDmIoFlags2 (Resource->Address.SpecificFlags); + } + else if (Resource->Address.ResourceType == ACPI_MEMORY_RANGE) + { + AcpiDmMemoryFlags2 (Resource->Address.SpecificFlags); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmSpaceFlags + * + * PARAMETERS: Flags - Flag byte to be decoded + * + * RETURN: None + * + * DESCRIPTION: Decode the flags specific to Space Address space descriptors + * + ******************************************************************************/ + +static void +AcpiDmSpaceFlags ( + UINT8 Flags) +{ + + AcpiOsPrintf ("%s, %s, %s, %s,", + AcpiGbl_ConsumeDecode [(Flags & 1)], + AcpiGbl_DECDecode [(Flags & 0x2) >> 1], + AcpiGbl_MinDecode [(Flags & 0x4) >> 2], + AcpiGbl_MaxDecode [(Flags & 0x8) >> 3]); +} + + /******************************************************************************* * * FUNCTION: AcpiDmIoFlags @@ -137,7 +469,7 @@ * ******************************************************************************/ -void +static void AcpiDmIoFlags ( UINT8 Flags) { @@ -151,6 +483,36 @@ AcpiDmIoFlags ( /******************************************************************************* * + * FUNCTION: AcpiDmIoFlags2 + * + * PARAMETERS: SpecificFlags - "Specific" flag byte to be decoded + * + * RETURN: None + * + * DESCRIPTION: Decode the flags specific to IO Address space descriptors + * + ******************************************************************************/ + +static void +AcpiDmIoFlags2 ( + UINT8 SpecificFlags) +{ + + AcpiOsPrintf (", %s", + AcpiGbl_TTPDecode [(SpecificFlags & 0x10) >> 4]); + + /* TRS is only used if TTP is TypeTranslation */ + + if (SpecificFlags & 0x10) + { + AcpiOsPrintf (", %s", + AcpiGbl_TRSDecode [(SpecificFlags & 0x20) >> 5]); + } +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmMemoryFlags * * PARAMETERS: Flags - Flag byte to be decoded @@ -162,11 +524,12 @@ AcpiDmIoFlags ( * ******************************************************************************/ -void +static void AcpiDmMemoryFlags ( UINT8 Flags, UINT8 SpecificFlags) { + AcpiOsPrintf ("%s, %s, %s, %s, %s, %s,", AcpiGbl_ConsumeDecode [(Flags & 1)], AcpiGbl_DECDecode [(Flags & 0x2) >> 1], @@ -179,6 +542,93 @@ AcpiDmMemoryFlags ( /******************************************************************************* * + * FUNCTION: AcpiDmMemoryFlags2 + * + * PARAMETERS: SpecificFlags - "Specific" flag byte to be decoded + * + * RETURN: None + * + * DESCRIPTION: Decode flags specific to Memory Address Space descriptors + * + ******************************************************************************/ + +static void +AcpiDmMemoryFlags2 ( + UINT8 SpecificFlags) +{ + + AcpiOsPrintf (", %s, %s", + AcpiGbl_MTPDecode [(SpecificFlags & 0x18) >> 3], + AcpiGbl_TTPDecode [(SpecificFlags & 0x20) >> 5]); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDmResourceSource + * + * PARAMETERS: Resource - Raw AML descriptor + * MinimumLength - descriptor length without optional fields + * ResourceLength + * + * RETURN: None + * + * DESCRIPTION: Dump optional ResourceSource fields of an address descriptor + * + ******************************************************************************/ + +static void +AcpiDmResourceSource ( + AML_RESOURCE *Resource, + ACPI_SIZE MinimumTotalLength, + UINT32 ResourceLength) +{ + UINT8 *AmlResourceSource; + UINT32 TotalLength; + + + TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER); + + /* Check if the optional ResourceSource fields are present */ + + if (TotalLength <= MinimumTotalLength) + { + /* The two optional fields are not used */ + + AcpiOsPrintf (",,"); + return; + } + + /* Get a pointer to the ResourceSource */ + + AmlResourceSource = ((UINT8 *) Resource) + MinimumTotalLength; + + /* + * Always emit the ResourceSourceIndex (Byte) + * + * NOTE: Some ASL compilers always create a 0 byte (in the AML) for the + * Index even if the String does not exist. Although this is in violation + * of the ACPI specification, it is very important to emit ASL code that + * can be compiled back to the identical AML. There may be fields and/or + * indexes into the resource template buffer that are compiled to absolute + * offsets, and these will be broken if the AML length is changed. + */ + AcpiOsPrintf ("0x%2.2X,", (UINT32) AmlResourceSource[0]); + + /* Make sure that the ResourceSource string exists before dumping it */ + + if (TotalLength > (MinimumTotalLength + 1)) + { + AcpiOsPrintf (" "); + AcpiUtPrintString ((char *) &AmlResourceSource[1], ACPI_UINT8_MAX); + } + + AcpiOsPrintf (","); +} + + +/******************************************************************************* + * * FUNCTION: AcpiDmWordDescriptor * * PARAMETERS: Resource - Pointer to the resource descriptor @@ -193,55 +643,27 @@ AcpiDmMemoryFlags ( void AcpiDmWordDescriptor ( - ASL_WORD_ADDRESS_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { - AcpiDmIndent (Level); - AcpiOsPrintf ("%s (", - AcpiGbl_WordDecode [(Resource->ResourceType & 3)]); + /* Dump resource name and flags */ - AcpiDmIoFlags (Resource->Flags); + AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS16, Level); - if ((Resource->ResourceType & 0x3) == 1) - { - AcpiOsPrintf (" %s,", - AcpiGbl_RNGDecode [(Resource->SpecificFlags & 0x3)]); - } + /* Dump the 5 contiguous WORD values */ - /* The WORD values */ + AcpiDmAddressFields (&Resource->Address16.Granularity, 16, Level); - AcpiOsPrintf ("\n"); - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%4.4X,\n", - (UINT32) Resource->Granularity); - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%4.4X,\n", - (UINT32) Resource->AddressMin); - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%4.4X,\n", - (UINT32) Resource->AddressMax); - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%4.4X,\n", - (UINT32) Resource->TranslationOffset); - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%4.4X", - (UINT32) Resource->AddressLength); + /* The ResourceSource fields are optional */ - /* Optional fields */ + AcpiDmIndent (Level + 1); + AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS16), Length); - if (Length > 13) - { - AcpiOsPrintf (", 0x%2.2X", - (UINT32) Resource->OptionalFields[0]); - } + /* Type-specific flags */ - if (Length > 14) - { - AcpiOsPrintf (", %s", - &Resource->OptionalFields[1]); - } + AcpiDmAddressFlags (Resource); AcpiOsPrintf (")\n"); } @@ -262,57 +684,27 @@ AcpiDmWordDescriptor ( void AcpiDmDwordDescriptor ( - ASL_DWORD_ADDRESS_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { - AcpiDmIndent (Level); - AcpiOsPrintf ("D%s (", - AcpiGbl_WordDecode [(Resource->ResourceType & 3)]); + /* Dump resource name and flags */ - if ((Resource->ResourceType & 0x3) == 1) - { - AcpiDmIoFlags (Resource->Flags); - AcpiOsPrintf (" %s,", - AcpiGbl_RNGDecode [(Resource->SpecificFlags & 0x3)]); - } - else - { - AcpiDmMemoryFlags (Resource->Flags, Resource->SpecificFlags); - } + AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS32, Level); - /* The DWORD values */ + /* Dump the 5 contiguous DWORD values */ + + AcpiDmAddressFields (&Resource->Address32.Granularity, 32, Level); + + /* The ResourceSource fields are optional */ - AcpiOsPrintf ("\n"); - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X,\n", - Resource->Granularity); - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X,\n", - Resource->AddressMin); - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X,\n", - Resource->AddressMax); - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X,\n", - Resource->TranslationOffset); AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X", - Resource->AddressLength); + AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS32), Length); - /* Optional fields */ + /* Type-specific flags */ - if (Length > 23) - { - AcpiOsPrintf (", 0x%2.2X", - Resource->OptionalFields[0]); - } - if (Length > 24) - { - AcpiOsPrintf (", %s", - &Resource->OptionalFields[1]); - } + AcpiDmAddressFlags (Resource); AcpiOsPrintf (")\n"); } @@ -333,62 +725,70 @@ AcpiDmDwordDescriptor ( void AcpiDmQwordDescriptor ( - ASL_QWORD_ADDRESS_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { - AcpiDmIndent (Level); - AcpiOsPrintf ("Q%s (", - AcpiGbl_WordDecode [(Resource->ResourceType & 3)]); + /* Dump resource name and flags */ - if ((Resource->ResourceType & 0x3) == 1) - { - AcpiDmIoFlags (Resource->Flags); - AcpiOsPrintf (" %s,", - AcpiGbl_RNGDecode [(Resource->SpecificFlags & 0x3)]); - } - else - { - AcpiDmMemoryFlags (Resource->Flags, Resource->SpecificFlags); - } + AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS64, Level); - /* The QWORD values */ + /* Dump the 5 contiguous QWORD values */ - AcpiOsPrintf ("\n"); - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X%8.8X,\n", - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->Granularity))); + AcpiDmAddressFields (&Resource->Address64.Granularity, 64, Level); - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X%8.8X,\n", - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->AddressMin))); + /* The ResourceSource fields are optional */ AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X%8.8X,\n", - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->AddressMax))); + AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS64), Length); - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X%8.8X,\n", - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->TranslationOffset))); + /* Type-specific flags */ - AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X%8.8X", - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->AddressLength))); + AcpiDmAddressFlags (Resource); + AcpiOsPrintf (")\n"); +} - /* Optional fields */ - if (Length > 43) - { - AcpiOsPrintf (", 0x%2.2X", - Resource->OptionalFields[0]); - } - if (Length > 44) - { - AcpiOsPrintf (", %s", - &Resource->OptionalFields[1]); - } +/******************************************************************************* + * + * FUNCTION: AcpiDmExtendedDescriptor + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Length - Length of the descriptor in bytes + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Decode a Extended Address Space descriptor + * + ******************************************************************************/ + +void +AcpiDmExtendedDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level) +{ + + /* Dump resource name and flags */ + + AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, Level); + + /* Dump the 5 contiguous QWORD values */ + + AcpiDmAddressFields (&Resource->ExtAddress64.Granularity, 64, Level); + + /* Extra field for this descriptor only */ + AcpiDmIndent (Level + 1); + AcpiDmDumpInteger64 (Resource->ExtAddress64.TypeSpecific, + "Type-Specific Attributes"); + + /* Type-specific flags */ + + AcpiDmIndent (Level + 1); + AcpiDmAddressFlags (Resource); AcpiOsPrintf (")\n"); } @@ -409,18 +809,23 @@ AcpiDmQwordDescriptor ( void AcpiDmMemory24Descriptor ( - ASL_MEMORY_24_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { + /* Dump name and read/write flag */ + AcpiDmIndent (Level); - AcpiOsPrintf ("Memory24 (%s, 0x%4.4X, 0x%4.4X, 0x%4.4X, 0x%4.4X)\n", - AcpiGbl_RWDecode [Resource->Information & 1], - (UINT32) Resource->AddressMin, - (UINT32) Resource->AddressMax, - (UINT32) Resource->Alignment, - (UINT32) Resource->RangeLength); + AcpiOsPrintf ("Memory24 (%s,\n", + AcpiGbl_RWDecode [Resource->Memory24.Flags & 1]); + + /* Dump the 4 contiguous WORD values */ + + AcpiDmMemoryFields (&Resource->Memory24.Minimum, 16, Level); + + AcpiDmIndent (Level + 1); + AcpiOsPrintf (")\n"); } @@ -440,24 +845,29 @@ AcpiDmMemory24Descriptor ( void AcpiDmMemory32Descriptor ( - ASL_MEMORY_32_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { + /* Dump name and read/write flag */ + AcpiDmIndent (Level); - AcpiOsPrintf ("Memory32 (%s, 0x%8.8X, 0x%8.8X, 0x%8.8X, 0x%8.8X)\n", - AcpiGbl_RWDecode [Resource->Information & 1], - Resource->AddressMin, - Resource->AddressMax, - Resource->Alignment, - Resource->RangeLength); + AcpiOsPrintf ("Memory32 (%s,\n", + AcpiGbl_RWDecode [Resource->Memory32.Flags & 1]); + + /* Dump the 4 contiguous DWORD values */ + + AcpiDmMemoryFields (&Resource->Memory32.Minimum, 32, Level); + + AcpiDmIndent (Level + 1); + AcpiOsPrintf (")\n"); } /******************************************************************************* * - * FUNCTION: AcpiDmFixedMem32Descriptor + * FUNCTION: AcpiDmFixedMemory32Descriptor * * PARAMETERS: Resource - Pointer to the resource descriptor * Length - Length of the descriptor in bytes @@ -470,17 +880,26 @@ AcpiDmMemory32Descriptor ( ******************************************************************************/ void -AcpiDmFixedMem32Descriptor ( - ASL_FIXED_MEMORY_32_DESC *Resource, +AcpiDmFixedMemory32Descriptor ( + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { + /* Dump name and read/write flag */ + AcpiDmIndent (Level); - AcpiOsPrintf ("Memory32Fixed (%s, 0x%8.8X, 0x%8.8X)\n", - AcpiGbl_RWDecode [Resource->Information & 1], - Resource->BaseAddress, - Resource->RangeLength); + AcpiOsPrintf ("Memory32Fixed (%s,\n", + AcpiGbl_RWDecode [Resource->FixedMemory32.Flags & 1]); + + AcpiDmIndent (Level + 1); + AcpiDmDumpInteger32 (Resource->FixedMemory32.Address, "Address Base"); + + AcpiDmIndent (Level + 1); + AcpiDmDumpInteger32 (Resource->FixedMemory32.AddressLength, "Address Length"); + + AcpiDmIndent (Level + 1); + AcpiOsPrintf (")\n"); } @@ -500,20 +919,36 @@ AcpiDmFixedMem32Descriptor ( void AcpiDmGenericRegisterDescriptor ( - ASL_GENERAL_REGISTER_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { AcpiDmIndent (Level); AcpiOsPrintf ("Register ("); + AcpiDmAddressSpace (Resource->GenericReg.AddressSpaceId); + AcpiOsPrintf ("\n"); + + AcpiDmIndent (Level + 1); + AcpiDmDumpInteger8 (Resource->GenericReg.BitWidth, "Register Bit Width"); + + AcpiDmIndent (Level + 1); + AcpiDmDumpInteger8 (Resource->GenericReg.BitOffset, "Register Bit Offset"); - AcpiDmAddressSpace (Resource->AddressSpaceId); + AcpiDmIndent (Level + 1); + AcpiDmDumpInteger64 (Resource->GenericReg.Address, "Register Address"); + + /* Optional field for ACPI 3.0 */ + + if (Resource->GenericReg.AccessSize) + { + AcpiDmIndent (Level + 1); + AcpiOsPrintf ("0x%2.2X // %s\n", + Resource->GenericReg.AccessSize, "Access Size"); + } - AcpiOsPrintf ("0x%2.2X, 0x%2.2X, 0x%8.8X%8.8X)\n", - (UINT32) Resource->BitWidth, - (UINT32) Resource->BitOffset, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Resource->Address))); + AcpiDmIndent (Level + 1); + AcpiOsPrintf (")\n"); } @@ -533,42 +968,40 @@ AcpiDmGenericRegisterDescriptor ( void AcpiDmInterruptDescriptor ( - ASL_EXTENDED_XRUPT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { UINT32 i; - UINT8 *Rover; AcpiDmIndent (Level); - AcpiOsPrintf ("Interrupt (%s, %s, %s, %s", - AcpiGbl_ConsumeDecode [(Resource->Flags & 1)], - AcpiGbl_HEDecode [(Resource->Flags >> 1) & 1], - AcpiGbl_LLDecode [(Resource->Flags >> 2) & 1], - AcpiGbl_SHRDecode [(Resource->Flags >> 3) & 1]); - - /* Resource Index/Source, optional -- at end of descriptor */ - - if (Resource->Length > (UINT16) (4 * Resource->TableLength) + 2) - { - /* Get a pointer past the interrupt values */ - - Rover = ((UINT8 *) Resource) + ((4 * Resource->TableLength) + 5); - - /* Resource Index */ - /* Resource Source */ - - AcpiOsPrintf (", 0x%X, \"%s\"", (UINT32) Rover[0], (char *) &Rover[1]); - } + AcpiOsPrintf ("Interrupt (%s, %s, %s, %s, ", + AcpiGbl_ConsumeDecode [(Resource->ExtendedIrq.Flags & 1)], + AcpiGbl_HEDecode [(Resource->ExtendedIrq.Flags >> 1) & 1], + AcpiGbl_LLDecode [(Resource->ExtendedIrq.Flags >> 2) & 1], + AcpiGbl_SHRDecode [(Resource->ExtendedIrq.Flags >> 3) & 1]); + + /* + * The ResourceSource fields are optional and appear after the interrupt + * list. Must compute length based on length of the list. First xrupt + * is included in the struct (reason for -1 below) + */ + AcpiDmResourceSource (Resource, + sizeof (AML_RESOURCE_EXTENDED_IRQ) + + (Resource->ExtendedIrq.InterruptCount - 1) * sizeof (UINT32), + Resource->ExtendedIrq.ResourceLength); + + /* Dump the interrupt list */ AcpiOsPrintf (")\n"); AcpiDmIndent (Level); AcpiOsPrintf ("{\n"); - for (i = 0; i < Resource->TableLength; i++) + for (i = 0; i < Resource->ExtendedIrq.InterruptCount; i++) { AcpiDmIndent (Level + 1); - AcpiOsPrintf ("0x%8.8X,\n", (UINT32) Resource->InterruptNumber[i]); + AcpiOsPrintf ("0x%8.8X,\n", + (UINT32) Resource->ExtendedIrq.Interrupts[i]); } AcpiDmIndent (Level); @@ -578,36 +1011,69 @@ AcpiDmInterruptDescriptor ( /******************************************************************************* * - * FUNCTION: AcpiDmVendorLargeDescriptor + * FUNCTION: AcpiDmVendorCommon * - * PARAMETERS: Resource - Pointer to the resource descriptor - * Length - Length of the descriptor in bytes + * PARAMETERS: Name - Descriptor name suffix + * ByteData - Pointer to the vendor byte data + * Length - Length of the byte data * Level - Current source code indentation level * * RETURN: None * - * DESCRIPTION: Decode a Vendor Large descriptor + * DESCRIPTION: Decode a Vendor descriptor, both Large and Small * ******************************************************************************/ void -AcpiDmVendorLargeDescriptor ( - ASL_LARGE_VENDOR_DESC *Resource, +AcpiDmVendorCommon ( + char *Name, + UINT8 *ByteData, UINT32 Length, UINT32 Level) { + /* Dump descriptor name */ + AcpiDmIndent (Level); - AcpiOsPrintf ("VendorLong ()\n"); - AcpiDmIndent (Level); + AcpiOsPrintf ("Vendor%s // Length = 0x%.2X\n", Name, Length); + + /* Dump the vendor bytes */ + AcpiDmIndent (Level); AcpiOsPrintf ("{\n"); - AcpiDmDisasmByteList (Level + 1, (UINT8 *) Resource->VendorDefined, Length); + AcpiDmDisasmByteList (Level + 1, ByteData, Length); + AcpiDmIndent (Level); AcpiOsPrintf ("}\n"); } +/******************************************************************************* + * + * FUNCTION: AcpiDmVendorLargeDescriptor + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Length - Length of the descriptor in bytes + * Level - Current source code indentation level + * + * RETURN: None + * + * DESCRIPTION: Decode a Vendor Large descriptor + * + ******************************************************************************/ + +void +AcpiDmVendorLargeDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level) +{ + + AcpiDmVendorCommon ("Long () ", + ((UINT8 *) Resource) + sizeof (AML_RESOURCE_LARGE_HEADER), + Length, Level); +} + #endif diff --git a/sys/contrib/dev/acpica/dmresrcs.c b/sys/contrib/dev/acpica/dmresrcs.c index 2d13867..78b5826 100644 --- a/sys/contrib/dev/acpica/dmresrcs.c +++ b/sys/contrib/dev/acpica/dmresrcs.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmresrcs.c - "Small" Resource Descriptor disassembly - * $Revision: 5 $ + * $Revision: 1.10 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -135,13 +135,13 @@ * * RETURN: None * - * DESCRIPTION: Decode a IRQ descriptor + * DESCRIPTION: Decode a IRQ descriptor, either Irq() or IrqNoFlags() * ******************************************************************************/ void AcpiDmIrqDescriptor ( - ASL_IRQ_FORMAT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { @@ -150,15 +150,19 @@ AcpiDmIrqDescriptor ( AcpiOsPrintf ("%s (", AcpiGbl_IrqDecode [Length & 1]); + /* Decode flags byte if present */ + if (Length & 1) { AcpiOsPrintf ("%s, %s, %s", - AcpiGbl_HEDecode [Resource->Flags & 1], - AcpiGbl_LLDecode [(Resource->Flags >> 3) & 1], - AcpiGbl_SHRDecode [(Resource->Flags >> 4) & 1]); + AcpiGbl_HEDecode [Resource->Irq.Flags & 1], + AcpiGbl_LLDecode [(Resource->Irq.Flags >> 3) & 1], + AcpiGbl_SHRDecode [(Resource->Irq.Flags >> 4) & 1]); } + AcpiOsPrintf (")\n"); - AcpiDmBitList (Resource->IrqMask); + AcpiDmIndent (Level + 1); + AcpiDmBitList (Resource->Irq.IrqMask); } @@ -178,18 +182,19 @@ AcpiDmIrqDescriptor ( void AcpiDmDmaDescriptor ( - ASL_DMA_FORMAT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { AcpiDmIndent (Level); - AcpiOsPrintf ("DMA (%s, %s, %s", - AcpiGbl_TYPDecode [(Resource->Flags >> 5) & 3], - AcpiGbl_BMDecode [(Resource->Flags >> 2) & 1], - AcpiGbl_SIZDecode [(Resource->Flags >> 0) & 3]); + AcpiOsPrintf ("DMA (%s, %s, %s)\n", + AcpiGbl_TYPDecode [(Resource->Dma.Flags >> 5) & 3], + AcpiGbl_BMDecode [(Resource->Dma.Flags >> 2) & 1], + AcpiGbl_SIZDecode [(Resource->Dma.Flags >> 0) & 3]); - AcpiDmBitList (Resource->DmaChannelMask); + AcpiDmIndent (Level + 1); + AcpiDmBitList (Resource->Dma.DmaChannelMask); } @@ -209,18 +214,29 @@ AcpiDmDmaDescriptor ( void AcpiDmIoDescriptor ( - ASL_IO_PORT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { AcpiDmIndent (Level); - AcpiOsPrintf ("IO (%s, 0x%4.4X, 0x%4.4X, 0x%2.2X, 0x%2.2X)\n", - AcpiGbl_IoDecode [(Resource->Information & 1)], - (UINT32) Resource->AddressMin, - (UINT32) Resource->AddressMax, - (UINT32) Resource->Alignment, - (UINT32) Resource->Length); + AcpiOsPrintf ("IO (%s,\n", + AcpiGbl_IoDecode [(Resource->Io.Flags & 1)]); + + AcpiDmIndent (Level + 1); + AcpiDmDumpInteger16 (Resource->Io.Minimum, "Address Range Minimum"); + + AcpiDmIndent (Level + 1); + AcpiDmDumpInteger16 (Resource->Io.Maximum, "Address Range Maximum"); + + AcpiDmIndent (Level + 1); + AcpiDmDumpInteger8 (Resource->Io.Alignment, "Address Alignment"); + + AcpiDmIndent (Level + 1); + AcpiDmDumpInteger8 (Resource->Io.AddressLength, "Address Length"); + + AcpiDmIndent (Level + 1); + AcpiOsPrintf (")\n"); } @@ -240,15 +256,22 @@ AcpiDmIoDescriptor ( void AcpiDmFixedIoDescriptor ( - ASL_FIXED_IO_PORT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { AcpiDmIndent (Level); - AcpiOsPrintf ("FixedIO (0x%4.4X, 0x%2.2X)\n", - (UINT32) Resource->BaseAddress, - (UINT32) Resource->Length); + AcpiOsPrintf ("FixedIO (\n"); + + AcpiDmIndent (Level + 1); + AcpiDmDumpInteger16 (Resource->FixedIo.Address, "Address Base"); + + AcpiDmIndent (Level + 1); + AcpiDmDumpInteger8 (Resource->FixedIo.AddressLength, "Address Length"); + + AcpiDmIndent (Level + 1); + AcpiOsPrintf (")\n"); } @@ -268,7 +291,7 @@ AcpiDmFixedIoDescriptor ( void AcpiDmStartDependentDescriptor ( - ASL_START_DEPENDENT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { @@ -278,8 +301,8 @@ AcpiDmStartDependentDescriptor ( if (Length & 1) { AcpiOsPrintf ("StartDependentFn (0x%2.2X, 0x%2.2X)\n", - (UINT32) Resource->Flags & 3, - (UINT32) (Resource->Flags >> 2) & 3); + (UINT32) Resource->StartDpf.Flags & 3, + (UINT32) (Resource->StartDpf.Flags >> 2) & 3); } else { @@ -307,7 +330,7 @@ AcpiDmStartDependentDescriptor ( void AcpiDmEndDependentDescriptor ( - ASL_START_DEPENDENT_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { @@ -335,18 +358,15 @@ AcpiDmEndDependentDescriptor ( void AcpiDmVendorSmallDescriptor ( - ASL_SMALL_VENDOR_DESC *Resource, + AML_RESOURCE *Resource, UINT32 Length, UINT32 Level) { - AcpiDmIndent (Level); - AcpiOsPrintf ("VendorShort () {"); - - AcpiDmDisasmByteList (0, (UINT8 *) Resource->VendorDefined, Length); - AcpiOsPrintf ("}\n"); + AcpiDmVendorCommon ("Short ()", + ((UINT8 *) Resource) + sizeof (AML_RESOURCE_SMALL_HEADER), + Length, Level); } #endif - diff --git a/sys/contrib/dev/acpica/dmutils.c b/sys/contrib/dev/acpica/dmutils.c index f38ee49..002f835 100644 --- a/sys/contrib/dev/acpica/dmutils.c +++ b/sys/contrib/dev/acpica/dmutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: dmutils - AML disassembler utilities - * $Revision: 10 $ + * $Revision: 1.19 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -118,8 +118,10 @@ #include <contrib/dev/acpica/acpi.h> #include <contrib/dev/acpica/amlcode.h> #include <contrib/dev/acpica/acdisasm.h> -#include <contrib/dev/acpica/acnamesp.h> +#ifdef ACPI_ASL_COMPILER +#include <contrib/dev/acpica/acnamesp.h> +#endif #ifdef ACPI_DISASSEMBLER @@ -192,9 +194,9 @@ const char *AcpiGbl_IoDecode[2] = const char *AcpiGbl_WordDecode[4] = { - "WordMemory", - "WordIO", - "WordBusNumber", + "Memory", + "IO", + "BusNumber", "Unknown-resource-type" }; @@ -222,28 +224,6 @@ const char *AcpiGbl_DECDecode[2] = "SubDecode" }; -const char *AcpiGbl_RNGDecode[4] = -{ - "InvalidRanges", - "NonISAOnlyRanges", - "ISAOnlyRanges", - "EntireRange" -}; - -const char *AcpiGbl_MEMDecode[4] = -{ - "NonCacheable", - "Cacheable", - "WriteCombining", - "Prefetchable" -}; - -const char *AcpiGbl_RWDecode[2] = -{ - "ReadOnly", - "ReadWrite" -}; - const char *AcpiGbl_IrqDecode[2] = { "IRQNoFlags", @@ -290,7 +270,60 @@ const char *AcpiGbl_SIZDecode[4] = "InvalidSize" }; +/* Type Specific Flags */ + +const char *AcpiGbl_TTPDecode[2] = +{ + "TypeStatic", + "TypeTranslation" +}; + +const char *AcpiGbl_MTPDecode[4] = +{ + "AddressRangeMemory", + "AddressRangeReserved", + "AddressRangeACPI", + "AddressRangeNVS" +}; +const char *AcpiGbl_MEMDecode[4] = +{ + "NonCacheable", + "Cacheable", + "WriteCombining", + "Prefetchable" +}; + +const char *AcpiGbl_RWDecode[2] = +{ + "ReadOnly", + "ReadWrite" +}; + +const char *AcpiGbl_TRSDecode[2] = +{ + "DenseTranslation", + "SparseTranslation" +}; + +const char *AcpiGbl_RNGDecode[4] = +{ + "InvalidRanges", + "NonISAOnlyRanges", + "ISAOnlyRanges", + "EntireRange" +}; + +const char *AcpiGbl_ConfigDecode[4] = +{ + "0 - Good Configuration", + "1 - Acceptable Configuration", + "2 - Suboptimal Configuration", + "3 - ***Invalid Configuration***", +}; + + +#ifdef ACPI_ASL_COMPILER /******************************************************************************* * * FUNCTION: AcpiDmAddToExternalList @@ -339,7 +372,7 @@ AcpiDmAddToExternalList ( AcpiGbl_ExternalList = NewExternal; } } - +#endif /******************************************************************************* * @@ -514,5 +547,4 @@ AcpiDmCommaIfFieldMember ( } } - #endif diff --git a/sys/contrib/dev/acpica/dmwalk.c b/sys/contrib/dev/acpica/dmwalk.c index 55dd484..d6a1be7 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: 14 $ + * $Revision: 1.24 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -128,14 +128,40 @@ ACPI_MODULE_NAME ("dmwalk") -#define DB_FULL_OP_INFO "%5.5X #%4.4hX " +#define DB_FULL_OP_INFO "[%4.4s] @%5.5X #%4.4X: " + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDmDescendingOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static ACPI_STATUS +AcpiDmAscendingOp ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +static void +AcpiDmWalkParseTree ( + ACPI_PARSE_OBJECT *Op, + ASL_WALK_CALLBACK DescendingCallback, + ASL_WALK_CALLBACK AscendingCallback, + void *Context); + +static UINT32 +AcpiDmBlockType ( + ACPI_PARSE_OBJECT *Op); /******************************************************************************* * * FUNCTION: AcpiDmDisassemble * - * PARAMETERS: Origin - Starting object + * PARAMETERS: WalkState - Current state + * Origin - Starting object * NumOpcodes - Max number of opcodes to be displayed * * RETURN: None @@ -161,8 +187,8 @@ AcpiDmDisassemble ( } Info.Level = 0; + Info.WalkState = WalkState; AcpiDmWalkParseTree (Op, AcpiDmDescendingOp, AcpiDmAscendingOp, &Info); - return; } @@ -171,7 +197,8 @@ AcpiDmDisassemble ( * * FUNCTION: AcpiDmWalkParseTree * - * PARAMETERS: DescendingCallback - Called during tree descent + * PARAMETERS: Op - Root Op object + * DescendingCallback - Called during tree descent * AscendingCallback - Called during tree ascent * Context - To be passed to the callbacks * @@ -181,7 +208,7 @@ AcpiDmDisassemble ( * ******************************************************************************/ -void +static void AcpiDmWalkParseTree ( ACPI_PARSE_OBJECT *Op, ASL_WALK_CALLBACK DescendingCallback, @@ -281,13 +308,13 @@ AcpiDmWalkParseTree ( * * PARAMETERS: Op - Object to be examined * - * RETURN: Status + * RETURN: BlockType - not a block, parens, braces, or even both. * * DESCRIPTION: Type of block for this op (parens or braces) * ******************************************************************************/ -UINT32 +static UINT32 AcpiDmBlockType ( ACPI_PARSE_OBJECT *Op) { @@ -356,7 +383,7 @@ AcpiDmBlockType ( * * PARAMETERS: Op - Object to be examined * - * RETURN: Status + * RETURN: ListType - has commas or not. * * DESCRIPTION: Type of block for this op (parens or braces) * @@ -390,7 +417,7 @@ AcpiDmListType ( case AML_INDEX_FIELD_OP: case AML_BANK_FIELD_OP: - return (0); + return (BLOCK_NONE); case AML_BUFFER_OP: case AML_PACKAGE_OP: @@ -424,7 +451,7 @@ AcpiDmListType ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDmDescendingOp ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -450,8 +477,13 @@ AcpiDmDescendingOp ( { /* In verbose mode, print the AML offset, opcode and depth count */ - VERBOSE_PRINT ((DB_FULL_OP_INFO, (UINT32) Op->Common.AmlOffset, - Op->Common.AmlOpcode)); + if (Info->WalkState) + { + VERBOSE_PRINT ((DB_FULL_OP_INFO, + (Info->WalkState->MethodNode ? + Info->WalkState->MethodNode->Name.Ascii : " "), + Op->Common.AmlOffset, (UINT32) Op->Common.AmlOpcode)); + } if (Op->Common.AmlOpcode == AML_SCOPE_OP) { @@ -463,13 +495,17 @@ AcpiDmDescendingOp ( if (AcpiGbl_ExternalList) { - AcpiOsPrintf (" /*\n * These objects were referenced but not defined in this table\n */\n"); - - /* Walk the list of externals (unresolved references) found during parsing */ + AcpiOsPrintf ( + " /*\n * These objects were referenced but not defined in this table\n */\n"); + /* + * Walk the list of externals (unresolved references) + * found during parsing + */ while (AcpiGbl_ExternalList) { - AcpiOsPrintf (" External (%s, DeviceObj)\n", AcpiGbl_ExternalList->Path); + AcpiOsPrintf (" External (%s, DeviceObj)\n", + AcpiGbl_ExternalList->Path); NextExternal = AcpiGbl_ExternalList->Next; ACPI_MEM_FREE (AcpiGbl_ExternalList->Path); @@ -486,8 +522,10 @@ AcpiDmDescendingOp ( (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) && (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) { - /* This is a first-level element of a term list, indent a new line */ - + /* + * This is a first-level element of a term list, + * indent a new line + */ AcpiDmIndent (Level); } @@ -542,10 +580,8 @@ AcpiDmDescendingOp ( AcpiDmDumpName ((char *) &Name); } - if (Op->Common.AmlOpcode != AML_INT_NAMEDFIELD_OP) { - AcpiDmValidateName ((char *) &Name, Op); if (AcpiGbl_DbOpt_verbose) { (void) AcpiPsDisplayObjectPathname (NULL, Op); @@ -567,7 +603,7 @@ AcpiDmDescendingOp ( /* Check for _HID and related EISAID() */ - AcpiIsEisaId (Op); + AcpiDmIsEisaId (Op); AcpiOsPrintf (", "); break; @@ -780,7 +816,7 @@ AcpiDmDescendingOp ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDmAscendingOp ( ACPI_PARSE_OBJECT *Op, UINT32 Level, @@ -820,8 +856,10 @@ AcpiDmAscendingOp ( (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) && (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) { - /* This is a first-level element of a term list, start a new line */ - + /* + * This is a first-level element of a term list + * start a new line + */ AcpiOsPrintf ("\n"); } } @@ -879,8 +917,10 @@ AcpiDmAscendingOp ( (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) && (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP)) { - /* This is a first-level element of a term list, start a new line */ - + /* + * This is a first-level element of a term list + * start a new line + */ AcpiOsPrintf ("\n"); } } @@ -925,7 +965,8 @@ AcpiDmAscendingOp ( } else { - Op->Common.Parent->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST; + Op->Common.Parent->Common.DisasmFlags |= + ACPI_PARSEOP_EMPTY_TERMLIST; AcpiOsPrintf (") {"); } } diff --git a/sys/contrib/dev/acpica/dsfield.c b/sys/contrib/dev/acpica/dsfield.c index 75c9d47..fd3745f 100644 --- a/sys/contrib/dev/acpica/dsfield.c +++ b/sys/contrib/dev/acpica/dsfield.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsfield - Dispatcher field routines - * $Revision: 74 $ + * $Revision: 1.78 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -127,13 +127,20 @@ #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsfield") +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsGetFieldNames ( + ACPI_CREATE_FIELD_INFO *Info, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg); + /******************************************************************************* * * FUNCTION: AcpiDsCreateBufferField * - * PARAMETERS: Opcode - The opcode to be executed - * Operands - List of operands for the opcode + * PARAMETERS: Op - Current parse op (CreateXXField) * WalkState - Current state * * RETURN: Status @@ -144,7 +151,7 @@ * CreateWordFieldOp, * CreateDWordFieldOp, * CreateQWordFieldOp, - * CreateFieldOp (all of which define fields in buffers) + * CreateFieldOp (all of which define a field in a buffer) * ******************************************************************************/ @@ -200,7 +207,8 @@ AcpiDsCreateBufferField ( } else { - Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND; + Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND; } /* @@ -216,16 +224,16 @@ AcpiDsCreateBufferField ( } } - /* We could put the returned object (Node) on the object stack for later, but - * for now, we will put it in the "op" object that the parser uses, so we - * can get it again at the end of this scope + /* We could put the returned object (Node) on the object stack for later, + * but for now, we will put it in the "op" object that the parser uses, + * so we can get it again at the end of this scope */ Op->Common.Node = Node; /* - * If there is no object attached to the node, this node was just created and - * we need to create the field object. Otherwise, this was a lookup of an - * existing node and we don't want to create the field object again. + * If there is no object attached to the node, this node was just created + * and we need to create the field object. Otherwise, this was a lookup + * of an existing node and we don't want to create the field object again. */ ObjDesc = AcpiNsGetAttachedObject (Node); if (ObjDesc) @@ -290,7 +298,7 @@ Cleanup: * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsGetFieldNames ( ACPI_CREATE_FIELD_INFO *Info, ACPI_WALK_STATE *WalkState, @@ -326,7 +334,8 @@ AcpiDsGetFieldNames ( if (Position > ACPI_UINT32_MAX) { - ACPI_REPORT_ERROR (("Bit offset within field too large (> 0xFFFFFFFF)\n")); + ACPI_REPORT_ERROR (( + "Bit offset within field too large (> 0xFFFFFFFF)\n")); return_ACPI_STATUS (AE_SUPPORT); } @@ -338,12 +347,15 @@ AcpiDsGetFieldNames ( /* * Get a new AccessType and AccessAttribute -- to be used for all - * field units that follow, until field end or another AccessAs keyword. + * field units that follow, until field end or another AccessAs + * keyword. * - * In FieldFlags, preserve the flag bits other than the ACCESS_TYPE bits + * In FieldFlags, preserve the flag bits other than the + * ACCESS_TYPE bits */ - Info->FieldFlags = (UINT8) ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | - ((UINT8) ((UINT32) Arg->Common.Value.Integer >> 8))); + Info->FieldFlags = (UINT8) + ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | + ((UINT8) ((UINT32) Arg->Common.Value.Integer >> 8))); Info->Attribute = (UINT8) (Arg->Common.Value.Integer); break; @@ -355,7 +367,8 @@ AcpiDsGetFieldNames ( Status = AcpiNsLookup (WalkState->ScopeInfo, (char *) &Arg->Named.Name, - Info->FieldType, ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, + Info->FieldType, ACPI_IMODE_EXECUTE, + ACPI_NS_DONT_OPEN_SCOPE, WalkState, &Info->FieldNode); if (ACPI_FAILURE (Status)) { @@ -388,8 +401,9 @@ AcpiDsGetFieldNames ( if (Position > ACPI_UINT32_MAX) { - ACPI_REPORT_ERROR (("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", - (char *) &Info->FieldNode->Name)); + ACPI_REPORT_ERROR (( + "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", + (char *) &Info->FieldNode->Name)); return_ACPI_STATUS (AE_SUPPORT); } @@ -399,7 +413,8 @@ AcpiDsGetFieldNames ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid opcode in field list: %X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid opcode in field list: %X\n", Arg->Common.AmlOpcode)); return_ACPI_STATUS (AE_AML_BAD_OPCODE); } @@ -533,7 +548,8 @@ AcpiDsInitFieldObjects ( Status = AcpiNsLookup (WalkState->ScopeInfo, (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1, - ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, + ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND, WalkState, &Node); if (ACPI_FAILURE (Status)) { diff --git a/sys/contrib/dev/acpica/dsinit.c b/sys/contrib/dev/acpica/dsinit.c index 22c9dac..8bcde17 100644 --- a/sys/contrib/dev/acpica/dsinit.c +++ b/sys/contrib/dev/acpica/dsinit.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsinit - Object initialization namespace walk - * $Revision: 10 $ + * $Revision: 1.17 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,12 +123,21 @@ #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsinit") +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + /******************************************************************************* * * FUNCTION: AcpiDsInitOneObject * - * PARAMETERS: ObjHandle - Node + * PARAMETERS: ObjHandle - Node for the object * Level - Current nesting level * Context - Points to a init info struct * ReturnValue - Not used @@ -144,27 +153,27 @@ * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsInitOneObject ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue) { + ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; ACPI_OBJECT_TYPE Type; ACPI_STATUS Status; - ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; ACPI_FUNCTION_NAME ("DsInitOneObject"); /* - * We are only interested in objects owned by the table that + * We are only interested in NS nodes owned by the table that * was just loaded */ - if (((ACPI_NAMESPACE_NODE *) ObjHandle)->OwnerId != - Info->TableDesc->TableId) + if (Node->OwnerId != Info->TableDesc->OwnerId) { return (AE_OK); } @@ -182,7 +191,8 @@ AcpiDsInitOneObject ( Status = AcpiDsInitializeRegion (ObjHandle); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %p [%4.4s] - Init failure, %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Region %p [%4.4s] - Init failure, %s\n", ObjHandle, AcpiUtGetNodeName (ObjHandle), AcpiFormatException (Status))); } @@ -193,10 +203,10 @@ AcpiDsInitOneObject ( case ACPI_TYPE_METHOD: - Info->MethodCount++; - - /* Print a dot for each method unless we are going to print the entire pathname */ - + /* + * Print a dot for each method unless we are going to print + * the entire pathname + */ if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); @@ -210,7 +220,7 @@ AcpiDsInitOneObject ( */ if (Info->TableDesc->Pointer->Revision == 1) { - ((ACPI_NAMESPACE_NODE *) ObjHandle)->Flags |= ANOBJ_DATA_WIDTH_32; + Node->Flags |= ANOBJ_DATA_WIDTH_32; } /* @@ -220,21 +230,15 @@ AcpiDsInitOneObject ( Status = AcpiDsParseMethod (ObjHandle); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "\n+Method %p [%4.4s] - parse failure, %s\n", ObjHandle, AcpiUtGetNodeName (ObjHandle), AcpiFormatException (Status))); /* This parse failed, but we will continue parsing more methods */ - - break; } - /* - * Delete the parse tree. We simply re-parse the method - * for every execution since there isn't much overhead - */ - AcpiNsDeleteNamespaceSubtree (ObjHandle); - AcpiNsDeleteNamespaceByOwner (((ACPI_NAMESPACE_NODE *) ObjHandle)->Object->Method.OwningId); + Info->MethodCount++; break; @@ -304,7 +308,7 @@ AcpiDsInitializeObjects ( ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n", - TableDesc->Pointer->Signature, TableDesc->TableId, Info.ObjectCount, + TableDesc->Pointer->Signature, TableDesc->OwnerId, Info.ObjectCount, Info.DeviceCount, Info.MethodCount, Info.OpRegionCount)); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, diff --git a/sys/contrib/dev/acpica/dsmethod.c b/sys/contrib/dev/acpica/dsmethod.c index 783b3ce..e66c828 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: 101 $ + * $Revision: 1.110 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -132,12 +132,11 @@ * * FUNCTION: AcpiDsParseMethod * - * PARAMETERS: ObjHandle - Method node + * PARAMETERS: Node - Method node * * RETURN: Status * - * DESCRIPTION: Call the parser and parse the AML that is associated with the - * method. + * DESCRIPTION: Parse the AML that is associated with the method. * * MUTEX: Assumes parser is locked * @@ -145,32 +144,29 @@ ACPI_STATUS AcpiDsParseMethod ( - ACPI_HANDLE ObjHandle) + ACPI_NAMESPACE_NODE *Node) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_PARSE_OBJECT *Op; - ACPI_NAMESPACE_NODE *Node; - ACPI_OWNER_ID OwnerId; ACPI_WALK_STATE *WalkState; - ACPI_FUNCTION_TRACE_PTR ("DsParseMethod", ObjHandle); + ACPI_FUNCTION_TRACE_PTR ("DsParseMethod", Node); /* Parameter Validation */ - if (!ObjHandle) + if (!Node) { return_ACPI_STATUS (AE_NULL_ENTRY); } ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Parsing [%4.4s] **** NamedObj=%p\n", - AcpiUtGetNodeName (ObjHandle), ObjHandle)); + AcpiUtGetNodeName (Node), Node)); /* Extract the method object from the method Node */ - Node = (ACPI_NAMESPACE_NODE *) ObjHandle; ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { @@ -211,15 +207,20 @@ AcpiDsParseMethod ( * objects (such as Operation Regions) can be created during the * first pass parse. */ - OwnerId = AcpiUtAllocateOwnerId (ACPI_OWNER_TYPE_METHOD); - ObjDesc->Method.OwningId = OwnerId; + Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } /* Create and initialize a new walk state */ - WalkState = AcpiDsCreateWalkState (OwnerId, NULL, NULL, NULL); + WalkState = AcpiDsCreateWalkState ( + ObjDesc->Method.OwnerId, NULL, NULL, NULL); if (!WalkState) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto Cleanup2; } Status = AcpiDsInitAmlWalk (WalkState, Op, Node, @@ -228,29 +229,40 @@ AcpiDsParseMethod ( if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); - return_ACPI_STATUS (Status); + goto Cleanup2; } /* * Parse the method, first pass * - * The first pass load is where newly declared named objects are - * added into the namespace. Actual evaluation of - * the named objects (what would be called a "second - * pass") happens during the actual execution of the - * method so that operands to the named objects can - * take on dynamic run-time values. + * The first pass load is where newly declared named objects are added into + * the namespace. Actual evaluation of the named objects (what would be + * called a "second pass") happens during the actual execution of the + * method so that operands to the named objects can take on dynamic + * run-time values. */ Status = AcpiPsParseAml (WalkState); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto Cleanup2; } ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** [%4.4s] Parsed **** NamedObj=%p Op=%p\n", - AcpiUtGetNodeName (ObjHandle), ObjHandle, Op)); + AcpiUtGetNodeName (Node), Node, Op)); + /* + * Delete the parse tree. We simply re-parse the method for every + * execution since there isn't much overhead (compared to keeping lots + * of parse trees around) + */ + AcpiNsDeleteNamespaceSubtree (Node); + AcpiNsDeleteNamespaceByOwner (ObjDesc->Method.OwnerId); + +Cleanup2: + AcpiUtReleaseOwnerId (&ObjDesc->Method.OwnerId); + +Cleanup: AcpiPsDeleteParseTree (Op); return_ACPI_STATUS (Status); } @@ -289,6 +301,15 @@ AcpiDsBeginMethodExecution ( return_ACPI_STATUS (AE_NULL_ENTRY); } + /* Prevent wraparound of thread count */ + + if (ObjDesc->Method.ThreadCount == ACPI_UINT8_MAX) + { + ACPI_REPORT_ERROR (( + "Method reached maximum reentrancy limit (255)\n")); + return_ACPI_STATUS (AE_AML_METHOD_LIMIT); + } + /* * If there is a concurrency limit on this method, we need to * obtain a unit from the method semaphore. @@ -320,6 +341,20 @@ AcpiDsBeginMethodExecution ( } /* + * Allocate an Owner ID for this method, only if this is the first thread + * to begin concurrent execution. We only need one OwnerId, even if the + * method is invoked recursively. + */ + if (!ObjDesc->Method.OwnerId) + { + Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* * Increment the method parse tree thread count since it has been * reentered one more time (even if it is the same thread) */ @@ -350,7 +385,7 @@ AcpiDsCallControlMethod ( { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *MethodNode; - ACPI_WALK_STATE *NextWalkState; + ACPI_WALK_STATE *NextWalkState = NULL; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_PARAMETER_INFO Info; UINT32 i; @@ -376,22 +411,20 @@ AcpiDsCallControlMethod ( return_ACPI_STATUS (AE_NULL_OBJECT); } - ObjDesc->Method.OwningId = AcpiUtAllocateOwnerId (ACPI_OWNER_TYPE_METHOD); - /* Init for new method, wait on concurrency semaphore */ Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc, ThisWalkState->MethodNode); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto Cleanup; } if (!(ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY)) { /* 1) Parse: Create a new walk state for the preempting walk */ - NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwningId, + NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwnerId, Op, ObjDesc, NULL); if (!NextWalkState) { @@ -424,7 +457,7 @@ AcpiDsCallControlMethod ( /* 2) Execute: Create a new state for the preempting walk */ - NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwningId, + NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwnerId, NULL, ObjDesc, Thread); if (!NextWalkState) { @@ -433,9 +466,8 @@ AcpiDsCallControlMethod ( } /* * The resolved arguments were put on the previous walk state's operand - * stack. Operands on the previous walk state stack always - * start at index 0. - * Null terminate the list of arguments + * stack. Operands on the previous walk state stack always + * start at index 0. Also, null terminate the list of arguments */ ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL; @@ -470,22 +502,22 @@ AcpiDsCallControlMethod ( if (ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) { Status = ObjDesc->Method.Implementation (NextWalkState); - return_ACPI_STATUS (Status); } - return_ACPI_STATUS (AE_OK); - + return_ACPI_STATUS (Status); - /* On error, we must delete the new walk state */ Cleanup: + /* Decrement the thread count on the method parse tree */ + if (NextWalkState && (NextWalkState->MethodDesc)) { - /* Decrement the thread count on the method parse tree */ - - NextWalkState->MethodDesc->Method.ThreadCount--; + NextWalkState->MethodDesc->Method.ThreadCount--; } - (void) AcpiDsTerminateControlMethod (NextWalkState); + + /* On error, we must delete the new walk state */ + + AcpiDsTerminateControlMethod (NextWalkState); AcpiDsDeleteWalkState (NextWalkState); return_ACPI_STATUS (Status); } @@ -549,7 +581,16 @@ AcpiDsRestartControlMethod ( */ WalkState->ReturnDesc = ReturnDesc; } - else + + /* + * 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. + */ + else if (!AcpiDsDoImplicitReturn (ReturnDesc, WalkState, FALSE)) { /* * Delete the return value if it will not be used by the @@ -569,7 +610,7 @@ AcpiDsRestartControlMethod ( * * PARAMETERS: WalkState - State of the method * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Terminate a control method. Delete everything that the method * created, delete all locals and arguments, and delete the parse @@ -577,7 +618,7 @@ AcpiDsRestartControlMethod ( * ******************************************************************************/ -ACPI_STATUS +void AcpiDsTerminateControlMethod ( ACPI_WALK_STATE *WalkState) { @@ -591,7 +632,7 @@ AcpiDsTerminateControlMethod ( if (!WalkState) { - return (AE_BAD_PARAMETER); + return_VOID; } /* The current method object was saved in the walk state */ @@ -599,7 +640,7 @@ AcpiDsTerminateControlMethod ( ObjDesc = WalkState->MethodDesc; if (!ObjDesc) { - return_ACPI_STATUS (AE_OK); + return_VOID; } /* Delete all arguments and locals */ @@ -614,7 +655,7 @@ AcpiDsTerminateControlMethod ( Status = AcpiUtAcquireMutex (ACPI_MTX_PARSER); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + return_VOID; } /* Signal completion of the execution of this method if necessary */ @@ -626,7 +667,6 @@ AcpiDsTerminateControlMethod ( if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("Could not signal method semaphore\n")); - Status = AE_OK; /* Ignore error and continue cleanup */ } @@ -638,8 +678,7 @@ AcpiDsTerminateControlMethod ( "*** Not deleting method namespace, there are still %d threads\n", WalkState->MethodDesc->Method.ThreadCount)); } - - if (!WalkState->MethodDesc->Method.ThreadCount) + else /* This is the last executing thread */ { /* * Support to dynamically change a method from NotSerialized to @@ -654,9 +693,8 @@ AcpiDsTerminateControlMethod ( if ((WalkState->MethodDesc->Method.Concurrency == 1) && (!WalkState->MethodDesc->Method.Semaphore)) { - Status = AcpiOsCreateSemaphore (1, - 1, - &WalkState->MethodDesc->Method.Semaphore); + Status = AcpiOsCreateSemaphore (1, 1, + &WalkState->MethodDesc->Method.Semaphore); } /* @@ -674,7 +712,7 @@ AcpiDsTerminateControlMethod ( Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + goto Exit; } if (MethodNode->Child) @@ -686,16 +724,14 @@ AcpiDsTerminateControlMethod ( * Delete any namespace entries created anywhere else within * the namespace */ - AcpiNsDeleteNamespaceByOwner (WalkState->MethodDesc->Method.OwningId); + AcpiNsDeleteNamespaceByOwner (WalkState->MethodDesc->Method.OwnerId); Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + AcpiUtReleaseOwnerId (&WalkState->MethodDesc->Method.OwnerId); } - Status = AcpiUtReleaseMutex (ACPI_MTX_PARSER); - return_ACPI_STATUS (Status); +Exit: + (void) AcpiUtReleaseMutex (ACPI_MTX_PARSER); + return_VOID; } diff --git a/sys/contrib/dev/acpica/dsmthdat.c b/sys/contrib/dev/acpica/dsmthdat.c index 00ef779..da4aac5 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: 80 $ + * $Revision: 1.85 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -126,6 +126,29 @@ #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsmthdat") +/* Local prototypes */ + +static void +AcpiDsMethodDataDeleteValue ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +AcpiDsMethodDataSetValue ( + UINT16 Opcode, + UINT32 Index, + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState); + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_OBJECT_TYPE +AcpiDsMethodDataGetType ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState); +#endif + /******************************************************************************* * @@ -136,8 +159,8 @@ * RETURN: Status * * DESCRIPTION: Initialize the data structures that hold the method's arguments - * and locals. The data struct is an array of NTEs for each. - * This allows RefOf and DeRefOf to work properly for these + * and locals. The data struct is an array of namespace nodes for + * each - this allows RefOf and DeRefOf to work properly for these * special data types. * * NOTES: WalkState fields are initialized to zero by the @@ -167,7 +190,8 @@ AcpiDsMethodDataInit ( WalkState->Arguments[i].Name.Integer |= (i << 24); WalkState->Arguments[i].Descriptor = ACPI_DESC_TYPE_NAMED; WalkState->Arguments[i].Type = ACPI_TYPE_ANY; - WalkState->Arguments[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; + WalkState->Arguments[i].Flags = ANOBJ_END_OF_PEER_LIST | + ANOBJ_METHOD_ARG; } /* Init the method locals */ @@ -180,7 +204,8 @@ AcpiDsMethodDataInit ( WalkState->LocalVariables[i].Name.Integer |= (i << 24); WalkState->LocalVariables[i].Descriptor = ACPI_DESC_TYPE_NAMED; WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY; - WalkState->LocalVariables[i].Flags = ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; + WalkState->LocalVariables[i].Flags = ANOBJ_END_OF_PEER_LIST | + ANOBJ_METHOD_LOCAL; } return_VOID; @@ -279,16 +304,19 @@ AcpiDsMethodDataInitArgs ( return_ACPI_STATUS (AE_OK); } - /* Copy passed parameters into the new method stack frame */ + /* Copy passed parameters into the new method stack frame */ - while ((Index < ACPI_METHOD_NUM_ARGS) && (Index < MaxParamCount) && Params[Index]) + while ((Index < ACPI_METHOD_NUM_ARGS) && + (Index < MaxParamCount) && + Params[Index]) { /* * A valid parameter. * Store the argument in the method/walk descriptor. * Do not copy the arg in order to implement call by reference */ - Status = AcpiDsMethodDataSetValue (AML_ARG_OP, Index, Params[Index], WalkState); + Status = AcpiDsMethodDataSetValue (AML_ARG_OP, Index, + Params[Index], WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -307,11 +335,13 @@ AcpiDsMethodDataInitArgs ( * FUNCTION: AcpiDsMethodDataGetNode * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which localVar or argument whose type - * to get + * Index - Which Local or Arg whose type to get * WalkState - Current walk state object + * Node - Where the node is returned. + * + * RETURN: Status and node * - * RETURN: Get the Node associated with a local or arg. + * DESCRIPTION: Get the Node associated with a local or arg. * ******************************************************************************/ @@ -334,7 +364,8 @@ AcpiDsMethodDataGetNode ( if (Index > ACPI_METHOD_MAX_LOCAL) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Local index %d is invalid (max %d)\n", Index, ACPI_METHOD_MAX_LOCAL)); return_ACPI_STATUS (AE_AML_INVALID_INDEX); } @@ -348,7 +379,8 @@ AcpiDsMethodDataGetNode ( if (Index > ACPI_METHOD_MAX_ARG) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Arg index %d is invalid (max %d)\n", Index, ACPI_METHOD_MAX_ARG)); return_ACPI_STATUS (AE_AML_INVALID_INDEX); } @@ -372,7 +404,7 @@ AcpiDsMethodDataGetNode ( * FUNCTION: AcpiDsMethodDataSetValue * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which localVar or argument to get + * Index - Which Local or Arg to get * Object - Object to be inserted into the stack entry * WalkState - Current walk state object * @@ -383,7 +415,7 @@ AcpiDsMethodDataGetNode ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsMethodDataSetValue ( UINT16 Opcode, UINT32 Index, @@ -427,69 +459,16 @@ AcpiDsMethodDataSetValue ( /******************************************************************************* * - * FUNCTION: AcpiDsMethodDataGetType - * - * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which localVar or argument whose type - * to get - * WalkState - Current walk state object - * - * RETURN: Data type of current value of the selected Arg or Local - * - ******************************************************************************/ - -ACPI_OBJECT_TYPE -AcpiDsMethodDataGetType ( - UINT16 Opcode, - UINT32 Index, - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status; - ACPI_NAMESPACE_NODE *Node; - ACPI_OPERAND_OBJECT *Object; - - - ACPI_FUNCTION_TRACE ("DsMethodDataGetType"); - - - /* Get the namespace node for the arg/local */ - - Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); - if (ACPI_FAILURE (Status)) - { - return_VALUE ((ACPI_TYPE_NOT_FOUND)); - } - - /* Get the object */ - - Object = AcpiNsGetAttachedObject (Node); - if (!Object) - { - /* Uninitialized local/arg, return TYPE_ANY */ - - return_VALUE (ACPI_TYPE_ANY); - } - - /* Get the object type */ - - return_VALUE (ACPI_GET_OBJECT_TYPE (Object)); -} - - -/******************************************************************************* - * * FUNCTION: AcpiDsMethodDataGetValue * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which localVar or argument to get * WalkState - Current walk state object - * *DestDesc - Ptr to Descriptor into which selected Arg - * or Local value should be copied + * DestDesc - Where Arg or Local value is returned * * RETURN: Status * - * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame - * at the current top of the method stack. + * DESCRIPTION: Retrieve value of selected Arg or Local for this method * Used only in AcpiExResolveToValue(). * ******************************************************************************/ @@ -561,14 +540,16 @@ AcpiDsMethodDataGetValue ( { case AML_ARG_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Arg[%d] at node %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Uninitialized Arg[%d] at node %p\n", Index, Node)); return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); case AML_LOCAL_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Uninitialized Local[%d] at node %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Uninitialized Local[%d] at node %p\n", Index, Node)); return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); @@ -600,12 +581,12 @@ AcpiDsMethodDataGetValue ( * * RETURN: None * - * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts + * DESCRIPTION: Delete the entry at Opcode:Index. Inserts * a null into the stack slot after the object is deleted. * ******************************************************************************/ -void +static void AcpiDsMethodDataDeleteValue ( UINT16 Opcode, UINT32 Index, @@ -658,7 +639,7 @@ AcpiDsMethodDataDeleteValue ( * FUNCTION: AcpiDsStoreObjectToLocal * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP - * Index - Which localVar or argument to set + * Index - Which Local or Arg to set * ObjDesc - Value to be stored * WalkState - Current walk state * @@ -754,22 +735,11 @@ AcpiDsStoreObjectToLocal ( if (Opcode == AML_ARG_OP) { /* - * Make sure that the object is the correct type. This may be overkill, but - * it is here because references were NS nodes in the past. Now they are - * operand objects of type Reference. - */ - if (ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) != ACPI_DESC_TYPE_OPERAND) - { - ACPI_REPORT_ERROR (("Invalid descriptor type while storing to method arg: [%s]\n", - AcpiUtGetDescriptorName (CurrentObjDesc))); - return_ACPI_STATUS (AE_AML_INTERNAL); - } - - /* - * If we have a valid reference object that came from RefOf(), do the - * indirect store + * If we have a valid reference object that came from RefOf(), + * do the indirect store */ - if ((CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_OPERAND) && + (CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && (CurrentObjDesc->Reference.Opcode == AML_REF_OF_OP)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, @@ -820,3 +790,57 @@ AcpiDsStoreObjectToLocal ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetType + * + * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP + * Index - Which Local or Arg whose type to get + * WalkState - Current walk state object + * + * RETURN: Data type of current value of the selected Arg or Local + * + * DESCRIPTION: Get the type of the object stored in the Local or Arg + * + ******************************************************************************/ + +ACPI_OBJECT_TYPE +AcpiDsMethodDataGetType ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE ("DsMethodDataGetType"); + + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_VALUE ((ACPI_TYPE_NOT_FOUND)); + } + + /* Get the object */ + + Object = AcpiNsGetAttachedObject (Node); + if (!Object) + { + /* Uninitialized local/arg, return TYPE_ANY */ + + return_VALUE (ACPI_TYPE_ANY); + } + + /* Get the object type */ + + return_VALUE (ACPI_GET_OBJECT_TYPE (Object)); +} +#endif + + diff --git a/sys/contrib/dev/acpica/dsobject.c b/sys/contrib/dev/acpica/dsobject.c index 068eee1..e0e4917 100644 --- a/sys/contrib/dev/acpica/dsobject.c +++ b/sys/contrib/dev/acpica/dsobject.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsobject - Dispatcher object management routines - * $Revision: 119 $ + * $Revision: 1.124 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -126,9 +126,15 @@ #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsobject") +static ACPI_STATUS +AcpiDsBuildInternalObject ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr); + #ifndef ACPI_NO_METHOD_EXECUTION -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsBuildInternalObject * @@ -141,9 +147,9 @@ * DESCRIPTION: Translate a parser Op object to the equivalent namespace object * Simple objects are any objects other than a package object! * - ****************************************************************************/ + ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsBuildInternalObject ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, @@ -166,9 +172,11 @@ AcpiDsBuildInternalObject ( */ if (!Op->Common.Node) { - Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String, + Status = AcpiNsLookup (WalkState->ScopeInfo, + Op->Common.Value.String, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + NULL, (ACPI_NAMESPACE_NODE **) &(Op->Common.Node)); if (ACPI_FAILURE (Status)) @@ -181,13 +189,15 @@ AcpiDsBuildInternalObject ( /* Create and init the internal ACPI object */ - ObjDesc = AcpiUtCreateInternalObject ((AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType); + ObjDesc = AcpiUtCreateInternalObject ( + (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Common.AmlOpcode, &ObjDesc); + Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Common.AmlOpcode, + &ObjDesc); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ObjDesc); @@ -199,7 +209,7 @@ AcpiDsBuildInternalObject ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsBuildInternalBufferObj * @@ -213,7 +223,7 @@ AcpiDsBuildInternalObject ( * DESCRIPTION: Translate a parser Op package object to the equivalent * namespace object * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsBuildInternalBufferObj ( @@ -318,7 +328,7 @@ AcpiDsBuildInternalBufferObj ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsBuildInternalPackageObj * @@ -332,7 +342,7 @@ AcpiDsBuildInternalBufferObj ( * DESCRIPTION: Translate a parser Op package object to the equivalent * namespace object * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsBuildInternalPackageObj ( @@ -429,12 +439,13 @@ AcpiDsBuildInternalPackageObj ( { /* Object (package or buffer) is already built */ - ObjDesc->Package.Elements[i] = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node); + ObjDesc->Package.Elements[i] = + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node); } else { Status = AcpiDsBuildInternalObject (WalkState, Arg, - &ObjDesc->Package.Elements[i]); + &ObjDesc->Package.Elements[i]); } i++; @@ -447,7 +458,7 @@ AcpiDsBuildInternalPackageObj ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsCreateNode * @@ -459,7 +470,7 @@ AcpiDsBuildInternalPackageObj ( * * DESCRIPTION: Create the object to be associated with a namespace node * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsCreateNode ( @@ -493,7 +504,8 @@ AcpiDsCreateNode ( /* Build an internal object for the argument(s) */ - Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg, &ObjDesc); + Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg, + &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -516,7 +528,7 @@ AcpiDsCreateNode ( #endif /* ACPI_NO_METHOD_EXECUTION */ -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsInitObjectFromOp * @@ -531,7 +543,7 @@ AcpiDsCreateNode ( * associated arguments. The namespace object is a more compact * representation of the Op and its arguments. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsInitObjectFromOp ( @@ -566,7 +578,8 @@ AcpiDsInitObjectFromOp ( /* * Defer evaluation of Buffer TermArg operand */ - ObjDesc->Buffer.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + ObjDesc->Buffer.Node = (ACPI_NAMESPACE_NODE *) + WalkState->Operands[0]; ObjDesc->Buffer.AmlStart = Op->Named.Data; ObjDesc->Buffer.AmlLength = Op->Named.Length; break; @@ -577,7 +590,8 @@ AcpiDsInitObjectFromOp ( /* * Defer evaluation of Package TermArg operand */ - ObjDesc->Package.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + ObjDesc->Package.Node = (ACPI_NAMESPACE_NODE *) + WalkState->Operands[0]; ObjDesc->Package.AmlStart = Op->Named.Data; ObjDesc->Package.AmlLength = Op->Named.Length; break; @@ -591,9 +605,10 @@ AcpiDsInitObjectFromOp ( /* * Resolve AML Constants here - AND ONLY HERE! * All constants are integers. - * We mark the integer with a flag that indicates that it started life - * as a constant -- so that stores to constants will perform as expected (noop). - * (ZeroOp is used as a placeholder for optional target operands.) + * We mark the integer with a flag that indicates that it started + * life as a constant -- so that stores to constants will perform + * as expected (noop). ZeroOp is used as a placeholder for optional + * target operands. */ ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT; @@ -622,12 +637,13 @@ AcpiDsInitObjectFromOp ( case AML_REVISION_OP: - ObjDesc->Integer.Value = ACPI_CA_SUPPORT_LEVEL; + ObjDesc->Integer.Value = ACPI_CA_VERSION; break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown constant opcode %X\n", Opcode)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown constant opcode %X\n", Opcode)); Status = AE_AML_OPERAND_TYPE; break; } @@ -637,11 +653,15 @@ AcpiDsInitObjectFromOp ( case AML_TYPE_LITERAL: ObjDesc->Integer.Value = Op->Common.Value.Integer; +#ifndef ACPI_NO_METHOD_EXECUTION + AcpiExTruncateFor32bitTable (ObjDesc); +#endif break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", OpInfo->Type)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", + OpInfo->Type)); Status = AE_AML_OPERAND_TYPE; break; } @@ -677,8 +697,10 @@ AcpiDsInitObjectFromOp ( ObjDesc->Reference.Offset = Opcode - AML_LOCAL_OP; #ifndef ACPI_NO_METHOD_EXECUTION - Status = AcpiDsMethodDataGetNode (AML_LOCAL_OP, ObjDesc->Reference.Offset, - WalkState, (ACPI_NAMESPACE_NODE **) &ObjDesc->Reference.Object); + Status = AcpiDsMethodDataGetNode (AML_LOCAL_OP, + ObjDesc->Reference.Offset, + WalkState, + (ACPI_NAMESPACE_NODE **) &ObjDesc->Reference.Object); #endif break; @@ -691,8 +713,10 @@ AcpiDsInitObjectFromOp ( ObjDesc->Reference.Offset = Opcode - AML_ARG_OP; #ifndef ACPI_NO_METHOD_EXECUTION - Status = AcpiDsMethodDataGetNode (AML_ARG_OP, ObjDesc->Reference.Offset, - WalkState, (ACPI_NAMESPACE_NODE **) &ObjDesc->Reference.Object); + Status = AcpiDsMethodDataGetNode (AML_ARG_OP, + ObjDesc->Reference.Offset, + WalkState, + (ACPI_NAMESPACE_NODE **) &ObjDesc->Reference.Object); #endif break; diff --git a/sys/contrib/dev/acpica/dsopcode.c b/sys/contrib/dev/acpica/dsopcode.c index 639e846..6b1ed3a 100644 --- a/sys/contrib/dev/acpica/dsopcode.c +++ b/sys/contrib/dev/acpica/dsopcode.c @@ -2,7 +2,7 @@ * * Module Name: dsopcode - Dispatcher Op Region support and handling of * "control" opcodes - * $Revision: 95 $ + * $Revision: 1.103 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -128,12 +128,31 @@ #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsopcode") +/* Local prototypes */ -/***************************************************************************** +static ACPI_STATUS +AcpiDsExecuteArguments ( + ACPI_NAMESPACE_NODE *Node, + ACPI_NAMESPACE_NODE *ScopeNode, + UINT32 AmlLength, + UINT8 *AmlStart); + +static ACPI_STATUS +AcpiDsInitBufferField ( + UINT16 AmlOpcode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *BufferDesc, + ACPI_OPERAND_OBJECT *OffsetDesc, + ACPI_OPERAND_OBJECT *LengthDesc, + ACPI_OPERAND_OBJECT *ResultDesc); + + +/******************************************************************************* * * FUNCTION: AcpiDsExecuteArguments * - * PARAMETERS: Node - Parent NS node + * PARAMETERS: Node - Object NS node + * ScopeNode - Parent NS node * AmlLength - Length of executable AML * AmlStart - Pointer to the AML * @@ -141,9 +160,9 @@ * * DESCRIPTION: Late (deferred) execution of region or field arguments * - ****************************************************************************/ + ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsExecuteArguments ( ACPI_NAMESPACE_NODE *Node, ACPI_NAMESPACE_NODE *ScopeNode, @@ -176,7 +195,8 @@ AcpiDsExecuteArguments ( WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); if (!WalkState) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto Cleanup; } Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, @@ -184,7 +204,7 @@ AcpiDsExecuteArguments ( if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); - return_ACPI_STATUS (Status); + goto Cleanup; } /* Mark this parse as a deferred opcode */ @@ -197,8 +217,7 @@ AcpiDsExecuteArguments ( Status = AcpiPsParseAml (WalkState); if (ACPI_FAILURE (Status)) { - AcpiPsDeleteParseTree (Op); - return_ACPI_STATUS (Status); + goto Cleanup; } /* Get and init the Op created above */ @@ -221,7 +240,8 @@ AcpiDsExecuteArguments ( WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); if (!WalkState) { - return_ACPI_STATUS (AE_NO_MEMORY); + Status = AE_NO_MEMORY; + goto Cleanup; } /* Execute the opcode and arguments */ @@ -231,19 +251,21 @@ AcpiDsExecuteArguments ( if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); - return_ACPI_STATUS (Status); + goto Cleanup; } /* Mark this execution as a deferred opcode */ WalkState->DeferredNode = Node; Status = AcpiPsParseAml (WalkState); + +Cleanup: AcpiPsDeleteParseTree (Op); return_ACPI_STATUS (Status); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsGetBufferFieldArguments * @@ -254,7 +276,7 @@ AcpiDsExecuteArguments ( * DESCRIPTION: Get BufferField Buffer and Index. This implements the late * evaluation of these field attributes. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsGetBufferFieldArguments ( @@ -290,7 +312,7 @@ AcpiDsGetBufferFieldArguments ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsGetBufferArguments * @@ -301,7 +323,7 @@ AcpiDsGetBufferFieldArguments ( * DESCRIPTION: Get Buffer length and initializer byte list. This implements * the late evaluation of these attributes. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsGetBufferArguments ( @@ -339,7 +361,7 @@ AcpiDsGetBufferArguments ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsGetPackageArguments * @@ -350,7 +372,7 @@ AcpiDsGetBufferArguments ( * DESCRIPTION: Get Package length and initializer byte list. This implements * the late evaluation of these attributes. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsGetPackageArguments ( @@ -441,17 +463,17 @@ AcpiDsGetRegionArguments ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsInitializeRegion * - * PARAMETERS: Op - A valid region Op object + * PARAMETERS: ObjHandle - Region namespace node * * RETURN: Status * * DESCRIPTION: Front end to EvInitializeRegion * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsInitializeRegion ( @@ -470,7 +492,7 @@ AcpiDsInitializeRegion ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsInitBufferField * @@ -478,16 +500,16 @@ AcpiDsInitializeRegion ( * ObjDesc - BufferField object * BufferDesc - Host Buffer * OffsetDesc - Offset into buffer - * Length - Length of field (CREATE_FIELD_OP only) - * Result - Where to store the result + * LengthDesc - Length of field (CREATE_FIELD_OP only) + * ResultDesc - Where to store the result * * RETURN: Status * * DESCRIPTION: Perform actual initialization of a buffer field * - ****************************************************************************/ + ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiDsInitBufferField ( UINT16 AmlOpcode, ACPI_OPERAND_OBJECT *ObjDesc, @@ -525,8 +547,10 @@ AcpiDsInitBufferField ( */ if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination not a NS Node [%s]\n", - AcpiPsGetOpcodeName (AmlOpcode), AcpiUtGetDescriptorName (ResultDesc))); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "(%s) destination not a NS Node [%s]\n", + AcpiPsGetOpcodeName (AmlOpcode), + AcpiUtGetDescriptorName (ResultDesc))); Status = AE_AML_OPERAND_TYPE; goto Cleanup; @@ -543,9 +567,19 @@ AcpiDsInitBufferField ( /* Offset is in bits, count is in bits */ + FieldFlags = AML_FIELD_ACCESS_BYTE; BitOffset = Offset; BitCount = (UINT32) LengthDesc->Integer.Value; - FieldFlags = AML_FIELD_ACCESS_BYTE; + + /* Must have a valid (>0) bit count */ + + if (BitCount == 0) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Attempt to CreateField of length 0\n")); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } break; case AML_CREATE_BIT_FIELD_OP: @@ -619,7 +653,8 @@ AcpiDsInitBufferField ( /* * Initialize areas of the field object that are common to all fields - * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), UPDATE_RULE = 0 (UPDATE_PRESERVE) + * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), + * UPDATE_RULE = 0 (UPDATE_PRESERVE) */ Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0, BitOffset, BitCount); @@ -632,8 +667,8 @@ AcpiDsInitBufferField ( /* Reference count for BufferDesc inherits ObjDesc count */ - BufferDesc->Common.ReferenceCount = (UINT16) (BufferDesc->Common.ReferenceCount + - ObjDesc->Common.ReferenceCount); + BufferDesc->Common.ReferenceCount = (UINT16) + (BufferDesc->Common.ReferenceCount + ObjDesc->Common.ReferenceCount); Cleanup: @@ -665,7 +700,7 @@ Cleanup: } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsEvalBufferFieldOperands * @@ -677,7 +712,7 @@ Cleanup: * DESCRIPTION: Get BufferField Buffer and Index * Called from AcpiDsExecEndOp during BufferField parse tree walk * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsEvalBufferFieldOperands ( @@ -757,7 +792,7 @@ AcpiDsEvalBufferFieldOperands ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsEvalRegionOperands * @@ -769,7 +804,7 @@ AcpiDsEvalBufferFieldOperands ( * DESCRIPTION: Get region address and length * Called from AcpiDsExecEndOp during OpRegion parse tree walk * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsEvalRegionOperands ( @@ -787,7 +822,8 @@ AcpiDsEvalRegionOperands ( /* - * This is where we evaluate the address and length fields of the OpRegion declaration + * This is where we evaluate the address and length fields of the + * OpRegion declaration */ Node = Op->Common.Node; @@ -809,7 +845,8 @@ AcpiDsEvalRegionOperands ( /* Resolve the length and address operands to numbers */ - Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); + Status = AcpiExResolveOperands (Op->Common.AmlOpcode, + ACPI_WALK_OPERANDS, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -840,7 +877,8 @@ AcpiDsEvalRegionOperands ( */ OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; - ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) OperandDesc->Integer.Value; + ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) + OperandDesc->Integer.Value; AcpiUtRemoveReference (OperandDesc); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", @@ -856,7 +894,7 @@ AcpiDsEvalRegionOperands ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiDsEvalDataObjectOperands * @@ -866,11 +904,10 @@ AcpiDsEvalRegionOperands ( * * RETURN: Status * - * DESCRIPTION: Get the operands and complete the following data objec types: - * Buffer - * Package + * DESCRIPTION: Get the operands and complete the following data object types: + * Buffer, Package. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiDsEvalDataObjectOperands ( @@ -940,7 +977,7 @@ AcpiDsEvalDataObjectOperands ( if (ACPI_SUCCESS (Status)) { /* - * Return the object in the WalkState, unless the parent is a package -- + * Return the object in the WalkState, unless the parent is a package - * in this case, the return object will be stored in the parse tree * for the package. */ @@ -1104,7 +1141,8 @@ AcpiDsExecEndControlOp ( Status = AE_CTRL_PENDING; } - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n", Op)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "[WHILE_OP] termination! Op=%p\n",Op)); /* Pop this control state and free it */ @@ -1127,6 +1165,10 @@ AcpiDsExecEndControlOp ( */ if (Op->Common.Value.Arg) { + /* Since we have a real Return(), delete any implicit return */ + + AcpiDsClearImplicitReturn (WalkState); + /* Return statement has an immediate operand */ Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); @@ -1156,6 +1198,10 @@ AcpiDsExecEndControlOp ( else if ((WalkState->Results) && (WalkState->Results->Results.NumResults > 0)) { + /* Since we have a real Return(), delete any implicit return */ + + AcpiDsClearImplicitReturn (WalkState); + /* * The return value has come from a previous calculation. * diff --git a/sys/contrib/dev/acpica/dsutils.c b/sys/contrib/dev/acpica/dsutils.c index 757f1f2..eb7149a 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: 107 $ + * $Revision: 1.115 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -128,7 +128,122 @@ ACPI_MODULE_NAME ("dsutils") +/******************************************************************************* + * + * FUNCTION: AcpiDsClearImplicitReturn + * + * PARAMETERS: WalkState - Current State + * + * RETURN: None. + * + * DESCRIPTION: Clear and remove a reference on an implicit return value. Used + * to delete "stale" return values (if enabled, the return value + * from every operator is saved at least momentarily, in case the + * parent method exits.) + * + ******************************************************************************/ + +void +AcpiDsClearImplicitReturn ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_FUNCTION_NAME ("DsClearImplicitReturn"); + + + /* + * Slack must be enabled for this feature + */ + if (!AcpiGbl_EnableInterpreterSlack) + { + return; + } + + if (WalkState->ImplicitReturnObj) + { + /* + * Delete any "stale" implicit return. However, in + * complex statements, the implicit return value can be + * bubbled up several levels. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Removing reference on stale implicit return obj %p\n", + WalkState->ImplicitReturnObj)); + + AcpiUtRemoveReference (WalkState->ImplicitReturnObj); + WalkState->ImplicitReturnObj = NULL; + } +} + + #ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiDsDoImplicitReturn + * + * PARAMETERS: ReturnDesc - The return value + * WalkState - Current State + * AddReference - True if a reference should be added to the + * return object + * + * RETURN: TRUE if implicit return enabled, FALSE otherwise + * + * DESCRIPTION: Implements the optional "implicit return". We save the result + * of every ASL operator and control method invocation in case the + * parent method exit. Before storing a new return value, we + * delete the previous return value. + * + ******************************************************************************/ + +BOOLEAN +AcpiDsDoImplicitReturn ( + ACPI_OPERAND_OBJECT *ReturnDesc, + ACPI_WALK_STATE *WalkState, + BOOLEAN AddReference) +{ + ACPI_FUNCTION_NAME ("DsDoImplicitReturn"); + + + /* + * Slack must be enabled for this feature, and we must + * have a valid return object + */ + if ((!AcpiGbl_EnableInterpreterSlack) || + (!ReturnDesc)) + { + return (FALSE); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result %p will be implicitly returned; Prev=%p\n", + ReturnDesc, + WalkState->ImplicitReturnObj)); + + /* + * Delete any "stale" implicit return value first. However, in + * complex statements, the implicit return value can be + * bubbled up several levels, so we don't clear the value if it + * is the same as the ReturnDesc. + */ + if (WalkState->ImplicitReturnObj) + { + if (WalkState->ImplicitReturnObj == ReturnDesc) + { + return (TRUE); + } + AcpiDsClearImplicitReturn (WalkState); + } + + /* Save the implicit return value, add a reference if requested */ + + WalkState->ImplicitReturnObj = ReturnDesc; + if (AddReference) + { + AcpiUtAddReference (ReturnDesc); + } + + return (TRUE); +} + /******************************************************************************* * @@ -150,7 +265,6 @@ AcpiDsIsResultUsed ( { const ACPI_OPCODE_INFO *ParentInfo; - ACPI_FUNCTION_TRACE_PTR ("DsIsResultUsed", Op); @@ -159,42 +273,37 @@ AcpiDsIsResultUsed ( if (!Op) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Op\n")); - return_VALUE (TRUE); + return_UINT8 (TRUE); } /* - * 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. + * We know that this operator 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 (!Op->Common.Parent || - Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP) - { - /* - * 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); - } + (void) AcpiDsDoImplicitReturn (WalkState->ResultObj, WalkState, TRUE); + /* + * Now determine if the parent will use the result + * + * If there is no parent, or the parent is a ScopeOp, we are executing + * at the method level. An executing method typically has no parent, + * since each method is parsed separately. A method invoked externally + * via ExecuteControlMethod has a ScopeOp as the parent. + */ + if ((!Op->Common.Parent) || + (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP)) + { /* No parent, the return value cannot possibly be used */ - return_VALUE (FALSE); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "At Method level, result of [%s] not used\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode))); + return_UINT8 (FALSE); } /* Get info on the parent. The RootOp is AML_SCOPE */ @@ -202,8 +311,9 @@ AcpiDsIsResultUsed ( ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); if (ParentInfo->Class == AML_CLASS_UNKNOWN) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown parent opcode. Op=%p\n", Op)); - return_VALUE (FALSE); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown parent opcode. Op=%p\n", Op)); + return_UINT8 (FALSE); } /* @@ -287,19 +397,21 @@ AcpiDsIsResultUsed ( ResultUsed: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] used by Parent [%s] Op=%p\n", - AcpiPsGetOpcodeName (Op->Common.AmlOpcode), - AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result of [%s] used by Parent [%s] Op=%p\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), + AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); - return_VALUE (TRUE); + return_UINT8 (TRUE); ResultNotUsed: - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] not used by Parent [%s] Op=%p\n", - AcpiPsGetOpcodeName (Op->Common.AmlOpcode), - AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result of [%s] not used by Parent [%s] Op=%p\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), + AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); - return_VALUE (FALSE); + return_UINT8 (FALSE); } @@ -346,9 +458,8 @@ AcpiDsDeleteResultIfNotUsed ( if (!AcpiDsIsResultUsed (Op, WalkState)) { - /* - * Must pop the result stack (ObjDesc should be equal to ResultObj) - */ + /* Must pop the result stack (ObjDesc should be equal to ResultObj) */ + Status = AcpiDsResultPop (&ObjDesc, WalkState); if (ACPI_SUCCESS (Status)) { @@ -425,9 +536,8 @@ AcpiDsClearOperands ( ACPI_FUNCTION_TRACE_PTR ("DsClearOperands", WalkState); - /* - * Remove a reference on each operand on the stack - */ + /* Remove a reference on each operand on the stack */ + for (i = 0; i < WalkState->NumOperands; i++) { /* @@ -497,11 +607,7 @@ AcpiDsCreateOperand ( return_ACPI_STATUS (Status); } - /* - * All prefixes have been handled, and the name is - * in NameString - */ - + /* All prefixes have been handled, and the name is in NameString */ /* * Special handling for BufferField declarations. This is a deferred @@ -516,7 +622,8 @@ AcpiDsCreateOperand ( (WalkState->DeferredNode->Type == ACPI_TYPE_BUFFER_FIELD) && (ArgIndex != 0)) { - ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, WalkState->DeferredNode); + ObjDesc = ACPI_CAST_PTR ( + ACPI_OPERAND_OBJECT, WalkState->DeferredNode); Status = AE_OK; } else /* All other opcodes */ @@ -546,10 +653,10 @@ AcpiDsCreateOperand ( } Status = AcpiNsLookup (WalkState->ScopeInfo, NameString, - ACPI_TYPE_ANY, InterpreterMode, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - WalkState, - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc)); + ACPI_TYPE_ANY, InterpreterMode, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc)); /* * The only case where we pass through (ignore) a NOT_FOUND * error is for the CondRefOf opcode. @@ -564,7 +671,8 @@ AcpiDsCreateOperand ( * indicate this to the interpreter, set the * object to the root */ - ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, AcpiGbl_RootNode); + ObjDesc = ACPI_CAST_PTR ( + ACPI_OPERAND_OBJECT, AcpiGbl_RootNode); Status = AE_OK; } else @@ -617,7 +725,8 @@ AcpiDsCreateOperand ( */ Opcode = AML_ZERO_OP; /* Has no arguments! */ - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Null namepath: Arg=%p\n", Arg)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Null namepath: Arg=%p\n", Arg)); } else { @@ -635,7 +744,7 @@ AcpiDsCreateOperand ( if (OpInfo->Flags & AML_HAS_RETVAL) { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, - "Argument previously created, already stacked \n")); + "Argument previously created, already stacked\n")); ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject ( WalkState->Operands [WalkState->NumOperands - 1], WalkState)); @@ -651,7 +760,8 @@ AcpiDsCreateOperand ( * Only error is underflow, and this indicates * a missing or null operand! */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Missing or null operand, %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Missing or null operand, %s\n", AcpiFormatException (Status))); return_ACPI_STATUS (Status); } @@ -668,8 +778,8 @@ AcpiDsCreateOperand ( /* Initialize the new object */ - Status = AcpiDsInitObjectFromOp (WalkState, Arg, - Opcode, &ObjDesc); + Status = AcpiDsInitObjectFromOp ( + WalkState, Arg, Opcode, &ObjDesc); if (ACPI_FAILURE (Status)) { AcpiUtDeleteObjectDesc (ObjDesc); @@ -696,7 +806,8 @@ AcpiDsCreateOperand ( * * FUNCTION: AcpiDsCreateOperands * - * PARAMETERS: FirstArg - First argument of a parser argument tree + * PARAMETERS: WalkState - Current state + * FirstArg - First argument of a parser argument tree * * RETURN: Status * diff --git a/sys/contrib/dev/acpica/dswexec.c b/sys/contrib/dev/acpica/dswexec.c index 13bc64c..d499afa 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: 113 $ + * $Revision: 1.120 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -147,11 +147,13 @@ static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = { AcpiExOpcode_3A_1T_1R, AcpiExOpcode_6A_0T_1R}; + /***************************************************************************** * * FUNCTION: AcpiDsGetPredicateValue * * PARAMETERS: WalkState - Current state of the parse tree walk + * ResultObj - if non-zero, pop result from result stack * * RETURN: Status * @@ -166,6 +168,7 @@ AcpiDsGetPredicateValue ( { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *LocalObjDesc = NULL; ACPI_FUNCTION_TRACE_PTR ("DsGetPredicateValue", WalkState); @@ -204,20 +207,27 @@ AcpiDsGetPredicateValue ( if (!ObjDesc) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No predicate ObjDesc=%p State=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "No predicate ObjDesc=%p State=%p\n", ObjDesc, WalkState)); return_ACPI_STATUS (AE_AML_NO_OPERAND); } /* - * Result of predicate evaluation currently must - * be a number + * Result of predicate evaluation must be an Integer + * object. Implicitly convert the argument if necessary. */ - if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) + Status = AcpiExConvertToInteger (ObjDesc, &LocalObjDesc, 16); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (ACPI_GET_OBJECT_TYPE (LocalObjDesc) != ACPI_TYPE_INTEGER) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Bad predicate (not a number) ObjDesc=%p State=%p Type=%X\n", + "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X\n", ObjDesc, WalkState, ACPI_GET_OBJECT_TYPE (ObjDesc))); Status = AE_AML_OPERAND_TYPE; @@ -226,13 +236,13 @@ AcpiDsGetPredicateValue ( /* Truncate the predicate to 32-bits if necessary */ - AcpiExTruncateFor32bitTable (ObjDesc); + AcpiExTruncateFor32bitTable (LocalObjDesc); /* * Save the result of the predicate evaluation on * the control stack */ - if (ObjDesc->Integer.Value) + if (LocalObjDesc->Integer.Value) { WalkState->ControlState->Common.Value = TRUE; } @@ -254,12 +264,16 @@ Cleanup: /* Break to debugger to display result */ - ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (ObjDesc, WalkState)); + ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (LocalObjDesc, WalkState)); /* * Delete the predicate result object (we know that * we don't need it anymore) */ + if (LocalObjDesc != ObjDesc) + { + AcpiUtRemoveReference (LocalObjDesc); + } AcpiUtRemoveReference (ObjDesc); WalkState->ControlState->Common.State = ACPI_CONTROL_NORMAL; @@ -272,7 +286,7 @@ Cleanup: * FUNCTION: AcpiDsExecBeginOp * * PARAMETERS: WalkState - Current state of the parse tree walk - * OutOp - Return op if a new one is created + * OutOp - Where to return op if a new one is created * * RETURN: Status * @@ -311,7 +325,8 @@ AcpiDsExecBeginOp ( if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType)) { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "(%s) Popping scope for Op %p\n", AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op)); Status = AcpiDsScopeStackPop (WalkState); @@ -383,11 +398,10 @@ AcpiDsExecBeginOp ( if (WalkState->WalkType == ACPI_WALK_METHOD) { /* - * Found a named object declaration during method - * execution; we must enter this object into the - * namespace. The created object is temporary and - * will be deleted upon completion of the execution - * of this method. + * Found a named object declaration during method execution; + * we must enter this object into the namespace. The created + * object is temporary and will be deleted upon completion of + * the execution of this method. */ Status = AcpiDsLoad2BeginOp (WalkState, NULL); } @@ -402,9 +416,10 @@ AcpiDsExecBeginOp ( case AML_CLASS_EXECUTE: case AML_CLASS_CREATE: - /* most operators with arguments */ - /* Start a new result/operand state */ - + /* + * Most operators with arguments. + * Start a new result/operand state + */ Status = AcpiDsResultStackPush (WalkState); break; @@ -424,8 +439,6 @@ AcpiDsExecBeginOp ( * FUNCTION: AcpiDsExecEndOp * * PARAMETERS: WalkState - Current state of the parse tree walk - * Op - Op that has been just been completed in the - * walk; Arguments have now been evaluated. * * RETURN: Status * @@ -477,7 +490,7 @@ AcpiDsExecEndOp ( switch (OpClass) { - case AML_CLASS_ARGUMENT: /* constants, literals, etc. -- do nothing */ + case AML_CLASS_ARGUMENT: /* constants, literals, etc. - do nothing */ break; @@ -499,17 +512,27 @@ AcpiDsExecEndOp ( goto Cleanup; } - /* Resolve all operands */ + /* + * All opcodes require operand resolution, with the only exceptions + * being the ObjectType and SizeOf operators. + */ + if (!(WalkState->OpInfo->Flags & AML_NO_OPERAND_RESOLVE)) + { + /* Resolve all operands */ - Status = AcpiExResolveOperands (WalkState->Opcode, + Status = AcpiExResolveOperands (WalkState->Opcode, &(WalkState->Operands [WalkState->NumOperands -1]), WalkState); + if (ACPI_SUCCESS (Status)) + { + ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, + AcpiPsGetOpcodeName (WalkState->Opcode), + WalkState->NumOperands, "after ExResolveOperands"); + } + } + if (ACPI_SUCCESS (Status)) { - ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, - AcpiPsGetOpcodeName (WalkState->Opcode), - WalkState->NumOperands, "after ExResolveOperands"); - /* * Dispatch the request to the appropriate interpreter handler * routine. There is one routine per opcode "type" based upon the @@ -569,21 +592,46 @@ AcpiDsExecEndOp ( /* 1 Operand, 0 ExternalResult, 0 InternalResult */ Status = AcpiDsExecEndControlOp (WalkState, Op); - if (ACPI_FAILURE (Status)) + + /* Make sure to properly pop the result stack */ + + if (ACPI_SUCCESS (Status)) { - break; + Status = AcpiDsResultStackPop (WalkState); + } + else if (Status == AE_CTRL_PENDING) + { + Status = AcpiDsResultStackPop (WalkState); + if (ACPI_SUCCESS (Status)) + { + Status = AE_CTRL_PENDING; + } } - - Status = AcpiDsResultStackPop (WalkState); break; case AML_TYPE_METHOD_CALL: + /* + * If the method is referenced from within a package + * declaration, it is not a invocation of the method, just + * a reference to it. + */ + if ((Op->Asl.Parent) && + ((Op->Asl.Parent->Asl.AmlOpcode == AML_PACKAGE_OP) || + (Op->Asl.Parent->Asl.AmlOpcode == AML_VAR_PACKAGE_OP))) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Method Reference in a Package, Op=%p\n", Op)); + Op->Common.Node = (ACPI_NAMESPACE_NODE *) Op->Asl.Value.Arg->Asl.Node->Object; + AcpiUtAddReference (Op->Asl.Value.Arg->Asl.Node->Object); + return_ACPI_STATUS (AE_OK); + } + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", Op)); /* - * (AML_METHODCALL) Op->Value->Arg->Node contains + * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains * the method Node pointer */ /* NextOp points to the op that holds the method name */ @@ -655,13 +703,15 @@ AcpiDsExecEndOp ( case AML_NAME_OP: /* - * Put the Node on the object stack (Contains the ACPI Name of - * this object) + * Put the Node on the object stack (Contains the ACPI Name + * of this object) */ WalkState->Operands[0] = (void *) Op->Common.Parent->Common.Node; WalkState->NumOperands = 1; - Status = AcpiDsCreateNode (WalkState, Op->Common.Parent->Common.Node, Op->Common.Parent); + Status = AcpiDsCreateNode (WalkState, + Op->Common.Parent->Common.Node, + Op->Common.Parent); if (ACPI_FAILURE (Status)) { break; @@ -673,7 +723,7 @@ AcpiDsExecEndOp ( case AML_INT_EVAL_SUBTREE_OP: Status = AcpiDsEvalDataObjectOperands (WalkState, Op, - AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node)); + AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node)); break; default: @@ -682,12 +732,19 @@ AcpiDsExecEndOp ( break; } + /* Done with result state (Now that operand stack is built) */ + + Status = AcpiDsResultStackPop (WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + /* * If a result object was returned from above, push it on the * current result stack */ - if (ACPI_SUCCESS (Status) && - WalkState->ResultObj) + if (WalkState->ResultObj) { Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); } @@ -724,7 +781,8 @@ AcpiDsExecEndOp ( case AML_TYPE_UNDEFINED: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Undefined opcode type Op=%p\n", Op)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Undefined opcode type Op=%p\n", Op)); return_ACPI_STATUS (AE_NOT_IMPLEMENTED); @@ -781,14 +839,15 @@ Cleanup: Status = AcpiGbl_ExceptionHandler (Status, WalkState->MethodNode->Name.Integer, WalkState->Opcode, WalkState->AmlOffset, NULL); - AcpiExEnterInterpreter (); + (void) AcpiExEnterInterpreter (); } if (WalkState->ResultObj) { /* Break to debugger to display result */ - ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj, WalkState)); + ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj, + WalkState)); /* * Delete the result op if and only if: diff --git a/sys/contrib/dev/acpica/dswload.c b/sys/contrib/dev/acpica/dswload.c index 78e28f5..a11dc55 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: 88 $ + * $Revision: 1.98 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,7 +124,7 @@ #include <contrib/dev/acpica/acnamesp.h> #include <contrib/dev/acpica/acevents.h> -#ifdef _ACPI_ASL_COMPILER +#ifdef ACPI_ASL_COMPILER #include <contrib/dev/acpica/acdisasm.h> #endif @@ -154,20 +154,23 @@ AcpiDsInitCallbacks ( switch (PassNumber) { case 1: - WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE; + WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | + ACPI_PARSE_DELETE_TREE; WalkState->DescendingCallback = AcpiDsLoad1BeginOp; WalkState->AscendingCallback = AcpiDsLoad1EndOp; break; case 2: - WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | ACPI_PARSE_DELETE_TREE; + WalkState->ParseFlags = ACPI_PARSE_LOAD_PASS1 | + ACPI_PARSE_DELETE_TREE; WalkState->DescendingCallback = AcpiDsLoad2BeginOp; WalkState->AscendingCallback = AcpiDsLoad2EndOp; break; case 3: #ifndef ACPI_NO_METHOD_EXECUTION - WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE; + WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | + ACPI_PARSE_DELETE_TREE; WalkState->DescendingCallback = AcpiDsExecBeginOp; WalkState->AscendingCallback = AcpiDsExecEndOp; #endif @@ -186,8 +189,7 @@ AcpiDsInitCallbacks ( * FUNCTION: AcpiDsLoad1BeginOp * * PARAMETERS: WalkState - Current state of the parse tree walk - * Op - Op that has been just been reached in the - * walk; Arguments have not been evaluated yet. + * OutOp - Where to return op if a new one is created * * RETURN: Status * @@ -220,15 +222,6 @@ AcpiDsLoad1BeginOp ( { if (!(WalkState->OpInfo->Flags & AML_NAMED)) { -#if 0 - if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) || - (WalkState->OpInfo->Class == AML_CLASS_CONTROL)) - { - AcpiOsPrintf ("\n\n***EXECUTABLE OPCODE %s***\n\n", WalkState->OpInfo->Name); - *OutOp = Op; - return (AE_CTRL_SKIP); - } -#endif *OutOp = Op; return (AE_OK); } @@ -262,7 +255,7 @@ AcpiDsLoad1BeginOp ( */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); -#ifdef _ACPI_ASL_COMPILER +#ifdef ACPI_ASL_COMPILER if (Status == AE_NOT_FOUND) { /* @@ -272,7 +265,8 @@ AcpiDsLoad1BeginOp ( */ AcpiDmAddToExternalList (Path); Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); + ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); } #endif if (ACPI_FAILURE (Status)) @@ -307,10 +301,12 @@ AcpiDsLoad1BeginOp ( * Name (DEB, 0) * Scope (DEB) { ... } * - * Note: silently change the type here. On the second pass, we will report a warning + * Note: silently change the type here. On the second pass, we will report + * a warning */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", Path, AcpiUtGetTypeName (Node->Type))); Node->Type = ACPI_TYPE_ANY; @@ -321,7 +317,8 @@ AcpiDsLoad1BeginOp ( /* All other types are an error */ - ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", + ACPI_REPORT_ERROR (( + "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)\n", AcpiUtGetTypeName (Node->Type), Path)); return (AE_AML_OPERAND_TYPE); @@ -332,7 +329,8 @@ AcpiDsLoad1BeginOp ( default: /* - * For all other named opcodes, we will enter the name into the namespace. + * For all other named opcodes, we will enter the name into + * the namespace. * * Setup the search flags. * Since we are entering a name into the namespace, we do not want to @@ -365,14 +363,16 @@ AcpiDsLoad1BeginOp ( } else { - ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Both Find or Create allowed\n", + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "[%s] Both Find or Create allowed\n", AcpiUtGetTypeName (ObjectType))); } /* * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that involve - * arguments to the opcode must be created as we go back up the parse tree later. + * as we go downward in the parse tree. Any necessary subobjects that + * involve arguments to the opcode must be created as we go back up the + * parse tree later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node)); @@ -424,8 +424,6 @@ AcpiDsLoad1BeginOp ( * FUNCTION: AcpiDsLoad1EndOp * * PARAMETERS: WalkState - Current state of the parse tree walk - * Op - Op that has been just been completed in the - * walk; Arguments have now been evaluated. * * RETURN: Status * @@ -476,7 +474,9 @@ AcpiDsLoad1EndOp ( if (Op->Common.AmlOpcode == AML_REGION_OP) { Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, - (ACPI_ADR_SPACE_TYPE) ((Op->Common.Value.Arg)->Common.Value.Integer), WalkState); + (ACPI_ADR_SPACE_TYPE) + ((Op->Common.Value.Arg)->Common.Value.Integer), + WalkState); if (ACPI_FAILURE (Status)) { return (Status); @@ -490,7 +490,8 @@ AcpiDsLoad1EndOp ( if (Op->Common.Value.Arg) { - ObjectType = (AcpiPsGetOpcodeInfo ((Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType; + ObjectType = (AcpiPsGetOpcodeInfo ( + (Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType; Op->Common.Node->Type = (UINT8) ObjectType; } } @@ -549,8 +550,7 @@ AcpiDsLoad1EndOp ( * FUNCTION: AcpiDsLoad2BeginOp * * PARAMETERS: WalkState - Current state of the parse tree walk - * Op - Op that has been just been reached in the - * walk; Arguments have not been evaluated yet. + * OutOp - Wher to return op if a new one is created * * RETURN: Status * @@ -578,17 +578,42 @@ AcpiDsLoad2BeginOp ( if (Op) { + if ((WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_CONDITIONAL_EXECUTING)) + { + /* We are executing a while loop outside of a method */ + + Status = AcpiDsExecBeginOp (WalkState, OutOp); + return_ACPI_STATUS (Status); + } + /* We only care about Namespace opcodes here */ - if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) && (WalkState->Opcode != AML_INT_NAMEPATH_OP)) || + if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) && + (WalkState->Opcode != AML_INT_NAMEPATH_OP)) || (!(WalkState->OpInfo->Flags & AML_NAMED))) { +#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE + if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) || + (WalkState->OpInfo->Class == AML_CLASS_CONTROL)) + { + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Begin/EXEC: %s (fl %8.8X)\n", WalkState->OpInfo->Name, + WalkState->OpInfo->Flags)); + + /* Executing a type1 or type2 opcode outside of a method */ + + Status = AcpiDsExecBeginOp (WalkState, OutOp); + return_ACPI_STATUS (Status); + } +#endif return_ACPI_STATUS (AE_OK); } - /* - * Get the name we are going to enter or lookup in the namespace - */ + /* Get the name we are going to enter or lookup in the namespace */ + if (WalkState->Opcode == AML_INT_NAMEPATH_OP) { /* For Namepath op, get the path string */ @@ -636,24 +661,28 @@ AcpiDsLoad2BeginOp ( case AML_INT_NAMEPATH_OP: /* - * The NamePath is an object reference to an existing object. Don't enter the - * name into the namespace, but look it up for use later + * The NamePath is an object reference to an existing object. + * Don't enter the name into the namespace, but look it up + * for use later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); break; case AML_SCOPE_OP: /* - * The Path is an object reference to an existing object. Don't enter the - * name into the namespace, but look it up for use later + * The Path is an object reference to an existing object. + * Don't enter the name into the namespace, but look it up + * for use later. */ Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); if (ACPI_FAILURE (Status)) { -#ifdef _ACPI_ASL_COMPILER +#ifdef ACPI_ASL_COMPILER if (Status == AE_NOT_FOUND) { Status = AE_OK; @@ -694,7 +723,8 @@ AcpiDsLoad2BeginOp ( * Scope (DEB) { ... } */ - ACPI_REPORT_WARNING (("Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", + ACPI_REPORT_WARNING (( + "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", BufferPtr, AcpiUtGetTypeName (Node->Type))); Node->Type = ACPI_TYPE_ANY; @@ -705,7 +735,8 @@ AcpiDsLoad2BeginOp ( /* All other types are an error */ - ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s]\n", + ACPI_REPORT_ERROR (( + "Invalid type (%s) for target of Scope operator [%4.4s]\n", AcpiUtGetTypeName (Node->Type), BufferPtr)); return (AE_AML_OPERAND_TYPE); @@ -736,8 +767,9 @@ AcpiDsLoad2BeginOp ( /* * Enter the named type into the internal namespace. We enter the name - * as we go downward in the parse tree. Any necessary subobjects that involve - * arguments to the opcode must be created as we go back up the parse tree later. + * as we go downward in the parse tree. Any necessary subobjects that + * involve arguments to the opcode must be created as we go back up the + * parse tree later. * * Note: Name may already exist if we are executing a deferred opcode. */ @@ -750,8 +782,11 @@ AcpiDsLoad2BeginOp ( break; } + /* Add new entry into namespace */ + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, - ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, WalkState, &(Node)); + ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, + WalkState, &(Node)); break; } @@ -761,7 +796,6 @@ AcpiDsLoad2BeginOp ( return_ACPI_STATUS (Status); } - if (!Op) { /* Create a new op */ @@ -778,10 +812,7 @@ AcpiDsLoad2BeginOp ( { Op->Named.Name = Node->Name.Integer; } - if (OutOp) - { - *OutOp = Op; - } + *OutOp = Op; } /* @@ -799,8 +830,6 @@ AcpiDsLoad2BeginOp ( * FUNCTION: AcpiDsLoad2EndOp * * PARAMETERS: WalkState - Current state of the parse tree walk - * Op - Op that has been just been completed in the - * walk; Arguments have now been evaluated. * * RETURN: Status * @@ -830,10 +859,28 @@ AcpiDsLoad2EndOp ( ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", WalkState->OpInfo->Name, Op, WalkState)); - /* Only interested in opcodes that have namespace objects */ + /* Check if opcode had an associated namespace object */ if (!(WalkState->OpInfo->Flags & AML_NSOBJECT)) { +#ifndef ACPI_NO_METHOD_EXECUTION +#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE + /* No namespace object. Executable opcode? */ + + if ((WalkState->OpInfo->Class == AML_CLASS_EXECUTE) || + (WalkState->OpInfo->Class == AML_CLASS_CONTROL)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "End/EXEC: %s (fl %8.8X)\n", WalkState->OpInfo->Name, + WalkState->OpInfo->Flags)); + + /* Executing a type1 or type2 opcode outside of a method */ + + Status = AcpiDsExecEndOp (WalkState); + return_ACPI_STATUS (Status); + } +#endif +#endif return_ACPI_STATUS (AE_OK); } @@ -843,7 +890,6 @@ AcpiDsLoad2EndOp ( "Ending scope Op=%p State=%p\n", Op, WalkState)); } - ObjectType = WalkState->OpInfo->ObjectType; /* @@ -861,7 +907,8 @@ AcpiDsLoad2EndOp ( /* Pop the scope stack */ - if (AcpiNsOpensScope (ObjectType) && (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)) + if (AcpiNsOpensScope (ObjectType) && + (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)) { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", AcpiUtGetTypeName (ObjectType), Op)); @@ -930,7 +977,7 @@ AcpiDsLoad2EndOp ( case AML_INDEX_FIELD_OP: Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node, - WalkState); + WalkState); break; case AML_BANK_FIELD_OP: @@ -1015,14 +1062,16 @@ AcpiDsLoad2EndOp ( #ifndef ACPI_NO_METHOD_EXECUTION case AML_REGION_OP: /* - * The OpRegion is not fully parsed at this time. Only valid argument is the SpaceId. - * (We must save the address of the AML of the address and length operands) + * The OpRegion is not fully parsed at this time. Only valid + * argument is the SpaceId. (We must save the address of the + * AML of the address and length operands) */ /* * If we have a valid region, initialize it * Namespace is NOT locked at this point. */ - Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), FALSE); + Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), + FALSE); if (ACPI_FAILURE (Status)) { /* @@ -1076,16 +1125,17 @@ AcpiDsLoad2EndOp ( { /* * Make sure that what we found is indeed a method - * We didn't search for a method on purpose, to see if the name would resolve + * We didn't search for a method on purpose, to see if the name + * would resolve */ if (NewNode->Type != ACPI_TYPE_METHOD) { Status = AE_AML_OPERAND_TYPE; } - /* We could put the returned object (Node) on the object stack for later, but - * for now, we will put it in the "op" object that the parser uses, so we - * can get it again at the end of this scope + /* We could put the returned object (Node) on the object stack for + * later, but for now, we will put it in the "op" object that the + * parser uses, so we can get it again at the end of this scope */ Op->Common.Node = NewNode; } diff --git a/sys/contrib/dev/acpica/dswscope.c b/sys/contrib/dev/acpica/dswscope.c index 934de71..5f1cc62 100644 --- a/sys/contrib/dev/acpica/dswscope.c +++ b/sys/contrib/dev/acpica/dswscope.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dswscope - Scope stack manipulation - * $Revision: 60 $ + * $Revision: 1.63 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,14 +124,13 @@ ACPI_MODULE_NAME ("dswscope") -#define STACK_POP(head) head - - /**************************************************************************** * * FUNCTION: AcpiDsScopeStackClear * - * PARAMETERS: None + * PARAMETERS: WalkState - Current state + * + * RETURN: None * * DESCRIPTION: Pop (and free) everything on the scope stack except the * root scope object (which remains at the stack top.) @@ -155,7 +154,8 @@ AcpiDsScopeStackClear ( WalkState->ScopeInfo = ScopeInfo->Scope.Next; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Popped object type (%s)\n", AcpiUtGetTypeName (ScopeInfo->Common.Value))); + "Popped object type (%s)\n", + AcpiUtGetTypeName (ScopeInfo->Common.Value))); AcpiUtDeleteGenericState (ScopeInfo); } } @@ -165,8 +165,11 @@ AcpiDsScopeStackClear ( * * FUNCTION: AcpiDsScopeStackPush * - * PARAMETERS: *Node, - Name to be made current - * Type, - Type of frame being pushed + * PARAMETERS: Node - Name to be made current + * Type - Type of frame being pushed + * WalkState - Current state + * + * RETURN: Status * * DESCRIPTION: Push the current scope on the scope stack, and make the * passed Node current. @@ -198,7 +201,8 @@ AcpiDsScopeStackPush ( if (!AcpiUtValidObjectType (Type)) { - ACPI_REPORT_WARNING (("DsScopeStackPush: Invalid object type: 0x%X\n", Type)); + ACPI_REPORT_WARNING (( + "DsScopeStackPush: Invalid object type: 0x%X\n", Type)); } /* Allocate a new scope object */ @@ -250,16 +254,11 @@ AcpiDsScopeStackPush ( * * FUNCTION: AcpiDsScopeStackPop * - * PARAMETERS: Type - The type of frame to be found + * PARAMETERS: WalkState - Current state * - * DESCRIPTION: Pop the scope stack until a frame of the requested type - * is found. + * RETURN: Status * - * RETURN: Count of frames popped. If no frame of the requested type - * was found, the count is returned as a negative number and - * the scope stack is emptied (which sets the current scope - * to the root). If the scope stack was empty at entry, the - * function is a no-op and returns 0. + * DESCRIPTION: Pop the scope stack once. * ***************************************************************************/ diff --git a/sys/contrib/dev/acpica/dswstate.c b/sys/contrib/dev/acpica/dswstate.c index e052dc2..f611d9d 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: 81 $ + * $Revision: 1.90 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,67 +125,29 @@ #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dswstate") +/* Local prototypes */ -/******************************************************************************* - * - * FUNCTION: AcpiDsResultInsert - * - * PARAMETERS: Object - Object to push - * Index - Where to insert the object - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Insert an object onto this walk's result stack - * - ******************************************************************************/ - +#ifdef ACPI_OBSOLETE_FUNCTIONS ACPI_STATUS AcpiDsResultInsert ( void *Object, UINT32 Index, - ACPI_WALK_STATE *WalkState) -{ - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_NAME ("DsResultInsert"); + ACPI_WALK_STATE *WalkState); +ACPI_STATUS +AcpiDsObjStackDeleteAll ( + ACPI_WALK_STATE *WalkState); - State = WalkState->Results; - if (!State) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", - WalkState)); - return (AE_NOT_EXIST); - } - - if (Index >= ACPI_OBJ_NUM_OPERANDS) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Index out of range: %X Obj=%p State=%p Num=%X\n", - Index, Object, WalkState, State->Results.NumResults)); - return (AE_BAD_PARAMETER); - } - - if (!Object) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null Object! Index=%X Obj=%p State=%p Num=%X\n", - Index, Object, WalkState, State->Results.NumResults)); - return (AE_BAD_PARAMETER); - } - - State->Results.ObjDesc [Index] = Object; - State->Results.NumResults++; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Obj=%p [%s] State=%p Num=%X Cur=%X\n", - Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL", - WalkState, State->Results.NumResults, WalkState->CurrentResult)); +ACPI_STATUS +AcpiDsObjStackPopObject ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState); - return (AE_OK); -} +void * +AcpiDsObjStackGetValue ( + UINT32 Index, + ACPI_WALK_STATE *WalkState); +#endif /******************************************************************************* @@ -308,15 +270,18 @@ AcpiDsResultPop ( *Object = State->Results.ObjDesc [Index -1]; State->Results.ObjDesc [Index -1] = NULL; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n", - *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Obj=%p [%s] Index=%X State=%p Num=%X\n", + *Object, + (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", (UINT32) Index -1, WalkState, State->Results.NumResults)); return (AE_OK); } } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "No result objects! State=%p\n", WalkState)); return (AE_AML_NO_RETURN_VALUE); } @@ -357,7 +322,8 @@ AcpiDsResultPopFromBottom ( if (!State->Results.NumResults) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", + WalkState)); return (AE_AML_NO_RETURN_VALUE); } @@ -378,12 +344,13 @@ AcpiDsResultPopFromBottom ( if (!*Object) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X, Index=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Null operand! State=%p #Ops=%X Index=%X\n", WalkState, State->Results.NumResults, (UINT32) Index)); return (AE_AML_NO_RETURN_VALUE); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s], Results=%p State=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Results=%p State=%p\n", *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", State, WalkState)); @@ -432,7 +399,8 @@ AcpiDsResultPush ( if (!Object) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Object! Obj=%p State=%p Num=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Null Object! Obj=%p State=%p Num=%X\n", Object, WalkState, State->Results.NumResults)); return (AE_BAD_PARAMETER); } @@ -529,44 +497,6 @@ AcpiDsResultStackPop ( /******************************************************************************* * - * FUNCTION: AcpiDsObjStackDeleteAll - * - * PARAMETERS: WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Clear the object stack by deleting all objects that are on it. - * Should be used with great care, if at all! - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsObjStackDeleteAll ( - ACPI_WALK_STATE *WalkState) -{ - UINT32 i; - - - ACPI_FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState); - - - /* The stack size is configurable, but fixed */ - - for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) - { - if (WalkState->Operands[i]) - { - AcpiUtRemoveReference (WalkState->Operands[i]); - WalkState->Operands[i] = NULL; - } - } - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * * FUNCTION: AcpiDsObjStackPush * * PARAMETERS: Object - Object to push @@ -609,69 +539,6 @@ AcpiDsObjStackPush ( } -#if 0 -/******************************************************************************* - * - * FUNCTION: AcpiDsObjStackPopObject - * - * PARAMETERS: PopCount - Number of objects/entries to pop - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT - * deleted by this routine. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiDsObjStackPopObject ( - ACPI_OPERAND_OBJECT **Object, - ACPI_WALK_STATE *WalkState) -{ - ACPI_FUNCTION_NAME ("DsObjStackPopObject"); - - - /* Check for stack underflow */ - - if (WalkState->NumOperands == 0) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Missing operand/stack empty! State=%p #Ops=%X\n", - WalkState, WalkState->NumOperands)); - *Object = NULL; - return (AE_AML_NO_OPERAND); - } - - /* Pop the stack */ - - WalkState->NumOperands--; - - /* Check for a valid operand */ - - if (!WalkState->Operands [WalkState->NumOperands]) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Null operand! State=%p #Ops=%X\n", - WalkState, WalkState->NumOperands)); - *Object = NULL; - return (AE_AML_NO_OPERAND); - } - - /* Get operand and set stack entry to null */ - - *Object = WalkState->Operands [WalkState->NumOperands]; - WalkState->Operands [WalkState->NumOperands] = NULL; - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", - *Object, AcpiUtGetObjectTypeName (*Object), - WalkState, WalkState->NumOperands)); - - return (AE_OK); -} -#endif - - /******************************************************************************* * * FUNCTION: AcpiDsObjStackPop @@ -779,49 +646,6 @@ AcpiDsObjStackPopAndDelete ( /******************************************************************************* * - * FUNCTION: AcpiDsObjStackGetValue - * - * PARAMETERS: Index - Stack index whose value is desired. Based - * on the top of the stack (index=0 == top) - * WalkState - Current Walk state - * - * RETURN: Status - * - * DESCRIPTION: Retrieve an object from this walk's object stack. Index must - * be within the range of the current stack pointer. - * - ******************************************************************************/ - -void * -AcpiDsObjStackGetValue ( - UINT32 Index, - ACPI_WALK_STATE *WalkState) -{ - - ACPI_FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState); - - - /* Can't do it if the stack is empty */ - - if (WalkState->NumOperands == 0) - { - return_PTR (NULL); - } - - /* or if the index is past the top of the stack */ - - if (Index > (WalkState->NumOperands - (UINT32) 1)) - { - return_PTR (NULL); - } - - return_PTR (WalkState->Operands[(ACPI_NATIVE_UINT)(WalkState->NumOperands - 1) - - Index]); -} - - -/******************************************************************************* - * * FUNCTION: AcpiDsGetCurrentWalkState * * PARAMETERS: Thread - Get current active state for this Thread @@ -858,11 +682,11 @@ AcpiDsGetCurrentWalkState ( * FUNCTION: AcpiDsPushWalkState * * PARAMETERS: WalkState - State to push - * WalkList - The list that owns the walk stack + * Thread - Thread state object * * RETURN: None * - * DESCRIPTION: Place the WalkState at the head of the state list. + * DESCRIPTION: Place the Thread state at the head of the state list. * ******************************************************************************/ @@ -885,9 +709,9 @@ AcpiDsPushWalkState ( * * FUNCTION: AcpiDsPopWalkState * - * PARAMETERS: WalkList - The list that owns the walk stack + * PARAMETERS: Thread - Current thread state * - * RETURN: A WalkState object popped from the stack + * RETURN: A WalkState object popped from the thread's stack * * DESCRIPTION: Remove and return the walkstate object that is at the head of * the walk stack for the given walk list. NULL indicates that @@ -916,7 +740,7 @@ AcpiDsPopWalkState ( /* * Don't clear the NEXT field, this serves as an indicator * that there is a parent WALK STATE - * NO: WalkState->Next = NULL; + * Do Not: WalkState->Next = NULL; */ } @@ -928,7 +752,9 @@ AcpiDsPopWalkState ( * * FUNCTION: AcpiDsCreateWalkState * - * PARAMETERS: Origin - Starting point for this walk + * PARAMETERS: OwnerId - ID for object creation + * Origin - Starting point for this walk + * MthDesc - Method object * Thread - Current thread state * * RETURN: Pointer to the new walk state. @@ -952,7 +778,7 @@ AcpiDsCreateWalkState ( ACPI_FUNCTION_TRACE ("DsCreateWalkState"); - WalkState = AcpiUtAcquireFromCache (ACPI_MEM_LIST_WALK); + WalkState = ACPI_MEM_CALLOCATE (sizeof (ACPI_WALK_STATE)); if (!WalkState) { return_PTR (NULL); @@ -977,7 +803,7 @@ AcpiDsCreateWalkState ( Status = AcpiDsResultStackPush (WalkState); if (ACPI_FAILURE (Status)) { - AcpiUtReleaseToCache (ACPI_MEM_LIST_WALK, WalkState); + ACPI_MEM_FREE (WalkState); return_PTR (NULL); } @@ -1001,8 +827,7 @@ AcpiDsCreateWalkState ( * MethodNode - Control method NS node, if any * AmlStart - Start of AML * AmlLength - Length of AML - * Params - Method args, if any - * ReturnObjDesc - Where to store a return object, if any + * Info - Method info block (params, etc.) * PassNumber - 1, 2, or 3 * * RETURN: Status @@ -1019,7 +844,7 @@ AcpiDsInitAmlWalk ( UINT8 *AmlStart, UINT32 AmlLength, ACPI_PARAMETER_INFO *Info, - UINT32 PassNumber) + UINT8 PassNumber) { ACPI_STATUS Status; ACPI_PARSE_STATE *ParserState = &WalkState->ParserState; @@ -1036,7 +861,8 @@ AcpiDsInitAmlWalk ( /* The NextOp of the NextWalk will be the beginning of the method */ - WalkState->NextOp = NULL; + WalkState->NextOp = NULL; + WalkState->PassNumber = PassNumber; if (Info) { @@ -1047,8 +873,8 @@ AcpiDsInitAmlWalk ( } else { - WalkState->Params = Info->Parameters; - WalkState->CallerReturnDesc = &Info->ReturnObject; + WalkState->Params = Info->Parameters; + WalkState->CallerReturnDesc = &Info->ReturnObject; } } @@ -1075,7 +901,8 @@ AcpiDsInitAmlWalk ( /* Init the method arguments */ - Status = AcpiDsMethodDataInitArgs (WalkState->Params, ACPI_METHOD_NUM_ARGS, WalkState); + Status = AcpiDsMethodDataInitArgs (WalkState->Params, + ACPI_METHOD_NUM_ARGS, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -1151,13 +978,15 @@ AcpiDsDeleteWalkState ( if (WalkState->DataType != ACPI_DESC_TYPE_WALK) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p is not a valid walk state\n", + WalkState)); return; } if (WalkState->ParserState.Scope) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p walk still has a scope list\n", + WalkState)); } /* Always must free any linked control states */ @@ -1190,33 +1019,214 @@ AcpiDsDeleteWalkState ( AcpiUtDeleteGenericState (State); } - AcpiUtReleaseToCache (ACPI_MEM_LIST_WALK, WalkState); + ACPI_MEM_FREE (WalkState); return_VOID; } -/****************************************************************************** +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* * - * FUNCTION: AcpiDsDeleteWalkStateCache + * FUNCTION: AcpiDsResultInsert * - * PARAMETERS: None + * PARAMETERS: Object - Object to push + * Index - Where to insert the object + * WalkState - Current Walk state * * RETURN: Status * - * DESCRIPTION: Purge the global state object cache. Used during subsystem - * termination. + * DESCRIPTION: Insert an object onto this walk's result stack * ******************************************************************************/ -void -AcpiDsDeleteWalkStateCache ( - void) +ACPI_STATUS +AcpiDsResultInsert ( + void *Object, + UINT32 Index, + ACPI_WALK_STATE *WalkState) { - ACPI_FUNCTION_TRACE ("DsDeleteWalkStateCache"); + ACPI_GENERIC_STATE *State; - AcpiUtDeleteGenericCache (ACPI_MEM_LIST_WALK); - return_VOID; + ACPI_FUNCTION_NAME ("DsResultInsert"); + + + State = WalkState->Results; + if (!State) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result object pushed! State=%p\n", + WalkState)); + return (AE_NOT_EXIST); + } + + if (Index >= ACPI_OBJ_NUM_OPERANDS) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Index out of range: %X Obj=%p State=%p Num=%X\n", + Index, Object, WalkState, State->Results.NumResults)); + return (AE_BAD_PARAMETER); + } + + if (!Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Null Object! Index=%X Obj=%p State=%p Num=%X\n", + Index, Object, WalkState, State->Results.NumResults)); + return (AE_BAD_PARAMETER); + } + + State->Results.ObjDesc [Index] = Object; + State->Results.NumResults++; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Obj=%p [%s] State=%p Num=%X Cur=%X\n", + Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL", + WalkState, State->Results.NumResults, WalkState->CurrentResult)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackDeleteAll + * + * PARAMETERS: WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Clear the object stack by deleting all objects that are on it. + * Should be used with great care, if at all! + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackDeleteAll ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR ("DsObjStackDeleteAll", WalkState); + + + /* The stack size is configurable, but fixed */ + + for (i = 0; i < ACPI_OBJ_NUM_OPERANDS; i++) + { + if (WalkState->Operands[i]) + { + AcpiUtRemoveReference (WalkState->Operands[i]); + WalkState->Operands[i] = NULL; + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPopObject + * + * PARAMETERS: Object - Where to return the popped object + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT + * deleted by this routine. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPopObject ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState) +{ + ACPI_FUNCTION_NAME ("DsObjStackPopObject"); + + + /* Check for stack underflow */ + + if (WalkState->NumOperands == 0) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Missing operand/stack empty! State=%p #Ops=%X\n", + WalkState, WalkState->NumOperands)); + *Object = NULL; + return (AE_AML_NO_OPERAND); + } + + /* Pop the stack */ + + WalkState->NumOperands--; + + /* Check for a valid operand */ + + if (!WalkState->Operands [WalkState->NumOperands]) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Null operand! State=%p #Ops=%X\n", + WalkState, WalkState->NumOperands)); + *Object = NULL; + return (AE_AML_NO_OPERAND); + } + + /* Get operand and set stack entry to null */ + + *Object = WalkState->Operands [WalkState->NumOperands]; + WalkState->Operands [WalkState->NumOperands] = NULL; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", + *Object, AcpiUtGetObjectTypeName (*Object), + WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackGetValue + * + * PARAMETERS: Index - Stack index whose value is desired. Based + * on the top of the stack (index=0 == top) + * WalkState - Current Walk state + * + * RETURN: Pointer to the requested operand + * + * DESCRIPTION: Retrieve an object from this walk's operand stack. Index must + * be within the range of the current stack pointer. + * + ******************************************************************************/ + +void * +AcpiDsObjStackGetValue ( + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + + ACPI_FUNCTION_TRACE_PTR ("DsObjStackGetValue", WalkState); + + + /* Can't do it if the stack is empty */ + + if (WalkState->NumOperands == 0) + { + return_PTR (NULL); + } + + /* or if the index is past the top of the stack */ + + if (Index > (WalkState->NumOperands - (UINT32) 1)) + { + return_PTR (NULL); + } + + return_PTR (WalkState->Operands[(ACPI_NATIVE_UINT)(WalkState->NumOperands - 1) - + Index]); } +#endif diff --git a/sys/contrib/dev/acpica/evevent.c b/sys/contrib/dev/acpica/evevent.c index 629b378..a180731 100644 --- a/sys/contrib/dev/acpica/evevent.c +++ b/sys/contrib/dev/acpica/evevent.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evevent - Fixed Event handling and dispatch - * $Revision: 113 $ + * $Revision: 1.117 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -120,6 +120,16 @@ #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evevent") +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvFixedEventInitialize ( + void); + +static UINT32 +AcpiEvFixedEventDispatch ( + UINT32 Event); + /******************************************************************************* * @@ -129,7 +139,7 @@ * * RETURN: Status * - * DESCRIPTION: Initialize global data structures for events. + * DESCRIPTION: Initialize global data structures for ACPI events (Fixed, GPE) * ******************************************************************************/ @@ -152,9 +162,9 @@ AcpiEvInitializeEvents ( } /* - * Initialize the Fixed and General Purpose Events. This is - * done prior to enabling SCIs to prevent interrupts from - * occurring before handers are installed. + * Initialize the Fixed and General Purpose Events. This is done prior to + * enabling SCIs to prevent interrupts from occurring before the handlers are + * installed. */ Status = AcpiEvFixedEventInitialize (); if (ACPI_FAILURE (Status)) @@ -239,7 +249,7 @@ AcpiEvInstallXruptHandlers ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiEvFixedEventInitialize ( void) { @@ -260,8 +270,9 @@ AcpiEvFixedEventInitialize ( if (AcpiGbl_FixedEventInfo[i].EnableRegisterId != 0xFF) { - Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[i].EnableRegisterId, - 0, ACPI_MTX_LOCK); + Status = AcpiSetRegister ( + AcpiGbl_FixedEventInfo[i].EnableRegisterId, + 0, ACPI_MTX_LOCK); if (ACPI_FAILURE (Status)) { return (Status); @@ -281,7 +292,7 @@ AcpiEvFixedEventInitialize ( * * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED * - * DESCRIPTION: Checks the PM status register for fixed events + * DESCRIPTION: Checks the PM status register for active fixed events * ******************************************************************************/ @@ -302,8 +313,10 @@ AcpiEvFixedEventDetect ( * Read the fixed feature status and enable registers, as all the cases * depend on their values. Ignore errors here. */ - (void) AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, &FixedStatus); - (void) AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE, &FixedEnable); + (void) AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, + &FixedStatus); + (void) AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_ENABLE, + &FixedEnable); ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, "Fixed Event Block: Enable %08X Status %08X\n", @@ -342,7 +355,7 @@ AcpiEvFixedEventDetect ( * ******************************************************************************/ -UINT32 +static UINT32 AcpiEvFixedEventDispatch ( UINT32 Event) { diff --git a/sys/contrib/dev/acpica/evgpe.c b/sys/contrib/dev/acpica/evgpe.c index 824adb7..20a7dc4 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: 44 $ + * $Revision: 1.53 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -121,6 +121,12 @@ #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evgpe") +/* Local prototypes */ + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchExecuteGpeMethod ( + void *Context); + /******************************************************************************* * @@ -422,9 +428,11 @@ AcpiEvGetGpeEventInfo ( if (GpeBlock) { if ((GpeNumber >= GpeBlock->BlockBaseNumber) && - (GpeNumber < GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8))) + (GpeNumber < GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8))) { - return (&GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]); + return (&GpeBlock->EventInfo[GpeNumber - + GpeBlock->BlockBaseNumber]); } } } @@ -473,13 +481,14 @@ UINT32 AcpiEvGpeDetect ( ACPI_GPE_XRUPT_INFO *GpeXruptList) { + ACPI_STATUS Status; + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; UINT8 EnabledStatusByte; - ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; UINT32 StatusReg; UINT32 EnableReg; - ACPI_STATUS Status; - ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_NATIVE_UINT Flags; ACPI_NATIVE_UINT i; ACPI_NATIVE_UINT j; @@ -495,7 +504,7 @@ AcpiEvGpeDetect ( /* Examine all GPE blocks attached to this interrupt level */ - AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_ISR); + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); GpeBlock = GpeXruptList->GpeBlockListHead; while (GpeBlock) { @@ -532,7 +541,7 @@ AcpiEvGpeDetect ( "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 */ + /* Check if there is anything active at all in this register */ EnabledStatusByte = (UINT8) (StatusReg & EnableReg); if (!EnabledStatusByte) @@ -555,8 +564,8 @@ AcpiEvGpeDetect ( * or method. */ IntStatus |= AcpiEvGpeDispatch ( - &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j], - (UINT32) j + GpeRegisterInfo->BaseGpeNumber); + &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j], + (UINT32) j + GpeRegisterInfo->BaseGpeNumber); } } } @@ -566,7 +575,7 @@ AcpiEvGpeDetect ( UnlockAndExit: - AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_ISR); + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); return (IntStatus); } @@ -623,7 +632,8 @@ AcpiEvAsynchExecuteGpeMethod ( * Take a snapshot of the GPE info for this level - we copy the * info to prevent a race condition with RemoveHandler/RemoveBlock. */ - ACPI_MEMCPY (&LocalGpeEventInfo, GpeEventInfo, sizeof (ACPI_GPE_EVENT_INFO)); + ACPI_MEMCPY (&LocalGpeEventInfo, GpeEventInfo, + sizeof (ACPI_GPE_EVENT_INFO)); Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); if (ACPI_FAILURE (Status)) @@ -635,7 +645,8 @@ AcpiEvAsynchExecuteGpeMethod ( * Must check for control method type dispatch one more * time to avoid race with EvGpeInstallHandler */ - if ((LocalGpeEventInfo.Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) + if ((LocalGpeEventInfo.Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_METHOD) { /* * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx @@ -656,7 +667,8 @@ AcpiEvAsynchExecuteGpeMethod ( } } - if ((LocalGpeEventInfo.Flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_LEVEL_TRIGGERED) + if ((LocalGpeEventInfo.Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_LEVEL_TRIGGERED) { /* * GPE is level-triggered, we clear the GPE status bit after @@ -680,7 +692,7 @@ AcpiEvAsynchExecuteGpeMethod ( * * FUNCTION: AcpiEvGpeDispatch * - * PARAMETERS: GpeEventInfo - info for this GPE + * PARAMETERS: GpeEventInfo - Info for this GPE * GpeNumber - Number relative to the parent GPE block * * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED @@ -707,14 +719,16 @@ AcpiEvGpeDispatch ( * If edge-triggered, clear the GPE status bit now. Note that * level-triggered events are cleared after the GPE is serviced. */ - if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_EDGE_TRIGGERED) + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_EDGE_TRIGGERED) { Status = AcpiHwClearGpe (GpeEventInfo); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("AcpiEvGpeDispatch: Unable to clear GPE[%2X]\n", - GpeNumber)); - return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); + ACPI_REPORT_ERROR (( + "AcpiEvGpeDispatch: %s, Unable to clear GPE[%2X]\n", + AcpiFormatException (Status), GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); } } @@ -749,15 +763,16 @@ AcpiEvGpeDispatch ( /* It is now safe to clear level-triggered events. */ - if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_LEVEL_TRIGGERED) + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_LEVEL_TRIGGERED) { Status = AcpiHwClearGpe (GpeEventInfo); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (( - "AcpiEvGpeDispatch: Unable to clear GPE[%2X]\n", - GpeNumber)); - return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); + "AcpiEvGpeDispatch: %s, Unable to clear GPE[%2X]\n", + AcpiFormatException (Status), GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); } } break; @@ -772,22 +787,22 @@ AcpiEvGpeDispatch ( if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (( - "AcpiEvGpeDispatch: Unable to disable GPE[%2X]\n", - GpeNumber)); - return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); + "AcpiEvGpeDispatch: %s, Unable to disable GPE[%2X]\n", + AcpiFormatException (Status), GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); } /* * Execute the method associated with the GPE * NOTE: Level-triggered GPEs are cleared after the method completes. */ - if (ACPI_FAILURE (AcpiOsQueueForExecution (OSD_PRIORITY_GPE, - AcpiEvAsynchExecuteGpeMethod, - GpeEventInfo))) + Status = AcpiOsQueueForExecution (OSD_PRIORITY_GPE, + AcpiEvAsynchExecuteGpeMethod, GpeEventInfo); + if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (( - "AcpiEvGpeDispatch: Unable to queue handler for GPE[%2X], event is disabled\n", - GpeNumber)); + "AcpiEvGpeDispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n", + AcpiFormatException (Status), GpeNumber)); } break; @@ -807,19 +822,18 @@ AcpiEvGpeDispatch ( if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (( - "AcpiEvGpeDispatch: Unable to disable GPE[%2X]\n", - GpeNumber)); - return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); + "AcpiEvGpeDispatch: %s, Unable to disable GPE[%2X]\n", + AcpiFormatException (Status), GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); } break; } - return_VALUE (ACPI_INTERRUPT_HANDLED); + return_UINT32 (ACPI_INTERRUPT_HANDLED); } #ifdef ACPI_GPE_NOTIFY_CHECK - /******************************************************************************* * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED * diff --git a/sys/contrib/dev/acpica/evgpeblk.c b/sys/contrib/dev/acpica/evgpeblk.c index 985e6ea..ed6321c 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: 39 $ + * $Revision: 1.47 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -121,6 +121,39 @@ #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evgpeblk") +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvSaveMethodInfo ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *ObjDesc, + void **ReturnValue); + +static ACPI_STATUS +AcpiEvMatchPrwAndGpe ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Info, + void **ReturnValue); + +static ACPI_GPE_XRUPT_INFO * +AcpiEvGetGpeXruptBlock ( + UINT32 InterruptNumber); + +static ACPI_STATUS +AcpiEvDeleteGpeXrupt ( + ACPI_GPE_XRUPT_INFO *GpeXrupt); + +static ACPI_STATUS +AcpiEvInstallGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock, + UINT32 InterruptNumber); + +static ACPI_STATUS +AcpiEvCreateGpeInfoBlocks ( + ACPI_GPE_BLOCK_INFO *GpeBlock); + /******************************************************************************* * @@ -181,7 +214,6 @@ AcpiEvValidGpeEvent ( * FUNCTION: AcpiEvWalkGpeList * * PARAMETERS: GpeWalkCallback - Routine called for each GPE block - * Flags - ACPI_NOT_ISR or ACPI_ISR * * RETURN: Status * @@ -191,18 +223,18 @@ AcpiEvValidGpeEvent ( ACPI_STATUS AcpiEvWalkGpeList ( - ACPI_GPE_CALLBACK GpeWalkCallback, - UINT32 Flags) + ACPI_GPE_CALLBACK GpeWalkCallback) { ACPI_GPE_BLOCK_INFO *GpeBlock; ACPI_GPE_XRUPT_INFO *GpeXruptInfo; ACPI_STATUS Status = AE_OK; + ACPI_NATIVE_UINT Flags; ACPI_FUNCTION_TRACE ("EvWalkGpeList"); - AcpiOsAcquireLock (AcpiGbl_GpeLock, Flags); + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); /* Walk the interrupt level descriptor list */ @@ -234,7 +266,7 @@ UnlockAndExit: } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiEvDeleteGpeHandlers * @@ -271,7 +303,8 @@ AcpiEvDeleteGpeHandlers ( { GpeEventInfo = &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j]; - if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_HANDLER) { ACPI_MEM_FREE (GpeEventInfo->Dispatch.Handler); GpeEventInfo->Dispatch.Handler = NULL; @@ -541,7 +574,7 @@ Cleanup: * * FUNCTION: AcpiEvGetGpeXruptBlock * - * PARAMETERS: InterruptLevel - Interrupt for a GPE block + * PARAMETERS: InterruptNumber - Interrupt for a GPE block * * RETURN: A GPE interrupt block * @@ -554,22 +587,23 @@ Cleanup: static ACPI_GPE_XRUPT_INFO * AcpiEvGetGpeXruptBlock ( - UINT32 InterruptLevel) + UINT32 InterruptNumber) { ACPI_GPE_XRUPT_INFO *NextGpeXrupt; ACPI_GPE_XRUPT_INFO *GpeXrupt; ACPI_STATUS Status; + ACPI_NATIVE_UINT Flags; ACPI_FUNCTION_TRACE ("EvGetGpeXruptBlock"); - /* No need for spin lock since we are not changing any list elements here */ + /* No need for lock since we are not changing any list elements here */ NextGpeXrupt = AcpiGbl_GpeXruptListHead; while (NextGpeXrupt) { - if (NextGpeXrupt->InterruptLevel == InterruptLevel) + if (NextGpeXrupt->InterruptNumber == InterruptNumber) { return_PTR (NextGpeXrupt); } @@ -585,11 +619,11 @@ AcpiEvGetGpeXruptBlock ( return_PTR (NULL); } - GpeXrupt->InterruptLevel = InterruptLevel; + GpeXrupt->InterruptNumber = InterruptNumber; /* Install new interrupt descriptor with spin lock */ - AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); if (AcpiGbl_GpeXruptListHead) { NextGpeXrupt = AcpiGbl_GpeXruptListHead; @@ -605,19 +639,19 @@ AcpiEvGetGpeXruptBlock ( { AcpiGbl_GpeXruptListHead = GpeXrupt; } - AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); /* Install new interrupt handler if not SCI_INT */ - if (InterruptLevel != AcpiGbl_FADT->SciInt) + if (InterruptNumber != AcpiGbl_FADT->SciInt) { - Status = AcpiOsInstallInterruptHandler (InterruptLevel, + Status = AcpiOsInstallInterruptHandler (InterruptNumber, AcpiEvGpeXruptHandler, GpeXrupt); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not install GPE interrupt handler at level 0x%X\n", - InterruptLevel)); + InterruptNumber)); return_PTR (NULL); } } @@ -644,6 +678,7 @@ AcpiEvDeleteGpeXrupt ( ACPI_GPE_XRUPT_INFO *GpeXrupt) { ACPI_STATUS Status; + ACPI_NATIVE_UINT Flags; ACPI_FUNCTION_TRACE ("EvDeleteGpeXrupt"); @@ -651,7 +686,7 @@ AcpiEvDeleteGpeXrupt ( /* We never want to remove the SCI interrupt handler */ - if (GpeXrupt->InterruptLevel == AcpiGbl_FADT->SciInt) + if (GpeXrupt->InterruptNumber == AcpiGbl_FADT->SciInt) { GpeXrupt->GpeBlockListHead = NULL; return_ACPI_STATUS (AE_OK); @@ -659,7 +694,7 @@ AcpiEvDeleteGpeXrupt ( /* Disable this interrupt */ - Status = AcpiOsRemoveInterruptHandler (GpeXrupt->InterruptLevel, + Status = AcpiOsRemoveInterruptHandler (GpeXrupt->InterruptNumber, AcpiEvGpeXruptHandler); if (ACPI_FAILURE (Status)) { @@ -668,7 +703,7 @@ AcpiEvDeleteGpeXrupt ( /* Unlink the interrupt block with lock */ - AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); if (GpeXrupt->Previous) { GpeXrupt->Previous->Next = GpeXrupt->Next; @@ -678,7 +713,7 @@ AcpiEvDeleteGpeXrupt ( { GpeXrupt->Next->Previous = GpeXrupt->Previous; } - AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); /* Free the block */ @@ -692,7 +727,7 @@ AcpiEvDeleteGpeXrupt ( * FUNCTION: AcpiEvInstallGpeBlock * * PARAMETERS: GpeBlock - New GPE block - * InterruptLevel - Level to be associated with this GPE block + * InterruptNumber - Xrupt to be associated with this GPE block * * RETURN: Status * @@ -703,11 +738,12 @@ AcpiEvDeleteGpeXrupt ( static ACPI_STATUS AcpiEvInstallGpeBlock ( ACPI_GPE_BLOCK_INFO *GpeBlock, - UINT32 InterruptLevel) + UINT32 InterruptNumber) { ACPI_GPE_BLOCK_INFO *NextGpeBlock; ACPI_GPE_XRUPT_INFO *GpeXruptBlock; ACPI_STATUS Status; + ACPI_NATIVE_UINT Flags; ACPI_FUNCTION_TRACE ("EvInstallGpeBlock"); @@ -719,16 +755,16 @@ AcpiEvInstallGpeBlock ( return_ACPI_STATUS (Status); } - GpeXruptBlock = AcpiEvGetGpeXruptBlock (InterruptLevel); + GpeXruptBlock = AcpiEvGetGpeXruptBlock (InterruptNumber); if (!GpeXruptBlock) { Status = AE_NO_MEMORY; goto UnlockAndExit; } - /* Install the new block at the end of the list for this interrupt with lock */ + /* Install the new block at the end of the list with lock */ - AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); if (GpeXruptBlock->GpeBlockListHead) { NextGpeBlock = GpeXruptBlock->GpeBlockListHead; @@ -746,7 +782,7 @@ AcpiEvInstallGpeBlock ( } GpeBlock->XruptBlock = GpeXruptBlock; - AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); UnlockAndExit: Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); @@ -771,6 +807,7 @@ AcpiEvDeleteGpeBlock ( ACPI_GPE_BLOCK_INFO *GpeBlock) { ACPI_STATUS Status; + ACPI_NATIVE_UINT Flags; ACPI_FUNCTION_TRACE ("EvInstallGpeBlock"); @@ -800,7 +837,7 @@ AcpiEvDeleteGpeBlock ( { /* Remove the block on this interrupt with lock */ - AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); if (GpeBlock->Previous) { GpeBlock->Previous->Next = GpeBlock->Next; @@ -814,7 +851,7 @@ AcpiEvDeleteGpeBlock ( { GpeBlock->Next->Previous = GpeBlock->Previous; } - AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); } /* Free the GpeBlock */ @@ -874,11 +911,13 @@ AcpiEvCreateGpeInfoBlocks ( * per register. Initialization to zeros is sufficient. */ GpeEventInfo = ACPI_MEM_CALLOCATE ( - ((ACPI_SIZE) GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH) * + ((ACPI_SIZE) GpeBlock->RegisterCount * + ACPI_GPE_REGISTER_WIDTH) * sizeof (ACPI_GPE_EVENT_INFO)); if (!GpeEventInfo) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not allocate the GpeEventInfo table\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not allocate the GpeEventInfo table\n")); Status = AE_NO_MEMORY; goto ErrorExit; } @@ -976,7 +1015,7 @@ ErrorExit: * GpeBlockAddress - Address and SpaceID * RegisterCount - Number of GPE register pairs in the block * GpeBlockBaseNumber - Starting GPE number for the block - * InterruptLevel - H/W interrupt for the block + * InterruptNumber - H/W interrupt for the block * ReturnGpeBlock - Where the new block descriptor is returned * * RETURN: Status @@ -991,7 +1030,7 @@ AcpiEvCreateGpeBlock ( ACPI_GENERIC_ADDRESS *GpeBlockAddress, UINT32 RegisterCount, UINT8 GpeBlockBaseNumber, - UINT32 InterruptLevel, + UINT32 InterruptNumber, ACPI_GPE_BLOCK_INFO **ReturnGpeBlock) { ACPI_GPE_BLOCK_INFO *GpeBlock; @@ -1026,7 +1065,8 @@ AcpiEvCreateGpeBlock ( GpeBlock->BlockBaseNumber = GpeBlockBaseNumber; GpeBlock->Node = GpeDevice; - ACPI_MEMCPY (&GpeBlock->BlockAddress, GpeBlockAddress, sizeof (ACPI_GENERIC_ADDRESS)); + ACPI_MEMCPY (&GpeBlock->BlockAddress, GpeBlockAddress, + sizeof (ACPI_GENERIC_ADDRESS)); /* Create the RegisterInfo and EventInfo sub-structures */ @@ -1039,7 +1079,7 @@ AcpiEvCreateGpeBlock ( /* Install the new block in the global list(s) */ - Status = AcpiEvInstallGpeBlock (GpeBlock, InterruptLevel); + Status = AcpiEvInstallGpeBlock (GpeBlock, InterruptNumber); if (ACPI_FAILURE (Status)) { ACPI_MEM_FREE (GpeBlock); @@ -1110,7 +1150,7 @@ AcpiEvCreateGpeBlock ( ((GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH) -1)), GpeDevice->Name.Ascii, GpeBlock->RegisterCount, - InterruptLevel)); + InterruptNumber)); /* Enable all valid GPEs found above */ @@ -1198,8 +1238,9 @@ AcpiEvGpeInitialize ( /* Install GPE Block 0 */ - Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, &AcpiGbl_FADT->XGpe0Blk, - RegisterCount0, 0, AcpiGbl_FADT->SciInt, &AcpiGbl_GpeFadtBlocks[0]); + Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, + &AcpiGbl_FADT->XGpe0Blk, RegisterCount0, 0, + AcpiGbl_FADT->SciInt, &AcpiGbl_GpeFadtBlocks[0]); if (ACPI_FAILURE (Status)) { @@ -1235,8 +1276,9 @@ AcpiEvGpeInitialize ( { /* Install GPE Block 1 */ - Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, &AcpiGbl_FADT->XGpe1Blk, - RegisterCount1, AcpiGbl_FADT->Gpe1Base, + Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice, + &AcpiGbl_FADT->XGpe1Blk, RegisterCount1, + AcpiGbl_FADT->Gpe1Base, AcpiGbl_FADT->SciInt, &AcpiGbl_GpeFadtBlocks[1]); if (ACPI_FAILURE (Status)) @@ -1251,7 +1293,7 @@ AcpiEvGpeInitialize ( * space. However, GPE0 always starts at GPE number zero. */ GpeNumberMax = AcpiGbl_FADT->Gpe1Base + - ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1); + ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1); } } diff --git a/sys/contrib/dev/acpica/evmisc.c b/sys/contrib/dev/acpica/evmisc.c index bd7202f..abc685d 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: 79 $ + * $Revision: 1.86 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,6 +123,35 @@ ACPI_MODULE_NAME ("evmisc") +#ifdef ACPI_DEBUG_OUTPUT +static const char *AcpiNotifyValueNames[] = +{ + "Bus Check", + "Device Check", + "Device Wake", + "Eject request", + "Device Check Light", + "Frequency Mismatch", + "Bus Mode Mismatch", + "Power Fault" +}; +#endif + +/* Local prototypes */ + +static void ACPI_SYSTEM_XFACE +AcpiEvNotifyDispatch ( + void *Context); + +static void ACPI_SYSTEM_XFACE +AcpiEvGlobalLockThread ( + void *Context); + +static UINT32 +AcpiEvGlobalLockHandler ( + void *Context); + + /******************************************************************************* * * FUNCTION: AcpiEvIsNotifyObject @@ -172,20 +201,6 @@ AcpiEvIsNotifyObject ( * ******************************************************************************/ -#ifdef ACPI_DEBUG_OUTPUT -static const char *AcpiNotifyValueNames[] = -{ - "Bus Check", - "Device Check", - "Device Wake", - "Eject request", - "Device Check Light", - "Frequency Mismatch", - "Bus Mode Mismatch", - "Power Fault" -}; -#endif - ACPI_STATUS AcpiEvQueueNotifyRequest ( ACPI_NAMESPACE_NODE *Node, @@ -202,9 +217,10 @@ AcpiEvQueueNotifyRequest ( /* * For value 3 (Ejection Request), some device method may need to be run. - * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need to be run. + * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need + * to be run. * For value 0x80 (Status Change) on the power button or sleep button, - * initiate soft-off or sleep operation? + * initiate soft-off or sleep operation? */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Dispatching Notify(%X) on node %p\n", NotifyValue, Node)); @@ -216,8 +232,9 @@ AcpiEvQueueNotifyRequest ( } else { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: 0x%2.2X **Device Specific**\n", - NotifyValue)); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Notify value: 0x%2.2X **Device Specific**\n", + NotifyValue)); } /* Get the notify object attached to the NS Node */ @@ -294,7 +311,7 @@ AcpiEvQueueNotifyRequest ( * * FUNCTION: AcpiEvNotifyDispatch * - * PARAMETERS: Context - To be passsed to the notify handler + * PARAMETERS: Context - To be passed to the notify handler * * RETURN: None. * @@ -303,7 +320,7 @@ AcpiEvQueueNotifyRequest ( * ******************************************************************************/ -void ACPI_SYSTEM_XFACE +static void ACPI_SYSTEM_XFACE AcpiEvNotifyDispatch ( void *Context) { @@ -318,7 +335,8 @@ AcpiEvNotifyDispatch ( /* * We will invoke a global notify handler if installed. - * This is done _before_ we invoke the per-device handler attached to the device. + * This is done _before_ we invoke the per-device handler attached + * to the device. */ if (NotifyInfo->Notify.Value <= ACPI_MAX_SYS_NOTIFY) { @@ -345,7 +363,8 @@ AcpiEvNotifyDispatch ( if (GlobalHandler) { - GlobalHandler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value, GlobalContext); + GlobalHandler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value, + GlobalContext); } /* Now invoke the per-device handler, if present */ @@ -353,8 +372,9 @@ AcpiEvNotifyDispatch ( HandlerObj = NotifyInfo->Notify.HandlerObj; if (HandlerObj) { - HandlerObj->Notify.Handler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value, - HandlerObj->Notify.Context); + HandlerObj->Notify.Handler (NotifyInfo->Notify.Node, + NotifyInfo->Notify.Value, + HandlerObj->Notify.Context); } /* All done with the info object */ @@ -464,7 +484,8 @@ AcpiEvGlobalLockHandler ( ******************************************************************************/ ACPI_STATUS -AcpiEvInitGlobalLockHandler (void) +AcpiEvInitGlobalLockHandler ( + void) { ACPI_STATUS Status; @@ -474,7 +495,7 @@ AcpiEvInitGlobalLockHandler (void) AcpiGbl_GlobalLockPresent = TRUE; Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, - AcpiEvGlobalLockHandler, NULL); + AcpiEvGlobalLockHandler, NULL); /* * If the global lock does not exist on this platform, the attempt @@ -485,6 +506,9 @@ AcpiEvInitGlobalLockHandler (void) */ if (Status == AE_NO_HARDWARE_RESPONSE) { + ACPI_REPORT_ERROR (( + "No response from Global Lock hardware, disabling lock\n")); + AcpiGbl_GlobalLockPresent = FALSE; Status = AE_OK; } @@ -529,8 +553,10 @@ AcpiEvAcquireGlobalLock ( AcpiGbl_GlobalLockThreadCount++; - /* If we (OS side vs. BIOS side) have the hardware lock already, we are done */ - + /* + * If we (OS side vs. BIOS side) have the hardware lock already, + * we are done + */ if (AcpiGbl_GlobalLockAcquired) { return_ACPI_STATUS (AE_OK); @@ -578,7 +604,8 @@ AcpiEvAcquireGlobalLock ( ******************************************************************************/ ACPI_STATUS -AcpiEvReleaseGlobalLock (void) +AcpiEvReleaseGlobalLock ( + void) { BOOLEAN Pending = FALSE; ACPI_STATUS Status = AE_OK; @@ -589,7 +616,8 @@ AcpiEvReleaseGlobalLock (void) if (!AcpiGbl_GlobalLockThreadCount) { - ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n")); + ACPI_REPORT_WARNING(( + "Cannot release HW Global Lock, it has not been acquired\n")); return_ACPI_STATUS (AE_NOT_ACQUIRED); } @@ -616,7 +644,8 @@ AcpiEvReleaseGlobalLock (void) */ if (Pending) { - Status = AcpiSetRegister (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1, ACPI_MTX_LOCK); + Status = AcpiSetRegister (ACPI_BITREG_GLOBAL_LOCK_RELEASE, + 1, ACPI_MTX_LOCK); } return_ACPI_STATUS (Status); @@ -636,7 +665,8 @@ AcpiEvReleaseGlobalLock (void) ******************************************************************************/ void -AcpiEvTerminate (void) +AcpiEvTerminate ( + void) { ACPI_NATIVE_UINT i; ACPI_STATUS Status; @@ -659,26 +689,28 @@ AcpiEvTerminate (void) Status = AcpiDisableEvent ((UINT32) i, 0); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not disable fixed event %d\n", (UINT32) i)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not disable fixed event %d\n", (UINT32) i)); } } /* Disable all GPEs in all GPE blocks */ - Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, ACPI_NOT_ISR); + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock); /* Remove SCI handler */ Status = AcpiEvRemoveSciHandler (); if (ACPI_FAILURE(Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not remove SCI handler\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not remove SCI handler\n")); } } /* Deallocate all handler objects installed within GPE info structs */ - Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers, ACPI_NOT_ISR); + Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers); /* Return to original mode if necessary */ diff --git a/sys/contrib/dev/acpica/evregion.c b/sys/contrib/dev/acpica/evregion.c index 50287d8..5447e13 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: 152 $ + * $Revision: 1.156 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -133,6 +133,22 @@ static UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = { ACPI_ADR_SPACE_PCI_CONFIG, ACPI_ADR_SPACE_DATA_TABLE}; +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvRegRun ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiEvInstallHandler ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + /******************************************************************************* * @@ -260,8 +276,8 @@ AcpiEvInitializeOpRegions ( * * FUNCTION: AcpiEvExecuteRegMethod * - * PARAMETERS: RegionObj - Object structure - * Function - Passed to _REG: On (1) or Off (0) + * PARAMETERS: RegionObj - Region object + * Function - Passed to _REG: On (1) or Off (0) * * RETURN: Status * @@ -412,14 +428,16 @@ AcpiEvAddressSpaceDispatch ( { /* No initialization routine, exit with error */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No init routine for region(%p) [%s]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "No init routine for region(%p) [%s]\n", RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId))); return_ACPI_STATUS (AE_NOT_EXIST); } /* - * We must exit the interpreter because the region setup will potentially - * execute control methods (e.g., _REG method for this region) + * We must exit the interpreter because the region + * setup will potentially execute control methods + * (e.g., _REG method for this region) */ AcpiExExitInterpreter (); @@ -730,7 +748,7 @@ AcpiEvAttachRegion ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiEvInstallHandler ( ACPI_HANDLE ObjHandle, UINT32 Level, @@ -973,7 +991,8 @@ AcpiEvInstallSpaceHandler ( { /* * It is (relatively) OK to attempt to install the SAME - * handler twice. This can easily happen with PCI_Config space. + * handler twice. This can easily happen + * with PCI_Config space. */ Status = AE_SAME_HANDLER; goto UnlockAndExit; @@ -1143,7 +1162,7 @@ AcpiEvExecuteRegMethods ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiEvRegRun ( ACPI_HANDLE ObjHandle, UINT32 Level, diff --git a/sys/contrib/dev/acpica/evrgnini.c b/sys/contrib/dev/acpica/evrgnini.c index 64a44cb..1af974c 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: 74 $ + * $Revision: 1.78 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -136,7 +136,7 @@ * * RETURN: Status * - * DESCRIPTION: Do any prep work for region handling, a nop for now + * DESCRIPTION: Setup a SystemMemory operation region * ******************************************************************************/ @@ -193,7 +193,7 @@ AcpiEvSystemMemoryRegionSetup ( * * RETURN: Status * - * DESCRIPTION: Do any prep work for region handling + * DESCRIPTION: Setup a IO operation region * ******************************************************************************/ @@ -224,14 +224,14 @@ AcpiEvIoSpaceRegionSetup ( * * FUNCTION: AcpiEvPciConfigRegionSetup * - * PARAMETERS: Handle - 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 * * RETURN: Status * - * DESCRIPTION: Do any prep work for region handling + * DESCRIPTION: Setup a PCI_Config operation region * * MUTEX: Assumes namespace is not locked * @@ -304,10 +304,14 @@ AcpiEvPciConfigRegionSetup ( Status = AcpiUtExecute_HID (PciRootNode, &ObjectHID); if (ACPI_SUCCESS (Status)) { - /* Got a valid _HID, check if this is a PCI root */ - + /* + * Got a valid _HID string, check if this is a PCI root. + * New for ACPI 3.0: check for a PCI Express root also. + */ if (!(ACPI_STRNCMP (ObjectHID.Value, PCI_ROOT_HID_STRING, - sizeof (PCI_ROOT_HID_STRING)))) + sizeof (PCI_ROOT_HID_STRING)) || + !(ACPI_STRNCMP (ObjectHID.Value, PCI_EXPRESS_ROOT_HID_STRING, + sizeof (PCI_EXPRESS_ROOT_HID_STRING))))) { /* Install a handler for this PCI root bridge */ @@ -420,7 +424,7 @@ AcpiEvPciConfigRegionSetup ( * * RETURN: Status * - * DESCRIPTION: Do any prep work for region handling + * DESCRIPTION: Setup a PciBAR operation region * * MUTEX: Assumes namespace is not locked * @@ -451,7 +455,7 @@ AcpiEvPciBarRegionSetup ( * * RETURN: Status * - * DESCRIPTION: Do any prep work for region handling + * DESCRIPTION: Setup a CMOS operation region * * MUTEX: Assumes namespace is not locked * @@ -482,7 +486,7 @@ AcpiEvCmosRegionSetup ( * * RETURN: Status * - * DESCRIPTION: Do any prep work for region handling + * DESCRIPTION: Default region initialization * ******************************************************************************/ diff --git a/sys/contrib/dev/acpica/evsci.c b/sys/contrib/dev/acpica/evsci.c index 478f004..653f048 100644 --- a/sys/contrib/dev/acpica/evsci.c +++ b/sys/contrib/dev/acpica/evsci.c @@ -2,7 +2,7 @@ * * Module Name: evsci - System Control Interrupt configuration and * legacy to ACPI mode state transition functions - * $Revision: 94 $ + * $Revision: 1.98 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,6 +123,12 @@ #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evsci") +/* Local prototypes */ + +static UINT32 ACPI_SYSTEM_XFACE +AcpiEvSciXruptHandler ( + void *Context); + /******************************************************************************* * @@ -165,7 +171,7 @@ AcpiEvSciXruptHandler ( */ InterruptHandled |= AcpiEvGpeDetect (GpeXruptList); - return_VALUE (InterruptHandled); + return_UINT32 (InterruptHandled); } @@ -203,7 +209,7 @@ AcpiEvGpeXruptHandler ( */ InterruptHandled |= AcpiEvGpeDetect (GpeXruptList); - return_VALUE (InterruptHandled); + return_UINT32 (InterruptHandled); } @@ -220,7 +226,8 @@ AcpiEvGpeXruptHandler ( ******************************************************************************/ UINT32 -AcpiEvInstallSciHandler (void) +AcpiEvInstallSciHandler ( + void) { UINT32 Status = AE_OK; @@ -254,7 +261,8 @@ AcpiEvInstallSciHandler (void) ******************************************************************************/ ACPI_STATUS -AcpiEvRemoveSciHandler (void) +AcpiEvRemoveSciHandler ( + void) { ACPI_STATUS Status; diff --git a/sys/contrib/dev/acpica/evxface.c b/sys/contrib/dev/acpica/evxface.c index 4ae85cc..6519ee5 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: 147 $ + * $Revision: 1.152 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -558,7 +558,8 @@ AcpiRemoveNotifyHandler ( if (Device == ACPI_ROOT_OBJECT) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing notify handler for ROOT object.\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Removing notify handler for ROOT object.\n")); if (((HandlerType & ACPI_SYSTEM_NOTIFY) && !AcpiGbl_SystemNotify.Handler) || @@ -651,8 +652,9 @@ UnlockAndExit: * * FUNCTION: AcpiInstallGpeHandler * - * PARAMETERS: GpeNumber - The GPE number within the GPE block - * GpeBlock - GPE block (NULL == FADT GPEs) + * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT + * defined GPEs) + * GpeNumber - The GPE number within the GPE block * Type - Whether this GPE should be treated as an * edge- or level-triggered interrupt. * Address - Address of the handler @@ -675,6 +677,7 @@ AcpiInstallGpeHandler ( ACPI_GPE_EVENT_INFO *GpeEventInfo; ACPI_HANDLER_INFO *Handler; ACPI_STATUS Status; + ACPI_NATIVE_UINT Flags; ACPI_FUNCTION_TRACE ("AcpiInstallGpeHandler"); @@ -733,7 +736,7 @@ AcpiInstallGpeHandler ( /* Install the handler */ - AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); GpeEventInfo->Dispatch.Handler = Handler; /* Setup up dispatch flags to indicate handler (vs. method) */ @@ -741,7 +744,7 @@ AcpiInstallGpeHandler ( GpeEventInfo->Flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); /* Clear bits */ GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_HANDLER); - AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); UnlockAndExit: @@ -754,8 +757,9 @@ UnlockAndExit: * * FUNCTION: AcpiRemoveGpeHandler * - * PARAMETERS: GpeNumber - The event to remove a handler - * GpeBlock - GPE block (NULL == FADT GPEs) + * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT + * defined GPEs) + * GpeNumber - The event to remove a handler * Address - Address of the handler * * RETURN: Status @@ -773,6 +777,7 @@ AcpiRemoveGpeHandler ( ACPI_GPE_EVENT_INFO *GpeEventInfo; ACPI_HANDLER_INFO *Handler; ACPI_STATUS Status; + ACPI_NATIVE_UINT Flags; ACPI_FUNCTION_TRACE ("AcpiRemoveGpeHandler"); @@ -826,7 +831,7 @@ AcpiRemoveGpeHandler ( /* Remove the handler */ - AcpiOsAcquireLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); Handler = GpeEventInfo->Dispatch.Handler; /* Restore Method node (if any), set dispatch flags */ @@ -837,7 +842,7 @@ AcpiRemoveGpeHandler ( { GpeEventInfo->Flags |= ACPI_GPE_DISPATCH_METHOD; } - AcpiOsReleaseLock (AcpiGbl_GpeLock, ACPI_NOT_ISR); + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); /* Now we can free the handler object */ @@ -855,7 +860,8 @@ UnlockAndExit: * FUNCTION: AcpiAcquireGlobalLock * * PARAMETERS: Timeout - How long the caller is willing to wait - * OutHandle - A handle to the lock if acquired + * Handle - Where the handle to the lock is returned + * (if acquired) * * RETURN: Status * @@ -903,7 +909,7 @@ AcpiAcquireGlobalLock ( * * RETURN: Status * - * DESCRIPTION: Release the ACPI Global Lock + * DESCRIPTION: Release the ACPI Global Lock. The handle must be valid. * ******************************************************************************/ diff --git a/sys/contrib/dev/acpica/evxfevnt.c b/sys/contrib/dev/acpica/evxfevnt.c index 3704f56..9a9b33b 100644 --- a/sys/contrib/dev/acpica/evxfevnt.c +++ b/sys/contrib/dev/acpica/evxfevnt.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable - * $Revision: 79 $ + * $Revision: 1.82 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -138,7 +138,8 @@ ******************************************************************************/ ACPI_STATUS -AcpiEnable (void) +AcpiEnable ( + void) { ACPI_STATUS Status = AE_OK; @@ -169,7 +170,8 @@ AcpiEnable (void) return_ACPI_STATUS (Status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Transition to ACPI mode successful\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Transition to ACPI mode successful\n")); } return_ACPI_STATUS (Status); @@ -184,12 +186,13 @@ AcpiEnable (void) * * RETURN: Status * - * DESCRIPTION: Transfers the system into LEGACY mode. + * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode. * ******************************************************************************/ ACPI_STATUS -AcpiDisable (void) +AcpiDisable ( + void) { ACPI_STATUS Status = AE_OK; @@ -205,7 +208,8 @@ AcpiDisable (void) if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY) { - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in legacy (non-ACPI) mode\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "System is already in legacy (non-ACPI) mode\n")); } else { @@ -215,7 +219,8 @@ AcpiDisable (void) if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not exit ACPI mode to legacy mode")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not exit ACPI mode to legacy mode")); return_ACPI_STATUS (Status); } @@ -299,7 +304,7 @@ AcpiEnableEvent ( * * RETURN: Status * - * DESCRIPTION: Enable an ACPI event (general purpose) + * DESCRIPTION: Set the type of an individual GPE * ******************************************************************************/ @@ -623,7 +628,7 @@ UnlockAndExit: * FUNCTION: AcpiGetEventStatus * * PARAMETERS: Event - The fixed event - * Event Status - Where the current status of the event will + * EventStatus - Where the current status of the event will * be returned * * RETURN: Status @@ -671,7 +676,7 @@ AcpiGetEventStatus ( * PARAMETERS: GpeDevice - Parent GPE Device * GpeNumber - GPE level within the GPE block * Flags - Called from an ISR or not - * Event Status - Where the current status of the event will + * EventStatus - Where the current status of the event will * be returned * * RETURN: Status @@ -734,7 +739,7 @@ UnlockAndExit: * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device * GpeBlockAddress - Address and SpaceID * RegisterCount - Number of GPE register pairs in the block - * InterruptLevel - H/W interrupt for the block + * InterruptNumber - H/W interrupt for the block * * RETURN: Status * @@ -747,7 +752,7 @@ AcpiInstallGpeBlock ( ACPI_HANDLE GpeDevice, ACPI_GENERIC_ADDRESS *GpeBlockAddress, UINT32 RegisterCount, - UINT32 InterruptLevel) + UINT32 InterruptNumber) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; @@ -783,7 +788,7 @@ AcpiInstallGpeBlock ( * is always zero */ Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount, - 0, InterruptLevel, &GpeBlock); + 0, InterruptNumber, &GpeBlock); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; diff --git a/sys/contrib/dev/acpica/evxfregn.c b/sys/contrib/dev/acpica/evxfregn.c index 5c023ab..a4f3c74 100644 --- a/sys/contrib/dev/acpica/evxfregn.c +++ b/sys/contrib/dev/acpica/evxfregn.c @@ -2,7 +2,7 @@ * * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and * Address Spaces. - * $Revision: 63 $ + * $Revision: 1.64 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License diff --git a/sys/contrib/dev/acpica/exconfig.c b/sys/contrib/dev/acpica/exconfig.c index 793131d..ea10bf5 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: 79 $ + * $Revision: 1.87 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -129,6 +129,14 @@ #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exconfig") +/* Local prototypes */ + +static ACPI_STATUS +AcpiExAddTable ( + ACPI_TABLE_HEADER *Table, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_OPERAND_OBJECT **DdbHandle); + /******************************************************************************* * @@ -145,7 +153,7 @@ * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExAddTable ( ACPI_TABLE_HEADER *Table, ACPI_NAMESPACE_NODE *ParentNode, @@ -167,18 +175,31 @@ AcpiExAddTable ( return_ACPI_STATUS (AE_NO_MEMORY); } + /* Init the table handle */ + + ObjDesc->Reference.Opcode = AML_LOAD_OP; + *DdbHandle = ObjDesc; + /* Install the new table into the local data structures */ ACPI_MEMSET (&TableInfo, 0, sizeof (ACPI_TABLE_DESC)); - TableInfo.Type = ACPI_TABLE_SSDT; - TableInfo.Pointer = Table; - TableInfo.Length = (ACPI_SIZE) Table->Length; - TableInfo.Allocation = ACPI_MEM_ALLOCATED; + TableInfo.Type = ACPI_TABLE_SSDT; + TableInfo.Pointer = Table; + TableInfo.Length = (ACPI_SIZE) Table->Length; + TableInfo.Allocation = ACPI_MEM_ALLOCATED; Status = AcpiTbInstallTable (&TableInfo); + ObjDesc->Reference.Object = TableInfo.InstalledDesc; + if (ACPI_FAILURE (Status)) { + if (Status == AE_ALREADY_EXISTS) + { + /* Table already exists, just return the handle */ + + return_ACPI_STATUS (AE_OK); + } goto Cleanup; } @@ -193,16 +214,12 @@ AcpiExAddTable ( goto Cleanup; } - /* Init the table handle */ - - ObjDesc->Reference.Opcode = AML_LOAD_OP; - ObjDesc->Reference.Object = TableInfo.InstalledDesc; - *DdbHandle = ObjDesc; return_ACPI_STATUS (AE_OK); Cleanup: AcpiUtRemoveReference (ObjDesc); + *DdbHandle = NULL; return_ACPI_STATUS (Status); } @@ -312,11 +329,10 @@ AcpiExLoadTableOp ( StartNode = ParentNode; } - /* - * Find the node referenced by the ParameterPathString - */ + /* Find the node referenced by the ParameterPathString */ + Status = AcpiNsGetNodeByPath (Operand[4]->String.Pointer, StartNode, - ACPI_NS_SEARCH_PARENT, &ParameterNode); + ACPI_NS_SEARCH_PARENT, &ParameterNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -337,8 +353,9 @@ AcpiExLoadTableOp ( { /* Store the parameter data into the optional parameter object */ - Status = AcpiExStore (Operand[5], ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), - WalkState); + Status = AcpiExStore (Operand[5], + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), + WalkState); if (ACPI_FAILURE (Status)) { (void) AcpiExUnloadTable (DdbHandle); @@ -468,16 +485,23 @@ AcpiExLoadOp ( Status = AcpiExReadDataFromField (WalkState, ObjDesc, &BufferDesc); if (ACPI_FAILURE (Status)) { - goto Cleanup; + return_ACPI_STATUS (Status); } - TablePtr = ACPI_CAST_PTR (ACPI_TABLE_HEADER, BufferDesc->Buffer.Pointer); + TablePtr = ACPI_CAST_PTR (ACPI_TABLE_HEADER, + BufferDesc->Buffer.Pointer); + + /* All done with the BufferDesc, delete it */ - /* Sanity check the table length */ + BufferDesc->Buffer.Pointer = NULL; + AcpiUtRemoveReference (BufferDesc); + + /* Sanity check the table length */ if (TablePtr->Length < sizeof (ACPI_TABLE_HEADER)) { - return_ACPI_STATUS (AE_BAD_HEADER); + Status = AE_BAD_HEADER; + goto Cleanup; } break; @@ -507,7 +531,9 @@ AcpiExLoadOp ( Status = AcpiExAddTable (TablePtr, AcpiGbl_RootNode, &DdbHandle); if (ACPI_FAILURE (Status)) { - goto Cleanup; + /* On error, TablePtr was deallocated above */ + + return_ACPI_STATUS (Status); } /* Store the DdbHandle into the Target operand */ @@ -516,18 +542,14 @@ AcpiExLoadOp ( if (ACPI_FAILURE (Status)) { (void) AcpiExUnloadTable (DdbHandle); - } - return_ACPI_STATUS (Status); + /* TablePtr was deallocated above */ + return_ACPI_STATUS (Status); + } Cleanup: - - if (BufferDesc) - { - AcpiUtRemoveReference (BufferDesc); - } - else + if (ACPI_FAILURE (Status)) { ACPI_MEM_FREE (TablePtr); } @@ -580,7 +602,8 @@ AcpiExUnloadTable ( * Delete the entire namespace under this table Node * (Offset contains the TableId) */ - AcpiNsDeleteNamespaceByOwner (TableInfo->TableId); + AcpiNsDeleteNamespaceByOwner (TableInfo->OwnerId); + AcpiUtReleaseOwnerId (&TableInfo->OwnerId); /* Delete the table itself */ diff --git a/sys/contrib/dev/acpica/exconvrt.c b/sys/contrib/dev/acpica/exconvrt.c index 801d4d3..6566cbc 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: 59 $ + * $Revision: 1.67 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,6 +125,15 @@ #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exconvrt") +/* Local prototypes */ + +static UINT32 +AcpiExConvertToAscii ( + ACPI_INTEGER Integer, + UINT16 Base, + UINT8 *String, + UINT8 MaxLength); + /******************************************************************************* * @@ -191,9 +200,8 @@ AcpiExConvertToInteger ( */ Result = 0; - /* - * String conversion is different than Buffer conversion - */ + /* String conversion is different than Buffer conversion */ + switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_STRING: @@ -214,6 +222,13 @@ AcpiExConvertToInteger ( case ACPI_TYPE_BUFFER: + /* Check for zero-length buffer */ + + if (!Count) + { + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + } + /* Transfer no more than an integer's worth of data */ if (Count > AcpiGbl_IntegerByteWidth) @@ -242,9 +257,8 @@ AcpiExConvertToInteger ( break; } - /* - * Create a new integer - */ + /* Create a new integer */ + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { @@ -322,8 +336,14 @@ AcpiExConvertToBuffer ( /* * Create a new Buffer object * Size will be the string length + * + * NOTE: Add one to the string length to include the null terminator. + * The ACPI spec is unclear on this subject, but there is existing + * ASL/AML code that depends on the null being transferred to the new + * buffer. */ - ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) ObjDesc->String.Length); + ReturnDesc = AcpiUtCreateBufferObject ( + (ACPI_SIZE) ObjDesc->String.Length + 1); if (!ReturnDesc) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -364,7 +384,7 @@ AcpiExConvertToBuffer ( * ******************************************************************************/ -UINT32 +static UINT32 AcpiExConvertToAscii ( ACPI_INTEGER Integer, UINT16 Base, @@ -436,8 +456,9 @@ AcpiExConvertToAscii ( case 16: - HexLength = ACPI_MUL_2 (DataWidth); /* 2 ascii hex chars per data byte */ + /* HexLength: 2 ascii hex chars per data byte */ + HexLength = (ACPI_NATIVE_UINT) ACPI_MUL_2 (DataWidth); for (i = 0, j = (HexLength-1); i < HexLength; i++, j--) { /* Get one hex digit, most significant digits first */ @@ -491,9 +512,9 @@ AcpiExConvertToString ( { ACPI_OPERAND_OBJECT *ReturnDesc; UINT8 *NewBuf; + UINT32 i; UINT32 StringLength = 0; UINT16 Base = 16; - UINT32 i; UINT8 Separator = ','; @@ -556,17 +577,37 @@ AcpiExConvertToString ( case ACPI_TYPE_BUFFER: + /* Setup string length, base, and separator */ + switch (Type) { - case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString operator */ + case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */ /* * 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 */ - /*lint -fallthrough */ + /* + * Calculate the final string length. Individual string values + * are variable length (include separator for each) + */ + for (i = 0; i < ObjDesc->Buffer.Length; i++) + { + if (ObjDesc->Buffer.Pointer[i] >= 100) + { + StringLength += 4; + } + else if (ObjDesc->Buffer.Pointer[i] >= 10) + { + StringLength += 3; + } + else + { + StringLength += 2; + } + } + break; case ACPI_IMPLICIT_CONVERT_HEX: /* @@ -574,60 +615,60 @@ AcpiExConvertToString ( *"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) - { - Separator = ' '; - } - - /*lint -fallthrough */ + Separator = ' '; + StringLength = (ObjDesc->Buffer.Length * 3); + break; - case ACPI_EXPLICIT_CONVERT_HEX: /* Used by ToHexString operator */ + case ACPI_EXPLICIT_CONVERT_HEX: /* Used by ToHexString */ /* * 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 and string buffer */ - - ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength -1); - if (!ReturnDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - NewBuf = ReturnDesc->Buffer.Pointer; + StringLength = (ObjDesc->Buffer.Length * 3); + break; - /* - * 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 */ - } + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } - /* Null terminate the string (overwrites final comma from above) */ + /* + * Perform the conversion. + * (-1 because of extra separator included in StringLength from above) + */ + StringLength--; + if (StringLength > ACPI_MAX_STRING_CONVERSION) /* ACPI limit */ + { + return_ACPI_STATUS (AE_AML_STRING_LIMIT); + } - NewBuf--; - *NewBuf = 0; + /* Create a new string object and string buffer */ - /* Recalculate length */ + ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } - ReturnDesc->String.Length = (UINT32) - ACPI_STRLEN (ReturnDesc->String.Pointer); - break; + NewBuf = ReturnDesc->Buffer.Pointer; - default: - return_ACPI_STATUS (AE_BAD_PARAMETER); + /* + * Convert buffer bytes to hex or decimal values + * (separated by commas or spaces) + */ + 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 */ } + + /* + * Null terminate the string + * (overwrites final comma/space from above) + */ + NewBuf--; + *NewBuf = 0; break; default: @@ -722,7 +763,6 @@ AcpiExConvertToTargetType ( case ACPI_TYPE_STRING: - /* * The operand must be a String. We can convert an * Integer or Buffer if necessary @@ -733,7 +773,6 @@ AcpiExConvertToTargetType ( case ACPI_TYPE_BUFFER: - /* * The operand must be a Buffer. We can convert an * Integer or String if necessary diff --git a/sys/contrib/dev/acpica/excreate.c b/sys/contrib/dev/acpica/excreate.c index 19eea72..f9d09e0 100644 --- a/sys/contrib/dev/acpica/excreate.c +++ b/sys/contrib/dev/acpica/excreate.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: excreate - Named object creation - * $Revision: 103 $ + * $Revision: 1.106 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -130,7 +130,7 @@ #ifndef ACPI_NO_METHOD_EXECUTION -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreateAlias * @@ -140,7 +140,7 @@ * * DESCRIPTION: Create a new named alias * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateAlias ( @@ -217,8 +217,7 @@ AcpiExCreateAlias ( * target node or the alias Node */ Status = AcpiNsAttachObject (AliasNode, - AcpiNsGetAttachedObject (TargetNode), - TargetNode->Type); + AcpiNsGetAttachedObject (TargetNode), TargetNode->Type); break; } @@ -228,7 +227,7 @@ AcpiExCreateAlias ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreateEvent * @@ -238,7 +237,7 @@ AcpiExCreateAlias ( * * DESCRIPTION: Create a new event object * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateEvent ( @@ -263,7 +262,7 @@ AcpiExCreateEvent ( * that the event is created in an unsignalled state */ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, - &ObjDesc->Event.Semaphore); + &ObjDesc->Event.Semaphore); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -272,7 +271,7 @@ AcpiExCreateEvent ( /* Attach object to the Node */ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], - ObjDesc, ACPI_TYPE_EVENT); + ObjDesc, ACPI_TYPE_EVENT); Cleanup: /* @@ -284,7 +283,7 @@ Cleanup: } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreateMutex * @@ -296,7 +295,7 @@ Cleanup: * * Mutex (Name[0], SyncLevel[1]) * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateMutex ( @@ -348,20 +347,20 @@ Cleanup: } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreateRegion * * PARAMETERS: AmlStart - Pointer to the region declaration AML * AmlLength - Max length of the declaration AML - * Operands - List of operands for the opcode + * RegionSpace - SpaceID for the region * WalkState - Current state * * RETURN: Status * * DESCRIPTION: Create a new operation region object * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateRegion ( @@ -404,7 +403,7 @@ AcpiExCreateRegion ( } ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", - AcpiUtGetRegionName (RegionSpace), RegionSpace)); + AcpiUtGetRegionName (RegionSpace), RegionSpace)); /* Create the region descriptor */ @@ -444,7 +443,7 @@ Cleanup: } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreateTableRegion * @@ -454,7 +453,7 @@ Cleanup: * * DESCRIPTION: Create a new DataTableRegion object * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateTableRegion ( @@ -546,7 +545,7 @@ Cleanup: } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreateProcessor * @@ -558,7 +557,7 @@ Cleanup: * * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateProcessor ( @@ -580,9 +579,8 @@ AcpiExCreateProcessor ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* - * Initialize the processor object from the operands - */ + /* Initialize the processor object from the operands */ + ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value; ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; @@ -599,7 +597,7 @@ AcpiExCreateProcessor ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExCreatePowerResource * @@ -611,7 +609,7 @@ AcpiExCreateProcessor ( * * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreatePowerResource ( @@ -648,10 +646,10 @@ AcpiExCreatePowerResource ( AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } - #endif -/***************************************************************************** + +/******************************************************************************* * * FUNCTION: AcpiExCreateMethod * @@ -663,7 +661,7 @@ AcpiExCreatePowerResource ( * * DESCRIPTION: Create a new method object * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS AcpiExCreateMethod ( diff --git a/sys/contrib/dev/acpica/exdump.c b/sys/contrib/dev/acpica/exdump.c index 72d1eb2..d3a4cd5 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: 176 $ + * $Revision: 1.188 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,23 +125,56 @@ #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exdump") - /* * The following routines are used for debug output only */ #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) -/***************************************************************************** +/* Local prototypes */ + +static void +AcpiExOutString ( + char *Title, + char *Value); + +static void +AcpiExOutPointer ( + char *Title, + void *Value); + +static void +AcpiExOutInteger ( + char *Title, + UINT32 Value); + +static void +AcpiExOutAddress ( + char *Title, + ACPI_PHYSICAL_ADDRESS Value); + +static void +AcpiExDumpReference ( + ACPI_OPERAND_OBJECT *ObjDesc); + +static void +AcpiExDumpPackage ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Level, + UINT32 Index); + + +/******************************************************************************* * * FUNCTION: AcpiExDumpOperand * - * PARAMETERS: *ObjDesc - Pointer to entry to be dumped + * PARAMETERS: *ObjDesc - Pointer to entry to be dumped + * Depth - Current nesting depth * * RETURN: None * * DESCRIPTION: Dump an operand object * - ****************************************************************************/ + ******************************************************************************/ void AcpiExDumpOperand ( @@ -162,16 +195,15 @@ AcpiExDumpOperand ( if (!ObjDesc) { - /* - * This could be a null element of a package - */ + /* This could be a null element of a package */ + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); return; } if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p is a NS Node: ", ObjDesc)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", ObjDesc)); ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_EXEC); return; } @@ -197,6 +229,7 @@ AcpiExDumpOperand ( ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc)); } + /* Decode object type */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { @@ -288,7 +321,7 @@ AcpiExDumpOperand ( case ACPI_TYPE_BUFFER: - AcpiOsPrintf ("Buffer len %X @ %p \n", + AcpiOsPrintf ("Buffer len %X @ %p\n", ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer); Length = ObjDesc->Buffer.Length; @@ -366,7 +399,9 @@ 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; @@ -382,10 +417,13 @@ AcpiExDumpOperand ( AcpiOsPrintf ( "RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at byte=%X bit=%X of below:\n", - ObjDesc->Field.BitLength, ObjDesc->Field.AccessByteWidth, + ObjDesc->Field.BitLength, + ObjDesc->Field.AccessByteWidth, ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK, ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK, - ObjDesc->Field.BaseByteOffset, ObjDesc->Field.StartFieldBitOffset); + ObjDesc->Field.BaseByteOffset, + ObjDesc->Field.StartFieldBitOffset); + AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1); break; @@ -399,17 +437,19 @@ AcpiExDumpOperand ( case ACPI_TYPE_BUFFER_FIELD: AcpiOsPrintf ( - "BufferField: %X bits at byte %X bit %X of \n", - ObjDesc->BufferField.BitLength, ObjDesc->BufferField.BaseByteOffset, + "BufferField: %X bits at byte %X bit %X of\n", + ObjDesc->BufferField.BitLength, + ObjDesc->BufferField.BaseByteOffset, ObjDesc->BufferField.StartFieldBitOffset); if (!ObjDesc->BufferField.BufferObj) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL* \n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n")); } - else if (ACPI_GET_OBJECT_TYPE (ObjDesc->BufferField.BufferObj) != ACPI_TYPE_BUFFER) + else if (ACPI_GET_OBJECT_TYPE (ObjDesc->BufferField.BufferObj) != + ACPI_TYPE_BUFFER) { - AcpiOsPrintf ("*not a Buffer* \n"); + AcpiOsPrintf ("*not a Buffer*\n"); } else { @@ -426,10 +466,10 @@ AcpiExDumpOperand ( case ACPI_TYPE_METHOD: - AcpiOsPrintf ( - "Method(%X) @ %p:%X\n", + AcpiOsPrintf ("Method(%X) @ %p:%X\n", ObjDesc->Method.ParamCount, - ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength); + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength); break; @@ -474,7 +514,7 @@ AcpiExDumpOperand ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExDumpOperands * @@ -488,7 +528,7 @@ AcpiExDumpOperand ( * * DESCRIPTION: Dump the object stack * - ****************************************************************************/ + ******************************************************************************/ void AcpiExDumpOperands ( @@ -533,15 +573,15 @@ AcpiExDumpOperands ( } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "************* Stack dump from %s(%d), %s\n", + "************* Operand Stack dump from %s(%d), %s\n", ModuleName, LineNumber, Note)); return; } -/***************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiExOut* + * FUNCTION: AcpiExOut* functions * * PARAMETERS: Title - Descriptive text * Value - Value to be displayed @@ -550,9 +590,9 @@ AcpiExDumpOperands ( * reduce the number of format strings required and keeps them * all in one place for easy modification. * - ****************************************************************************/ + ******************************************************************************/ -void +static void AcpiExOutString ( char *Title, char *Value) @@ -560,7 +600,7 @@ AcpiExOutString ( AcpiOsPrintf ("%20s : %s\n", Title, Value); } -void +static void AcpiExOutPointer ( char *Title, void *Value) @@ -568,15 +608,15 @@ AcpiExOutPointer ( AcpiOsPrintf ("%20s : %p\n", Title, Value); } -void +static void AcpiExOutInteger ( char *Title, UINT32 Value) { - AcpiOsPrintf ("%20s : %X\n", Title, Value); + AcpiOsPrintf ("%20s : %.2X\n", Title, Value); } -void +static void AcpiExOutAddress ( char *Title, ACPI_PHYSICAL_ADDRESS Value) @@ -590,16 +630,16 @@ AcpiExOutAddress ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiExDumpNode * * PARAMETERS: *Node - Descriptor to dump - * Flags - Force display + * Flags - Force display if TRUE * * DESCRIPTION: Dumps the members of the given.Node * - ****************************************************************************/ + ******************************************************************************/ void AcpiExDumpNode ( @@ -630,28 +670,177 @@ AcpiExDumpNode ( } -/***************************************************************************** +/******************************************************************************* + * + * FUNCTION: AcpiExDumpReference + * + * PARAMETERS: Object - Descriptor to dump + * + * DESCRIPTION: Dumps a reference object + * + ******************************************************************************/ + +static void +AcpiExDumpReference ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_BUFFER RetBuf; + ACPI_STATUS Status; + + + if (ObjDesc->Reference.Opcode == AML_INT_NAMEPATH_OP) + { + AcpiOsPrintf ("Named Object %p ", ObjDesc->Reference.Node); + RetBuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, &RetBuf); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf ("Could not convert name to pathname\n"); + } + else + { + AcpiOsPrintf ("%s\n", (char *) RetBuf.Pointer); + ACPI_MEM_FREE (RetBuf.Pointer); + } + } + else if (ObjDesc->Reference.Object) + { + AcpiOsPrintf ("\nReferenced Object: %p\n", ObjDesc->Reference.Object); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpPackage + * + * PARAMETERS: Object - Descriptor to dump + * Level - Indentation Level + * Index - Package index for this object + * + * DESCRIPTION: Dumps the elements of the package + * + ******************************************************************************/ + +static void +AcpiExDumpPackage ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Level, + UINT32 Index) +{ + UINT32 i; + + + /* Indentation and index output */ + + if (Level > 0) + { + for (i = 0; i < Level; i++) + { + AcpiOsPrintf (" "); + } + + AcpiOsPrintf ("[%.2d] ", Index); + } + + AcpiOsPrintf ("%p ", ObjDesc); + + /* Null package elements are allowed */ + + if (!ObjDesc) + { + AcpiOsPrintf ("[Null Object]\n"); + return; + } + + /* Packages may only contain a few object types */ + + switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + { + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("[String] Value: "); + for (i = 0; i < ObjDesc->String.Length; i++) + { + AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]); + } + AcpiOsPrintf ("\n"); + break; + + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length); + if (ObjDesc->Buffer.Length) + { + AcpiUtDumpBuffer ((UINT8 *) ObjDesc->Buffer.Pointer, + ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); + } + else + { + AcpiOsPrintf ("\n"); + } + break; + + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("[Package] Contains %d Elements:\n", + ObjDesc->Package.Count); + + for (i = 0; i < ObjDesc->Package.Count; i++) + { + AcpiExDumpPackage (ObjDesc->Package.Elements[i], Level+1, i); + } + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + AcpiOsPrintf ("[Object Reference] "); + AcpiExDumpReference (ObjDesc); + break; + + + default: + + AcpiOsPrintf ("[Unknown Type] %X\n", ACPI_GET_OBJECT_TYPE (ObjDesc)); + break; + } +} + + +/******************************************************************************* * * FUNCTION: AcpiExDumpObjectDescriptor * - * PARAMETERS: *Object - Descriptor to dump - * Flags - Force display + * PARAMETERS: Object - Descriptor to dump + * Flags - Force display if TRUE * * DESCRIPTION: Dumps the members of the object descriptor given. * - ****************************************************************************/ + ******************************************************************************/ void AcpiExDumpObjectDescriptor ( ACPI_OPERAND_OBJECT *ObjDesc, UINT32 Flags) { - UINT32 i; - - ACPI_FUNCTION_TRACE ("ExDumpObjectDescriptor"); + if (!ObjDesc) + { + return_VOID; + } + if (!Flags) { if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) @@ -716,25 +905,13 @@ AcpiExDumpObjectDescriptor ( case ACPI_TYPE_PACKAGE: AcpiExOutInteger ("Flags", ObjDesc->Package.Flags); - AcpiExOutInteger ("Count", ObjDesc->Package.Count); - AcpiExOutPointer ("Elements", ObjDesc->Package.Elements); + AcpiExOutInteger ("Elements", ObjDesc->Package.Count); + AcpiExOutPointer ("Element List", ObjDesc->Package.Elements); /* Dump the package contents */ - if (ObjDesc->Package.Count > 0) - { - AcpiOsPrintf ("\nPackage Contents:\n"); - for (i = 0; i < ObjDesc->Package.Count; i++) - { - AcpiOsPrintf ("[%.3d] %p", i, ObjDesc->Package.Elements[i]); - if (ObjDesc->Package.Elements[i]) - { - AcpiOsPrintf (" %s", - AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[i])); - } - AcpiOsPrintf ("\n"); - } - } + AcpiOsPrintf ("\nPackage Contents:\n"); + AcpiExDumpPackage (ObjDesc, 0, 0); break; @@ -757,7 +934,7 @@ AcpiExDumpObjectDescriptor ( AcpiExOutInteger ("ParamCount", ObjDesc->Method.ParamCount); AcpiExOutInteger ("Concurrency", ObjDesc->Method.Concurrency); AcpiExOutPointer ("Semaphore", ObjDesc->Method.Semaphore); - AcpiExOutInteger ("OwningId", ObjDesc->Method.OwningId); + AcpiExOutInteger ("OwnerId", ObjDesc->Method.OwnerId); AcpiExOutInteger ("AmlLength", ObjDesc->Method.AmlLength); AcpiExOutPointer ("AmlStart", ObjDesc->Method.AmlStart); break; @@ -821,9 +998,6 @@ AcpiExDumpObjectDescriptor ( 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)) @@ -858,11 +1032,14 @@ AcpiExDumpObjectDescriptor ( case ACPI_TYPE_LOCAL_REFERENCE: AcpiExOutInteger ("TargetType", ObjDesc->Reference.TargetType); - AcpiExOutString ("Opcode", (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name); + 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); + + AcpiExDumpReference (ObjDesc); break; diff --git a/sys/contrib/dev/acpica/exfield.c b/sys/contrib/dev/acpica/exfield.c index a8d455a..3cb7482 100644 --- a/sys/contrib/dev/acpica/exfield.c +++ b/sys/contrib/dev/acpica/exfield.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: exfield - ACPI AML (p-code) execution - field manipulation - * $Revision: 120 $ + * $Revision: 1.124 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -163,6 +163,10 @@ AcpiExReadDataFromField ( { return_ACPI_STATUS (AE_AML_NO_OPERAND); } + if (!RetBufferDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_BUFFER_FIELD) { @@ -201,8 +205,8 @@ AcpiExReadDataFromField ( * Note: Smbus protocol value is passed in upper 16-bits of Function */ Status = AcpiExAccessRegion (ObjDesc, 0, - ACPI_CAST_PTR (ACPI_INTEGER, BufferDesc->Buffer.Pointer), - ACPI_READ | (ObjDesc->Field.Attribute << 16)); + ACPI_CAST_PTR (ACPI_INTEGER, BufferDesc->Buffer.Pointer), + ACPI_READ | (ObjDesc->Field.Attribute << 16)); AcpiExReleaseGlobalLock (Locked); goto Exit; } @@ -268,7 +272,7 @@ Exit: { AcpiUtRemoveReference (BufferDesc); } - else if (RetBufferDesc) + else { *RetBufferDesc = BufferDesc; } @@ -283,6 +287,7 @@ Exit: * * PARAMETERS: SourceDesc - Contains data to write * ObjDesc - The named field + * ResultDesc - Where the return value is returned, if any * * RETURN: Status * @@ -343,13 +348,16 @@ AcpiExWriteDataToField ( { ACPI_REPORT_ERROR (("SMBus write requires Buffer, found type %s\n", AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } if (SourceDesc->Buffer.Length < ACPI_SMBUS_BUFFER_SIZE) { - ACPI_REPORT_ERROR (("SMBus write requires Buffer of length %X, found length %X\n", + ACPI_REPORT_ERROR (( + "SMBus write requires Buffer of length %X, found length %X\n", ACPI_SMBUS_BUFFER_SIZE, SourceDesc->Buffer.Length)); + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); } @@ -360,14 +368,16 @@ AcpiExWriteDataToField ( } Buffer = BufferDesc->Buffer.Pointer; - ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, ACPI_SMBUS_BUFFER_SIZE); + ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, + ACPI_SMBUS_BUFFER_SIZE); /* Lock entire transaction if requested */ Locked = AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); /* - * Perform the write (returns status and perhaps data in the same buffer) + * Perform the write (returns status and perhaps data in the + * same buffer) * Note: SMBus protocol type is passed in upper 16-bits of Function. */ Status = AcpiExAccessRegion (ObjDesc, 0, @@ -379,9 +389,8 @@ AcpiExWriteDataToField ( return_ACPI_STATUS (Status); } - /* - * Get a pointer to the data to be written - */ + /* Get a pointer to the data to be written */ + switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) { case ACPI_TYPE_INTEGER: @@ -410,7 +419,8 @@ AcpiExWriteDataToField ( * the ACPI specification. */ NewBuffer = NULL; - RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength); + RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES ( + ObjDesc->CommonField.BitLength); if (Length < RequiredLength) { @@ -436,6 +446,7 @@ AcpiExWriteDataToField ( "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n", SourceDesc, AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (SourceDesc)), ACPI_GET_OBJECT_TYPE (SourceDesc), Buffer, Length)); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n", ObjDesc, AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc)), diff --git a/sys/contrib/dev/acpica/exfldio.c b/sys/contrib/dev/acpica/exfldio.c index 3b56738..efd1dec 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: 111 $ + * $Revision: 1.116 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -127,12 +127,31 @@ #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exfldio") +/* Local prototypes */ + +static ACPI_STATUS +AcpiExFieldDatumIo ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 ReadWrite); + +static BOOLEAN +AcpiExRegisterOverflow ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Value); + +static ACPI_STATUS +AcpiExSetupRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset); + /******************************************************************************* * * FUNCTION: AcpiExSetupRegion * - * PARAMETERS: *ObjDesc - Field to be read or written + * PARAMETERS: ObjDesc - Field to be read or written * FieldDatumByteOffset - Byte offset of this datum within the * parent field * @@ -144,7 +163,7 @@ * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExSetupRegion ( ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset) @@ -208,9 +227,9 @@ AcpiExSetupRegion ( * length of one field datum (access width) must fit within the region. * (Region length is specified in bytes) */ - if (RgnDesc->Region.Length < (ObjDesc->CommonField.BaseByteOffset - + FieldDatumByteOffset - + ObjDesc->CommonField.AccessByteWidth)) + if (RgnDesc->Region.Length < (ObjDesc->CommonField.BaseByteOffset + + FieldDatumByteOffset + + ObjDesc->CommonField.AccessByteWidth)) { if (AcpiGbl_EnableInterpreterSlack) { @@ -240,7 +259,8 @@ AcpiExSetupRegion ( "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n", AcpiUtGetNodeName (ObjDesc->CommonField.Node), ObjDesc->CommonField.AccessByteWidth, - AcpiUtGetNodeName (RgnDesc->Region.Node), RgnDesc->Region.Length)); + AcpiUtGetNodeName (RgnDesc->Region.Node), + RgnDesc->Region.Length)); } /* @@ -252,7 +272,8 @@ AcpiExSetupRegion ( AcpiUtGetNodeName (ObjDesc->CommonField.Node), ObjDesc->CommonField.BaseByteOffset, FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth, - AcpiUtGetNodeName (RgnDesc->Region.Node), RgnDesc->Region.Length)); + AcpiUtGetNodeName (RgnDesc->Region.Node), + RgnDesc->Region.Length)); return_ACPI_STATUS (AE_AML_REGION_LIMIT); } @@ -265,10 +286,10 @@ AcpiExSetupRegion ( * * FUNCTION: AcpiExAccessRegion * - * PARAMETERS: *ObjDesc - Field to be read + * PARAMETERS: ObjDesc - Field to be read * FieldDatumByteOffset - Byte offset of this datum within the * parent field - * *Value - Where to store value (must at least + * Value - Where to store value (must at least * the size of ACPI_INTEGER) * Function - Read or Write flag plus other region- * dependent flags @@ -312,9 +333,9 @@ AcpiExAccessRegion ( * 3) The current offset into the field */ RgnDesc = ObjDesc->CommonField.RegionObj; - Address = RgnDesc->Region.Address - + ObjDesc->CommonField.BaseByteOffset - + FieldDatumByteOffset; + Address = RgnDesc->Region.Address + + ObjDesc->CommonField.BaseByteOffset + + FieldDatumByteOffset; if ((Function & ACPI_IO_MASK) == ACPI_READ) { @@ -337,7 +358,8 @@ AcpiExAccessRegion ( /* Invoke the appropriate AddressSpace/OpRegion handler */ Status = AcpiEvAddressSpaceDispatch (RgnDesc, Function, - Address, ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); + Address, + ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); if (ACPI_FAILURE (Status)) { @@ -365,7 +387,7 @@ AcpiExAccessRegion ( * * FUNCTION: AcpiExRegisterOverflow * - * PARAMETERS: *ObjDesc - Register(Field) to be written + * PARAMETERS: ObjDesc - Register(Field) to be written * Value - Value to be stored * * RETURN: TRUE if value overflows the field, FALSE otherwise @@ -378,7 +400,7 @@ AcpiExAccessRegion ( * ******************************************************************************/ -BOOLEAN +static BOOLEAN AcpiExRegisterOverflow ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_INTEGER Value) @@ -412,10 +434,10 @@ AcpiExRegisterOverflow ( * * FUNCTION: AcpiExFieldDatumIo * - * PARAMETERS: *ObjDesc - Field to be read + * PARAMETERS: ObjDesc - Field to be read * FieldDatumByteOffset - Byte offset of this datum within the * parent field - * *Value - Where to store value (must be 64 bits) + * Value - Where to store value (must be 64 bits) * ReadWrite - Read or Write flag * * RETURN: Status @@ -426,7 +448,7 @@ AcpiExRegisterOverflow ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExFieldDatumIo ( ACPI_OPERAND_OBJECT *ObjDesc, UINT32 FieldDatumByteOffset, @@ -445,7 +467,9 @@ AcpiExFieldDatumIo ( if (!Value) { LocalValue = 0; - Value = &LocalValue; /* To support reads without saving return value */ + + /* To support reads without saving return value */ + Value = &LocalValue; } /* Clear the entire return buffer first, [Very Important!] */ @@ -458,8 +482,10 @@ AcpiExFieldDatumIo ( * * BufferField - Read/write from/to a Buffer * RegionField - Read/write from/to a Operation Region. - * BankField - Write to a Bank Register, then read/write from/to an OpRegion - * IndexField - Write to an Index Register, then read/write from/to a Data Register + * BankField - Write to a Bank Register, then read/write from/to an + * OperationRegion + * IndexField - Write to an Index Register, then read/write from/to a + * Data Register */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { @@ -483,10 +509,11 @@ AcpiExFieldDatumIo ( * Copy the data from the source buffer. * Length is the field width in bytes. */ - ACPI_MEMCPY (Value, (ObjDesc->BufferField.BufferObj)->Buffer.Pointer - + ObjDesc->BufferField.BaseByteOffset - + FieldDatumByteOffset, - ObjDesc->CommonField.AccessByteWidth); + ACPI_MEMCPY (Value, + (ObjDesc->BufferField.BufferObj)->Buffer.Pointer + + ObjDesc->BufferField.BaseByteOffset + + FieldDatumByteOffset, + ObjDesc->CommonField.AccessByteWidth); } else { @@ -494,9 +521,9 @@ AcpiExFieldDatumIo ( * Copy the data to the target buffer. * Length is the field width in bytes. */ - ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer - + ObjDesc->BufferField.BaseByteOffset - + FieldDatumByteOffset, + ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer + + ObjDesc->BufferField.BaseByteOffset + + FieldDatumByteOffset, Value, ObjDesc->CommonField.AccessByteWidth); } @@ -506,8 +533,10 @@ AcpiExFieldDatumIo ( case ACPI_TYPE_LOCAL_BANK_FIELD: - /* Ensure that the BankValue is not beyond the capacity of the register */ - + /* + * Ensure that the BankValue is not beyond the capacity of + * the register + */ if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj, (ACPI_INTEGER) ObjDesc->BankField.Value)) { @@ -547,8 +576,10 @@ AcpiExFieldDatumIo ( case ACPI_TYPE_LOCAL_INDEX_FIELD: - /* Ensure that the IndexValue is not beyond the capacity of the register */ - + /* + * Ensure that the IndexValue is not beyond the capacity of + * the register + */ if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj, (ACPI_INTEGER) ObjDesc->IndexField.Value)) { @@ -604,15 +635,17 @@ AcpiExFieldDatumIo ( { if (ReadWrite == ACPI_READ) { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Read %8.8X%8.8X, Width %d\n", - ACPI_FORMAT_UINT64 (*Value), - ObjDesc->CommonField.AccessByteWidth)); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Value Read %8.8X%8.8X, Width %d\n", + ACPI_FORMAT_UINT64 (*Value), + ObjDesc->CommonField.AccessByteWidth)); } else { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Written %8.8X%8.8X, Width %d\n", - ACPI_FORMAT_UINT64 (*Value), - ObjDesc->CommonField.AccessByteWidth)); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Value Written %8.8X%8.8X, Width %d\n", + ACPI_FORMAT_UINT64 (*Value), + ObjDesc->CommonField.AccessByteWidth)); } } @@ -624,8 +657,10 @@ AcpiExFieldDatumIo ( * * FUNCTION: AcpiExWriteWithUpdateRule * - * PARAMETERS: *ObjDesc - Field to be set - * Value - Value to store + * PARAMETERS: ObjDesc - Field to be written + * Mask - bitmask within field datum + * FieldValue - Value to write + * FieldDatumByteOffset - Offset of datum within field * * RETURN: Status * @@ -725,213 +760,6 @@ AcpiExWriteWithUpdateRule ( /******************************************************************************* * - * FUNCTION: AcpiExGetBufferDatum - * - * PARAMETERS: Datum - Where the Datum is returned - * Buffer - Raw field buffer - * BufferLength - Entire length (used for big-endian only) - * ByteGranularity - 1/2/4/8 Granularity of the field - * (aka Datum Size) - * BufferOffset - Datum offset into the buffer - * - * RETURN: none - * - * DESCRIPTION: Get a datum from the buffer according to the buffer field - * byte granularity - * - ******************************************************************************/ - -void -AcpiExGetBufferDatum ( - ACPI_INTEGER *Datum, - void *Buffer, - UINT32 BufferLength, - UINT32 ByteGranularity, - UINT32 BufferOffset) -{ - UINT32 Index; - - - ACPI_FUNCTION_TRACE_U32 ("ExGetBufferDatum", ByteGranularity); - - - /* Get proper index into buffer (handles big/little endian) */ - - Index = ACPI_BUFFER_INDEX (BufferLength, BufferOffset, ByteGranularity); - - /* Move the requested number of bytes */ - - switch (ByteGranularity) - { - case ACPI_FIELD_BYTE_GRANULARITY: - - *Datum = ((UINT8 *) Buffer) [Index]; - break; - - case ACPI_FIELD_WORD_GRANULARITY: - - ACPI_MOVE_16_TO_64 (Datum, &(((UINT16 *) Buffer) [Index])); - break; - - case ACPI_FIELD_DWORD_GRANULARITY: - - ACPI_MOVE_32_TO_64 (Datum, &(((UINT32 *) Buffer) [Index])); - break; - - case ACPI_FIELD_QWORD_GRANULARITY: - - ACPI_MOVE_64_TO_64 (Datum, &(((UINT64 *) Buffer) [Index])); - break; - - default: - /* Should not get here */ - break; - } - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExSetBufferDatum - * - * PARAMETERS: MergedDatum - Value to store - * Buffer - Receiving buffer - * BufferLength - Entire length (used for big-endian only) - * ByteGranularity - 1/2/4/8 Granularity of the field - * (aka Datum Size) - * BufferOffset - Datum offset into the buffer - * - * RETURN: none - * - * DESCRIPTION: Store the merged datum to the buffer according to the - * byte granularity - * - ******************************************************************************/ - -void -AcpiExSetBufferDatum ( - ACPI_INTEGER MergedDatum, - void *Buffer, - UINT32 BufferLength, - UINT32 ByteGranularity, - UINT32 BufferOffset) -{ - UINT32 Index; - - - ACPI_FUNCTION_TRACE_U32 ("ExSetBufferDatum", ByteGranularity); - - - /* Get proper index into buffer (handles big/little endian) */ - - Index = ACPI_BUFFER_INDEX (BufferLength, BufferOffset, ByteGranularity); - - /* Move the requested number of bytes */ - - switch (ByteGranularity) - { - case ACPI_FIELD_BYTE_GRANULARITY: - - ((UINT8 *) Buffer) [Index] = (UINT8) MergedDatum; - break; - - case ACPI_FIELD_WORD_GRANULARITY: - - ACPI_MOVE_64_TO_16 (&(((UINT16 *) Buffer)[Index]), &MergedDatum); - break; - - case ACPI_FIELD_DWORD_GRANULARITY: - - ACPI_MOVE_64_TO_32 (&(((UINT32 *) Buffer)[Index]), &MergedDatum); - break; - - case ACPI_FIELD_QWORD_GRANULARITY: - - ACPI_MOVE_64_TO_64 (&(((UINT64 *) Buffer)[Index]), &MergedDatum); - break; - - default: - /* Should not get here */ - break; - } - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiExCommonBufferSetup - * - * PARAMETERS: ObjDesc - Field object - * BufferLength - Length of caller's buffer - * DatumCount - Where the DatumCount is returned - * - * RETURN: Status, DatumCount - * - * DESCRIPTION: Common code to validate the incoming buffer size and compute - * the number of field "datums" that must be read or written. - * A "datum" is the smallest unit that can be read or written - * to the field, it is either 1,2,4, or 8 bytes. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiExCommonBufferSetup ( - ACPI_OPERAND_OBJECT *ObjDesc, - UINT32 BufferLength, - UINT32 *DatumCount) -{ - UINT32 ByteFieldLength; - UINT32 ActualByteFieldLength; - - - ACPI_FUNCTION_TRACE ("ExCommonBufferSetup"); - - - /* - * Incoming buffer must be at least as long as the field, we do not - * allow "partial" field reads/writes. We do not care if the buffer is - * larger than the field, this typically happens when an integer is - * read/written to a field that is actually smaller than an integer. - */ - ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES ( - ObjDesc->CommonField.BitLength); - if (ByteFieldLength > BufferLength) - { - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Field size %X (bytes) is too large for buffer (%X)\n", - ByteFieldLength, BufferLength)); - - 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) - */ - ActualByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES ( - ObjDesc->CommonField.StartFieldBitOffset + - ObjDesc->CommonField.BitLength); - - - *DatumCount = ACPI_ROUND_UP_TO (ActualByteFieldLength, - ObjDesc->CommonField.AccessByteWidth); - - ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "BufferBytes %X, ActualBytes %X, Datums %X, ByteGran %X\n", - ByteFieldLength, ActualByteFieldLength, - *DatumCount, ObjDesc->CommonField.AccessByteWidth)); - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * * FUNCTION: AcpiExExtractFromField * * PARAMETERS: ObjDesc - Field to be read @@ -951,139 +779,101 @@ AcpiExExtractFromField ( UINT32 BufferLength) { ACPI_STATUS Status; - UINT32 FieldDatumByteOffset; - UINT32 BufferDatumOffset; - ACPI_INTEGER PreviousRawDatum = 0; - ACPI_INTEGER ThisRawDatum = 0; - ACPI_INTEGER MergedDatum = 0; + ACPI_INTEGER RawDatum; + ACPI_INTEGER MergedDatum; + UINT32 FieldOffset = 0; + UINT32 BufferOffset = 0; + UINT32 BufferTailBits; UINT32 DatumCount; + UINT32 FieldDatumCount; UINT32 i; ACPI_FUNCTION_TRACE ("ExExtractFromField"); - /* Validate buffer, compute number of datums */ + /* Validate target buffer and clear it */ - Status = AcpiExCommonBufferSetup (ObjDesc, BufferLength, &DatumCount); - if (ACPI_FAILURE (Status)) + if (BufferLength < ACPI_ROUND_BITS_UP_TO_BYTES ( + ObjDesc->CommonField.BitLength)) { - return_ACPI_STATUS (Status); - } + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Field size %X (bits) is too large for buffer (%X)\n", + ObjDesc->CommonField.BitLength, BufferLength)); - /* - * Clear the caller's buffer (the whole buffer length as given) - * This is very important, especially in the cases where the buffer - * is longer than the size of the field. - */ + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } ACPI_MEMSET (Buffer, 0, BufferLength); - FieldDatumByteOffset = 0; - BufferDatumOffset= 0; - - /* Read the entire field */ - - for (i = 0; i < DatumCount; i++) - { - Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, - &ThisRawDatum, ACPI_READ); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - - /* We might actually be done if the request fits in one datum */ - - if ((DatumCount == 1) && - (ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM)) - { - /* 1) Shift the valid data bits down to start at bit 0 */ + /* Compute the number of datums (access width data items) */ - MergedDatum = (ThisRawDatum >> ObjDesc->CommonField.StartFieldBitOffset); + DatumCount = ACPI_ROUND_UP_TO ( + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessBitWidth); + FieldDatumCount = ACPI_ROUND_UP_TO ( + ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.AccessBitWidth); - /* 2) Mask off any upper unused bits (bits not part of the field) */ + /* Priming read from the field */ - if (ObjDesc->CommonField.EndBufferValidBits) - { - MergedDatum &= ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndBufferValidBits); - } + Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, &RawDatum, ACPI_READ); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset; - /* Store the datum to the caller buffer */ + /* Read the rest of the field */ - AcpiExSetBufferDatum (MergedDatum, Buffer, BufferLength, - ObjDesc->CommonField.AccessByteWidth, BufferDatumOffset); + for (i = 1; i < FieldDatumCount; i++) + { + /* Get next input datum from the field */ - return_ACPI_STATUS (AE_OK); + FieldOffset += ObjDesc->CommonField.AccessByteWidth; + Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, + &RawDatum, ACPI_READ); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); } - /* Special handling for the last datum to ignore extra bits */ + /* Merge with previous datum if necessary */ - if ((i >= (DatumCount -1)) && - (ObjDesc->CommonField.EndFieldValidBits)) - { - /* - * This is the last iteration of the loop. We need to clear - * any unused bits (bits that are not part of this field) before - * we store the final merged datum into the caller buffer. - */ - ThisRawDatum &= - ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits); - } + MergedDatum |= RawDatum << + (ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset); - /* - * Create the (possibly) merged datum to be stored to the caller buffer - */ - if (ObjDesc->CommonField.StartFieldBitOffset == 0) + if (i == DatumCount) { - /* Field is not skewed and we can just copy the datum */ - - AcpiExSetBufferDatum (ThisRawDatum, Buffer, BufferLength, - ObjDesc->CommonField.AccessByteWidth, BufferDatumOffset); - BufferDatumOffset++; + break; } - else - { - /* Not aligned -- on the first iteration, just save the datum */ - - if (i != 0) - { - /* - * Put together the appropriate bits of the two raw data to make a - * single complete field datum - * - * 1) Normalize the first datum down to bit 0 - */ - MergedDatum = (PreviousRawDatum >> ObjDesc->CommonField.StartFieldBitOffset); - - /* 2) Insert the second datum "above" the first datum */ - MergedDatum |= (ThisRawDatum << ObjDesc->CommonField.DatumValidBits); - - AcpiExSetBufferDatum (MergedDatum, Buffer, BufferLength, - ObjDesc->CommonField.AccessByteWidth, BufferDatumOffset); - BufferDatumOffset++; - } + /* Write merged datum to target buffer */ - /* - * Save the raw datum that was just acquired since it may contain bits - * of the *next* field datum - */ - PreviousRawDatum = ThisRawDatum; - } + ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); - FieldDatumByteOffset += ObjDesc->CommonField.AccessByteWidth; + BufferOffset += ObjDesc->CommonField.AccessByteWidth; + MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset; } - /* For non-aligned case, there is one last datum to insert */ + /* Mask off any extra bits in the last datum */ - if (ObjDesc->CommonField.StartFieldBitOffset != 0) + BufferTailBits = ObjDesc->CommonField.BitLength % + ObjDesc->CommonField.AccessBitWidth; + if (BufferTailBits) { - MergedDatum = (ThisRawDatum >> ObjDesc->CommonField.StartFieldBitOffset); - - AcpiExSetBufferDatum (MergedDatum, Buffer, BufferLength, - ObjDesc->CommonField.AccessByteWidth, BufferDatumOffset); + MergedDatum &= ACPI_MASK_BITS_ABOVE (BufferTailBits); } + /* Write the last datum to the buffer */ + + ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + return_ACPI_STATUS (AE_OK); } @@ -1109,180 +899,100 @@ AcpiExInsertIntoField ( UINT32 BufferLength) { ACPI_STATUS Status; - UINT32 FieldDatumByteOffset; - UINT32 DatumOffset; ACPI_INTEGER Mask; ACPI_INTEGER MergedDatum; - ACPI_INTEGER PreviousRawDatum; - ACPI_INTEGER ThisRawDatum; + ACPI_INTEGER RawDatum = 0; + UINT32 FieldOffset = 0; + UINT32 BufferOffset = 0; + UINT32 BufferTailBits; UINT32 DatumCount; + UINT32 FieldDatumCount; + UINT32 i; ACPI_FUNCTION_TRACE ("ExInsertIntoField"); - /* Validate buffer, compute number of datums */ + /* Validate input buffer */ - Status = AcpiExCommonBufferSetup (ObjDesc, BufferLength, &DatumCount); - if (ACPI_FAILURE (Status)) + if (BufferLength < ACPI_ROUND_BITS_UP_TO_BYTES ( + ObjDesc->CommonField.BitLength)) { - return_ACPI_STATUS (Status); - } - - /* - * Break the request into up to three parts (similar to an I/O request): - * 1) non-aligned part at start - * 2) aligned part in middle - * 3) non-aligned part at the end - */ - FieldDatumByteOffset = 0; - DatumOffset= 0; - - /* Get a single datum from the caller's buffer */ - - AcpiExGetBufferDatum (&PreviousRawDatum, Buffer, BufferLength, - ObjDesc->CommonField.AccessByteWidth, DatumOffset); - - /* - * Part1: - * Write a partial field datum if field does not begin on a datum boundary - * Note: The code in this section also handles the aligned case - * - * Construct Mask with 1 bits where the field is, 0 bits elsewhere - * (Only the bottom 5 bits of BitLength are valid for a shift operation) - * - * Mask off bits that are "below" the field (if any) - */ - Mask = ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); - - /* If the field fits in one datum, may need to mask upper bits */ - - if ((ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM) && - ObjDesc->CommonField.EndFieldValidBits) - { - /* There are bits above the field, mask them off also */ + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Field size %X (bits) is too large for buffer (%X)\n", + ObjDesc->CommonField.BitLength, BufferLength)); - Mask &= ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits); + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); } - /* Shift and mask the value into the field position */ - - MergedDatum = (PreviousRawDatum << ObjDesc->CommonField.StartFieldBitOffset); - MergedDatum &= Mask; + /* Compute the number of datums (access width data items) */ - /* Apply the update rule (if necessary) and write the datum to the field */ + Mask = ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); + DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessBitWidth); + FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.AccessBitWidth); - Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, MergedDatum, - FieldDatumByteOffset); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + /* Get initial Datum from the input buffer */ - /* We just wrote the first datum */ + ACPI_MEMCPY (&RawDatum, Buffer, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); - DatumOffset++; + MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset; - /* If the entire field fits within one datum, we are done. */ + /* Write the entire field */ - if ((DatumCount == 1) && - (ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM)) + for (i = 1; i < FieldDatumCount; i++) { - return_ACPI_STATUS (AE_OK); - } + /* Write merged datum to the target field */ - /* - * Part2: - * Write the aligned data. - * - * We don't need to worry about the update rule for these data, because - * all of the bits in each datum are part of the field. - * - * The last datum must be special cased because it might contain bits - * that are not part of the field -- therefore the "update rule" must be - * applied in Part3 below. - */ - while (DatumOffset < DatumCount) - { - FieldDatumByteOffset += ObjDesc->CommonField.AccessByteWidth; + MergedDatum &= Mask; + Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, + MergedDatum, FieldOffset); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } - /* - * Get the next raw buffer datum. It may contain bits of the previous - * field datum - */ - AcpiExGetBufferDatum (&ThisRawDatum, Buffer, BufferLength, - ObjDesc->CommonField.AccessByteWidth, DatumOffset); + /* Start new output datum by merging with previous input datum */ - /* Create the field datum based on the field alignment */ + FieldOffset += ObjDesc->CommonField.AccessByteWidth; + MergedDatum = RawDatum >> + (ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset); + Mask = ACPI_INTEGER_MAX; - if (ObjDesc->CommonField.StartFieldBitOffset != 0) + if (i == DatumCount) { - /* - * Put together appropriate bits of the two raw buffer data to make - * a single complete field datum - */ - MergedDatum = - (PreviousRawDatum >> ObjDesc->CommonField.DatumValidBits) | - (ThisRawDatum << ObjDesc->CommonField.StartFieldBitOffset); - } - else - { - /* Field began aligned on datum boundary */ - - MergedDatum = ThisRawDatum; + break; } - /* - * Special handling for the last datum if the field does NOT end on - * a datum boundary. Update Rule must be applied to the bits outside - * the field. - */ - DatumOffset++; - if ((DatumOffset == DatumCount) && - (ObjDesc->CommonField.EndFieldValidBits)) - { - /* - * If there are dangling non-aligned bits, perform one more merged write - * Else - field is aligned at the end, no need for any more writes - */ + /* Get the next input datum from the buffer */ - /* - * Part3: - * This is the last datum and the field does not end on a datum boundary. - * Build the partial datum and write with the update rule. - * - * Mask off the unused bits above (after) the end-of-field - */ - Mask = ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits); - MergedDatum &= Mask; + BufferOffset += ObjDesc->CommonField.AccessByteWidth; + ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + MergedDatum |= RawDatum << ObjDesc->CommonField.StartFieldBitOffset; + } - /* Write the last datum with the update rule */ + /* Mask off any extra bits in the last datum */ - Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, MergedDatum, - FieldDatumByteOffset); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - else - { - /* Normal (aligned) case -- write the completed datum */ + BufferTailBits = (ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset) % + ObjDesc->CommonField.AccessBitWidth; + if (BufferTailBits) + { + Mask &= ACPI_MASK_BITS_ABOVE (BufferTailBits); + } - Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, - &MergedDatum, ACPI_WRITE); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } + /* Write the last datum to the field */ - /* - * Save the most recent datum since it may contain bits of the *next* - * field datum. Update current byte offset. - */ - PreviousRawDatum = ThisRawDatum; - } + MergedDatum &= Mask; + Status = AcpiExWriteWithUpdateRule (ObjDesc, + Mask, MergedDatum, FieldOffset); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exmisc.c b/sys/contrib/dev/acpica/exmisc.c index ba7ee5da..2ab3d0a 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: 126 $ + * $Revision: 1.132 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -173,6 +173,7 @@ AcpiExGetObjectReference ( { case AML_LOCAL_OP: case AML_ARG_OP: + case AML_DEBUG_OP: /* The referenced object is the pseudo-node for the local/arg */ @@ -181,7 +182,7 @@ AcpiExGetObjectReference ( default: - ACPI_REPORT_ERROR (("Unknown Reference subtype in get ref %X\n", + ACPI_REPORT_ERROR (("Unknown Reference opcode in GetReference %X\n", ObjDesc->Reference.Opcode)); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -199,7 +200,7 @@ AcpiExGetObjectReference ( default: - ACPI_REPORT_ERROR (("Invalid descriptor type in get ref: %X\n", + ACPI_REPORT_ERROR (("Invalid descriptor type in GetReference: %X\n", ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))); return_ACPI_STATUS (AE_TYPE); } @@ -217,8 +218,9 @@ AcpiExGetObjectReference ( ReferenceObj->Reference.Object = ReferencedObj; *ReturnDesc = ReferenceObj; - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p Type [%s], returning Reference %p\n", - ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Object %p Type [%s], returning Reference %p\n", + ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc)); return_ACPI_STATUS (AE_OK); } @@ -384,7 +386,7 @@ AcpiExDoConcatenate ( /* Result of two Integers is a Buffer */ /* Need enough buffer space for two integers */ - ReturnDesc = AcpiUtCreateBufferObject ( + ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); if (!ReturnDesc) { @@ -478,7 +480,7 @@ Cleanup: { AcpiUtRemoveReference (LocalOperand1); } - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (Status); } @@ -545,7 +547,7 @@ AcpiExDoMathOp ( return (Integer0 * Integer1); - case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result) */ + case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/ return (Integer0 << Integer1); @@ -764,8 +766,8 @@ AcpiExDoLogicalOp ( /* Lexicographic compare: compare the data bytes */ - Compare = ACPI_MEMCMP ((const char * ) Operand0->Buffer.Pointer, - (const char * ) LocalOperand1->Buffer.Pointer, + Compare = ACPI_MEMCMP (Operand0->Buffer.Pointer, + LocalOperand1->Buffer.Pointer, (Length0 > Length1) ? Length1 : Length0); switch (Opcode) diff --git a/sys/contrib/dev/acpica/exmutex.c b/sys/contrib/dev/acpica/exmutex.c index afc690f..06f1972 100644 --- a/sys/contrib/dev/acpica/exmutex.c +++ b/sys/contrib/dev/acpica/exmutex.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exmutex - ASL Mutex Acquire/Release functions - * $Revision: 24 $ + * $Revision: 1.28 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,6 +123,13 @@ #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exmutex") +/* Local prototypes */ + +static void +AcpiExLinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_STATE *Thread); + /******************************************************************************* * @@ -130,7 +137,7 @@ * * PARAMETERS: ObjDesc - The mutex to be unlinked * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list * @@ -170,16 +177,16 @@ AcpiExUnlinkMutex ( * * FUNCTION: AcpiExLinkMutex * - * PARAMETERS: ObjDesc - The mutex to be linked - * ListHead - head of the "AcquiredMutex" list + * PARAMETERS: ObjDesc - The mutex to be linked + * Thread - Current executing thread object * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk * ******************************************************************************/ -void +static void AcpiExLinkMutex ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_THREAD_STATE *Thread) @@ -211,8 +218,9 @@ AcpiExLinkMutex ( * * FUNCTION: AcpiExAcquireMutex * - * PARAMETERS: TimeDesc - The 'time to delay' object descriptor - * ObjDesc - The object descriptor for this op + * PARAMETERS: TimeDesc - Timeout integer + * ObjDesc - Mutex object + * WalkState - Current method execution state * * RETURN: Status * @@ -242,7 +250,7 @@ AcpiExAcquireMutex ( if (!WalkState->Thread) { ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], null thread info\n", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -252,8 +260,9 @@ AcpiExAcquireMutex ( */ if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel) { - ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], incorrect SyncLevel\n", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + ACPI_REPORT_ERROR (( + "Cannot acquire Mutex [%4.4s], incorrect SyncLevel\n", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } @@ -263,8 +272,10 @@ AcpiExAcquireMutex ( { /* Special case for Global Lock, allow all threads */ - if ((ObjDesc->Mutex.OwnerThread->ThreadId == WalkState->Thread->ThreadId) || - (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore)) + if ((ObjDesc->Mutex.OwnerThread->ThreadId == + WalkState->Thread->ThreadId) || + (ObjDesc->Mutex.Semaphore == + AcpiGbl_GlobalLockSemaphore)) { /* * The mutex is already owned by this thread, @@ -306,6 +317,7 @@ AcpiExAcquireMutex ( * FUNCTION: AcpiExReleaseMutex * * PARAMETERS: ObjDesc - The object descriptor for this op + * WalkState - Current method execution state * * RETURN: Status * @@ -368,8 +380,9 @@ AcpiExReleaseMutex ( */ if (ObjDesc->Mutex.SyncLevel > WalkState->Thread->CurrentSyncLevel) { - ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], incorrect SyncLevel\n", - AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + ACPI_REPORT_ERROR (( + "Cannot release Mutex [%4.4s], incorrect SyncLevel\n", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } @@ -404,11 +417,11 @@ AcpiExReleaseMutex ( * * FUNCTION: AcpiExReleaseAllMutexes * - * PARAMETERS: MutexList - Head of the mutex list + * PARAMETERS: Thread - Current executing thread object * * RETURN: Status * - * DESCRIPTION: Release all mutexes in the list + * DESCRIPTION: Release all mutexes held by this thread * ******************************************************************************/ diff --git a/sys/contrib/dev/acpica/exnames.c b/sys/contrib/dev/acpica/exnames.c index 0f096d7..e45bcb3 100644 --- a/sys/contrib/dev/acpica/exnames.c +++ b/sys/contrib/dev/acpica/exnames.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exnames - interpreter/scanner name load/execute - * $Revision: 95 $ + * $Revision: 1.103 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,13 +124,17 @@ #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exnames") +/* Local prototypes */ -/* AML Package Length encodings */ +static char * +AcpiExAllocateNameString ( + UINT32 PrefixCount, + UINT32 NumNameSegs); -#define ACPI_AML_PACKAGE_TYPE1 0x40 -#define ACPI_AML_PACKAGE_TYPE2 0x4000 -#define ACPI_AML_PACKAGE_TYPE3 0x400000 -#define ACPI_AML_PACKAGE_TYPE4 0x40000000 +static ACPI_STATUS +AcpiExNameSegment ( + UINT8 **InAmlAddress, + char *NameString); /******************************************************************************* @@ -138,7 +142,7 @@ * FUNCTION: AcpiExAllocateNameString * * PARAMETERS: PrefixCount - Count of parent levels. Special cases: - * (-1) = root, 0 = none + * (-1)==root, 0==none * NumNameSegs - count of 4-character name segments * * RETURN: A pointer to the allocated string segment. This segment must @@ -149,7 +153,7 @@ * ******************************************************************************/ -char * +static char * AcpiExAllocateNameString ( UINT32 PrefixCount, UINT32 NumNameSegs) @@ -162,7 +166,7 @@ AcpiExAllocateNameString ( /* - * Allow room for all \ and ^ prefixes, all segments, and a MultiNamePrefix. + * Allow room for all \ and ^ prefixes, all segments and a MultiNamePrefix. * Also, one byte for the null terminator. * This may actually be somewhat longer than needed. */ @@ -184,7 +188,8 @@ AcpiExAllocateNameString ( NameString = ACPI_MEM_ALLOCATE (SizeNeeded); if (!NameString) { - ACPI_REPORT_ERROR (("ExAllocateNameString: Could not allocate size %d\n", SizeNeeded)); + ACPI_REPORT_ERROR (( + "ExAllocateNameString: Could not allocate size %d\n", SizeNeeded)); return_PTR (NULL); } @@ -234,15 +239,17 @@ AcpiExAllocateNameString ( * * FUNCTION: AcpiExNameSegment * - * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) + * PARAMETERS: InAmlAddress - Pointer to the name in the AML code + * NameString - Where to return the name. The name is appended + * to any existing string to form a namepath * * RETURN: Status * - * DESCRIPTION: Execute a name segment (4 bytes) + * DESCRIPTION: Extract an ACPI name (4 bytes) from the AML byte stream * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExNameSegment ( UINT8 **InAmlAddress, char *NameString) @@ -291,12 +298,12 @@ AcpiExNameSegment ( { ACPI_STRCAT (NameString, CharBuf); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Appended to - %s \n", NameString)); + "Appended to - %s\n", NameString)); } else { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "No Name string - %s \n", CharBuf)); + "No Name string - %s\n", CharBuf)); } } else if (Index == 0) @@ -312,10 +319,13 @@ AcpiExNameSegment ( } else { - /* Segment started with one or more valid characters, but fewer than 4 */ - + /* + * Segment started with one or more valid characters, but fewer than + * the required 4 + */ Status = AE_AML_BAD_NAME; - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad character %02x in name, at %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Bad character %02x in name, at %p\n", *AmlAddress, AmlAddress)); } @@ -328,11 +338,16 @@ AcpiExNameSegment ( * * FUNCTION: AcpiExGetNameString * - * PARAMETERS: DataType - Data type to be associated with this name + * PARAMETERS: DataType - Object type to be associated with this + * name + * InAmlAddress - Pointer to the namestring in the AML code + * OutNameString - Where the namestring is returned + * OutNameLength - Length of the returned string * - * RETURN: Status + * RETURN: Status, namestring and length * - * DESCRIPTION: Get a name, including any prefixes. + * DESCRIPTION: Extract a full namepath from the AML byte stream, + * including any prefixes. * ******************************************************************************/ @@ -380,7 +395,8 @@ AcpiExGetNameString ( { case AML_ROOT_PREFIX: - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n", AmlAddress)); + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n", + AmlAddress)); /* * Remember that we have a RootPrefix -- @@ -398,7 +414,8 @@ AcpiExGetNameString ( do { - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n", AmlAddress)); + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n", + AmlAddress)); AmlAddress++; PrefixCount++; @@ -416,14 +433,14 @@ AcpiExGetNameString ( break; } - /* Examine first character of name for name segment prefix operator */ switch (*AmlAddress) { case AML_DUAL_NAME_PREFIX: - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n", AmlAddress)); + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n", + AmlAddress)); AmlAddress++; NameString = AcpiExAllocateNameString (PrefixCount, 2); @@ -447,7 +464,8 @@ AcpiExGetNameString ( case AML_MULTI_NAME_PREFIX_OP: - ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n", AmlAddress)); + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n", + AmlAddress)); /* Fetch count of segments remaining in name path */ @@ -467,7 +485,8 @@ AcpiExGetNameString ( HasPrefix = TRUE; while (NumSegments && - (Status = AcpiExNameSegment (&AmlAddress, NameString)) == AE_OK) + (Status = AcpiExNameSegment (&AmlAddress, NameString)) == + AE_OK) { NumSegments--; } @@ -481,7 +500,8 @@ AcpiExGetNameString ( if (PrefixCount == ACPI_UINT32_MAX) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "NameSeg is \"\\\" followed by NULL\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "NameSeg is \"\\\" followed by NULL\n")); } /* Consume the NULL byte */ @@ -522,6 +542,15 @@ AcpiExGetNameString ( Status = AE_AML_BAD_NAME; } + if (ACPI_FAILURE (Status)) + { + if (NameString) + { + ACPI_MEM_FREE (NameString); + } + return_ACPI_STATUS (Status); + } + *OutNameString = NameString; *OutNameLength = (UINT32) (AmlAddress - InAmlAddress); diff --git a/sys/contrib/dev/acpica/exoparg1.c b/sys/contrib/dev/acpica/exoparg1.c index 30ed7e0..cee66e0 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: 163 $ + * $Revision: 1.172 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -171,7 +171,8 @@ AcpiExOpcode_0A_0T_1R ( ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_0A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_0A_0T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -188,8 +189,9 @@ AcpiExOpcode_0A_0T_1R ( Status = AE_NO_MEMORY; goto Cleanup; } - +#if ACPI_MACHINE_WIDTH != 16 ReturnDesc->Integer.Value = AcpiOsGetTimer (); +#endif break; default: /* Unknown opcode */ @@ -202,17 +204,18 @@ AcpiExOpcode_0A_0T_1R ( Cleanup: - if (!WalkState->ResultObj) - { - WalkState->ResultObj = ReturnDesc; - } - /* Delete return object on error */ - if (ACPI_FAILURE (Status)) + if ((ACPI_FAILURE (Status)) || WalkState->ResultObj) { AcpiUtRemoveReference (ReturnDesc); } + else + { + /* Save the return value */ + + WalkState->ResultObj = ReturnDesc; + } return_ACPI_STATUS (Status); } @@ -239,7 +242,8 @@ AcpiExOpcode_1A_0T_0R ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -315,7 +319,8 @@ AcpiExOpcode_1A_1T_0R ( ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_0R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -369,7 +374,8 @@ AcpiExOpcode_1A_1T_1R ( ACPI_INTEGER Digit; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -418,7 +424,7 @@ AcpiExOpcode_1A_1T_1R ( break; - case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */ + case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */ ReturnDesc->Integer.Value = Operand[0]->Integer.Value; @@ -497,8 +503,10 @@ AcpiExOpcode_1A_1T_1R ( { (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32); - /* Insert the BCD digit that resides in the remainder from above */ - + /* + * Insert the BCD digit that resides in the + * remainder from above + */ ReturnDesc->Integer.Value |= (((ACPI_INTEGER) Temp32) << ACPI_MUL_4 (i)); } @@ -535,7 +543,8 @@ AcpiExOpcode_1A_1T_1R ( /* Get the object reference, store it, and remove our reference */ - Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc2, WalkState); + Status = AcpiExGetObjectReference (Operand[0], + &ReturnDesc2, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -575,10 +584,10 @@ AcpiExOpcode_1A_1T_1R ( if (!WalkState->ResultObj) { /* - * Normally, we would remove a reference on the Operand[0] parameter; - * But since it is being used as the internal return object - * (meaning we would normally increment it), the two cancel out, - * and we simply don't do anything. + * Normally, we would remove a reference on the Operand[0] + * parameter; But since it is being used as the internal return + * object (meaning we would normally increment it), the two + * cancel out, and we simply don't do anything. */ WalkState->ResultObj = Operand[0]; WalkState->Operands[0] = NULL; /* Prevent deletion */ @@ -600,6 +609,11 @@ AcpiExOpcode_1A_1T_1R ( Status = AcpiExConvertToString (Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_DECIMAL); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } break; @@ -607,12 +621,22 @@ AcpiExOpcode_1A_1T_1R ( Status = AcpiExConvertToString (Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_HEX); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } break; case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */ Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } break; @@ -620,15 +644,19 @@ AcpiExOpcode_1A_1T_1R ( Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, ACPI_ANY_BASE); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } break; case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */ case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */ - /* - * These are two obsolete opcodes - */ + /* These are two obsolete opcodes */ + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s is obsolete and not implemented\n", AcpiPsGetOpcodeName (WalkState->Opcode))); @@ -644,10 +672,12 @@ AcpiExOpcode_1A_1T_1R ( goto Cleanup; } - /* - * Store the return value computed above into the target object - */ - Status = AcpiExStore (ReturnDesc, Operand[1], WalkState); + if (ACPI_SUCCESS (Status)) + { + /* Store the return value computed above into the target object */ + + Status = AcpiExStore (ReturnDesc, Operand[1], WalkState); + } Cleanup: @@ -692,7 +722,8 @@ AcpiExOpcode_1A_0T_1R ( ACPI_INTEGER Value; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ @@ -791,9 +822,9 @@ AcpiExOpcode_1A_0T_1R ( /* * 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 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 */ @@ -825,7 +856,8 @@ AcpiExOpcode_1A_0T_1R ( /* Get the base object */ - Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, &TempDesc); + Status = AcpiExResolveMultiple (WalkState, + Operand[0], &Type, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -912,8 +944,10 @@ AcpiExOpcode_1A_0T_1R ( /* Set Operand[0] to the value of the local/arg */ - Status = AcpiDsMethodDataGetValue (Operand[0]->Reference.Opcode, - Operand[0]->Reference.Offset, WalkState, &TempDesc); + Status = AcpiDsMethodDataGetValue ( + Operand[0]->Reference.Opcode, + Operand[0]->Reference.Offset, + WalkState, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; @@ -947,22 +981,27 @@ AcpiExOpcode_1A_0T_1R ( case ACPI_TYPE_STRING: /* - * This is a DerefOf (String). The string is a reference to a named ACPI object. + * This is a DerefOf (String). The string is a reference + * to a named ACPI object. * * 1) Find the owning Node - * 2) Dereference the node to an actual object. Could be a Field, so we nee - * to resolve the node to a value. + * 2) Dereference the node to an actual object. Could be a + * Field, so we need to resolve the node to a value. */ Status = AcpiNsGetNodeByPath (Operand[0]->String.Pointer, - WalkState->ScopeInfo->Scope.Node, ACPI_NS_SEARCH_PARENT, - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ReturnDesc)); + WalkState->ScopeInfo->Scope.Node, + ACPI_NS_SEARCH_PARENT, + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc)); if (ACPI_FAILURE (Status)) { goto Cleanup; } Status = AcpiExResolveNodeToValue ( - ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ReturnDesc), WalkState); + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc), + WalkState); goto Cleanup; @@ -980,15 +1019,18 @@ AcpiExOpcode_1A_0T_1R ( /* * This is a DerefOf (ObjectReference) * Get the actual object from the Node (This is the dereference). - * -- This case may only happen when a LocalX or ArgX is dereferenced above. + * This case may only happen when a LocalX or ArgX is + * dereferenced above. */ - ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) Operand[0]); + ReturnDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) Operand[0]); + AcpiUtAddReference (ReturnDesc); } else { /* - * This must be a reference object produced by either the Index() or - * RefOf() operator + * This must be a reference object produced by either the + * Index() or RefOf() operator */ switch (Operand[0]->Reference.Opcode) { @@ -1032,25 +1074,15 @@ AcpiExOpcode_1A_0T_1R ( case ACPI_TYPE_PACKAGE: /* - * Return the referenced element of the package. We must add - * another reference to the referenced object, however. + * Return the referenced element of the package. We must + * add another reference to the referenced object, however. */ ReturnDesc = *(Operand[0]->Reference.Where); - if (!ReturnDesc) + if (ReturnDesc) { - /* - * We can't return a NULL dereferenced value. This is - * an uninitialized package element and is thus a - * severe error. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "NULL package element obj %p\n", - Operand[0])); - Status = AE_AML_UNINITIALIZED_ELEMENT; - goto Cleanup; + AcpiUtAddReference (ReturnDesc); } - AcpiUtAddReference (ReturnDesc); break; @@ -1069,10 +1101,12 @@ AcpiExOpcode_1A_0T_1R ( ReturnDesc = Operand[0]->Reference.Object; - if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == ACPI_DESC_TYPE_NAMED) + if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == + ACPI_DESC_TYPE_NAMED) { - ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ReturnDesc); + ReturnDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) ReturnDesc); } /* Add another reference to the object! */ diff --git a/sys/contrib/dev/acpica/exoparg2.c b/sys/contrib/dev/acpica/exoparg2.c index bb8befb..880a45c 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: 129 $ + * $Revision: 1.134 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -194,7 +194,7 @@ AcpiExOpcode_2A_0T_0R ( Value = (UINT32) Operand[1]->Integer.Value; - /* Notifies allowed on this object? */ + /* Are notifies allowed on this object? */ if (!AcpiEvIsNotifyObject (Node)) { @@ -282,12 +282,13 @@ AcpiExOpcode_2A_2T_1R ( AcpiPsGetOpcodeName (WalkState->Opcode)); - /* - * Execute the opcode - */ + /* Execute the opcode */ + switch (WalkState->Opcode) { - case AML_DIVIDE_OP: /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */ + case AML_DIVIDE_OP: + + /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */ ReturnDesc1 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc1) @@ -324,7 +325,6 @@ AcpiExOpcode_2A_2T_1R ( goto Cleanup; } - /* Store the results to the target reference operands */ Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState); @@ -381,7 +381,7 @@ AcpiExOpcode_2A_1T_1R ( { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - UINT32 Index; + ACPI_INTEGER Index; ACPI_STATUS Status = AE_OK; ACPI_SIZE Length; @@ -390,9 +390,8 @@ AcpiExOpcode_2A_1T_1R ( AcpiPsGetOpcodeName (WalkState->Opcode)); - /* - * Execute the opcode - */ + /* Execute the opcode */ + if (WalkState->OpInfo->Flags & AML_MATH) { /* All simple math opcodes (add, etc.) */ @@ -410,10 +409,9 @@ AcpiExOpcode_2A_1T_1R ( goto StoreResultToTarget; } - switch (WalkState->Opcode) { - case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */ + case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) @@ -431,18 +429,19 @@ AcpiExOpcode_2A_1T_1R ( break; - case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ + case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ Status = AcpiExDoConcatenate (Operand[0], Operand[1], &ReturnDesc, WalkState); break; - case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */ + case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */ /* * Input object is guaranteed to be a buffer at this point (it may have - * been converted.) Copy the raw buffer data to a new object of type String. + * been converted.) Copy the raw buffer data to a new object of + * type String. */ /* @@ -476,14 +475,16 @@ AcpiExOpcode_2A_1T_1R ( goto Cleanup; } - /* Copy the raw buffer data with no transform. NULL terminated already. */ + /* Copy the raw buffer data with no transform. NULL terminated already*/ ACPI_MEMCPY (ReturnDesc->String.Pointer, Operand[0]->Buffer.Pointer, Length); break; - case AML_CONCAT_RES_OP: /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */ + case AML_CONCAT_RES_OP: + + /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */ Status = AcpiExConcatTemplate (Operand[0], Operand[1], &ReturnDesc, WalkState); @@ -501,11 +502,10 @@ AcpiExOpcode_2A_1T_1R ( goto Cleanup; } - Index = (UINT32) Operand[1]->Integer.Value; + Index = Operand[1]->Integer.Value; + + /* At this point, the Source operand is a Package, Buffer, or String */ - /* - * At this point, the Source operand is a Package, Buffer, or String - */ if (ACPI_GET_OBJECT_TYPE (Operand[0]) == ACPI_TYPE_PACKAGE) { /* Object to be indexed is a Package */ @@ -513,15 +513,16 @@ AcpiExOpcode_2A_1T_1R ( if (Index >= Operand[0]->Package.Count) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Index value (%X) beyond package end (%X)\n", - Index, Operand[0]->Package.Count)); + "Index value (%X%8.8X) beyond package end (%X)\n", + ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count)); Status = AE_AML_PACKAGE_LIMIT; goto Cleanup; } ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; ReturnDesc->Reference.Object = Operand[0]; - ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index]; + ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [ + Index]; } else { @@ -530,8 +531,8 @@ AcpiExOpcode_2A_1T_1R ( if (Index >= Operand[0]->Buffer.Length) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Index value (%X) beyond end of buffer (%X)\n", - Index, Operand[0]->Buffer.Length)); + "Index value (%X%8.8X) beyond end of buffer (%X)\n", + ACPI_FORMAT_UINT64 (Index), Operand[0]->Buffer.Length)); Status = AE_AML_BUFFER_LIMIT; goto Cleanup; } @@ -540,10 +541,16 @@ AcpiExOpcode_2A_1T_1R ( ReturnDesc->Reference.Object = Operand[0]; } + /* + * Add a reference to the target package/buffer/string for the life + * of the index. + */ + AcpiUtAddReference (Operand[0]); + /* Complete the Index reference object */ ReturnDesc->Reference.Opcode = AML_INDEX_OP; - ReturnDesc->Reference.Offset = Index; + ReturnDesc->Reference.Offset = (UINT32) Index; /* Store the reference to the Target */ @@ -633,24 +640,26 @@ AcpiExOpcode_2A_0T_1R ( goto Cleanup; } - /* - * Execute the Opcode - */ - if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC) /* LogicalOp (Operand0, Operand1) */ + /* Execute the Opcode */ + + 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) */ + else if (WalkState->OpInfo->Flags & AML_LOGICAL) { + /* LogicalOp (Operand0, Operand1) */ + Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0], Operand[1], &LogicalResult); goto StoreLogicalResult; } - switch (WalkState->Opcode) { case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */ diff --git a/sys/contrib/dev/acpica/exoparg3.c b/sys/contrib/dev/acpica/exoparg3.c index 31a303e..f1b9ea0 100644 --- a/sys/contrib/dev/acpica/exoparg3.c +++ b/sys/contrib/dev/acpica/exoparg3.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exoparg3 - AML execution - opcodes with 3 arguments - * $Revision: 19 $ + * $Revision: 1.27 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -172,12 +172,13 @@ AcpiExOpcode_3A_0T_0R ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_0T_0R", + AcpiPsGetOpcodeName (WalkState->Opcode)); switch (WalkState->Opcode) { - case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ + case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", @@ -193,9 +194,8 @@ AcpiExOpcode_3A_0T_0R ( Fatal->Argument = (UINT32) Operand[2]->Integer.Value; } - /* - * Always signal the OS! - */ + /* Always signal the OS! */ + Status = AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal); /* Might return while OS is shutting down, just continue */ @@ -237,24 +237,26 @@ AcpiExOpcode_3A_1T_1R ( { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; - char *Buffer; + char *Buffer = NULL; ACPI_STATUS Status = AE_OK; - ACPI_NATIVE_UINT Index; + ACPI_INTEGER Index; ACPI_SIZE Length; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_1T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); switch (WalkState->Opcode) { - case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ + case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ /* * Create the return object. The Source operand is guaranteed to be * either a String or a Buffer, so just use its type. */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_GET_OBJECT_TYPE (Operand[0])); + ReturnDesc = AcpiUtCreateInternalObject ( + ACPI_GET_OBJECT_TYPE (Operand[0])); if (!ReturnDesc) { Status = AE_NO_MEMORY; @@ -263,25 +265,33 @@ AcpiExOpcode_3A_1T_1R ( /* Get the Integer values from the objects */ - Index = (ACPI_NATIVE_UINT) Operand[1]->Integer.Value; + Index = Operand[1]->Integer.Value; Length = (ACPI_SIZE) Operand[2]->Integer.Value; /* * If the index is beyond the length of the String/Buffer, or if the * requested length is zero, return a zero-length String/Buffer */ - if ((Index < Operand[0]->String.Length) && - (Length > 0)) + if (Index >= Operand[0]->String.Length) { - /* Truncate request if larger than the actual String/Buffer */ + Length = 0; + } - if ((Index + Length) > - Operand[0]->String.Length) - { - Length = (ACPI_SIZE) Operand[0]->String.Length - Index; - } + /* Truncate request if larger than the actual String/Buffer */ - /* Allocate a new buffer for the String/Buffer */ + else if ((Index + Length) > Operand[0]->String.Length) + { + Length = (ACPI_SIZE) Operand[0]->String.Length - + (ACPI_SIZE) Index; + } + + /* Strings always have a sub-pointer, not so for buffers */ + + switch (ACPI_GET_OBJECT_TYPE (Operand[0])) + { + case ACPI_TYPE_STRING: + + /* Always allocate a new buffer for the String */ Buffer = ACPI_MEM_CALLOCATE ((ACPI_SIZE) Length + 1); if (!Buffer) @@ -289,17 +299,47 @@ AcpiExOpcode_3A_1T_1R ( Status = AE_NO_MEMORY; goto Cleanup; } + break; + + case ACPI_TYPE_BUFFER: + + /* If the requested length is zero, don't allocate a buffer */ + + if (Length > 0) + { + /* Allocate a new buffer for the Buffer */ + + Buffer = ACPI_MEM_CALLOCATE (Length); + if (!Buffer) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + } + break; + default: /* Should not happen */ + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + if (Length > 0) + { /* Copy the portion requested */ ACPI_MEMCPY (Buffer, Operand[0]->String.Pointer + Index, Length); + } - /* Set the length of the new String/Buffer */ + /* Set the length of the new String/Buffer */ - ReturnDesc->String.Pointer = Buffer; - ReturnDesc->String.Length = (UINT32) Length; - } + ReturnDesc->String.Pointer = Buffer; + ReturnDesc->String.Length = (UINT32) Length; + + /* Mark buffer initialized */ + + ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; break; @@ -319,14 +359,14 @@ Cleanup: /* Delete return object on error */ - if (ACPI_FAILURE (Status)) + if (ACPI_FAILURE (Status) || WalkState->ResultObj) { AcpiUtRemoveReference (ReturnDesc); } /* Set the return object and exit */ - if (!WalkState->ResultObj) + else { WalkState->ResultObj = ReturnDesc; } diff --git a/sys/contrib/dev/acpica/exoparg6.c b/sys/contrib/dev/acpica/exoparg6.c index 1834c6a..1104842 100644 --- a/sys/contrib/dev/acpica/exoparg6.c +++ b/sys/contrib/dev/acpica/exoparg6.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exoparg6 - AML execution - opcodes with 6 arguments - * $Revision: 13 $ + * $Revision: 1.23 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -150,87 +150,139 @@ * fully resolved operands. !*/ +/* Local prototypes */ + +static BOOLEAN +AcpiExDoMatch ( + UINT32 MatchOp, + ACPI_OPERAND_OBJECT *PackageObj, + ACPI_OPERAND_OBJECT *MatchObj); + /******************************************************************************* * * FUNCTION: AcpiExDoMatch * * PARAMETERS: MatchOp - The AML match operand - * PackageValue - Value from the target package - * MatchValue - Value to be matched + * PackageObj - Object from the target package + * MatchObj - Object to be matched * * RETURN: TRUE if the match is successful, FALSE otherwise * - * DESCRIPTION: Implements the low-level match for the ASL Match operator + * DESCRIPTION: Implements the low-level match for the ASL Match operator. + * Package elements will be implicitly converted to the type of + * the match object (Integer/Buffer/String). * ******************************************************************************/ -BOOLEAN +static BOOLEAN AcpiExDoMatch ( UINT32 MatchOp, - ACPI_INTEGER PackageValue, - ACPI_INTEGER MatchValue) + ACPI_OPERAND_OBJECT *PackageObj, + ACPI_OPERAND_OBJECT *MatchObj) { - + BOOLEAN LogicalResult = TRUE; + ACPI_STATUS Status; + + + /* + * Note: Since the PackageObj/MatchObj ordering is opposite to that of + * the standard logical operators, we have to reverse them when we call + * DoLogicalOp in order to make the implicit conversion rules work + * correctly. However, this means we have to flip the entire equation + * also. A bit ugly perhaps, but overall, better than fussing the + * parameters around at runtime, over and over again. + * + * Below, P[i] refers to the package element, M refers to the Match object. + */ switch (MatchOp) { - case MATCH_MTR: /* always true */ + case MATCH_MTR: - break; + /* Always true */ + break; - case MATCH_MEQ: /* true if equal */ + case MATCH_MEQ: - if (PackageValue != MatchValue) + /* + * True if equal: (P[i] == M) + * Change to: (M == P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LEQUAL_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) { return (FALSE); } break; + case MATCH_MLE: - case MATCH_MLE: /* true if less than or equal */ - - if (PackageValue > MatchValue) + /* + * True if less than or equal: (P[i] <= M) (P[i] NotGreater than M) + * Change to: (M >= P[i]) (M NotLess than P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) { return (FALSE); } + LogicalResult = (BOOLEAN) !LogicalResult; break; + case MATCH_MLT: - case MATCH_MLT: /* true if less than */ - - if (PackageValue >= MatchValue) + /* + * True if less than: (P[i] < M) + * Change to: (M > P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) { return (FALSE); } break; + case MATCH_MGE: - case MATCH_MGE: /* true if greater than or equal */ - - if (PackageValue < MatchValue) + /* + * True if greater than or equal: (P[i] >= M) (P[i] NotLess than M) + * Change to: (M <= P[i]) (M NotGreater than P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) { return (FALSE); } + LogicalResult = (BOOLEAN)!LogicalResult; break; + case MATCH_MGT: - case MATCH_MGT: /* true if greater than */ - - if (PackageValue <= MatchValue) + /* + * True if greater than: (P[i] > M) + * Change to: (M < P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) { return (FALSE); } break; + default: - default: /* undefined */ + /* Undefined */ return (FALSE); } - - return TRUE; + return LogicalResult; } @@ -253,39 +305,46 @@ AcpiExOpcode_6A_0T_1R ( ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; ACPI_STATUS Status = AE_OK; - UINT32 Index; + ACPI_INTEGER Index; ACPI_OPERAND_OBJECT *ThisElement; - ACPI_FUNCTION_TRACE_STR ("ExOpcode_6A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); + ACPI_FUNCTION_TRACE_STR ("ExOpcode_6A_0T_1R", + AcpiPsGetOpcodeName (WalkState->Opcode)); switch (WalkState->Opcode) { case AML_MATCH_OP: /* - * Match (SearchPackage[0], MatchOp1[1], MatchObject1[2], - * MatchOp2[3], MatchObject2[4], StartIndex[5]) + * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2], + * MatchOp2[3], MatchObj2[4], StartIndex[5]) */ - /* Validate match comparison sub-opcodes */ + /* Validate both Match Term Operators (MTR, MEQ, etc.) */ if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) || (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "operation encoding out of range\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Match operator out of range\n")); Status = AE_AML_OPERAND_VALUE; goto Cleanup; } - Index = (UINT32) Operand[5]->Integer.Value; - if (Index >= (UINT32) Operand[0]->Package.Count) + /* Get the package StartIndex, validate against the package length */ + + Index = Operand[5]->Integer.Value; + if (Index >= Operand[0]->Package.Count) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index beyond package end\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Index (%X%8.8X) beyond package end (%X)\n", + ACPI_FORMAT_UINT64 (Index), Operand[0]->Package.Count)); Status = AE_AML_PACKAGE_LIMIT; goto Cleanup; } + /* Create an integer for the return value */ + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { @@ -299,40 +358,42 @@ AcpiExOpcode_6A_0T_1R ( ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; /* - * Examine each element until a match is found. Within the loop, + * Examine each element until a match is found. Both match conditions + * must be satisfied for a match to occur. Within the loop, * "continue" signifies that the current element does not match * and the next should be examined. * * Upon finding a match, the loop will terminate via "break" at - * the bottom. If it terminates "normally", MatchValue will be -1 - * (its initial value) indicating that no match was found. When - * returned as a Number, this will produce the Ones value as specified. + * the bottom. If it terminates "normally", MatchValue will be + * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no + * match was found. */ for ( ; Index < Operand[0]->Package.Count; Index++) { + /* Get the current package element */ + ThisElement = Operand[0]->Package.Elements[Index]; - /* - * Treat any NULL or non-numeric elements as non-matching. - */ - if (!ThisElement || - ACPI_GET_OBJECT_TYPE (ThisElement) != ACPI_TYPE_INTEGER) + /* Treat any uninitialized (NULL) elements as non-matching */ + + if (!ThisElement) { continue; } /* - * "continue" (proceed to next iteration of enclosing - * "for" loop) signifies a non-match. + * Both match conditions must be satisfied. Execution of a continue + * (proceed to next iteration of enclosing for loop) signifies a + * non-match. */ if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value, - ThisElement->Integer.Value, Operand[2]->Integer.Value)) + ThisElement, Operand[2])) { continue; } if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value, - ThisElement->Integer.Value, Operand[4]->Integer.Value)) + ThisElement, Operand[4])) { continue; } @@ -342,7 +403,6 @@ AcpiExOpcode_6A_0T_1R ( ReturnDesc->Integer.Value = Index; break; } - break; @@ -354,13 +414,12 @@ AcpiExOpcode_6A_0T_1R ( default: - ACPI_REPORT_ERROR (("AcpiExOpcode_3A_0T_0R: Unknown opcode %X\n", + ACPI_REPORT_ERROR (("AcpiExOpcode_6A_0T_1R: Unknown opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } - WalkState->ResultObj = ReturnDesc; diff --git a/sys/contrib/dev/acpica/exprep.c b/sys/contrib/dev/acpica/exprep.c index f02cf25..217afe2 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: 128 $ + * $Revision: 1.135 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -126,8 +126,23 @@ #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exprep") +/* Local prototypes */ + +static UINT32 +AcpiExDecodeFieldAccess ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT32 *ReturnByteAlignment); + #ifdef ACPI_UNDER_DEVELOPMENT + +static UINT32 +AcpiExGenerateAccess ( + UINT32 FieldBitOffset, + UINT32 FieldBitLength, + UINT32 RegionLength); + /******************************************************************************* * * FUNCTION: AcpiExGenerateAccess @@ -173,12 +188,14 @@ AcpiExGenerateAccess ( /* Round Field start offset and length to "minimal" byte boundaries */ FieldByteOffset = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8)); - FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength + FieldBitOffset, 8)); + FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength + + FieldBitOffset, 8)); FieldByteLength = FieldByteEndOffset - FieldByteOffset; ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Bit length %d, Bit offset %d\n", FieldBitLength, FieldBitOffset)); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Byte Length %d, Byte Offset %d, End Offset %d\n", FieldByteLength, FieldByteOffset, FieldByteEndOffset)); @@ -192,21 +209,27 @@ AcpiExGenerateAccess ( for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1) { /* - * 1) Round end offset up to next access boundary and make sure that this - * does not go beyond the end of the parent region. - * 2) When the Access width is greater than the FieldByteLength, we are done. - * (This does not optimize for the perfectly aligned case yet). + * 1) Round end offset up to next access boundary and make sure that + * this does not go beyond the end of the parent region. + * 2) When the Access width is greater than the FieldByteLength, we + * are done. (This does not optimize for the perfectly aligned + * case yet). */ if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength) { - FieldStartOffset = ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) / - AccessByteWidth; - FieldEndOffset = ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset), - AccessByteWidth) / AccessByteWidth; - Accesses = FieldEndOffset - FieldStartOffset; + FieldStartOffset = + ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) / + AccessByteWidth; + + FieldEndOffset = + ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset), + AccessByteWidth) / AccessByteWidth; + + Accesses = FieldEndOffset - FieldStartOffset; ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "AccessWidth %d end is within region\n", AccessByteWidth)); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Field Start %d, Field End %d -- requires %d accesses\n", FieldStartOffset, FieldEndOffset, Accesses)); @@ -216,8 +239,8 @@ AcpiExGenerateAccess ( if (Accesses <= 1) { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "Entire field can be accessed with one operation of size %d\n", - AccessByteWidth)); + "Entire field can be accessed with one operation of size %d\n", + AccessByteWidth)); return_VALUE (AccessByteWidth); } @@ -234,16 +257,21 @@ AcpiExGenerateAccess ( else { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, - "AccessWidth %d end is NOT within region\n", AccessByteWidth)); + "AccessWidth %d end is NOT within region\n", AccessByteWidth)); if (AccessByteWidth == 1) { ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Field goes beyond end-of-region!\n")); - return_VALUE (0); /* Field does not fit in the region at all */ - } - /* This width goes beyond the end-of-region, back off to previous access */ + /* Field does not fit in the region at all */ + return_VALUE (0); + } + + /* + * This width goes beyond the end-of-region, back off to + * previous access + */ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Backing off to previous optimal access width of %d\n", MinimumAccessWidth)); @@ -251,8 +279,10 @@ AcpiExGenerateAccess ( } } - /* Could not read/write field with one operation, just use max access width */ - + /* + * Could not read/write field with one operation, + * just use max access width + */ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Cannot access field in one operation, using width 8\n")); return_VALUE (8); @@ -264,8 +294,9 @@ AcpiExGenerateAccess ( * * FUNCTION: AcpiExDecodeFieldAccess * - * PARAMETERS: Access - Encoded field access bits - * Length - Field length. + * PARAMETERS: ObjDesc - Field object + * FieldFlags - Encoded fieldflags (contains access bits) + * ReturnByteAlignment - Where the byte alignment is returned * * RETURN: Field granularity (8, 16, 32 or 64) and * ByteAlignment (1, 2, 3, or 4) @@ -295,9 +326,10 @@ AcpiExDecodeFieldAccess ( case AML_FIELD_ACCESS_ANY: #ifdef ACPI_UNDER_DEVELOPMENT - ByteAlignment = AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset, - ObjDesc->CommonField.BitLength, - 0xFFFFFFFF /* Temp until we pass RegionLength as param */); + ByteAlignment = + AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BitLength, + 0xFFFFFFFF /* Temp until we pass RegionLength as parameter */); BitLength = ByteAlignment * 8; #endif @@ -332,7 +364,7 @@ AcpiExDecodeFieldAccess ( ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown field access type %X\n", Access)); - return_VALUE (0); + return_UINT32 (0); } if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_BUFFER_FIELD) @@ -346,7 +378,7 @@ AcpiExDecodeFieldAccess ( } *ReturnByteAlignment = ByteAlignment; - return_VALUE (BitLength); + return_UINT32 (BitLength); } @@ -358,6 +390,7 @@ AcpiExDecodeFieldAccess ( * FieldFlags - Access, LockRule, and UpdateRule. * The format of a FieldFlag is described * in the ACPI specification + * FieldAttribute - Special attributes (not used) * FieldBitPosition - Field start position * FieldBitLength - Field length in number of bits * @@ -420,7 +453,9 @@ AcpiExPrepCommonFieldObject ( /* Setup width (access granularity) fields */ ObjDesc->CommonField.AccessByteWidth = (UINT8) - ACPI_DIV_8 (AccessBitWidth); /* 1, 2, 4, 8 */ + ACPI_DIV_8 (AccessBitWidth); /* 1, 2, 4, 8 */ + + ObjDesc->CommonField.AccessBitWidth = (UINT8) AccessBitWidth; /* * BaseByteOffset is the address of the start of the field within the @@ -445,28 +480,6 @@ AcpiExPrepCommonFieldObject ( (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset)); /* - * Valid bits -- the number of bits that compose a partial datum, - * 1) At the end of the field within the region (arbitrary starting bit - * offset) - * 2) At the end of a buffer used to contain the field (starting offset - * always zero) - */ - ObjDesc->CommonField.EndFieldValidBits = (UINT8) - ((ObjDesc->CommonField.StartFieldBitOffset + FieldBitLength) % - AccessBitWidth); - /* StartBufferBitOffset always = 0 */ - - ObjDesc->CommonField.EndBufferValidBits = (UINT8) - (FieldBitLength % AccessBitWidth); - - /* - * DatumValidBits is the number of valid field bits in the first - * field datum. - */ - ObjDesc->CommonField.DatumValidBits = (UINT8) - (AccessBitWidth - ObjDesc->CommonField.StartFieldBitOffset); - - /* * Does the entire field fit within a single field access element? (datum) * (i.e., without crossing a datum boundary) */ @@ -484,11 +497,7 @@ AcpiExPrepCommonFieldObject ( * * FUNCTION: AcpiExPrepFieldValue * - * PARAMETERS: Node - Owning Node - * RegionNode - Region in which field is being defined - * FieldFlags - Access, LockRule, and UpdateRule. - * FieldBitPosition - Field start position - * FieldBitLength - Field length in number of bits + * PARAMETERS: Info - Contains all field creation info * * RETURN: Status * @@ -555,7 +564,7 @@ AcpiExPrepFieldValue ( { case ACPI_TYPE_LOCAL_REGION_FIELD: - ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); + ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); /* An additional reference for the container */ @@ -571,8 +580,10 @@ AcpiExPrepFieldValue ( case ACPI_TYPE_LOCAL_BANK_FIELD: ObjDesc->BankField.Value = Info->BankValue; - ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); - ObjDesc->BankField.BankObj = AcpiNsGetAttachedObject (Info->RegisterNode); + ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject ( + Info->RegionNode); + ObjDesc->BankField.BankObj = AcpiNsGetAttachedObject ( + Info->RegisterNode); /* An additional reference for the attached objects */ @@ -591,10 +602,13 @@ AcpiExPrepFieldValue ( case ACPI_TYPE_LOCAL_INDEX_FIELD: - ObjDesc->IndexField.IndexObj = AcpiNsGetAttachedObject (Info->RegisterNode); - ObjDesc->IndexField.DataObj = AcpiNsGetAttachedObject (Info->DataRegisterNode); + ObjDesc->IndexField.IndexObj = AcpiNsGetAttachedObject ( + Info->RegisterNode); + ObjDesc->IndexField.DataObj = AcpiNsGetAttachedObject ( + Info->DataRegisterNode); ObjDesc->IndexField.Value = (UINT32) - (Info->FieldBitPosition / ACPI_MUL_8 (ObjDesc->Field.AccessByteWidth)); + (Info->FieldBitPosition / ACPI_MUL_8 ( + ObjDesc->Field.AccessByteWidth)); if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj) { diff --git a/sys/contrib/dev/acpica/exregion.c b/sys/contrib/dev/acpica/exregion.c index 58c6aa3..52546cc 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: 87 $ + * $Revision: 1.91 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -158,7 +158,7 @@ AcpiExSystemMemorySpaceHandler ( ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext; UINT32 Length; ACPI_SIZE WindowSize; -#ifndef ACPI_MISALIGNED_TRANSFERS +#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED UINT32 Remainder; #endif @@ -191,8 +191,7 @@ AcpiExSystemMemorySpaceHandler ( return_ACPI_STATUS (AE_AML_OPERAND_VALUE); } - -#ifndef ACPI_MISALIGNED_TRANSFERS +#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED /* * Hardware does not support non-aligned data transfers, we must verify * the request. @@ -211,7 +210,8 @@ AcpiExSystemMemorySpaceHandler ( */ if ((Address < MemInfo->MappedPhysicalAddress) || (((ACPI_INTEGER) Address + Length) > - ((ACPI_INTEGER) MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) + ((ACPI_INTEGER) + MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) { /* * The request cannot be resolved by the current memory mapping; @@ -229,7 +229,9 @@ AcpiExSystemMemorySpaceHandler ( * Don't attempt to map memory beyond the end of the region, and * constrain the maximum mapping size to something reasonable. */ - WindowSize = (ACPI_SIZE) ((MemInfo->Address + MemInfo->Length) - Address); + WindowSize = (ACPI_SIZE) + ((MemInfo->Address + MemInfo->Length) - Address); + if (WindowSize > ACPI_SYSMEM_REGION_WINDOW_SIZE) { WindowSize = ACPI_SYSMEM_REGION_WINDOW_SIZE; @@ -241,8 +243,9 @@ AcpiExSystemMemorySpaceHandler ( (void **) &MemInfo->MappedLogicalAddress); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X%8.8X, size %X\n", - ACPI_FORMAT_UINT64 (Address), (UINT32) WindowSize)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not map memory at %8.8X%8.8X, size %X\n", + ACPI_FORMAT_UINT64 (Address), (UINT32) WindowSize)); MemInfo->MappedLength = 0; return_ACPI_STATUS (Status); } @@ -258,10 +261,12 @@ AcpiExSystemMemorySpaceHandler ( * access */ LogicalAddrPtr = MemInfo->MappedLogicalAddress + - ((ACPI_INTEGER) Address - (ACPI_INTEGER) MemInfo->MappedPhysicalAddress); + ((ACPI_INTEGER) Address - + (ACPI_INTEGER) MemInfo->MappedPhysicalAddress); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "SystemMemory %d (%d width) Address=%8.8X%8.8X\n", Function, BitWidth, + "SystemMemory %d (%d width) Address=%8.8X%8.8X\n", + Function, BitWidth, ACPI_FORMAT_UINT64 (Address))); /* @@ -383,13 +388,15 @@ AcpiExSystemIoSpaceHandler ( { case ACPI_READ: - Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) Address, &Value32, BitWidth); + Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) Address, + &Value32, BitWidth); *Value = Value32; break; case ACPI_WRITE: - Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) Address, (UINT32) *Value, BitWidth); + Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) Address, + (UINT32) *Value, BitWidth); break; default: @@ -461,12 +468,14 @@ AcpiExPciConfigSpaceHandler ( case ACPI_READ: *Value = 0; - Status = AcpiOsReadPciConfiguration (PciId, PciRegister, Value, BitWidth); + Status = AcpiOsReadPciConfiguration (PciId, PciRegister, + Value, BitWidth); break; case ACPI_WRITE: - Status = AcpiOsWritePciConfiguration (PciId, PciRegister, *Value, BitWidth); + Status = AcpiOsWritePciConfiguration (PciId, PciRegister, + *Value, BitWidth); break; default: @@ -591,8 +600,7 @@ AcpiExDataTableSpaceHandler ( LogicalAddrPtr = ACPI_PHYSADDR_TO_PTR (Address); - - /* Perform the memory read or write */ + /* Perform the memory read or write */ switch (Function) { diff --git a/sys/contrib/dev/acpica/exresnte.c b/sys/contrib/dev/acpica/exresnte.c index 0368741..d5ea4c6 100644 --- a/sys/contrib/dev/acpica/exresnte.c +++ b/sys/contrib/dev/acpica/exresnte.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exresnte - AML Interpreter object resolution - * $Revision: 65 $ + * $Revision: 1.68 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -294,15 +294,15 @@ AcpiExResolveNodeToValue ( case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead Node=%p SourceDesc=%p Type=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "FieldRead Node=%p SourceDesc=%p Type=%X\n", Node, SourceDesc, EntryType)); Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc); break; - /* - * For these objects, just return the object attached to the Node - */ + /* For these objects, just return the object attached to the Node */ + case ACPI_TYPE_MUTEX: case ACPI_TYPE_METHOD: case ACPI_TYPE_POWER: @@ -317,12 +317,12 @@ AcpiExResolveNodeToValue ( AcpiUtAddReference (ObjDesc); break; - /* TYPE_ANY is untyped, and thus there is no object associated with it */ case ACPI_TYPE_ANY: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Untyped entry %p, no attached object!\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Untyped entry %p, no attached object!\n", Node)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ @@ -344,7 +344,8 @@ AcpiExResolveNodeToValue ( default: /* No named references are allowed here */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported Reference opcode %X (%s)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unsupported Reference opcode %X (%s)\n", SourceDesc->Reference.Opcode, AcpiPsGetOpcodeName (SourceDesc->Reference.Opcode))); @@ -353,11 +354,12 @@ AcpiExResolveNodeToValue ( break; - /* Default case is for unknown types */ - default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Node %p - Unknown object type %X\n", + /* Default case is for unknown types */ + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Node %p - Unknown object type %X\n", Node, EntryType)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -365,7 +367,7 @@ AcpiExResolveNodeToValue ( } /* switch (EntryType) */ - /* Put the object descriptor on the stack */ + /* Return the object descriptor */ *ObjectPtr = (void *) ObjDesc; return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/exresolv.c b/sys/contrib/dev/acpica/exresolv.c index 51f234c..630540c 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: 125 $ + * $Revision: 1.132 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -128,6 +128,13 @@ #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exresolv") +/* Local prototypes */ + +static ACPI_STATUS +AcpiExResolveObjectToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + /******************************************************************************* * @@ -173,6 +180,12 @@ AcpiExResolveToValue ( { return_ACPI_STATUS (Status); } + + if (!*StackPtr) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } } /* @@ -199,18 +212,17 @@ AcpiExResolveToValue ( * * FUNCTION: AcpiExResolveObjectToValue * - * PARAMETERS: StackPtr - Pointer to a stack location that contains a - * ptr to an internal object. + * PARAMETERS: StackPtr - Pointer to an internal object * WalkState - Current method state * * RETURN: Status * - * DESCRIPTION: Retrieve the value from an internal object. The Reference type + * DESCRIPTION: Retrieve the value from an internal object. The Reference type * uses the associated AML opcode to determine the value. * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExResolveObjectToValue ( ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState) @@ -240,7 +252,7 @@ AcpiExResolveObjectToValue ( case AML_NAME_OP: /* - * Convert indirect name ptr to a direct name ptr. + * Convert name reference to a namespace node * Then, AcpiExResolveNodeToValue can be used to get the value */ TempNode = StackDesc->Reference.Object; @@ -249,7 +261,7 @@ AcpiExResolveObjectToValue ( AcpiUtRemoveReference (StackDesc); - /* Put direct name pointer onto stack and exit */ + /* Return the namespace node */ (*StackPtr) = TempNode; break; @@ -340,10 +352,19 @@ AcpiExResolveObjectToValue ( break; + case AML_INT_NAMEPATH_OP: /* Reference to a named object */ + + /* Get the object pointed to by the namespace node */ + + *StackPtr = (StackDesc->Reference.Node)->Object; + AcpiUtAddReference (*StackPtr); + AcpiUtRemoveReference (StackDesc); + break; default: - ACPI_REPORT_ERROR (("During resolve, Unknown Reference opcode %X (%s) in %p\n", + ACPI_REPORT_ERROR (( + "During resolve, Unknown Reference opcode %X (%s) in %p\n", Opcode, AcpiPsGetOpcodeName (Opcode), StackDesc)); Status = AE_AML_INTERNAL; break; @@ -363,9 +384,8 @@ AcpiExResolveObjectToValue ( break; - /* - * These cases may never happen here, but just in case.. - */ + /* These cases may never happen here, but just in case.. */ + case ACPI_TYPE_BUFFER_FIELD: case ACPI_TYPE_LOCAL_REGION_FIELD: case ACPI_TYPE_LOCAL_BANK_FIELD: @@ -418,10 +438,8 @@ AcpiExResolveMultiple ( ACPI_FUNCTION_TRACE ("AcpiExResolveMultiple"); + /* Operand can be either a namespace node or an operand descriptor */ - /* - * Operand can be either a namespace node or an operand descriptor - */ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) { case ACPI_DESC_TYPE_OPERAND: @@ -445,10 +463,8 @@ AcpiExResolveMultiple ( return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } + /* If type is anything other than a reference, we are done */ - /* - * If type is anything other than a reference, we are done - */ if (Type != ACPI_TYPE_LOCAL_REFERENCE) { goto Exit; @@ -474,8 +490,9 @@ AcpiExResolveMultiple ( if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR (("AcpiExResolveMultiple: Not a NS node %p [%s]\n", - Node, AcpiUtGetDescriptorName (Node))); + ACPI_REPORT_ERROR (( + "AcpiExResolveMultiple: Not a NS node %p [%s]\n", + Node, AcpiUtGetDescriptorName (Node))); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -517,6 +534,13 @@ AcpiExResolveMultiple ( * This could of course in turn be another reference object. */ ObjDesc = *(ObjDesc->Reference.Where); + if (!ObjDesc) + { + /* NULL package elements are allowed */ + + Type = 0; /* Uninitialized */ + goto Exit; + } break; @@ -530,8 +554,9 @@ AcpiExResolveMultiple ( if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { - ACPI_REPORT_ERROR (("AcpiExResolveMultiple: Not a NS node %p [%s]\n", - Node, AcpiUtGetDescriptorName (Node))); + ACPI_REPORT_ERROR (( + "AcpiExResolveMultiple: Not a NS node %p [%s]\n", + Node, AcpiUtGetDescriptorName (Node))); return_ACPI_STATUS (AE_AML_INTERNAL); } @@ -561,7 +586,7 @@ AcpiExResolveMultiple ( if (ReturnDesc) { Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Opcode, - ObjDesc->Reference.Offset, WalkState, &ObjDesc); + ObjDesc->Reference.Offset, WalkState, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -597,7 +622,8 @@ AcpiExResolveMultiple ( default: - ACPI_REPORT_ERROR (("AcpiExResolveMultiple: Unknown Reference subtype %X\n", + ACPI_REPORT_ERROR (( + "AcpiExResolveMultiple: Unknown Reference subtype %X\n", ObjDesc->Reference.Opcode)); return_ACPI_STATUS (AE_AML_INTERNAL); } diff --git a/sys/contrib/dev/acpica/exresop.c b/sys/contrib/dev/acpica/exresop.c index e1d5b04..505d2e1 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: 70 $ + * $Revision: 1.86 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -126,6 +126,14 @@ #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exresop") +/* Local prototypes */ + +static ACPI_STATUS +AcpiExCheckObjectType ( + ACPI_OBJECT_TYPE TypeNeeded, + ACPI_OBJECT_TYPE ThisType, + void *Object); + /******************************************************************************* * @@ -141,7 +149,7 @@ * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExCheckObjectType ( ACPI_OBJECT_TYPE TypeNeeded, ACPI_OBJECT_TYPE ThisType, @@ -220,6 +228,7 @@ AcpiExResolveOperands ( const ACPI_OPCODE_INFO *OpInfo; UINT32 ThisArgType; ACPI_OBJECT_TYPE TypeNeeded; + UINT16 TargetOp = 0; ACPI_FUNCTION_TRACE_U32 ("ExResolveOperands", Opcode); @@ -240,7 +249,8 @@ AcpiExResolveOperands ( return_ACPI_STATUS (AE_AML_INTERNAL); } - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X [%s] RequiredOperandTypes=%8.8X \n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Opcode %X [%s] RequiredOperandTypes=%8.8X\n", Opcode, OpInfo->Name, ArgTypes)); /* @@ -270,7 +280,7 @@ AcpiExResolveOperands ( { case ACPI_DESC_TYPE_NAMED: - /* Node */ + /* Namespace Node */ ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; break; @@ -286,7 +296,8 @@ AcpiExResolveOperands ( if (!AcpiUtValidObjectType (ObjectType)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad operand object type [%X]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Bad operand object type [%X]\n", ObjectType)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); @@ -294,9 +305,8 @@ AcpiExResolveOperands ( if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE) { - /* - * Decode the Reference - */ + /* Decode the Reference */ + OpInfo = AcpiPsGetOpcodeInfo (Opcode); if (OpInfo->Class == AML_CLASS_UNKNOWN) { @@ -306,12 +316,17 @@ AcpiExResolveOperands ( switch (ObjDesc->Reference.Opcode) { case AML_DEBUG_OP: + TargetOp = AML_DEBUG_OP; + + /*lint -fallthrough */ + case AML_NAME_OP: case AML_INDEX_OP: case AML_REF_OF_OP: case AML_ARG_OP: case AML_LOCAL_OP: - case AML_LOAD_OP: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ + case AML_LOAD_OP: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ + case AML_INT_NAMEPATH_OP: /* Reference to a named object */ ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Operand is a Reference, RefOpcode [%s]\n", @@ -341,10 +356,8 @@ AcpiExResolveOperands ( return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } + /* Get one argument type, point to the next */ - /* - * Get one argument type, point to the next - */ ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes); INCREMENT_ARG_LIST (ArgTypes); @@ -360,26 +373,31 @@ AcpiExResolveOperands ( (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_STRING)) { /* - * String found - the string references a named object and must be - * resolved to a node + * String found - the string references a named object and + * must be resolved to a node */ goto NextOperand; } - /* Else not a string - fall through to the normal Reference case below */ + /* + * Else not a string - fall through to the normal Reference + * case below + */ /*lint -fallthrough */ case ARGI_REFERENCE: /* References: */ case ARGI_INTEGER_REF: case ARGI_OBJECT_REF: case ARGI_DEVICE_REF: - case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ - case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ - case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ - - /* Need an operand of type ACPI_TYPE_LOCAL_REFERENCE */ + case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ + case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ + case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ - if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) /* Node (name) ptr OK as-is */ + /* + * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE + * A Namespace Node is OK as-is + */ + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) { goto NextOperand; } @@ -391,12 +409,10 @@ AcpiExResolveOperands ( return_ACPI_STATUS (Status); } - if (AML_NAME_OP == ObjDesc->Reference.Opcode) + if (ObjDesc->Reference.Opcode == AML_NAME_OP) { - /* - * Convert an indirect name ptr to direct name ptr and put - * it on the stack - */ + /* Convert a named reference to the actual named object */ + TempNode = ObjDesc->Reference.Object; AcpiUtRemoveReference (ObjDesc); (*StackPtr) = TempNode; @@ -404,7 +420,7 @@ AcpiExResolveOperands ( goto NextOperand; - case ARGI_ANYTYPE: + case ARGI_DATAREFOBJ: /* Store operator only */ /* * We don't want to resolve IndexOp reference objects during @@ -425,7 +441,6 @@ AcpiExResolveOperands ( break; } - /* * Resolve this object to a value */ @@ -487,7 +502,7 @@ AcpiExResolveOperands ( /* * The more complex cases allow multiple resolved object types */ - case ARGI_INTEGER: /* Number */ + case ARGI_INTEGER: /* * Need an operand of type ACPI_TYPE_INTEGER, @@ -508,6 +523,11 @@ AcpiExResolveOperands ( return_ACPI_STATUS (Status); } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } goto NextOperand; @@ -532,6 +552,11 @@ AcpiExResolveOperands ( return_ACPI_STATUS (Status); } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } goto NextOperand; @@ -557,6 +582,11 @@ AcpiExResolveOperands ( return_ACPI_STATUS (Status); } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } goto NextOperand; @@ -604,6 +634,11 @@ AcpiExResolveOperands ( { return_ACPI_STATUS (Status); } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } break; default: @@ -669,7 +704,7 @@ AcpiExResolveOperands ( case ARGI_REGION_OR_FIELD: - /* Need an operand of type ACPI_TYPE_REGION or a FIELD in a region */ + /* Need an operand of type REGION or a FIELD in a region */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { @@ -691,6 +726,54 @@ AcpiExResolveOperands ( goto NextOperand; + case ARGI_DATAREFOBJ: + + /* Used by the Store() operator only */ + + switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REFERENCE: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + case ACPI_TYPE_DDB_HANDLE: + + /* Valid operand */ + break; + + default: + + if (AcpiGbl_EnableInterpreterSlack) + { + /* + * Enable original behavior of Store(), allowing any and all + * objects as the source operand. The ACPI spec does not + * allow this, however. + */ + break; + } + + if (TargetOp == AML_DEBUG_OP) + { + /* Allow store of any object to the Debug object */ + + break; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p\n", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + default: /* Unknown type */ @@ -722,8 +805,7 @@ NextOperand: { StackPtr--; } - - } /* while (*Types) */ + } return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exstore.c b/sys/contrib/dev/acpica/exstore.c index 53c3f16..cb35b62 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: 186 $ + * $Revision: 1.196 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -122,11 +122,187 @@ #include <contrib/dev/acpica/acinterp.h> #include <contrib/dev/acpica/amlcode.h> #include <contrib/dev/acpica/acnamesp.h> +#include <contrib/dev/acpica/acparser.h> #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exstore") +/* Local prototypes */ + +static void +AcpiExDoDebugObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + UINT32 Level, + UINT32 Index); + +static ACPI_STATUS +AcpiExStoreObjectToIndex ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState); + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoDebugObject + * + * PARAMETERS: SourceDesc - Value to be stored + * Level - Indentation level (used for packages) + * Index - Current package element, zero if not pkg + * + * RETURN: None + * + * DESCRIPTION: Handles stores to the Debug Object. + * + ******************************************************************************/ + +static void +AcpiExDoDebugObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + UINT32 Level, + UINT32 Index) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR ("ExDoDebugObject", SourceDesc); + + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s", + Level, " ")); + + /* Display index for package output only */ + + if (Index > 0) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, + "(%.2u) ", Index -1)); + } + + if (!SourceDesc) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "<Null Object>\n")); + return_VOID; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: ", + AcpiUtGetObjectTypeName (SourceDesc))); + + if (!AcpiUtValidInternalObject (SourceDesc)) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, + "%p, Invalid Internal Object!\n", SourceDesc)); + return_VOID; + } + } + else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s: %p\n", + AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type), + SourceDesc)); + return_VOID; + } + else + { + return_VOID; + } + + switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) + { + case ACPI_TYPE_INTEGER: + + /* Output correct integer width */ + + 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, "[0x%.2X]\n", + (UINT32) SourceDesc->Buffer.Length)); + ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer, + (SourceDesc->Buffer.Length < 32) ? SourceDesc->Buffer.Length : 32); + break; + + case ACPI_TYPE_STRING: + + 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, "[0x%.2X Elements]\n", + SourceDesc->Package.Count)); + + /* Output the entire contents of the package */ + + for (i = 0; i < SourceDesc->Package.Count; i++) + { + AcpiExDoDebugObject (SourceDesc->Package.Elements[i], + Level+4, i+1); + } + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + + if (SourceDesc->Reference.Opcode == AML_INDEX_OP) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s, 0x%X]\n", + AcpiPsGetOpcodeName (SourceDesc->Reference.Opcode), + SourceDesc->Reference.Offset)); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[%s]\n", + AcpiPsGetOpcodeName (SourceDesc->Reference.Opcode))); + } + + + if (SourceDesc->Reference.Object) + { + if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) == + ACPI_DESC_TYPE_NAMED) + { + AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *) + SourceDesc->Reference.Object)->Object, + Level+4, 0); + } + else + { + AcpiExDoDebugObject (SourceDesc->Reference.Object, Level+4, 0); + } + } + else if (SourceDesc->Reference.Node) + { + AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object, + Level+4, 0); + } + break; + + default: + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%p %s\n", + SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); + break; + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); + return_VOID; +} + /******************************************************************************* * @@ -233,8 +409,9 @@ AcpiExStore ( /* Storing an object into a Name "container" */ - Status = AcpiExStoreObjectToNode (SourceDesc, RefDesc->Reference.Object, - WalkState, ACPI_IMPLICIT_CONVERSION); + Status = AcpiExStoreObjectToNode (SourceDesc, + RefDesc->Reference.Object, + WalkState, ACPI_IMPLICIT_CONVERSION); break; @@ -252,7 +429,7 @@ AcpiExStore ( /* Store to a method local/arg */ Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Opcode, - RefDesc->Reference.Offset, SourceDesc, WalkState); + RefDesc->Reference.Offset, SourceDesc, WalkState); break; @@ -266,64 +443,7 @@ AcpiExStore ( "**** 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))); - - 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: - - 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, "[0x%.2X]", - (UINT32) SourceDesc->Buffer.Length)); - ACPI_DUMP_BUFFER (SourceDesc->Buffer.Pointer, - (SourceDesc->Buffer.Length < 32) ? SourceDesc->Buffer.Length : 32); - break; - - - case ACPI_TYPE_STRING: - - 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, "[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)); - break; - } - - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); + AcpiExDoDebugObject (SourceDesc, 0, 0); break; @@ -355,7 +475,7 @@ AcpiExStore ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiExStoreObjectToIndex ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *IndexDesc, @@ -399,21 +519,27 @@ AcpiExStoreObjectToIndex ( { /* Decrement reference count by the ref count of the parent package */ - for (i = 0; i < ((ACPI_OPERAND_OBJECT *) IndexDesc->Reference.Object)->Common.ReferenceCount; i++) + for (i = 0; + i < ((ACPI_OPERAND_OBJECT *) + IndexDesc->Reference.Object)->Common.ReferenceCount; + i++) { AcpiUtRemoveReference (ObjDesc); } } - + *(IndexDesc->Reference.Where) = NewDesc; - /* Increment reference count by the ref count of the parent package -1 */ + /* Increment ref count by the ref count of the parent package-1 */ - for (i = 1; i < ((ACPI_OPERAND_OBJECT *) IndexDesc->Reference.Object)->Common.ReferenceCount; i++) + for (i = 1; + i < ((ACPI_OPERAND_OBJECT *) + IndexDesc->Reference.Object)->Common.ReferenceCount; + i++) { AcpiUtAddReference (NewDesc); } - + break; @@ -530,9 +656,8 @@ AcpiExStoreObjectToNode ( ACPI_FUNCTION_TRACE_PTR ("ExStoreObjectToNode", SourceDesc); - /* - * Get current type of the node, and object attached to Node - */ + /* Get current type of the node, and object attached to Node */ + TargetType = AcpiNsGetType (Node); TargetDesc = AcpiNsGetAttachedObject (Node); @@ -552,16 +677,15 @@ AcpiExStoreObjectToNode ( /* If no implicit conversion, drop into the default case below */ - if (!ImplicitConversion) + if ((!ImplicitConversion) || (WalkState->Opcode == AML_COPY_OP)) { /* Force execution of default (no implicit conversion) */ TargetType = ACPI_TYPE_ANY; } - /* - * Do the actual store operation - */ + /* Do the actual store operation */ + switch (TargetType) { case ACPI_TYPE_BUFFER_FIELD: @@ -569,10 +693,10 @@ AcpiExStoreObjectToNode ( case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: - /* - * For fields, copy the source data to the target field. - */ - Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, &WalkState->ResultObj); + /* For fields, copy the source data to the target field. */ + + Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, + &WalkState->ResultObj); break; @@ -586,7 +710,8 @@ AcpiExStoreObjectToNode ( * * Copy and/or convert the source object to a new target object */ - Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, &NewDesc, WalkState); + Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, + &NewDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -616,12 +741,13 @@ AcpiExStoreObjectToNode ( default: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Storing %s (%p) directly into node (%p), no implicit conversion\n", + "Storing %s (%p) directly into node (%p) with no implicit conversion\n", AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node)); /* No conversions for all other types. Just attach the source object */ - Status = AcpiNsAttachObject (Node, SourceDesc, ACPI_GET_OBJECT_TYPE (SourceDesc)); + Status = AcpiNsAttachObject (Node, SourceDesc, + ACPI_GET_OBJECT_TYPE (SourceDesc)); break; } diff --git a/sys/contrib/dev/acpica/exstoren.c b/sys/contrib/dev/acpica/exstoren.c index 189136b..23054a0 100644 --- a/sys/contrib/dev/acpica/exstoren.c +++ b/sys/contrib/dev/acpica/exstoren.c @@ -3,7 +3,7 @@ * * Module Name: exstoren - AML Interpreter object store support, * Store to Node (namespace object) - * $Revision: 59 $ + * $Revision: 1.64 $ * *****************************************************************************/ @@ -11,7 +11,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -155,9 +155,8 @@ AcpiExResolveObject ( ACPI_FUNCTION_TRACE ("ExResolveObject"); - /* - * Ensure we have a Target that can be stored to - */ + /* Ensure we have a Target that can be stored to */ + switch (TargetType) { case ACPI_TYPE_BUFFER_FIELD: @@ -196,17 +195,15 @@ AcpiExResolveObject ( break; } - /* - * Must have a Integer, Buffer, or String - */ + /* Must have a Integer, Buffer, or String */ + if ((ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_INTEGER) && (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_BUFFER) && (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_STRING) && !((ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_LOCAL_REFERENCE) && (SourceDesc->Reference.Opcode == AML_LOAD_OP))) { - /* - * Conversion successful but still not a valid type - */ + /* Conversion successful but still not a valid type */ + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Cannot assign type %s to %s (must be type Int/Str/Buf)\n", AcpiUtGetObjectTypeName (SourceDesc), @@ -219,9 +216,8 @@ AcpiExResolveObject ( case ACPI_TYPE_LOCAL_ALIAS: case ACPI_TYPE_LOCAL_METHOD_ALIAS: - /* - * Aliases are resolved by AcpiExPrepOperands - */ + /* Aliases are resolved by AcpiExPrepOperands */ + ACPI_REPORT_ERROR (("Store into Alias - should never happen\n")); Status = AE_AML_INTERNAL; break; @@ -313,8 +309,8 @@ AcpiExStoreObjectToObject ( * Otherwise, ActualSrcDesc is a temporary object to hold the * converted object. */ - Status = AcpiExConvertToTargetType (ACPI_GET_OBJECT_TYPE (DestDesc), SourceDesc, - &ActualSrcDesc, WalkState); + Status = AcpiExConvertToTargetType (ACPI_GET_OBJECT_TYPE (DestDesc), + SourceDesc, &ActualSrcDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -323,7 +319,7 @@ AcpiExStoreObjectToObject ( if (SourceDesc == ActualSrcDesc) { /* - * No conversion was performed. Return the SourceDesc as the + * No conversion was performed. Return the SourceDesc as the * new object. */ *NewDesc = SourceDesc; @@ -358,7 +354,8 @@ AcpiExStoreObjectToObject ( case ACPI_TYPE_PACKAGE: - Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc, WalkState); + Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc, + WalkState); break; default: diff --git a/sys/contrib/dev/acpica/exstorob.c b/sys/contrib/dev/acpica/exstorob.c index 0edd05a..73e5db2 100644 --- a/sys/contrib/dev/acpica/exstorob.c +++ b/sys/contrib/dev/acpica/exstorob.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: exstorob - AML Interpreter object store support, store to object - * $Revision: 51 $ + * $Revision: 1.57 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -150,9 +150,8 @@ AcpiExStoreBufferToBuffer ( ACPI_FUNCTION_TRACE_PTR ("ExStoreBufferToBuffer", SourceDesc); - /* - * We know that SourceDesc is a buffer by now - */ + /* We know that SourceDesc is a buffer by now */ + Buffer = (UINT8 *) SourceDesc->Buffer.Pointer; Length = SourceDesc->Buffer.Length; @@ -169,36 +168,57 @@ AcpiExStoreBufferToBuffer ( return_ACPI_STATUS (AE_NO_MEMORY); } - TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; TargetDesc->Buffer.Length = Length; } - /* - * Buffer is a static allocation, - * only place what will fit in the buffer. - */ + /* Copy source buffer to target buffer */ + if (Length <= TargetDesc->Buffer.Length) { /* Clear existing buffer and copy in the new one */ ACPI_MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length); ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length); + +#ifdef ACPI_OBSOLETE_BEHAVIOR + /* + * NOTE: ACPI versions up to 3.0 specified that the buffer must be + * truncated if the string is smaller than the buffer. However, "other" + * implementations of ACPI never did this and thus became the defacto + * standard. ACPI 3.0A changes this behavior such that the buffer + * is no longer truncated. + */ + + /* + * OBSOLETE BEHAVIOR: + * If the original source was a string, we must truncate the buffer, + * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer + * copy must not truncate the original buffer. + */ + if (OriginalSrcType == ACPI_TYPE_STRING) + { + /* Set the new length of the target */ + + TargetDesc->Buffer.Length = Length; + } +#endif } else { - /* - * Truncate the source, copy only what will fit - */ - ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, TargetDesc->Buffer.Length); + /* Truncate the source, copy only what will fit */ + + ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, + TargetDesc->Buffer.Length); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Truncating src buffer from %X to %X\n", + "Truncating source buffer from %X to %X\n", Length, TargetDesc->Buffer.Length)); } /* Copy flags */ TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags; + TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; return_ACPI_STATUS (AE_OK); } @@ -228,9 +248,8 @@ AcpiExStoreStringToString ( ACPI_FUNCTION_TRACE_PTR ("ExStoreStringToString", SourceDesc); - /* - * We know that SourceDesc is a string by now. - */ + /* We know that SourceDesc is a string by now */ + Buffer = (UINT8 *) SourceDesc->String.Pointer; Length = SourceDesc->String.Length; @@ -245,7 +264,8 @@ AcpiExStoreStringToString ( * String will fit in existing non-static buffer. * Clear old string and copy in the new one */ - ACPI_MEMSET (TargetDesc->String.Pointer, 0, (ACPI_SIZE) TargetDesc->String.Length + 1); + ACPI_MEMSET (TargetDesc->String.Pointer, 0, + (ACPI_SIZE) TargetDesc->String.Length + 1); ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); } else @@ -257,13 +277,13 @@ AcpiExStoreStringToString ( if (TargetDesc->String.Pointer && (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) { - /* - * Only free if not a pointer into the DSDT - */ + /* Only free if not a pointer into the DSDT */ + ACPI_MEM_FREE (TargetDesc->String.Pointer); } - TargetDesc->String.Pointer = ACPI_MEM_CALLOCATE ((ACPI_SIZE) Length + 1); + TargetDesc->String.Pointer = ACPI_MEM_CALLOCATE ( + (ACPI_SIZE) Length + 1); if (!TargetDesc->String.Pointer) { return_ACPI_STATUS (AE_NO_MEMORY); diff --git a/sys/contrib/dev/acpica/exsystem.c b/sys/contrib/dev/acpica/exsystem.c index 8e11af5..d28b257 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: 81 $ + * $Revision: 1.84 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -129,8 +129,8 @@ * * FUNCTION: AcpiExSystemWaitSemaphore * - * PARAMETERS: Semaphore - OSD semaphore to wait on - * Timeout - Max time to wait + * PARAMETERS: Semaphore - Semaphore to wait on + * Timeout - Max time to wait * * RETURN: Status * @@ -166,7 +166,8 @@ AcpiExSystemWaitSemaphore ( Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*** Thread awake after blocking, %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "*** Thread awake after blocking, %s\n", AcpiFormatException (Status))); /* Reacquire the interpreter */ @@ -188,8 +189,8 @@ AcpiExSystemWaitSemaphore ( * * FUNCTION: AcpiExSystemDoStall * - * PARAMETERS: HowLong - The amount of time to stall, - * in microseconds + * PARAMETERS: HowLong - The amount of time to stall, + * in microseconds * * RETURN: Status * @@ -219,7 +220,8 @@ AcpiExSystemDoStall ( * (ACPI specifies 100 usec as max, but this gives some slack in * order to support existing BIOSs) */ - ACPI_REPORT_ERROR (("Stall: Time parameter is too large (%d)\n", HowLong)); + ACPI_REPORT_ERROR (("Stall: Time parameter is too large (%d)\n", + HowLong)); Status = AE_AML_OPERAND_VALUE; } else @@ -235,8 +237,8 @@ AcpiExSystemDoStall ( * * FUNCTION: AcpiExSystemDoSuspend * - * PARAMETERS: HowLong - The amount of time to suspend, - * in milliseconds + * PARAMETERS: HowLong - The amount of time to suspend, + * in milliseconds * * RETURN: None * @@ -271,8 +273,8 @@ AcpiExSystemDoSuspend ( * * FUNCTION: AcpiExSystemAcquireMutex * - * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor - * *ObjDesc - The object descriptor for this op + * PARAMETERS: TimeDesc - The 'time to delay' object descriptor + * ObjDesc - The object descriptor for this op * * RETURN: Status * @@ -298,9 +300,8 @@ AcpiExSystemAcquireMutex ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * Support for the _GL_ Mutex object -- go get the global lock - */ + /* Support for the _GL_ Mutex object -- go get the global lock */ + if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore) { Status = AcpiEvAcquireGlobalLock ((UINT16) TimeDesc->Integer.Value); @@ -308,7 +309,7 @@ AcpiExSystemAcquireMutex ( } Status = AcpiExSystemWaitSemaphore (ObjDesc->Mutex.Semaphore, - (UINT16) TimeDesc->Integer.Value); + (UINT16) TimeDesc->Integer.Value); return_ACPI_STATUS (Status); } @@ -317,7 +318,7 @@ AcpiExSystemAcquireMutex ( * * FUNCTION: AcpiExSystemReleaseMutex * - * PARAMETERS: *ObjDesc - The object descriptor for this op + * PARAMETERS: ObjDesc - The object descriptor for this op * * RETURN: Status * @@ -343,9 +344,8 @@ AcpiExSystemReleaseMutex ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * Support for the _GL_ Mutex object -- release the global lock - */ + /* Support for the _GL_ Mutex object -- release the global lock */ + if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore) { Status = AcpiEvReleaseGlobalLock (); @@ -361,9 +361,9 @@ AcpiExSystemReleaseMutex ( * * FUNCTION: AcpiExSystemSignalEvent * - * PARAMETERS: *ObjDesc - The object descriptor for this op + * PARAMETERS: ObjDesc - The object descriptor for this op * - * RETURN: AE_OK + * RETURN: Status * * DESCRIPTION: Provides an access point to perform synchronization operations * within the AML. @@ -393,8 +393,8 @@ AcpiExSystemSignalEvent ( * * FUNCTION: AcpiExSystemWaitEvent * - * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor - * *ObjDesc - The object descriptor for this op + * PARAMETERS: TimeDesc - The 'time to delay' object descriptor + * ObjDesc - The object descriptor for this op * * RETURN: Status * @@ -418,7 +418,7 @@ AcpiExSystemWaitEvent ( if (ObjDesc) { Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.Semaphore, - (UINT16) TimeDesc->Integer.Value); + (UINT16) TimeDesc->Integer.Value); } return_ACPI_STATUS (Status); @@ -429,7 +429,7 @@ AcpiExSystemWaitEvent ( * * FUNCTION: AcpiExSystemResetEvent * - * PARAMETERS: *ObjDesc - The object descriptor for this op + * PARAMETERS: ObjDesc - The object descriptor for this op * * RETURN: Status * diff --git a/sys/contrib/dev/acpica/exutils.c b/sys/contrib/dev/acpica/exutils.c index 3f0a365..f22f959 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: 112 $ + * $Revision: 1.118 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -141,22 +141,31 @@ #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exutils") +/* Local prototypes */ -#ifndef ACPI_NO_METHOD_EXECUTION +static UINT32 +AcpiExDigitsNeeded ( + ACPI_INTEGER Value, + UINT32 Base); + +#ifndef ACPI_NO_METHOD_EXECUTION /******************************************************************************* * * FUNCTION: AcpiExEnterInterpreter * * PARAMETERS: None * + * RETURN: Status + * * DESCRIPTION: Enter the interpreter execution region. Failure to enter * the interpreter region is a fatal system error * ******************************************************************************/ ACPI_STATUS -AcpiExEnterInterpreter (void) +AcpiExEnterInterpreter ( + void) { ACPI_STATUS Status; @@ -179,6 +188,8 @@ AcpiExEnterInterpreter (void) * * PARAMETERS: None * + * RETURN: None + * * DESCRIPTION: Exit the interpreter execution region * * Cases where the interpreter is unlocked: @@ -194,7 +205,8 @@ AcpiExEnterInterpreter (void) ******************************************************************************/ void -AcpiExExitInterpreter (void) +AcpiExExitInterpreter ( + void) { ACPI_STATUS Status; @@ -293,12 +305,13 @@ AcpiExAcquireGlobalLock ( } else { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not acquire Global Lock, %s\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not acquire Global Lock, %s\n", AcpiFormatException (Status))); } } - return_VALUE (Locked); + return_UINT8 (Locked); } @@ -309,7 +322,7 @@ AcpiExAcquireGlobalLock ( * PARAMETERS: LockedByMe - Return value from corresponding call to * AcquireGlobalLock. * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Release the global lock if it is locked. * @@ -352,11 +365,14 @@ AcpiExReleaseGlobalLock ( * PARAMETERS: Value - Value to be represented * Base - Base of representation * - * RETURN: the number of digits needed to represent Value in Base + * RETURN: The number of digits. + * + * DESCRIPTION: Calculate the number of digits needed to represent the Value + * in the given Base (Radix) * ******************************************************************************/ -UINT32 +static UINT32 AcpiExDigitsNeeded ( ACPI_INTEGER Value, UINT32 Base) @@ -372,7 +388,7 @@ AcpiExDigitsNeeded ( if (Value == 0) { - return_VALUE (1); + return_UINT32 (1); } CurrentValue = Value; @@ -386,7 +402,7 @@ AcpiExDigitsNeeded ( NumDigits++; } - return_VALUE (NumDigits); + return_UINT32 (NumDigits); } @@ -397,6 +413,8 @@ AcpiExDigitsNeeded ( * PARAMETERS: NumericId - EISA ID to be converted * OutString - Where to put the converted string (8 bytes) * + * RETURN: None + * * DESCRIPTION: Convert a numeric EISA ID to string representation * ******************************************************************************/ @@ -434,7 +452,10 @@ AcpiExEisaIdToString ( * PARAMETERS: Value - Value to be converted * OutString - Where to put the converted string (8 bytes) * - * RETURN: Convert a number to string representation + * RETURN: None, string + * + * DESCRIPTION: Convert a number to string representation. Assumes string + * buffer is large enough to hold the string. * ******************************************************************************/ diff --git a/sys/contrib/dev/acpica/hwacpi.c b/sys/contrib/dev/acpica/hwacpi.c index b16292c..940a045 100644 --- a/sys/contrib/dev/acpica/hwacpi.c +++ b/sys/contrib/dev/acpica/hwacpi.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface - * $Revision: 66 $ + * $Revision: 1.70 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -132,7 +132,8 @@ * * RETURN: Status * - * DESCRIPTION: Initialize and validate various ACPI registers + * DESCRIPTION: Initialize and validate the various ACPI registers defined in + * the FADT. * ******************************************************************************/ @@ -150,7 +151,7 @@ AcpiHwInitialize ( if (!AcpiGbl_FADT) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "A FADT is not loaded\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No FADT is present\n")); return_ACPI_STATUS (AE_NO_ACPI_TABLES); } @@ -209,7 +210,8 @@ AcpiHwSetMode ( */ if (!AcpiGbl_FADT->AcpiEnable && !AcpiGbl_FADT->AcpiDisable) { - ACPI_REPORT_ERROR (("No ACPI mode transition supported in this system (enable/disable both zero)\n")); + ACPI_REPORT_ERROR (( + "No ACPI mode transition supported in this system (enable/disable both zero)\n")); return_ACPI_STATUS (AE_OK); } @@ -242,7 +244,8 @@ AcpiHwSetMode ( if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("Could not write mode change, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Could not write mode change, %s\n", + AcpiFormatException (Status))); return_ACPI_STATUS (Status); } @@ -255,7 +258,8 @@ AcpiHwSetMode ( { if (AcpiHwGetMode() == Mode) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", Mode)); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", + Mode)); return_ACPI_STATUS (AE_OK); } AcpiOsStall(1000); @@ -267,7 +271,7 @@ AcpiHwSetMode ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiHwGetMode * @@ -281,7 +285,8 @@ AcpiHwSetMode ( ******************************************************************************/ UINT32 -AcpiHwGetMode (void) +AcpiHwGetMode ( + void) { ACPI_STATUS Status; UINT32 Value; @@ -296,21 +301,21 @@ AcpiHwGetMode (void) */ if (!AcpiGbl_FADT->SmiCmd) { - return_VALUE (ACPI_SYS_MODE_ACPI); + return_UINT32 (ACPI_SYS_MODE_ACPI); } Status = AcpiGetRegister (ACPI_BITREG_SCI_ENABLE, &Value, ACPI_MTX_LOCK); if (ACPI_FAILURE (Status)) { - return_VALUE (ACPI_SYS_MODE_LEGACY); + return_UINT32 (ACPI_SYS_MODE_LEGACY); } if (Value) { - return_VALUE (ACPI_SYS_MODE_ACPI); + return_UINT32 (ACPI_SYS_MODE_ACPI); } else { - return_VALUE (ACPI_SYS_MODE_LEGACY); + return_UINT32 (ACPI_SYS_MODE_LEGACY); } } diff --git a/sys/contrib/dev/acpica/hwgpe.c b/sys/contrib/dev/acpica/hwgpe.c index 55f6d9a..591c524 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: 65 $ + * $Revision: 1.71 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -121,6 +121,13 @@ #define _COMPONENT ACPI_HARDWARE ACPI_MODULE_NAME ("hwgpe") +/* Local prototypes */ + +static ACPI_STATUS +AcpiHwEnableWakeupGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock); + /****************************************************************************** * @@ -284,7 +291,7 @@ UnlockAndExit: * * RETURN: Status * - * DESCRIPTION: Disable all GPEs within a GPE block + * DESCRIPTION: Disable all GPEs within a single GPE block * ******************************************************************************/ @@ -324,7 +331,7 @@ AcpiHwDisableGpeBlock ( * * RETURN: Status * - * DESCRIPTION: Clear status bits for all GPEs within a GPE block + * DESCRIPTION: Clear status bits for all GPEs within a single GPE block * ******************************************************************************/ @@ -364,8 +371,8 @@ AcpiHwClearGpeBlock ( * * RETURN: Status * - * DESCRIPTION: Enable all "runtime" GPEs within a GPE block. (Includes - * combination wake/run GPEs.) + * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes + * combination wake/run GPEs. * ******************************************************************************/ @@ -412,12 +419,12 @@ AcpiHwEnableRuntimeGpeBlock ( * * RETURN: Status * - * DESCRIPTION: Enable all "wake" GPEs within a GPE block. (Includes - * combination wake/run GPEs.) + * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes + * combination wake/run GPEs. * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiHwEnableWakeupGpeBlock ( ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock) @@ -437,7 +444,8 @@ AcpiHwEnableWakeupGpeBlock ( /* Enable all "wake" GPEs in this register */ - Status = AcpiHwLowLevelWrite (8, GpeBlock->RegisterInfo[i].EnableForWake, + Status = AcpiHwLowLevelWrite (8, + GpeBlock->RegisterInfo[i].EnableForWake, &GpeBlock->RegisterInfo[i].EnableAddress); if (ACPI_FAILURE (Status)) { @@ -453,17 +461,17 @@ AcpiHwEnableWakeupGpeBlock ( * * FUNCTION: AcpiHwDisableAllGpes * - * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR + * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: Disable and clear all GPEs + * DESCRIPTION: Disable and clear all GPEs in all GPE blocks * ******************************************************************************/ ACPI_STATUS AcpiHwDisableAllGpes ( - UINT32 Flags) + void) { ACPI_STATUS Status; @@ -471,8 +479,8 @@ AcpiHwDisableAllGpes ( ACPI_FUNCTION_TRACE ("HwDisableAllGpes"); - Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, Flags); - Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, Flags); + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock); + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock); return_ACPI_STATUS (Status); } @@ -481,17 +489,17 @@ AcpiHwDisableAllGpes ( * * FUNCTION: AcpiHwEnableAllRuntimeGpes * - * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR + * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: Enable all GPEs of the given type + * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks * ******************************************************************************/ ACPI_STATUS AcpiHwEnableAllRuntimeGpes ( - UINT32 Flags) + void) { ACPI_STATUS Status; @@ -499,7 +507,7 @@ AcpiHwEnableAllRuntimeGpes ( ACPI_FUNCTION_TRACE ("HwEnableAllRuntimeGpes"); - Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, Flags); + Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock); return_ACPI_STATUS (Status); } @@ -508,17 +516,17 @@ AcpiHwEnableAllRuntimeGpes ( * * FUNCTION: AcpiHwEnableAllWakeupGpes * - * PARAMETERS: Flags - ACPI_NOT_ISR or ACPI_ISR + * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: Enable all GPEs of the given type + * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks * ******************************************************************************/ ACPI_STATUS AcpiHwEnableAllWakeupGpes ( - UINT32 Flags) + void) { ACPI_STATUS Status; @@ -526,7 +534,7 @@ AcpiHwEnableAllWakeupGpes ( ACPI_FUNCTION_TRACE ("HwEnableAllWakeupGpes"); - Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, Flags); + Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/hwregs.c b/sys/contrib/dev/acpica/hwregs.c index e038243..8cb5fc3 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: 162 $ + * $Revision: 1.172 $ * ******************************************************************************/ @@ -11,7 +11,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -162,8 +162,9 @@ AcpiHwClearAcpiStatus ( } } - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, - ACPI_BITMASK_ALL_FIXED_STATUS); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_STATUS, + ACPI_BITMASK_ALL_FIXED_STATUS); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -183,7 +184,7 @@ AcpiHwClearAcpiStatus ( /* Clear the GPE Bits in all GPE registers in all GPE blocks */ - Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, ACPI_ISR); + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock); UnlockAndExit: if (Flags & ACPI_MTX_LOCK) @@ -217,30 +218,32 @@ AcpiGetSleepTypeData ( { ACPI_STATUS Status = AE_OK; ACPI_PARAMETER_INFO Info; + char *SleepStateName; ACPI_FUNCTION_TRACE ("AcpiGetSleepTypeData"); - /* - * Validate parameters - */ + /* Validate parameters */ + if ((SleepState > ACPI_S_STATES_MAX) || !SleepTypeA || !SleepTypeB) { return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * Evaluate the namespace object containing the values for this state - */ + /* Evaluate the namespace object containing the values for this state */ + Info.Parameters = NULL; - Status = AcpiNsEvaluateByName ((char *) AcpiGbl_SleepStateNames[SleepState], - &Info); + Info.ReturnObject = NULL; + SleepStateName = (char *) AcpiGbl_SleepStateNames[SleepState]; + + Status = AcpiNsEvaluateByName (SleepStateName, &Info); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s while evaluating SleepState [%s]\n", - AcpiFormatException (Status), AcpiGbl_SleepStateNames[SleepState])); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "%s while evaluating SleepState [%s]\n", + AcpiFormatException (Status), SleepStateName)); return_ACPI_STATUS (Status); } @@ -249,7 +252,8 @@ AcpiGetSleepTypeData ( if (!Info.ReturnObject) { - ACPI_REPORT_ERROR (("Missing Sleep State object\n")); + ACPI_REPORT_ERROR (("No Sleep State object returned from [%s]\n", + SleepStateName)); Status = AE_NOT_EXIST; } @@ -257,42 +261,53 @@ AcpiGetSleepTypeData ( else if (ACPI_GET_OBJECT_TYPE (Info.ReturnObject) != ACPI_TYPE_PACKAGE) { - ACPI_REPORT_ERROR (("Sleep State object not a Package\n")); + ACPI_REPORT_ERROR (("Sleep State return object is not a Package\n")); Status = AE_AML_OPERAND_TYPE; } - /* The package must have at least two elements */ - + /* + * The package must have at least two elements. NOTE (March 2005): This + * goes against the current ACPI spec which defines this object as a + * package with one encoded DWORD element. However, existing practice + * by BIOS vendors seems to be to have 2 or more elements, at least + * one per sleep type (A/B). + */ else if (Info.ReturnObject->Package.Count < 2) { - ACPI_REPORT_ERROR (("Sleep State package does not have at least two elements\n")); + ACPI_REPORT_ERROR (( + "Sleep State return package does not have at least two elements\n")); Status = AE_AML_NO_OPERAND; } /* The first two elements must both be of type Integer */ - else if ((ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[0]) != ACPI_TYPE_INTEGER) || - (ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[1]) != ACPI_TYPE_INTEGER)) + else if ((ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[0]) + != ACPI_TYPE_INTEGER) || + (ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[1]) + != ACPI_TYPE_INTEGER)) { - ACPI_REPORT_ERROR (("Sleep State package elements are not both Integers (%s, %s)\n", + ACPI_REPORT_ERROR (( + "Sleep State return package elements are not both Integers (%s, %s)\n", AcpiUtGetObjectTypeName (Info.ReturnObject->Package.Elements[0]), AcpiUtGetObjectTypeName (Info.ReturnObject->Package.Elements[1]))); Status = AE_AML_OPERAND_TYPE; } else { - /* - * Valid _Sx_ package size, type, and value - */ - *SleepTypeA = (UINT8) (Info.ReturnObject->Package.Elements[0])->Integer.Value; - *SleepTypeB = (UINT8) (Info.ReturnObject->Package.Elements[1])->Integer.Value; + /* Valid _Sx_ package size, type, and value */ + + *SleepTypeA = (UINT8) + (Info.ReturnObject->Package.Elements[0])->Integer.Value; + *SleepTypeB = (UINT8) + (Info.ReturnObject->Package.Elements[1])->Integer.Value; } if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "While evaluating SleepState [%s], bad Sleep object %p type %s\n", - AcpiGbl_SleepStateNames[SleepState], Info.ReturnObject, + "%s While evaluating SleepState [%s], bad Sleep object %p type %s\n", + AcpiFormatException (Status), + SleepStateName, Info.ReturnObject, AcpiUtGetObjectTypeName (Info.ReturnObject))); } @@ -307,9 +322,9 @@ AcpiGetSleepTypeData ( * * PARAMETERS: RegisterId - Index of ACPI Register to access * - * RETURN: The bit mask to be used when accessing the register + * RETURN: The bitmask to be used when accessing the register * - * DESCRIPTION: Map RegisterId into a register bit mask. + * DESCRIPTION: Map RegisterId into a register bitmask. * ******************************************************************************/ @@ -453,7 +468,7 @@ AcpiSetRegister ( /* Always do a register read first so we can insert the new bits */ Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, - BitRegInfo->ParentRegister, &RegisterValue); + BitRegInfo->ParentRegister, &RegisterValue); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; @@ -493,7 +508,7 @@ AcpiSetRegister ( BitRegInfo->AccessBitMask, Value); Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1_ENABLE, (UINT16) RegisterValue); + ACPI_REGISTER_PM1_ENABLE, (UINT16) RegisterValue); break; @@ -510,7 +525,7 @@ AcpiSetRegister ( BitRegInfo->AccessBitMask, Value); Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM1_CONTROL, (UINT16) RegisterValue); + ACPI_REGISTER_PM1_CONTROL, (UINT16) RegisterValue); break; @@ -525,17 +540,19 @@ AcpiSetRegister ( ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n", RegisterValue, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)))); + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS ( + AcpiGbl_FADT->XPm2CntBlk.Address)))); ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, BitRegInfo->AccessBitMask, Value); ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n", RegisterValue, - ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)))); + ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS ( + AcpiGbl_FADT->XPm2CntBlk.Address)))); Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, - ACPI_REGISTER_PM2_CONTROL, (UINT8) (RegisterValue)); + ACPI_REGISTER_PM2_CONTROL, (UINT8) (RegisterValue)); break; @@ -553,7 +570,9 @@ UnlockAndExit: /* Normalize the value that was read */ - ACPI_DEBUG_EXEC (RegisterValue = ((RegisterValue & BitRegInfo->AccessBitMask) >> BitRegInfo->BitPosition)); + ACPI_DEBUG_EXEC (RegisterValue = + ((RegisterValue & BitRegInfo->AccessBitMask) >> + BitRegInfo->BitPosition)); ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n", Value, RegisterValue, BitRegInfo->ParentRegister)); @@ -567,7 +586,7 @@ UnlockAndExit: * * PARAMETERS: UseLock - Mutex hw access * RegisterId - RegisterID + Offset - * ReturnValue - Value that was read from the register + * ReturnValue - Where the register value is returned * * RETURN: Status and the value read. * @@ -661,7 +680,8 @@ AcpiHwRegisterRead ( break; default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", RegisterId)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", + RegisterId)); Status = AE_BAD_PARAMETER; break; } @@ -879,10 +899,11 @@ AcpiHwLowLevelRead ( return (AE_BAD_PARAMETER); } - 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 (Address)), - AcpiUtGetRegionName (Reg->AddressSpaceId))); + 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 (Address)), + AcpiUtGetRegionName (Reg->AddressSpaceId))); return (Status); } @@ -960,10 +981,11 @@ AcpiHwLowLevelWrite ( return (AE_BAD_PARAMETER); } - 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 (Address)), - AcpiUtGetRegionName (Reg->AddressSpaceId))); + 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 (Address)), + AcpiUtGetRegionName (Reg->AddressSpaceId))); return (Status); } diff --git a/sys/contrib/dev/acpica/hwsleep.c b/sys/contrib/dev/acpica/hwsleep.c index f5adf6b..42a1fdf 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: 70 $ + * $Revision: 1.77 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -121,20 +121,7 @@ ACPI_MODULE_NAME ("hwsleep") -#define METHOD_NAME__BFS "\\_BFS" -#define METHOD_NAME__GTS "\\_GTS" -#define METHOD_NAME__PTS "\\_PTS" -#define METHOD_NAME__SST "\\_SI._SST" -#define METHOD_NAME__WAK "\\_WAK" - -#define ACPI_SST_INDICATOR_OFF 0 -#define ACPI_SST_WORKING 1 -#define ACPI_SST_WAKING 2 -#define ACPI_SST_SLEEPING 3 -#define ACPI_SST_SLEEP_CONTEXT 4 - - -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiSetFirmwareWakingVector * @@ -143,7 +130,7 @@ * * RETURN: Status * - * DESCRIPTION: Access function for dFirmwareWakingVector field in FACS + * DESCRIPTION: Access function for the FirmwareWakingVector field in FACS * ******************************************************************************/ @@ -172,17 +159,17 @@ AcpiSetFirmwareWakingVector ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiGetFirmwareWakingVector * - * PARAMETERS: *PhysicalAddress - Output buffer where contents of + * PARAMETERS: *PhysicalAddress - Where the contents of * the FirmwareWakingVector field of - * the FACS will be stored. + * the FACS will be returned. * - * RETURN: Status + * RETURN: Status, vector * - * DESCRIPTION: Access function for FirmwareWakingVector field in FACS + * DESCRIPTION: Access function for the FirmwareWakingVector field in FACS * ******************************************************************************/ @@ -216,7 +203,7 @@ AcpiGetFirmwareWakingVector ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiEnterSleepStatePrep * @@ -294,7 +281,7 @@ AcpiEnterSleepStatePrep ( break; default: - Arg.Integer.Value = ACPI_SST_INDICATOR_OFF; /* Default is indicator off */ + Arg.Integer.Value = ACPI_SST_INDICATOR_OFF; /* Default is off */ break; } @@ -303,14 +290,15 @@ AcpiEnterSleepStatePrep ( Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _SST failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _SST failed, %s\n", + AcpiFormatException (Status))); } return_ACPI_STATUS (AE_OK); } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiEnterSleepState * @@ -369,7 +357,8 @@ AcpiEnterSleepState ( { /* Disable BM arbitration */ - Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_DO_NOT_LOCK); + Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, + 1, ACPI_MTX_DO_NOT_LOCK); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -380,14 +369,14 @@ AcpiEnterSleepState ( * 1) Disable/Clear all GPEs * 2) Enable all wakeup GPEs */ - Status = AcpiHwDisableAllGpes (ACPI_ISR); + Status = AcpiHwDisableAllGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } AcpiGbl_SystemAwakeAndRunning = FALSE; - Status = AcpiHwEnableAllWakeupGpes (ACPI_ISR); + Status = AcpiHwEnableAllWakeupGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -395,16 +384,19 @@ AcpiEnterSleepState ( /* Get current value of PM1A control */ - Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL, &PM1AControl); + Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_CONTROL, &PM1AControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Entering sleep state [S%d]\n", SleepState)); + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Entering sleep state [S%d]\n", SleepState)); /* Clear SLP_EN and SLP_TYP fields */ - PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask | SleepEnableRegInfo->AccessBitMask); + PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask | + SleepEnableRegInfo->AccessBitMask); PM1BControl = PM1AControl; /* Insert SLP_TYP bits */ @@ -419,13 +411,15 @@ AcpiEnterSleepState ( /* Write #1: fill in SLP_TYP data */ - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1A_CONTROL, PM1AControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1B_CONTROL, PM1BControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -440,13 +434,15 @@ AcpiEnterSleepState ( ACPI_FLUSH_CPU_CACHE (); - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1A_CONTROL, PM1AControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl); + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1B_CONTROL, PM1BControl); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -455,10 +451,11 @@ AcpiEnterSleepState ( if (SleepState > ACPI_STATE_S3) { /* - * We wanted to sleep > S3, but it didn't happen (by virtue of the fact that - * we are still executing!) + * We wanted to sleep > S3, but it didn't happen (by virtue of the + * fact that we are still executing!) * - * Wait ten seconds, then try again. This is to get S4/S5 to work on all machines. + * Wait ten seconds, then try again. This is to get S4/S5 to work on + * all machines. * * We wait so long to allow chipsets that poll this reg very slowly to * still read the right value. Ideally, this block would go @@ -466,7 +463,8 @@ AcpiEnterSleepState ( */ AcpiOsStall (10000000); - Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL, + Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, + ACPI_REGISTER_PM1_CONTROL, SleepEnableRegInfo->AccessBitMask); if (ACPI_FAILURE (Status)) { @@ -478,7 +476,8 @@ AcpiEnterSleepState ( do { - Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, ACPI_MTX_DO_NOT_LOCK); + Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, + ACPI_MTX_DO_NOT_LOCK); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -492,7 +491,7 @@ AcpiEnterSleepState ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiEnterSleepStateS4bios * @@ -532,14 +531,14 @@ AcpiEnterSleepStateS4bios ( * 1) Disable/Clear all GPEs * 2) Enable all wakeup GPEs */ - Status = AcpiHwDisableAllGpes (ACPI_ISR); + Status = AcpiHwDisableAllGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } AcpiGbl_SystemAwakeAndRunning = FALSE; - Status = AcpiHwEnableAllWakeupGpes (ACPI_ISR); + Status = AcpiHwEnableAllWakeupGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -547,11 +546,13 @@ AcpiEnterSleepStateS4bios ( ACPI_FLUSH_CPU_CACHE (); - Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, (UINT32) AcpiGbl_FADT->S4BiosReq, 8); + Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, + (UINT32) AcpiGbl_FADT->S4BiosReq, 8); do { AcpiOsStall(1000); - Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, ACPI_MTX_DO_NOT_LOCK); + Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, + ACPI_MTX_DO_NOT_LOCK); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -562,7 +563,7 @@ AcpiEnterSleepStateS4bios ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiLeaveSleepState * @@ -645,20 +646,23 @@ AcpiLeaveSleepState ( Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _SST failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _SST failed, %s\n", + AcpiFormatException (Status))); } Arg.Integer.Value = SleepState; Status = AcpiEvaluateObject (NULL, METHOD_NAME__BFS, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", + AcpiFormatException (Status))); } Status = AcpiEvaluateObject (NULL, METHOD_NAME__WAK, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", + AcpiFormatException (Status))); } /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ @@ -667,14 +671,14 @@ AcpiLeaveSleepState ( * 1) Disable/Clear all GPEs * 2) Enable all runtime GPEs */ - Status = AcpiHwDisableAllGpes (ACPI_NOT_ISR); + Status = AcpiHwDisableAllGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } AcpiGbl_SystemAwakeAndRunning = TRUE; - Status = AcpiHwEnableAllRuntimeGpes (ACPI_NOT_ISR); + Status = AcpiHwEnableAllRuntimeGpes (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -682,9 +686,12 @@ AcpiLeaveSleepState ( /* Enable power button */ - (void) AcpiSetRegister(AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, + (void) AcpiSetRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, 1, ACPI_MTX_DO_NOT_LOCK); - (void) AcpiSetRegister(AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, + + (void) AcpiSetRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, 1, ACPI_MTX_DO_NOT_LOCK); /* Enable BM arbitration */ @@ -699,7 +706,8 @@ AcpiLeaveSleepState ( Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) { - ACPI_REPORT_ERROR (("Method _SST failed, %s\n", AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Method _SST failed, %s\n", + AcpiFormatException (Status))); } return_ACPI_STATUS (Status); diff --git a/sys/contrib/dev/acpica/hwtimer.c b/sys/contrib/dev/acpica/hwtimer.c index 315bddb..58f5a79 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: 28 $ + * $Revision: 1.30 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -164,7 +164,7 @@ AcpiGetTimerResolution ( * * PARAMETERS: Ticks - Where the timer value is returned * - * RETURN: Status and current ticks + * RETURN: Status and current timer value (ticks) * * DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks). * diff --git a/sys/contrib/dev/acpica/nsaccess.c b/sys/contrib/dev/acpica/nsaccess.c index 37267a1..84ec3c4 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: 184 $ + * $Revision: 1.192 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -141,7 +141,8 @@ ******************************************************************************/ ACPI_STATUS -AcpiNsRootInitialize (void) +AcpiNsRootInitialize ( + void) { ACPI_STATUS Status; const ACPI_PREDEFINED_NAMES *InitVal = NULL; @@ -239,29 +240,28 @@ AcpiNsRootInitialize (void) switch (InitVal->Type) { case ACPI_TYPE_METHOD: - ObjDesc->Method.ParamCount = (UINT8) ACPI_STRTOUL - (Val, NULL, 10); + ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val); ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; -#if defined (_ACPI_ASL_COMPILER) || defined (_ACPI_DUMP_APP) +#if defined (ACPI_ASL_COMPILER) - /* - * iASL Compiler cheats by putting parameter count - * in the OwnerID - */ - NewNode->OwnerId = ObjDesc->Method.ParamCount; + /* Save the parameter count for the iASL compiler */ + + NewNode->Value = ObjDesc->Method.ParamCount; #else /* Mark this as a very SPECIAL method */ ObjDesc->Method.MethodFlags = AML_METHOD_INTERNAL_ONLY; + +#ifndef ACPI_DUMP_APP ObjDesc->Method.Implementation = AcpiUtOsiImplementation; #endif +#endif break; case ACPI_TYPE_INTEGER: - ObjDesc->Integer.Value = - (ACPI_INTEGER) ACPI_STRTOUL (Val, NULL, 10); + ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val); break; @@ -279,8 +279,7 @@ AcpiNsRootInitialize (void) case ACPI_TYPE_MUTEX: ObjDesc->Mutex.Node = NewNode; - ObjDesc->Mutex.SyncLevel = (UINT8) ACPI_STRTOUL - (Val, NULL, 10); + ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1); if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0) { @@ -357,7 +356,7 @@ UnlockAndExit: * * FUNCTION: AcpiNsLookup * - * PARAMETERS: PrefixNode - Search scope if name is not fully qualified + * PARAMETERS: ScopeInfo - Current scope info block * Pathname - Search pathname, in internal format * (as represented in the AML stream) * Type - Type associated with name @@ -602,7 +601,7 @@ AcpiNsLookup ( Path++; ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Multi Pathname (%d Segments, Flags=%X) \n", + "Multi Pathname (%d Segments, Flags=%X)\n", NumSegments, Flags)); break; diff --git a/sys/contrib/dev/acpica/nsalloc.c b/sys/contrib/dev/acpica/nsalloc.c index b87824e..0173809 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: 88 $ + * $Revision: 1.97 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,14 +124,20 @@ #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsalloc") +/* Local prototypes */ + +static void +AcpiNsRemoveReference ( + ACPI_NAMESPACE_NODE *Node); + /******************************************************************************* * * FUNCTION: AcpiNsCreateNode * - * PARAMETERS: AcpiName - Name of the new node + * PARAMETERS: Name - Name of the new node (4 char ACPI name) * - * RETURN: None + * RETURN: New namespace node (Null on failure) * * DESCRIPTION: Create a namespace node * @@ -153,7 +159,7 @@ AcpiNsCreateNode ( return_PTR (NULL); } - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].TotalAllocated++); + ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalAllocated++); Node->Name.Integer = Name; Node->ReferenceCount = 1; @@ -227,8 +233,7 @@ AcpiNsDeleteNode ( } } - - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].TotalFreed++); + ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); /* * Detach an object if there is one then delete the node @@ -239,60 +244,6 @@ AcpiNsDeleteNode ( } -#ifdef ACPI_ALPHABETIC_NAMESPACE -/******************************************************************************* - * - * FUNCTION: AcpiNsCompareNames - * - * PARAMETERS: Name1 - First name to compare - * Name2 - Second name to compare - * - * RETURN: value from strncmp - * - * DESCRIPTION: Compare two ACPI names. Names that are prefixed with an - * underscore are forced to be alphabetically first. - * - ******************************************************************************/ - -int -AcpiNsCompareNames ( - char *Name1, - char *Name2) -{ - char ReversedName1[ACPI_NAME_SIZE]; - char ReversedName2[ACPI_NAME_SIZE]; - UINT32 i; - UINT32 j; - - - /* - * Replace all instances of "underscore" with a value that is smaller so - * that all names that are prefixed with underscore(s) are alphabetically - * first. - * - * Reverse the name bytewise so we can just do a 32-bit compare instead - * of a strncmp. - */ - for (i = 0, j= (ACPI_NAME_SIZE - 1); i < ACPI_NAME_SIZE; i++, j--) - { - ReversedName1[j] = Name1[i]; - if (Name1[i] == '_') - { - ReversedName1[j] = '*'; - } - - ReversedName2[j] = Name2[i]; - if (Name2[i] == '_') - { - ReversedName2[j] = '*'; - } - } - - return (*(int *) ReversedName1 - *(int *) ReversedName2); -} -#endif - - /******************************************************************************* * * FUNCTION: AcpiNsInstallNode @@ -307,10 +258,9 @@ AcpiNsCompareNames ( * DESCRIPTION: Initialize a new namespace node and install it amongst * its peers. * - * Note: Current namespace lookup is linear search. However, the - * nodes are linked in alphabetical order to 1) put all reserved - * names (start with underscore) first, and to 2) make a readable - * namespace dump. + * Note: Current namespace lookup is linear search. This appears + * to be sufficient as namespace searches consume only a small + * fraction of the execution time of the ACPI subsystem. * ******************************************************************************/ @@ -321,12 +271,8 @@ AcpiNsInstallNode ( ACPI_NAMESPACE_NODE *Node, /* New Child*/ ACPI_OBJECT_TYPE Type) { - UINT16 OwnerId = 0; + ACPI_OWNER_ID OwnerId = 0; ACPI_NAMESPACE_NODE *ChildNode; -#ifdef ACPI_ALPHABETIC_NAMESPACE - - ACPI_NAMESPACE_NODE *PreviousChildNode; -#endif ACPI_FUNCTION_TRACE ("NsInstallNode"); @@ -353,61 +299,6 @@ AcpiNsInstallNode ( } else { -#ifdef ACPI_ALPHABETIC_NAMESPACE - /* - * Walk the list whilst searching for the correct - * alphabetic placement. - */ - PreviousChildNode = NULL; - while (AcpiNsCompareNames (AcpiUtGetNodeName (ChildNode), AcpiUtGetNodeName (Node)) < 0) - { - if (ChildNode->Flags & ANOBJ_END_OF_PEER_LIST) - { - /* Last peer; Clear end-of-list flag */ - - ChildNode->Flags &= ~ANOBJ_END_OF_PEER_LIST; - - /* This node is the new peer to the child node */ - - ChildNode->Peer = Node; - - /* This node is the new end-of-list */ - - Node->Flags |= ANOBJ_END_OF_PEER_LIST; - Node->Peer = ParentNode; - break; - } - - /* Get next peer */ - - PreviousChildNode = ChildNode; - ChildNode = ChildNode->Peer; - } - - /* Did the node get inserted at the end-of-list? */ - - if (!(Node->Flags & ANOBJ_END_OF_PEER_LIST)) - { - /* - * Loop above terminated without reaching the end-of-list. - * Insert the new node at the current location - */ - if (PreviousChildNode) - { - /* Insert node alphabetically */ - - Node->Peer = ChildNode; - PreviousChildNode->Peer = Node; - } - else - { - /* Insert node alphabetically at start of list */ - - Node->Peer = ChildNode; - ParentNode->Child = Node; - } - } -#else while (!(ChildNode->Flags & ANOBJ_END_OF_PEER_LIST)) { ChildNode = ChildNode->Peer; @@ -418,9 +309,8 @@ AcpiNsInstallNode ( /* Clear end-of-list flag */ ChildNode->Flags &= ~ANOBJ_END_OF_PEER_LIST; - Node->Flags |= ANOBJ_END_OF_PEER_LIST; + Node->Flags |= ANOBJ_END_OF_PEER_LIST; Node->Peer = ParentNode; -#endif } /* Init the new entry */ @@ -506,7 +396,7 @@ AcpiNsDeleteChildren ( /* Now we can free this child object */ - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].TotalFreed++); + ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", ChildNode, AcpiGbl_CurrentNodeCount)); @@ -530,7 +420,8 @@ AcpiNsDeleteChildren ( if (ChildNode->ReferenceCount != 1) { - ACPI_REPORT_WARNING (("Existing references (%d) on node being deleted (%p)\n", + ACPI_REPORT_WARNING (( + "Existing references (%d) on node being deleted (%p)\n", ChildNode->ReferenceCount, ChildNode)); } @@ -654,7 +545,7 @@ AcpiNsDeleteNamespaceSubtree ( * ******************************************************************************/ -void +static void AcpiNsRemoveReference ( ACPI_NAMESPACE_NODE *Node) { @@ -711,7 +602,7 @@ AcpiNsRemoveReference ( void AcpiNsDeleteNamespaceByOwner ( - UINT16 OwnerId) + ACPI_OWNER_ID OwnerId) { ACPI_NAMESPACE_NODE *ChildNode; ACPI_NAMESPACE_NODE *DeletionNode; @@ -722,6 +613,11 @@ AcpiNsDeleteNamespaceByOwner ( ACPI_FUNCTION_TRACE_U32 ("NsDeleteNamespaceByOwner", OwnerId); + if (OwnerId == 0) + { + return_VOID; + } + ParentNode = AcpiGbl_RootNode; ChildNode = NULL; DeletionNode = NULL; diff --git a/sys/contrib/dev/acpica/nsdump.c b/sys/contrib/dev/acpica/nsdump.c index b345b28..007c20a 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: 160 $ + * $Revision: 1.172 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,16 +125,32 @@ #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsdump") +/* Local prototypes */ -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +#ifdef ACPI_OBSOLETE_FUNCTIONS +void +AcpiNsDumpRootDevices ( + void); + +static ACPI_STATUS +AcpiNsDumpOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); +#endif + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /******************************************************************************* * * FUNCTION: AcpiNsPrintPathname * - * PARAMETERS: NumSegment - Number of ACPI name segments + * PARAMETERS: NumSegments - Number of ACPI name segments * Pathname - The compressed (internal) path * + * RETURN: None + * * DESCRIPTION: Print an object's full namespace pathname * ******************************************************************************/ @@ -144,6 +160,9 @@ AcpiNsPrintPathname ( UINT32 NumSegments, char *Pathname) { + ACPI_NATIVE_UINT i; + + ACPI_FUNCTION_NAME ("NsPrintPathname"); @@ -158,9 +177,14 @@ AcpiNsPrintPathname ( while (NumSegments) { - AcpiOsPrintf ("%4.4s", Pathname); - Pathname += ACPI_NAME_SIZE; + for (i = 0; i < 4; i++) + { + ACPI_IS_PRINT (Pathname[i]) ? + AcpiOsPrintf ("%c", Pathname[i]) : + AcpiOsPrintf ("?"); + } + Pathname += ACPI_NAME_SIZE; NumSegments--; if (NumSegments) { @@ -181,6 +205,8 @@ AcpiNsPrintPathname ( * Level - Desired debug level * Component - Caller's component ID * + * RETURN: None + * * DESCRIPTION: Print an object's full namespace pathname * Manages allocation/freeing of a pathname buffer * @@ -216,9 +242,12 @@ AcpiNsDumpPathname ( * * FUNCTION: AcpiNsDumpOneObject * - * PARAMETERS: Handle - Node to be dumped + * PARAMETERS: ObjHandle - Node to be dumped * Level - Nesting level of the handle * Context - Passed into WalkNamespace + * ReturnValue - Not used + * + * RETURN: Status * * DESCRIPTION: Dump a single Node * This procedure is a UserFunction called by AcpiNsWalkNamespace. @@ -263,41 +292,46 @@ AcpiNsDumpOneObject ( /* Check if the owner matches */ - if ((Info->OwnerId != ACPI_UINT32_MAX) && + if ((Info->OwnerId != ACPI_OWNER_ID_MAX) && (Info->OwnerId != ThisNode->OwnerId)) { return (AE_OK); } - /* Indent the object according to the level */ + if (!(Info->DisplayType & ACPI_DISPLAY_SHORT)) + { + /* Indent the object according to the level */ - AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " "); + AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " "); - /* Check the node type and name */ + /* Check the node type and name */ - if (Type > ACPI_TYPE_LOCAL_MAX) - { - ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", Type)); - } + if (Type > ACPI_TYPE_LOCAL_MAX) + { + ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", Type)); + } - if (!AcpiUtValidAcpiName (ThisNode->Name.Integer)) - { - ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", - ThisNode->Name.Integer)); + if (!AcpiUtValidAcpiName (ThisNode->Name.Integer)) + { + ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", + ThisNode->Name.Integer)); + } + + AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode)); } /* * Now we can print out the pertinent information */ - AcpiOsPrintf ("%4.4s %-12s %p ", - AcpiUtGetNodeName (ThisNode), AcpiUtGetTypeName (Type), ThisNode); + AcpiOsPrintf (" %-12s %p ", + AcpiUtGetTypeName (Type), ThisNode); DbgLevel = AcpiDbgLevel; AcpiDbgLevel = 0; ObjDesc = AcpiNsGetAttachedObject (ThisNode); AcpiDbgLevel = DbgLevel; - switch (Info->DisplayType) + switch (Info->DisplayType & ACPI_DISPLAY_MASK) { case ACPI_DISPLAY_SUMMARY: @@ -492,8 +526,7 @@ AcpiNsDumpOneObject ( return (AE_OK); } - AcpiOsPrintf ("(R%d)", - ObjDesc->Common.ReferenceCount); + AcpiOsPrintf ("(R%d)", ObjDesc->Common.ReferenceCount); switch (Type) { @@ -556,7 +589,7 @@ AcpiNsDumpOneObject ( while (ObjDesc) { ObjType = ACPI_TYPE_INVALID; - AcpiOsPrintf (" Attached Object %p: ", ObjDesc); + AcpiOsPrintf ("Attached Object %p: ", ObjDesc); /* Decode the type of attached object and dump the contents */ @@ -566,9 +599,9 @@ AcpiNsDumpOneObject ( AcpiOsPrintf ("(Ptr to Node)\n"); BytesToDump = sizeof (ACPI_NAMESPACE_NODE); + ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); break; - case ACPI_DESC_TYPE_OPERAND: ObjType = ACPI_GET_OBJECT_TYPE (ObjDesc); @@ -581,24 +614,19 @@ AcpiNsDumpOneObject ( } else { - AcpiOsPrintf ("(Ptr to ACPI Object type %s, %X)\n", - AcpiUtGetTypeName (ObjType), ObjType); + AcpiOsPrintf ("(Ptr to ACPI Object type %X [%s])\n", + ObjType, AcpiUtGetTypeName (ObjType)); BytesToDump = sizeof (ACPI_OPERAND_OBJECT); } - break; + ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); + break; default: - AcpiOsPrintf ( - "(String or Buffer ptr - not an object descriptor) [%s]\n", - AcpiUtGetDescriptorName (ObjDesc)); - BytesToDump = 16; break; } - ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); - /* If value is NOT an internal object, we are done */ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) @@ -611,13 +639,17 @@ AcpiNsDumpOneObject ( */ switch (ObjType) { + case ACPI_TYPE_BUFFER: case ACPI_TYPE_STRING: + /* + * NOTE: takes advantage of common fields between string/buffer + */ + BytesToDump = ObjDesc->String.Length; ObjDesc = (void *) ObjDesc->String.Pointer; - break; - - case ACPI_TYPE_BUFFER: - ObjDesc = (void *) ObjDesc->Buffer.Pointer; - break; + AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n", + ObjDesc, BytesToDump); + ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); + goto Cleanup; case ACPI_TYPE_BUFFER_FIELD: ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj; @@ -661,12 +693,15 @@ Cleanup: * FUNCTION: AcpiNsDumpObjects * * PARAMETERS: Type - Object type to be dumped + * DisplayType - 0 or ACPI_DISPLAY_SUMMARY * 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. * StartHandle - Where in namespace to start/end search * + * RETURN: None + * * DESCRIPTION: Dump typed objects within the loaded namespace. * Uses AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject. * @@ -677,7 +712,7 @@ AcpiNsDumpObjects ( ACPI_OBJECT_TYPE Type, UINT8 DisplayType, UINT32 MaxDepth, - UINT32 OwnerId, + ACPI_OWNER_ID OwnerId, ACPI_HANDLE StartHandle) { ACPI_WALK_INFO Info; @@ -698,6 +733,39 @@ AcpiNsDumpObjects ( /******************************************************************************* * + * FUNCTION: AcpiNsDumpEntry + * + * PARAMETERS: Handle - Node to be dumped + * DebugLevel - Output level + * + * RETURN: None + * + * DESCRIPTION: Dump a single Node + * + ******************************************************************************/ + +void +AcpiNsDumpEntry ( + ACPI_HANDLE Handle, + UINT32 DebugLevel) +{ + ACPI_WALK_INFO Info; + + + ACPI_FUNCTION_ENTRY (); + + + Info.DebugLevel = DebugLevel; + Info.OwnerId = ACPI_OWNER_ID_MAX; + Info.DisplayType = ACPI_DISPLAY_SUMMARY; + + (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL); +} + + +#ifdef ACPI_ASL_COMPILER +/******************************************************************************* + * * FUNCTION: AcpiNsDumpTables * * PARAMETERS: SearchBase - Root of subtree to be dumped, or @@ -705,6 +773,8 @@ AcpiNsDumpObjects ( * MaxDepth - Maximum depth of dump. Use INT_MAX * for an effectively unlimited depth. * + * RETURN: None + * * DESCRIPTION: Dump the name space, or a portion of it. * ******************************************************************************/ @@ -732,46 +802,16 @@ AcpiNsDumpTables ( if (ACPI_NS_ALL == SearchBase) { - /* entire namespace */ + /* Entire namespace */ SearchHandle = AcpiGbl_RootNode; ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n")); } AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth, - ACPI_UINT32_MAX, SearchHandle); + ACPI_OWNER_ID_MAX, SearchHandle); return_VOID; } - - -/******************************************************************************* - * - * FUNCTION: AcpiNsDumpEntry - * - * PARAMETERS: Handle - Node to be dumped - * DebugLevel - Output level - * - * DESCRIPTION: Dump a single Node - * - ******************************************************************************/ - -void -AcpiNsDumpEntry ( - ACPI_HANDLE Handle, - UINT32 DebugLevel) -{ - ACPI_WALK_INFO Info; - - - ACPI_FUNCTION_ENTRY (); - - - Info.DebugLevel = DebugLevel; - Info.OwnerId = ACPI_UINT32_MAX; - Info.DisplayType = ACPI_DISPLAY_SUMMARY; - - (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL); -} - +#endif #endif diff --git a/sys/contrib/dev/acpica/nsdumpdv.c b/sys/contrib/dev/acpica/nsdumpdv.c index 318d19e..b62b85d 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: 12 $ + * $Revision: 1.16 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -118,15 +118,18 @@ #define __NSDUMPDV_C__ #include <contrib/dev/acpica/acpi.h> -#include <contrib/dev/acpica/acnamesp.h> +/* TBD: This entire module is apparently obsolete and should be removed */ + #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsdumpdv") - +#ifdef ACPI_OBSOLETE_FUNCTIONS #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +#include <contrib/dev/acpica/acnamesp.h> + /******************************************************************************* * * FUNCTION: AcpiNsDumpOneDevice @@ -134,13 +137,16 @@ * PARAMETERS: Handle - Node to be dumped * Level - Nesting level of the handle * Context - Passed into WalkNamespace + * ReturnValue - Not used + * + * RETURN: Status * * DESCRIPTION: Dump a single Node that represents a device * This procedure is a UserFunction called by AcpiNsWalkNamespace. * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsDumpOneDevice ( ACPI_HANDLE ObjHandle, UINT32 Level, @@ -185,12 +191,15 @@ AcpiNsDumpOneDevice ( * * PARAMETERS: None * + * RETURN: None + * * DESCRIPTION: Dump all objects of type "device" * ******************************************************************************/ void -AcpiNsDumpRootDevices (void) +AcpiNsDumpRootDevices ( + void) { ACPI_HANDLE SysBusHandle; ACPI_STATUS Status; @@ -221,5 +230,6 @@ AcpiNsDumpRootDevices (void) } #endif +#endif diff --git a/sys/contrib/dev/acpica/nseval.c b/sys/contrib/dev/acpica/nseval.c index 09c13c0..e2ca559 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: 129 $ + * $Revision: 1.134 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -127,19 +127,33 @@ #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nseval") +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsExecuteControlMethod ( + ACPI_PARAMETER_INFO *Info); + +static ACPI_STATUS +AcpiNsGetObjectValue ( + ACPI_PARAMETER_INFO *Info); + /******************************************************************************* * * FUNCTION: AcpiNsEvaluateRelative * - * PARAMETERS: Pathname - Name of method to execute, If NULL, the - * handle is the object to execute - * Info - Method info block + * PARAMETERS: Pathname - Name of method to execute, If NULL, the + * handle is the object to execute + * Info - Method info block, contains: + * 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, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. * * RETURN: Status * - * DESCRIPTION: Find and execute the requested method using the handle as a - * scope + * DESCRIPTION: Evaluate the object or find and execute the requested method * * MUTEX: Locks Namespace * @@ -238,8 +252,8 @@ Cleanup1: * * FUNCTION: AcpiNsEvaluateByName * - * PARAMETERS: Pathname - Fully qualified pathname to the object - * Info - Contains: + * PARAMETERS: Pathname - Fully qualified pathname to the object + * Info - Method info block, contains: * 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, @@ -248,8 +262,8 @@ Cleanup1: * * RETURN: Status * - * DESCRIPTION: Find and execute the requested method passing the given - * parameters + * DESCRIPTION: Evaluate the object or rind and execute the requested method + * passing the given parameters * * MUTEX: Locks Namespace * @@ -326,17 +340,21 @@ Cleanup: * * FUNCTION: AcpiNsEvaluateByHandle * - * PARAMETERS: Handle - Method Node to execute - * Params - List of parameters to pass to the method, - * terminated by NULL. Params itself may be + * PARAMETERS: Info - Method info block, contains: + * Node - Method/Object Node to execute + * Parameters - List of parameters to pass to the method, + * terminated by NULL. Params itself may be * NULL if no parameters are being passed. - * ParamType - Type of Parameter list - * ReturnObject - Where to put method's return value (if - * any). If NULL, no value is returned. + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * ParameterType - Type of Parameter list + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. * * RETURN: Status * - * DESCRIPTION: Execute the requested method passing the given parameters + * DESCRIPTION: Evaluate object or execute the requested method passing the + * given parameters * * MUTEX: Locks Namespace * @@ -438,7 +456,17 @@ AcpiNsEvaluateByHandle ( * * FUNCTION: AcpiNsExecuteControlMethod * - * PARAMETERS: Info - Method info block (w/params) + * PARAMETERS: Info - Method info block, contains: + * Node - Method Node to execute + * ObjDesc - Method object + * Parameters - 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. + * ParameterType - Type of Parameter list + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. * * RETURN: Status * @@ -448,12 +476,11 @@ AcpiNsEvaluateByHandle ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsExecuteControlMethod ( ACPI_PARAMETER_INFO *Info) { ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_TRACE ("NsExecuteControlMethod"); @@ -461,8 +488,8 @@ AcpiNsExecuteControlMethod ( /* Verify that there is a method associated with this object */ - ObjDesc = AcpiNsGetAttachedObject (Info->Node); - if (!ObjDesc) + Info->ObjDesc = AcpiNsGetAttachedObject (Info->Node); + if (!Info->ObjDesc) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n")); @@ -474,7 +501,7 @@ AcpiNsExecuteControlMethod ( ACPI_LV_INFO, _COMPONENT); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Method at AML address %p Length %X\n", - ObjDesc->Method.AmlStart + 1, ObjDesc->Method.AmlLength - 1)); + Info->ObjDesc->Method.AmlStart + 1, Info->ObjDesc->Method.AmlLength - 1)); /* * Unlock the namespace before execution. This allows namespace access @@ -499,7 +526,7 @@ AcpiNsExecuteControlMethod ( return_ACPI_STATUS (Status); } - Status = AcpiPsxExecute (Info); + Status = AcpiPsExecuteMethod (Info); AcpiExExitInterpreter (); return_ACPI_STATUS (Status); @@ -510,7 +537,10 @@ AcpiNsExecuteControlMethod ( * * FUNCTION: AcpiNsGetObjectValue * - * PARAMETERS: Info - Method info block (w/params) + * PARAMETERS: Info - Method info block, contains: + * Node - Object's NS node + * ReturnObject - Where to put object value (if + * any). If NULL, no value is returned. * * RETURN: Status * @@ -520,7 +550,7 @@ AcpiNsExecuteControlMethod ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsGetObjectValue ( ACPI_PARAMETER_INFO *Info) { diff --git a/sys/contrib/dev/acpica/nsinit.c b/sys/contrib/dev/acpica/nsinit.c index 74381a1..70a4d27 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: 62 $ + * $Revision: 1.68 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,6 +125,22 @@ #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsinit") +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiNsInitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + /******************************************************************************* * @@ -269,7 +285,7 @@ AcpiNsInitializeDevices ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsInitOneObject ( ACPI_HANDLE ObjHandle, UINT32 Level, @@ -416,7 +432,7 @@ AcpiNsInitOneObject ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsInitOneDevice ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, @@ -462,7 +478,8 @@ AcpiNsInitOneDevice ( /* * Run _STA to determine if we can run _INI on the device. */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Pinfo.Node, "_STA")); + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, + Pinfo.Node, METHOD_NAME__STA)); Status = AcpiUtExecute_STA (Pinfo.Node, &Flags); if (ACPI_FAILURE (Status)) @@ -491,8 +508,9 @@ AcpiNsInitOneDevice ( /* * The device is present. Run _INI. */ - ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Pinfo.Node, "_INI")); - Status = AcpiNsEvaluateRelative ("_INI", &Pinfo); + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, + Pinfo.Node, METHOD_NAME__INI)); + Status = AcpiNsEvaluateRelative (METHOD_NAME__INI, &Pinfo); if (ACPI_FAILURE (Status)) { /* No _INI (AE_NOT_FOUND) means device requires no initialization */ @@ -515,7 +533,7 @@ AcpiNsInitOneDevice ( } else { - /* Delete any return object (Especially if ImplicitReturn is enabled) */ + /* Delete any return object (especially if ImplicitReturn is enabled) */ if (Pinfo.ReturnObject) { diff --git a/sys/contrib/dev/acpica/nsload.c b/sys/contrib/dev/acpica/nsload.c index a5cddda..ea99510 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: 69 $ + * $Revision: 1.73 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,9 +124,24 @@ #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsload") +/* Local prototypes */ -#ifndef ACPI_NO_METHOD_EXECUTION +static ACPI_STATUS +AcpiNsLoadTableByType ( + ACPI_TABLE_TYPE TableType); + +#ifdef ACPI_FUTURE_IMPLEMENTATION +ACPI_STATUS +AcpiNsUnloadNamespace ( + ACPI_HANDLE Handle); +static ACPI_STATUS +AcpiNsDeleteSubtree ( + ACPI_HANDLE StartHandle); +#endif + + +#ifndef ACPI_NO_METHOD_EXECUTION /******************************************************************************* * * FUNCTION: AcpiNsLoadTable @@ -238,7 +253,7 @@ AcpiNsLoadTable ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsLoadTableByType ( ACPI_TABLE_TYPE TableType) { @@ -264,7 +279,7 @@ AcpiNsLoadTableByType ( { case ACPI_TABLE_DSDT: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading DSDT\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace load: DSDT\n")); TableDesc = AcpiGbl_TableLists[ACPI_TABLE_DSDT].Next; @@ -286,18 +301,19 @@ AcpiNsLoadTableByType ( case ACPI_TABLE_SSDT: + case ACPI_TABLE_PSDT: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d SSDTs\n", - AcpiGbl_TableLists[ACPI_TABLE_SSDT].Count)); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace load: %d SSDT or PSDTs\n", + AcpiGbl_TableLists[TableType].Count)); /* - * Traverse list of SSDT tables + * Traverse list of SSDT or PSDT tables */ - TableDesc = AcpiGbl_TableLists[ACPI_TABLE_SSDT].Next; - for (i = 0; i < AcpiGbl_TableLists[ACPI_TABLE_SSDT].Count; i++) + TableDesc = AcpiGbl_TableLists[TableType].Next; + for (i = 0; i < AcpiGbl_TableLists[TableType].Count; i++) { /* - * Only attempt to load table if it is not + * Only attempt to load table into namespace if it is not * already loaded! */ if (!TableDesc->LoadedIntoNamespace) @@ -316,36 +332,6 @@ AcpiNsLoadTableByType ( break; - case ACPI_TABLE_PSDT: - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d PSDTs\n", - AcpiGbl_TableLists[ACPI_TABLE_PSDT].Count)); - - /* - * Traverse list of PSDT tables - */ - TableDesc = AcpiGbl_TableLists[ACPI_TABLE_PSDT].Next; - - for (i = 0; i < AcpiGbl_TableLists[ACPI_TABLE_PSDT].Count; i++) - { - /* Only attempt to load table if it is not already loaded! */ - - if (!TableDesc->LoadedIntoNamespace) - { - Status = AcpiNsLoadTable (TableDesc, AcpiGbl_RootNode); - if (ACPI_FAILURE (Status)) - { - break; - } - - TableDesc->LoadedIntoNamespace = TRUE; - } - - TableDesc = TableDesc->Next; - } - break; - - default: Status = AE_SUPPORT; break; @@ -412,6 +398,7 @@ AcpiNsLoadNamespace ( } +#ifdef ACPI_FUTURE_IMPLEMENTATION /******************************************************************************* * * FUNCTION: AcpiNsDeleteSubtree @@ -428,7 +415,7 @@ AcpiNsLoadNamespace ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiNsDeleteSubtree ( ACPI_HANDLE StartHandle) { @@ -549,6 +536,6 @@ AcpiNsUnloadNamespace ( return_ACPI_STATUS (Status); } - +#endif #endif diff --git a/sys/contrib/dev/acpica/nsnames.c b/sys/contrib/dev/acpica/nsnames.c index 76fc5fe..315257b 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: 86 $ + * $Revision: 1.91 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,6 +124,14 @@ #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsnames") +/* Local prototypes */ + +static void +AcpiNsBuildExternalPath ( + ACPI_NAMESPACE_NODE *Node, + ACPI_SIZE Size, + char *NameBuffer); + /******************************************************************************* * @@ -140,7 +148,7 @@ * ******************************************************************************/ -void +static void AcpiNsBuildExternalPath ( ACPI_NAMESPACE_NODE *Node, ACPI_SIZE Size, @@ -203,7 +211,7 @@ AcpiNsBuildExternalPath ( * * FUNCTION: AcpiNsGetExternalPathname * - * PARAMETERS: Node - NS node whose pathname is needed + * PARAMETERS: Node - Namespace node whose pathname is needed * * RETURN: Pointer to storage containing the fully qualified name of * the node, In external format (name segments separated by path @@ -339,7 +347,7 @@ AcpiNsHandleToPathname ( AcpiNsBuildExternalPath (Node, RequiredSize, Buffer->Pointer); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n", + 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/nsobject.c b/sys/contrib/dev/acpica/nsobject.c index 45db574..59b8cb0 100644 --- a/sys/contrib/dev/acpica/nsobject.c +++ b/sys/contrib/dev/acpica/nsobject.c @@ -2,7 +2,7 @@ * * Module Name: nsobject - Utilities for objects attached to namespace * table entries - * $Revision: 90 $ + * $Revision: 1.93 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -135,6 +135,8 @@ * Type - Type of object, or ACPI_TYPE_ANY if not * known * + * RETURN: Status + * * DESCRIPTION: Record the given object as the value associated with the * name whose ACPI_HANDLE is passed. If Object is NULL * and Type is ACPI_TYPE_ANY, set the name as having no value. @@ -174,7 +176,8 @@ AcpiNsAttachObject ( { /* Null object */ - ACPI_REPORT_ERROR (("NsAttachObject: Null object, but type not ACPI_TYPE_ANY\n")); + ACPI_REPORT_ERROR (( + "NsAttachObject: Null object, but type not ACPI_TYPE_ANY\n")); return_ACPI_STATUS (AE_BAD_PARAMETER); } @@ -191,7 +194,8 @@ AcpiNsAttachObject ( if (Node->Object == Object) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj %p already installed in NameObj %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Obj %p already installed in NameObj %p\n", Object, Node)); return_ACPI_STATUS (AE_OK); @@ -277,7 +281,7 @@ AcpiNsAttachObject ( * * FUNCTION: AcpiNsDetachObject * - * PARAMETERS: Node - An node whose object will be detached + * PARAMETERS: Node - A Namespace node whose object will be detached * * RETURN: None. * @@ -336,7 +340,7 @@ AcpiNsDetachObject ( * * FUNCTION: AcpiNsGetAttachedObject * - * PARAMETERS: Node - Parent Node to be examined + * PARAMETERS: Node - Namespace node * * RETURN: Current value of the object field from the Node whose * handle is passed @@ -374,7 +378,7 @@ AcpiNsGetAttachedObject ( * * FUNCTION: AcpiNsGetSecondaryObject * - * PARAMETERS: Node - Parent Node to be examined + * PARAMETERS: Node - Namespace node * * RETURN: Current value of the object field from the Node whose * handle is passed. diff --git a/sys/contrib/dev/acpica/nsparse.c b/sys/contrib/dev/acpica/nsparse.c index cecfa5d..d288632 100644 --- a/sys/contrib/dev/acpica/nsparse.c +++ b/sys/contrib/dev/acpica/nsparse.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: nsparse - namespace interface to AML parser - * $Revision: 6 $ + * $Revision: 1.10 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -141,7 +141,7 @@ ACPI_STATUS AcpiNsOneCompleteParse ( - UINT32 PassNumber, + UINT8 PassNumber, ACPI_TABLE_DESC *TableDesc) { ACPI_PARSE_OBJECT *ParseRoot; @@ -162,7 +162,7 @@ AcpiNsOneCompleteParse ( /* Create and initialize a new walk state */ - WalkState = AcpiDsCreateWalkState (TableDesc->TableId, + WalkState = AcpiDsCreateWalkState (TableDesc->OwnerId, NULL, NULL, NULL); if (!WalkState) { @@ -223,6 +223,7 @@ AcpiNsParseTable ( * to service the entire parse. The second pass of the parse then * performs another complete parse of the AML.. */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); Status = AcpiNsOneCompleteParse (1, TableDesc); if (ACPI_FAILURE (Status)) { @@ -238,6 +239,7 @@ AcpiNsParseTable ( * overhead of this is compensated for by the fact that the * parse objects are all cached. */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); Status = AcpiNsOneCompleteParse (2, TableDesc); if (ACPI_FAILURE (Status)) { diff --git a/sys/contrib/dev/acpica/nssearch.c b/sys/contrib/dev/acpica/nssearch.c index 6bab859..3310dba 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: 103 $ + * $Revision: 1.106 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,15 +123,24 @@ #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nssearch") +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsSearchParentTree ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **ReturnNode); + /******************************************************************************* * * FUNCTION: 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 + * 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 * * RETURN: Status * @@ -243,10 +252,10 @@ AcpiNsSearchNode ( * * FUNCTION: AcpiNsSearchParentTree * - * PARAMETERS: *TargetName - Ascii ACPI name to search for - * *Node - Starting node where search will begin - * Type - Object type to match - * **ReturnNode - Where the matched Node is returned + * PARAMETERS: TargetName - Ascii ACPI name to search for + * Node - Starting node where search will begin + * Type - Object type to match + * ReturnNode - Where the matched Node is returned * * RETURN: Status * @@ -341,12 +350,12 @@ AcpiNsSearchParentTree ( * * PARAMETERS: TargetName - Ascii ACPI name to search for (4 chars) * WalkState - Current state of the walk - * *Node - Starting node where search will begin + * Node - Starting node where search will begin * InterpreterMode - Add names only in ACPI_MODE_LOAD_PASS_x. * Otherwise,search only. * Type - Object type to match * Flags - Flags describing the search restrictions - * **ReturnNode - Where the Node is returned + * ReturnNode - Where the Node is returned * * RETURN: Status * diff --git a/sys/contrib/dev/acpica/nsutils.c b/sys/contrib/dev/acpica/nsutils.c index 21b73a7..184e885 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: 136 $ + * $Revision: 1.141 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,6 +125,18 @@ #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsutils") +/* Local prototypes */ + +static BOOLEAN +AcpiNsValidPathSeparator ( + char Sep); + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_NAME +AcpiNsFindParentName ( + ACPI_NAMESPACE_NODE *NodeToSearch); +#endif + /******************************************************************************* * @@ -133,7 +145,8 @@ * PARAMETERS: ModuleName - Caller's module name (for error output) * LineNumber - Caller's line number (for error output) * ComponentId - Caller's component ID (for error output) - * Message - Error message to use on failure + * InternalName - Name or path of the namespace node + * LookupStatus - Exception code from NS lookup * * RETURN: None * @@ -200,6 +213,9 @@ AcpiNsReportError ( * LineNumber - Caller's line number (for error output) * ComponentId - Caller's component ID (for error output) * Message - Error message to use on failure + * PrefixNode - Prefix relative to the path + * Path - Path to the node + * MethodStatus - Execution status * * RETURN: None * @@ -242,8 +258,8 @@ AcpiNsReportMethodError ( * * FUNCTION: AcpiNsPrintNodePathname * - * PARAMETERS: Node - Object - * Msg - Prefix message + * PARAMETERS: Node - Object + * Message - Prefix message * * DESCRIPTION: Print an object's full namespace pathname * Manages allocation/freeing of a pathname buffer @@ -253,7 +269,7 @@ AcpiNsReportMethodError ( void AcpiNsPrintNodePathname ( ACPI_NAMESPACE_NODE *Node, - char *Msg) + char *Message) { ACPI_BUFFER Buffer; ACPI_STATUS Status; @@ -272,9 +288,9 @@ AcpiNsPrintNodePathname ( Status = AcpiNsHandleToPathname (Node, &Buffer); if (ACPI_SUCCESS (Status)) { - if (Msg) + if (Message) { - AcpiOsPrintf ("%s ", Msg); + AcpiOsPrintf ("%s ", Message); } AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node); @@ -308,7 +324,7 @@ AcpiNsValidRootPrefix ( * * FUNCTION: AcpiNsValidPathSeparator * - * PARAMETERS: Sep - Character to be checked + * PARAMETERS: Sep - Character to be checked * * RETURN: TRUE if a valid path separator * @@ -316,7 +332,7 @@ AcpiNsValidRootPrefix ( * ******************************************************************************/ -BOOLEAN +static BOOLEAN AcpiNsValidPathSeparator ( char Sep) { @@ -329,10 +345,12 @@ AcpiNsValidPathSeparator ( * * FUNCTION: AcpiNsGetType * - * PARAMETERS: Handle - Parent Node to be examined + * PARAMETERS: Node - Parent Node to be examined * * RETURN: Type field from Node whose handle is passed * + * DESCRIPTION: Return the type of a Namespace node + * ******************************************************************************/ ACPI_OBJECT_TYPE @@ -345,10 +363,10 @@ AcpiNsGetType ( if (!Node) { ACPI_REPORT_WARNING (("NsGetType: Null Node input pointer\n")); - return_VALUE (ACPI_TYPE_ANY); + return_UINT32 (ACPI_TYPE_ANY); } - return_VALUE ((ACPI_OBJECT_TYPE) Node->Type); + return_UINT32 ((ACPI_OBJECT_TYPE) Node->Type); } @@ -356,11 +374,13 @@ AcpiNsGetType ( * * FUNCTION: AcpiNsLocal * - * PARAMETERS: Type - A namespace object type + * PARAMETERS: Type - A namespace object type * * RETURN: LOCAL if names must be found locally in objects of the * passed type, 0 if enclosing scopes should be searched * + * DESCRIPTION: Returns scope rule for the given object type. + * ******************************************************************************/ UINT32 @@ -375,10 +395,10 @@ AcpiNsLocal ( /* Type code out of range */ ACPI_REPORT_WARNING (("NsLocal: Invalid Object Type\n")); - return_VALUE (ACPI_NS_NORMAL); + return_UINT32 (ACPI_NS_NORMAL); } - return_VALUE ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL); + return_UINT32 ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL); } @@ -389,7 +409,7 @@ AcpiNsLocal ( * PARAMETERS: Info - Info struct initialized with the * external name pointer. * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Calculate the length of the internal (AML) namestring * corresponding to the external (ASL) namestring. @@ -663,14 +683,16 @@ AcpiNsInternalizeName ( * * FUNCTION: AcpiNsExternalizeName * - * PARAMETERS: *InternalName - Internal representation of name - * **ConvertedName - Where to return the resulting - * external representation of name + * PARAMETERS: InternalNameLength - Lenth of the internal name below + * InternalName - Internal representation of name + * ConvertedNameLength - Where the length is returned + * ConvertedName - Where the resulting external name + * is returned * * RETURN: Status * * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) - * to its external form (e.g. "\_PR_.CPU0") + * to its external (printable) form (e.g. "\_PR_.CPU0") * ******************************************************************************/ @@ -844,8 +866,9 @@ AcpiNsExternalizeName ( * * DESCRIPTION: Convert a namespace handle to a real Node * - * Note: Real integer handles allow for more verification - * and keep all pointers within this subsystem. + * Note: Real integer handles would allow for more verification + * and keep all pointers within this subsystem - however this introduces + * more (and perhaps unnecessary) overhead. * ******************************************************************************/ @@ -905,7 +928,7 @@ AcpiNsConvertEntryToHandle ( return ((ACPI_HANDLE) Node); -/* --------------------------------------------------- +/* Example future implementation --------------------- if (!Node) { @@ -931,12 +954,13 @@ AcpiNsConvertEntryToHandle ( * * RETURN: none * - * DESCRIPTION: free memory allocated for table storage. + * DESCRIPTION: free memory allocated for namespace and ACPI table storage. * ******************************************************************************/ void -AcpiNsTerminate (void) +AcpiNsTerminate ( + void) { ACPI_OPERAND_OBJECT *ObjDesc; @@ -994,10 +1018,10 @@ AcpiNsOpensScope ( /* type code out of range */ ACPI_REPORT_WARNING (("NsOpensScope: Invalid Object Type %X\n", Type)); - return_VALUE (ACPI_NS_NORMAL); + return_UINT32 (ACPI_NS_NORMAL); } - return_VALUE (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE); + return_UINT32 (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE); } @@ -1076,7 +1100,6 @@ AcpiNsGetNodeByPath ( (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); Cleanup: - /* Cleanup */ if (InternalPath) { ACPI_MEM_FREE (InternalPath); @@ -1087,57 +1110,6 @@ Cleanup: /******************************************************************************* * - * FUNCTION: AcpiNsFindParentName - * - * PARAMETERS: *ChildNode - Named Obj whose name is to be found - * - * RETURN: The ACPI name - * - * DESCRIPTION: Search for the given obj in its parent scope and return the - * name segment, or "????" if the parent name can't be found - * (which "should not happen"). - * - ******************************************************************************/ - -ACPI_NAME -AcpiNsFindParentName ( - ACPI_NAMESPACE_NODE *ChildNode) -{ - ACPI_NAMESPACE_NODE *ParentNode; - - - ACPI_FUNCTION_TRACE ("NsFindParentName"); - - - if (ChildNode) - { - /* Valid entry. Get the parent Node */ - - ParentNode = AcpiNsGetParentNode (ChildNode); - if (ParentNode) - { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Parent of %p [%4.4s] is %p [%4.4s]\n", - ChildNode, AcpiUtGetNodeName (ChildNode), - ParentNode, AcpiUtGetNodeName (ParentNode))); - - if (ParentNode->Name.Integer) - { - return_VALUE ((ACPI_NAME) ParentNode->Name.Integer); - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Unable to find parent of %p (%4.4s)\n", - ChildNode, AcpiUtGetNodeName (ChildNode))); - } - - return_VALUE (ACPI_UNKNOWN_NAME); -} - - -/******************************************************************************* - * * FUNCTION: AcpiNsGetParentNode * * PARAMETERS: Node - Current table entry @@ -1148,7 +1120,6 @@ AcpiNsFindParentName ( * ******************************************************************************/ - ACPI_NAMESPACE_NODE * AcpiNsGetParentNode ( ACPI_NAMESPACE_NODE *Node) @@ -1171,7 +1142,6 @@ AcpiNsGetParentNode ( Node = Node->Peer; } - return (Node->Peer); } @@ -1190,7 +1160,6 @@ AcpiNsGetParentNode ( * ******************************************************************************/ - ACPI_NAMESPACE_NODE * AcpiNsGetNextValidNode ( ACPI_NAMESPACE_NODE *Node) @@ -1209,3 +1178,56 @@ AcpiNsGetNextValidNode ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiNsFindParentName + * + * PARAMETERS: *ChildNode - Named Obj whose name is to be found + * + * RETURN: The ACPI name + * + * DESCRIPTION: Search for the given obj in its parent scope and return the + * name segment, or "????" if the parent name can't be found + * (which "should not happen"). + * + ******************************************************************************/ + +ACPI_NAME +AcpiNsFindParentName ( + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_NAMESPACE_NODE *ParentNode; + + + ACPI_FUNCTION_TRACE ("NsFindParentName"); + + + if (ChildNode) + { + /* Valid entry. Get the parent Node */ + + ParentNode = AcpiNsGetParentNode (ChildNode); + if (ParentNode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Parent of %p [%4.4s] is %p [%4.4s]\n", + ChildNode, AcpiUtGetNodeName (ChildNode), + ParentNode, AcpiUtGetNodeName (ParentNode))); + + if (ParentNode->Name.Integer) + { + return_VALUE ((ACPI_NAME) ParentNode->Name.Integer); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Unable to find parent of %p (%4.4s)\n", + ChildNode, AcpiUtGetNodeName (ChildNode))); + } + + return_VALUE (ACPI_UNKNOWN_NAME); +} +#endif + + diff --git a/sys/contrib/dev/acpica/nswalk.c b/sys/contrib/dev/acpica/nswalk.c index 58c26df..847a3dc 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: 37 $ + * $Revision: 1.39 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -131,7 +131,7 @@ * * PARAMETERS: Type - Type of node to be searched for * ParentNode - Parent node whose children we are - * getting + * getting * ChildNode - Previous child that was found. * The NEXT child will be returned * diff --git a/sys/contrib/dev/acpica/nsxfeval.c b/sys/contrib/dev/acpica/nsxfeval.c index 259bda9..c4b9c8c 100644 --- a/sys/contrib/dev/acpica/nsxfeval.c +++ b/sys/contrib/dev/acpica/nsxfeval.c @@ -2,7 +2,7 @@ * * Module Name: nsxfeval - Public interfaces to the ACPI subsystem * ACPI Object evaluation interfaces - * $Revision: 14 $ + * $Revision: 1.17 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -132,11 +132,11 @@ * FUNCTION: AcpiEvaluateObjectTyped * * PARAMETERS: Handle - Object handle (optional) - * *Pathname - Object pathname (optional) - * **ExternalParams - List of parameters to pass to method, + * Pathname - Object pathname (optional) + * ExternalParams - List of parameters to pass to method, * terminated by NULL. May be NULL * if no parameters are being passed. - * *ReturnBuffer - Where to put method's return value (if + * ReturnBuffer - Where to put method's return value (if * any). If NULL, no value is returned. * ReturnType - Expected type of return object * @@ -404,7 +404,8 @@ AcpiEvaluateObject ( { /* Validate/Allocate/Clear caller buffer */ - Status = AcpiUtInitializeBuffer (ReturnBuffer, BufferSpaceNeeded); + Status = AcpiUtInitializeBuffer (ReturnBuffer, + BufferSpaceNeeded); if (ACPI_FAILURE (Status)) { /* @@ -526,7 +527,8 @@ AcpiWalkNamespace ( return_ACPI_STATUS (Status); } - Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, ACPI_NS_WALK_UNLOCK, + Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, + ACPI_NS_WALK_UNLOCK, UserFunction, Context, ReturnValue); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); @@ -640,7 +642,8 @@ AcpiNsGetDeviceCallback ( } } - Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context, ReturnValue); + Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context, + ReturnValue); return (Status); } diff --git a/sys/contrib/dev/acpica/nsxfname.c b/sys/contrib/dev/acpica/nsxfname.c index 38599ad..7885849 100644 --- a/sys/contrib/dev/acpica/nsxfname.c +++ b/sys/contrib/dev/acpica/nsxfname.c @@ -2,7 +2,7 @@ * * Module Name: nsxfname - Public interfaces to the ACPI subsystem * ACPI Namespace oriented interfaces - * $Revision: 101 $ + * $Revision: 1.104 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -130,9 +130,9 @@ * FUNCTION: AcpiGetHandle * * PARAMETERS: Parent - Object to search under (search scope). - * PathName - Pointer to an asciiz string containing the - * name - * RetHandle - Where the return handle is placed + * Pathname - Pointer to an asciiz string containing the + * name + * RetHandle - Where the return handle is returned * * RETURN: Status * @@ -304,7 +304,7 @@ UnlockAndExit: * FUNCTION: AcpiGetObjectInfo * * PARAMETERS: Handle - Object Handle - * Info - Where the info is returned + * Buffer - Where the info is returned * * RETURN: Status * @@ -321,7 +321,7 @@ AcpiGetObjectInfo ( { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; - ACPI_DEVICE_INFO Info; + ACPI_DEVICE_INFO *Info; ACPI_DEVICE_INFO *ReturnInfo; ACPI_COMPATIBLE_ID_LIST *CidList = NULL; ACPI_SIZE Size; @@ -340,61 +340,66 @@ AcpiGetObjectInfo ( return (Status); } + Info = ACPI_MEM_CALLOCATE (sizeof (ACPI_DEVICE_INFO)); + if (!Info) + { + return (AE_NO_MEMORY); + } + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { - return (Status); + goto Cleanup; } Node = AcpiNsMapHandleToNode (Handle); if (!Node) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); - return (AE_BAD_PARAMETER); + goto Cleanup; } /* Init return structure */ Size = sizeof (ACPI_DEVICE_INFO); - ACPI_MEMSET (&Info, 0, Size); - Info.Type = Node->Type; - Info.Name = Node->Name.Integer; - Info.Valid = 0; + Info->Type = Node->Type; + Info->Name = Node->Name.Integer; + Info->Valid = 0; Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { - return (Status); + goto Cleanup; } /* If not a device, we are all done */ - if (Info.Type == ACPI_TYPE_DEVICE) + if (Info->Type == ACPI_TYPE_DEVICE) { /* * Get extra info for ACPI Devices objects only: * Run the Device _HID, _UID, _CID, _STA, _ADR and _SxD methods. * * Note: none of these methods are required, so they may or may - * not be present for this device. The Info.Valid bitfield is used + * not be present for this device. The Info->Valid bitfield is used * to indicate which methods were found and ran successfully. */ /* Execute the Device._HID method */ - Status = AcpiUtExecute_HID (Node, &Info.HardwareId); + Status = AcpiUtExecute_HID (Node, &Info->HardwareId); if (ACPI_SUCCESS (Status)) { - Info.Valid |= ACPI_VALID_HID; + Info->Valid |= ACPI_VALID_HID; } /* Execute the Device._UID method */ - Status = AcpiUtExecute_UID (Node, &Info.UniqueId); + Status = AcpiUtExecute_UID (Node, &Info->UniqueId); if (ACPI_SUCCESS (Status)) { - Info.Valid |= ACPI_VALID_UID; + Info->Valid |= ACPI_VALID_UID; } /* Execute the Device._CID method */ @@ -404,35 +409,33 @@ AcpiGetObjectInfo ( { Size += ((ACPI_SIZE) CidList->Count - 1) * sizeof (ACPI_COMPATIBLE_ID); - Info.Valid |= ACPI_VALID_CID; + Info->Valid |= ACPI_VALID_CID; } /* Execute the Device._STA method */ - Status = AcpiUtExecute_STA (Node, &Info.CurrentStatus); + Status = AcpiUtExecute_STA (Node, &Info->CurrentStatus); if (ACPI_SUCCESS (Status)) { - Info.Valid |= ACPI_VALID_STA; + Info->Valid |= ACPI_VALID_STA; } /* Execute the Device._ADR method */ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, - &Info.Address); + &Info->Address); if (ACPI_SUCCESS (Status)) { - Info.Valid |= ACPI_VALID_ADR; + Info->Valid |= ACPI_VALID_ADR; } /* Execute the Device._SxD methods */ - Status = AcpiUtExecute_Sxds (Node, Info.HighestDstates); + Status = AcpiUtExecute_Sxds (Node, Info->HighestDstates); if (ACPI_SUCCESS (Status)) { - Info.Valid |= ACPI_VALID_SXDS; + Info->Valid |= ACPI_VALID_SXDS; } - - Status = AE_OK; } /* Validate/Allocate/Clear caller buffer */ @@ -446,7 +449,7 @@ AcpiGetObjectInfo ( /* Populate the return buffer */ ReturnInfo = Buffer->Pointer; - ACPI_MEMCPY (ReturnInfo, &Info, sizeof (ACPI_DEVICE_INFO)); + ACPI_MEMCPY (ReturnInfo, Info, sizeof (ACPI_DEVICE_INFO)); if (CidList) { @@ -455,6 +458,7 @@ AcpiGetObjectInfo ( Cleanup: + ACPI_MEM_FREE (Info); if (CidList) { ACPI_MEM_FREE (CidList); diff --git a/sys/contrib/dev/acpica/nsxfobj.c b/sys/contrib/dev/acpica/nsxfobj.c index 73e4b73..0b98c55 100644 --- a/sys/contrib/dev/acpica/nsxfobj.c +++ b/sys/contrib/dev/acpica/nsxfobj.c @@ -2,7 +2,7 @@ * * Module Name: nsxfobj - Public interfaces to the ACPI subsystem * ACPI Object oriented interfaces - * $Revision: 117 $ + * $Revision: 1.119 $ * ******************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -130,7 +130,7 @@ * FUNCTION: AcpiGetType * * PARAMETERS: Handle - Handle of object whose type is desired - * *RetType - Where the type will be placed + * RetType - Where the type will be placed * * RETURN: Status * diff --git a/sys/contrib/dev/acpica/osunixxf.c b/sys/contrib/dev/acpica/osunixxf.c index 28894a8..18197d7 100644 --- a/sys/contrib/dev/acpica/osunixxf.c +++ b/sys/contrib/dev/acpica/osunixxf.c @@ -8,7 +8,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -185,15 +185,7 @@ AcpiOsGetRootPointer ( ACPI_POINTER *Address) { -#if 0 - /* The supporting code for this is not yet available. - * Return to the old situation for now. - */ return (AeLocalGetRootPointer(Flags, Address)); -#else - return (AE_OK); -#endif - } @@ -254,7 +246,7 @@ AcpiOsTableOverride ( *NewTable = NULL; -#ifdef _ACPI_EXEC_APP +#ifdef ACPI_EXEC_APP /* This code exercises the table override mechanism in the core */ @@ -672,19 +664,19 @@ AcpiOsDeleteLock ( } -void +ACPI_NATIVE_UINT AcpiOsAcquireLock ( - ACPI_HANDLE Handle, - UINT32 Flags) + ACPI_HANDLE Handle) { AcpiOsWaitSemaphore (Handle, 1, 0xFFFF); + return (0); } void AcpiOsReleaseLock ( ACPI_HANDLE Handle, - UINT32 Flags) + ACPI_NATIVE_UINT Flags) { AcpiOsSignalSemaphore (Handle, 1); } diff --git a/sys/contrib/dev/acpica/psargs.c b/sys/contrib/dev/acpica/psargs.c index 4610358..33d5587 100644 --- a/sys/contrib/dev/acpica/psargs.c +++ b/sys/contrib/dev/acpica/psargs.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psargs - Parse AML opcode arguments - * $Revision: 76 $ + * $Revision: 1.81 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,6 +124,16 @@ #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psargs") +/* Local prototypes */ + +static UINT32 +AcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState); + +static ACPI_PARSE_OBJECT * +AcpiPsGetNextField ( + ACPI_PARSE_STATE *ParserState); + /******************************************************************************* * @@ -138,7 +148,7 @@ * ******************************************************************************/ -UINT32 +static UINT32 AcpiPsGetNextPackageLength ( ACPI_PARSE_STATE *ParserState) { @@ -152,7 +162,6 @@ AcpiPsGetNextPackageLength ( EncodedLength = (UINT32) ACPI_GET8 (ParserState->Aml); ParserState->Aml++; - switch (EncodedLength >> 6) /* bits 6-7 contain encoding scheme */ { case 0: /* 1-byte encoding (bits 0-5) */ @@ -193,7 +202,7 @@ AcpiPsGetNextPackageLength ( break; } - return_VALUE (Length); + return_UINT32 (Length); } @@ -367,15 +376,16 @@ AcpiPsGetNextNamepath ( * parent tree, but don't open a new scope -- we just want to lookup the * object (MUST BE mode EXECUTE to perform upsearch) */ - Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); + Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + NULL, &Node); if (ACPI_SUCCESS (Status) && MethodCall) { if (Node->Type == ACPI_TYPE_METHOD) { - /* - * This name is actually a control method invocation - */ + /* This name is actually a control method invocation */ + MethodDesc = AcpiNsGetAttachedObject (Node); ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Control Method - %p Desc %p Path=%p\n", @@ -447,7 +457,7 @@ AcpiPsGetNextNamepath ( /* * We got a NOT_FOUND during table load or we encountered * a CondRefOf(x) where the target does not exist. - * -- either case is ok + * Either case is ok */ Status = AE_OK; } @@ -575,12 +585,13 @@ AcpiPsGetNextSimpleArg ( * ******************************************************************************/ -ACPI_PARSE_OBJECT * +static ACPI_PARSE_OBJECT * AcpiPsGetNextField ( ACPI_PARSE_STATE *ParserState) { - UINT32 AmlOffset = (UINT32) ACPI_PTR_DIFF (ParserState->Aml, - ParserState->AmlStart); + UINT32 AmlOffset = (UINT32) + ACPI_PTR_DIFF (ParserState->Aml, + ParserState->AmlStart); ACPI_PARSE_OBJECT *Field; UINT16 Opcode; UINT32 Name; @@ -589,7 +600,7 @@ AcpiPsGetNextField ( ACPI_FUNCTION_TRACE ("PsGetNextField"); - /* determine field type */ + /* Determine field type */ switch (ACPI_GET8 (ParserState->Aml)) { @@ -611,7 +622,6 @@ AcpiPsGetNextField ( break; } - /* Allocate a new field op */ Field = AcpiPsAllocOp (Opcode); @@ -674,10 +684,10 @@ AcpiPsGetNextField ( * * FUNCTION: AcpiPsGetNextArg * - * PARAMETERS: ParserState - Current parser state object + * PARAMETERS: WalkState - Current state + * ParserState - Current parser state object * ArgType - The argument type (AML_*_ARG) - * ArgCount - If the argument points to a control method - * the method's argument is returned here. + * ReturnArg - Where the next arg is returned * * RETURN: Status, and an op object containing the next argument. * @@ -712,7 +722,7 @@ AcpiPsGetNextArg ( case ARGP_NAME: case ARGP_NAMESTRING: - /* constants, strings, and namestrings are all the same size */ + /* Constants, strings, and namestrings are all the same size */ Arg = AcpiPsAllocOp (AML_BYTE_OP); if (!Arg) @@ -753,7 +763,6 @@ AcpiPsGetNextArg ( { Arg = Field; } - Prev = Field; } @@ -778,8 +787,8 @@ AcpiPsGetNextArg ( /* Fill in bytelist data */ - Arg->Common.Value.Size = (UINT32) ACPI_PTR_DIFF (ParserState->PkgEnd, - ParserState->Aml); + Arg->Common.Value.Size = (UINT32) + ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml); Arg->Named.Data = ParserState->Aml; /* Skip to End of byte data */ @@ -810,7 +819,7 @@ AcpiPsGetNextArg ( } else { - /* single complex argument, nothing returned */ + /* Single complex argument, nothing returned */ WalkState->ArgCount = 1; } @@ -820,7 +829,7 @@ AcpiPsGetNextArg ( case ARGP_DATAOBJ: case ARGP_TERMARG: - /* single complex argument, nothing returned */ + /* Single complex argument, nothing returned */ WalkState->ArgCount = 1; break; @@ -832,7 +841,7 @@ AcpiPsGetNextArg ( if (ParserState->Aml < ParserState->PkgEnd) { - /* non-empty list of variable arguments, nothing returned */ + /* Non-empty list of variable arguments, nothing returned */ WalkState->ArgCount = ACPI_VAR_ARGS; } diff --git a/sys/contrib/dev/acpica/psloop.c b/sys/contrib/dev/acpica/psloop.c new file mode 100644 index 0000000..91933c7 --- /dev/null +++ b/sys/contrib/dev/acpica/psloop.c @@ -0,0 +1,927 @@ +/****************************************************************************** + * + * Module Name: psloop - Main AML parse loop + * $Revision: 1.5 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +/* + * Parse the AML and build an operation tree as most interpreters, + * like Perl, do. Parsing is done by hand rather than with a YACC + * generated parser to tightly constrain stack and dynamic memory + * usage. At the same time, parsing is kept flexible and the code + * fairly compact by parsing based on a list of AML opcode + * templates in AmlOpInfo[] + */ + +#include <contrib/dev/acpica/acpi.h> +#include <contrib/dev/acpica/acparser.h> +#include <contrib/dev/acpica/acdispat.h> +#include <contrib/dev/acpica/amlcode.h> + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psloop") + +static UINT32 AcpiGbl_Depth = 0; + + +/******************************************************************************* + * + * FUNCTION: AcpiPsParseLoop + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Parse AML (pointed to by the current parser state) and return + * a tree of ops. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_STATUS Status2; + ACPI_PARSE_OBJECT *Op = NULL; /* current op */ + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_PARSE_OBJECT *PreOp = NULL; + ACPI_PARSE_STATE *ParserState; + UINT8 *AmlOpStart = NULL; + + + ACPI_FUNCTION_TRACE_PTR ("PsParseLoop", WalkState); + + if (WalkState->DescendingCallback == NULL) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + ParserState = &WalkState->ParserState; + WalkState->ArgTypes = 0; + +#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) + + if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART) + { + /* We are restarting a preempted control method */ + + if (AcpiPsHasCompletedScope (ParserState)) + { + /* + * We must check if a predicate to an IF or WHILE statement + * was just completed + */ + if ((ParserState->Scope->ParseScope.Op) && + ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) || + (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) && + (WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_PREDICATE_EXECUTING)) + { + /* + * A predicate was just completed, get the value of the + * predicate and branch based on that value + */ + WalkState->Op = NULL; + Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE)); + if (ACPI_FAILURE (Status) && + ((Status & AE_CODE_MASK) != AE_CODE_CONTROL)) + { + if (Status == AE_AML_NO_RETURN_VALUE) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invoked method did not return a value, %s\n", + AcpiFormatException (Status))); + + } + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "GetPredicate Failed, %s\n", + AcpiFormatException (Status))); + return_ACPI_STATUS (Status); + } + + Status = AcpiPsNextParseState (WalkState, Op, Status); + } + + AcpiPsPopScope (ParserState, &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op)); + } + else if (WalkState->PrevOp) + { + /* We were in the middle of an op */ + + Op = WalkState->PrevOp; + WalkState->ArgTypes = WalkState->PrevArgTypes; + } + } +#endif + + /* Iterative parsing loop, while there is more AML to process: */ + + while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) + { + AmlOpStart = ParserState->Aml; + if (!Op) + { + /* Get the next opcode from the AML stream */ + + WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (ParserState->Aml, + ParserState->AmlStart); + WalkState->Opcode = AcpiPsPeekOpcode (ParserState); + + /* + * First cut to determine what we have found: + * 1) A valid AML opcode + * 2) A name string + * 3) An unknown/invalid opcode + */ + WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); + switch (WalkState->OpInfo->Class) + { + case AML_CLASS_ASCII: + case AML_CLASS_PREFIX: + /* + * Starts with a valid prefix or ASCII char, this is a name + * string. Convert the bare name string to a namepath. + */ + WalkState->Opcode = AML_INT_NAMEPATH_OP; + WalkState->ArgTypes = ARGP_NAMESTRING; + break; + + case AML_CLASS_UNKNOWN: + + /* The opcode is unrecognized. Just skip unknown opcodes */ + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Found unknown opcode %X at AML address %p offset %X, ignoring\n", + WalkState->Opcode, ParserState->Aml, WalkState->AmlOffset)); + + ACPI_DUMP_BUFFER (ParserState->Aml, 128); + + /* Assume one-byte bad opcode */ + + ParserState->Aml++; + continue; + + default: + + /* Found opcode info, this is a normal opcode */ + + ParserState->Aml += AcpiPsGetOpcodeSize (WalkState->Opcode); + WalkState->ArgTypes = WalkState->OpInfo->ParseArgs; + break; + } + + /* Create Op structure and append to parent's argument list */ + + if (WalkState->OpInfo->Flags & AML_NAMED) + { + /* Allocate a new PreOp if necessary */ + + if (!PreOp) + { + PreOp = AcpiPsAllocOp (WalkState->Opcode); + if (!PreOp) + { + Status = AE_NO_MEMORY; + goto CloseThisOp; + } + } + + PreOp->Common.Value.Arg = NULL; + PreOp->Common.AmlOpcode = WalkState->Opcode; + + /* + * Get and append arguments until we find the node that contains + * the name (the type ARGP_NAME). + */ + while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && + (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME)) + { + Status = AcpiPsGetNextArg (WalkState, ParserState, + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); + if (ACPI_FAILURE (Status)) + { + goto CloseThisOp; + } + + AcpiPsAppendArg (PreOp, Arg); + INCREMENT_ARG_LIST (WalkState->ArgTypes); + } + + /* + * Make sure that we found a NAME and didn't run out of + * arguments + */ + if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes)) + { + Status = AE_AML_NO_OPERAND; + goto CloseThisOp; + } + + /* We know that this arg is a name, move to next arg */ + + INCREMENT_ARG_LIST (WalkState->ArgTypes); + + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + WalkState->Op = NULL; + + Status = WalkState->DescendingCallback (WalkState, &Op); + if (ACPI_FAILURE (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "During name lookup/catalog, %s\n", + AcpiFormatException (Status))); + goto CloseThisOp; + } + + if (!Op) + { + continue; + } + + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + + if (ACPI_FAILURE (Status)) + { + goto CloseThisOp; + } + + AcpiPsAppendArg (Op, PreOp->Common.Value.Arg); + AcpiGbl_Depth++; + + if (Op->Common.AmlOpcode == AML_REGION_OP) + { + /* + * Defer final parsing of an OperationRegion body, + * because we don't have enough info in the first pass + * to parse it correctly (i.e., there may be method + * calls within the TermArg elements of the body.) + * + * However, we must continue parsing because + * the opregion is not a standalone package -- + * we don't know where the end is at this point. + * + * (Length is unknown until parse of the body complete) + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = 0; + } + } + else + { + /* Not a named opcode, just allocate Op and append to parent */ + + WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); + Op = AcpiPsAllocOp (WalkState->Opcode); + if (!Op) + { + Status = AE_NO_MEMORY; + goto CloseThisOp; + } + + if (WalkState->OpInfo->Flags & AML_CREATE) + { + /* + * Backup to beginning of CreateXXXfield declaration + * BodyLength is unknown until we parse the body + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = 0; + } + + AcpiPsAppendArg (AcpiPsGetParentScope (ParserState), Op); + + if ((WalkState->DescendingCallback != NULL)) + { + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + WalkState->Op = Op; + + Status = WalkState->DescendingCallback (WalkState, &Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + + if (ACPI_FAILURE (Status)) + { + goto CloseThisOp; + } + } + } + + Op->Common.AmlOffset = WalkState->AmlOffset; + + if (WalkState->OpInfo) + { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n", + (UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name, + Op, ParserState->Aml, Op->Common.AmlOffset)); + } + } + + + /* + * Start ArgCount at zero because we don't know if there are + * any args yet + */ + WalkState->ArgCount = 0; + + /* Are there any arguments that must be processed? */ + + if (WalkState->ArgTypes) + { + /* Get arguments */ + + switch (Op->Common.AmlOpcode) + { + case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ + case AML_WORD_OP: /* AML_WORDDATA_ARG */ + case AML_DWORD_OP: /* AML_DWORDATA_ARG */ + case AML_QWORD_OP: /* AML_QWORDATA_ARG */ + case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ + + /* Fill in constant or string argument directly */ + + AcpiPsGetNextSimpleArg (ParserState, + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op); + break; + + case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ + + Status = AcpiPsGetNextNamepath (WalkState, ParserState, Op, 1); + if (ACPI_FAILURE (Status)) + { + goto CloseThisOp; + } + + WalkState->ArgTypes = 0; + break; + + default: + /* + * Op is not a constant or string, append each argument + * to the Op + */ + while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && + !WalkState->ArgCount) + { + WalkState->AmlOffset = (UINT32) + ACPI_PTR_DIFF (ParserState->Aml, ParserState->AmlStart); + + Status = AcpiPsGetNextArg (WalkState, ParserState, + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), + &Arg); + if (ACPI_FAILURE (Status)) + { + goto CloseThisOp; + } + + if (Arg) + { + Arg->Common.AmlOffset = WalkState->AmlOffset; + AcpiPsAppendArg (Op, Arg); + } + INCREMENT_ARG_LIST (WalkState->ArgTypes); + } + + + /* Special processing for certain opcodes */ + + /* TBD (remove): Temporary mechanism to disable this code if needed */ + +#ifdef ACPI_ENABLE_MODULE_LEVEL_CODE + + if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS1) && + ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) == 0)) + { + /* + * We want to skip If/Else/While constructs during Pass1 + * because we want to actually conditionally execute the + * code during Pass2. + * + * Except for disassembly, where we always want to + * walk the If/Else/While packages + */ + switch (Op->Common.AmlOpcode) + { + case AML_IF_OP: + case AML_ELSE_OP: + case AML_WHILE_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Pass1: Skipping an If/Else/While body\n")); + + /* Skip body of if/else/while in pass 1 */ + + ParserState->Aml = ParserState->PkgEnd; + WalkState->ArgCount = 0; + break; + + default: + break; + } + } +#endif + switch (Op->Common.AmlOpcode) + { + case AML_METHOD_OP: + + /* + * Skip parsing of control method + * because we don't have enough info in the first pass + * to parse it correctly. + * + * Save the length and address of the body + */ + Op->Named.Data = ParserState->Aml; + Op->Named.Length = (UINT32) (ParserState->PkgEnd - + ParserState->Aml); + + /* Skip body of method */ + + ParserState->Aml = ParserState->PkgEnd; + WalkState->ArgCount = 0; + break; + + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_VAR_PACKAGE_OP: + + if ((Op->Common.Parent) && + (Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && + (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2)) + { + /* + * Skip parsing of Buffers and Packages + * because we don't have enough info in the first pass + * to parse them correctly. + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = (UINT32) (ParserState->PkgEnd - + AmlOpStart); + + /* Skip body */ + + ParserState->Aml = ParserState->PkgEnd; + WalkState->ArgCount = 0; + } + break; + + case AML_WHILE_OP: + + if (WalkState->ControlState) + { + WalkState->ControlState->Control.PackageEnd = + ParserState->PkgEnd; + } + break; + + default: + + /* No action for all other opcodes */ + break; + } + break; + } + } + + /* Check for arguments that need to be processed */ + + if (WalkState->ArgCount) + { + /* + * There are arguments (complex ones), push Op and + * prepare for argument + */ + Status = AcpiPsPushScope (ParserState, Op, + WalkState->ArgTypes, WalkState->ArgCount); + if (ACPI_FAILURE (Status)) + { + goto CloseThisOp; + } + Op = NULL; + continue; + } + + /* + * All arguments have been processed -- Op is complete, + * prepare for next + */ + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if (WalkState->OpInfo->Flags & AML_NAMED) + { + if (AcpiGbl_Depth) + { + AcpiGbl_Depth--; + } + + if (Op->Common.AmlOpcode == AML_REGION_OP) + { + /* + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. + * + * Completed parsing an OpRegion declaration, we now + * know the length. + */ + Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + } + } + + if (WalkState->OpInfo->Flags & AML_CREATE) + { + /* + * Backup to beginning of CreateXXXfield declaration (1 for + * Opcode) + * + * BodyLength is unknown until we parse the body + */ + Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + } + + /* This op complete, notify the dispatcher */ + + if (WalkState->AscendingCallback != NULL) + { + WalkState->Op = Op; + WalkState->Opcode = Op->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + } + + +CloseThisOp: + /* + * Finished one argument of the containing scope + */ + ParserState->Scope->ParseScope.ArgCount--; + + /* Finished with PreOp */ + + if (PreOp) + { + AcpiPsFreeOp (PreOp); + PreOp = NULL; + } + + /* Close this Op (will result in parse subtree deletion) */ + + Status2 = AcpiPsCompleteThisOp (WalkState, Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + Op = NULL; + + switch (Status) + { + case AE_OK: + break; + + + case AE_CTRL_TRANSFER: + + /* We are about to transfer to a called method. */ + + WalkState->PrevOp = Op; + WalkState->PrevArgTypes = WalkState->ArgTypes; + return_ACPI_STATUS (Status); + + + case AE_CTRL_END: + + AcpiPsPopScope (ParserState, &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + if (Op) + { + WalkState->Op = Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + WalkState->Opcode = Op->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + + Status2 = AcpiPsCompleteThisOp (WalkState, Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + Op = NULL; + } + Status = AE_OK; + break; + + + case AE_CTRL_BREAK: + case AE_CTRL_CONTINUE: + + /* Pop off scopes until we find the While */ + + while (!Op || (Op->Common.AmlOpcode != AML_WHILE_OP)) + { + AcpiPsPopScope (ParserState, &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + } + + /* Close this iteration of the While loop */ + + WalkState->Op = Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + WalkState->Opcode = Op->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + + Status2 = AcpiPsCompleteThisOp (WalkState, Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + Op = NULL; + + Status = AE_OK; + break; + + + case AE_CTRL_TERMINATE: + + Status = AE_OK; + + /* Clean up */ + do + { + if (Op) + { + Status2 = AcpiPsCompleteThisOp (WalkState, Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + AcpiPsPopScope (ParserState, &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); + + + default: /* All other non-AE_OK status */ + + do + { + if (Op) + { + Status2 = AcpiPsCompleteThisOp (WalkState, Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + AcpiPsPopScope (ParserState, &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + } while (Op); + + + /* + * TBD: Cleanup parse ops on error + */ +#if 0 + if (Op == NULL) + { + AcpiPsPopScope (ParserState, &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + } +#endif + WalkState->PrevOp = Op; + WalkState->PrevArgTypes = WalkState->ArgTypes; + return_ACPI_STATUS (Status); + } + + /* This scope complete? */ + + if (AcpiPsHasCompletedScope (ParserState)) + { + AcpiPsPopScope (ParserState, &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op)); + } + else + { + Op = NULL; + } + + } /* while ParserState->Aml */ + + + /* + * Complete the last Op (if not completed), and clear the scope stack. + * It is easily possible to end an AML "package" with an unbounded number + * of open scopes (such as when several ASL blocks are closed with + * sequential closing braces). We want to terminate each one cleanly. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op)); + do + { + if (Op) + { + if (WalkState->AscendingCallback != NULL) + { + WalkState->Op = Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + WalkState->Opcode = Op->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + goto CloseThisOp; + } + + if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + + /* Clean up */ + do + { + if (Op) + { + Status2 = AcpiPsCompleteThisOp (WalkState, Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + AcpiPsPopScope (ParserState, &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); + } + + else if (ACPI_FAILURE (Status)) + { + /* First error is most important */ + + (void) AcpiPsCompleteThisOp (WalkState, Op); + return_ACPI_STATUS (Status); + } + } + + Status2 = AcpiPsCompleteThisOp (WalkState, Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, + &WalkState->ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); +} + + diff --git a/sys/contrib/dev/acpica/psopcode.c b/sys/contrib/dev/acpica/psopcode.c index c42bf82..b7a805a 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: 83 $ + * $Revision: 1.93 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,6 +117,7 @@ #include <contrib/dev/acpica/acpi.h> #include <contrib/dev/acpica/acparser.h> +#include <contrib/dev/acpica/acopcode.h> #include <contrib/dev/acpica/amlcode.h> @@ -124,23 +125,6 @@ ACPI_MODULE_NAME ("psopcode") -#define _UNK 0x6B -/* - * Reserved ASCII characters. Do not use any of these for - * internal opcodes, since they are used to differentiate - * name strings from AML opcodes - */ -#define _ASC 0x6C -#define _NAM 0x6C -#define _PFX 0x6D -#define _UNKNOWN_OPCODE 0x02 /* An example unknown opcode */ - -#define MAX_EXTENDED_OPCODE 0x88 -#define NUM_EXTENDED_OPCODE (MAX_EXTENDED_OPCODE + 1) -#define MAX_INTERNAL_OPCODE -#define NUM_INTERNAL_OPCODE (MAX_INTERNAL_OPCODE + 1) - - /******************************************************************************* * * NAME: AcpiGbl_AmlOpInfo @@ -152,274 +136,9 @@ * ******************************************************************************/ - -/* - * All AML opcodes and the parse-time arguments for each. Used by the AML parser Each list is compressed - * into a 32-bit number and stored in the master opcode table at the end of this file. - */ - - -#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA) -#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME) -#define ARGP_ARG0 ARG_NONE -#define ARGP_ARG1 ARG_NONE -#define ARGP_ARG2 ARG_NONE -#define ARGP_ARG3 ARG_NONE -#define ARGP_ARG4 ARG_NONE -#define ARGP_ARG5 ARG_NONE -#define ARGP_ARG6 ARG_NONE -#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST) -#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_BREAK_OP ARG_NONE -#define ARGP_BREAK_POINT_OP ARG_NONE -#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST) -#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA) -#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME) -#define ARGP_CONTINUE_OP ARG_NONE -#define ARGP_COPY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SIMPLENAME) -#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_CREATE_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_CREATE_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_CREATE_QWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_CREATE_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) -#define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_DEBUG_OP ARG_NONE -#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) -#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET) -#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA) -#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST) -#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME) -#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG) -#define ARGP_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST) -#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) -#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST) -#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME) -#define ARGP_LOAD_TABLE_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_LOCAL0 ARG_NONE -#define ARGP_LOCAL1 ARG_NONE -#define ARGP_LOCAL2 ARG_NONE -#define ARGP_LOCAL3 ARG_NONE -#define ARGP_LOCAL4 ARG_NONE -#define ARGP_LOCAL5 ARG_NONE -#define ARGP_LOCAL6 ARG_NONE -#define ARGP_LOCAL7 ARG_NONE -#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST) -#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_MID_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_MOD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA) -#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ) -#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_NOOP_OP ARG_NONE -#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) -#define ARGP_ONE_OP ARG_NONE -#define ARGP_ONES_OP ARG_NONE -#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) -#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST) -#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST) -#define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA) -#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) -#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_REVISION_OP ARG_NONE -#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST) -#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG) -#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING) -#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME) -#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) -#define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) -#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME) -#define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_DATAOBJLIST) -#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) -#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) -#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA) -#define ARGP_ZERO_OP ARG_NONE - - -/* - * All AML opcodes and the runtime arguments for each. Used by the AML interpreter Each list is compressed - * into a 32-bit number and stored in the master opcode table at the end of this file. - * - * (Used by PrepOperands procedure and the ASL Compiler) - */ - - -#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE -#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_INTEGER) -#define ARGI_ADD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE -#define ARGI_ARG0 ARG_NONE -#define ARGI_ARG1 ARG_NONE -#define ARGI_ARG2 ARG_NONE -#define ARGI_ARG3 ARG_NONE -#define ARGI_ARG4 ARG_NONE -#define ARGI_ARG5 ARG_NONE -#define ARGI_ARG6 ARG_NONE -#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE -#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_BREAK_OP ARG_NONE -#define ARGI_BREAK_POINT_OP ARG_NONE -#define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER) -#define ARGI_BYTE_OP ARGI_INVALID_OPCODE -#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE -#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF) -#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF) -#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF) -#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE -#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET) -#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_CREATE_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#define ARGI_CREATE_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) -#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_DEBUG_OP ARG_NONE -#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF) -#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING) -#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE -#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF) -#define ARGI_DWORD_OP ARGI_INVALID_OPCODE -#define ARGI_ELSE_OP ARGI_INVALID_OPCODE -#define ARGI_EVENT_OP ARGI_INVALID_OPCODE -#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_FIELD_OP ARGI_INVALID_OPCODE -#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_IF_OP ARGI_INVALID_OPCODE -#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_INTEGER_REF) -#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_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_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 -#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_FIELD,ARGI_TARGETREF) -#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE) -#define ARGI_LOCAL0 ARG_NONE -#define ARGI_LOCAL1 ARG_NONE -#define ARGI_LOCAL2 ARG_NONE -#define ARGI_LOCAL3 ARG_NONE -#define ARGI_LOCAL4 ARG_NONE -#define ARGI_LOCAL5 ARG_NONE -#define ARGI_LOCAL6 ARG_NONE -#define ARGI_LOCAL7 ARG_NONE -#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_METHOD_OP ARGI_INVALID_OPCODE -#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE -#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) -#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE -#define ARGI_NAME_OP ARGI_INVALID_OPCODE -#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE -#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE -#define ARGI_NOOP_OP ARG_NONE -#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER) -#define ARGI_ONE_OP ARG_NONE -#define ARGI_ONES_OP ARG_NONE -#define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) -#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE -#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE -#define ARGI_QWORD_OP ARGI_INVALID_OPCODE -#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF) -#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) -#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX) -#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE -#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT) -#define ARGI_RETURN_OP ARGI_INVALID_OPCODE -#define ARGI_REVISION_OP ARG_NONE -#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE -#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_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 -#define ARGI_STORE_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_TARGETREF) -#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_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) -#define ARGI_WHILE_OP ARGI_INVALID_OPCODE -#define ARGI_WORD_OP ARGI_INVALID_OPCODE -#define ARGI_ZERO_OP ARG_NONE - - /* * Summary of opcode types/flags - */ - -/****************************************************************************** + * Opcodes that have associated namespace objects (AML_NSOBJECT flag) @@ -533,14 +252,13 @@ AML_CREATE_DWORD_FIELD_OP AML_CREATE_QWORD_FIELD_OP -******************************************************************************/ + ******************************************************************************/ /* - * Master Opcode information table. A summary of everything we know about each opcode, all in one place. + * Master Opcode information table. A summary of everything we know about each + * opcode, all in one place. */ - - const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = { /*! [Begin] no source code translation */ @@ -594,14 +312,14 @@ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = /* 2D */ ACPI_OP ("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), /* 2E */ ACPI_OP ("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), /* 2F */ ACPI_OP ("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R), -/* 30 */ ACPI_OP ("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), -/* 31 */ ACPI_OP ("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 30 */ ACPI_OP ("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), +/* 31 */ ACPI_OP ("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R), /* 32 */ ACPI_OP ("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT), /* 33 */ ACPI_OP ("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), /* 34 */ ACPI_OP ("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), /* 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), +/* 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 | AML_NO_OPERAND_RESOLVE), /* 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), @@ -666,7 +384,7 @@ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = /* 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), -/* 6F */ ACPI_OP ("Package /*Var*/", ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER), +/* 6F */ ACPI_OP ("Package", /* Var */ ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER), /* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), /* 71 */ ACPI_OP ("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), /* 72 */ ACPI_OP ("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), @@ -766,8 +484,7 @@ static const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] = * * PARAMETERS: Opcode - The AML opcode * - * RETURN: A pointer to the info about the opcode. NULL if the opcode was - * not found in the table. + * RETURN: A pointer to the info about the opcode. * * DESCRIPTION: Find AML opcode description based on the opcode. * NOTE: This procedure must ALWAYS return a valid pointer! @@ -784,34 +501,25 @@ AcpiPsGetOpcodeInfo ( /* * Detect normal 8-bit opcode or extended 16-bit opcode */ - switch ((UINT8) (Opcode >> 8)) + if (!(Opcode & 0xFF00)) { - case 0: - /* Simple (8-bit) opcode: 0-255, can't index beyond table */ return (&AcpiGbl_AmlOpInfo [AcpiGbl_ShortOpIndex [(UINT8) Opcode]]); + } - case AML_EXTOP: - - /* Extended (16-bit, prefix+opcode) opcode */ - - if (((UINT8) Opcode) <= MAX_EXTENDED_OPCODE) - { - return (&AcpiGbl_AmlOpInfo [AcpiGbl_LongOpIndex [(UINT8) Opcode]]); - } - - /* Else fall through to error case below */ - /*lint -fallthrough */ - - default: + if (((Opcode & 0xFF00) == AML_EXTENDED_OPCODE) && + (((UINT8) Opcode) <= MAX_EXTENDED_OPCODE)) + { + /* Valid extended (16-bit) opcode */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown AML opcode [%4.4X]\n", Opcode)); - break; + return (&AcpiGbl_AmlOpInfo [AcpiGbl_LongOpIndex [(UINT8) Opcode]]); } + /* Unknown AML opcode */ - /* Default is "unknown opcode" */ + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown AML opcode [%4.4X]\n", Opcode)); return (&AcpiGbl_AmlOpInfo [_UNK]); } diff --git a/sys/contrib/dev/acpica/psparse.c b/sys/contrib/dev/acpica/psparse.c index 9a62670..8260329 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: 146 $ + * $Revision: 1.158 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -135,9 +135,6 @@ ACPI_MODULE_NAME ("psparse") -static UINT32 AcpiGbl_Depth = 0; - - /******************************************************************************* * * FUNCTION: AcpiPsGetOpcodeSize @@ -174,7 +171,7 @@ AcpiPsGetOpcodeSize ( * * PARAMETERS: ParserState - A parser state object * - * RETURN: Status + * RETURN: Next AML opcode * * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) * @@ -191,10 +188,9 @@ AcpiPsPeekOpcode ( Aml = ParserState->Aml; Opcode = (UINT16) ACPI_GET8 (Aml); - - if (Opcode == AML_EXTOP) + if (Opcode == AML_EXTENDED_OP_PREFIX) { - /* Extended opcode */ + /* Extended opcode, get the second opcode byte */ Aml++; Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml)); @@ -211,13 +207,13 @@ AcpiPsPeekOpcode ( * PARAMETERS: WalkState - Current State * Op - Op to complete * - * RETURN: None. + * RETURN: Status * * DESCRIPTION: Perform any cleanup at the completion of an Op. * ******************************************************************************/ -void +ACPI_STATUS AcpiPsCompleteThisOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) @@ -235,7 +231,7 @@ AcpiPsCompleteThisOp ( if (!Op) { - return_VOID; + return_ACPI_STATUS (AE_OK); /* OK for now */ } /* Delete this op and the subtree below it if asked to */ @@ -243,18 +239,26 @@ AcpiPsCompleteThisOp ( if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) || (WalkState->OpInfo->Class == AML_CLASS_ARGUMENT)) { - return_VOID; + return_ACPI_STATUS (AE_OK); } /* Make sure that we only delete this subtree */ if (Op->Common.Parent) { + Prev = Op->Common.Parent->Common.Value.Arg; + if (!Prev) + { + /* Nothing more to do */ + + goto Cleanup; + } + /* * 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); + ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); switch (ParentInfo->Class) { @@ -270,7 +274,7 @@ AcpiPsCompleteThisOp ( ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); if (!ReplacementOp) { - goto Cleanup; + goto AllocateError; } break; @@ -289,13 +293,11 @@ AcpiPsCompleteThisOp ( ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); if (!ReplacementOp) { - goto Cleanup; + goto AllocateError; } } - - if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && - (WalkState->DescendingCallback != AcpiDsExecBeginOp)) - + else if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && + (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2)) { if ((Op->Common.AmlOpcode == AML_BUFFER_OP) || (Op->Common.AmlOpcode == AML_PACKAGE_OP) || @@ -304,7 +306,7 @@ AcpiPsCompleteThisOp ( ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode); if (!ReplacementOp) { - goto Cleanup; + goto AllocateError; } ReplacementOp->Named.Data = Op->Named.Data; @@ -314,16 +316,16 @@ AcpiPsCompleteThisOp ( break; default: + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); if (!ReplacementOp) { - goto Cleanup; + goto AllocateError; } } /* We must unlink this op from the parent tree */ - Prev = Op->Common.Parent->Common.Value.Arg; if (Prev == Op) { /* This op is the first in the list */ @@ -366,7 +368,6 @@ AcpiPsCompleteThisOp ( Next = NULL; } } - Prev = Next; } } @@ -374,10 +375,18 @@ AcpiPsCompleteThisOp ( Cleanup: - /* Now we can actually delete the subtree rooted at op */ + /* Now we can actually delete the subtree rooted at Op */ + + AcpiPsDeleteParseTree (Op); + return_ACPI_STATUS (AE_OK); + + +AllocateError: + + /* Always delete the subtree, even on error */ AcpiPsDeleteParseTree (Op); - return_VOID; + return_ACPI_STATUS (AE_NO_MEMORY); } @@ -385,7 +394,9 @@ Cleanup: * * FUNCTION: AcpiPsNextParseState * - * PARAMETERS: ParserState - Current parser state object + * PARAMETERS: WalkState - Current state + * Op - Current parse op + * CallbackStatus - Status from previous operation * * RETURN: Status * @@ -477,9 +488,8 @@ AcpiPsNextParseState ( case AE_CTRL_TRANSFER: - /* - * A method call (invocation) -- transfer control - */ + /* A method call (invocation) -- transfer control */ + Status = AE_CTRL_TRANSFER; WalkState->PrevOp = Op; WalkState->MethodCallOp = Op; @@ -492,6 +502,7 @@ AcpiPsNextParseState ( default: + Status = CallbackStatus; if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL) { @@ -506,715 +517,9 @@ AcpiPsNextParseState ( /******************************************************************************* * - * FUNCTION: AcpiPsParseLoop - * - * PARAMETERS: ParserState - Current parser state object - * - * RETURN: Status - * - * DESCRIPTION: Parse AML (pointed to by the current parser state) and return - * a tree of ops. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiPsParseLoop ( - ACPI_WALK_STATE *WalkState) -{ - ACPI_STATUS Status = AE_OK; - ACPI_PARSE_OBJECT *Op = NULL; /* current op */ - ACPI_PARSE_OBJECT *Arg = NULL; - ACPI_PARSE_OBJECT *PreOp = NULL; - ACPI_PARSE_STATE *ParserState; - UINT8 *AmlOpStart = NULL; - - - ACPI_FUNCTION_TRACE_PTR ("PsParseLoop", WalkState); - - if (WalkState->DescendingCallback == NULL) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - ParserState = &WalkState->ParserState; - WalkState->ArgTypes = 0; - -#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) - if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART) - { - /* We are restarting a preempted control method */ - - if (AcpiPsHasCompletedScope (ParserState)) - { - /* - * We must check if a predicate to an IF or WHILE statement - * was just completed - */ - if ((ParserState->Scope->ParseScope.Op) && - ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) || - (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) && - (WalkState->ControlState) && - (WalkState->ControlState->Common.State == - ACPI_CONTROL_PREDICATE_EXECUTING)) - { - /* - * A predicate was just completed, get the value of the - * predicate and branch based on that value - */ - WalkState->Op = NULL; - Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE)); - if (ACPI_FAILURE (Status) && - ((Status & AE_CODE_MASK) != AE_CODE_CONTROL)) - { - if (Status == AE_AML_NO_RETURN_VALUE) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invoked method did not return a value, %s\n", - AcpiFormatException (Status))); - - } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "GetPredicate Failed, %s\n", - AcpiFormatException (Status))); - return_ACPI_STATUS (Status); - } - - Status = AcpiPsNextParseState (WalkState, Op, Status); - } - - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op)); - } - else if (WalkState->PrevOp) - { - /* We were in the middle of an op */ - - Op = WalkState->PrevOp; - WalkState->ArgTypes = WalkState->PrevArgTypes; - } - } -#endif - - /* - * Iterative parsing loop, while there is more aml to process: - */ - while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) - { - AmlOpStart = ParserState->Aml; - if (!Op) - { - /* Get the next opcode from the AML stream */ - - WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (ParserState->Aml, - ParserState->AmlStart); - WalkState->Opcode = AcpiPsPeekOpcode (ParserState); - - /* - * First cut to determine what we have found: - * 1) A valid AML opcode - * 2) A name string - * 3) An unknown/invalid opcode - */ - WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); - switch (WalkState->OpInfo->Class) - { - case AML_CLASS_ASCII: - case AML_CLASS_PREFIX: - /* - * Starts with a valid prefix or ASCII char, this is a name - * string. Convert the bare name string to a namepath. - */ - WalkState->Opcode = AML_INT_NAMEPATH_OP; - WalkState->ArgTypes = ARGP_NAMESTRING; - break; - - case AML_CLASS_UNKNOWN: - - /* The opcode is unrecognized. Just skip unknown opcodes */ - - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Found unknown opcode %X at AML address %p offset %X, ignoring\n", - WalkState->Opcode, ParserState->Aml, WalkState->AmlOffset)); - - ACPI_DUMP_BUFFER (ParserState->Aml, 128); - - /* Assume one-byte bad opcode */ - - ParserState->Aml++; - continue; - - default: - - /* Found opcode info, this is a normal opcode */ - - ParserState->Aml += AcpiPsGetOpcodeSize (WalkState->Opcode); - WalkState->ArgTypes = WalkState->OpInfo->ParseArgs; - break; - } - - /* Create Op structure and append to parent's argument list */ - - if (WalkState->OpInfo->Flags & AML_NAMED) - { - /* Allocate a new PreOp if necessary */ - - if (!PreOp) - { - PreOp = AcpiPsAllocOp (WalkState->Opcode); - if (!PreOp) - { - Status = AE_NO_MEMORY; - goto CloseThisOp; - } - } - - PreOp->Common.Value.Arg = NULL; - PreOp->Common.AmlOpcode = WalkState->Opcode; - - /* - * Get and append arguments until we find the node that contains - * the name (the type ARGP_NAME). - */ - while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && - (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME)) - { - Status = AcpiPsGetNextArg (WalkState, ParserState, - GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); - if (ACPI_FAILURE (Status)) - { - goto CloseThisOp; - } - - AcpiPsAppendArg (PreOp, Arg); - INCREMENT_ARG_LIST (WalkState->ArgTypes); - } - - /* Make sure that we found a NAME and didn't run out of arguments */ - - if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes)) - { - Status = AE_AML_NO_OPERAND; - goto CloseThisOp; - } - - /* We know that this arg is a name, move to next arg */ - - INCREMENT_ARG_LIST (WalkState->ArgTypes); - - /* - * Find the object. This will either insert the object into - * the namespace or simply look it up - */ - WalkState->Op = NULL; - - Status = WalkState->DescendingCallback (WalkState, &Op); - if (ACPI_FAILURE (Status)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "During name lookup/catalog, %s\n", - AcpiFormatException (Status))); - goto CloseThisOp; - } - - if (Op == NULL) - { - continue; - } - - Status = AcpiPsNextParseState (WalkState, Op, Status); - if (Status == AE_CTRL_PENDING) - { - Status = AE_OK; - goto CloseThisOp; - } - - if (ACPI_FAILURE (Status)) - { - goto CloseThisOp; - } - - AcpiPsAppendArg (Op, PreOp->Common.Value.Arg); - AcpiGbl_Depth++; - - if (Op->Common.AmlOpcode == AML_REGION_OP) - { - /* - * Defer final parsing of an OperationRegion body, - * because we don't have enough info in the first pass - * to parse it correctly (i.e., there may be method - * calls within the TermArg elements of the body.) - * - * However, we must continue parsing because - * the opregion is not a standalone package -- - * we don't know where the end is at this point. - * - * (Length is unknown until parse of the body complete) - */ - Op->Named.Data = AmlOpStart; - Op->Named.Length = 0; - } - } - else - { - /* Not a named opcode, just allocate Op and append to parent */ - - WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); - Op = AcpiPsAllocOp (WalkState->Opcode); - if (!Op) - { - Status = AE_NO_MEMORY; - goto CloseThisOp; - } - - if (WalkState->OpInfo->Flags & AML_CREATE) - { - /* - * Backup to beginning of CreateXXXfield declaration - * BodyLength is unknown until we parse the body - */ - Op->Named.Data = AmlOpStart; - Op->Named.Length = 0; - } - - AcpiPsAppendArg (AcpiPsGetParentScope (ParserState), Op); - - if ((WalkState->DescendingCallback != NULL)) - { - /* - * Find the object. This will either insert the object into - * the namespace or simply look it up - */ - WalkState->Op = Op; - - Status = WalkState->DescendingCallback (WalkState, &Op); - Status = AcpiPsNextParseState (WalkState, Op, Status); - if (Status == AE_CTRL_PENDING) - { - Status = AE_OK; - goto CloseThisOp; - } - - if (ACPI_FAILURE (Status)) - { - goto CloseThisOp; - } - } - } - - Op->Common.AmlOffset = WalkState->AmlOffset; - - if (WalkState->OpInfo) - { - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n", - (UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name, - Op, ParserState->Aml, Op->Common.AmlOffset)); - } - } - - - /* Start ArgCount at zero because we don't know if there are any args yet */ - - WalkState->ArgCount = 0; - - if (WalkState->ArgTypes) /* Are there any arguments that must be processed? */ - { - /* Get arguments */ - - switch (Op->Common.AmlOpcode) - { - case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ - case AML_WORD_OP: /* AML_WORDDATA_ARG */ - case AML_DWORD_OP: /* AML_DWORDATA_ARG */ - case AML_QWORD_OP: /* AML_QWORDATA_ARG */ - case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ - - /* Fill in constant or string argument directly */ - - AcpiPsGetNextSimpleArg (ParserState, - GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op); - break; - - case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ - - Status = AcpiPsGetNextNamepath (WalkState, ParserState, Op, 1); - if (ACPI_FAILURE (Status)) - { - goto CloseThisOp; - } - - WalkState->ArgTypes = 0; - break; - - default: - - /* Op is not a constant or string, append each argument to the Op */ - - while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && - !WalkState->ArgCount) - { - WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (ParserState->Aml, - ParserState->AmlStart); - Status = AcpiPsGetNextArg (WalkState, ParserState, - GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); - if (ACPI_FAILURE (Status)) - { - goto CloseThisOp; - } - - if (Arg) - { - Arg->Common.AmlOffset = WalkState->AmlOffset; - AcpiPsAppendArg (Op, Arg); - } - INCREMENT_ARG_LIST (WalkState->ArgTypes); - } - - /* Special processing for certain opcodes */ - - switch (Op->Common.AmlOpcode) - { - case AML_METHOD_OP: - - /* - * Skip parsing of control method - * because we don't have enough info in the first pass - * to parse it correctly. - * - * Save the length and address of the body - */ - Op->Named.Data = ParserState->Aml; - Op->Named.Length = (UINT32) (ParserState->PkgEnd - ParserState->Aml); - - /* Skip body of method */ - - ParserState->Aml = ParserState->PkgEnd; - WalkState->ArgCount = 0; - break; - - case AML_BUFFER_OP: - case AML_PACKAGE_OP: - case AML_VAR_PACKAGE_OP: - - if ((Op->Common.Parent) && - (Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && - (WalkState->DescendingCallback != AcpiDsExecBeginOp)) - { - /* - * Skip parsing of Buffers and Packages - * because we don't have enough info in the first pass - * to parse them correctly. - */ - Op->Named.Data = AmlOpStart; - Op->Named.Length = (UINT32) (ParserState->PkgEnd - AmlOpStart); - - /* Skip body */ - - ParserState->Aml = ParserState->PkgEnd; - WalkState->ArgCount = 0; - } - break; - - case AML_WHILE_OP: - - if (WalkState->ControlState) - { - WalkState->ControlState->Control.PackageEnd = ParserState->PkgEnd; - } - break; - - default: - - /* No action for all other opcodes */ - break; - } - break; - } - } - - /* Check for arguments that need to be processed */ - - if (WalkState->ArgCount) - { - /* There are arguments (complex ones), push Op and prepare for argument */ - - Status = AcpiPsPushScope (ParserState, Op, - WalkState->ArgTypes, WalkState->ArgCount); - if (ACPI_FAILURE (Status)) - { - goto CloseThisOp; - } - Op = NULL; - continue; - } - - /* All arguments have been processed -- Op is complete, prepare for next */ - - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - if (WalkState->OpInfo->Flags & AML_NAMED) - { - if (AcpiGbl_Depth) - { - AcpiGbl_Depth--; - } - - if (Op->Common.AmlOpcode == AML_REGION_OP) - { - /* - * Skip parsing of control method or opregion body, - * because we don't have enough info in the first pass - * to parse them correctly. - * - * Completed parsing an OpRegion declaration, we now - * know the length. - */ - Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); - } - } - - if (WalkState->OpInfo->Flags & AML_CREATE) - { - /* - * Backup to beginning of CreateXXXfield declaration (1 for - * Opcode) - * - * BodyLength is unknown until we parse the body - */ - Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); - } - - /* This op complete, notify the dispatcher */ - - if (WalkState->AscendingCallback != NULL) - { - WalkState->Op = Op; - WalkState->Opcode = Op->Common.AmlOpcode; - - Status = WalkState->AscendingCallback (WalkState); - Status = AcpiPsNextParseState (WalkState, Op, Status); - if (Status == AE_CTRL_PENDING) - { - Status = AE_OK; - goto CloseThisOp; - } - } - - -CloseThisOp: - /* - * Finished one argument of the containing scope - */ - ParserState->Scope->ParseScope.ArgCount--; - - /* Close this Op (will result in parse subtree deletion) */ - - AcpiPsCompleteThisOp (WalkState, Op); - Op = NULL; - if (PreOp) - { - AcpiPsFreeOp (PreOp); - PreOp = NULL; - } - - switch (Status) - { - case AE_OK: - break; - - - case AE_CTRL_TRANSFER: - - /* - * We are about to transfer to a called method. - */ - WalkState->PrevOp = Op; - WalkState->PrevArgTypes = WalkState->ArgTypes; - return_ACPI_STATUS (Status); - - - case AE_CTRL_END: - - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); - - if (Op) - { - WalkState->Op = Op; - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - WalkState->Opcode = Op->Common.AmlOpcode; - - Status = WalkState->AscendingCallback (WalkState); - Status = AcpiPsNextParseState (WalkState, Op, Status); - - AcpiPsCompleteThisOp (WalkState, Op); - Op = NULL; - } - Status = AE_OK; - break; - - - case AE_CTRL_BREAK: - case AE_CTRL_CONTINUE: - - /* Pop off scopes until we find the While */ - - while (!Op || (Op->Common.AmlOpcode != AML_WHILE_OP)) - { - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); - } - - /* Close this iteration of the While loop */ - - WalkState->Op = Op; - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - WalkState->Opcode = Op->Common.AmlOpcode; - - Status = WalkState->AscendingCallback (WalkState); - Status = AcpiPsNextParseState (WalkState, Op, Status); - - AcpiPsCompleteThisOp (WalkState, Op); - Op = NULL; - - Status = AE_OK; - break; - - - case AE_CTRL_TERMINATE: - - Status = AE_OK; - - /* Clean up */ - do - { - if (Op) - { - AcpiPsCompleteThisOp (WalkState, Op); - } - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); - - } while (Op); - - return_ACPI_STATUS (Status); - - - default: /* All other non-AE_OK status */ - - do - { - if (Op) - { - AcpiPsCompleteThisOp (WalkState, Op); - } - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); - - } while (Op); - - - /* - * TBD: Cleanup parse ops on error - */ -#if 0 - if (Op == NULL) - { - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); - } -#endif - WalkState->PrevOp = Op; - WalkState->PrevArgTypes = WalkState->ArgTypes; - return_ACPI_STATUS (Status); - } - - /* This scope complete? */ - - if (AcpiPsHasCompletedScope (ParserState)) - { - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op)); - } - else - { - Op = NULL; - } - - } /* while ParserState->Aml */ - - - /* - * Complete the last Op (if not completed), and clear the scope stack. - * It is easily possible to end an AML "package" with an unbounded number - * of open scopes (such as when several ASL blocks are closed with - * sequential closing braces). We want to terminate each one cleanly. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op)); - do - { - if (Op) - { - if (WalkState->AscendingCallback != NULL) - { - WalkState->Op = Op; - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - WalkState->Opcode = Op->Common.AmlOpcode; - - Status = WalkState->AscendingCallback (WalkState); - Status = AcpiPsNextParseState (WalkState, Op, Status); - if (Status == AE_CTRL_PENDING) - { - Status = AE_OK; - goto CloseThisOp; - } - - if (Status == AE_CTRL_TERMINATE) - { - Status = AE_OK; - - /* Clean up */ - do - { - if (Op) - { - AcpiPsCompleteThisOp (WalkState, Op); - } - - AcpiPsPopScope (ParserState, &Op, - &WalkState->ArgTypes, &WalkState->ArgCount); - - } while (Op); - - return_ACPI_STATUS (Status); - } - - else if (ACPI_FAILURE (Status)) - { - AcpiPsCompleteThisOp (WalkState, Op); - return_ACPI_STATUS (Status); - } - } - - AcpiPsCompleteThisOp (WalkState, Op); - } - - AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes, - &WalkState->ArgCount); - - } while (Op); - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * * FUNCTION: AcpiPsParseAml * - * PARAMETERS: StartScope - The starting point of the parse. Becomes the - * root of the parsed op tree. - * Aml - Pointer to the raw AML code to parse - * AmlSize - Length of the AML to parse + * PARAMETERS: WalkState - Current state * * * RETURN: Status @@ -1228,7 +533,6 @@ AcpiPsParseAml ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; - ACPI_STATUS TerminateStatus; ACPI_THREAD_STATE *Thread; ACPI_THREAD_STATE *PrevWalkList = AcpiGbl_CurrentWalkList; ACPI_WALK_STATE *PreviousWalkState; @@ -1236,8 +540,10 @@ AcpiPsParseAml ( ACPI_FUNCTION_TRACE ("PsParseAml"); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Entered with WalkState=%p Aml=%p size=%X\n", - WalkState, WalkState->ParserState.Aml, WalkState->ParserState.AmlSize)); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Entered with WalkState=%p Aml=%p size=%X\n", + WalkState, WalkState->ParserState.Aml, + WalkState->ParserState.AmlSize)); /* Create and initialize a new thread state */ @@ -1303,31 +609,26 @@ AcpiPsParseAml ( ACPI_REPORT_METHOD_ERROR ("Method execution failed", WalkState->MethodNode, NULL, Status); + /* Ensure proper cleanup */ + + WalkState->ParseFlags |= ACPI_PARSE_EXECUTE; + /* Check for possible multi-thread reentrancy problem */ if ((Status == AE_ALREADY_EXISTS) && (!WalkState->MethodDesc->Method.Semaphore)) { /* - * This method is marked NotSerialized, but it tried to create a named - * object, causing the second thread entrance to fail. We will workaround - * this by marking the method permanently as Serialized. + * This method is marked NotSerialized, but it tried to create + * a named object, causing the second thread entrance to fail. + * We will workaround this by marking the method permanently + * as Serialized. */ WalkState->MethodDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED; WalkState->MethodDesc->Method.Concurrency = 1; } } - if (WalkState->MethodDesc) - { - /* Decrement the thread count on the method parse tree */ - - if (WalkState->MethodDesc->Method.ThreadCount) - { - WalkState->MethodDesc->Method.ThreadCount--; - } - } - /* We are done with this walk, move on to the parent if any */ WalkState = AcpiDsPopWalkState (Thread); @@ -1342,14 +643,14 @@ AcpiPsParseAml ( */ if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) { - TerminateStatus = AcpiDsTerminateControlMethod (WalkState); - if (ACPI_FAILURE (TerminateStatus)) + if (WalkState->MethodDesc) { - ACPI_REPORT_ERROR (( - "Could not terminate control method properly\n")); + /* Decrement the thread count on the method parse tree */ - /* Ignore error and continue */ + WalkState->MethodDesc->Method.ThreadCount--; } + + AcpiDsTerminateControlMethod (WalkState); } /* Delete this walk state and all linked control states */ @@ -1358,8 +659,9 @@ AcpiPsParseAml ( PreviousWalkState = WalkState; - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "ReturnValue=%p, State=%p\n", - WalkState->ReturnDesc, WalkState)); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "ReturnValue=%p, ImplicitValue=%p State=%p\n", + WalkState->ReturnDesc, WalkState->ImplicitReturnObj, WalkState)); /* Check if we have restarted a preempted walk */ @@ -1373,8 +675,22 @@ AcpiPsParseAml ( * If the method return value is not used by the parent, * The object is deleted */ - Status = AcpiDsRestartControlMethod (WalkState, - PreviousWalkState->ReturnDesc); + if (!PreviousWalkState->ReturnDesc) + { + Status = AcpiDsRestartControlMethod (WalkState, + PreviousWalkState->ImplicitReturnObj); + } + else + { + /* + * We have a valid return value, delete any implicit + * return value. + */ + AcpiDsClearImplicitReturn (PreviousWalkState); + + Status = AcpiDsRestartControlMethod (WalkState, + PreviousWalkState->ReturnDesc); + } if (ACPI_SUCCESS (Status)) { WalkState->WalkType |= ACPI_WALK_METHOD_RESTART; @@ -1394,13 +710,33 @@ AcpiPsParseAml ( */ else if (PreviousWalkState->CallerReturnDesc) { - *(PreviousWalkState->CallerReturnDesc) = PreviousWalkState->ReturnDesc; /* NULL if no return value */ + if (PreviousWalkState->ImplicitReturnObj) + { + *(PreviousWalkState->CallerReturnDesc) = + PreviousWalkState->ImplicitReturnObj; + } + else + { + /* NULL if no return value */ + + *(PreviousWalkState->CallerReturnDesc) = + PreviousWalkState->ReturnDesc; + } } - else if (PreviousWalkState->ReturnDesc) + else { - /* Caller doesn't want it, must delete it */ + if (PreviousWalkState->ReturnDesc) + { + /* Caller doesn't want it, must delete it */ - AcpiUtRemoveReference (PreviousWalkState->ReturnDesc); + AcpiUtRemoveReference (PreviousWalkState->ReturnDesc); + } + if (PreviousWalkState->ImplicitReturnObj) + { + /* Caller doesn't want it, must delete it */ + + AcpiUtRemoveReference (PreviousWalkState->ImplicitReturnObj); + } } AcpiDsDeleteWalkState (PreviousWalkState); diff --git a/sys/contrib/dev/acpica/psscope.c b/sys/contrib/dev/acpica/psscope.c index 786838b..0065910 100644 --- a/sys/contrib/dev/acpica/psscope.c +++ b/sys/contrib/dev/acpica/psscope.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psscope - Parser scope stack management routines - * $Revision: 38 $ + * $Revision: 1.42 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -138,6 +138,7 @@ ACPI_PARSE_OBJECT * AcpiPsGetParentScope ( ACPI_PARSE_STATE *ParserState) { + return (ParserState->Scope->ParseScope.Op); } @@ -160,8 +161,10 @@ BOOLEAN AcpiPsHasCompletedScope ( ACPI_PARSE_STATE *ParserState) { - return ((BOOLEAN) ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd || - !ParserState->Scope->ParseScope.ArgCount))); + + return ((BOOLEAN) + ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd || + !ParserState->Scope->ParseScope.ArgCount))); } @@ -242,11 +245,11 @@ AcpiPsPushScope ( return_ACPI_STATUS (AE_NO_MEMORY); } - Scope->Common.DataType = ACPI_DESC_TYPE_STATE_PSCOPE; - Scope->ParseScope.Op = Op; - Scope->ParseScope.ArgList = RemainingArgs; - Scope->ParseScope.ArgCount = ArgCount; - Scope->ParseScope.PkgEnd = ParserState->PkgEnd; + Scope->Common.DataType = ACPI_DESC_TYPE_STATE_PSCOPE; + Scope->ParseScope.Op = Op; + Scope->ParseScope.ArgList = RemainingArgs; + Scope->ParseScope.ArgCount = ArgCount; + Scope->ParseScope.PkgEnd = ParserState->PkgEnd; /* Push onto scope stack */ @@ -254,13 +257,13 @@ AcpiPsPushScope ( if (ArgCount == ACPI_VAR_ARGS) { - /* multiple arguments */ + /* Multiple arguments */ Scope->ParseScope.ArgEnd = ParserState->PkgEnd; } else { - /* single argument */ + /* Single argument */ Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR); } @@ -298,19 +301,18 @@ AcpiPsPopScope ( ACPI_FUNCTION_TRACE ("PsPopScope"); - /* - * Only pop the scope if there is in fact a next scope - */ + /* Only pop the scope if there is in fact a next scope */ + if (Scope->Common.Next) { Scope = AcpiUtPopGenericState (&ParserState->Scope); /* return to parsing previous op */ - *Op = Scope->ParseScope.Op; - *ArgList = Scope->ParseScope.ArgList; - *ArgCount = Scope->ParseScope.ArgCount; - ParserState->PkgEnd = Scope->ParseScope.PkgEnd; + *Op = Scope->ParseScope.Op; + *ArgList = Scope->ParseScope.ArgList; + *ArgCount = Scope->ParseScope.ArgCount; + ParserState->PkgEnd = Scope->ParseScope.PkgEnd; /* All done with this scope state structure */ @@ -320,12 +322,13 @@ AcpiPsPopScope ( { /* empty parse stack, prepare to fetch next opcode */ - *Op = NULL; - *ArgList = 0; - *ArgCount = 0; + *Op = NULL; + *ArgList = 0; + *ArgCount = 0; } - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped Op %p Args %X\n", *Op, *ArgCount)); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Popped Op %p Args %X\n", *Op, *ArgCount)); return_VOID; } @@ -336,7 +339,7 @@ AcpiPsPopScope ( * * PARAMETERS: ParserState - Current parser state object * - * RETURN: Status + * RETURN: None * * DESCRIPTION: Destroy available list, remaining stack levels, and return * root scope diff --git a/sys/contrib/dev/acpica/pstree.c b/sys/contrib/dev/acpica/pstree.c index bcd7414..61e0602 100644 --- a/sys/contrib/dev/acpica/pstree.c +++ b/sys/contrib/dev/acpica/pstree.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: pstree - Parser op tree manipulation/traversal/search - * $Revision: 42 $ + * $Revision: 1.46 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,6 +124,14 @@ #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("pstree") +/* Local prototypes */ + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *op); +#endif + /******************************************************************************* * @@ -132,7 +140,7 @@ * PARAMETERS: Op - Get an argument for this op * Argn - Nth argument to get * - * RETURN: The argument (as an Op object). NULL if argument does not exist + * RETURN: The argument (as an Op object). NULL if argument does not exist * * DESCRIPTION: Get the specified op's argument. * @@ -233,7 +241,6 @@ AcpiPsAppendArg ( return; } - /* Append the argument to the linked argument list */ if (Op->Common.Value.Arg) @@ -247,7 +254,6 @@ AcpiPsAppendArg ( } PrevArg->Common.Next = Arg; } - else { /* No argument list, this will be the first argument */ @@ -255,7 +261,6 @@ AcpiPsAppendArg ( Op->Common.Value.Arg = Arg; } - /* Set the parent in this arg and any args linked after it */ while (Arg) @@ -268,74 +273,6 @@ AcpiPsAppendArg ( /******************************************************************************* * - * FUNCTION: AcpiPsGetChild - * - * PARAMETERS: Op - Get the child of this Op - * - * RETURN: Child Op, Null if none is found. - * - * DESCRIPTION: Get op's children or NULL if none - * - ******************************************************************************/ - -ACPI_PARSE_OBJECT * -AcpiPsGetChild ( - ACPI_PARSE_OBJECT *Op) -{ - ACPI_PARSE_OBJECT *Child = NULL; - - - ACPI_FUNCTION_ENTRY (); - - - switch (Op->Common.AmlOpcode) - { - case AML_SCOPE_OP: - case AML_ELSE_OP: - case AML_DEVICE_OP: - case AML_THERMAL_ZONE_OP: - case AML_INT_METHODCALL_OP: - - Child = AcpiPsGetArg (Op, 0); - break; - - - case AML_BUFFER_OP: - case AML_PACKAGE_OP: - case AML_METHOD_OP: - case AML_IF_OP: - case AML_WHILE_OP: - case AML_FIELD_OP: - - Child = AcpiPsGetArg (Op, 1); - break; - - - case AML_POWER_RES_OP: - case AML_INDEX_FIELD_OP: - - Child = AcpiPsGetArg (Op, 2); - break; - - - case AML_PROCESSOR_OP: - case AML_BANK_FIELD_OP: - - Child = AcpiPsGetArg (Op, 3); - break; - - - default: - /* All others have no children */ - break; - } - - return (Child); -} - - -/******************************************************************************* - * * FUNCTION: AcpiPsGetDepthNext * * PARAMETERS: Origin - Root of subtree to search @@ -366,7 +303,7 @@ AcpiPsGetDepthNext ( return (NULL); } - /* look for an argument or child */ + /* Look for an argument or child */ Next = AcpiPsGetArg (Op, 0); if (Next) @@ -374,7 +311,7 @@ AcpiPsGetDepthNext ( return (Next); } - /* look for a sibling */ + /* Look for a sibling */ Next = Op->Common.Next; if (Next) @@ -382,7 +319,7 @@ AcpiPsGetDepthNext ( return (Next); } - /* look for a sibling of parent */ + /* Look for a sibling of parent */ Parent = Op->Common.Parent; @@ -396,14 +333,14 @@ AcpiPsGetDepthNext ( if (Arg == Origin) { - /* reached parent of origin, end search */ + /* Reached parent of origin, end search */ return (NULL); } if (Parent->Common.Next) { - /* found sibling of parent */ + /* Found sibling of parent */ return (Parent->Common.Next); } @@ -416,3 +353,73 @@ AcpiPsGetDepthNext ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiPsGetChild + * + * PARAMETERS: Op - Get the child of this Op + * + * RETURN: Child Op, Null if none is found. + * + * DESCRIPTION: Get op's children or NULL if none + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Child = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + switch (Op->Common.AmlOpcode) + { + case AML_SCOPE_OP: + case AML_ELSE_OP: + case AML_DEVICE_OP: + case AML_THERMAL_ZONE_OP: + case AML_INT_METHODCALL_OP: + + Child = AcpiPsGetArg (Op, 0); + break; + + + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_METHOD_OP: + case AML_IF_OP: + case AML_WHILE_OP: + case AML_FIELD_OP: + + Child = AcpiPsGetArg (Op, 1); + break; + + + case AML_POWER_RES_OP: + case AML_INDEX_FIELD_OP: + + Child = AcpiPsGetArg (Op, 2); + break; + + + case AML_PROCESSOR_OP: + case AML_BANK_FIELD_OP: + + Child = AcpiPsGetArg (Op, 3); + break; + + + default: + /* All others have no children */ + break; + } + + return (Child); +} +#endif + + diff --git a/sys/contrib/dev/acpica/psutils.c b/sys/contrib/dev/acpica/psutils.c index d42c765..877a8d7 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: 58 $ + * $Revision: 1.66 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -118,7 +118,6 @@ #include <contrib/dev/acpica/acpi.h> #include <contrib/dev/acpica/acparser.h> #include <contrib/dev/acpica/amlcode.h> -#include <contrib/dev/acpica/acnamesp.h> #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psutils") @@ -130,7 +129,7 @@ * * PARAMETERS: None * - * RETURN: ScopeOp + * RETURN: A new Scope object, null on failure * * DESCRIPTION: Create a Scope and associated namepath op with the root name * @@ -149,7 +148,6 @@ AcpiPsCreateScopeOp ( return (NULL); } - ScopeOp->Named.Name = ACPI_ROOT_NAME; return (ScopeOp); } @@ -162,10 +160,9 @@ AcpiPsCreateScopeOp ( * PARAMETERS: Op - A newly allocated Op object * Opcode - Opcode to store in the Op * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on - * opcode + * DESCRIPTION: Initialize a parse (Op) object * ******************************************************************************/ @@ -181,7 +178,8 @@ AcpiPsInitOp ( Op->Common.AmlOpcode = Opcode; ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (Op->Common.AmlOpName, - (AcpiPsGetOpcodeInfo (Opcode))->Name, sizeof (Op->Common.AmlOpName))); + (AcpiPsGetOpcodeInfo (Opcode))->Name, + sizeof (Op->Common.AmlOpName))); } @@ -191,7 +189,7 @@ AcpiPsInitOp ( * * PARAMETERS: Opcode - Opcode that will be stored in the new Op * - * RETURN: Pointer to the new Op. + * RETURN: Pointer to the new Op, null on failure * * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on * opcode. A cache of opcodes is available for the pure @@ -234,13 +232,13 @@ AcpiPsAllocOp ( { /* The generic op (default) is by far the most common (16 to 1) */ - Op = AcpiUtAcquireFromCache (ACPI_MEM_LIST_PSNODE); + Op = AcpiOsAcquireObject (AcpiGbl_PsNodeCache); } else { /* Extended parseop */ - Op = AcpiUtAcquireFromCache (ACPI_MEM_LIST_PSNODE_EXT); + Op = AcpiOsAcquireObject (AcpiGbl_PsNodeExtCache); } /* Initialize the Op */ @@ -282,42 +280,17 @@ AcpiPsFreeOp ( if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) { - AcpiUtReleaseToCache (ACPI_MEM_LIST_PSNODE, Op); + (void) AcpiOsReleaseObject (AcpiGbl_PsNodeCache, Op); } else { - AcpiUtReleaseToCache (ACPI_MEM_LIST_PSNODE_EXT, Op); + (void) AcpiOsReleaseObject (AcpiGbl_PsNodeExtCache, Op); } } /******************************************************************************* * - * FUNCTION: AcpiPsDeleteParseCache - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Free all objects that are on the parse cache list. - * - ******************************************************************************/ - -void -AcpiPsDeleteParseCache ( - void) -{ - ACPI_FUNCTION_TRACE ("PsDeleteParseCache"); - - - AcpiUtDeleteGenericCache (ACPI_MEM_LIST_PSNODE); - AcpiUtDeleteGenericCache (ACPI_MEM_LIST_PSNODE_EXT); - return_VOID; -} - - -/******************************************************************************* - * * FUNCTION: Utility functions * * DESCRIPTION: Low level character and object functions @@ -355,7 +328,6 @@ AcpiPsGetName ( ACPI_PARSE_OBJECT *Op) { - /* The "generic" object has no name associated with it */ if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) diff --git a/sys/contrib/dev/acpica/pswalk.c b/sys/contrib/dev/acpica/pswalk.c index 70e6a88..99beef6 100644 --- a/sys/contrib/dev/acpica/pswalk.c +++ b/sys/contrib/dev/acpica/pswalk.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: pswalk - Parser routines to walk parsed op tree(s) - * $Revision: 70 $ + * $Revision: 1.75 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -117,7 +117,6 @@ #include <contrib/dev/acpica/acpi.h> #include <contrib/dev/acpica/acparser.h> -#include <contrib/dev/acpica/acdispat.h> #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("pswalk") @@ -125,199 +124,6 @@ /******************************************************************************* * - * FUNCTION: AcpiPsGetNextWalkOp - * - * PARAMETERS: WalkState - Current state of the walk - * Op - Current Op to be walked - * AscendingCallback - Procedure called when Op is complete - * - * RETURN: Status - * - * DESCRIPTION: Get the next Op in a walk of the parse tree. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiPsGetNextWalkOp ( - ACPI_WALK_STATE *WalkState, - ACPI_PARSE_OBJECT *Op, - ACPI_PARSE_UPWARDS AscendingCallback) -{ - ACPI_PARSE_OBJECT *Next; - ACPI_PARSE_OBJECT *Parent; - ACPI_PARSE_OBJECT *GrandParent; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_PTR ("PsGetNextWalkOp", Op); - - - /* Check for a argument only if we are descending in the tree */ - - if (WalkState->NextOpInfo != ACPI_NEXT_OP_UPWARD) - { - /* Look for an argument or child of the current op */ - - Next = AcpiPsGetArg (Op, 0); - if (Next) - { - /* Still going downward in tree (Op is not completed yet) */ - - WalkState->PrevOp = Op; - WalkState->NextOp = Next; - WalkState->NextOpInfo = ACPI_NEXT_OP_DOWNWARD; - - return_ACPI_STATUS (AE_OK); - } - - /* - * No more children, this Op is complete. Save Next and Parent - * in case the Op object gets deleted by the callback routine - */ - Next = Op->Common.Next; - Parent = Op->Common.Parent; - - WalkState->Op = Op; - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); - WalkState->Opcode = Op->Common.AmlOpcode; - - Status = AscendingCallback (WalkState); - - /* - * If we are back to the starting point, the walk is complete. - */ - if (Op == WalkState->Origin) - { - /* Reached the point of origin, the walk is complete */ - - WalkState->PrevOp = Op; - WalkState->NextOp = NULL; - - return_ACPI_STATUS (Status); - } - - /* - * Check for a sibling to the current op. A sibling means - * we are still going "downward" in the tree. - */ - if (Next) - { - /* There is a sibling, it will be next */ - - WalkState->PrevOp = Op; - WalkState->NextOp = Next; - WalkState->NextOpInfo = ACPI_NEXT_OP_DOWNWARD; - - /* Continue downward */ - - return_ACPI_STATUS (Status); - } - - /* - * Drop into the loop below because we are moving upwards in - * the tree - */ - } - else - { - /* - * We are resuming a walk, and we were (are) going upward in the tree. - * So, we want to drop into the parent loop below. - */ - Parent = Op; - } - - /* - * Look for a sibling of the current Op's parent - * Continue moving up the tree until we find a node that has not been - * visited, or we get back to where we started. - */ - while (Parent) - { - /* We are moving up the tree, therefore this parent Op is complete */ - - GrandParent = Parent->Common.Parent; - Next = Parent->Common.Next; - - WalkState->Op = Parent; - WalkState->OpInfo = AcpiPsGetOpcodeInfo (Parent->Common.AmlOpcode); - WalkState->Opcode = Parent->Common.AmlOpcode; - - Status = AscendingCallback (WalkState); - - /* - * If we are back to the starting point, the walk is complete. - */ - if (Parent == WalkState->Origin) - { - /* Reached the point of origin, the walk is complete */ - - WalkState->PrevOp = Parent; - WalkState->NextOp = NULL; - - return_ACPI_STATUS (Status); - } - - /* - * If there is a sibling to this parent (it is not the starting point - * Op), then we will visit it. - */ - if (Next) - { - /* found sibling of parent */ - - WalkState->PrevOp = Parent; - WalkState->NextOp = Next; - WalkState->NextOpInfo = ACPI_NEXT_OP_DOWNWARD; - - return_ACPI_STATUS (Status); - } - - /* No siblings, no errors, just move up one more level in the tree */ - - Op = Parent; - Parent = GrandParent; - WalkState->PrevOp = Op; - } - - - /* - * Got all the way to the top of the tree, we must be done! - * However, the code should have terminated in the loop above - */ - WalkState->NextOp = NULL; - - return_ACPI_STATUS (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiPsDeleteCompletedOp - * - * PARAMETERS: State - Walk state - * Op - Completed op - * - * RETURN: AE_OK - * - * DESCRIPTION: Callback function for AcpiPsGetNextWalkOp(). Used during - * AcpiPsDeleteParse tree to delete Op objects when all sub-objects - * have been visited (and deleted.) - * - ******************************************************************************/ - -ACPI_STATUS -AcpiPsDeleteCompletedOp ( - ACPI_WALK_STATE *WalkState) -{ - - AcpiPsFreeOp (WalkState->Op); - return (AE_OK); -} - - -/******************************************************************************* - * * FUNCTION: AcpiPsDeleteParseTree * * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete @@ -332,62 +138,56 @@ void AcpiPsDeleteParseTree ( ACPI_PARSE_OBJECT *SubtreeRoot) { - ACPI_WALK_STATE *WalkState; - ACPI_THREAD_STATE *Thread; - ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op = SubtreeRoot; + ACPI_PARSE_OBJECT *Next = NULL; + ACPI_PARSE_OBJECT *Parent = NULL; ACPI_FUNCTION_TRACE_PTR ("PsDeleteParseTree", SubtreeRoot); - if (!SubtreeRoot) - { - return_VOID; - } - - /* Create and initialize a new walk list */ + /* Visit all nodes in the subtree */ - Thread = AcpiUtCreateThreadState (); - if (!Thread) + while (Op) { - return_VOID; - } + /* Check if we are not ascending */ - WalkState = AcpiDsCreateWalkState (0, NULL, NULL, Thread); - if (!WalkState) - { - return_VOID; - } + if (Op != Parent) + { + /* Look for an argument or child of the current op */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + /* Still going downward in tree (Op is not completed yet) */ - WalkState->ParseFlags = 0; - WalkState->DescendingCallback = NULL; - WalkState->AscendingCallback = NULL; + Op = Next; + continue; + } + } - WalkState->Origin = SubtreeRoot; - WalkState->NextOp = SubtreeRoot; + /* No more children, this Op is complete. */ - /* Head downward in the tree */ + Next = Op->Common.Next; + Parent = Op->Common.Parent; - WalkState->NextOpInfo = ACPI_NEXT_OP_DOWNWARD; + AcpiPsFreeOp (Op); - /* Visit all nodes in the subtree */ + /* If we are back to the starting point, the walk is complete. */ - while (WalkState->NextOp) - { - Status = AcpiPsGetNextWalkOp (WalkState, WalkState->NextOp, - AcpiPsDeleteCompletedOp); - if (ACPI_FAILURE (Status)) + if (Op == SubtreeRoot) + { + return_VOID; + } + if (Next) { - break; + Op = Next; + } + else + { + Op = Parent; } } - /* We are done with this walk */ - - AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread)); - AcpiDsDeleteWalkState (WalkState); - return_VOID; } - - diff --git a/sys/contrib/dev/acpica/psxface.c b/sys/contrib/dev/acpica/psxface.c index e20a8cf..4c202cf 100644 --- a/sys/contrib/dev/acpica/psxface.c +++ b/sys/contrib/dev/acpica/psxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: psxface - Parser external interfaces - * $Revision: 75 $ + * $Revision: 1.84 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -120,213 +120,404 @@ #include <contrib/dev/acpica/acparser.h> #include <contrib/dev/acpica/acdispat.h> #include <contrib/dev/acpica/acinterp.h> -#include <contrib/dev/acpica/acnamesp.h> #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psxface") +/* Local Prototypes */ + +static void +AcpiPsStartTrace ( + ACPI_PARAMETER_INFO *Info); + +static void +AcpiPsStopTrace ( + ACPI_PARAMETER_INFO *Info); + +static ACPI_STATUS +AcpiPsExecutePass ( + ACPI_PARAMETER_INFO *Info); + +static void +AcpiPsUpdateParameterList ( + ACPI_PARAMETER_INFO *Info, + UINT16 Action); + /******************************************************************************* * - * FUNCTION: AcpiPsxExecute + * FUNCTION: AcpiDebugTrace * - * PARAMETERS: Info->Node - A method object containing both the AML - * address and length. - * **Params - List of parameters to pass to method, - * terminated by NULL. Params itself may be - * NULL if no parameters are being passed. - * **ReturnObjDesc - Return object from execution of the - * method. + * PARAMETERS: MethodName - Valid ACPI name string + * DebugLevel - Optional level mask. 0 to use default + * DebugLayer - Optional layer mask. 0 to use default + * Flags - bit 1: one shot(1) or persistent(0) * * RETURN: Status * - * DESCRIPTION: Execute a control method + * DESCRIPTION: External interface to enable debug tracing during control + * method execution * ******************************************************************************/ ACPI_STATUS -AcpiPsxExecute ( +AcpiDebugTrace ( + char *Name, + UINT32 DebugLevel, + UINT32 DebugLayer, + UINT32 Flags) +{ + ACPI_STATUS Status; + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* TBDs: Validate name, allow full path or just nameseg */ + + AcpiGbl_TraceMethodName = *(UINT32 *) Name; + AcpiGbl_TraceFlags = Flags; + + if (DebugLevel) + { + AcpiGbl_TraceDbgLevel = DebugLevel; + } + if (DebugLayer) + { + AcpiGbl_TraceDbgLayer = DebugLayer; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsStartTrace + * + * PARAMETERS: Info - Method info struct + * + * RETURN: None + * + * DESCRIPTION: Start control method execution trace + * + ******************************************************************************/ + +static void +AcpiPsStartTrace ( ACPI_PARAMETER_INFO *Info) { ACPI_STATUS Status; - ACPI_OPERAND_OBJECT *ObjDesc; - UINT32 i; - ACPI_PARSE_OBJECT *Op; - ACPI_WALK_STATE *WalkState; - ACPI_FUNCTION_TRACE ("PsxExecute"); + ACPI_FUNCTION_ENTRY (); - /* Validate the Node and get the attached object */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return; + } - if (!Info || !Info->Node) + if ((!AcpiGbl_TraceMethodName) || + (AcpiGbl_TraceMethodName != Info->Node->Name.Integer)) { - return_ACPI_STATUS (AE_NULL_ENTRY); + goto Exit; } - ObjDesc = AcpiNsGetAttachedObject (Info->Node); - if (!ObjDesc) + AcpiGbl_OriginalDbgLevel = AcpiDbgLevel; + AcpiGbl_OriginalDbgLayer = AcpiDbgLayer; + + AcpiDbgLevel = 0x00FFFFFF; + AcpiDbgLayer = ACPI_UINT32_MAX; + + if (AcpiGbl_TraceDbgLevel) + { + AcpiDbgLevel = AcpiGbl_TraceDbgLevel; + } + if (AcpiGbl_TraceDbgLayer) { - return_ACPI_STATUS (AE_NULL_OBJECT); + AcpiDbgLayer = AcpiGbl_TraceDbgLayer; } - /* Init for new method, wait on concurrency semaphore */ - Status = AcpiDsBeginMethodExecution (Info->Node, ObjDesc, NULL); +Exit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsStopTrace + * + * PARAMETERS: Info - Method info struct + * + * RETURN: None + * + * DESCRIPTION: Stop control method execution trace + * + ******************************************************************************/ + +static void +AcpiPsStopTrace ( + ACPI_PARAMETER_INFO *Info) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { - return_ACPI_STATUS (Status); + return; } - if ((Info->ParameterType == ACPI_PARAM_ARGS) && - (Info->Parameters)) + if ((!AcpiGbl_TraceMethodName) || + (AcpiGbl_TraceMethodName != Info->Node->Name.Integer)) { - /* - * The caller "owns" the parameters, so give each one an extra - * reference - */ - for (i = 0; Info->Parameters[i]; i++) - { - AcpiUtAddReference (Info->Parameters[i]); - } + goto Exit; } - /* - * 1) Perform the first pass parse of the method to enter any - * named objects that it creates into the namespace - */ - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, - "**** Begin Method Parse **** Entry=%p obj=%p\n", - Info->Node, ObjDesc)); + /* Disable further tracing if type is one-shot */ - /* Create and init a Root Node */ - - Op = AcpiPsCreateScopeOp (); - if (!Op) + if (AcpiGbl_TraceFlags & 1) { - Status = AE_NO_MEMORY; - goto Cleanup1; + AcpiGbl_TraceMethodName = 0; + AcpiGbl_TraceDbgLevel = 0; + AcpiGbl_TraceDbgLayer = 0; } - /* - * Get a new OwnerId for objects created by this method. Namespace - * objects (such as Operation Regions) can be created during the - * first pass parse. - */ - ObjDesc->Method.OwningId = AcpiUtAllocateOwnerId (ACPI_OWNER_TYPE_METHOD); + AcpiDbgLevel = AcpiGbl_OriginalDbgLevel; + AcpiDbgLayer = AcpiGbl_OriginalDbgLayer; - /* Create and initialize a new walk state */ +Exit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); +} - WalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwningId, - NULL, NULL, NULL); - if (!WalkState) + +/******************************************************************************* + * + * FUNCTION: AcpiPsExecuteMethod + * + * PARAMETERS: Info - Method info block, contains: + * Node - Method Node to execute + * ObjDesc - Method object + * Parameters - 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. + * ParameterType - Type of Parameter list + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * PassNumber - Parse or execute pass + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsExecuteMethod ( + ACPI_PARAMETER_INFO *Info) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("PsExecuteMethod"); + + + /* Validate the Info and method Node */ + + if (!Info || !Info->Node) { - Status = AE_NO_MEMORY; - goto Cleanup2; + return_ACPI_STATUS (AE_NULL_ENTRY); } - Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node, - ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength, NULL, 1); + /* Init for new method, wait on concurrency semaphore */ + + Status = AcpiDsBeginMethodExecution (Info->Node, Info->ObjDesc, NULL); if (ACPI_FAILURE (Status)) { - goto Cleanup3; + return_ACPI_STATUS (Status); } - /* Parse the AML */ + /* + * The caller "owns" the parameters, so give each one an extra + * reference + */ + AcpiPsUpdateParameterList (Info, REF_INCREMENT); - Status = AcpiPsParseAml (WalkState); - AcpiPsDeleteParseTree (Op); + /* Begin tracing if requested */ + + AcpiPsStartTrace (Info); + + /* + * 1) Perform the first pass parse of the method to enter any + * named objects that it creates into the namespace + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "**** Begin Method Parse **** Entry=%p obj=%p\n", + Info->Node, Info->ObjDesc)); + + Info->PassNumber = 1; + Status = AcpiPsExecutePass (Info); if (ACPI_FAILURE (Status)) { - goto Cleanup1; /* Walk state is already deleted */ + goto Cleanup; } /* - * 2) Execute the method. Performs second pass parse simultaneously + * 2) Execute the method. Performs second pass parse simultaneously */ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Begin Method Execution **** Entry=%p obj=%p\n", - Info->Node, ObjDesc)); + Info->Node, Info->ObjDesc)); - /* Create and init a Root Node */ + Info->PassNumber = 3; + Status = AcpiPsExecutePass (Info); - Op = AcpiPsCreateScopeOp (); - if (!Op) - { - Status = AE_NO_MEMORY; - goto Cleanup1; - } - /* Init new op with the method name and pointer back to the NS node */ +Cleanup: + /* End optional tracing */ - AcpiPsSetName (Op, Info->Node->Name.Integer); - Op->Common.Node = Info->Node; + AcpiPsStopTrace (Info); - /* Create and initialize a new walk state */ + /* Take away the extra reference that we gave the parameters above */ - WalkState = AcpiDsCreateWalkState (0, NULL, NULL, NULL); - if (!WalkState) - { - Status = AE_NO_MEMORY; - goto Cleanup2; - } + AcpiPsUpdateParameterList (Info, REF_DECREMENT); + + /* Exit now if error above */ - Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node, - ObjDesc->Method.AmlStart, - ObjDesc->Method.AmlLength, Info, 3); if (ACPI_FAILURE (Status)) { - goto Cleanup3; + return_ACPI_STATUS (Status); } /* - * The walk of the parse tree is where we actually execute the method + * If the method has returned an object, signal this to the caller with + * a control exception code */ - Status = AcpiPsParseAml (WalkState); - goto Cleanup2; /* Walk state already deleted */ + if (Info->ReturnObject) + { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n", + Info->ReturnObject)); + ACPI_DUMP_STACK_ENTRY (Info->ReturnObject); + Status = AE_CTRL_RETURN_VALUE; + } -Cleanup3: - AcpiDsDeleteWalkState (WalkState); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsUpdateParameterList + * + * PARAMETERS: Info - See ACPI_PARAMETER_INFO + * (Used: ParameterType and Parameters) + * Action - Add or Remove reference + * + * RETURN: Status + * + * DESCRIPTION: Update reference count on all method parameter objects + * + ******************************************************************************/ + +static void +AcpiPsUpdateParameterList ( + ACPI_PARAMETER_INFO *Info, + UINT16 Action) +{ + ACPI_NATIVE_UINT i; -Cleanup2: - AcpiPsDeleteParseTree (Op); -Cleanup1: if ((Info->ParameterType == ACPI_PARAM_ARGS) && (Info->Parameters)) { - /* Take away the extra reference that we gave the parameters above */ + /* Update reference count for each parameter */ for (i = 0; Info->Parameters[i]; i++) { /* Ignore errors, just do them all */ - (void) AcpiUtUpdateObjectReference (Info->Parameters[i], REF_DECREMENT); + (void) AcpiUtUpdateObjectReference (Info->Parameters[i], Action); } } +} - if (ACPI_FAILURE (Status)) + +/******************************************************************************* + * + * FUNCTION: AcpiPsExecutePass + * + * PARAMETERS: Info - See ACPI_PARAMETER_INFO + * (Used: PassNumber, Node, and ObjDesc) + * + * RETURN: Status + * + * DESCRIPTION: Single AML pass: Parse or Execute a control method + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsExecutePass ( + ACPI_PARAMETER_INFO *Info) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE ("PsExecutePass"); + + + /* Create and init a Root Node */ + + Op = AcpiPsCreateScopeOp (); + if (!Op) { - return_ACPI_STATUS (Status); + return_ACPI_STATUS (AE_NO_MEMORY); } - /* - * If the method has returned an object, signal this to the caller with - * a control exception code - */ - if (Info->ReturnObject) + /* Create and initialize a new walk state */ + + WalkState = AcpiDsCreateWalkState ( + Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL); + if (!WalkState) { - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n", - Info->ReturnObject)); - ACPI_DUMP_STACK_ENTRY (Info->ReturnObject); + Status = AE_NO_MEMORY; + goto Cleanup; + } - Status = AE_CTRL_RETURN_VALUE; + Status = AcpiDsInitAmlWalk (WalkState, Op, Info->Node, + Info->ObjDesc->Method.AmlStart, + Info->ObjDesc->Method.AmlLength, + Info->PassNumber == 1 ? NULL : Info, + Info->PassNumber); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; } + /* Parse the AML */ + + Status = AcpiPsParseAml (WalkState); + + /* Walk state was deleted by ParseAml */ + +Cleanup: + AcpiPsDeleteParseTree (Op); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/rsaddr.c b/sys/contrib/dev/acpica/rsaddr.c index 8640e7a..c252978 100644 --- a/sys/contrib/dev/acpica/rsaddr.c +++ b/sys/contrib/dev/acpica/rsaddr.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsaddr - Address resource descriptors (16/32/64) - * $Revision: 35 $ + * $Revision: 1.48 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,1193 +125,355 @@ /******************************************************************************* * - * FUNCTION: AcpiRsAddress16Resource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. + * AcpiRsConvertAddress16 - All WORD (16-bit) address resources * ******************************************************************************/ -ACPI_STATUS -AcpiRsAddress16Resource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[5] = { - UINT8 *Buffer = ByteStreamBuffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT8 *TempPtr; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS16); - UINT32 Index; - UINT16 Temp16; - UINT8 Temp8; - - - ACPI_FUNCTION_TRACE ("RsAddress16Resource"); - - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - Buffer += 1; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - - /* Validate minimum descriptor length */ - - if (Temp16 < 13) - { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); - } - - *BytesConsumed = Temp16 + 3; - OutputStruct->Id = ACPI_RSTYPE_ADDRESS16; - - /* - * Get the Resource Type (Byte3) - */ - Buffer += 2; - Temp8 = *Buffer; - - /* Values 0-2 are valid */ - - if (Temp8 > 2) - { - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); - } - - OutputStruct->Data.Address16.ResourceType = Temp8 & 0x03; - - /* - * Get the General Flags (Byte4) - */ - Buffer += 1; - Temp8 = *Buffer; - - /* Producer / Consumer */ - - OutputStruct->Data.Address16.ProducerConsumer = Temp8 & 0x01; - - /* Decode */ - - OutputStruct->Data.Address16.Decode = (Temp8 >> 1) & 0x01; - - /* Min Address Fixed */ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress16)}, - OutputStruct->Data.Address16.MinAddressFixed = (Temp8 >> 2) & 0x01; + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16, + sizeof (AML_RESOURCE_ADDRESS16), + 0}, - /* Max Address Fixed */ - - OutputStruct->Data.Address16.MaxAddressFixed = (Temp8 >> 3) & 0x01; - - /* - * Get the Type Specific Flags (Byte5) - */ - Buffer += 1; - Temp8 = *Buffer; - - if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address16.ResourceType) - { - OutputStruct->Data.Address16.Attribute.Memory.ReadWriteAttribute = - (UINT16) (Temp8 & 0x01); - OutputStruct->Data.Address16.Attribute.Memory.CacheAttribute = - (UINT16) ((Temp8 >> 1) & 0x03); - } - else - { - if (ACPI_IO_RANGE == OutputStruct->Data.Address16.ResourceType) - { - OutputStruct->Data.Address16.Attribute.Io.RangeAttribute = - (UINT16) (Temp8 & 0x03); - OutputStruct->Data.Address16.Attribute.Io.TranslationAttribute = - (UINT16) ((Temp8 >> 4) & 0x03); - } - else - { - /* BUS_NUMBER_RANGE == Address16.Data->ResourceType */ - /* Nothing needs to be filled in */ - } - } + /* Resource Type, General Flags, and Type-Specific Flags */ - /* - * Get Granularity (Bytes 6-7) - */ - Buffer += 1; - ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.Granularity, Buffer); + {ACPI_RSC_ADDRESS, 0, 0, 0}, /* - * Get MinAddressRange (Bytes 8-9) + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length */ - Buffer += 2; - ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.MinAddressRange, Buffer); + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Address16.Granularity), + AML_OFFSET (Address16.Granularity), + 5}, - /* - * Get MaxAddressRange (Bytes 10-11) - */ - Buffer += 2; - ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.MaxAddressRange, Buffer); + /* Optional ResourceSource (Index and String) */ - /* - * Get AddressTranslationOffset (Bytes 12-13) - */ - Buffer += 2; - ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.AddressTranslationOffset, Buffer); - - /* - * Get AddressLength (Bytes 14-15) - */ - Buffer += 2; - ACPI_MOVE_16_TO_32 (&OutputStruct->Data.Address16.AddressLength, Buffer); - - /* - * Resource Source Index (if present) - */ - Buffer += 2; - - /* - * This will leave us pointing to the Resource Source Index - * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes: - * Each Interrupt takes 32-bits + the 5 bytes of the - * stream that are default. - * - * Note: Some resource descriptors will have an additional null, so - * we add 1 to the length. - */ - if (*BytesConsumed > (16 + 1)) - { - /* Dereference the Index */ - - Temp8 = *Buffer; - OutputStruct->Data.Address16.ResourceSource.Index = (UINT32) Temp8; - - /* Point to the String */ - - Buffer += 1; - - /* Point the String pointer to the end of this structure */ - - OutputStruct->Data.Address16.ResourceSource.StringPtr = - (char *)((UINT8 * )OutputStruct + StructSize); - - TempPtr = (UINT8 *) OutputStruct->Data.Address16.ResourceSource.StringPtr; - - /* Copy the string into the buffer */ - - Index = 0; - - while (0x00 != *Buffer) - { - *TempPtr = *Buffer; - - TempPtr += 1; - Buffer += 1; - Index += 1; - } - - /* - * Add the terminating null - */ - *TempPtr = 0x00; - - OutputStruct->Data.Address16.ResourceSource.StringLength = Index + 1; - - /* - * In order for the StructSize to fall on a 32-bit boundary, - * calculate the length of the string and expand the - * StructSize to the next 32-bit boundary. - */ - Temp8 = (UINT8) (Index + 1); - StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8); - } - else - { - OutputStruct->Data.Address16.ResourceSource.Index = 0x00; - OutputStruct->Data.Address16.ResourceSource.StringLength = 0; - OutputStruct->Data.Address16.ResourceSource.StringPtr = NULL; - } - - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; - - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address16.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS16)} +}; /******************************************************************************* * - * FUNCTION: AcpiRsAddress16Stream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * AcpiRsConvertAddress32 - All DWORD (32-bit) address resources * ******************************************************************************/ -ACPI_STATUS -AcpiRsAddress16Stream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[5] = { - UINT8 *Buffer = *OutputBuffer; - UINT8 *LengthField; - UINT8 Temp8; - char *TempPointer = NULL; - ACPI_SIZE ActualBytes; - - - ACPI_FUNCTION_TRACE ("RsAddress16Stream"); - - - /* - * The descriptor field is static - */ - *Buffer = 0x88; - Buffer += 1; - - /* - * Save a pointer to the Length field - to be filled in later - */ - LengthField = Buffer; - Buffer += 2; - - /* - * Set the Resource Type (Memory, Io, BusNumber) - */ - Temp8 = (UINT8) (LinkedList->Data.Address16.ResourceType & 0x03); - *Buffer = Temp8; - Buffer += 1; + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress32)}, - /* - * Set the general flags - */ - Temp8 = (UINT8) (LinkedList->Data.Address16.ProducerConsumer & 0x01); - - Temp8 |= (LinkedList->Data.Address16.Decode & 0x01) << 1; - Temp8 |= (LinkedList->Data.Address16.MinAddressFixed & 0x01) << 2; - Temp8 |= (LinkedList->Data.Address16.MaxAddressFixed & 0x01) << 3; - - *Buffer = Temp8; - Buffer += 1; - - /* - * Set the type specific flags - */ - Temp8 = 0; - - if (ACPI_MEMORY_RANGE == LinkedList->Data.Address16.ResourceType) - { - Temp8 = (UINT8) - (LinkedList->Data.Address16.Attribute.Memory.ReadWriteAttribute & - 0x01); - - Temp8 |= - (LinkedList->Data.Address16.Attribute.Memory.CacheAttribute & - 0x03) << 1; - } - else if (ACPI_IO_RANGE == LinkedList->Data.Address16.ResourceType) - { - Temp8 = (UINT8) - (LinkedList->Data.Address16.Attribute.Io.RangeAttribute & - 0x03); - Temp8 |= - (LinkedList->Data.Address16.Attribute.Io.TranslationAttribute & - 0x03) << 4; - } - - *Buffer = Temp8; - Buffer += 1; - - /* - * Set the address space granularity - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.Granularity); - Buffer += 2; - - /* - * Set the address range minimum - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.MinAddressRange); - Buffer += 2; - - /* - * Set the address range maximum - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.MaxAddressRange); - Buffer += 2; + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32, + sizeof (AML_RESOURCE_ADDRESS32), + 0}, - /* - * Set the address translation offset - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.AddressTranslationOffset); - Buffer += 2; + /* Resource Type, General Flags, and Type-Specific Flags */ - /* - * Set the address length - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Address16.AddressLength); - Buffer += 2; + {ACPI_RSC_ADDRESS, 0, 0, 0}, /* - * Resource Source Index and Resource Source are optional + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length */ - if (0 != LinkedList->Data.Address16.ResourceSource.StringLength) - { - Temp8 = (UINT8) LinkedList->Data.Address16.ResourceSource.Index; - - *Buffer = Temp8; - Buffer += 1; - - TempPointer = (char *) Buffer; + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Address32.Granularity), + AML_OFFSET (Address32.Granularity), + 5}, - /* - * Copy the string - */ - ACPI_STRCPY (TempPointer, - LinkedList->Data.Address16.ResourceSource.StringPtr); + /* Optional ResourceSource (Index and String) */ - /* - * Buffer needs to be set to the length of the sting + one for the - * terminating null - */ - Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address16.ResourceSource.StringPtr) + 1); - } - - /* - * Return the number of bytes consumed in this operation - */ - ActualBytes = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - *BytesConsumed = ActualBytes; - - /* - * Set the length field to the number of bytes consumed - * minus the header size (3 bytes) - */ - ActualBytes -= 3; - ACPI_MOVE_SIZE_TO_16 (LengthField, &ActualBytes); - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address32.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS32)} +}; /******************************************************************************* * - * FUNCTION: AcpiRsAddress32Resource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. + * AcpiRsConvertAddress64 - All QWORD (64-bit) address resources * ******************************************************************************/ -ACPI_STATUS -AcpiRsAddress32Resource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[5] = { - UINT8 *Buffer; - ACPI_RESOURCE *OutputStruct= (void *) *OutputBuffer; - UINT16 Temp16; - UINT8 Temp8; - UINT8 *TempPtr; - ACPI_SIZE StructSize; - UINT32 Index; - + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress64)}, - ACPI_FUNCTION_TRACE ("RsAddress32Resource"); + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64, + sizeof (AML_RESOURCE_ADDRESS64), + 0}, + /* Resource Type, General Flags, and Type-Specific Flags */ - Buffer = ByteStreamBuffer; - StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS32); + {ACPI_RSC_ADDRESS, 0, 0, 0}, /* - * Point past the Descriptor to get the number of bytes consumed + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length */ - Buffer += 1; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.Address64.Granularity), + AML_OFFSET (Address64.Granularity), + 5}, - /* Validate minimum descriptor length */ + /* Optional ResourceSource (Index and String) */ - if (Temp16 < 23) - { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); - } - - *BytesConsumed = Temp16 + 3; - OutputStruct->Id = ACPI_RSTYPE_ADDRESS32; + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address64.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS64)} +}; - /* - * Get the Resource Type (Byte3) - */ - Buffer += 2; - Temp8 = *Buffer; - /* Values 0-2 are valid */ - if(Temp8 > 2) - { - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); - } - - OutputStruct->Data.Address32.ResourceType = Temp8 & 0x03; - - /* - * Get the General Flags (Byte4) - */ - Buffer += 1; - Temp8 = *Buffer; - - /* - * Producer / Consumer - */ - OutputStruct->Data.Address32.ProducerConsumer = Temp8 & 0x01; - - /* - * Decode - */ - OutputStruct->Data.Address32.Decode = (Temp8 >> 1) & 0x01; - - /* - * Min Address Fixed - */ - OutputStruct->Data.Address32.MinAddressFixed = (Temp8 >> 2) & 0x01; - - /* - * Max Address Fixed - */ - OutputStruct->Data.Address32.MaxAddressFixed = (Temp8 >> 3) & 0x01; - - /* - * Get the Type Specific Flags (Byte5) - */ - Buffer += 1; - Temp8 = *Buffer; - - if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address32.ResourceType) - { - OutputStruct->Data.Address32.Attribute.Memory.ReadWriteAttribute = - (UINT16) (Temp8 & 0x01); - - OutputStruct->Data.Address32.Attribute.Memory.CacheAttribute = - (UINT16) ((Temp8 >> 1) & 0x03); - } - else - { - if (ACPI_IO_RANGE == OutputStruct->Data.Address32.ResourceType) - { - OutputStruct->Data.Address32.Attribute.Io.RangeAttribute = - (UINT16) (Temp8 & 0x03); - OutputStruct->Data.Address32.Attribute.Io.TranslationAttribute = - (UINT16) ((Temp8 >> 4) & 0x03); - } - else - { - /* BUS_NUMBER_RANGE == OutputStruct->Data.Address32.ResourceType */ - /* Nothing needs to be filled in */ - } - } - - /* - * Get Granularity (Bytes 6-9) - */ - Buffer += 1; - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.Granularity, Buffer); - - /* - * Get MinAddressRange (Bytes 10-13) - */ - Buffer += 4; - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.MinAddressRange, Buffer); - - /* - * Get MaxAddressRange (Bytes 14-17) - */ - Buffer += 4; - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.MaxAddressRange, Buffer); - - /* - * Get AddressTranslationOffset (Bytes 18-21) - */ - Buffer += 4; - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.AddressTranslationOffset, Buffer); - - /* - * Get AddressLength (Bytes 22-25) - */ - Buffer += 4; - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Address32.AddressLength, Buffer); - - /* - * Resource Source Index (if present) - */ - Buffer += 4; - - /* - * This will leave us pointing to the Resource Source Index - * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes: - * - * Note: Some resource descriptors will have an additional null, so - * we add 1 to the length. - */ - if (*BytesConsumed > (26 + 1)) - { - /* Dereference the Index */ - - Temp8 = *Buffer; - OutputStruct->Data.Address32.ResourceSource.Index = - (UINT32) Temp8; - - /* Point to the String */ - - Buffer += 1; - - /* Point the String pointer to the end of this structure */ - - OutputStruct->Data.Address32.ResourceSource.StringPtr = - (char *)((UINT8 *)OutputStruct + StructSize); - - TempPtr = (UINT8 *) OutputStruct->Data.Address32.ResourceSource.StringPtr; - - /* Copy the string into the buffer */ +/******************************************************************************* + * + * AcpiRsConvertExtAddress64 - All Extended (64-bit) address resources + * + ******************************************************************************/ - Index = 0; - while (0x00 != *Buffer) - { - *TempPtr = *Buffer; +ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtAddress64)}, - TempPtr += 1; - Buffer += 1; - Index += 1; - } + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64, + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64), + 0}, - /* - * Add the terminating null - */ - *TempPtr = 0x00; - OutputStruct->Data.Address32.ResourceSource.StringLength = Index + 1; + /* Resource Type, General Flags, and Type-Specific Flags */ - /* - * In order for the StructSize to fall on a 32-bit boundary, - * calculate the length of the string and expand the - * StructSize to the next 32-bit boundary. - */ - Temp8 = (UINT8) (Index + 1); - StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8); - } - else - { - OutputStruct->Data.Address32.ResourceSource.Index = 0x00; - OutputStruct->Data.Address32.ResourceSource.StringLength = 0; - OutputStruct->Data.Address32.ResourceSource.StringPtr = NULL; - } + {ACPI_RSC_ADDRESS, 0, 0, 0}, - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; + /* Revision ID */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.ExtAddress64.RevisionID), + AML_OFFSET (ExtAddress64.RevisionID), + 1}, /* - * Return the final size of the structure + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + * Type-Specific Attribute */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.ExtAddress64.Granularity), + AML_OFFSET (ExtAddress64.Granularity), + 6} +}; /******************************************************************************* * - * FUNCTION: AcpiRsAddress32Stream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * AcpiRsConvertGeneralFlags - Flags common to all address descriptors * ******************************************************************************/ -ACPI_STATUS -AcpiRsAddress32Stream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +static ACPI_RSCONVERT_INFO AcpiRsConvertGeneralFlags[6] = { - UINT8 *Buffer; - UINT16 *LengthField; - UINT8 Temp8; - char *TempPointer; + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.Flags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertGeneralFlags)}, + /* Resource Type (Memory, Io, BusNumber, etc.) */ - ACPI_FUNCTION_TRACE ("RsAddress32Stream"); + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Address.ResourceType), + AML_OFFSET (Address.ResourceType), + 1}, + /* General Flags - Consume, Decode, MinFixed, MaxFixed */ - Buffer = *OutputBuffer; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.ProducerConsumer), + AML_OFFSET (Address.Flags), + 0}, - /* - * The descriptor field is static - */ - *Buffer = 0x87; - Buffer += 1; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Decode), + AML_OFFSET (Address.Flags), + 1}, - /* - * Set a pointer to the Length field - to be filled in later - */ - LengthField = ACPI_CAST_PTR (UINT16, Buffer); - Buffer += 2; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MinAddressFixed), + AML_OFFSET (Address.Flags), + 2}, - /* - * Set the Resource Type (Memory, Io, BusNumber) - */ - Temp8 = (UINT8) (LinkedList->Data.Address32.ResourceType & 0x03); + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MaxAddressFixed), + AML_OFFSET (Address.Flags), + 3} +}; - *Buffer = Temp8; - Buffer += 1; - /* - * Set the general flags - */ - Temp8 = (UINT8) (LinkedList->Data.Address32.ProducerConsumer & 0x01); - Temp8 |= (LinkedList->Data.Address32.Decode & 0x01) << 1; - Temp8 |= (LinkedList->Data.Address32.MinAddressFixed & 0x01) << 2; - Temp8 |= (LinkedList->Data.Address32.MaxAddressFixed & 0x01) << 3; +/******************************************************************************* + * + * AcpiRsConvertMemFlags - Flags common to Memory address descriptors + * + ******************************************************************************/ - *Buffer = Temp8; - Buffer += 1; +static ACPI_RSCONVERT_INFO AcpiRsConvertMemFlags[5] = +{ + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemFlags)}, - /* - * Set the type specific flags - */ - Temp8 = 0; + /* Memory-specific flags */ - if (ACPI_MEMORY_RANGE == LinkedList->Data.Address32.ResourceType) - { - Temp8 = (UINT8) - (LinkedList->Data.Address32.Attribute.Memory.ReadWriteAttribute & - 0x01); + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.WriteProtect), + AML_OFFSET (Address.SpecificFlags), + 0}, - Temp8 |= - (LinkedList->Data.Address32.Attribute.Memory.CacheAttribute & - 0x03) << 1; - } - else if (ACPI_IO_RANGE == LinkedList->Data.Address32.ResourceType) - { - Temp8 = (UINT8) - (LinkedList->Data.Address32.Attribute.Io.RangeAttribute & - 0x03); - Temp8 |= - (LinkedList->Data.Address32.Attribute.Io.TranslationAttribute & - 0x03) << 4; - } + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Caching), + AML_OFFSET (Address.SpecificFlags), + 1}, - *Buffer = Temp8; - Buffer += 1; + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.RangeType), + AML_OFFSET (Address.SpecificFlags), + 3}, - /* - * Set the address space granularity - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.Granularity); - Buffer += 4; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Translation), + AML_OFFSET (Address.SpecificFlags), + 5} +}; - /* - * Set the address range minimum - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.MinAddressRange); - Buffer += 4; - /* - * Set the address range maximum - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.MaxAddressRange); - Buffer += 4; - - /* - * Set the address translation offset - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.AddressTranslationOffset); - Buffer += 4; - - /* - * Set the address length - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Address32.AddressLength); - Buffer += 4; - - /* - * Resource Source Index and Resource Source are optional - */ - if (0 != LinkedList->Data.Address32.ResourceSource.StringLength) - { - Temp8 = (UINT8) LinkedList->Data.Address32.ResourceSource.Index; - - *Buffer = Temp8; - Buffer += 1; +/******************************************************************************* + * + * AcpiRsConvertIoFlags - Flags common to I/O address descriptors + * + ******************************************************************************/ - TempPointer = (char *) Buffer; +static ACPI_RSCONVERT_INFO AcpiRsConvertIoFlags[4] = +{ + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertIoFlags)}, - /* - * Copy the string - */ - ACPI_STRCPY (TempPointer, - LinkedList->Data.Address32.ResourceSource.StringPtr); + /* I/O-specific flags */ - /* - * Buffer needs to be set to the length of the sting + one for the - * terminating null - */ - Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address32.ResourceSource.StringPtr) + 1); - } + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.RangeType), + AML_OFFSET (Address.SpecificFlags), + 0}, - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.Translation), + AML_OFFSET (Address.SpecificFlags), + 4}, - /* - * Set the length field to the number of bytes consumed - * minus the header size (3 bytes) - */ - *LengthField = (UINT16) (*BytesConsumed - 3); - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.TranslationType), + AML_OFFSET (Address.SpecificFlags), + 5} +}; /******************************************************************************* * - * FUNCTION: AcpiRsAddress64Resource + * FUNCTION: AcpiRsGetAddressCommon * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Resource - Pointer to the internal resource struct + * Aml - Pointer to the AML resource descriptor * - * RETURN: Status + * RETURN: TRUE if the ResourceType field is OK, FALSE otherwise * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor + * to an internal resource descriptor * ******************************************************************************/ -ACPI_STATUS -AcpiRsAddress64Resource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +BOOLEAN +AcpiRsGetAddressCommon ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml) { - UINT8 *Buffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT16 Temp16; - UINT8 Temp8; - UINT8 *TempPtr; - ACPI_SIZE StructSize; - UINT32 Index; - + ACPI_FUNCTION_ENTRY (); - ACPI_FUNCTION_TRACE ("RsAddress64Resource"); + /* Validate the Resource Type */ - Buffer = ByteStreamBuffer; - StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS64); - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - Buffer += 1; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - - /* Validate minimum descriptor length */ - - if (Temp16 < 43) + if ((Aml->Address.ResourceType > 2) && (Aml->Address.ResourceType < 0xC0)) { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + return (FALSE); } - *BytesConsumed = Temp16 + 3; - OutputStruct->Id = ACPI_RSTYPE_ADDRESS64; + /* Get the Resource Type and General Flags */ - /* - * Get the Resource Type (Byte3) - */ - Buffer += 2; - Temp8 = *Buffer; + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertGeneralFlags); - /* Values 0-2 are valid */ + /* Get the Type-Specific Flags (Memory and I/O descriptors only) */ - if(Temp8 > 2) + if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE) { - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertMemFlags); } - - OutputStruct->Data.Address64.ResourceType = Temp8 & 0x03; - - /* - * Get the General Flags (Byte4) - */ - Buffer += 1; - Temp8 = *Buffer; - - /* - * Producer / Consumer - */ - OutputStruct->Data.Address64.ProducerConsumer = Temp8 & 0x01; - - /* - * Decode - */ - OutputStruct->Data.Address64.Decode = (Temp8 >> 1) & 0x01; - - /* - * Min Address Fixed - */ - OutputStruct->Data.Address64.MinAddressFixed = (Temp8 >> 2) & 0x01; - - /* - * Max Address Fixed - */ - OutputStruct->Data.Address64.MaxAddressFixed = (Temp8 >> 3) & 0x01; - - /* - * Get the Type Specific Flags (Byte5) - */ - Buffer += 1; - Temp8 = *Buffer; - - if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address64.ResourceType) + else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE) { - OutputStruct->Data.Address64.Attribute.Memory.ReadWriteAttribute = - (UINT16) (Temp8 & 0x01); - - OutputStruct->Data.Address64.Attribute.Memory.CacheAttribute = - (UINT16) ((Temp8 >> 1) & 0x03); + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertIoFlags); } else { - if (ACPI_IO_RANGE == OutputStruct->Data.Address64.ResourceType) - { - OutputStruct->Data.Address64.Attribute.Io.RangeAttribute = - (UINT16) (Temp8 & 0x03); - OutputStruct->Data.Address64.Attribute.Io.TranslationAttribute = - (UINT16) ((Temp8 >> 4) & 0x03); - } - else - { - /* BUS_NUMBER_RANGE == OutputStruct->Data.Address64.ResourceType */ - /* Nothing needs to be filled in */ - } - } - - /* - * Get Granularity (Bytes 6-13) - */ - Buffer += 1; - ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.Granularity, Buffer); - - /* - * Get MinAddressRange (Bytes 14-21) - */ - Buffer += 8; - ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.MinAddressRange, Buffer); - - /* - * Get MaxAddressRange (Bytes 22-29) - */ - Buffer += 8; - ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.MaxAddressRange, Buffer); - - /* - * Get AddressTranslationOffset (Bytes 30-37) - */ - Buffer += 8; - ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.AddressTranslationOffset, Buffer); - - /* - * Get AddressLength (Bytes 38-45) - */ - Buffer += 8; - ACPI_MOVE_64_TO_64 (&OutputStruct->Data.Address64.AddressLength, Buffer); - - /* - * Resource Source Index (if present) - */ - Buffer += 8; + /* Generic resource type, just grab the TypeSpecific byte */ - /* - * This will leave us pointing to the Resource Source Index - * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes: - * Each Interrupt takes 32-bits + the 5 bytes of the - * stream that are default. - * - * Note: Some resource descriptors will have an additional null, so - * we add 1 to the length. - */ - if (*BytesConsumed > (46 + 1)) - { - /* Dereference the Index */ - - Temp8 = *Buffer; - OutputStruct->Data.Address64.ResourceSource.Index = - (UINT32) Temp8; - - /* Point to the String */ - - Buffer += 1; - - /* Point the String pointer to the end of this structure */ - - OutputStruct->Data.Address64.ResourceSource.StringPtr = - (char *)((UINT8 *)OutputStruct + StructSize); - - TempPtr = (UINT8 *) OutputStruct->Data.Address64.ResourceSource.StringPtr; - - /* Copy the string into the buffer */ - - Index = 0; - while (0x00 != *Buffer) - { - *TempPtr = *Buffer; - - TempPtr += 1; - Buffer += 1; - Index += 1; - } - - /* - * Add the terminating null - */ - *TempPtr = 0x00; - OutputStruct->Data.Address64.ResourceSource.StringLength = Index + 1; - - /* - * In order for the StructSize to fall on a 32-bit boundary, - * calculate the length of the string and expand the - * StructSize to the next 32-bit boundary. - */ - Temp8 = (UINT8) (Index + 1); - StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8); - } - else - { - OutputStruct->Data.Address64.ResourceSource.Index = 0x00; - OutputStruct->Data.Address64.ResourceSource.StringLength = 0; - OutputStruct->Data.Address64.ResourceSource.StringPtr = NULL; + Resource->Data.Address.Info.TypeSpecific = Aml->Address.SpecificFlags; } - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; - - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); + return (TRUE); } /******************************************************************************* * - * FUNCTION: AcpiRsAddress64Stream + * FUNCTION: AcpiRsSetAddressCommon * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * Resource - Pointer to the internal resource struct * - * RETURN: Status + * RETURN: None * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert common flag fields from a resource descriptor to an + * AML descriptor * ******************************************************************************/ -ACPI_STATUS -AcpiRsAddress64Stream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +void +AcpiRsSetAddressCommon ( + AML_RESOURCE *Aml, + ACPI_RESOURCE *Resource) { - UINT8 *Buffer; - UINT16 *LengthField; - UINT8 Temp8; - char *TempPointer; - + ACPI_FUNCTION_ENTRY (); - ACPI_FUNCTION_TRACE ("RsAddress64Stream"); + /* Set the Resource Type and General Flags */ - Buffer = *OutputBuffer; + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertGeneralFlags); - /* - * The descriptor field is static - */ - *Buffer = 0x8A; - Buffer += 1; - - /* - * Set a pointer to the Length field - to be filled in later - */ - LengthField = ACPI_CAST_PTR (UINT16, Buffer); - Buffer += 2; - - /* - * Set the Resource Type (Memory, Io, BusNumber) - */ - Temp8 = (UINT8) (LinkedList->Data.Address64.ResourceType & 0x03); - - *Buffer = Temp8; - Buffer += 1; - - /* - * Set the general flags - */ - Temp8 = (UINT8) (LinkedList->Data.Address64.ProducerConsumer & 0x01); - Temp8 |= (LinkedList->Data.Address64.Decode & 0x01) << 1; - Temp8 |= (LinkedList->Data.Address64.MinAddressFixed & 0x01) << 2; - Temp8 |= (LinkedList->Data.Address64.MaxAddressFixed & 0x01) << 3; + /* Set the Type-Specific Flags (Memory and I/O descriptors only) */ - *Buffer = Temp8; - Buffer += 1; - - /* - * Set the type specific flags - */ - Temp8 = 0; - - if (ACPI_MEMORY_RANGE == LinkedList->Data.Address64.ResourceType) + if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE) { - Temp8 = (UINT8) - (LinkedList->Data.Address64.Attribute.Memory.ReadWriteAttribute & - 0x01); - - Temp8 |= - (LinkedList->Data.Address64.Attribute.Memory.CacheAttribute & - 0x03) << 1; + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertMemFlags); } - else if (ACPI_IO_RANGE == LinkedList->Data.Address64.ResourceType) + else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE) { - Temp8 = (UINT8) - (LinkedList->Data.Address64.Attribute.Io.RangeAttribute & - 0x03); - Temp8 |= - (LinkedList->Data.Address64.Attribute.Io.RangeAttribute & - 0x03) << 4; + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertIoFlags); } - - *Buffer = Temp8; - Buffer += 1; - - /* - * Set the address space granularity - */ - ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.Granularity); - Buffer += 8; - - /* - * Set the address range minimum - */ - ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.MinAddressRange); - Buffer += 8; - - /* - * Set the address range maximum - */ - ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.MaxAddressRange); - Buffer += 8; - - /* - * Set the address translation offset - */ - ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.AddressTranslationOffset); - Buffer += 8; - - /* - * Set the address length - */ - ACPI_MOVE_64_TO_64 (Buffer, &LinkedList->Data.Address64.AddressLength); - Buffer += 8; - - /* - * Resource Source Index and Resource Source are optional - */ - if (0 != LinkedList->Data.Address64.ResourceSource.StringLength) + else { - Temp8 = (UINT8) LinkedList->Data.Address64.ResourceSource.Index; - - *Buffer = Temp8; - Buffer += 1; - - TempPointer = (char *) Buffer; + /* Generic resource type, just copy the TypeSpecific byte */ - /* - * Copy the string - */ - ACPI_STRCPY (TempPointer, LinkedList->Data.Address64.ResourceSource.StringPtr); - - /* - * Buffer needs to be set to the length of the sting + one for the - * terminating null - */ - Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.Address64.ResourceSource.StringPtr) + 1); + Aml->Address.SpecificFlags = Resource->Data.Address.Info.TypeSpecific; } - - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - - /* - * Set the length field to the number of bytes consumed - * minus the header size (3 bytes) - */ - *LengthField = (UINT16) (*BytesConsumed - 3); - return_ACPI_STATUS (AE_OK); } + diff --git a/sys/contrib/dev/acpica/rscalc.c b/sys/contrib/dev/acpica/rscalc.c index 00e633a..3c33c6a 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: 52 $ + * $Revision: 1.66 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,679 +125,492 @@ ACPI_MODULE_NAME ("rscalc") +/* Local prototypes */ + +static UINT8 +AcpiRsCountSetBits ( + UINT16 BitField); + +static ACPI_RS_LENGTH +AcpiRsStructOptionLength ( + ACPI_RESOURCE_SOURCE *ResourceSource); + +static UINT32 +AcpiRsStreamOptionLength ( + UINT32 ResourceLength, + UINT32 MinimumTotalLength); + + /******************************************************************************* * - * FUNCTION: AcpiRsGetByteStreamLength + * FUNCTION: AcpiRsCountSetBits * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * SizeNeeded - UINT32 pointer of the size buffer needed - * to properly return the parsed data + * PARAMETERS: BitField - Field in which to count bits * - * RETURN: Status + * RETURN: Number of bits set within the field * - * DESCRIPTION: Takes the resource byte stream and parses it once, calculating - * the size buffer needed to hold the linked list that conveys - * the resource data. + * DESCRIPTION: Count the number of bits set in a resource field. Used for + * (Short descriptor) interrupt and DMA lists. * ******************************************************************************/ -ACPI_STATUS -AcpiRsGetByteStreamLength ( - ACPI_RESOURCE *LinkedList, - ACPI_SIZE *SizeNeeded) +static UINT8 +AcpiRsCountSetBits ( + UINT16 BitField) { - ACPI_SIZE ByteStreamSizeNeeded = 0; - ACPI_SIZE SegmentSize; - BOOLEAN Done = FALSE; + UINT8 BitsSet; - ACPI_FUNCTION_TRACE ("RsGetByteStreamLength"); + ACPI_FUNCTION_ENTRY (); - while (!Done) + for (BitsSet = 0; BitField; BitsSet++) { - /* - * Init the variable that will hold the size to add to the total. - */ - SegmentSize = 0; + /* Zero the least significant bit that is set */ - switch (LinkedList->Id) - { - case ACPI_RSTYPE_IRQ: - /* - * IRQ Resource - * For an IRQ Resource, Byte 3, although optional, will always be - * created - it holds IRQ information. - */ - SegmentSize = 4; - break; - - case ACPI_RSTYPE_DMA: - /* - * DMA Resource - * For this resource the size is static - */ - SegmentSize = 3; - break; - - case ACPI_RSTYPE_START_DPF: - /* - * Start Dependent Functions Resource - * For a StartDependentFunctions Resource, Byte 1, although - * optional, will always be created. - */ - SegmentSize = 2; - break; - - case ACPI_RSTYPE_END_DPF: - /* - * End Dependent Functions Resource - * For this resource the size is static - */ - SegmentSize = 1; - break; - - case ACPI_RSTYPE_IO: - /* - * IO Port Resource - * For this resource the size is static - */ - SegmentSize = 8; - break; - - case ACPI_RSTYPE_FIXED_IO: - /* - * Fixed IO Port Resource - * For this resource the size is static - */ - SegmentSize = 4; - break; + BitField &= (BitField - 1); + } - 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. - */ - if (LinkedList->Data.VendorSpecific.Length > 7) - { - SegmentSize = 3; - } - else - { - SegmentSize = 1; - } - SegmentSize += LinkedList->Data.VendorSpecific.Length; - break; + return (BitsSet); +} - case ACPI_RSTYPE_END_TAG: - /* - * End Tag - * For this resource the size is static - */ - SegmentSize = 2; - Done = TRUE; - break; - case ACPI_RSTYPE_MEM24: - /* - * 24-Bit Memory Resource - * For this resource the size is static - */ - SegmentSize = 12; - break; +/******************************************************************************* + * + * FUNCTION: AcpiRsStructOptionLength + * + * PARAMETERS: ResourceSource - Pointer to optional descriptor field + * + * RETURN: Status + * + * DESCRIPTION: Common code to handle optional ResourceSourceIndex and + * ResourceSource fields in some Large descriptors. Used during + * list-to-stream conversion + * + ******************************************************************************/ - case ACPI_RSTYPE_MEM32: - /* - * 32-Bit Memory Range Resource - * For this resource the size is static - */ - SegmentSize = 20; - break; +static ACPI_RS_LENGTH +AcpiRsStructOptionLength ( + ACPI_RESOURCE_SOURCE *ResourceSource) +{ + ACPI_FUNCTION_ENTRY (); - case ACPI_RSTYPE_FIXED_MEM32: - /* - * 32-Bit Fixed Memory Resource - * For this resource the size is static - */ - SegmentSize = 12; - break; - 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. - */ - SegmentSize = 16; + /* + * If the ResourceSource string is valid, return the size of the string + * (StringLength includes the NULL terminator) plus the size of the + * ResourceSourceIndex (1). + */ + if (ResourceSource->StringPtr) + { + return ((ACPI_RS_LENGTH) (ResourceSource->StringLength + 1)); + } - if (LinkedList->Data.Address16.ResourceSource.StringPtr) - { - SegmentSize += LinkedList->Data.Address16.ResourceSource.StringLength; - SegmentSize++; - } - break; + return (0); +} - case ACPI_RSTYPE_ADDRESS32: - /* - * 32-Bit Address Resource - * The base size of this byte stream is 26. 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 = 26; - if (LinkedList->Data.Address32.ResourceSource.StringPtr) - { - SegmentSize += LinkedList->Data.Address32.ResourceSource.StringLength; - SegmentSize++; - } - break; - - case ACPI_RSTYPE_ADDRESS64: - /* - * 64-Bit Address Resource - * 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; +/******************************************************************************* + * + * FUNCTION: AcpiRsStreamOptionLength + * + * PARAMETERS: ResourceLength - Length from the resource header + * MinimumTotalLength - Minimum length of this resource, before + * any optional fields. Includes header size + * + * RETURN: Length of optional string (0 if no string present) + * + * DESCRIPTION: Common code to handle optional ResourceSourceIndex and + * ResourceSource fields in some Large descriptors. Used during + * stream-to-list conversion + * + ******************************************************************************/ - if (LinkedList->Data.Address64.ResourceSource.StringPtr) - { - SegmentSize += LinkedList->Data.Address64.ResourceSource.StringLength; - SegmentSize++; - } - break; +static UINT32 +AcpiRsStreamOptionLength ( + UINT32 ResourceLength, + UINT32 MinimumAmlResourceLength) +{ + UINT32 StringLength = 0; - 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. - * 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 = 9 + - (((ACPI_SIZE) LinkedList->Data.ExtendedIrq.NumberOfInterrupts - 1) * 4); - if (LinkedList->Data.ExtendedIrq.ResourceSource.StringPtr) - { - SegmentSize += LinkedList->Data.ExtendedIrq.ResourceSource.StringLength; - SegmentSize++; - } - break; + ACPI_FUNCTION_ENTRY (); - default: - /* - * If we get here, everything is out of sync, exit with error - */ - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); - } /* switch (LinkedList->Id) */ + /* + * The ResourceSourceIndex and ResourceSource are optional elements of some + * Large-type resource descriptors. + */ - /* - * Update the total - */ - ByteStreamSizeNeeded += SegmentSize; + /* + * If the length of the actual resource descriptor is greater than the ACPI + * spec-defined minimum length, it means that a ResourceSourceIndex exists + * and is followed by a (required) null terminated string. The string length + * (including the null terminator) is the resource length minus the minimum + * length, minus one byte for the ResourceSourceIndex itself. + */ + if (ResourceLength > MinimumAmlResourceLength) + { + /* Compute the length of the optional string */ - /* - * Point to the next object - */ - LinkedList = ACPI_PTR_ADD (ACPI_RESOURCE, - LinkedList, LinkedList->Length); + StringLength = ResourceLength - MinimumAmlResourceLength - 1; } - /* - * This is the data the caller needs - */ - *SizeNeeded = ByteStreamSizeNeeded; - return_ACPI_STATUS (AE_OK); + /* Round up length to 32 bits for internal structure alignment */ + + return (ACPI_ROUND_UP_TO_32BITS (StringLength)); } /******************************************************************************* * - * FUNCTION: AcpiRsGetListLength + * FUNCTION: AcpiRsGetAmlLength * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource byte stream - * ByteStreamBufferLength - Size of ByteStreamBuffer - * SizeNeeded - UINT32 pointer of the size buffer - * needed to properly return the - * parsed data + * PARAMETERS: Resource - Pointer to the resource linked list + * SizeNeeded - Where the required size is returned * * RETURN: Status * - * DESCRIPTION: Takes the resource byte stream and parses it once, calculating - * the size buffer needed to hold the linked list that conveys - * the resource data. + * DESCRIPTION: Takes a linked list of internal resource descriptors and + * calculates the size buffer needed to hold the corresponding + * external resource byte stream. * ******************************************************************************/ ACPI_STATUS -AcpiRsGetListLength ( - UINT8 *ByteStreamBuffer, - UINT32 ByteStreamBufferLength, +AcpiRsGetAmlLength ( + ACPI_RESOURCE *Resource, ACPI_SIZE *SizeNeeded) { - UINT32 BufferSize = 0; - UINT32 BytesParsed = 0; - UINT8 NumberOfInterrupts = 0; - UINT8 NumberOfChannels = 0; - UINT8 ResourceType; - UINT32 StructureSize; - UINT32 BytesConsumed; - UINT8 *Buffer; - UINT8 Temp8; - UINT16 Temp16; - UINT8 Index; - UINT8 AdditionalBytes; + ACPI_SIZE AmlSizeNeeded = 0; + ACPI_RS_LENGTH TotalSize; - ACPI_FUNCTION_TRACE ("RsGetListLength"); + ACPI_FUNCTION_TRACE ("RsGetAmlLength"); - while (BytesParsed < ByteStreamBufferLength) + /* Traverse entire list of internal resource descriptors */ + + while (Resource) { - /* - * The next byte in the stream is the resource type - */ - ResourceType = AcpiRsGetResourceType (*ByteStreamBuffer); + /* Validate the descriptor type */ - switch (ResourceType) + if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) { - case ACPI_RDESC_TYPE_MEMORY_24: - /* - * 24-Bit Memory Resource - */ - BytesConsumed = 12; + return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + } - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_MEM24); - break; + /* Get the base size of the (external stream) resource descriptor */ + TotalSize = AcpiGbl_AmlResourceSizes [Resource->Type]; - case ACPI_RDESC_TYPE_LARGE_VENDOR: + /* + * Augment the base size for descriptors with optional and/or + * variable-length fields + */ + switch (Resource->Type) + { + case ACPI_RESOURCE_TYPE_VENDOR: /* - * Vendor Defined Resource + * 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. */ - Buffer = ByteStreamBuffer; - ++Buffer; + if (Resource->Data.Vendor.ByteLength > 7) + { + /* Base size of a Large resource descriptor */ - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - BytesConsumed = Temp16 + 3; + TotalSize = sizeof (AML_RESOURCE_LARGE_HEADER); + } - /* - * Ensure a 32-bit boundary for the structure - */ - Temp16 = (UINT16) ACPI_ROUND_UP_TO_32BITS (Temp16); + /* Add the size of the vendor-specific data */ - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_VENDOR) + - (Temp16 * sizeof (UINT8)); + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + Resource->Data.Vendor.ByteLength); break; - case ACPI_RDESC_TYPE_MEMORY_32: + case ACPI_RESOURCE_TYPE_END_TAG: /* - * 32-Bit Memory Range Resource + * End Tag: + * We are done -- return the accumulated total size. */ - BytesConsumed = 20; + *SizeNeeded = AmlSizeNeeded + TotalSize; - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_MEM32); - break; + /* Normal exit */ + + return_ACPI_STATUS (AE_OK); - case ACPI_RDESC_TYPE_FIXED_MEMORY_32: + case ACPI_RESOURCE_TYPE_ADDRESS16: /* - * 32-Bit Fixed Memory Resource + * 16-Bit Address Resource: + * Add the size of the optional ResourceSource info */ - BytesConsumed = 12; - - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_FIXED_MEM32); + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + AcpiRsStructOptionLength ( + &Resource->Data.Address16.ResourceSource)); break; - case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: + case ACPI_RESOURCE_TYPE_ADDRESS32: /* - * 64-Bit Address Resource + * 32-Bit Address Resource: + * Add the size of the optional ResourceSource info */ - Buffer = ByteStreamBuffer; - - ++Buffer; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - - BytesConsumed = Temp16 + 3; + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + AcpiRsStructOptionLength ( + &Resource->Data.Address32.ResourceSource)); + break; - /* - * 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) - { - Temp8 = (UINT8) (Temp16 - 44); - } - else - { - Temp8 = 0; - } + case ACPI_RESOURCE_TYPE_ADDRESS64: /* - * Ensure a 64-bit boundary for the structure + * 64-Bit Address Resource: + * Add the size of the optional ResourceSource info */ - Temp8 = (UINT8) ACPI_ROUND_UP_TO_64BITS (Temp8); - - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS64) + - (Temp8 * sizeof (UINT8)); + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + AcpiRsStructOptionLength ( + &Resource->Data.Address64.ResourceSource)); break; - case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: /* - * 32-Bit Address Resource + * Extended IRQ Resource: + * Add the size of each additional optional interrupt beyond the + * required 1 (4 bytes for each UINT32 interrupt number) */ - Buffer = ByteStreamBuffer; + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + + ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) + - ++Buffer; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); + /* Add the size of the optional ResourceSource info */ - 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 - * 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) - { - Temp8 = (UINT8) (Temp16 - 24); - } - else - { - Temp8 = 0; - } + AcpiRsStructOptionLength ( + &Resource->Data.ExtendedIrq.ResourceSource)); + break; - /* - * Ensure a 32-bit boundary for the structure - */ - Temp8 = (UINT8) ACPI_ROUND_UP_TO_32BITS (Temp8); - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS32) + - (Temp8 * sizeof (UINT8)); + default: break; + } + /* Update the total */ - case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: - /* - * 16-Bit Address Resource - */ - Buffer = ByteStreamBuffer; - - ++Buffer; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); + AmlSizeNeeded += TotalSize; - BytesConsumed = Temp16 + 3; + /* Point to the next object */ - /* - * 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) - { - Temp8 = (UINT8) (Temp16 - 14); - } - else - { - Temp8 = 0; - } + Resource = ACPI_PTR_ADD (ACPI_RESOURCE, + Resource, Resource->Length); + } - /* - * Ensure a 32-bit boundary for the structure - */ - Temp8 = (UINT8) ACPI_ROUND_UP_TO_32BITS (Temp8); + /* Did not find an END_TAG descriptor */ - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS16) + - (Temp8 * sizeof (UINT8)); - break; + return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); +} - case ACPI_RDESC_TYPE_EXTENDED_XRUPT: - /* - * Extended IRQ - */ - Buffer = ByteStreamBuffer; +/******************************************************************************* + * + * FUNCTION: AcpiRsGetListLength + * + * PARAMETERS: AmlBuffer - Pointer to the resource byte stream + * AmlBufferLength - Size of AmlBuffer + * SizeNeeded - Where the size needed is returned + * + * RETURN: Status + * + * DESCRIPTION: Takes an external resource byte stream and calculates the size + * buffer needed to hold the corresponding internal resource + * descriptor linked list. + * + ******************************************************************************/ - ++Buffer; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); +ACPI_STATUS +AcpiRsGetListLength ( + UINT8 *AmlBuffer, + UINT32 AmlBufferLength, + ACPI_SIZE *SizeNeeded) +{ + UINT8 *Buffer; + ACPI_RESOURCE_INFO *ResourceInfo; + UINT32 BufferSize = 0; + UINT32 BytesParsed = 0; + UINT8 ResourceType; + UINT16 Temp16; + UINT16 ResourceLength; + UINT16 HeaderLength; + UINT32 ExtraStructBytes; - BytesConsumed = Temp16 + 3; - /* - * 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; + ACPI_FUNCTION_TRACE ("RsGetListLength"); - /* - * To compensate for multiple interrupt numbers, add 4 bytes for - * each additional interrupts greater than 1 - */ - 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 - * 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) - { - Temp8 = (UINT8) (Temp16 - (9 + AdditionalBytes)); - } - else - { - Temp8 = 0; - } + while (BytesParsed < AmlBufferLength) + { + /* The next byte in the stream is the resource descriptor type */ - /* - * Ensure a 32-bit boundary for the structure - */ - Temp8 = (UINT8) ACPI_ROUND_UP_TO_32BITS (Temp8); + ResourceType = AcpiUtGetResourceType (AmlBuffer); - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_EXT_IRQ) + - (AdditionalBytes * sizeof (UINT8)) + - (Temp8 * sizeof (UINT8)); - break; + /* Get the base stream size and structure sizes for the descriptor */ + ResourceInfo = AcpiRsGetResourceInfo (ResourceType); + if (!ResourceInfo) + { + return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + } - case ACPI_RDESC_TYPE_IRQ_FORMAT: - /* - * IRQ Resource. - * Determine if it there are two or three trailing bytes - */ - Buffer = ByteStreamBuffer; - Temp8 = *Buffer; + /* Get the Length field from the input resource descriptor */ - if(Temp8 & 0x01) - { - BytesConsumed = 4; - } - else - { - BytesConsumed = 3; - } + ResourceLength = AcpiUtGetResourceLength (AmlBuffer); - /* Point past the descriptor */ + /* Augment the size for descriptors with optional fields */ - ++Buffer; + ExtraStructBytes = 0; + if (!(ResourceType & ACPI_RESOURCE_NAME_LARGE)) + { /* - * Look at the number of bits set + * Small resource descriptors */ - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); + HeaderLength = sizeof (AML_RESOURCE_SMALL_HEADER); + Buffer = AmlBuffer + HeaderLength; - for (Index = 0; Index < 16; Index++) + switch (ResourceType) { - if (Temp16 & 0x1) - { - ++NumberOfInterrupts; - } - - Temp16 >>= 1; - } + case ACPI_RESOURCE_NAME_IRQ: + /* + * IRQ Resource: + * Get the number of bits set in the IRQ word + */ + ACPI_MOVE_16_TO_16 (&Temp16, Buffer); + ExtraStructBytes = (AcpiRsCountSetBits (Temp16) * + sizeof (UINT32)); + break; - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_IO) + - (NumberOfInterrupts * sizeof (UINT32)); - break; + case ACPI_RESOURCE_NAME_DMA: + /* + * DMA Resource: + * Get the number of bits set in the DMA channels byte + */ + ACPI_MOVE_16_TO_16 (&Temp16, Buffer); + ExtraStructBytes = (AcpiRsCountSetBits (Temp16) * + sizeof (UINT32)); + break; - case ACPI_RDESC_TYPE_DMA_FORMAT: - /* - * DMA Resource - */ - Buffer = ByteStreamBuffer; - BytesConsumed = 3; - /* Point past the descriptor */ + case ACPI_RESOURCE_NAME_VENDOR_SMALL: + /* + * Vendor Specific Resource: + * Ensure a 32-bit boundary for the structure + */ + ExtraStructBytes = ACPI_ROUND_UP_TO_32BITS (ResourceLength); + break; - ++Buffer; - /* - * Look at the number of bits set - */ - Temp8 = *Buffer; + case ACPI_RESOURCE_NAME_END_TAG: + /* + * End Tag: + * Terminate the loop now + */ + AmlBufferLength = BytesParsed; + break; - for(Index = 0; Index < 8; Index++) - { - if(Temp8 & 0x1) - { - ++NumberOfChannels; - } - Temp8 >>= 1; + default: + break; } - - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_DMA) + - (NumberOfChannels * sizeof (UINT32)); - break; - - - case ACPI_RDESC_TYPE_START_DEPENDENT: + } + else + { /* - * Start Dependent Functions Resource - * Determine if it there are two or three trailing bytes + * Large resource descriptors */ - Buffer = ByteStreamBuffer; - Temp8 = *Buffer; + HeaderLength = sizeof (AML_RESOURCE_LARGE_HEADER); + Buffer = AmlBuffer + HeaderLength; - if(Temp8 & 0x01) - { - BytesConsumed = 2; - } - else + switch (ResourceType) { - BytesConsumed = 1; - } - - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_START_DPF); - break; - - - case ACPI_RDESC_TYPE_END_DEPENDENT: - /* - * End Dependent Functions Resource - */ - BytesConsumed = 1; - StructureSize = ACPI_RESOURCE_LENGTH; - break; - + case ACPI_RESOURCE_NAME_VENDOR_LARGE: + /* + * Vendor Defined Resource: + * Add vendor data and ensure a 32-bit boundary for the structure + */ + ExtraStructBytes = ACPI_ROUND_UP_TO_32BITS (ResourceLength); + break; - case ACPI_RDESC_TYPE_IO_PORT: - /* - * IO Port Resource - */ - BytesConsumed = 8; - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_IO); - break; + case ACPI_RESOURCE_NAME_ADDRESS32: + case ACPI_RESOURCE_NAME_ADDRESS16: + /* + * 32-Bit or 16-bit Address Resource: + * Add the size of any optional data (ResourceSource) + */ + ExtraStructBytes = AcpiRsStreamOptionLength (ResourceLength, + ResourceInfo->MinimumAmlResourceLength); + break; - case ACPI_RDESC_TYPE_FIXED_IO_PORT: - /* - * Fixed IO Port Resource - */ - BytesConsumed = 4; - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_FIXED_IO); - break; + case ACPI_RESOURCE_NAME_EXTENDED_IRQ: + /* + * Extended IRQ: + * Point past the InterruptVectorFlags to get the + * InterruptTableLength. + */ + Buffer++; - case ACPI_RDESC_TYPE_SMALL_VENDOR: - /* - * Vendor Specific Resource - */ - Buffer = ByteStreamBuffer; + /* + * Add 4 bytes for each additional interrupt. Note: at least one + * interrupt is required and is included in the minimum + * descriptor size + */ + ExtraStructBytes = ((*Buffer - 1) * sizeof (UINT32)); - Temp8 = *Buffer; - Temp8 = (UINT8) (Temp8 & 0x7); - BytesConsumed = Temp8 + 1; + /* Add the size of any optional data (ResourceSource) */ - /* - * Ensure a 32-bit boundary for the structure - */ - Temp8 = (UINT8) ACPI_ROUND_UP_TO_32BITS (Temp8); - StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_VENDOR) + - (Temp8 * sizeof (UINT8)); - break; + ExtraStructBytes += AcpiRsStreamOptionLength ( + ResourceLength - ExtraStructBytes, + ResourceInfo->MinimumAmlResourceLength); + break; - case ACPI_RDESC_TYPE_END_TAG: - /* - * End Tag - */ - BytesConsumed = 2; - StructureSize = ACPI_RESOURCE_LENGTH; - ByteStreamBufferLength = BytesParsed; - break; + case ACPI_RESOURCE_NAME_ADDRESS64: + /* + * 64-Bit Address Resource: + * Add the size of any optional data (ResourceSource) + * Ensure a 64-bit boundary for the structure + */ + ExtraStructBytes = ACPI_ROUND_UP_TO_64BITS ( + AcpiRsStreamOptionLength (ResourceLength, + ResourceInfo->MinimumAmlResourceLength)); + break; - default: - /* - * If we get here, everything is out of sync, - * exit with an error - */ - return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + default: + break; + } } - /* - * Update the return value and counter - */ - BufferSize += (UINT32) ACPI_ALIGN_RESOURCE_SIZE (StructureSize); - BytesParsed += BytesConsumed; + /* Update the required buffer size for the internal descriptor structs */ + + Temp16 = (UINT16) (ResourceInfo->MinimumInternalStructLength + ExtraStructBytes); + BufferSize += (UINT32) ACPI_ALIGN_RESOURCE_SIZE (Temp16); /* - * Set the byte stream to point to the next resource + * Update byte count and point to the next resource within the stream + * using the size of the header plus the length contained in the header */ - ByteStreamBuffer += BytesConsumed; + Temp16 = (UINT16) (HeaderLength + ResourceLength); + BytesParsed += Temp16; + AmlBuffer += Temp16; } - /* - * This is the data the caller needs - */ + /* This is the data the caller needs */ + *SizeNeeded = BufferSize; return_ACPI_STATUS (AE_OK); } @@ -854,9 +667,8 @@ AcpiRsGetPciRoutingTableLength ( for (Index = 0; Index < NumberOfElements; Index++) { - /* - * Dereference the sub-package - */ + /* Dereference the sub-package */ + PackageElement = *TopObjectList; /* @@ -865,33 +677,35 @@ AcpiRsGetPciRoutingTableLength ( */ SubObjectList = PackageElement->Package.Elements; - /* - * Scan the IrqTableElements for the Source Name String - */ + /* Scan the IrqTableElements for the Source Name String */ + NameFound = FALSE; for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++) { - if ((ACPI_TYPE_STRING == ACPI_GET_OBJECT_TYPE (*SubObjectList)) || - ((ACPI_TYPE_LOCAL_REFERENCE == ACPI_GET_OBJECT_TYPE (*SubObjectList)) && - ((*SubObjectList)->Reference.Opcode == AML_INT_NAMEPATH_OP))) + if ((ACPI_TYPE_STRING == + ACPI_GET_OBJECT_TYPE (*SubObjectList)) || + + ((ACPI_TYPE_LOCAL_REFERENCE == + ACPI_GET_OBJECT_TYPE (*SubObjectList)) && + + ((*SubObjectList)->Reference.Opcode == + AML_INT_NAMEPATH_OP))) { NameFound = TRUE; } else { - /* - * Look at the next element - */ + /* Look at the next element */ + SubObjectList++; } } TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); - /* - * Was a String type found? - */ + /* Was a String type found? */ + if (NameFound) { if (ACPI_GET_OBJECT_TYPE (*SubObjectList) == ACPI_TYPE_STRING) @@ -900,7 +714,8 @@ AcpiRsGetPciRoutingTableLength ( * The length String.Length field does not include the * terminating NULL, add 1 */ - TempSizeNeeded += ((ACPI_SIZE) (*SubObjectList)->String.Length + 1); + TempSizeNeeded += ((ACPI_SIZE) + (*SubObjectList)->String.Length + 1); } else { @@ -921,14 +736,14 @@ AcpiRsGetPciRoutingTableLength ( TempSizeNeeded = ACPI_ROUND_UP_TO_64BITS (TempSizeNeeded); - /* - * Point to the next ACPI_OPERAND_OBJECT - */ + /* Point to the next ACPI_OPERAND_OBJECT */ + TopObjectList++; } /* - * Adding an extra element to the end of the list, essentially a NULL terminator + * Adding an extra element to the end of the list, essentially a + * NULL terminator */ *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE); return_ACPI_STATUS (AE_OK); diff --git a/sys/contrib/dev/acpica/rscreate.c b/sys/contrib/dev/acpica/rscreate.c index afc4814..9d764bf 100644 --- a/sys/contrib/dev/acpica/rscreate.c +++ b/sys/contrib/dev/acpica/rscreate.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rscreate - Create resource lists/tables - * $Revision: 66 $ + * $Revision: 1.71 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -130,10 +130,10 @@ * * FUNCTION: AcpiRsCreateResourceList * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource byte stream - * OutputBuffer - Pointer to the user's buffer + * PARAMETERS: AmlBuffer - Pointer to the resource byte stream + * OutputBuffer - Pointer to the user's buffer * - * RETURN: Status - AE_OK if okay, else a valid ACPI_STATUS code + * RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code * If OutputBuffer is not large enough, OutputBufferLength * indicates how large OutputBuffer should be, else it * indicates how may UINT8 elements of OutputBuffer are valid. @@ -146,33 +146,32 @@ ACPI_STATUS AcpiRsCreateResourceList ( - ACPI_OPERAND_OBJECT *ByteStreamBuffer, + ACPI_OPERAND_OBJECT *AmlBuffer, ACPI_BUFFER *OutputBuffer) { ACPI_STATUS Status; - UINT8 *ByteStreamStart; + UINT8 *AmlStart; ACPI_SIZE ListSizeNeeded = 0; - UINT32 ByteStreamBufferLength; + UINT32 AmlBufferLength; ACPI_FUNCTION_TRACE ("RsCreateResourceList"); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ByteStreamBuffer = %p\n", - ByteStreamBuffer)); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n", + AmlBuffer)); - /* - * Params already validated, so we don't re-validate here - */ - ByteStreamBufferLength = ByteStreamBuffer->Buffer.Length; - ByteStreamStart = ByteStreamBuffer->Buffer.Pointer; + /* Params already validated, so we don't re-validate here */ + + AmlBufferLength = AmlBuffer->Buffer.Length; + AmlStart = AmlBuffer->Buffer.Pointer; /* - * Pass the ByteStreamBuffer into a module that can calculate + * Pass the AmlBuffer into a module that can calculate * the buffer size needed for the linked list */ - Status = AcpiRsGetListLength (ByteStreamStart, ByteStreamBufferLength, + Status = AcpiRsGetListLength (AmlStart, AmlBufferLength, &ListSizeNeeded); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n", @@ -192,7 +191,7 @@ AcpiRsCreateResourceList ( /* Do the conversion */ - Status = AcpiRsByteStreamToList (ByteStreamStart, ByteStreamBufferLength, + Status = AcpiRsConvertAmlToResources (AmlStart, AmlBufferLength, OutputBuffer->Pointer); if (ACPI_FAILURE (Status)) { @@ -249,9 +248,8 @@ AcpiRsCreatePciRoutingTable ( /* Params already validated, so we don't re-validate here */ - /* - * Get the required buffer length - */ + /* Get the required buffer length */ + Status = AcpiRsGetPciRoutingTableLength (PackageObject, &BufferSizeNeeded); if (ACPI_FAILURE (Status)) @@ -298,9 +296,8 @@ AcpiRsCreatePciRoutingTable ( */ UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); - /* - * Each element of the top-level package must also be a package - */ + /* Each element of the top-level package must also be a package */ + if (ACPI_GET_OBJECT_TYPE (*TopObjectList) != ACPI_TYPE_PACKAGE) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, @@ -326,9 +323,8 @@ AcpiRsCreatePciRoutingTable ( */ SubObjectList = (*TopObjectList)->Package.Elements; - /* - * 1) First subobject: Dereference the PRT.Address - */ + /* 1) First subobject: Dereference the PRT.Address */ + ObjDesc = SubObjectList[0]; if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { @@ -342,9 +338,8 @@ AcpiRsCreatePciRoutingTable ( return_ACPI_STATUS (AE_BAD_DATA); } - /* - * 2) Second subobject: Dereference the PRT.Pin - */ + /* 2) Second subobject: Dereference the PRT.Pin */ + ObjDesc = SubObjectList[1]; if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { @@ -358,9 +353,8 @@ AcpiRsCreatePciRoutingTable ( return_ACPI_STATUS (AE_BAD_DATA); } - /* - * 3) Third subobject: Dereference the PRT.SourceName - */ + /* 3) Third subobject: Dereference the PRT.SourceName */ + ObjDesc = SubObjectList[2]; switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { @@ -385,7 +379,9 @@ AcpiRsCreatePciRoutingTable ( Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer); - UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; /* include null terminator */ + /* +1 to include null terminator */ + + UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; break; @@ -393,8 +389,10 @@ AcpiRsCreatePciRoutingTable ( ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer); - /* Add to the Length field the length of the string (add 1 for terminator) */ - + /* + * Add to the Length field the length of the string + * (add 1 for terminator) + */ UserPrt->Length += ObjDesc->String.Length + 1; break; @@ -422,9 +420,8 @@ AcpiRsCreatePciRoutingTable ( UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BITS (UserPrt->Length); - /* - * 4) Fourth subobject: Dereference the PRT.SourceIndex - */ + /* 4) Fourth subobject: Dereference the PRT.SourceIndex */ + ObjDesc = SubObjectList[3]; if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { @@ -451,7 +448,7 @@ AcpiRsCreatePciRoutingTable ( /******************************************************************************* * - * FUNCTION: AcpiRsCreateByteStream + * FUNCTION: AcpiRsCreateAmlResources * * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list * OutputBuffer - Pointer to the user's buffer @@ -468,15 +465,15 @@ AcpiRsCreatePciRoutingTable ( ******************************************************************************/ ACPI_STATUS -AcpiRsCreateByteStream ( +AcpiRsCreateAmlResources ( ACPI_RESOURCE *LinkedListBuffer, ACPI_BUFFER *OutputBuffer) { ACPI_STATUS Status; - ACPI_SIZE ByteStreamSizeNeeded = 0; + ACPI_SIZE AmlSizeNeeded = 0; - ACPI_FUNCTION_TRACE ("RsCreateByteStream"); + ACPI_FUNCTION_TRACE ("RsCreateAmlResources"); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n", @@ -488,11 +485,11 @@ AcpiRsCreateByteStream ( * Pass the LinkedListBuffer into a module that calculates * the buffer size needed for the byte stream. */ - Status = AcpiRsGetByteStreamLength (LinkedListBuffer, - &ByteStreamSizeNeeded); + Status = AcpiRsGetAmlLength (LinkedListBuffer, + &AmlSizeNeeded); - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ByteStreamSizeNeeded=%X, %s\n", - (UINT32) ByteStreamSizeNeeded, AcpiFormatException (Status))); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", + (UINT32) AmlSizeNeeded, AcpiFormatException (Status))); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -500,7 +497,7 @@ AcpiRsCreateByteStream ( /* Validate/Allocate/Clear caller buffer */ - Status = AcpiUtInitializeBuffer (OutputBuffer, ByteStreamSizeNeeded); + Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -508,7 +505,7 @@ AcpiRsCreateByteStream ( /* Do the conversion */ - Status = AcpiRsListToByteStream (LinkedListBuffer, ByteStreamSizeNeeded, + Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded, OutputBuffer->Pointer); if (ACPI_FAILURE (Status)) { diff --git a/sys/contrib/dev/acpica/rsdump.c b/sys/contrib/dev/acpica/rsdump.c index c6990f5..8be18b5 100644 --- a/sys/contrib/dev/acpica/rsdump.c +++ b/sys/contrib/dev/acpica/rsdump.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsdump - Functions to display the resource structures. - * $Revision: 38 $ + * $Revision: 1.54 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -119,6 +119,7 @@ #include <contrib/dev/acpica/acpi.h> #include <contrib/dev/acpica/acresrc.h> +#include <contrib/dev/acpica/acdisasm.h> #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsdump") @@ -126,1123 +127,741 @@ #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) -/******************************************************************************* - * - * FUNCTION: AcpiRsDumpIrq - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: None - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ +/* Local prototypes */ -void -AcpiRsDumpIrq ( - ACPI_RESOURCE_DATA *Data) -{ - ACPI_RESOURCE_IRQ *IrqData = (ACPI_RESOURCE_IRQ *) Data; - UINT8 Index = 0; +static void +AcpiRsOutString ( + char *Title, + char *Value); +static void +AcpiRsOutInteger8 ( + char *Title, + UINT8 Value); - ACPI_FUNCTION_ENTRY (); +static void +AcpiRsOutInteger16 ( + char *Title, + UINT16 Value); +static void +AcpiRsOutInteger32 ( + char *Title, + UINT32 Value); - AcpiOsPrintf ("IRQ Resource\n"); +static void +AcpiRsOutInteger64 ( + char *Title, + UINT64 Value); - AcpiOsPrintf (" %s Triggered\n", - ACPI_LEVEL_SENSITIVE == IrqData->EdgeLevel ? "Level" : "Edge"); +static void +AcpiRsOutTitle ( + char *Title); - AcpiOsPrintf (" Active %s\n", - ACPI_ACTIVE_LOW == IrqData->ActiveHighLow ? "Low" : "High"); +static void +AcpiRsDumpByteList ( + UINT16 Length, + UINT8 *Data); - AcpiOsPrintf (" %s\n", - ACPI_SHARED == IrqData->SharedExclusive ? "Shared" : "Exclusive"); +static void +AcpiRsDumpDwordList ( + UINT8 Length, + UINT32 *Data); - AcpiOsPrintf (" %X Interrupts ( ", IrqData->NumberOfInterrupts); +static void +AcpiRsDumpShortByteList ( + UINT8 Length, + UINT8 *Data); - for (Index = 0; Index < IrqData->NumberOfInterrupts; Index++) - { - AcpiOsPrintf ("%X ", IrqData->Interrupts[Index]); - } +static void +AcpiRsDumpResourceSource ( + ACPI_RESOURCE_SOURCE *ResourceSource); - AcpiOsPrintf (")\n"); - return; -} +static void +AcpiRsDumpAddressCommon ( + ACPI_RESOURCE_DATA *Resource); +static void +AcpiRsDumpDescriptor ( + void *Resource, + ACPI_RSDUMP_INFO *Table); -/******************************************************************************* - * - * FUNCTION: AcpiRsDumpDma - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: None - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ -void -AcpiRsDumpDma ( - ACPI_RESOURCE_DATA *Data) -{ - ACPI_RESOURCE_DMA *DmaData = (ACPI_RESOURCE_DMA *) Data; - UINT8 Index = 0; - - - ACPI_FUNCTION_ENTRY (); - - - AcpiOsPrintf ("DMA Resource\n"); - - switch (DmaData->Type) - { - case ACPI_COMPATIBILITY: - AcpiOsPrintf (" Compatibility mode\n"); - break; - - case ACPI_TYPE_A: - AcpiOsPrintf (" Type A\n"); - break; - - case ACPI_TYPE_B: - AcpiOsPrintf (" Type B\n"); - break; - - case ACPI_TYPE_F: - AcpiOsPrintf (" Type F\n"); - break; - - default: - AcpiOsPrintf (" Invalid DMA type\n"); - break; - } - - AcpiOsPrintf (" %sBus Master\n", - ACPI_BUS_MASTER == DmaData->BusMaster ? "" : "Not a "); - - - switch (DmaData->Transfer) - { - case ACPI_TRANSFER_8: - AcpiOsPrintf (" 8-bit only transfer\n"); - break; - - case ACPI_TRANSFER_8_16: - AcpiOsPrintf (" 8 and 16-bit transfer\n"); - break; - - case ACPI_TRANSFER_16: - AcpiOsPrintf (" 16 bit only transfer\n"); - break; - - default: - AcpiOsPrintf (" Invalid transfer preference\n"); - break; - } - - AcpiOsPrintf (" Number of Channels: %X ( ", DmaData->NumberOfChannels); - - for (Index = 0; Index < DmaData->NumberOfChannels; Index++) - { - AcpiOsPrintf ("%X ", DmaData->Channels[Index]); - } - - AcpiOsPrintf (")\n"); - return; -} +#define ACPI_RSD_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE_DATA,f) +#define ACPI_PRT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_PCI_ROUTING_TABLE,f) +#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (ACPI_RSDUMP_INFO)) /******************************************************************************* * - * FUNCTION: AcpiRsDumpStartDependFns - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: None + * Resource Descriptor info tables * - * DESCRIPTION: Prints out the various members of the Data structure type. + * Note: The first table entry must be a Title or Literal and must contain + * the table length (number of table entries) * ******************************************************************************/ -void -AcpiRsDumpStartDependFns ( - ACPI_RESOURCE_DATA *Data) +ACPI_RSDUMP_INFO AcpiRsDumpIrq[6] = { - ACPI_RESOURCE_START_DPF *SdfData = (ACPI_RESOURCE_START_DPF *) Data; - - - ACPI_FUNCTION_ENTRY (); - - - AcpiOsPrintf ("Start Dependent Functions Resource\n"); - - switch (SdfData->CompatibilityPriority) - { - case ACPI_GOOD_CONFIGURATION: - AcpiOsPrintf (" Good configuration\n"); - break; - - case ACPI_ACCEPTABLE_CONFIGURATION: - AcpiOsPrintf (" Acceptable configuration\n"); - break; - - case ACPI_SUB_OPTIMAL_CONFIGURATION: - AcpiOsPrintf (" Sub-optimal configuration\n"); - break; - - default: - AcpiOsPrintf (" Invalid compatibility priority\n"); - break; - } - - switch(SdfData->PerformanceRobustness) - { - case ACPI_GOOD_CONFIGURATION: - AcpiOsPrintf (" Good configuration\n"); - break; - - case ACPI_ACCEPTABLE_CONFIGURATION: - AcpiOsPrintf (" Acceptable configuration\n"); - break; - - case ACPI_SUB_OPTIMAL_CONFIGURATION: - AcpiOsPrintf (" Sub-optimal configuration\n"); - break; - - default: - AcpiOsPrintf (" Invalid performance " - "robustness preference\n"); - break; - } - - return; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiRsDumpIo - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: None - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -AcpiRsDumpIo ( - ACPI_RESOURCE_DATA *Data) + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIrq), "IRQ", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Triggering), "Triggering", AcpiGbl_HEDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Polarity), "Polarity", AcpiGbl_LLDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Sharable), "Sharing", AcpiGbl_SHRDecode}, + {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.InterruptCount), "Interrupt Count", NULL}, + {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Irq.Interrupts[0]), "Interrupt List", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpDma[6] = { - ACPI_RESOURCE_IO *IoData = (ACPI_RESOURCE_IO *) Data; - - - ACPI_FUNCTION_ENTRY (); - - - AcpiOsPrintf ("Io Resource\n"); - - AcpiOsPrintf (" %d bit decode\n", - ACPI_DECODE_16 == IoData->IoDecode ? 16 : 10); - - AcpiOsPrintf (" Range minimum base: %08X\n", - IoData->MinBaseAddress); - - AcpiOsPrintf (" Range maximum base: %08X\n", - IoData->MaxBaseAddress); - - AcpiOsPrintf (" Alignment: %08X\n", - IoData->Alignment); - - AcpiOsPrintf (" Range Length: %08X\n", - IoData->RangeLength); - - return; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiRsDumpFixedIo - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: None - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -AcpiRsDumpFixedIo ( - ACPI_RESOURCE_DATA *Data) + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpDma), "DMA", NULL}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Type), "Speed", AcpiGbl_TYPDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Dma.BusMaster), "Mastering", AcpiGbl_BMDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Transfer), "Transfer Type", AcpiGbl_SIZDecode}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Dma.ChannelCount), "Channel Count", NULL}, + {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Dma.Channels[0]), "Channel List", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[3] = { - ACPI_RESOURCE_FIXED_IO *FixedIoData = (ACPI_RESOURCE_FIXED_IO *) Data; - - - ACPI_FUNCTION_ENTRY (); - - - AcpiOsPrintf ("Fixed Io Resource\n"); - AcpiOsPrintf (" Range base address: %08X", - FixedIoData->BaseAddress); + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpStartDpf), "Start-Dependent-Functions",NULL}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.CompatibilityPriority), "Compatibility Priority", AcpiGbl_ConfigDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.PerformanceRobustness), "Performance/Robustness", AcpiGbl_ConfigDecode} +}; - AcpiOsPrintf (" Range length: %08X", - FixedIoData->RangeLength); - - return; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiRsDumpVendorSpecific - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: None - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ - -void -AcpiRsDumpVendorSpecific ( - ACPI_RESOURCE_DATA *Data) +ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[1] = { - ACPI_RESOURCE_VENDOR *VendorData = (ACPI_RESOURCE_VENDOR *) Data; - UINT16 Index = 0; + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndDpf), "End-Dependent-Functions", NULL} +}; +ACPI_RSDUMP_INFO AcpiRsDumpIo[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIo), "I/O", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Io.IoDecode), "Address Decoding", AcpiGbl_IoDecode}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.Alignment), "Alignment", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[3] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedIo), "Fixed I/O", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (FixedIo.Address), "Address", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (FixedIo.AddressLength), "Address Length", NULL} +}; - ACPI_FUNCTION_ENTRY (); +ACPI_RSDUMP_INFO AcpiRsDumpVendor[3] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpVendor), "Vendor Specific", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Vendor.ByteLength), "Length", NULL}, + {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET (Vendor.ByteData[0]), "Vendor Data", NULL} +}; +ACPI_RSDUMP_INFO AcpiRsDumpEndTag[1] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndTag), "EndTag", NULL} +}; - AcpiOsPrintf ("Vendor Specific Resource\n"); +ACPI_RSDUMP_INFO AcpiRsDumpMemory24[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory24), "24-Bit Memory Range", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory24.WriteProtect), "Write Protect", AcpiGbl_RWDecode}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Alignment), "Alignment", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpMemory32[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory32), "32-Bit Memory Range", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory32.WriteProtect), "Write Protect", AcpiGbl_RWDecode}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Alignment), "Alignment", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[4] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedMemory32), "32-Bit Fixed Memory Range",NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (FixedMemory32.WriteProtect), "Write Protect", AcpiGbl_RWDecode}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.Address), "Address", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.AddressLength), "Address Length", NULL} +}; - AcpiOsPrintf (" Length: %08X\n", VendorData->Length); +ACPI_RSDUMP_INFO AcpiRsDumpAddress16[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress16), "16-Bit WORD Address Space",NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.AddressLength), "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address16.ResourceSource), NULL, NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpAddress32[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress32), "32-Bit DWORD Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.AddressLength), "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address32.ResourceSource), NULL, NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpAddress64[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress64), "64-Bit QWORD Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.AddressLength), "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address64.ResourceSource), NULL, NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtAddress64), "64-Bit Extended Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.AddressLength), "Address Length", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TypeSpecific), "Type-Specific Attribute", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtIrq), "Extended IRQ", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.ProducerConsumer), "Type", AcpiGbl_ConsumeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Triggering), "Triggering", AcpiGbl_HEDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Polarity), "Polarity", AcpiGbl_LLDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Sharable), "Sharing", AcpiGbl_SHRDecode}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (ExtendedIrq.ResourceSource), NULL, NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (ExtendedIrq.InterruptCount), "Interrupt Count", NULL}, + {ACPI_RSD_DWORDLIST,ACPI_RSD_OFFSET (ExtendedIrq.Interrupts[0]), "Interrupt List", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGenericReg), "Generic Register", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.SpaceId), "Space ID", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitWidth), "Bit Width", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitOffset), "Bit Offset", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.AccessSize), "Access Size", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (GenericReg.Address), "Address", NULL} +}; + + +/* + * Tables used for common address descriptor flag fields + */ +static ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[5] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGeneralFlags), NULL, NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.ProducerConsumer), "Consumer/Producer", AcpiGbl_ConsumeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Decode), "Address Decode", AcpiGbl_DECDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MinAddressFixed), "Min Relocatability", AcpiGbl_MinDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MaxAddressFixed), "Max Relocatability", AcpiGbl_MaxDecode} +}; + +static ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[5] = +{ + {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemoryFlags), "Resource Type", "Memory Range"}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.WriteProtect), "Write Protect", AcpiGbl_RWDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Caching), "Caching", AcpiGbl_MEMDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.RangeType), "Range Type", AcpiGbl_MTPDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Translation), "Translation", AcpiGbl_TTPDecode} +}; + +static ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[4] = +{ + {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIoFlags), "Resource Type", "I/O Range"}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.RangeType), "Range Type", AcpiGbl_RNGDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.Translation), "Translation", AcpiGbl_TTPDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.TranslationType), "Translation Type", AcpiGbl_TRSDecode} +}; - for (Index = 0; Index < VendorData->Length; Index++) - { - AcpiOsPrintf (" Byte %X: %08X\n", - Index, VendorData->Reserved[Index]); - } - return; -} +/* + * Table used to dump _PRT contents + */ +static ACPI_RSDUMP_INFO AcpiRsDumpPrt[5] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpPrt), NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_PRT_OFFSET (Address), "Address", NULL}, + {ACPI_RSD_UINT32, ACPI_PRT_OFFSET (Pin), "Pin", NULL}, + {ACPI_RSD_STRING, ACPI_PRT_OFFSET (Source[0]), "Source", NULL}, + {ACPI_RSD_UINT32, ACPI_PRT_OFFSET (SourceIndex), "Source Index", NULL} +}; /******************************************************************************* * - * FUNCTION: AcpiRsDumpMemory24 + * FUNCTION: AcpiRsDumpDescriptor * - * PARAMETERS: Data - pointer to the resource structure to dump. + * PARAMETERS: Resource * * RETURN: None * - * DESCRIPTION: Prints out the various members of the Data structure type. + * DESCRIPTION: * ******************************************************************************/ -void -AcpiRsDumpMemory24 ( - ACPI_RESOURCE_DATA *Data) +static void +AcpiRsDumpDescriptor ( + void *Resource, + ACPI_RSDUMP_INFO *Table) { - ACPI_RESOURCE_MEM24 *Memory24Data = (ACPI_RESOURCE_MEM24 *) Data; + void *Target = NULL; + void *PreviousTarget; + char *Name; + UINT8 Count; - ACPI_FUNCTION_ENTRY (); + /* First table entry must contain the table length (# of table entries) */ + Count = Table->Offset; - AcpiOsPrintf ("24-Bit Memory Range Resource\n"); + while (Count) + { + PreviousTarget = Target; + Target = ((UINT8 *) Resource) + Table->Offset; + Name = Table->Name; - AcpiOsPrintf (" Read%s\n", - ACPI_READ_WRITE_MEMORY == - Memory24Data->ReadWriteAttribute ? - "/Write" : " only"); + switch (Table->Opcode) + { + case ACPI_RSD_TITLE: + /* + * Optional resource title + */ + if (Table->Name) + { + AcpiOsPrintf ("%s Resource\n", Name); + } + break; - AcpiOsPrintf (" Range minimum base: %08X\n", - Memory24Data->MinBaseAddress); + /* Strings */ - AcpiOsPrintf (" Range maximum base: %08X\n", - Memory24Data->MaxBaseAddress); + case ACPI_RSD_LITERAL: + AcpiRsOutString (Name, (char *) Table->Pointer); + break; - AcpiOsPrintf (" Alignment: %08X\n", - Memory24Data->Alignment); + case ACPI_RSD_STRING: + AcpiRsOutString (Name, (char *) Target); + break; - AcpiOsPrintf (" Range length: %08X\n", - Memory24Data->RangeLength); + /* Data items, 8/16/32/64 bit */ - return; -} + case ACPI_RSD_UINT8: + AcpiRsOutInteger8 (Name, *(UINT8 *) Target); + break; + case ACPI_RSD_UINT16: + AcpiRsOutInteger16 (Name, *(UINT16 *) Target); + break; -/******************************************************************************* - * - * FUNCTION: AcpiRsDumpMemory32 - * - * PARAMETERS: Data - pointer to the resource structure to dump. - * - * RETURN: None - * - * DESCRIPTION: Prints out the various members of the Data structure type. - * - ******************************************************************************/ + case ACPI_RSD_UINT32: + AcpiRsOutInteger32 (Name, *(UINT32 *) Target); + break; -void -AcpiRsDumpMemory32 ( - ACPI_RESOURCE_DATA *Data) -{ - ACPI_RESOURCE_MEM32 *Memory32Data = (ACPI_RESOURCE_MEM32 *) Data; + case ACPI_RSD_UINT64: + AcpiRsOutInteger64 (Name, *(UINT64 *) Target); + break; + /* Flags: 1-bit and 2-bit flags supported */ - ACPI_FUNCTION_ENTRY (); + case ACPI_RSD_1BITFLAG: + AcpiRsOutString (Name, (char *) + ((const char **) Table->Pointer)[(*(UINT8 *) Target) & 0x01]); + break; + case ACPI_RSD_2BITFLAG: + AcpiRsOutString (Name, (char *) + ((const char **) Table->Pointer)[(*(UINT8 *) Target) & 0x03]); + break; - AcpiOsPrintf ("32-Bit Memory Range Resource\n"); + case ACPI_RSD_SHORTLIST: + /* + * Short byte list (single line output) for DMA and IRQ resources + * Note: The list length is obtained from the previous table entry + */ + if (PreviousTarget) + { + AcpiRsOutTitle (Name); + AcpiRsDumpShortByteList (*((UINT8 *) PreviousTarget), + (UINT8 *) Target); + } + break; - AcpiOsPrintf (" Read%s\n", - ACPI_READ_WRITE_MEMORY == - Memory32Data->ReadWriteAttribute ? - "/Write" : " only"); + case ACPI_RSD_LONGLIST: + /* + * Long byte list for Vendor resource data + * Note: The list length is obtained from the previous table entry + */ + if (PreviousTarget) + { + AcpiRsDumpByteList (*((UINT16 *) PreviousTarget), + (UINT8 *) Target); + } + break; - AcpiOsPrintf (" Range minimum base: %08X\n", - Memory32Data->MinBaseAddress); + case ACPI_RSD_DWORDLIST: + /* + * Dword list for Extended Interrupt resources + * Note: The list length is obtained from the previous table entry + */ + if (PreviousTarget) + { + AcpiRsDumpDwordList (*((UINT8 *) PreviousTarget), + (UINT32 *) Target); + } + break; - AcpiOsPrintf (" Range maximum base: %08X\n", - Memory32Data->MaxBaseAddress); + case ACPI_RSD_ADDRESS: + /* + * Common flags for all Address resources + */ + AcpiRsDumpAddressCommon ((ACPI_RESOURCE_DATA *) Target); + break; - AcpiOsPrintf (" Alignment: %08X\n", - Memory32Data->Alignment); + case ACPI_RSD_SOURCE: + /* + * Optional ResourceSource for Address resources + */ + AcpiRsDumpResourceSource ((ACPI_RESOURCE_SOURCE *) Target); + break; - AcpiOsPrintf (" Range length: %08X\n", - Memory32Data->RangeLength); + default: + AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n", + Table->Opcode); + return; + } - return; + Table++; + Count--; + } } /******************************************************************************* * - * FUNCTION: AcpiRsDumpFixedMemory32 + * FUNCTION: AcpiRsDumpResourceSource * - * PARAMETERS: Data - pointer to the resource structure to dump. + * PARAMETERS: ResourceSource - Pointer to a Resource Source struct * - * RETURN: + * RETURN: None * - * DESCRIPTION: Prints out the various members of the Data structure type. + * DESCRIPTION: Common routine for dumping the optional ResourceSource and the + * corresponding ResourceSourceIndex. * ******************************************************************************/ -void -AcpiRsDumpFixedMemory32 ( - ACPI_RESOURCE_DATA *Data) +static void +AcpiRsDumpResourceSource ( + ACPI_RESOURCE_SOURCE *ResourceSource) { - ACPI_RESOURCE_FIXED_MEM32 *FixedMemory32Data = (ACPI_RESOURCE_FIXED_MEM32 *) Data; - - ACPI_FUNCTION_ENTRY (); - AcpiOsPrintf ("32-Bit Fixed Location Memory Range Resource\n"); - - AcpiOsPrintf (" Read%s\n", - ACPI_READ_WRITE_MEMORY == - FixedMemory32Data->ReadWriteAttribute ? - "/Write" : " Only"); - - AcpiOsPrintf (" Range base address: %08X\n", - FixedMemory32Data->RangeBaseAddress); + if (ResourceSource->Index == 0xFF) + { + return; + } - AcpiOsPrintf (" Range length: %08X\n", - FixedMemory32Data->RangeLength); + AcpiRsOutInteger8 ("Resource Source Index", + ResourceSource->Index); - return; + AcpiRsOutString ("Resource Source", + ResourceSource->StringPtr ? + ResourceSource->StringPtr : "[Not Specified]"); } /******************************************************************************* * - * FUNCTION: AcpiRsDumpAddress16 + * FUNCTION: AcpiRsDumpAddressCommon * - * PARAMETERS: Data - pointer to the resource structure to dump. + * PARAMETERS: Resource - Pointer to an internal resource descriptor * * RETURN: None * - * DESCRIPTION: Prints out the various members of the Data structure type. + * DESCRIPTION: Dump the fields that are common to all Address resource + * descriptors * ******************************************************************************/ -void -AcpiRsDumpAddress16 ( - ACPI_RESOURCE_DATA *Data) +static void +AcpiRsDumpAddressCommon ( + ACPI_RESOURCE_DATA *Resource) { - ACPI_RESOURCE_ADDRESS16 *Address16Data = (ACPI_RESOURCE_ADDRESS16 *) Data; - - ACPI_FUNCTION_ENTRY (); - AcpiOsPrintf ("16-Bit Address Space Resource\n"); - AcpiOsPrintf (" Resource Type: "); + /* Decode the type-specific flags */ - switch (Address16Data->ResourceType) + switch (Resource->Address.ResourceType) { case ACPI_MEMORY_RANGE: - AcpiOsPrintf ("Memory Range\n"); - - switch (Address16Data->Attribute.Memory.CacheAttribute) - { - case ACPI_NON_CACHEABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Noncacheable memory\n"); - break; - - case ACPI_CACHABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Cacheable memory\n"); - break; - - case ACPI_WRITE_COMBINING_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Write-combining memory\n"); - break; - - case ACPI_PREFETCHABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Prefetchable memory\n"); - break; - - default: - AcpiOsPrintf (" Type Specific: " - "Invalid cache attribute\n"); - break; - } - - AcpiOsPrintf (" Type Specific: Read%s\n", - ACPI_READ_WRITE_MEMORY == - Address16Data->Attribute.Memory.ReadWriteAttribute ? - "/Write" : " Only"); + AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags); break; case ACPI_IO_RANGE: - AcpiOsPrintf ("I/O Range\n"); - - switch (Address16Data->Attribute.Io.RangeAttribute) - { - case ACPI_NON_ISA_ONLY_RANGES: - AcpiOsPrintf (" Type Specific: " - "Non-ISA Io Addresses\n"); - break; - - case ACPI_ISA_ONLY_RANGES: - AcpiOsPrintf (" Type Specific: " - "ISA Io Addresses\n"); - break; - - case ACPI_ENTIRE_RANGE: - AcpiOsPrintf (" Type Specific: " - "ISA and non-ISA Io Addresses\n"); - break; - - default: - AcpiOsPrintf (" Type Specific: " - "Invalid range attribute\n"); - break; - } - - AcpiOsPrintf (" Type Specific: %s Translation\n", - ACPI_SPARSE_TRANSLATION == - Address16Data->Attribute.Io.TranslationAttribute ? - "Sparse" : "Dense"); + AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags); break; case ACPI_BUS_NUMBER_RANGE: - AcpiOsPrintf ("Bus Number Range\n"); + AcpiRsOutString ("Resource Type", "Bus Number Range"); break; default: - AcpiOsPrintf ("Invalid resource type. Exiting.\n"); - return; + AcpiRsOutInteger8 ("Resource Type", + (UINT8) Resource->Address.ResourceType); + break; } - AcpiOsPrintf (" Resource %s\n", - ACPI_CONSUMER == Address16Data->ProducerConsumer ? - "Consumer" : "Producer"); - - AcpiOsPrintf (" %s decode\n", - ACPI_SUB_DECODE == Address16Data->Decode ? - "Subtractive" : "Positive"); - - AcpiOsPrintf (" Min address is %s fixed\n", - ACPI_ADDRESS_FIXED == Address16Data->MinAddressFixed ? - "" : "not"); - - AcpiOsPrintf (" Max address is %s fixed\n", - ACPI_ADDRESS_FIXED == Address16Data->MaxAddressFixed ? - "" : "not"); - - AcpiOsPrintf (" Granularity: %08X\n", - Address16Data->Granularity); + /* Decode the general flags */ - AcpiOsPrintf (" Address range min: %08X\n", - Address16Data->MinAddressRange); - - AcpiOsPrintf (" Address range max: %08X\n", - Address16Data->MaxAddressRange); - - AcpiOsPrintf (" Address translation offset: %08X\n", - Address16Data->AddressTranslationOffset); - - AcpiOsPrintf (" Address Length: %08X\n", - Address16Data->AddressLength); - - if (0xFF != Address16Data->ResourceSource.Index) - { - AcpiOsPrintf (" Resource Source Index: %X\n", - Address16Data->ResourceSource.Index); - AcpiOsPrintf (" Resource Source: %s\n", - Address16Data->ResourceSource.StringPtr); - } - - return; + AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags); } /******************************************************************************* * - * FUNCTION: AcpiRsDumpAddress32 + * FUNCTION: AcpiRsDumpResourceList * - * PARAMETERS: Data - pointer to the resource structure to dump. + * PARAMETERS: ResourceList - Pointer to a resource descriptor list * * RETURN: None * - * DESCRIPTION: Prints out the various members of the Data structure type. + * DESCRIPTION: Dispatches the structure to the correct dump routine. * ******************************************************************************/ void -AcpiRsDumpAddress32 ( - ACPI_RESOURCE_DATA *Data) +AcpiRsDumpResourceList ( + ACPI_RESOURCE *ResourceList) { - ACPI_RESOURCE_ADDRESS32 *Address32Data = (ACPI_RESOURCE_ADDRESS32 *) Data; + UINT32 Count = 0; + UINT32 Type; ACPI_FUNCTION_ENTRY (); - AcpiOsPrintf ("32-Bit Address Space Resource\n"); - - switch (Address32Data->ResourceType) + if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer)) { - case ACPI_MEMORY_RANGE: - - AcpiOsPrintf (" Resource Type: Memory Range\n"); - - switch (Address32Data->Attribute.Memory.CacheAttribute) - { - case ACPI_NON_CACHEABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Noncacheable memory\n"); - break; - - case ACPI_CACHABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Cacheable memory\n"); - break; - - case ACPI_WRITE_COMBINING_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Write-combining memory\n"); - break; - - case ACPI_PREFETCHABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Prefetchable memory\n"); - break; - - default: - AcpiOsPrintf (" Type Specific: " - "Invalid cache attribute\n"); - break; - } - - AcpiOsPrintf (" Type Specific: Read%s\n", - ACPI_READ_WRITE_MEMORY == - Address32Data->Attribute.Memory.ReadWriteAttribute ? - "/Write" : " Only"); - break; - - case ACPI_IO_RANGE: - - AcpiOsPrintf (" Resource Type: Io Range\n"); - - switch (Address32Data->Attribute.Io.RangeAttribute) - { - case ACPI_NON_ISA_ONLY_RANGES: - AcpiOsPrintf (" Type Specific: " - "Non-ISA Io Addresses\n"); - break; - - case ACPI_ISA_ONLY_RANGES: - AcpiOsPrintf (" Type Specific: " - "ISA Io Addresses\n"); - break; - - case ACPI_ENTIRE_RANGE: - AcpiOsPrintf (" Type Specific: " - "ISA and non-ISA Io Addresses\n"); - break; - - default: - AcpiOsPrintf (" Type Specific: " - "Invalid Range attribute"); - break; - } - - AcpiOsPrintf (" Type Specific: %s Translation\n", - ACPI_SPARSE_TRANSLATION == - Address32Data->Attribute.Io.TranslationAttribute ? - "Sparse" : "Dense"); - break; - - case ACPI_BUS_NUMBER_RANGE: - - AcpiOsPrintf (" Resource Type: Bus Number Range\n"); - break; - - default: - - AcpiOsPrintf (" Invalid Resource Type..exiting.\n"); return; } - AcpiOsPrintf (" Resource %s\n", - ACPI_CONSUMER == Address32Data->ProducerConsumer ? - "Consumer" : "Producer"); + /* Walk list and dump all resource descriptors (END_TAG terminates) */ - AcpiOsPrintf (" %s decode\n", - ACPI_SUB_DECODE == Address32Data->Decode ? - "Subtractive" : "Positive"); - - AcpiOsPrintf (" Min address is %s fixed\n", - ACPI_ADDRESS_FIXED == Address32Data->MinAddressFixed ? - "" : "not "); + do + { + AcpiOsPrintf ("\n[%02X] ", Count); + Count++; - AcpiOsPrintf (" Max address is %s fixed\n", - ACPI_ADDRESS_FIXED == Address32Data->MaxAddressFixed ? - "" : "not "); + /* Validate Type before dispatch */ - AcpiOsPrintf (" Granularity: %08X\n", - Address32Data->Granularity); + Type = ResourceList->Type; + if (Type > ACPI_RESOURCE_TYPE_MAX) + { + AcpiOsPrintf ( + "Invalid descriptor type (%X) in resource list\n", + ResourceList->Type); + return; + } - AcpiOsPrintf (" Address range min: %08X\n", - Address32Data->MinAddressRange); + /* Dump the resource descriptor */ - AcpiOsPrintf (" Address range max: %08X\n", - Address32Data->MaxAddressRange); + AcpiRsDumpDescriptor (&ResourceList->Data, + AcpiGbl_DumpResourceDispatch[Type]); - AcpiOsPrintf (" Address translation offset: %08X\n", - Address32Data->AddressTranslationOffset); + /* Point to the next resource structure */ - AcpiOsPrintf (" Address Length: %08X\n", - Address32Data->AddressLength); + ResourceList = ACPI_PTR_ADD (ACPI_RESOURCE, ResourceList, + ResourceList->Length); - if(0xFF != Address32Data->ResourceSource.Index) - { - AcpiOsPrintf (" Resource Source Index: %X\n", - Address32Data->ResourceSource.Index); - AcpiOsPrintf (" Resource Source: %s\n", - Address32Data->ResourceSource.StringPtr); - } + /* Exit when END_TAG descriptor is reached */ - return; + } while (Type != ACPI_RESOURCE_TYPE_END_TAG); } /******************************************************************************* * - * FUNCTION: AcpiRsDumpAddress64 + * FUNCTION: AcpiRsDumpIrqList * - * PARAMETERS: Data - pointer to the resource structure to dump. + * PARAMETERS: RouteTable - Pointer to the routing table to dump. * * RETURN: None * - * DESCRIPTION: Prints out the various members of the Data structure type. + * DESCRIPTION: Print IRQ routing table * ******************************************************************************/ void -AcpiRsDumpAddress64 ( - ACPI_RESOURCE_DATA *Data) +AcpiRsDumpIrqList ( + UINT8 *RouteTable) { - ACPI_RESOURCE_ADDRESS64 *Address64Data = (ACPI_RESOURCE_ADDRESS64 *) Data; + ACPI_PCI_ROUTING_TABLE *PrtElement; + UINT8 Count; ACPI_FUNCTION_ENTRY (); - AcpiOsPrintf ("64-Bit Address Space Resource\n"); - - switch (Address64Data->ResourceType) + if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer)) { - case ACPI_MEMORY_RANGE: - - AcpiOsPrintf (" Resource Type: Memory Range\n"); - - switch (Address64Data->Attribute.Memory.CacheAttribute) - { - case ACPI_NON_CACHEABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Noncacheable memory\n"); - break; - - case ACPI_CACHABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Cacheable memory\n"); - break; - - case ACPI_WRITE_COMBINING_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Write-combining memory\n"); - break; - - case ACPI_PREFETCHABLE_MEMORY: - AcpiOsPrintf (" Type Specific: " - "Prefetchable memory\n"); - break; - - default: - AcpiOsPrintf (" Type Specific: " - "Invalid cache attribute\n"); - break; - } - - AcpiOsPrintf (" Type Specific: Read%s\n", - ACPI_READ_WRITE_MEMORY == - Address64Data->Attribute.Memory.ReadWriteAttribute ? - "/Write" : " Only"); - break; - - case ACPI_IO_RANGE: - - AcpiOsPrintf (" Resource Type: Io Range\n"); - - switch (Address64Data->Attribute.Io.RangeAttribute) - { - case ACPI_NON_ISA_ONLY_RANGES: - AcpiOsPrintf (" Type Specific: " - "Non-ISA Io Addresses\n"); - break; - - case ACPI_ISA_ONLY_RANGES: - AcpiOsPrintf (" Type Specific: " - "ISA Io Addresses\n"); - break; - - case ACPI_ENTIRE_RANGE: - AcpiOsPrintf (" Type Specific: " - "ISA and non-ISA Io Addresses\n"); - break; - - default: - AcpiOsPrintf (" Type Specific: " - "Invalid Range attribute"); - break; - } - - AcpiOsPrintf (" Type Specific: %s Translation\n", - ACPI_SPARSE_TRANSLATION == - Address64Data->Attribute.Io.TranslationAttribute ? - "Sparse" : "Dense"); - break; - - case ACPI_BUS_NUMBER_RANGE: - - AcpiOsPrintf (" Resource Type: Bus Number Range\n"); - break; - - default: - - AcpiOsPrintf (" Invalid Resource Type..exiting.\n"); return; } - AcpiOsPrintf (" Resource %s\n", - ACPI_CONSUMER == Address64Data->ProducerConsumer ? - "Consumer" : "Producer"); - - AcpiOsPrintf (" %s decode\n", - ACPI_SUB_DECODE == Address64Data->Decode ? - "Subtractive" : "Positive"); - - AcpiOsPrintf (" Min address is %s fixed\n", - ACPI_ADDRESS_FIXED == Address64Data->MinAddressFixed ? - "" : "not "); - - AcpiOsPrintf (" Max address is %s fixed\n", - ACPI_ADDRESS_FIXED == Address64Data->MaxAddressFixed ? - "" : "not "); + PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable); - AcpiOsPrintf (" Granularity: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Address64Data->Granularity)); + /* Dump all table elements, Exit on zero length element */ - AcpiOsPrintf (" Address range min: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Address64Data->MinAddressRange)); - - AcpiOsPrintf (" Address range max: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Address64Data->MaxAddressRange)); - - AcpiOsPrintf (" Address translation offset: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Address64Data->AddressTranslationOffset)); - - AcpiOsPrintf (" Address Length: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (Address64Data->AddressLength)); - - if(0xFF != Address64Data->ResourceSource.Index) + for (Count = 0; PrtElement->Length; Count++) { - AcpiOsPrintf (" Resource Source Index: %X\n", - Address64Data->ResourceSource.Index); - AcpiOsPrintf (" Resource Source: %s\n", - Address64Data->ResourceSource.StringPtr); - } + AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count); + AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt); - return; + PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, + ((UINT8 *) PrtElement) + PrtElement->Length); + } } /******************************************************************************* * - * FUNCTION: AcpiRsDumpExtendedIrq + * FUNCTION: AcpiRsOut* * - * PARAMETERS: Data - pointer to the resource structure to dump. + * PARAMETERS: Title - Name of the resource field + * Value - Value of the resource field * * RETURN: None * - * DESCRIPTION: Prints out the various members of the Data structure type. + * DESCRIPTION: Miscellaneous helper functions to consistently format the + * output of the resource dump routines * ******************************************************************************/ -void -AcpiRsDumpExtendedIrq ( - ACPI_RESOURCE_DATA *Data) +static void +AcpiRsOutString ( + char *Title, + char *Value) { - ACPI_RESOURCE_EXT_IRQ *ExtIrqData = (ACPI_RESOURCE_EXT_IRQ *) Data; - UINT8 Index = 0; - - - ACPI_FUNCTION_ENTRY (); - - - AcpiOsPrintf ("Extended IRQ Resource\n"); - - AcpiOsPrintf (" Resource %s\n", - ACPI_CONSUMER == ExtIrqData->ProducerConsumer ? - "Consumer" : "Producer"); - - AcpiOsPrintf (" %s\n", - ACPI_LEVEL_SENSITIVE == ExtIrqData->EdgeLevel ? - "Level" : "Edge"); - - AcpiOsPrintf (" Active %s\n", - ACPI_ACTIVE_LOW == ExtIrqData->ActiveHighLow ? - "low" : "high"); - - AcpiOsPrintf (" %s\n", - ACPI_SHARED == ExtIrqData->SharedExclusive ? - "Shared" : "Exclusive"); + AcpiOsPrintf ("%27s : %s\n", Title, Value); +} - AcpiOsPrintf (" Interrupts : %X ( ", - ExtIrqData->NumberOfInterrupts); +static void +AcpiRsOutInteger8 ( + char *Title, + UINT8 Value) +{ + AcpiOsPrintf ("%27s : %2.2X\n", Title, Value); +} - for (Index = 0; Index < ExtIrqData->NumberOfInterrupts; Index++) - { - AcpiOsPrintf ("%X ", ExtIrqData->Interrupts[Index]); - } +static void +AcpiRsOutInteger16 ( + char *Title, + UINT16 Value) +{ + AcpiOsPrintf ("%27s : %4.4X\n", Title, Value); +} - AcpiOsPrintf (")\n"); +static void +AcpiRsOutInteger32 ( + char *Title, + UINT32 Value) +{ + AcpiOsPrintf ("%27s : %8.8X\n", Title, Value); +} - if(0xFF != ExtIrqData->ResourceSource.Index) - { - AcpiOsPrintf (" Resource Source Index: %X", - ExtIrqData->ResourceSource.Index); - AcpiOsPrintf (" Resource Source: %s", - ExtIrqData->ResourceSource.StringPtr); - } +static void +AcpiRsOutInteger64 ( + char *Title, + UINT64 Value) +{ + AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title, + ACPI_FORMAT_UINT64 (Value)); +} - return; +static void +AcpiRsOutTitle ( + char *Title) +{ + AcpiOsPrintf ("%27s : ", Title); } /******************************************************************************* * - * FUNCTION: AcpiRsDumpResourceList + * FUNCTION: AcpiRsDump*List * - * PARAMETERS: Data - pointer to the resource structure to dump. + * PARAMETERS: Length - Number of elements in the list + * Data - Start of the list * * RETURN: None * - * DESCRIPTION: Dispatches the structure to the correct dump routine. + * DESCRIPTION: Miscellaneous functions to dump lists of raw data * ******************************************************************************/ -void -AcpiRsDumpResourceList ( - ACPI_RESOURCE *Resource) +static void +AcpiRsDumpByteList ( + UINT16 Length, + UINT8 *Data) { - UINT8 Count = 0; - BOOLEAN Done = FALSE; - - - ACPI_FUNCTION_ENTRY (); + UINT8 i; - if (AcpiDbgLevel & ACPI_LV_RESOURCES && _COMPONENT & AcpiDbgLayer) + for (i = 0; i < Length; i++) { - while (!Done) - { - AcpiOsPrintf ("Resource structure %X.\n", Count++); - - switch (Resource->Id) - { - case ACPI_RSTYPE_IRQ: - AcpiRsDumpIrq (&Resource->Data); - break; - - case ACPI_RSTYPE_DMA: - AcpiRsDumpDma (&Resource->Data); - break; - - case ACPI_RSTYPE_START_DPF: - AcpiRsDumpStartDependFns (&Resource->Data); - break; - - case ACPI_RSTYPE_END_DPF: - AcpiOsPrintf ("EndDependentFunctions Resource\n"); - /* AcpiRsDumpEndDependentFunctions (Resource->Data);*/ - break; - - case ACPI_RSTYPE_IO: - AcpiRsDumpIo (&Resource->Data); - break; - - case ACPI_RSTYPE_FIXED_IO: - AcpiRsDumpFixedIo (&Resource->Data); - break; - - case ACPI_RSTYPE_VENDOR: - AcpiRsDumpVendorSpecific (&Resource->Data); - break; - - case ACPI_RSTYPE_END_TAG: - /*RsDumpEndTag (Resource->Data);*/ - AcpiOsPrintf ("EndTag Resource\n"); - Done = TRUE; - break; - - case ACPI_RSTYPE_MEM24: - AcpiRsDumpMemory24 (&Resource->Data); - break; - - case ACPI_RSTYPE_MEM32: - AcpiRsDumpMemory32 (&Resource->Data); - break; - - case ACPI_RSTYPE_FIXED_MEM32: - AcpiRsDumpFixedMemory32 (&Resource->Data); - break; - - case ACPI_RSTYPE_ADDRESS16: - AcpiRsDumpAddress16 (&Resource->Data); - break; - - case ACPI_RSTYPE_ADDRESS32: - AcpiRsDumpAddress32 (&Resource->Data); - break; - - case ACPI_RSTYPE_ADDRESS64: - AcpiRsDumpAddress64 (&Resource->Data); - break; - - case ACPI_RSTYPE_EXT_IRQ: - AcpiRsDumpExtendedIrq (&Resource->Data); - break; - - default: - AcpiOsPrintf ("Invalid resource type\n"); - break; - - } - - Resource = ACPI_PTR_ADD (ACPI_RESOURCE, Resource, Resource->Length); - } + AcpiOsPrintf ("%25s%2.2X : %2.2X\n", + "Byte", i, Data[i]); } - - return; } -/******************************************************************************* - * - * FUNCTION: AcpiRsDumpIrqList - * - * PARAMETERS: Data - pointer to the routing table to dump. - * - * RETURN: None - * - * DESCRIPTION: Dispatches the structures to the correct dump routine. - * - ******************************************************************************/ - -void -AcpiRsDumpIrqList ( - UINT8 *RouteTable) +static void +AcpiRsDumpShortByteList ( + UINT8 Length, + UINT8 *Data) { - UINT8 *Buffer = RouteTable; - UINT8 Count = 0; - BOOLEAN Done = FALSE; - ACPI_PCI_ROUTING_TABLE *PrtElement; - - - ACPI_FUNCTION_ENTRY (); + UINT8 i; - if (AcpiDbgLevel & ACPI_LV_RESOURCES && _COMPONENT & AcpiDbgLayer) + for (i = 0; i < Length; i++) { - PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); - - while (!Done) - { - AcpiOsPrintf ("PCI IRQ Routing Table structure %X.\n", Count++); - - AcpiOsPrintf (" Address: %8.8X%8.8X\n", - ACPI_FORMAT_UINT64 (PrtElement->Address)); - - AcpiOsPrintf (" Pin: %X\n", PrtElement->Pin); - - AcpiOsPrintf (" Source: %s\n", PrtElement->Source); - - AcpiOsPrintf (" SourceIndex: %X\n", - PrtElement->SourceIndex); + AcpiOsPrintf ("%X ", Data[i]); + } + AcpiOsPrintf ("\n"); +} - Buffer += PrtElement->Length; +static void +AcpiRsDumpDwordList ( + UINT8 Length, + UINT32 *Data) +{ + UINT8 i; - PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); - if(0 == PrtElement->Length) - { - Done = TRUE; - } - } + for (i = 0; i < Length; i++) + { + AcpiOsPrintf ("%25s%2.2X : %8.8X\n", + "Dword", i, Data[i]); } - - return; } #endif diff --git a/sys/contrib/dev/acpica/rsinfo.c b/sys/contrib/dev/acpica/rsinfo.c new file mode 100644 index 0000000..eaf0b2b --- /dev/null +++ b/sys/contrib/dev/acpica/rsinfo.c @@ -0,0 +1,300 @@ +/******************************************************************************* + * + * Module Name: rsinfo - Dispatch and Info tables + * $Revision: 1.4 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __RSINFO_C__ + +#include <contrib/dev/acpica/acpi.h> +#include <contrib/dev/acpica/acresrc.h> + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsinfo") + +/* + * Resource dispatch and information tables. Any new resource types (either + * Large or Small) must be reflected in each of these tables, so they are here + * in one place. + * + * The tables for Large descriptors are indexed by bits 6:0 of the AML + * descriptor type byte. The tables for Small descriptors are indexed by + * bits 6:3 of the descriptor byte. The tables for internal resource + * descriptors are indexed by the ACPI_RESOURCE_TYPE field. + */ + + +/* Dispatch table for resource-to-AML (Set Resource) conversion functions */ + +ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[] = +{ + AcpiRsSetIrq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */ + AcpiRsConvertDma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */ + AcpiRsSetStartDpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */ + AcpiRsConvertEndDpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */ + AcpiRsConvertIo, /* 0x04, ACPI_RESOURCE_TYPE_IO */ + AcpiRsConvertFixedIo, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */ + AcpiRsSetVendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */ + AcpiRsConvertEndTag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */ + AcpiRsConvertMemory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */ + AcpiRsConvertMemory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */ + AcpiRsConvertFixedMemory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ + AcpiRsConvertAddress16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */ + AcpiRsConvertAddress32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */ + AcpiRsConvertAddress64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */ + AcpiRsConvertExtAddress64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ + AcpiRsConvertExtIrq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ + AcpiRsConvertGenericReg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ +}; + +/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ + +ACPI_RSCONVERT_INFO *AcpiGbl_SmGetResourceDispatch[] = +{ + NULL, /* 0x00, Reserved */ + NULL, /* 0x01, Reserved */ + NULL, /* 0x02, Reserved */ + NULL, /* 0x03, Reserved */ + AcpiRsGetIrq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */ + AcpiRsConvertDma, /* 0x05, ACPI_RESOURCE_NAME_DMA */ + AcpiRsGetStartDpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */ + AcpiRsConvertEndDpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */ + AcpiRsConvertIo, /* 0x08, ACPI_RESOURCE_NAME_IO */ + AcpiRsConvertFixedIo, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */ + NULL, /* 0x0A, Reserved */ + NULL, /* 0x0B, Reserved */ + NULL, /* 0x0C, Reserved */ + NULL, /* 0x0D, Reserved */ + AcpiRsGetVendorSmall, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */ + AcpiRsConvertEndTag /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ +}; + +ACPI_RSCONVERT_INFO *AcpiGbl_LgGetResourceDispatch[] = +{ + NULL, /* 0x00, Reserved */ + AcpiRsConvertMemory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */ + AcpiRsConvertGenericReg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ + NULL, /* 0x03, Reserved */ + AcpiRsGetVendorLarge, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */ + AcpiRsConvertMemory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */ + AcpiRsConvertFixedMemory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */ + AcpiRsConvertAddress32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */ + AcpiRsConvertAddress16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */ + AcpiRsConvertExtIrq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */ + AcpiRsConvertAddress64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */ + AcpiRsConvertExtAddress64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */ +}; + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +/* Dispatch table for resource dump functions */ + +ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[] = +{ + AcpiRsDumpIrq, /* ACPI_RESOURCE_TYPE_IRQ */ + AcpiRsDumpDma, /* ACPI_RESOURCE_TYPE_DMA */ + AcpiRsDumpStartDpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */ + AcpiRsDumpEndDpf, /* ACPI_RESOURCE_TYPE_END_DEPENDENT */ + AcpiRsDumpIo, /* ACPI_RESOURCE_TYPE_IO */ + AcpiRsDumpFixedIo, /* ACPI_RESOURCE_TYPE_FIXED_IO */ + AcpiRsDumpVendor, /* ACPI_RESOURCE_TYPE_VENDOR */ + AcpiRsDumpEndTag, /* ACPI_RESOURCE_TYPE_END_TAG */ + AcpiRsDumpMemory24, /* ACPI_RESOURCE_TYPE_MEMORY24 */ + AcpiRsDumpMemory32, /* ACPI_RESOURCE_TYPE_MEMORY32 */ + AcpiRsDumpFixedMemory32, /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ + AcpiRsDumpAddress16, /* ACPI_RESOURCE_TYPE_ADDRESS16 */ + AcpiRsDumpAddress32, /* ACPI_RESOURCE_TYPE_ADDRESS32 */ + AcpiRsDumpAddress64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */ + AcpiRsDumpExtAddress64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ + AcpiRsDumpExtIrq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ + AcpiRsDumpGenericReg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ +}; + + +#endif + + +/* + * Base sizes for external AML resource descriptors, indexed by internal type. + * Includes size of the descriptor header (1 byte for small descriptors, + * 3 bytes for large descriptors) + */ +const UINT8 AcpiGbl_AmlResourceSizes[] = +{ + sizeof (AML_RESOURCE_IRQ), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */ + sizeof (AML_RESOURCE_DMA), /* ACPI_RESOURCE_TYPE_DMA */ + sizeof (AML_RESOURCE_START_DEPENDENT), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */ + sizeof (AML_RESOURCE_END_DEPENDENT), /* ACPI_RESOURCE_TYPE_END_DEPENDENT */ + sizeof (AML_RESOURCE_IO), /* ACPI_RESOURCE_TYPE_IO */ + sizeof (AML_RESOURCE_FIXED_IO), /* ACPI_RESOURCE_TYPE_FIXED_IO */ + sizeof (AML_RESOURCE_VENDOR_SMALL), /* ACPI_RESOURCE_TYPE_VENDOR */ + sizeof (AML_RESOURCE_END_TAG), /* ACPI_RESOURCE_TYPE_END_TAG */ + sizeof (AML_RESOURCE_MEMORY24), /* ACPI_RESOURCE_TYPE_MEMORY24 */ + sizeof (AML_RESOURCE_MEMORY32), /* ACPI_RESOURCE_TYPE_MEMORY32 */ + sizeof (AML_RESOURCE_FIXED_MEMORY32), /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ + sizeof (AML_RESOURCE_ADDRESS16), /* ACPI_RESOURCE_TYPE_ADDRESS16 */ + sizeof (AML_RESOURCE_ADDRESS32), /* ACPI_RESOURCE_TYPE_ADDRESS32 */ + sizeof (AML_RESOURCE_ADDRESS64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */ + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),/*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ + sizeof (AML_RESOURCE_EXTENDED_IRQ), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ + sizeof (AML_RESOURCE_GENERIC_REGISTER) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ +}; + + +/* Macros used in the tables below */ + +#define ACPI_RLARGE(r) (sizeof (r) - sizeof (AML_RESOURCE_LARGE_HEADER)) +#define ACPI_RSMALL(r) (sizeof (r) - sizeof (AML_RESOURCE_SMALL_HEADER)) + +/* + * Base sizes of resource descriptors, both the AML stream resource length + * (minus size of header and length fields),and the size of the internal + * struct representation. + */ +ACPI_RESOURCE_INFO AcpiGbl_SmResourceInfo [] = +{ + {0, 0, 0}, + {0, 0, 0}, + {0, 0, 0}, + {0, 0, 0}, + {2, ACPI_RSMALL (AML_RESOURCE_IRQ), ACPI_RS_SIZE (ACPI_RESOURCE_IRQ)}, + {0, ACPI_RSMALL (AML_RESOURCE_DMA), ACPI_RS_SIZE (ACPI_RESOURCE_DMA)}, + {2, ACPI_RSMALL (AML_RESOURCE_START_DEPENDENT), ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT)}, + {0, ACPI_RSMALL (AML_RESOURCE_END_DEPENDENT), ACPI_RS_SIZE_MIN}, + {0, ACPI_RSMALL (AML_RESOURCE_IO), ACPI_RS_SIZE (ACPI_RESOURCE_IO)}, + {0, ACPI_RSMALL (AML_RESOURCE_FIXED_IO), ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO)}, + {0, 0, 0}, + {0, 0, 0}, + {0, 0, 0}, + {0, 0, 0}, + {1, ACPI_RSMALL (AML_RESOURCE_VENDOR_SMALL), ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR)}, + {0, ACPI_RSMALL (AML_RESOURCE_END_TAG), ACPI_RS_SIZE_MIN} +}; + +ACPI_RESOURCE_INFO AcpiGbl_LgResourceInfo [] = +{ + {0, 0, 0}, + {0, ACPI_RLARGE (AML_RESOURCE_MEMORY24), ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24)}, + {0, ACPI_RLARGE (AML_RESOURCE_GENERIC_REGISTER), ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER)}, + {0, 0, 0}, + {1, ACPI_RLARGE (AML_RESOURCE_VENDOR_LARGE), ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR)}, + {0, ACPI_RLARGE (AML_RESOURCE_MEMORY32), ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32)}, + {0, ACPI_RLARGE (AML_RESOURCE_FIXED_MEMORY32), ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32)}, + {1, ACPI_RLARGE (AML_RESOURCE_ADDRESS32), ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32)}, + {1, ACPI_RLARGE (AML_RESOURCE_ADDRESS16), ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16)}, + {1, ACPI_RLARGE (AML_RESOURCE_EXTENDED_IRQ), ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ)}, + {1, ACPI_RLARGE (AML_RESOURCE_ADDRESS64), ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64)}, + {0, ACPI_RLARGE (AML_RESOURCE_EXTENDED_ADDRESS64), ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64)} +}; + diff --git a/sys/contrib/dev/acpica/rsio.c b/sys/contrib/dev/acpica/rsio.c index 5645968..82667f1 100644 --- a/sys/contrib/dev/acpica/rsio.c +++ b/sys/contrib/dev/acpica/rsio.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsio - IO and DMA resource descriptors - * $Revision: 25 $ + * $Revision: 1.33 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,500 +125,217 @@ /******************************************************************************* * - * FUNCTION: AcpiRsIoResource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. + * AcpiRsConvertIo * ******************************************************************************/ -ACPI_STATUS -AcpiRsIoResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +ACPI_RSCONVERT_INFO AcpiRsConvertIo[5] = { - UINT8 *Buffer = ByteStreamBuffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_IO); + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO, + ACPI_RS_SIZE (ACPI_RESOURCE_IO), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertIo)}, + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO, + sizeof (AML_RESOURCE_IO), + 0}, - ACPI_FUNCTION_TRACE ("RsIoResource"); - + /* Decode flag */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Io.IoDecode), + AML_OFFSET (Io.Flags), + 0}, /* - * The number of bytes consumed are Constant + * These fields are contiguous in both the source and destination: + * Address Alignment + * Length + * Minimum Base Address + * Maximum Base Address */ - *BytesConsumed = 8; + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Io.Alignment), + AML_OFFSET (Io.Alignment), + 2}, - OutputStruct->Id = ACPI_RSTYPE_IO; - - /* - * Check Decode - */ - Buffer += 1; - Temp8 = *Buffer; - - OutputStruct->Data.Io.IoDecode = Temp8 & 0x01; - - /* - * Check MinBase Address - */ - Buffer += 1; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - - OutputStruct->Data.Io.MinBaseAddress = Temp16; - - /* - * Check MaxBase Address - */ - Buffer += 2; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - - OutputStruct->Data.Io.MaxBaseAddress = Temp16; - - /* - * Check Base alignment - */ - Buffer += 2; - Temp8 = *Buffer; - - OutputStruct->Data.Io.Alignment = Temp8; - - /* - * Check RangeLength - */ - Buffer += 1; - Temp8 = *Buffer; - - OutputStruct->Data.Io.RangeLength = Temp8; - - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; - - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Io.Minimum), + AML_OFFSET (Io.Minimum), + 2} +}; /******************************************************************************* * - * FUNCTION: AcpiRsFixedIoResource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. + * AcpiRsConvertFixedIo * ******************************************************************************/ -ACPI_STATUS -AcpiRsFixedIoResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[4] = { - UINT8 *Buffer = ByteStreamBuffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_FIXED_IO); - - - ACPI_FUNCTION_TRACE ("RsFixedIoResource"); - + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO, + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedIo)}, + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO, + sizeof (AML_RESOURCE_FIXED_IO), + 0}, /* - * The number of bytes consumed are Constant + * These fields are contiguous in both the source and destination: + * Base Address + * Length */ - *BytesConsumed = 4; + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.FixedIo.AddressLength), + AML_OFFSET (FixedIo.AddressLength), + 1}, - OutputStruct->Id = ACPI_RSTYPE_FIXED_IO; - - /* - * Check Range Base Address - */ - Buffer += 1; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - - OutputStruct->Data.FixedIo.BaseAddress = Temp16; - - /* - * Check RangeLength - */ - Buffer += 2; - Temp8 = *Buffer; - - OutputStruct->Data.FixedIo.RangeLength = Temp8; - - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; - - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.FixedIo.Address), + AML_OFFSET (FixedIo.Address), + 1} +}; /******************************************************************************* * - * FUNCTION: AcpiRsIoStream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * AcpiRsConvertGenericReg * ******************************************************************************/ -ACPI_STATUS -AcpiRsIoStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[4] = { - UINT8 *Buffer = *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - - - ACPI_FUNCTION_TRACE ("RsIoStream"); - - - /* - * The descriptor field is static - */ - *Buffer = 0x47; - Buffer += 1; - - /* - * Io Information Byte - */ - Temp8 = (UINT8) (LinkedList->Data.Io.IoDecode & 0x01); - - *Buffer = Temp8; - Buffer += 1; + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER, + ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertGenericReg)}, + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER, + sizeof (AML_RESOURCE_GENERIC_REGISTER), + 0}, /* - * Set the Range minimum base address + * These fields are contiguous in both the source and destination: + * Address Space ID + * Register Bit Width + * Register Bit Offset + * Access Size */ - Temp16 = (UINT16) LinkedList->Data.Io.MinBaseAddress; + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.GenericReg.SpaceId), + AML_OFFSET (GenericReg.AddressSpaceId), + 4}, - ACPI_MOVE_16_TO_16 (Buffer, &Temp16); - Buffer += 2; + /* Get the Register Address */ - /* - * Set the Range maximum base address - */ - Temp16 = (UINT16) LinkedList->Data.Io.MaxBaseAddress; - - ACPI_MOVE_16_TO_16 (Buffer, &Temp16); - Buffer += 2; - - /* - * Set the base alignment - */ - Temp8 = (UINT8) LinkedList->Data.Io.Alignment; - - *Buffer = Temp8; - Buffer += 1; - - /* - * Set the range length - */ - Temp8 = (UINT8) LinkedList->Data.Io.RangeLength; - - *Buffer = Temp8; - Buffer += 1; - - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.GenericReg.Address), + AML_OFFSET (GenericReg.Address), + 1} +}; /******************************************************************************* * - * FUNCTION: AcpiRsFixedIoStream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * AcpiRsConvertEndDpf * ******************************************************************************/ -ACPI_STATUS -AcpiRsFixedIoStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[2] = { - UINT8 *Buffer = *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT, + ACPI_RS_SIZE_MIN, + ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndDpf)}, - ACPI_FUNCTION_TRACE ("RsFixedIoStream"); + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT, + sizeof (AML_RESOURCE_END_DEPENDENT), + 0} +}; - /* - * The descriptor field is static - */ - *Buffer = 0x4B; - - Buffer += 1; - - /* - * Set the Range base address - */ - Temp16 = (UINT16) LinkedList->Data.FixedIo.BaseAddress; - - ACPI_MOVE_16_TO_16 (Buffer, &Temp16); - Buffer += 2; - - /* - * Set the range length - */ - Temp8 = (UINT8) LinkedList->Data.FixedIo.RangeLength; +/******************************************************************************* + * + * AcpiRsConvertEndTag + * + ******************************************************************************/ - *Buffer = Temp8; - Buffer += 1; +ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[2] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG, + ACPI_RS_SIZE_MIN, + ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndTag)}, /* - * Return the number of bytes consumed in this operation + * Note: The checksum field is set to zero, meaning that the resource + * data is treated as if the checksum operation succeeded. + * (ACPI Spec 1.0b Section 6.4.2.8) */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG, + sizeof (AML_RESOURCE_END_TAG), + 0} +}; /******************************************************************************* * - * FUNCTION: AcpiRsDmaResource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. + * AcpiRsGetStartDpf * ******************************************************************************/ -ACPI_STATUS -AcpiRsDmaResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[5] = { - UINT8 *Buffer = ByteStreamBuffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT8 Temp8 = 0; - UINT8 Index; - UINT8 i; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_DMA); + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT, + ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT), + ACPI_RSC_TABLE_SIZE (AcpiRsGetStartDpf)}, + /* Defaults for Compatibility and Performance priorities */ - ACPI_FUNCTION_TRACE ("RsDmaResource"); + {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + ACPI_ACCEPTABLE_CONFIGURATION, + 2}, + /* All done if there is no flag byte present in the descriptor */ - /* - * The number of bytes consumed are Constant - */ - *BytesConsumed = 3; - OutputStruct->Id = ACPI_RSTYPE_DMA; - - /* - * Point to the 8-bits of Byte 1 - */ - Buffer += 1; - Temp8 = *Buffer; - - /* Decode the DMA channel bits */ - - for (i = 0, Index = 0; Index < 8; Index++) - { - if ((Temp8 >> Index) & 0x01) - { - OutputStruct->Data.Dma.Channels[i] = Index; - i++; - } - } - - /* Zero DMA channels is valid */ - - OutputStruct->Data.Dma.NumberOfChannels = i; - if (i > 0) - { - /* - * Calculate the structure size based upon the number of interrupts - */ - StructSize += ((ACPI_SIZE) i - 1) * 4; - } - - /* - * Point to Byte 2 - */ - Buffer += 1; - Temp8 = *Buffer; + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1}, - /* - * Check for transfer preference (Bits[1:0]) - */ - OutputStruct->Data.Dma.Transfer = Temp8 & 0x03; - - if (0x03 == OutputStruct->Data.Dma.Transfer) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid DMA.Transfer preference (3)\n")); - return_ACPI_STATUS (AE_BAD_DATA); - } - - /* - * Get bus master preference (Bit[2]) - */ - OutputStruct->Data.Dma.BusMaster = (Temp8 >> 2) & 0x01; - - /* - * Get channel speed support (Bits[6:5]) - */ - OutputStruct->Data.Dma.Type = (Temp8 >> 5) & 0x03; + /* Flag byte is present, get the flags */ - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + AML_OFFSET (StartDpf.Flags), + 0}, - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), + AML_OFFSET (StartDpf.Flags), + 2} +}; /******************************************************************************* * - * FUNCTION: AcpiRsDmaStream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * AcpiRsSetStartDpf * ******************************************************************************/ -ACPI_STATUS -AcpiRsDmaStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[6] = { - UINT8 *Buffer = *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - UINT8 Index; + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT, + sizeof (AML_RESOURCE_START_DEPENDENT), + ACPI_RSC_TABLE_SIZE (AcpiRsSetStartDpf)}, + /* Set the default flag values */ - ACPI_FUNCTION_TRACE ("RsDmaStream"); - - - /* - * The descriptor field is static - */ - *Buffer = 0x2A; - Buffer += 1; - Temp8 = 0; + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + AML_OFFSET (StartDpf.Flags), + 0}, + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), + AML_OFFSET (StartDpf.Flags), + 2}, /* - * Loop through all of the Channels and set the mask bits + * All done if flags byte is necessary -- if either priority value + * is not ACPI_ACCEPTABLE_CONFIGURATION */ - for (Index = 0; - Index < LinkedList->Data.Dma.NumberOfChannels; - Index++) - { - Temp16 = (UINT16) LinkedList->Data.Dma.Channels[Index]; - Temp8 |= 0x1 << Temp16; - } + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + ACPI_ACCEPTABLE_CONFIGURATION}, - *Buffer = Temp8; - Buffer += 1; + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), + ACPI_ACCEPTABLE_CONFIGURATION}, - /* - * Set the DMA Info - */ - Temp8 = (UINT8) ((LinkedList->Data.Dma.Type & 0x03) << 5); - Temp8 |= ((LinkedList->Data.Dma.BusMaster & 0x01) << 2); - Temp8 |= (LinkedList->Data.Dma.Transfer & 0x03); + /* Flag byte is not necessary */ - *Buffer = Temp8; - Buffer += 1; + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)} +}; - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - return_ACPI_STATUS (AE_OK); -} diff --git a/sys/contrib/dev/acpica/rsirq.c b/sys/contrib/dev/acpica/rsirq.c index 6b7c5dc..0953fa4 100644 --- a/sys/contrib/dev/acpica/rsirq.c +++ b/sys/contrib/dev/acpica/rsirq.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsirq - IRQ resource descriptors - * $Revision: 38 $ + * $Revision: 1.48 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,563 +125,189 @@ /******************************************************************************* * - * FUNCTION: AcpiRsIrqResource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. + * AcpiRsGetIrq * ******************************************************************************/ -ACPI_STATUS -AcpiRsIrqResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +ACPI_RSCONVERT_INFO AcpiRsGetIrq[7] = { - UINT8 *Buffer = ByteStreamBuffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - UINT8 Index; - UINT8 i; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_IRQ); - - - ACPI_FUNCTION_TRACE ("RsIrqResource"); - + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ, + ACPI_RS_SIZE (ACPI_RESOURCE_IRQ), + ACPI_RSC_TABLE_SIZE (AcpiRsGetIrq)}, - /* - * The number of bytes consumed are contained in the descriptor - * (Bits:0-1) - */ - Temp8 = *Buffer; - *BytesConsumed = (Temp8 & 0x03) + 1; - OutputStruct->Id = ACPI_RSTYPE_IRQ; + /* Get the IRQ mask (bytes 1:2) */ - /* - * Point to the 16-bits of Bytes 1 and 2 - */ - Buffer += 1; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); + {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]), + AML_OFFSET (Irq.IrqMask), + ACPI_RS_OFFSET (Data.Irq.InterruptCount)}, - OutputStruct->Data.Irq.NumberOfInterrupts = 0; + /* Set default flags (others are zero) */ - /* Decode the IRQ bits */ + {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.Irq.Triggering), + ACPI_EDGE_SENSITIVE, + 1}, - for (i = 0, Index = 0; Index < 16; Index++) - { - if ((Temp16 >> Index) & 0x01) - { - OutputStruct->Data.Irq.Interrupts[i] = Index; - i++; - } - } + /* All done if no flag byte present in descriptor */ - /* Zero interrupts is valid */ + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3}, - OutputStruct->Data.Irq.NumberOfInterrupts = i; - if (i > 0) - { - /* - * Calculate the structure size based upon the number of interrupts - */ - StructSize += ((ACPI_SIZE) i - 1) * 4; - } + /* Get flags: Triggering[0], Polarity[3], Sharing[4] */ - /* - * Point to Byte 3 if it is used - */ - if (4 == *BytesConsumed) - { - Buffer += 2; - Temp8 = *Buffer; - - /* - * Check for HE, LL interrupts - */ - switch (Temp8 & 0x09) - { - case 0x01: /* HE */ - OutputStruct->Data.Irq.EdgeLevel = ACPI_EDGE_SENSITIVE; - OutputStruct->Data.Irq.ActiveHighLow = ACPI_ACTIVE_HIGH; - break; - - case 0x08: /* LL */ - OutputStruct->Data.Irq.EdgeLevel = ACPI_LEVEL_SENSITIVE; - OutputStruct->Data.Irq.ActiveHighLow = ACPI_ACTIVE_LOW; - break; - - default: - /* - * Only _LL and _HE polarity/trigger interrupts - * are allowed (ACPI spec, section "IRQ Format") - * so 0x00 and 0x09 are illegal. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid interrupt polarity/trigger in resource list, %X\n", Temp8)); - return_ACPI_STATUS (AE_BAD_DATA); - } - - /* - * Check for sharable - */ - OutputStruct->Data.Irq.SharedExclusive = (Temp8 >> 3) & 0x01; - } - else - { - /* - * Assume Edge Sensitive, Active High, Non-Sharable - * per ACPI Specification - */ - OutputStruct->Data.Irq.EdgeLevel = ACPI_EDGE_SENSITIVE; - OutputStruct->Data.Irq.ActiveHighLow = ACPI_ACTIVE_HIGH; - OutputStruct->Data.Irq.SharedExclusive = ACPI_EXCLUSIVE; - } + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering), + AML_OFFSET (Irq.Flags), + 0}, - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity), + AML_OFFSET (Irq.Flags), + 3}, - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable), + AML_OFFSET (Irq.Flags), + 4} +}; /******************************************************************************* * - * FUNCTION: AcpiRsIrqStream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * AcpiRsSetIrq * ******************************************************************************/ -ACPI_STATUS -AcpiRsIrqStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +ACPI_RSCONVERT_INFO AcpiRsSetIrq[9] = { - UINT8 *Buffer = *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - UINT8 Index; - BOOLEAN IRQInfoByteNeeded; + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ, + sizeof (AML_RESOURCE_IRQ), + ACPI_RSC_TABLE_SIZE (AcpiRsSetIrq)}, + /* Convert interrupt list to 16-bit IRQ bitmask */ - ACPI_FUNCTION_TRACE ("RsIrqStream"); + {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]), + AML_OFFSET (Irq.IrqMask), + ACPI_RS_OFFSET (Data.Irq.InterruptCount)}, + /* Set the flags byte by default */ - /* - * The descriptor field is set based upon whether a third byte is - * needed to contain the IRQ Information. - */ - if (ACPI_EDGE_SENSITIVE == LinkedList->Data.Irq.EdgeLevel && - ACPI_ACTIVE_HIGH == LinkedList->Data.Irq.ActiveHighLow && - ACPI_EXCLUSIVE == LinkedList->Data.Irq.SharedExclusive) - { - *Buffer = 0x22; - IRQInfoByteNeeded = FALSE; - } - else - { - *Buffer = 0x23; - IRQInfoByteNeeded = TRUE; - } - - Buffer += 1; - Temp16 = 0; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering), + AML_OFFSET (Irq.Flags), + 0}, + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity), + AML_OFFSET (Irq.Flags), + 3}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable), + AML_OFFSET (Irq.Flags), + 4}, /* - * Loop through all of the interrupts and set the mask bits + * Check if the flags byte is necessary. Not needed if the flags are: + * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE */ - for(Index = 0; - Index < LinkedList->Data.Irq.NumberOfInterrupts; - Index++) - { - Temp8 = (UINT8) LinkedList->Data.Irq.Interrupts[Index]; - Temp16 |= 0x1 << Temp8; - } + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.Irq.Triggering), + ACPI_EDGE_SENSITIVE}, - ACPI_MOVE_16_TO_16 (Buffer, &Temp16); - Buffer += 2; + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.Irq.Polarity), + ACPI_ACTIVE_HIGH}, - /* - * Set the IRQ Info byte if needed. - */ - if (IRQInfoByteNeeded) - { - Temp8 = 0; - Temp8 = (UINT8) ((LinkedList->Data.Irq.SharedExclusive & - 0x01) << 4); - - if (ACPI_LEVEL_SENSITIVE == LinkedList->Data.Irq.EdgeLevel && - ACPI_ACTIVE_LOW == LinkedList->Data.Irq.ActiveHighLow) - { - Temp8 |= 0x08; - } - else - { - Temp8 |= 0x01; - } - - *Buffer = Temp8; - Buffer += 1; - } + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.Irq.Sharable), + ACPI_EXCLUSIVE}, - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - return_ACPI_STATUS (AE_OK); -} + /* IrqNoFlags() descriptor can be used */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)} +}; /******************************************************************************* * - * FUNCTION: AcpiRsExtendedIrqResource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. + * AcpiRsConvertExtIrq * ******************************************************************************/ -ACPI_STATUS -AcpiRsExtendedIrqResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[9] = { - UINT8 *Buffer = ByteStreamBuffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - UINT8 *TempPtr; - UINT8 Index; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_EXT_IRQ); - - - ACPI_FUNCTION_TRACE ("RsExtendedIrqResource"); - - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - Buffer += 1; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ, + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtIrq)}, - /* Validate minimum descriptor length */ + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ, + sizeof (AML_RESOURCE_EXTENDED_IRQ), + 0}, - if (Temp16 < 6) - { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); - } + /* Flag bits */ - *BytesConsumed = Temp16 + 3; - OutputStruct->Id = ACPI_RSTYPE_EXT_IRQ; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.ProducerConsumer), + AML_OFFSET (ExtendedIrq.Flags), + 0}, - /* - * Point to the Byte3 - */ - Buffer += 2; - Temp8 = *Buffer; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Triggering), + AML_OFFSET (ExtendedIrq.Flags), + 1}, - OutputStruct->Data.ExtendedIrq.ProducerConsumer = Temp8 & 0x01; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Polarity), + AML_OFFSET (ExtendedIrq.Flags), + 2}, - /* - * Check for Interrupt Mode - * - * The definition of an Extended IRQ changed between ACPI spec v1.0b - * and ACPI spec 2.0 (section 6.4.3.6 in both). - * - * - Edge/Level are defined opposite in the table vs the headers - */ - OutputStruct->Data.ExtendedIrq.EdgeLevel = - (Temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Sharable), + AML_OFFSET (ExtendedIrq.Flags), + 3}, - /* - * Check Interrupt Polarity - */ - OutputStruct->Data.ExtendedIrq.ActiveHighLow = (Temp8 >> 2) & 0x1; + /* IRQ Table length (Byte4) */ - /* - * Check for sharable - */ - OutputStruct->Data.ExtendedIrq.SharedExclusive = (Temp8 >> 3) & 0x01; + {ACPI_RSC_COUNT, ACPI_RS_OFFSET (Data.ExtendedIrq.InterruptCount), + AML_OFFSET (ExtendedIrq.InterruptCount), + sizeof (UINT32)}, - /* - * Point to Byte4 (IRQ Table length) - */ - Buffer += 1; - Temp8 = *Buffer; + /* Copy every IRQ in the table, each is 32 bits */ - /* Must have at least one IRQ */ + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]), + AML_OFFSET (ExtendedIrq.Interrupts[0]), + 0}, - if (Temp8 < 1) - { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); - } + /* Optional ResourceSource (Index and String) */ - OutputStruct->Data.ExtendedIrq.NumberOfInterrupts = Temp8; - - /* - * Add any additional structure size to properly calculate - * the next pointer at the end of this function - */ - StructSize += (Temp8 - 1) * 4; - - /* - * Point to Byte5 (First IRQ Number) - */ - Buffer += 1; - - /* - * Cycle through every IRQ in the table - */ - for (Index = 0; Index < Temp8; Index++) - { - ACPI_MOVE_32_TO_32 ( - &OutputStruct->Data.ExtendedIrq.Interrupts[Index], Buffer); - - /* Point to the next IRQ */ - - Buffer += 4; - } - - /* - * This will leave us pointing to the Resource Source Index - * If it is present, then save it off and calculate the - * pointer to where the null terminated string goes: - * Each Interrupt takes 32-bits + the 5 bytes of the - * stream that are default. - * - * Note: Some resource descriptors will have an additional null, so - * we add 1 to the length. - */ - if (*BytesConsumed > - ((ACPI_SIZE) OutputStruct->Data.ExtendedIrq.NumberOfInterrupts * 4) + (5 + 1)) - { - /* Dereference the Index */ - - Temp8 = *Buffer; - OutputStruct->Data.ExtendedIrq.ResourceSource.Index = (UINT32) Temp8; - - /* Point to the String */ - - Buffer += 1; - - /* - * Point the String pointer to the end of this structure. - */ - OutputStruct->Data.ExtendedIrq.ResourceSource.StringPtr = - (char *)((char *) OutputStruct + StructSize); - - TempPtr = (UINT8 *) OutputStruct->Data.ExtendedIrq.ResourceSource.StringPtr; - - /* Copy the string into the buffer */ - - Index = 0; - while (0x00 != *Buffer) - { - *TempPtr = *Buffer; - - TempPtr += 1; - Buffer += 1; - Index += 1; - } - - /* - * Add the terminating null - */ - *TempPtr = 0x00; - OutputStruct->Data.ExtendedIrq.ResourceSource.StringLength = Index + 1; - - /* - * In order for the StructSize to fall on a 32-bit boundary, - * calculate the length of the string and expand the - * StructSize to the next 32-bit boundary. - */ - Temp8 = (UINT8) (Index + 1); - StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8); - } - else - { - OutputStruct->Data.ExtendedIrq.ResourceSource.Index = 0x00; - OutputStruct->Data.ExtendedIrq.ResourceSource.StringLength = 0; - OutputStruct->Data.ExtendedIrq.ResourceSource.StringPtr = NULL; - } - - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; - - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET (Data.ExtendedIrq.ResourceSource), + ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]), + sizeof (AML_RESOURCE_EXTENDED_IRQ)} +}; /******************************************************************************* * - * FUNCTION: AcpiRsExtendedIrqStream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * AcpiRsConvertDma * ******************************************************************************/ -ACPI_STATUS -AcpiRsExtendedIrqStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +ACPI_RSCONVERT_INFO AcpiRsConvertDma[6] = { - UINT8 *Buffer = *OutputBuffer; - UINT16 *LengthField; - UINT8 Temp8 = 0; - UINT8 Index; - char *TempPointer = NULL; + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA, + ACPI_RS_SIZE (ACPI_RESOURCE_DMA), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertDma)}, + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA, + sizeof (AML_RESOURCE_DMA), + 0}, - ACPI_FUNCTION_TRACE ("RsExtendedIrqStream"); + /* Flags: transfer preference, bus mastering, channel speed */ + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Transfer), + AML_OFFSET (Dma.Flags), + 0}, - /* - * The descriptor field is static - */ - *Buffer = 0x89; - Buffer += 1; + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Dma.BusMaster), + AML_OFFSET (Dma.Flags), + 2}, - /* - * Set a pointer to the Length field - to be filled in later - */ - LengthField = ACPI_CAST_PTR (UINT16, Buffer); - Buffer += 2; - - /* - * Set the Interrupt vector flags - */ - Temp8 = (UINT8)(LinkedList->Data.ExtendedIrq.ProducerConsumer & 0x01); - Temp8 |= ((LinkedList->Data.ExtendedIrq.SharedExclusive & 0x01) << 3); - - /* - * Set the Interrupt Mode - * - * The definition of an Extended IRQ changed between ACPI spec v1.0b - * and ACPI spec 2.0 (section 6.4.3.6 in both). This code does not - * implement the more restrictive definition of 1.0b - * - * - Edge/Level are defined opposite in the table vs the headers - */ - if (ACPI_EDGE_SENSITIVE == LinkedList->Data.ExtendedIrq.EdgeLevel) - { - Temp8 |= 0x2; - } - - /* - * Set the Interrupt Polarity - */ - Temp8 |= ((LinkedList->Data.ExtendedIrq.ActiveHighLow & 0x1) << 2); + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Type), + AML_OFFSET (Dma.Flags), + 5}, - *Buffer = Temp8; - Buffer += 1; + /* DMA channel mask bits */ - /* - * Set the Interrupt table length - */ - Temp8 = (UINT8) LinkedList->Data.ExtendedIrq.NumberOfInterrupts; - - *Buffer = Temp8; - Buffer += 1; - - for (Index = 0; Index < LinkedList->Data.ExtendedIrq.NumberOfInterrupts; - Index++) - { - ACPI_MOVE_32_TO_32 (Buffer, - &LinkedList->Data.ExtendedIrq.Interrupts[Index]); - Buffer += 4; - } - - /* - * Resource Source Index and Resource Source are optional - */ - if (0 != LinkedList->Data.ExtendedIrq.ResourceSource.StringLength) - { - *Buffer = (UINT8) LinkedList->Data.ExtendedIrq.ResourceSource.Index; - Buffer += 1; - - TempPointer = (char *) Buffer; - - /* - * Copy the string - */ - ACPI_STRCPY (TempPointer, - LinkedList->Data.ExtendedIrq.ResourceSource.StringPtr); - - /* - * Buffer needs to be set to the length of the sting + one for the - * terminating null - */ - Buffer += (ACPI_SIZE)(ACPI_STRLEN (LinkedList->Data.ExtendedIrq.ResourceSource.StringPtr) + 1); - } - - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - - /* - * Set the length field to the number of bytes consumed - * minus the header size (3 bytes) - */ - *LengthField = (UINT16) (*BytesConsumed - 3); - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_BITMASK, ACPI_RS_OFFSET (Data.Dma.Channels[0]), + AML_OFFSET (Dma.DmaChannelMask), + ACPI_RS_OFFSET (Data.Dma.ChannelCount)} +}; diff --git a/sys/contrib/dev/acpica/rslist.c b/sys/contrib/dev/acpica/rslist.c index ecb6029..ac1d95f 100644 --- a/sys/contrib/dev/acpica/rslist.c +++ b/sys/contrib/dev/acpica/rslist.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rslist - Linked list utilities - * $Revision: 34 $ + * $Revision: 1.47 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,65 +123,141 @@ ACPI_MODULE_NAME ("rslist") +/* Local prototypes */ + +static ACPI_RSCONVERT_INFO * +AcpiRsGetConversionInfo ( + UINT8 ResourceType); + +static ACPI_STATUS +AcpiRsValidateResourceLength ( + AML_RESOURCE *Aml); + + /******************************************************************************* * - * FUNCTION: AcpiRsGetResourceType + * FUNCTION: AcpiRsValidateResourceLength * - * PARAMETERS: ResourceStartByte - Byte 0 of a resource descriptor + * PARAMETERS: Aml - Pointer to the AML resource descriptor * - * RETURN: The Resource Type (Name) with no extraneous bits + * RETURN: Status - AE_OK if the resource length appears valid * - * DESCRIPTION: Extract the Resource Type/Name from the first byte of - * a resource descriptor. + * DESCRIPTION: Validate the ResourceLength. Fixed-length descriptors must + * have the exact length; variable-length descriptors must be + * at least as long as the minimum. Certain Small descriptors + * can vary in size by at most one byte. * ******************************************************************************/ -UINT8 -AcpiRsGetResourceType ( - UINT8 ResourceStartByte) +static ACPI_STATUS +AcpiRsValidateResourceLength ( + AML_RESOURCE *Aml) { + ACPI_RESOURCE_INFO *ResourceInfo; + UINT16 MinimumAmlResourceLength; + UINT16 ResourceLength; + ACPI_FUNCTION_ENTRY (); - /* - * Determine if this is a small or large resource - */ - switch (ResourceStartByte & ACPI_RDESC_TYPE_MASK) + /* Get the size and type info about this resource descriptor */ + + ResourceInfo = AcpiRsGetResourceInfo (Aml->SmallHeader.DescriptorType); + if (!ResourceInfo) { - case ACPI_RDESC_TYPE_SMALL: + return (AE_AML_INVALID_RESOURCE_TYPE); + } - /* - * Small Resource Type -- Only bits 6:3 are valid - */ - return ((UINT8) (ResourceStartByte & ACPI_RDESC_SMALL_MASK)); + ResourceLength = AcpiUtGetResourceLength (Aml); + MinimumAmlResourceLength = ResourceInfo->MinimumAmlResourceLength; + /* Validate based upon the type of resource, fixed length or variable */ - case ACPI_RDESC_TYPE_LARGE: + if (ResourceInfo->LengthType == ACPI_FIXED_LENGTH) + { + /* Fixed length resource, length must match exactly */ - /* - * Large Resource Type -- All bits are valid - */ - return (ResourceStartByte); + if (ResourceLength != MinimumAmlResourceLength) + { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + } + else if (ResourceInfo->LengthType == ACPI_VARIABLE_LENGTH) + { + /* Variable length resource, must be at least the minimum */ + if (ResourceLength < MinimumAmlResourceLength) + { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + } + else + { + /* Small variable length resource, allowed to be (Min) or (Min-1) */ - default: - /* No other types of resource descriptor */ - break; + if ((ResourceLength > MinimumAmlResourceLength) || + (ResourceLength < (MinimumAmlResourceLength - 1))) + { + return (AE_AML_BAD_RESOURCE_LENGTH); + } } - return (0xFF); + return (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiRsByteStreamToList + * FUNCTION: AcpiRsGetConversionInfo * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource byte stream - * ByteStreamBufferLength - Length of ByteStreamBuffer - * OutputBuffer - Pointer to the buffer that will - * contain the output structures + * PARAMETERS: ResourceType - Byte 0 of a resource descriptor + * + * RETURN: Pointer to the resource conversion info table + * + * DESCRIPTION: Get the conversion table associated with this resource type + * + ******************************************************************************/ + +static ACPI_RSCONVERT_INFO * +AcpiRsGetConversionInfo ( + UINT8 ResourceType) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Determine if this is a small or large resource */ + + if (ResourceType & ACPI_RESOURCE_NAME_LARGE) + { + /* Large Resource Type -- bits 6:0 contain the name */ + + if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX) + { + return (NULL); + } + + return (AcpiGbl_LgGetResourceDispatch [ + (ResourceType & ACPI_RESOURCE_NAME_LARGE_MASK)]); + } + else + { + /* Small Resource Type -- bits 6:3 contain the name */ + + return (AcpiGbl_SmGetResourceDispatch [ + ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3)]); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsConvertAmlToResources + * + * PARAMETERS: AmlBuffer - Pointer to the resource byte stream + * AmlBufferLength - Length of AmlBuffer + * OutputBuffer - Pointer to the buffer that will + * contain the output structures * * RETURN: Status * @@ -191,235 +267,102 @@ AcpiRsGetResourceType ( ******************************************************************************/ ACPI_STATUS -AcpiRsByteStreamToList ( - UINT8 *ByteStreamBuffer, - UINT32 ByteStreamBufferLength, +AcpiRsConvertAmlToResources ( + UINT8 *AmlBuffer, + UINT32 AmlBufferLength, UINT8 *OutputBuffer) { + UINT8 *Buffer = OutputBuffer; ACPI_STATUS Status; ACPI_SIZE BytesParsed = 0; - UINT8 ResourceType = 0; - ACPI_SIZE BytesConsumed = 0; - UINT8 *Buffer = OutputBuffer; - ACPI_SIZE StructureSize = 0; - BOOLEAN EndTagProcessed = FALSE; ACPI_RESOURCE *Resource; + ACPI_RSDESC_SIZE DescriptorLength; + ACPI_RSCONVERT_INFO *Info; - ACPI_FUNCTION_TRACE ("RsByteStreamToList"); + ACPI_FUNCTION_TRACE ("RsConvertAmlToResources"); - while (BytesParsed < ByteStreamBufferLength && - !EndTagProcessed) + + /* Loop until end-of-buffer or an EndTag is found */ + + while (BytesParsed < AmlBufferLength) { - /* - * The next byte in the stream is the resource type - */ - ResourceType = AcpiRsGetResourceType (*ByteStreamBuffer); + /* Get the conversion table associated with this Descriptor Type */ - switch (ResourceType) + Info = AcpiRsGetConversionInfo (*AmlBuffer); + if (!Info) { - case ACPI_RDESC_TYPE_MEMORY_24: - /* - * 24-Bit Memory Resource - */ - Status = AcpiRsMemory24Resource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_LARGE_VENDOR: - /* - * Vendor Defined Resource - */ - Status = AcpiRsVendorResource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_MEMORY_32: - /* - * 32-Bit Memory Range Resource - */ - Status = AcpiRsMemory32RangeResource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_FIXED_MEMORY_32: - /* - * 32-Bit Fixed Memory Resource - */ - Status = AcpiRsFixedMemory32Resource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: - /* - * 64-Bit Address Resource - */ - Status = AcpiRsAddress64Resource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: - /* - * 32-Bit Address Resource - */ - Status = AcpiRsAddress32Resource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: - /* - * 16-Bit Address Resource - */ - Status = AcpiRsAddress16Resource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_EXTENDED_XRUPT: - /* - * Extended IRQ - */ - Status = AcpiRsExtendedIrqResource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_IRQ_FORMAT: - /* - * IRQ Resource - */ - Status = AcpiRsIrqResource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_DMA_FORMAT: - /* - * DMA Resource - */ - Status = AcpiRsDmaResource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_START_DEPENDENT: - /* - * Start Dependent Functions Resource - */ - Status = AcpiRsStartDependFnsResource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_END_DEPENDENT: - /* - * End Dependent Functions Resource - */ - Status = AcpiRsEndDependFnsResource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_IO_PORT: - /* - * IO Port Resource - */ - Status = AcpiRsIoResource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_FIXED_IO_PORT: - /* - * Fixed IO Port Resource - */ - Status = AcpiRsFixedIoResource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_SMALL_VENDOR: - /* - * Vendor Specific Resource - */ - Status = AcpiRsVendorResource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - case ACPI_RDESC_TYPE_END_TAG: - /* - * End Tag - */ - EndTagProcessed = TRUE; - Status = AcpiRsEndTagResource (ByteStreamBuffer, - &BytesConsumed, &Buffer, &StructureSize); - break; - - - default: - /* - * Invalid/Unknown resource type - */ - Status = AE_AML_INVALID_RESOURCE_TYPE; - break; + /* No table indicates an invalid resource type */ + + return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); } + DescriptorLength = AcpiUtGetDescriptorLength (AmlBuffer); + + /* + * Perform limited validation of the resource length, based upon + * what we know about the resource type + */ + Status = AcpiRsValidateResourceLength ( + ACPI_CAST_PTR (AML_RESOURCE, AmlBuffer)); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - /* - * Update the return value and counter - */ - BytesParsed += BytesConsumed; + /* Convert the AML byte stream resource to a local resource struct */ - /* - * Set the byte stream to point to the next resource - */ - ByteStreamBuffer += BytesConsumed; + Status = AcpiRsConvertAmlToResource ( + ACPI_CAST_PTR (ACPI_RESOURCE, Buffer), + ACPI_CAST_PTR (AML_RESOURCE, AmlBuffer), + Info); + if (ACPI_FAILURE (Status)) + { + ACPI_REPORT_ERROR (( + "Could not convert AML resource (type %X) to resource, %s\n", + *AmlBuffer, AcpiFormatException (Status))); + return_ACPI_STATUS (Status); + } + + /* Set the aligned length of the new resource descriptor */ - /* - * Set the Buffer to the next structure - */ Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer); Resource->Length = (UINT32) ACPI_ALIGN_RESOURCE_SIZE (Resource->Length); - Buffer += ACPI_ALIGN_RESOURCE_SIZE (StructureSize); - } /* end while */ + /* Normal exit on completion of an EndTag resource descriptor */ - /* - * Check the reason for exiting the while loop - */ - if (!EndTagProcessed) - { - return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + if (AcpiUtGetResourceType (AmlBuffer) == ACPI_RESOURCE_NAME_END_TAG) + { + return_ACPI_STATUS (AE_OK); + } + + /* Update counter and point to the next input resource */ + + BytesParsed += DescriptorLength; + AmlBuffer += DescriptorLength; + + /* Point to the next structure in the output buffer */ + + Buffer += Resource->Length; } - return_ACPI_STATUS (AE_OK); + /* Completed buffer, but did not find an EndTag resource descriptor */ + + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); } /******************************************************************************* * - * FUNCTION: AcpiRsListToByteStream + * FUNCTION: AcpiRsConvertResourcesToAml * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * ByteSteamSizeNeeded - Calculated size of the byte stream - * needed from calling - * AcpiRsGetByteStreamLength() - * The size of the OutputBuffer is - * guaranteed to be >= - * ByteStreamSizeNeeded - * OutputBuffer - Pointer to the buffer that will - * contain the byte stream + * PARAMETERS: Resource - Pointer to the resource linked list + * AmlSizeNeeded - Calculated size of the byte stream + * needed from calling AcpiRsGetAmlLength() + * The size of the OutputBuffer is + * guaranteed to be >= AmlSizeNeeded + * OutputBuffer - Pointer to the buffer that will + * contain the byte stream * * RETURN: Status * @@ -429,171 +372,79 @@ AcpiRsByteStreamToList ( ******************************************************************************/ ACPI_STATUS -AcpiRsListToByteStream ( - ACPI_RESOURCE *LinkedList, - ACPI_SIZE ByteStreamSizeNeeded, +AcpiRsConvertResourcesToAml ( + ACPI_RESOURCE *Resource, + ACPI_SIZE AmlSizeNeeded, UINT8 *OutputBuffer) { + UINT8 *AmlBuffer = OutputBuffer; + UINT8 *EndAmlBuffer = OutputBuffer + AmlSizeNeeded; ACPI_STATUS Status; - UINT8 *Buffer = OutputBuffer; - ACPI_SIZE BytesConsumed = 0; - BOOLEAN Done = FALSE; - ACPI_FUNCTION_TRACE ("RsListToByteStream"); + ACPI_FUNCTION_TRACE ("RsConvertResourcesToAml"); - while (!Done) + /* Walk the resource descriptor list, convert each descriptor */ + + while (AmlBuffer < EndAmlBuffer) { - switch (LinkedList->Id) + /* Validate the Resource Type */ + + if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) { - case ACPI_RSTYPE_IRQ: - /* - * IRQ Resource - */ - Status = AcpiRsIrqStream (LinkedList, &Buffer, &BytesConsumed); - break; - - case ACPI_RSTYPE_DMA: - /* - * DMA Resource - */ - Status = AcpiRsDmaStream (LinkedList, &Buffer, &BytesConsumed); - break; - - case ACPI_RSTYPE_START_DPF: - /* - * Start Dependent Functions Resource - */ - Status = AcpiRsStartDependFnsStream (LinkedList, - &Buffer, &BytesConsumed); - break; - - case ACPI_RSTYPE_END_DPF: - /* - * End Dependent Functions Resource - */ - Status = AcpiRsEndDependFnsStream (LinkedList, - &Buffer, &BytesConsumed); - break; - - case ACPI_RSTYPE_IO: - /* - * IO Port Resource - */ - Status = AcpiRsIoStream (LinkedList, &Buffer, &BytesConsumed); - break; - - case ACPI_RSTYPE_FIXED_IO: - /* - * Fixed IO Port Resource - */ - Status = AcpiRsFixedIoStream (LinkedList, &Buffer, &BytesConsumed); - break; - - case ACPI_RSTYPE_VENDOR: - /* - * Vendor Defined Resource - */ - Status = AcpiRsVendorStream (LinkedList, &Buffer, &BytesConsumed); - break; - - case ACPI_RSTYPE_END_TAG: - /* - * End Tag - */ - Status = AcpiRsEndTagStream (LinkedList, &Buffer, &BytesConsumed); - - /* - * An End Tag indicates the end of the Resource Template - */ - Done = TRUE; - break; - - case ACPI_RSTYPE_MEM24: - /* - * 24-Bit Memory Resource - */ - Status = AcpiRsMemory24Stream (LinkedList, &Buffer, &BytesConsumed); - break; - - case ACPI_RSTYPE_MEM32: - /* - * 32-Bit Memory Range Resource - */ - Status = AcpiRsMemory32RangeStream (LinkedList, &Buffer, - &BytesConsumed); - break; - - case ACPI_RSTYPE_FIXED_MEM32: - /* - * 32-Bit Fixed Memory Resource - */ - Status = AcpiRsFixedMemory32Stream (LinkedList, &Buffer, - &BytesConsumed); - break; - - case ACPI_RSTYPE_ADDRESS16: - /* - * 16-Bit Address Descriptor Resource - */ - Status = AcpiRsAddress16Stream (LinkedList, &Buffer, - &BytesConsumed); - break; - - case ACPI_RSTYPE_ADDRESS32: - /* - * 32-Bit Address Descriptor Resource - */ - Status = AcpiRsAddress32Stream (LinkedList, &Buffer, - &BytesConsumed); - break; - - case ACPI_RSTYPE_ADDRESS64: - /* - * 64-Bit Address Descriptor Resource - */ - Status = AcpiRsAddress64Stream (LinkedList, &Buffer, - &BytesConsumed); - break; - - case ACPI_RSTYPE_EXT_IRQ: - /* - * Extended IRQ Resource - */ - Status = AcpiRsExtendedIrqStream (LinkedList, &Buffer, - &BytesConsumed); - break; - - default: - /* - * If we get here, everything is out of sync, - * so exit with an error - */ - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid descriptor type (%X) in resource list\n", - LinkedList->Id)); - Status = AE_BAD_DATA; - break; - - } /* switch (LinkedList->Id) */ + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid descriptor type (%X) in resource list\n", + Resource->Type)); + return_ACPI_STATUS (AE_BAD_DATA); + } + /* Perform the conversion */ + + Status = AcpiRsConvertResourceToAml (Resource, + ACPI_CAST_PTR (AML_RESOURCE, AmlBuffer), + AcpiGbl_SetResourceDispatch[Resource->Type]); if (ACPI_FAILURE (Status)) { + ACPI_REPORT_ERROR (("Could not convert resource (type %X) to AML, %s\n", + Resource->Type, AcpiFormatException (Status))); return_ACPI_STATUS (Status); } - /* - * Set the Buffer to point to the open byte - */ - Buffer += BytesConsumed; + /* Perform final sanity check on the new AML resource descriptor */ + + Status = AcpiRsValidateResourceLength ( + ACPI_CAST_PTR (AML_RESOURCE, AmlBuffer)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Check for end-of-list, normal exit */ + + if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG) + { + /* An End Tag indicates the end of the input Resource Template */ + + return_ACPI_STATUS (AE_OK); + } /* - * Point to the next object + * Extract the total length of the new descriptor and set the + * AmlBuffer to point to the next (output) resource descriptor */ - LinkedList = ACPI_PTR_ADD (ACPI_RESOURCE, - LinkedList, LinkedList->Length); + AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer); + + /* Point to the next input resource descriptor */ + + Resource = ACPI_PTR_ADD (ACPI_RESOURCE, Resource, Resource->Length); + + /* Check for end-of-list, normal exit */ + } - return_ACPI_STATUS (AE_OK); + /* Completed buffer, but did not find an EndTag resource descriptor */ + + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); } diff --git a/sys/contrib/dev/acpica/rsmemory.c b/sys/contrib/dev/acpica/rsmemory.c index 6ca3c6d..fcd4f6a 100644 --- a/sys/contrib/dev/acpica/rsmemory.c +++ b/sys/contrib/dev/acpica/rsmemory.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsmem24 - Memory resource descriptors - * $Revision: 25 $ + * $Revision: 1.32 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -125,516 +125,199 @@ /******************************************************************************* * - * FUNCTION: AcpiRsMemory24Resource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. + * AcpiRsConvertMemory24 * ******************************************************************************/ -ACPI_STATUS -AcpiRsMemory24Resource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[4] = { - UINT8 *Buffer = ByteStreamBuffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_MEM24); - - - ACPI_FUNCTION_TRACE ("RsMemory24Resource"); - - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - Buffer += 1; - - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - Buffer += 2; - *BytesConsumed = (ACPI_SIZE) Temp16 + 3; - OutputStruct->Id = ACPI_RSTYPE_MEM24; - - /* - * Check Byte 3 the Read/Write bit - */ - Temp8 = *Buffer; - Buffer += 1; - OutputStruct->Data.Memory24.ReadWriteAttribute = Temp8 & 0x01; - - /* - * Get MinBaseAddress (Bytes 4-5) - */ - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - Buffer += 2; - OutputStruct->Data.Memory24.MinBaseAddress = Temp16; - - /* - * Get MaxBaseAddress (Bytes 6-7) - */ - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - Buffer += 2; - OutputStruct->Data.Memory24.MaxBaseAddress = Temp16; + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24, + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory24)}, - /* - * Get Alignment (Bytes 8-9) - */ - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - Buffer += 2; - OutputStruct->Data.Memory24.Alignment = Temp16; + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24, + sizeof (AML_RESOURCE_MEMORY24), + 0}, - /* - * Get RangeLength (Bytes 10-11) - */ - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - OutputStruct->Data.Memory24.RangeLength = Temp16; + /* Read/Write bit */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory24.WriteProtect), + AML_OFFSET (Memory24.Flags), + 0}, /* - * Set the Length parameter + * These fields are contiguous in both the source and destination: + * Minimum Base Address + * Maximum Base Address + * Address Base Alignment + * Range Length */ - OutputStruct->Length = (UINT32) StructSize; - - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Memory24.Minimum), + AML_OFFSET (Memory24.Minimum), + 4} +}; /******************************************************************************* * - * FUNCTION: AcpiRsMemory24Stream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * AcpiRsConvertMemory32 * ******************************************************************************/ -ACPI_STATUS -AcpiRsMemory24Stream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[4] = { - UINT8 *Buffer = *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - - - ACPI_FUNCTION_TRACE ("RsMemory24Stream"); - - - /* - * The descriptor field is static - */ - *Buffer = 0x81; - Buffer += 1; - - /* - * The length field is static - */ - Temp16 = 0x09; - ACPI_MOVE_16_TO_16 (Buffer, &Temp16); - Buffer += 2; - - /* - * Set the Information Byte - */ - Temp8 = (UINT8) (LinkedList->Data.Memory24.ReadWriteAttribute & 0x01); - *Buffer = Temp8; - Buffer += 1; - - /* - * Set the Range minimum base address - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Memory24.MinBaseAddress); - Buffer += 2; - - /* - * Set the Range maximum base address - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Memory24.MaxBaseAddress); - Buffer += 2; + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32, + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory32)}, - /* - * Set the base alignment - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Memory24.Alignment); - Buffer += 2; + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32, + sizeof (AML_RESOURCE_MEMORY32), + 0}, - /* - * Set the range length - */ - ACPI_MOVE_32_TO_16 (Buffer, &LinkedList->Data.Memory24.RangeLength); - Buffer += 2; + /* Read/Write bit */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory32.WriteProtect), + AML_OFFSET (Memory32.Flags), + 0}, /* - * Return the number of bytes consumed in this operation + * These fields are contiguous in both the source and destination: + * Minimum Base Address + * Maximum Base Address + * Address Base Alignment + * Range Length */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Memory32.Minimum), + AML_OFFSET (Memory32.Minimum), + 4} +}; /******************************************************************************* * - * FUNCTION: AcpiRsMemory32RangeResource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. + * AcpiRsConvertFixedMemory32 * ******************************************************************************/ -ACPI_STATUS -AcpiRsMemory32RangeResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[4] = { - UINT8 *Buffer = ByteStreamBuffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_MEM32); - - - ACPI_FUNCTION_TRACE ("RsMemory32RangeResource"); - - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - Buffer += 1; - - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - Buffer += 2; - *BytesConsumed = (ACPI_SIZE) Temp16 + 3; - - OutputStruct->Id = ACPI_RSTYPE_MEM32; - - /* - * Point to the place in the output buffer where the data portion will - * begin. - * 1. Set the RESOURCE_DATA * Data to point to its own address, then - * 2. Set the pointer to the next address. - * - * NOTE: OutputStruct->Data is cast to UINT8, otherwise, this addition adds - * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(UINT8) - */ - - /* - * Check Byte 3 the Read/Write bit - */ - Temp8 = *Buffer; - Buffer += 1; - - OutputStruct->Data.Memory32.ReadWriteAttribute = Temp8 & 0x01; - - /* - * Get MinBaseAddress (Bytes 4-7) - */ - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Memory32.MinBaseAddress, Buffer); - Buffer += 4; + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32, + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedMemory32)}, - /* - * Get MaxBaseAddress (Bytes 8-11) - */ - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Memory32.MaxBaseAddress, Buffer); - Buffer += 4; - - /* - * Get Alignment (Bytes 12-15) - */ - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Memory32.Alignment, Buffer); - Buffer += 4; + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32, + sizeof (AML_RESOURCE_FIXED_MEMORY32), + 0}, - /* - * Get RangeLength (Bytes 16-19) - */ - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.Memory32.RangeLength, Buffer); - - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; + /* Read/Write bit */ + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.FixedMemory32.WriteProtect), + AML_OFFSET (FixedMemory32.Flags), + 0}, /* - * Return the final size of the structure + * These fields are contiguous in both the source and destination: + * Base Address + * Range Length */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.FixedMemory32.Address), + AML_OFFSET (FixedMemory32.Address), + 2} +}; /******************************************************************************* * - * FUNCTION: AcpiRsFixedMemory32Resource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. + * AcpiRsGetVendorSmall * ******************************************************************************/ -ACPI_STATUS -AcpiRsFixedMemory32Resource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[3] = { - UINT8 *Buffer = ByteStreamBuffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_FIXED_MEM32); - - - ACPI_FUNCTION_TRACE ("RsFixedMemory32Resource"); - - - /* - * Point past the Descriptor to get the number of bytes consumed - */ - Buffer += 1; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - - Buffer += 2; - *BytesConsumed = (ACPI_SIZE) Temp16 + 3; - - OutputStruct->Id = ACPI_RSTYPE_FIXED_MEM32; + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorSmall)}, - /* - * Check Byte 3 the Read/Write bit - */ - Temp8 = *Buffer; - Buffer += 1; - OutputStruct->Data.FixedMemory32.ReadWriteAttribute = Temp8 & 0x01; + /* Length of the vendor data (byte count) */ - /* - * Get RangeBaseAddress (Bytes 4-7) - */ - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeBaseAddress, Buffer); - Buffer += 4; - - /* - * Get RangeLength (Bytes 8-11) - */ - ACPI_MOVE_32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeLength, Buffer); + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + sizeof (UINT8)}, - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; + /* Vendor data */ - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_SMALL_HEADER), + 0} +}; /******************************************************************************* * - * FUNCTION: AcpiRsMemory32RangeStream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * AcpiRsGetVendorLarge * ******************************************************************************/ -ACPI_STATUS -AcpiRsMemory32RangeStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[3] = { - UINT8 *Buffer = *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorLarge)}, - ACPI_FUNCTION_TRACE ("RsMemory32RangeStream"); + /* Length of the vendor data (byte count) */ + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + sizeof (UINT8)}, - /* - * The descriptor field is static - */ - *Buffer = 0x85; - Buffer += 1; - - /* - * The length field is static - */ - Temp16 = 0x11; - - ACPI_MOVE_16_TO_16 (Buffer, &Temp16); - Buffer += 2; - - /* - * Set the Information Byte - */ - Temp8 = (UINT8) (LinkedList->Data.Memory32.ReadWriteAttribute & 0x01); - *Buffer = Temp8; - Buffer += 1; - - /* - * Set the Range minimum base address - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Memory32.MinBaseAddress); - Buffer += 4; - - /* - * Set the Range maximum base address - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Memory32.MaxBaseAddress); - Buffer += 4; - - /* - * Set the base alignment - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Memory32.Alignment); - Buffer += 4; + /* Vendor data */ - /* - * Set the range length - */ - ACPI_MOVE_32_TO_32 (Buffer, &LinkedList->Data.Memory32.RangeLength); - Buffer += 4; - - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - return_ACPI_STATUS (AE_OK); -} + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_LARGE_HEADER), + 0} +}; /******************************************************************************* * - * FUNCTION: AcpiRsFixedMemory32Stream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * AcpiRsSetVendor * ******************************************************************************/ -ACPI_STATUS -AcpiRsFixedMemory32Stream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +ACPI_RSCONVERT_INFO AcpiRsSetVendor[7] = { - UINT8 *Buffer = *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; + /* Default is a small vendor descriptor */ + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL, + sizeof (AML_RESOURCE_SMALL_HEADER), + ACPI_RSC_TABLE_SIZE (AcpiRsSetVendor)}, - ACPI_FUNCTION_TRACE ("RsFixedMemory32Stream"); + /* Get the length and copy the data */ + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + 0}, - /* - * The descriptor field is static - */ - *Buffer = 0x86; - Buffer += 1; + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_SMALL_HEADER), + 0}, /* - * The length field is static + * All done if the Vendor byte length is 7 or less, meaning that it will + * fit within a small descriptor */ - Temp16 = 0x09; + {ACPI_RSC_EXIT_LE, 0, 0, 7}, - ACPI_MOVE_16_TO_16 (Buffer, &Temp16); - Buffer += 2; + /* Must create a large vendor descriptor */ - /* - * Set the Information Byte - */ - Temp8 = (UINT8) (LinkedList->Data.FixedMemory32.ReadWriteAttribute & 0x01); - *Buffer = Temp8; - Buffer += 1; + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE, + sizeof (AML_RESOURCE_LARGE_HEADER), + 0}, - /* - * Set the Range base address - */ - ACPI_MOVE_32_TO_32 (Buffer, - &LinkedList->Data.FixedMemory32.RangeBaseAddress); - Buffer += 4; + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + 0}, - /* - * Set the range length - */ - ACPI_MOVE_32_TO_32 (Buffer, - &LinkedList->Data.FixedMemory32.RangeLength); - Buffer += 4; + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_LARGE_HEADER), + 0} +}; - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - return_ACPI_STATUS (AE_OK); -} diff --git a/sys/contrib/dev/acpica/rsmisc.c b/sys/contrib/dev/acpica/rsmisc.c index c878845..ae5a4ec 100644 --- a/sys/contrib/dev/acpica/rsmisc.c +++ b/sys/contrib/dev/acpica/rsmisc.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsmisc - Miscellaneous resource descriptors - * $Revision: 27 $ + * $Revision: 1.35 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,561 +123,550 @@ ACPI_MODULE_NAME ("rsmisc") +#define INIT_RESOURCE_TYPE(i) i->ResourceOffset +#define INIT_RESOURCE_LENGTH(i) i->AmlOffset +#define INIT_TABLE_LENGTH(i) i->Value + +#define COMPARE_OPCODE(i) i->ResourceOffset +#define COMPARE_TARGET(i) i->AmlOffset +#define COMPARE_VALUE(i) i->Value + + /******************************************************************************* * - * FUNCTION: AcpiRsEndTagResource + * FUNCTION: AcpiRsConvertAmlToResource * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned + * Info - Pointer to appropriate conversion table * * RETURN: Status * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. + * DESCRIPTION: Convert an external AML resource descriptor to the corresponding + * internal resource descriptor * ******************************************************************************/ ACPI_STATUS -AcpiRsEndTagResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) +AcpiRsConvertAmlToResource ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info) { - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - ACPI_SIZE StructSize = ACPI_RESOURCE_LENGTH; + ACPI_RS_LENGTH AmlResourceLength; + void *Source; + void *Destination; + char *Target; + UINT8 Count; + UINT8 FlagsMode = FALSE; + UINT16 ItemCount = 0; + UINT16 Temp16 = 0; - ACPI_FUNCTION_TRACE ("RsEndTagResource"); + ACPI_FUNCTION_TRACE ("RsGetResource"); - /* - * The number of bytes consumed is static - */ - *BytesConsumed = 2; + if (((ACPI_NATIVE_UINT) Resource) & 0x3) + { + AcpiOsPrintf ("**** GET: Misaligned resource pointer: %p Type %2.2X Len %X\n", + Resource, Resource->Type, Resource->Length); + } - /* - * Fill out the structure - */ - OutputStruct->Id = ACPI_RSTYPE_END_TAG; + /* Extract the resource Length field (does not include header length) */ - /* - * Set the Length parameter - */ - OutputStruct->Length = 0; + AmlResourceLength = AcpiUtGetResourceLength (Aml); /* - * Return the final size of the structure + * First table entry must be ACPI_RSC_INITxxx and must contain the + * table length (# of table entries) */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + Count = INIT_TABLE_LENGTH (Info); + while (Count) + { + /* + * Source is the external AML byte stream buffer, + * destination is the internal resource descriptor + */ + Source = ((UINT8 *) Aml) + Info->AmlOffset; + Destination = ((UINT8 *) Resource) + Info->ResourceOffset; -/******************************************************************************* - * - * FUNCTION: AcpiRsEndTagStream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ + switch (Info->Opcode) + { + case ACPI_RSC_INITGET: + /* + * Get the resource type and the initial (minimum) length + */ + ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info)); + Resource->Type = INIT_RESOURCE_TYPE (Info); + Resource->Length = INIT_RESOURCE_LENGTH (Info); + break; -ACPI_STATUS -AcpiRsEndTagStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) -{ - UINT8 *Buffer = *OutputBuffer; - UINT8 Temp8 = 0; + case ACPI_RSC_INITSET: + break; - ACPI_FUNCTION_TRACE ("RsEndTagStream"); + case ACPI_RSC_FLAGINIT: - /* - * The descriptor field is static - */ - *Buffer = 0x79; - Buffer += 1; + FlagsMode = TRUE; + break; - /* - * Set the Checksum - zero means that the resource data is treated as if - * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8) - */ - Temp8 = 0; - *Buffer = Temp8; - Buffer += 1; + case ACPI_RSC_1BITFLAG: + /* + * Mask and shift the flag bit + */ + *((UINT8 *) Destination) = (UINT8) + ((*((UINT8 *) Source) >> Info->Value) & 0x01); + break; - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - return_ACPI_STATUS (AE_OK); -} + case ACPI_RSC_2BITFLAG: + /* + * Mask and shift the flag bits + */ + *((UINT8 *) Destination) = (UINT8) + ((*((UINT8 *) Source) >> Info->Value) & 0x03); + break; -/******************************************************************************* - * - * FUNCTION: AcpiRsVendorResource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ -ACPI_STATUS -AcpiRsVendorResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) -{ - UINT8 *Buffer = ByteStreamBuffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - UINT8 Index; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_VENDOR); + case ACPI_RSC_COUNT: + ItemCount = *((UINT8 *) Source); + *((UINT8 *) Destination) = (UINT8) ItemCount; - ACPI_FUNCTION_TRACE ("RsVendorResource"); + Resource->Length = Resource->Length + + (Info->Value * (ItemCount - 1)); + break; - /* - * Dereference the Descriptor to find if this is a large or small item. - */ - Temp8 = *Buffer; + case ACPI_RSC_COUNT16: - if (Temp8 & 0x80) - { - /* - * Large Item, point to the length field - */ - Buffer += 1; + ItemCount = AmlResourceLength; + *((UINT16 *) Destination) = ItemCount; - /* Dereference */ + Resource->Length = Resource->Length + + (Info->Value * (ItemCount - 1)); + break; - ACPI_MOVE_16_TO_16 (&Temp16, Buffer); - /* Calculate bytes consumed */ + case ACPI_RSC_LENGTH: - *BytesConsumed = (ACPI_SIZE) Temp16 + 3; + Resource->Length = Resource->Length + Info->Value; + break; - /* Point to the first vendor byte */ - Buffer += 2; - } - else - { - /* - * Small Item, dereference the size - */ - Temp16 = (UINT8)(*Buffer & 0x07); + case ACPI_RSC_MOVE8: + case ACPI_RSC_MOVE16: + case ACPI_RSC_MOVE32: + case ACPI_RSC_MOVE64: + /* + * Raw data move. Use the Info value field unless ItemCount has + * been previously initialized via a COUNT opcode + */ + if (Info->Value) + { + ItemCount = Info->Value; + } + AcpiRsMoveData (Destination, Source, ItemCount, + Info->Opcode); + break; - /* Calculate bytes consumed */ - *BytesConsumed = (ACPI_SIZE) Temp16 + 1; + case ACPI_RSC_SET8: - /* Point to the first vendor byte */ + ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value); + break; - Buffer += 1; - } - OutputStruct->Id = ACPI_RSTYPE_VENDOR; - OutputStruct->Data.VendorSpecific.Length = Temp16; + case ACPI_RSC_DATA8: - for (Index = 0; Index < Temp16; Index++) - { - OutputStruct->Data.VendorSpecific.Reserved[Index] = *Buffer; - Buffer += 1; - } + Target = ((char *) Resource) + Info->Value; + ACPI_MEMCPY (Destination, Source, *(ACPI_CAST_PTR (UINT16, Target))); + break; - /* - * In order for the StructSize to fall on a 32-bit boundary, - * calculate the length of the vendor string and expand the - * StructSize to the next 32-bit boundary. - */ - StructSize += ACPI_ROUND_UP_TO_32BITS (Temp16); - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; + case ACPI_RSC_ADDRESS: + /* + * Common handler for address descriptor flags + */ + if (!AcpiRsGetAddressCommon (Resource, Aml)) + { + return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + } + break; - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; + + case ACPI_RSC_SOURCE: + /* + * Optional ResourceSource (Index and String) + */ + Resource->Length += + AcpiRsGetResourceSource (AmlResourceLength, Info->Value, + Destination, Aml, NULL); + break; + + + case ACPI_RSC_SOURCEX: + /* + * Optional ResourceSource (Index and String). This is the more + * complicated case used by the Interrupt() macro + */ + Target = ((char *) Resource) + Info->AmlOffset + (ItemCount * 4); + + Resource->Length += + AcpiRsGetResourceSource (AmlResourceLength, + (ACPI_RS_LENGTH) (((ItemCount - 1) * sizeof (UINT32)) + Info->Value), + Destination, Aml, Target); + break; + + + case ACPI_RSC_BITMASK: + /* + * 8-bit encoded bitmask (DMA macro) + */ + ItemCount = AcpiRsDecodeBitmask (*((UINT8 *) Source), Destination); + if (ItemCount) + { + Resource->Length += Resource->Length + (ItemCount - 1); + } + + Target = ((char *) Resource) + Info->Value; + *((UINT8 *) Target) = (UINT8) ItemCount; + break; + + + case ACPI_RSC_BITMASK16: + /* + * 16-bit encoded bitmask (IRQ macro) + */ + ACPI_MOVE_16_TO_16 (&Temp16, Source); + + ItemCount = AcpiRsDecodeBitmask (Temp16, Destination); + if (ItemCount) + { + Resource->Length = Resource->Length + (ItemCount - 1); + } + + Target = ((char *) Resource) + Info->Value; + *((UINT8 *) Target) = (UINT8) ItemCount; + break; + + + case ACPI_RSC_EXIT_NE: + /* + * Control - Exit conversion if not equal + */ + switch (Info->ResourceOffset) + { + case ACPI_RSC_COMPARE_AML_LENGTH: + if (AmlResourceLength != Info->Value) + { + goto Exit; + } + break; + + case ACPI_RSC_COMPARE_VALUE: + if (*((UINT8 *) Source) != Info->Value) + { + goto Exit; + } + break; + + default: + AcpiOsPrintf ("*** Invalid conversion sub-opcode\n"); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + break; + + + default: + + AcpiOsPrintf ("*** Invalid conversion opcode\n"); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Count--; + Info++; + } + +Exit: + if (!FlagsMode) + { + /* Round the resource struct length up to the next 32-bit boundary */ + + Resource->Length = ACPI_ROUND_UP_TO_32BITS (Resource->Length); + } return_ACPI_STATUS (AE_OK); } /******************************************************************************* * - * FUNCTION: AcpiRsVendorStream + * FUNCTION: AcpiRsConvertResourceToAml * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned + * Info - Pointer to appropriate conversion table * * RETURN: Status * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. * ******************************************************************************/ ACPI_STATUS -AcpiRsVendorStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) +AcpiRsConvertResourceToAml ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info) { - UINT8 *Buffer = *OutputBuffer; + void *Source = NULL; + void *Destination; + ACPI_RSDESC_SIZE AmlLength = 0; + UINT8 Count; UINT16 Temp16 = 0; - UINT8 Temp8 = 0; - UINT8 Index; + UINT16 ItemCount = 0; + + ACPI_FUNCTION_TRACE ("RsConvertResourceToAml"); - ACPI_FUNCTION_TRACE ("RsVendorStream"); + /* Validate the Resource pointer, must be 32-bit aligned */ + + if (((ACPI_NATIVE_UINT) Resource) & 0x3) + { + AcpiOsPrintf ("**** SET: Misaligned resource pointer: %p Type %2.2X Len %X\n", + Resource, Resource->Type, Resource->Length); + } /* - * Dereference the length to find if this is a large or small item. + * First table entry must be ACPI_RSC_INITxxx and must contain the + * table length (# of table entries) */ - if(LinkedList->Data.VendorSpecific.Length > 7) + Count = INIT_TABLE_LENGTH (Info); + + while (Count) { /* - * Large Item, Set the descriptor field and length bytes + * Source is the internal resource descriptor, + * destination is the external AML byte stream buffer */ - *Buffer = 0x84; - Buffer += 1; + Source = ((UINT8 *) Resource) + Info->ResourceOffset; + Destination = ((UINT8 *) Aml) + Info->AmlOffset; - Temp16 = (UINT16) LinkedList->Data.VendorSpecific.Length; + switch (Info->Opcode) + { + case ACPI_RSC_INITSET: - ACPI_MOVE_16_TO_16 (Buffer, &Temp16); - Buffer += 2; - } - else - { - /* - * Small Item, Set the descriptor field - */ - Temp8 = 0x70; - Temp8 |= (UINT8) LinkedList->Data.VendorSpecific.Length; + ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info)); + AmlLength = INIT_RESOURCE_LENGTH (Info); + AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml); + break; - *Buffer = Temp8; - Buffer += 1; - } - /* - * Loop through all of the Vendor Specific fields - */ - for (Index = 0; Index < LinkedList->Data.VendorSpecific.Length; Index++) - { - Temp8 = LinkedList->Data.VendorSpecific.Reserved[Index]; + case ACPI_RSC_INITGET: + break; - *Buffer = Temp8; - Buffer += 1; - } - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - return_ACPI_STATUS (AE_OK); -} + case ACPI_RSC_FLAGINIT: + /* + * Clear the flag byte + */ + *((UINT8 *) Destination) = 0; + break; -/******************************************************************************* - * - * FUNCTION: AcpiRsStartDependFnsResource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ + case ACPI_RSC_1BITFLAG: + /* + * Mask and shift the flag bit + */ + *((UINT8 *) Destination) |= (UINT8) + ((*((UINT8 *) Source) & 0x01) << Info->Value); + break; -ACPI_STATUS -AcpiRsStartDependFnsResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) -{ - UINT8 *Buffer = ByteStreamBuffer; - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - UINT8 Temp8 = 0; - ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_START_DPF); + case ACPI_RSC_2BITFLAG: + /* + * Mask and shift the flag bits + */ + *((UINT8 *) Destination) |= (UINT8) + ((*((UINT8 *) Source) & 0x03) << Info->Value); + break; - ACPI_FUNCTION_TRACE ("RsStartDependFnsResource"); + case ACPI_RSC_COUNT: - /* - * The number of bytes consumed are contained in the descriptor (Bits:0-1) - */ - Temp8 = *Buffer; + ItemCount = *((UINT8 *) Source); + *((UINT8 *) Destination) = (UINT8) ItemCount; - *BytesConsumed = (Temp8 & 0x01) + 1; + AmlLength = (UINT16) (AmlLength + + (Info->Value * (ItemCount - 1))); + break; - OutputStruct->Id = ACPI_RSTYPE_START_DPF; - /* - * Point to Byte 1 if it is used - */ - if (2 == *BytesConsumed) - { - Buffer += 1; - Temp8 = *Buffer; + case ACPI_RSC_COUNT16: - /* - * Check Compatibility priority - */ - OutputStruct->Data.StartDpf.CompatibilityPriority = Temp8 & 0x03; + ItemCount = *((UINT16 *) Source); + AmlLength = (UINT16) (AmlLength + ItemCount); + AcpiRsSetResourceLength (AmlLength, Aml); + break; - if (3 == OutputStruct->Data.StartDpf.CompatibilityPriority) - { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); - } - /* - * Check Performance/Robustness preference - */ - OutputStruct->Data.StartDpf.PerformanceRobustness = (Temp8 >> 2) & 0x03; + case ACPI_RSC_LENGTH: - if (3 == OutputStruct->Data.StartDpf.PerformanceRobustness) - { - return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); - } - } - else - { - OutputStruct->Data.StartDpf.CompatibilityPriority = - ACPI_ACCEPTABLE_CONFIGURATION; + AcpiRsSetResourceLength (Info->Value, Aml); + break; - OutputStruct->Data.StartDpf.PerformanceRobustness = - ACPI_ACCEPTABLE_CONFIGURATION; - } - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; + case ACPI_RSC_MOVE8: + case ACPI_RSC_MOVE16: + case ACPI_RSC_MOVE32: + case ACPI_RSC_MOVE64: - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + if (Info->Value) + { + ItemCount = Info->Value; + } + AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); + break; -/******************************************************************************* - * - * FUNCTION: AcpiRsEndDependFnsResource - * - * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte - * stream - * BytesConsumed - Pointer to where the number of bytes - * consumed the ByteStreamBuffer is - * returned - * OutputBuffer - Pointer to the return data buffer - * StructureSize - Pointer to where the number of bytes - * in the return data struct is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the resource byte stream and fill out the appropriate - * structure pointed to by the OutputBuffer. Return the - * number of bytes consumed from the byte stream. - * - ******************************************************************************/ + case ACPI_RSC_ADDRESS: -ACPI_STATUS -AcpiRsEndDependFnsResource ( - UINT8 *ByteStreamBuffer, - ACPI_SIZE *BytesConsumed, - UINT8 **OutputBuffer, - ACPI_SIZE *StructureSize) -{ - ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer; - ACPI_SIZE StructSize = ACPI_RESOURCE_LENGTH; + /* Set the Resource Type, General Flags, and Type-Specific Flags */ + AcpiRsSetAddressCommon (Aml, Resource); + break; - ACPI_FUNCTION_TRACE ("RsEndDependFnsResource"); + case ACPI_RSC_SOURCEX: + /* + * Optional ResourceSource (Index and String) + */ + AmlLength = AcpiRsSetResourceSource ( + Aml, (ACPI_RS_LENGTH) AmlLength, Source); + AcpiRsSetResourceLength (AmlLength, Aml); + break; - /* - * The number of bytes consumed is static - */ - *BytesConsumed = 1; - /* - * Fill out the structure - */ - OutputStruct->Id = ACPI_RSTYPE_END_DPF; + case ACPI_RSC_SOURCE: + /* + * Optional ResourceSource (Index and String). This is the more + * complicated case used by the Interrupt() macro + */ + AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source); + AcpiRsSetResourceLength (AmlLength, Aml); + break; - /* - * Set the Length parameter - */ - OutputStruct->Length = (UINT32) StructSize; - /* - * Return the final size of the structure - */ - *StructureSize = StructSize; - return_ACPI_STATUS (AE_OK); -} + case ACPI_RSC_BITMASK: + /* + * 8-bit encoded bitmask (DMA macro) + */ + *((UINT8 *) Destination) = (UINT8) + AcpiRsEncodeBitmask (Source, *(((UINT8 *) Resource) + Info->Value)); + break; -/******************************************************************************* - * - * FUNCTION: AcpiRsStartDependFnsStream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - UINT32 pointer that is filled with - * the number of bytes of the - * OutputBuffer used - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ + case ACPI_RSC_BITMASK16: + /* + * 16-bit encoded bitmask (IRQ macro) + */ + Temp16 = AcpiRsEncodeBitmask (Source, *(((UINT8 *) Resource) + Info->Value)); + ACPI_MOVE_16_TO_16 (Destination, &Temp16); + break; -ACPI_STATUS -AcpiRsStartDependFnsStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) -{ - UINT8 *Buffer = *OutputBuffer; - UINT8 Temp8 = 0; + case ACPI_RSC_EXIT_LE: + /* + * Control - Exit conversion if less than or equal + */ + if (ItemCount <= Info->Value) + { + goto Exit; + } + break; - ACPI_FUNCTION_TRACE ("RsStartDependFnsStream"); + case ACPI_RSC_EXIT_NE: + /* + * Control - Exit conversion if not equal + */ + switch (COMPARE_OPCODE (Info)) + { + case ACPI_RSC_COMPARE_VALUE: + if (*((UINT8 *) (((UINT8 *) Resource) + COMPARE_TARGET(Info))) != COMPARE_VALUE (Info)) + { + goto Exit; + } + break; - /* - * The descriptor field is set based upon whether a byte is needed - * to contain Priority data. - */ - if (ACPI_ACCEPTABLE_CONFIGURATION == - LinkedList->Data.StartDpf.CompatibilityPriority && - ACPI_ACCEPTABLE_CONFIGURATION == - LinkedList->Data.StartDpf.PerformanceRobustness) - { - *Buffer = 0x30; - } - else - { - *Buffer = 0x31; - Buffer += 1; + default: + AcpiOsPrintf ("*** Invalid conversion sub-opcode\n"); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + break; - /* - * Set the Priority Byte Definition - */ - Temp8 = 0; - Temp8 = (UINT8) ((LinkedList->Data.StartDpf.PerformanceRobustness & - 0x03) << 2); - Temp8 |= (LinkedList->Data.StartDpf.CompatibilityPriority & - 0x03); - *Buffer = Temp8; - } - Buffer += 1; + default: - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); + AcpiOsPrintf ("*** Invalid conversion opcode\n"); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Count--; + Info++; + } + +Exit: return_ACPI_STATUS (AE_OK); } -/******************************************************************************* - * - * FUNCTION: AcpiRsEndDependFnsStream - * - * PARAMETERS: LinkedList - Pointer to the resource linked list - * OutputBuffer - Pointer to the user's return buffer - * BytesConsumed - Pointer to where the number of bytes - * used in the OutputBuffer is returned - * - * RETURN: Status - * - * DESCRIPTION: Take the linked list resource structure and fills in the - * the appropriate bytes in a byte stream - * - ******************************************************************************/ +#if 0 +/* Previous resource validations */ -ACPI_STATUS -AcpiRsEndDependFnsStream ( - ACPI_RESOURCE *LinkedList, - UINT8 **OutputBuffer, - ACPI_SIZE *BytesConsumed) -{ - UINT8 *Buffer = *OutputBuffer; + if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) + { + return_ACPI_STATUS (AE_SUPPORT); + } + if (Resource->Data.StartDpf.PerformanceRobustness >= 3) + { + return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); + } - ACPI_FUNCTION_TRACE ("RsEndDependFnsStream"); + if (((Aml->Irq.Flags & 0x09) == 0x00) || + ((Aml->Irq.Flags & 0x09) == 0x09)) + { + /* + * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive] + * polarity/trigger interrupts are allowed (ACPI spec, section + * "IRQ Format"), so 0x00 and 0x09 are illegal. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid interrupt polarity/trigger in resource list, %X\n", + Aml->Irq.Flags)); + return_ACPI_STATUS (AE_BAD_DATA); + } + Resource->Data.ExtendedIrq.InterruptCount = Temp8; + if (Temp8 < 1) + { + /* Must have at least one IRQ */ - /* - * The descriptor field is static - */ - *Buffer = 0x38; - Buffer += 1; + return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + } + + if (Resource->Data.Dma.Transfer == 0x03) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid DMA.Transfer preference (3)\n")); + return_ACPI_STATUS (AE_BAD_DATA); + } +#endif - /* - * Return the number of bytes consumed in this operation - */ - *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer); - return_ACPI_STATUS (AE_OK); -} diff --git a/sys/contrib/dev/acpica/rsutils.c b/sys/contrib/dev/acpica/rsutils.c index 96d27e0..72cb9bf 100644 --- a/sys/contrib/dev/acpica/rsutils.c +++ b/sys/contrib/dev/acpica/rsutils.c @@ -1,7 +1,7 @@ /******************************************************************************* * * Module Name: rsutils - Utilities for the resource manager - * $Revision: 39 $ + * $Revision: 1.50 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -128,6 +128,489 @@ /******************************************************************************* * + * FUNCTION: AcpiRsDecodeBitmask + * + * PARAMETERS: Mask - Bitmask to decode + * List - Where the converted list is returned + * + * RETURN: Count of bits set (length of list) + * + * DESCRIPTION: Convert a bit mask into a list of values + * + ******************************************************************************/ + +UINT8 +AcpiRsDecodeBitmask ( + UINT16 Mask, + UINT8 *List) +{ + ACPI_NATIVE_UINT i; + UINT8 BitCount; + + + /* Decode the mask bits */ + + for (i = 0, BitCount = 0; Mask; i++) + { + if (Mask & 0x0001) + { + List[BitCount] = (UINT8) i; + BitCount++; + } + + Mask >>= 1; + } + + return (BitCount); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsEncodeBitmask + * + * PARAMETERS: List - List of values to encode + * Count - Length of list + * + * RETURN: Encoded bitmask + * + * DESCRIPTION: Convert a list of values to an encoded bitmask + * + ******************************************************************************/ + +UINT16 +AcpiRsEncodeBitmask ( + UINT8 *List, + UINT8 Count) +{ + ACPI_NATIVE_UINT i; + UINT16 Mask; + + + /* Encode the list into a single bitmask */ + + for (i = 0, Mask = 0; i < Count; i++) + { + Mask |= (0x0001 << List[i]); + } + + return (Mask); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMoveData + * + * PARAMETERS: Destination - Pointer to the destination descriptor + * Source - Pointer to the source descriptor + * ItemCount - How many items to move + * MoveType - Byte width + * + * RETURN: None + * + * DESCRIPTION: Move multiple data items from one descriptor to another. Handles + * alignment issues and endian issues if necessary, as configured + * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) + * + ******************************************************************************/ + +void +AcpiRsMoveData ( + void *Destination, + void *Source, + UINT16 ItemCount, + UINT8 MoveType) +{ + ACPI_NATIVE_UINT i; + + + /* One move per item */ + + for (i = 0; i < ItemCount; i++) + { + switch (MoveType) + { + /* + * For the 8-bit case, we can perform the move all at once + * since there are no alignment or endian issues + */ + case ACPI_RSC_MOVE8: + ACPI_MEMCPY (Destination, Source, ItemCount); + return; + + /* + * 16-, 32-, and 64-bit cases must use the move macros that perform + * endian conversion and/or accomodate hardware that cannot perform + * misaligned memory transfers + */ + case ACPI_RSC_MOVE16: + ACPI_MOVE_16_TO_16 (&((UINT16 *) Destination)[i], + &((UINT16 *) Source)[i]); + break; + + case ACPI_RSC_MOVE32: + ACPI_MOVE_32_TO_32 (&((UINT32 *) Destination)[i], + &((UINT32 *) Source)[i]); + break; + + case ACPI_RSC_MOVE64: + ACPI_MOVE_64_TO_64 (&((UINT64 *) Destination)[i], + &((UINT64 *) Source)[i]); + break; + + default: + return; + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetResourceInfo + * + * PARAMETERS: ResourceType - Byte 0 of a resource descriptor + * + * RETURN: Pointer to the resource conversion handler + * + * DESCRIPTION: Extract the Resource Type/Name from the first byte of + * a resource descriptor. + * + ******************************************************************************/ + +ACPI_RESOURCE_INFO * +AcpiRsGetResourceInfo ( + UINT8 ResourceType) +{ + ACPI_RESOURCE_INFO *SizeInfo; + + + ACPI_FUNCTION_ENTRY (); + + + /* Determine if this is a small or large resource */ + + if (ResourceType & ACPI_RESOURCE_NAME_LARGE) + { + /* Large Resource Type -- bits 6:0 contain the name */ + + if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX) + { + return (NULL); + } + + SizeInfo = &AcpiGbl_LgResourceInfo [ + (ResourceType & ACPI_RESOURCE_NAME_LARGE_MASK)]; + } + else + { + /* Small Resource Type -- bits 6:3 contain the name */ + + SizeInfo = &AcpiGbl_SmResourceInfo [ + ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3)]; + } + + /* Zero entry indicates an invalid resource type */ + + if (!SizeInfo->MinimumInternalStructLength) + { + return (NULL); + } + + return (SizeInfo); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetResourceLength + * + * PARAMETERS: TotalLength - Length of the AML descriptor, including + * the header and length fields. + * Aml - Pointer to the raw AML descriptor + * + * RETURN: None + * + * DESCRIPTION: Set the ResourceLength field of an AML + * resource descriptor, both Large and Small descriptors are + * supported automatically. Note: Descriptor Type field must + * be valid. + * + ******************************************************************************/ + +void +AcpiRsSetResourceLength ( + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml) +{ + ACPI_RS_LENGTH ResourceLength; + + + ACPI_FUNCTION_ENTRY (); + + + /* Determine if this is a small or large resource */ + + if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE) + { + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ + + ResourceLength = (ACPI_RS_LENGTH) + (TotalLength - sizeof (AML_RESOURCE_LARGE_HEADER)); + + /* Insert length into the Large descriptor length field */ + + ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength); + } + else + { + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ + + ResourceLength = (ACPI_RS_LENGTH) + (TotalLength - sizeof (AML_RESOURCE_SMALL_HEADER)); + + /* Insert length into the descriptor type byte */ + + Aml->SmallHeader.DescriptorType = (UINT8) + + /* Clear any existing length, preserving descriptor type bits */ + + ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) + + | ResourceLength); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetResourceHeader + * + * PARAMETERS: DescriptorType - Byte to be inserted as the type + * TotalLength - Length of the AML descriptor, including + * the header and length fields. + * Aml - Pointer to the raw AML descriptor + * + * RETURN: None + * + * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML + * resource descriptor, both Large and Small descriptors are + * supported automatically + * + ******************************************************************************/ + +void +AcpiRsSetResourceHeader ( + UINT8 DescriptorType, + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Set the Descriptor Type */ + + Aml->SmallHeader.DescriptorType = DescriptorType; + + /* Set the Resource Length */ + + AcpiRsSetResourceLength (TotalLength, Aml); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStrcpy + * + * PARAMETERS: Destination - Pointer to the destination string + * Source - Pointer to the source string + * + * RETURN: String length, including NULL terminator + * + * DESCRIPTION: Local string copy that returns the string length, saving a + * strcpy followed by a strlen. + * + ******************************************************************************/ + +static UINT16 +AcpiRsStrcpy ( + char *Destination, + char *Source) +{ + UINT16 i; + + + ACPI_FUNCTION_ENTRY (); + + + for (i = 0; Source[i]; i++) + { + Destination[i] = Source[i]; + } + + Destination[i] = 0; + + /* Return string length including the NULL terminator */ + + return ((UINT16) (i + 1)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetResourceSource + * + * PARAMETERS: ResourceLength - Length field of the descriptor + * MinimumLength - Minimum length of the descriptor (minus + * any optional fields) + * ResourceSource - Where the ResourceSource is returned + * Aml - Pointer to the raw AML descriptor + * StringPtr - (optional) where to store the actual + * ResourceSource string + * + * RETURN: Length of the string plus NULL terminator, rounded up to 32 bit + * + * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor + * to an internal resource descriptor + * + ******************************************************************************/ + +ACPI_RS_LENGTH +AcpiRsGetResourceSource ( + ACPI_RS_LENGTH ResourceLength, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource, + AML_RESOURCE *Aml, + char *StringPtr) +{ + ACPI_RSDESC_SIZE TotalLength; + UINT8 *AmlResourceSource; + + + ACPI_FUNCTION_ENTRY (); + + + TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER); + AmlResourceSource = ((UINT8 *) Aml) + MinimumLength; + + /* + * ResourceSource is present if the length of the descriptor is longer than + * the minimum length. + * + * Note: Some resource descriptors will have an additional null, so + * we add 1 to the minimum length. + */ + if (TotalLength > (ACPI_RSDESC_SIZE )(MinimumLength + 1)) + { + /* Get the ResourceSourceIndex */ + + ResourceSource->Index = AmlResourceSource[0]; + + ResourceSource->StringPtr = StringPtr; + if (!StringPtr) + { + /* + * String destination pointer is not specified; Set the String + * pointer to the end of the current ResourceSource structure. + */ + ResourceSource->StringPtr = (char *) + ((UINT8 *) ResourceSource) + sizeof (ACPI_RESOURCE_SOURCE); + } + + /* + * In order for the StructSize to fall on a 32-bit boundary, calculate + * the length of the string (+1 for the NULL terminator) and expand the + * StructSize to the next 32-bit boundary. + * + * Zero the entire area of the buffer. + */ + TotalLength = ACPI_ROUND_UP_TO_32BITS ( + ACPI_STRLEN ((char *) &AmlResourceSource[1]) + 1); + ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength); + + /* Copy the ResourceSource string to the destination */ + + ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr, + (char *) &AmlResourceSource[1]); + + return ((ACPI_RS_LENGTH) TotalLength); + } + else + { + /* ResourceSource is not present */ + + ResourceSource->Index = 0; + ResourceSource->StringLength = 0; + ResourceSource->StringPtr = NULL; + return (0); + } +} + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetResourceSource + * + * PARAMETERS: Aml - Pointer to the raw AML descriptor + * MinimumLength - Minimum length of the descriptor (minus + * any optional fields) + * ResourceSource - Internal ResourceSource + + * + * RETURN: Total length of the AML descriptor + * + * DESCRIPTION: Convert an optional ResourceSource from internal format to a + * raw AML resource descriptor + * + ******************************************************************************/ + +ACPI_RSDESC_SIZE +AcpiRsSetResourceSource ( + AML_RESOURCE *Aml, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource) +{ + UINT8 *AmlResourceSource; + ACPI_RSDESC_SIZE DescriptorLength; + + + ACPI_FUNCTION_ENTRY (); + + + DescriptorLength = MinimumLength; + + /* Non-zero string length indicates presence of a ResourceSource */ + + if (ResourceSource->StringLength) + { + /* Point to the end of the AML descriptor */ + + AmlResourceSource = ((UINT8 *) Aml) + MinimumLength; + + /* Copy the ResourceSourceIndex */ + + AmlResourceSource[0] = (UINT8) ResourceSource->Index; + + /* Copy the ResourceSource string */ + + ACPI_STRCPY ((char *) &AmlResourceSource[1], + ResourceSource->StringPtr); + + /* + * Add the length of the string (+ 1 for null terminator) to the + * final descriptor length + */ + DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1); + } + + /* Return the new total length of the AML descriptor */ + + return (DescriptorLength); +} + + +/******************************************************************************* + * * FUNCTION: AcpiRsGetPrtMethodData * * PARAMETERS: Handle - a handle to the containing object @@ -158,10 +641,10 @@ AcpiRsGetPrtMethodData ( /* Parameters guaranteed valid by caller */ - /* - * Execute the method, no parameters - */ - Status = AcpiUtEvaluateObject (Handle, "_PRT", ACPI_BTYPE_PACKAGE, &ObjDesc); + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Handle, METHOD_NAME__PRT, + ACPI_BTYPE_PACKAGE, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -212,10 +695,10 @@ AcpiRsGetCrsMethodData ( /* Parameters guaranteed valid by caller */ - /* - * Execute the method, no parameters - */ - Status = AcpiUtEvaluateObject (Handle, "_CRS", ACPI_BTYPE_BUFFER, &ObjDesc); + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Handle, METHOD_NAME__CRS, + ACPI_BTYPE_BUFFER, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -267,10 +750,10 @@ AcpiRsGetPrsMethodData ( /* Parameters guaranteed valid by caller */ - /* - * Execute the method, no parameters - */ - Status = AcpiUtEvaluateObject (Handle, "_PRS", ACPI_BTYPE_BUFFER, &ObjDesc); + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Handle, METHOD_NAME__PRS, + ACPI_BTYPE_BUFFER, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -295,6 +778,7 @@ AcpiRsGetPrsMethodData ( * FUNCTION: AcpiRsGetMethodData * * PARAMETERS: Handle - a handle to the containing object + * Path - Path to method, relative to Handle * RetBuffer - a pointer to a buffer structure for the * results * @@ -323,9 +807,8 @@ AcpiRsGetMethodData ( /* Parameters guaranteed valid by caller */ - /* - * Execute the method, no parameters - */ + /* Execute the method, no parameters */ + Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -386,15 +869,14 @@ AcpiRsSetSrsMethodData ( * Convert the linked list into a byte stream */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; - Status = AcpiRsCreateByteStream (InBuffer->Pointer, &Buffer); + Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - /* - * Init the param object - */ + /* Init the param object */ + Params[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); if (!Params[0]) { @@ -402,9 +884,8 @@ AcpiRsSetSrsMethodData ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* - * Set up the parameter object - */ + /* Set up the parameter object */ + Params[0]->Buffer.Length = (UINT32) Buffer.Length; Params[0]->Buffer.Pointer = Buffer.Pointer; Params[0]->Common.Flags = AOPOBJ_DATA_VALID; @@ -414,14 +895,21 @@ AcpiRsSetSrsMethodData ( Info.Parameters = Params; Info.ParameterType = ACPI_PARAM_ARGS; - /* - * Execute the method, no return value - */ - Status = AcpiNsEvaluateRelative ("_SRS", &Info); + /* Execute the method, no return value */ + + Status = AcpiNsEvaluateRelative (METHOD_NAME__SRS, &Info); + if (ACPI_SUCCESS (Status)) + { + /* Delete any return object (especially if ImplicitReturn is enabled) */ + + if (Info.ReturnObject) + { + AcpiUtRemoveReference (Info.ReturnObject); + } + } + + /* Clean up and return the status from AcpiNsEvaluateRelative */ - /* - * Clean up and return the status from AcpiNsEvaluateRelative - */ AcpiUtRemoveReference (Params[0]); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/rsxface.c b/sys/contrib/dev/acpica/rsxface.c index 5d0b3bb..109179e 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: 31 $ + * $Revision: 1.37 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,6 +123,23 @@ #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rsxface") +/* Local macros for 16,32-bit to 64-bit conversion */ + +#define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field) +#define ACPI_COPY_ADDRESS(Out, In) \ + ACPI_COPY_FIELD(Out, In, ResourceType); \ + ACPI_COPY_FIELD(Out, In, ProducerConsumer); \ + ACPI_COPY_FIELD(Out, In, Decode); \ + ACPI_COPY_FIELD(Out, In, MinAddressFixed); \ + ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \ + ACPI_COPY_FIELD(Out, In, Info); \ + ACPI_COPY_FIELD(Out, In, Granularity); \ + ACPI_COPY_FIELD(Out, In, Minimum); \ + ACPI_COPY_FIELD(Out, In, Maximum); \ + ACPI_COPY_FIELD(Out, In, TranslationOffset); \ + ACPI_COPY_FIELD(Out, In, AddressLength); \ + ACPI_COPY_FIELD(Out, In, ResourceSource); + /******************************************************************************* * @@ -312,10 +329,10 @@ AcpiGetPossibleResources ( ACPI_STATUS AcpiWalkResources ( - ACPI_HANDLE DeviceHandle, - char *Path, - ACPI_WALK_RESOURCE_CALLBACK UserFunction, - void *Context) + ACPI_HANDLE DeviceHandle, + char *Path, + ACPI_WALK_RESOURCE_CALLBACK UserFunction, + void *Context) { ACPI_STATUS Status; ACPI_BUFFER Buffer = {ACPI_ALLOCATE_BUFFER, NULL}; @@ -349,7 +366,7 @@ AcpiWalkResources ( for (;;) { - if (!Resource || Resource->Id == ACPI_RSTYPE_END_TAG) + if (!Resource || Resource->Type == ACPI_RESOURCE_TYPE_END_TAG) { break; } @@ -428,9 +445,8 @@ AcpiSetCurrentResources ( ACPI_FUNCTION_TRACE ("AcpiSetCurrentResources"); - /* - * Must have a valid handle and buffer - */ + /* Must have a valid handle and buffer */ + if ((!DeviceHandle) || (!InBuffer) || (!InBuffer->Pointer) || @@ -444,27 +460,12 @@ AcpiSetCurrentResources ( } -#define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field) -#define ACPI_COPY_ADDRESS(Out, In) \ - ACPI_COPY_FIELD(Out, In, ResourceType); \ - ACPI_COPY_FIELD(Out, In, ProducerConsumer); \ - ACPI_COPY_FIELD(Out, In, Decode); \ - ACPI_COPY_FIELD(Out, In, MinAddressFixed); \ - ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \ - ACPI_COPY_FIELD(Out, In, Attribute); \ - ACPI_COPY_FIELD(Out, In, Granularity); \ - ACPI_COPY_FIELD(Out, In, MinAddressRange); \ - ACPI_COPY_FIELD(Out, In, MaxAddressRange); \ - ACPI_COPY_FIELD(Out, In, AddressTranslationOffset); \ - ACPI_COPY_FIELD(Out, In, AddressLength); \ - ACPI_COPY_FIELD(Out, In, ResourceSource); - /****************************************************************************** * * FUNCTION: AcpiResourceToAddress64 * - * PARAMETERS: resource - Pointer to a resource - * out - Pointer to the users's return + * PARAMETERS: Resource - Pointer to a resource + * Out - Pointer to the users's return * buffer (a struct * acpi_resource_address64) * @@ -486,29 +487,27 @@ AcpiResourceToAddress64 ( ACPI_RESOURCE_ADDRESS32 *Address32; - switch (Resource->Id) { - case ACPI_RSTYPE_ADDRESS16: + switch (Resource->Type) + { + case ACPI_RESOURCE_TYPE_ADDRESS16: Address16 = (ACPI_RESOURCE_ADDRESS16 *) &Resource->Data; - ACPI_COPY_ADDRESS(Out, Address16); + ACPI_COPY_ADDRESS (Out, Address16); break; - - case ACPI_RSTYPE_ADDRESS32: + case ACPI_RESOURCE_TYPE_ADDRESS32: Address32 = (ACPI_RESOURCE_ADDRESS32 *) &Resource->Data; - ACPI_COPY_ADDRESS(Out, Address32); + ACPI_COPY_ADDRESS (Out, Address32); break; - - case ACPI_RSTYPE_ADDRESS64: + case ACPI_RESOURCE_TYPE_ADDRESS64: /* Simple copy for 64 bit source */ ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64)); break; - default: return (AE_BAD_PARAMETER); } diff --git a/sys/contrib/dev/acpica/tbconvrt.c b/sys/contrib/dev/acpica/tbconvrt.c index 16ad304..aafb62c 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: 57 $ + * $Revision: 1.64 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,6 +123,24 @@ #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbconvrt") +/* Local prototypes */ + +static void +AcpiTbInitGenericAddress ( + ACPI_GENERIC_ADDRESS *NewGasStruct, + UINT8 RegisterBitWidth, + ACPI_PHYSICAL_ADDRESS Address); + +static void +AcpiTbConvertFadt1 ( + FADT_DESCRIPTOR_REV2 *LocalFadt, + FADT_DESCRIPTOR_REV1 *OriginalFadt); + +static void +AcpiTbConvertFadt2 ( + FADT_DESCRIPTOR_REV2 *LocalFadt, + FADT_DESCRIPTOR_REV2 *OriginalFadt); + /******************************************************************************* * @@ -149,7 +167,9 @@ AcpiTbGetTableCount ( ACPI_FUNCTION_ENTRY (); - if (RSDP->Revision < 2) + /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ + + if (AcpiGbl_RootTableType == ACPI_TABLE_TYPE_RSDT) { PointerSize = sizeof (UINT32); } @@ -214,15 +234,19 @@ AcpiTbConvertToXsdt ( for (i = 0; i < AcpiGbl_RsdtTableCount; i++) { - if (AcpiGbl_RSDP->Revision < 2) + /* RSDT pointers are 32 bits, XSDT pointers are 64 bits */ + + if (AcpiGbl_RootTableType == ACPI_TABLE_TYPE_RSDT) { ACPI_STORE_ADDRESS (NewTable->TableOffsetEntry[i], - (ACPI_CAST_PTR (RSDT_DESCRIPTOR_REV1, TableInfo->Pointer))->TableOffsetEntry[i]); + (ACPI_CAST_PTR (RSDT_DESCRIPTOR_REV1, + TableInfo->Pointer))->TableOffsetEntry[i]); } else { NewTable->TableOffsetEntry[i] = - (ACPI_CAST_PTR (XSDT_DESCRIPTOR, TableInfo->Pointer))->TableOffsetEntry[i]; + (ACPI_CAST_PTR (XSDT_DESCRIPTOR, + TableInfo->Pointer))->TableOffsetEntry[i]; } } @@ -240,7 +264,7 @@ AcpiTbConvertToXsdt ( } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiTbInitGenericAddress * @@ -266,7 +290,7 @@ AcpiTbInitGenericAddress ( NewGasStruct->AddressSpaceId = ACPI_ADR_SPACE_SYSTEM_IO; NewGasStruct->RegisterBitWidth = RegisterBitWidth; NewGasStruct->RegisterBitOffset = 0; - NewGasStruct->Reserved = 0; + NewGasStruct->AccessWidth = 0; } @@ -277,7 +301,7 @@ AcpiTbInitGenericAddress ( * PARAMETERS: LocalFadt - Pointer to new FADT * OriginalFadt - Pointer to old FADT * - * RETURN: Populates LocalFadt + * RETURN: None, populates LocalFadt * * DESCRIPTION: Convert an ACPI 1.0 FADT to common internal format * @@ -289,7 +313,6 @@ AcpiTbConvertFadt1 ( FADT_DESCRIPTOR_REV1 *OriginalFadt) { - /* ACPI 1.0 FACS */ /* The BIOS stored FADT should agree with Revision 1.0 */ @@ -307,7 +330,8 @@ AcpiTbConvertFadt1 ( ACPI_STORE_ADDRESS (LocalFadt->XDsdt, LocalFadt->V1_Dsdt); /* - * System Interrupt Model isn't used in ACPI 2.0 (LocalFadt->Reserved1 = 0;) + * System Interrupt Model isn't used in ACPI 2.0 + * (LocalFadt->Reserved1 = 0;) */ /* @@ -342,7 +366,8 @@ AcpiTbConvertFadt1 ( * that immediately follows. */ ACPI_MEMCPY (&LocalFadt->ResetRegister, - &((FADT_DESCRIPTOR_REV2_MINUS *) OriginalFadt)->ResetRegister, + &(ACPI_CAST_PTR (FADT_DESCRIPTOR_REV2_MINUS, + OriginalFadt))->ResetRegister, sizeof (ACPI_GENERIC_ADDRESS) + 1); } else @@ -378,7 +403,8 @@ AcpiTbConvertFadt1 ( AcpiTbInitGenericAddress (&AcpiGbl_XPm1aEnable, (UINT8) ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen), - (ACPI_PHYSICAL_ADDRESS) (ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address) + + (ACPI_PHYSICAL_ADDRESS) + (ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address) + ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen))); /* PM1B is optional; leave null if not present */ @@ -387,7 +413,8 @@ AcpiTbConvertFadt1 ( { AcpiTbInitGenericAddress (&AcpiGbl_XPm1bEnable, (UINT8) ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen), - (ACPI_PHYSICAL_ADDRESS) (ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address) + + (ACPI_PHYSICAL_ADDRESS) + (ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address) + ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen))); } } @@ -400,7 +427,7 @@ AcpiTbConvertFadt1 ( * PARAMETERS: LocalFadt - Pointer to new FADT * OriginalFadt - Pointer to old FADT * - * RETURN: Populates LocalFadt + * RETURN: None, populates LocalFadt * * DESCRIPTION: Convert an ACPI 2.0 FADT to common internal format. * Handles optional "X" fields. @@ -424,7 +451,8 @@ AcpiTbConvertFadt2 ( */ if (!(ACPI_GET_ADDRESS (LocalFadt->XFirmwareCtrl))) { - ACPI_STORE_ADDRESS (LocalFadt->XFirmwareCtrl, LocalFadt->V1_FirmwareCtrl); + ACPI_STORE_ADDRESS (LocalFadt->XFirmwareCtrl, + LocalFadt->V1_FirmwareCtrl); } if (!(ACPI_GET_ADDRESS (LocalFadt->XDsdt))) @@ -435,37 +463,43 @@ AcpiTbConvertFadt2 ( if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address))) { AcpiTbInitGenericAddress (&LocalFadt->XPm1aEvtBlk, - LocalFadt->Pm1EvtLen, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1aEvtBlk); + LocalFadt->Pm1EvtLen, + (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1aEvtBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address))) { AcpiTbInitGenericAddress (&LocalFadt->XPm1bEvtBlk, - LocalFadt->Pm1EvtLen, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1bEvtBlk); + LocalFadt->Pm1EvtLen, + (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1bEvtBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1aCntBlk.Address))) { AcpiTbInitGenericAddress (&LocalFadt->XPm1aCntBlk, - LocalFadt->Pm1CntLen, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1aCntBlk); + LocalFadt->Pm1CntLen, + (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1aCntBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1bCntBlk.Address))) { AcpiTbInitGenericAddress (&LocalFadt->XPm1bCntBlk, - LocalFadt->Pm1CntLen, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1bCntBlk); + LocalFadt->Pm1CntLen, + (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm1bCntBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPm2CntBlk.Address))) { AcpiTbInitGenericAddress (&LocalFadt->XPm2CntBlk, - LocalFadt->Pm2CntLen, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm2CntBlk); + LocalFadt->Pm2CntLen, + (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_Pm2CntBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPmTmrBlk.Address))) { AcpiTbInitGenericAddress (&LocalFadt->XPmTmrBlk, - LocalFadt->PmTmLen, (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_PmTmrBlk); + LocalFadt->PmTmLen, + (ACPI_PHYSICAL_ADDRESS) LocalFadt->V1_PmTmrBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XGpe0Blk.Address))) @@ -484,9 +518,12 @@ AcpiTbConvertFadt2 ( AcpiTbInitGenericAddress (&AcpiGbl_XPm1aEnable, (UINT8) ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen), - (ACPI_PHYSICAL_ADDRESS) (ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address) + + (ACPI_PHYSICAL_ADDRESS) + (ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address) + ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen))); - AcpiGbl_XPm1aEnable.AddressSpaceId = LocalFadt->XPm1aEvtBlk.AddressSpaceId; + + AcpiGbl_XPm1aEnable.AddressSpaceId = + LocalFadt->XPm1aEvtBlk.AddressSpaceId; /* PM1B is optional; leave null if not present */ @@ -494,9 +531,12 @@ AcpiTbConvertFadt2 ( { AcpiTbInitGenericAddress (&AcpiGbl_XPm1bEnable, (UINT8) ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen), - (ACPI_PHYSICAL_ADDRESS) (ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address) + + (ACPI_PHYSICAL_ADDRESS) + (ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address) + ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen))); - AcpiGbl_XPm1bEnable.AddressSpaceId = LocalFadt->XPm1bEvtBlk.AddressSpaceId; + + AcpiGbl_XPm1bEnable.AddressSpaceId = + LocalFadt->XPm1bEvtBlk.AddressSpaceId; } } @@ -518,7 +558,8 @@ AcpiTbConvertFadt2 ( ******************************************************************************/ ACPI_STATUS -AcpiTbConvertTableFadt (void) +AcpiTbConvertTableFadt ( + void) { FADT_DESCRIPTOR_REV2 *LocalFadt; ACPI_TABLE_DESC *TableDesc; @@ -533,7 +574,8 @@ AcpiTbConvertTableFadt (void) */ if (AcpiGbl_FADT->Length < sizeof (FADT_DESCRIPTOR_REV1)) { - ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n", AcpiGbl_FADT->Length)); + ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n", + AcpiGbl_FADT->Length)); return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); } @@ -551,8 +593,9 @@ AcpiTbConvertTableFadt (void) { /* Length is too short to be a V2.0 table */ - ACPI_REPORT_WARNING (("Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n", - AcpiGbl_FADT->Length, AcpiGbl_FADT->Revision)); + ACPI_REPORT_WARNING (( + "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n", + AcpiGbl_FADT->Length, AcpiGbl_FADT->Revision)); AcpiTbConvertFadt1 (LocalFadt, (void *) AcpiGbl_FADT); } @@ -570,9 +613,8 @@ AcpiTbConvertTableFadt (void) AcpiTbConvertFadt1 (LocalFadt, (void *) AcpiGbl_FADT); } - /* - * Global FADT pointer will point to the new common V2.0 FADT - */ + /* Global FADT pointer will point to the new common V2.0 FADT */ + AcpiGbl_FADT = LocalFadt; AcpiGbl_FADT->Length = sizeof (FADT_DESCRIPTOR); @@ -600,9 +642,9 @@ AcpiTbConvertTableFadt (void) /******************************************************************************* * - * FUNCTION: AcpiTbConvertTableFacs + * FUNCTION: AcpiTbBuildCommonFacs * - * PARAMETERS: TableInfo - Info for currently installad FACS + * PARAMETERS: TableInfo - Info for currently installed FACS * * RETURN: Status * @@ -623,13 +665,15 @@ AcpiTbBuildCommonFacs ( if (AcpiGbl_FACS->Length < 24) { - ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n", AcpiGbl_FACS->Length)); + ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n", + AcpiGbl_FACS->Length)); return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); } if (AcpiGbl_FACS->Length < 64) { - ACPI_REPORT_WARNING (("FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", + ACPI_REPORT_WARNING (( + "FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", AcpiGbl_FACS->Length)); } @@ -643,7 +687,8 @@ AcpiTbBuildCommonFacs ( { /* ACPI 1.0 FACS or short table or optional X_ field is zero */ - AcpiGbl_CommonFACS.FirmwareWakingVector = ACPI_CAST_PTR (UINT64, &(AcpiGbl_FACS->FirmwareWakingVector)); + AcpiGbl_CommonFACS.FirmwareWakingVector = ACPI_CAST_PTR (UINT64, + &(AcpiGbl_FACS->FirmwareWakingVector)); AcpiGbl_CommonFACS.VectorWidth = 32; } else diff --git a/sys/contrib/dev/acpica/tbget.c b/sys/contrib/dev/acpica/tbget.c index fd0cba4..457678b 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: 90 $ + * $Revision: 1.94 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,6 +123,19 @@ #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbget") +/* Local prototypes */ + +static ACPI_STATUS +AcpiTbGetThisTable ( + ACPI_POINTER *Address, + ACPI_TABLE_HEADER *Header, + ACPI_TABLE_DESC *TableInfo); + +static ACPI_STATUS +AcpiTbTableOverride ( + ACPI_TABLE_HEADER *Header, + ACPI_TABLE_DESC *TableInfo); + /******************************************************************************* * @@ -150,9 +163,8 @@ AcpiTbGetTable ( ACPI_FUNCTION_TRACE ("TbGetTable"); - /* - * Get the header in order to get signature and table size - */ + /* Get the header in order to get signature and table size */ + Status = AcpiTbGetTableHeader (Address, &Header); if (ACPI_FAILURE (Status)) { @@ -203,8 +215,8 @@ AcpiTbGetTableHeader ( /* - * Flags contains the current processor mode (Virtual or Physical addressing) - * The PointerType is either Logical or Physical + * Flags contains the current processor mode (Virtual or Physical + * addressing) The PointerType is either Logical or Physical */ switch (Address->PointerType) { @@ -213,7 +225,8 @@ AcpiTbGetTableHeader ( /* Pointer matches processor mode, copy the header */ - ACPI_MEMCPY (ReturnHeader, Address->Pointer.Logical, sizeof (ACPI_TABLE_HEADER)); + ACPI_MEMCPY (ReturnHeader, Address->Pointer.Logical, + sizeof (ACPI_TABLE_HEADER)); break; @@ -221,11 +234,12 @@ AcpiTbGetTableHeader ( /* Create a logical address for the physical pointer*/ - Status = AcpiOsMapMemory (Address->Pointer.Physical, sizeof (ACPI_TABLE_HEADER), - (void *) &Header); + Status = AcpiOsMapMemory (Address->Pointer.Physical, + sizeof (ACPI_TABLE_HEADER), (void *) &Header); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("Could not map memory at %8.8X%8.8X for length %X\n", + ACPI_REPORT_ERROR (( + "Could not map memory at %8.8X%8.8X for length %X\n", ACPI_FORMAT_UINT64 (Address->Pointer.Physical), sizeof (ACPI_TABLE_HEADER))); return_ACPI_STATUS (Status); @@ -289,9 +303,8 @@ AcpiTbGetTableBody ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * Attempt table override. - */ + /* Attempt table override. */ + Status = AcpiTbTableOverride (Header, TableInfo); if (ACPI_SUCCESS (Status)) { @@ -321,7 +334,7 @@ AcpiTbGetTableBody ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiTbTableOverride ( ACPI_TABLE_HEADER *Header, ACPI_TABLE_DESC *TableInfo) @@ -398,7 +411,7 @@ AcpiTbTableOverride ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiTbGetThisTable ( ACPI_POINTER *Address, ACPI_TABLE_HEADER *Header, @@ -413,8 +426,8 @@ AcpiTbGetThisTable ( /* - * Flags contains the current processor mode (Virtual or Physical addressing) - * The PointerType is either Logical or Physical + * Flags contains the current processor mode (Virtual or Physical + * addressing) The PointerType is either Logical or Physical */ switch (Address->PointerType) { @@ -426,7 +439,8 @@ AcpiTbGetThisTable ( FullTable = ACPI_MEM_ALLOCATE (Header->Length); if (!FullTable) { - ACPI_REPORT_ERROR (("Could not allocate table memory for [%4.4s] length %X\n", + ACPI_REPORT_ERROR (( + "Could not allocate table memory for [%4.4s] length %X\n", Header->Signature, Header->Length)); return_ACPI_STATUS (AE_NO_MEMORY); } @@ -447,13 +461,15 @@ AcpiTbGetThisTable ( * Just map the table's physical memory * into our address space. */ - Status = AcpiOsMapMemory (Address->Pointer.Physical, (ACPI_SIZE) Header->Length, - (void *) &FullTable); + Status = AcpiOsMapMemory (Address->Pointer.Physical, + (ACPI_SIZE) Header->Length, (void *) &FullTable); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", + ACPI_REPORT_ERROR (( + "Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n", Header->Signature, - ACPI_FORMAT_UINT64 (Address->Pointer.Physical), Header->Length)); + ACPI_FORMAT_UINT64 (Address->Pointer.Physical), + Header->Length)); return (Status); } @@ -557,9 +573,8 @@ AcpiTbGetTablePtr ( return_ACPI_STATUS (AE_OK); } - /* - * Check for instance out of range - */ + /* Check for instance out of range */ + if (Instance > AcpiGbl_TableLists[TableType].Count) { return_ACPI_STATUS (AE_NOT_EXIST); diff --git a/sys/contrib/dev/acpica/tbgetall.c b/sys/contrib/dev/acpica/tbgetall.c index 996015f..05739b6 100644 --- a/sys/contrib/dev/acpica/tbgetall.c +++ b/sys/contrib/dev/acpica/tbgetall.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbgetall - Get all required ACPI tables - * $Revision: 9 $ + * $Revision: 1.13 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,6 +123,19 @@ #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbgetall") +/* Local prototypes */ + +static ACPI_STATUS +AcpiTbGetPrimaryTable ( + ACPI_POINTER *Address, + ACPI_TABLE_DESC *TableInfo); + +static ACPI_STATUS +AcpiTbGetSecondaryTable ( + ACPI_POINTER *Address, + ACPI_STRING Signature, + ACPI_TABLE_DESC *TableInfo); + /******************************************************************************* * @@ -137,7 +150,7 @@ * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiTbGetPrimaryTable ( ACPI_POINTER *Address, ACPI_TABLE_DESC *TableInfo) @@ -156,9 +169,8 @@ AcpiTbGetPrimaryTable ( return_ACPI_STATUS (AE_OK); } - /* - * Get the header in order to get signature and table size - */ + /* Get the header in order to get signature and table size */ + Status = AcpiTbGetTableHeader (Address, &Header); if (ACPI_FAILURE (Status)) { @@ -208,7 +220,7 @@ AcpiTbGetPrimaryTable ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiTbGetSecondaryTable ( ACPI_POINTER *Address, ACPI_STRING Signature, @@ -233,7 +245,8 @@ AcpiTbGetSecondaryTable ( if (ACPI_STRNCMP (Header.Signature, Signature, ACPI_NAME_SIZE)) { - ACPI_REPORT_ERROR (("Incorrect table signature - wanted [%s] found [%4.4s]\n", + ACPI_REPORT_ERROR (( + "Incorrect table signature - wanted [%s] found [%4.4s]\n", Signature, Header.Signature)); return_ACPI_STATUS (AE_BAD_SIGNATURE); } @@ -313,7 +326,8 @@ AcpiTbGetRequiredTables ( { /* Get the table address from the common internal XSDT */ - Address.Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_XSDT->TableOffsetEntry[i]); + Address.Pointer.Value = ACPI_GET_ADDRESS ( + AcpiGbl_XSDT->TableOffsetEntry[i]); /* * Get the tables needed by this subsystem (FADT and any SSDTs). @@ -337,19 +351,19 @@ AcpiTbGetRequiredTables ( } /* - * Convert the FADT to a common format. This allows earlier revisions of the - * table to coexist with newer versions, using common access code. + * Convert the FADT to a common format. This allows earlier revisions of + * the table to coexist with newer versions, using common access code. */ Status = AcpiTbConvertTableFadt (); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("Could not convert FADT to internal common format\n")); + ACPI_REPORT_ERROR (( + "Could not convert FADT to internal common format\n")); return_ACPI_STATUS (Status); } - /* - * Get the FACS (Pointed to by the FADT) - */ + /* Get the FACS (Pointed to by the FADT) */ + Address.Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_FADT->XFirmwareCtrl); Status = AcpiTbGetSecondaryTable (&Address, FACS_SIG, &TableInfo); @@ -370,9 +384,8 @@ AcpiTbGetRequiredTables ( return_ACPI_STATUS (Status); } - /* - * Get/install the DSDT (Pointed to by the FADT) - */ + /* Get/install the DSDT (Pointed to by the FADT) */ + Address.Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt); Status = AcpiTbGetSecondaryTable (&Address, DSDT_SIG, &TableInfo); diff --git a/sys/contrib/dev/acpica/tbinstal.c b/sys/contrib/dev/acpica/tbinstal.c index 39a25d5..f7bd0db 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: 74 $ + * $Revision: 1.80 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,6 +124,14 @@ #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbinstal") +/* Local prototypes */ + +static ACPI_STATUS +AcpiTbMatchSignature ( + char *Signature, + ACPI_TABLE_DESC *TableInfo, + UINT8 SearchType); + /******************************************************************************* * @@ -131,6 +139,7 @@ * * PARAMETERS: Signature - Table signature to match * TableInfo - Return data + * SearchType - Table type to match (primary/secondary) * * RETURN: Status * @@ -139,7 +148,7 @@ * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiTbMatchSignature ( char *Signature, ACPI_TABLE_DESC *TableInfo, @@ -151,9 +160,8 @@ AcpiTbMatchSignature ( ACPI_FUNCTION_TRACE ("TbMatchSignature"); - /* - * Search for a signature match among the known table types - */ + /* Search for a signature match among the known table types */ + for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) { if (!(AcpiGbl_TableData[i].Flags & SearchType)) @@ -195,9 +203,7 @@ AcpiTbMatchSignature ( * * RETURN: Status * - * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must - * already be loaded and validated. - * Install the table into the global data structs. + * DESCRIPTION: Install the table into the global data structures. * ******************************************************************************/ @@ -207,6 +213,7 @@ AcpiTbInstallTable ( { ACPI_STATUS Status; + ACPI_FUNCTION_TRACE ("TbInstallTable"); @@ -215,23 +222,35 @@ AcpiTbInstallTable ( Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("Could not acquire table mutex for [%4.4s], %s\n", - TableInfo->Pointer->Signature, AcpiFormatException (Status))); + ACPI_REPORT_ERROR (("Could not acquire table mutex, %s\n", + AcpiFormatException (Status))); return_ACPI_STATUS (Status); } + /* + * Ignore a table that is already installed. For example, some BIOS + * ASL code will repeatedly attempt to load the same SSDT. + */ + Status = AcpiTbIsTableInstalled (TableInfo); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + /* Install the table into the global data structure */ Status = AcpiTbInitTableDescriptor (TableInfo->Type, TableInfo); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("Could not install ACPI table [%4.4s], %s\n", + ACPI_REPORT_ERROR (("Could not install table [%4.4s], %s\n", TableInfo->Pointer->Signature, AcpiFormatException (Status))); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s located at %p\n", AcpiGbl_TableData[TableInfo->Type].Name, TableInfo->Pointer)); + +UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_ACPI_STATUS (Status); } @@ -242,6 +261,7 @@ AcpiTbInstallTable ( * FUNCTION: AcpiTbRecognizeTable * * PARAMETERS: TableInfo - Return value from AcpiTbGetTableBody + * SearchType - Table type to match (primary/secondary) * * RETURN: Status * @@ -285,7 +305,8 @@ AcpiTbRecognizeTable ( * This can be any one of many valid ACPI tables, it just isn't one of * the tables that is consumed by the core subsystem */ - Status = AcpiTbMatchSignature (TableHeader->Signature, TableInfo, SearchType); + Status = AcpiTbMatchSignature (TableHeader->Signature, + TableInfo, SearchType); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -325,6 +346,7 @@ AcpiTbInitTableDescriptor ( { ACPI_TABLE_LIST *ListHead; ACPI_TABLE_DESC *TableDesc; + ACPI_STATUS Status; ACPI_FUNCTION_TRACE_U32 ("TbInitTableDescriptor", TableType); @@ -338,9 +360,16 @@ AcpiTbInitTableDescriptor ( return_ACPI_STATUS (AE_NO_MEMORY); } - /* - * Install the table into the global data structure - */ + /* Get a new owner ID for the table */ + + Status = AcpiUtAllocateOwnerId (&TableDesc->OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Install the table into the global data structure */ + ListHead = &AcpiGbl_TableLists[TableType]; /* @@ -408,7 +437,6 @@ AcpiTbInitTableDescriptor ( TableDesc->AmlStart = (UINT8 *) (TableDesc->Pointer + 1), TableDesc->AmlLength = (UINT32) (TableDesc->Length - (UINT32) sizeof (ACPI_TABLE_HEADER)); - TableDesc->TableId = AcpiUtAllocateOwnerId (ACPI_OWNER_TYPE_TABLE); TableDesc->LoadedIntoNamespace = FALSE; /* @@ -422,7 +450,7 @@ AcpiTbInitTableDescriptor ( /* Return Data */ - TableInfo->TableId = TableDesc->TableId; + TableInfo->OwnerId = TableDesc->OwnerId; TableInfo->InstalledDesc = TableDesc; return_ACPI_STATUS (AE_OK); @@ -442,7 +470,8 @@ AcpiTbInitTableDescriptor ( ******************************************************************************/ void -AcpiTbDeleteAllTables (void) +AcpiTbDeleteAllTables ( + void) { ACPI_TABLE_TYPE Type; diff --git a/sys/contrib/dev/acpica/tbrsdt.c b/sys/contrib/dev/acpica/tbrsdt.c index 425e51a..258a75d 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: 13 $ + * $Revision: 1.20 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -159,7 +159,8 @@ AcpiTbVerifyRsdp ( /* * Obtain access to the RSDP structure */ - Status = AcpiOsMapMemory (Address->Pointer.Physical, sizeof (RSDP_DESCRIPTOR), + Status = AcpiOsMapMemory (Address->Pointer.Physical, + sizeof (RSDP_DESCRIPTOR), (void *) &Rsdp); if (ACPI_FAILURE (Status)) { @@ -171,36 +172,14 @@ AcpiTbVerifyRsdp ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* - * The signature and checksum must both be correct - */ - if (ACPI_STRNCMP ((char *) Rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) - { - /* Nope, BAD Signature */ - - Status = AE_BAD_SIGNATURE; - goto Cleanup; - } + /* Verify RSDP signature and checksum */ - /* Check the standard checksum */ - - if (AcpiTbChecksum (Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) + Status = AcpiTbValidateRsdp (Rsdp); + if (ACPI_FAILURE (Status)) { - Status = AE_BAD_CHECKSUM; goto Cleanup; } - /* Check extended checksum if table version >= 2 */ - - if (Rsdp->Revision >= 2) - { - if (AcpiTbChecksum (Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0) - { - Status = AE_BAD_CHECKSUM; - goto Cleanup; - } - } - /* The RSDP supplied is OK */ TableInfo.Pointer = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp); @@ -236,12 +215,12 @@ Cleanup: * * FUNCTION: AcpiTbGetRsdtAddress * - * PARAMETERS: None + * PARAMETERS: OutAddress - Where the address is returned * - * RETURN: RSDT physical address + * RETURN: None, Address * - * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the - * version of the RSDP + * DESCRIPTION: Extract the address of either the RSDT or XSDT, depending on the + * version of the RSDP and whether the XSDT pointer is valid * ******************************************************************************/ @@ -255,17 +234,21 @@ AcpiTbGetRsdtAddress ( OutAddress->PointerType = AcpiGbl_TableFlags | ACPI_LOGICAL_ADDRESSING; - /* - * For RSDP revision 0 or 1, we use the RSDT. - * For RSDP revision 2 (and above), we use the XSDT - */ - if (AcpiGbl_RSDP->Revision < 2) + /* Use XSDT if it is present */ + + if ((AcpiGbl_RSDP->Revision >= 2) && + ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress)) { - OutAddress->Pointer.Value = AcpiGbl_RSDP->RsdtPhysicalAddress; + OutAddress->Pointer.Value = + ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress); + AcpiGbl_RootTableType = ACPI_TABLE_TYPE_XSDT; } else { - OutAddress->Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress); + /* No XSDT, use the RSDT */ + + OutAddress->Pointer.Value = AcpiGbl_RSDP->RsdtPhysicalAddress; + AcpiGbl_RootTableType = ACPI_TABLE_TYPE_RSDT; } } @@ -293,10 +276,9 @@ AcpiTbValidateRsdt ( /* - * For RSDP revision 0 or 1, we use the RSDT. - * For RSDP revision 2 and above, we use the XSDT + * Search for appropriate signature, RSDT or XSDT */ - if (AcpiGbl_RSDP->Revision < 2) + if (AcpiGbl_RootTableType == ACPI_TABLE_TYPE_RSDT) { NoMatch = ACPI_STRNCMP ((char *) TablePtr, RSDT_SIG, sizeof (RSDT_SIG) -1); @@ -311,7 +293,8 @@ AcpiTbValidateRsdt ( { /* Invalid RSDT or XSDT signature */ - ACPI_REPORT_ERROR (("Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); + ACPI_REPORT_ERROR (( + "Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); ACPI_DUMP_BUFFER (AcpiGbl_RSDP, 20); @@ -320,13 +303,13 @@ AcpiTbValidateRsdt ( AcpiGbl_RSDP->RsdtPhysicalAddress, (void *) (ACPI_NATIVE_UINT) AcpiGbl_RSDP->RsdtPhysicalAddress)); - if (AcpiGbl_RSDP->Revision < 2) + if (AcpiGbl_RootTableType == ACPI_TABLE_TYPE_RSDT) { - ACPI_REPORT_ERROR (("Looking for RSDT (RSDP->Rev < 2)\n")) + ACPI_REPORT_ERROR (("Looking for RSDT\n")) } else { - ACPI_REPORT_ERROR (("Looking for XSDT (RSDP->Rev >= 2)\n")) + ACPI_REPORT_ERROR (("Looking for XSDT\n")) } ACPI_DUMP_BUFFER ((char *) TablePtr, 48); @@ -372,11 +355,12 @@ AcpiTbGetTableRsdt ( { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT/XSDT, %s\n", AcpiFormatException (Status))); + return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n", + "RSDP located at %p, points to RSDT physical=%8.8X%8.8X\n", AcpiGbl_RSDP, ACPI_FORMAT_UINT64 (Address.Pointer.Value))); @@ -390,7 +374,8 @@ AcpiTbGetTableRsdt ( /* Get the number of tables defined in the RSDT or XSDT */ - AcpiGbl_RsdtTableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, TableInfo.Pointer); + AcpiGbl_RsdtTableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, + TableInfo.Pointer); /* Convert and/or copy to an XSDT structure */ diff --git a/sys/contrib/dev/acpica/tbutils.c b/sys/contrib/dev/acpica/tbutils.c index b91d578..3429ebf 100644 --- a/sys/contrib/dev/acpica/tbutils.c +++ b/sys/contrib/dev/acpica/tbutils.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: tbutils - Table manipulation utilities - * $Revision: 61 $ + * $Revision: 1.71 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,49 +123,82 @@ #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbutils") +/* Local prototypes */ + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_STATUS +AcpiTbHandleToObject ( + UINT16 TableId, + ACPI_TABLE_DESC **TableDesc); +#endif + /******************************************************************************* * - * FUNCTION: AcpiTbHandleToObject + * FUNCTION: AcpiTbIsTableInstalled * - * PARAMETERS: TableId - Id for which the function is searching - * TableDesc - Pointer to return the matching table - * descriptor. + * PARAMETERS: NewTableDesc - Descriptor for new table being installed * - * RETURN: Search the tables to find one with a matching TableId and - * return a pointer to that table descriptor. + * RETURN: Status - AE_ALREADY_EXISTS if the table is already installed + * + * DESCRIPTION: Determine if an ACPI table is already installed + * + * MUTEX: Table data structures should be locked * ******************************************************************************/ ACPI_STATUS -AcpiTbHandleToObject ( - UINT16 TableId, - ACPI_TABLE_DESC **ReturnTableDesc) +AcpiTbIsTableInstalled ( + ACPI_TABLE_DESC *NewTableDesc) { - UINT32 i; ACPI_TABLE_DESC *TableDesc; - ACPI_FUNCTION_NAME ("TbHandleToObject"); + ACPI_FUNCTION_TRACE ("TbIsTableInstalled"); - for (i = 0; i < ACPI_TABLE_MAX; i++) + /* Get the list descriptor and first table descriptor */ + + TableDesc = AcpiGbl_TableLists[NewTableDesc->Type].Next; + + /* Examine all installed tables of this type */ + + while (TableDesc) { - TableDesc = AcpiGbl_TableLists[i].Next; - while (TableDesc) + /* + * If the table lengths match, perform a full bytewise compare. This + * means that we will allow tables with duplicate OemTableId(s), as + * long as the tables are different in some way. + * + * Checking if the table has been loaded into the namespace means that + * we don't check for duplicate tables during the initial installation + * of tables within the RSDT/XSDT. + */ + if ((TableDesc->LoadedIntoNamespace) && + (TableDesc->Pointer->Length == NewTableDesc->Pointer->Length) && + (!ACPI_MEMCMP (TableDesc->Pointer, NewTableDesc->Pointer, + NewTableDesc->Pointer->Length))) { - if (TableDesc->TableId == TableId) - { - *ReturnTableDesc = TableDesc; - return (AE_OK); - } + /* Match: this table is already installed */ - TableDesc = TableDesc->Next; + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, + "Table [%4.4s] already installed: Rev %X OemTableId [%8.8s]\n", + NewTableDesc->Pointer->Signature, + NewTableDesc->Pointer->Revision, + NewTableDesc->Pointer->OemTableId)); + + NewTableDesc->OwnerId = TableDesc->OwnerId; + NewTableDesc->InstalledDesc = TableDesc; + + return_ACPI_STATUS (AE_ALREADY_EXISTS); } + + /* Get next table on the list */ + + TableDesc = TableDesc->Next; } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "TableId=%X does not exist\n", TableId)); - return (AE_BAD_PARAMETER); + return_ACPI_STATUS (AE_OK); } @@ -205,6 +238,7 @@ AcpiTbValidateTableHeader ( { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Cannot read table header at %p\n", TableHeader)); + return (AE_BAD_ADDRESS); } @@ -219,6 +253,7 @@ AcpiTbValidateTableHeader ( ACPI_REPORT_WARNING (("Invalid table signature found: [%4.4s]\n", (char *) &Signature)); + ACPI_DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER)); return (AE_BAD_SIGNATURE); } @@ -233,6 +268,7 @@ AcpiTbValidateTableHeader ( ACPI_REPORT_WARNING (("Invalid table header length (0x%X) found\n", (UINT32) TableHeader->Length)); + ACPI_DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER)); return (AE_BAD_HEADER); } @@ -267,14 +303,16 @@ AcpiTbVerifyTableChecksum ( /* Compute the checksum on the table */ - Checksum = AcpiTbChecksum (TableHeader, TableHeader->Length); + Checksum = AcpiTbGenerateChecksum (TableHeader, TableHeader->Length); /* Return the appropriate exception */ if (Checksum) { - ACPI_REPORT_WARNING (("Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", - TableHeader->Signature, (UINT32) TableHeader->Checksum, (UINT32) Checksum)); + ACPI_REPORT_WARNING (( + "Invalid checksum in table [%4.4s] (%02X, sum %02X is not zero)\n", + TableHeader->Signature, (UINT32) TableHeader->Checksum, + (UINT32) Checksum)); Status = AE_BAD_CHECKSUM; } @@ -284,19 +322,19 @@ AcpiTbVerifyTableChecksum ( /******************************************************************************* * - * FUNCTION: AcpiTbChecksum + * FUNCTION: AcpiTbGenerateChecksum * * PARAMETERS: Buffer - Buffer to checksum * Length - Size of the buffer * - * RETURNS 8 bit checksum of buffer + * RETURN: 8 bit checksum of buffer * * DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it. * ******************************************************************************/ UINT8 -AcpiTbChecksum ( +AcpiTbGenerateChecksum ( void *Buffer, UINT32 Length) { @@ -320,3 +358,50 @@ AcpiTbChecksum ( } +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiTbHandleToObject + * + * PARAMETERS: TableId - Id for which the function is searching + * TableDesc - Pointer to return the matching table + * descriptor. + * + * RETURN: Search the tables to find one with a matching TableId and + * return a pointer to that table descriptor. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbHandleToObject ( + UINT16 TableId, + ACPI_TABLE_DESC **ReturnTableDesc) +{ + UINT32 i; + ACPI_TABLE_DESC *TableDesc; + + + ACPI_FUNCTION_NAME ("TbHandleToObject"); + + + for (i = 0; i < ACPI_TABLE_MAX; i++) + { + TableDesc = AcpiGbl_TableLists[i].Next; + while (TableDesc) + { + if (TableDesc->TableId == TableId) + { + *ReturnTableDesc = TableDesc; + return (AE_OK); + } + + TableDesc = TableDesc->Next; + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "TableId=%X does not exist\n", TableId)); + return (AE_BAD_PARAMETER); +} +#endif + + diff --git a/sys/contrib/dev/acpica/tbxface.c b/sys/contrib/dev/acpica/tbxface.c index 025eada..b4bb3fe 100644 --- a/sys/contrib/dev/acpica/tbxface.c +++ b/sys/contrib/dev/acpica/tbxface.c @@ -2,7 +2,7 @@ * * Module Name: tbxface - Public interfaces to the ACPI subsystem * ACPI table oriented interfaces - * $Revision: 64 $ + * $Revision: 1.70 $ * *****************************************************************************/ @@ -10,7 +10,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -140,7 +140,8 @@ ******************************************************************************/ ACPI_STATUS -AcpiLoadTables (void) +AcpiLoadTables ( + void) { ACPI_POINTER RsdpAddress; ACPI_STATUS Status; @@ -156,7 +157,7 @@ AcpiLoadTables (void) if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("AcpiLoadTables: Could not get RSDP, %s\n", - AcpiFormatException (Status))); + AcpiFormatException (Status))); goto ErrorExit; } @@ -168,7 +169,7 @@ AcpiLoadTables (void) if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("AcpiLoadTables: RSDP Failed validation: %s\n", - AcpiFormatException (Status))); + AcpiFormatException (Status))); goto ErrorExit; } @@ -178,7 +179,7 @@ AcpiLoadTables (void) if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("AcpiLoadTables: Could not load RSDT: %s\n", - AcpiFormatException (Status))); + AcpiFormatException (Status))); goto ErrorExit; } @@ -187,21 +188,21 @@ AcpiLoadTables (void) Status = AcpiTbGetRequiredTables (); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("AcpiLoadTables: Error getting required tables (DSDT/FADT/FACS): %s\n", - AcpiFormatException (Status))); + ACPI_REPORT_ERROR (( + "AcpiLoadTables: Error getting required tables (DSDT/FADT/FACS): %s\n", + AcpiFormatException (Status))); goto ErrorExit; } ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); - /* Load the namespace from the tables */ Status = AcpiNsLoadNamespace (); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("AcpiLoadTables: Could not load namespace: %s\n", - AcpiFormatException (Status))); + AcpiFormatException (Status))); goto ErrorExit; } @@ -260,11 +261,26 @@ AcpiLoadTable ( return_ACPI_STATUS (Status); } + /* Check signature for a valid table type */ + + Status = AcpiTbRecognizeTable (&TableInfo, ACPI_TABLE_ALL); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + /* Install the new table into the local data structures */ Status = AcpiTbInstallTable (&TableInfo); if (ACPI_FAILURE (Status)) { + if (Status == AE_ALREADY_EXISTS) + { + /* Table already exists, no error */ + + Status = AE_OK; + } + /* Free table allocated by AcpiTbGetTableBody */ AcpiTbDeleteSingleTable (&TableInfo); @@ -332,7 +348,6 @@ AcpiUnloadTable ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Find all tables of the requested type */ TableDesc = AcpiGbl_TableLists[TableType].Next; @@ -344,8 +359,8 @@ AcpiUnloadTable ( * "Scope" operator. Thus, we need to track ownership by an ID, not * simply a position within the hierarchy */ - AcpiNsDeleteNamespaceByOwner (TableDesc->TableId); - + AcpiNsDeleteNamespaceByOwner (TableDesc->OwnerId); + AcpiUtReleaseOwnerId (&TableDesc->OwnerId); TableDesc = TableDesc->Next; } @@ -406,7 +421,6 @@ AcpiGetTableHeader ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Get a pointer to the entire table */ Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr); @@ -415,19 +429,17 @@ AcpiGetTableHeader ( return_ACPI_STATUS (Status); } - /* - * The function will return a NULL pointer if the table is not loaded - */ + /* The function will return a NULL pointer if the table is not loaded */ + if (TblPtr == NULL) { return_ACPI_STATUS (AE_NOT_EXIST); } - /* - * Copy the header to the caller's buffer - */ + /* Copy the header to the caller's buffer */ + ACPI_MEMCPY ((void *) OutTableHeader, (void *) TblPtr, - sizeof (ACPI_TABLE_HEADER)); + sizeof (ACPI_TABLE_HEADER)); return_ACPI_STATUS (Status); } @@ -492,7 +504,6 @@ AcpiGetTable ( return_ACPI_STATUS (AE_BAD_PARAMETER); } - /* Get a pointer to the entire table */ Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr); @@ -514,9 +525,8 @@ AcpiGetTable ( if (TableType == ACPI_TABLE_RSDP) { - /* - * RSD PTR is the only "table" without a header - */ + /* RSD PTR is the only "table" without a header */ + TableLength = sizeof (RSDP_DESCRIPTOR); } else diff --git a/sys/contrib/dev/acpica/tbxfroot.c b/sys/contrib/dev/acpica/tbxfroot.c index 8c89af2..af51d3b 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: 79 $ + * $Revision: 1.91 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,6 +123,66 @@ #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbxfroot") +/* Local prototypes */ + +static ACPI_STATUS +AcpiTbFindRsdp ( + ACPI_TABLE_DESC *TableInfo, + UINT32 Flags); + +static UINT8 * +AcpiTbScanMemoryForRsdp ( + UINT8 *StartAddress, + UINT32 Length); + + +/******************************************************************************* + * + * FUNCTION: AcpiTbValidateRsdp + * + * PARAMETERS: Rsdp - Pointer to unvalidated RSDP + * + * RETURN: Status + * + * DESCRIPTION: Validate the RSDP (ptr) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbValidateRsdp ( + RSDP_DESCRIPTOR *Rsdp) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * The signature and checksum must both be correct + */ + if (ACPI_STRNCMP ((char *) Rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) + { + /* Nope, BAD Signature */ + + return (AE_BAD_SIGNATURE); + } + + /* Check the standard checksum */ + + if (AcpiTbGenerateChecksum (Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) + { + return (AE_BAD_CHECKSUM); + } + + /* Check extended checksum if table version >= 2 */ + + if ((Rsdp->Revision >= 2) && + (AcpiTbGenerateChecksum (Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) + { + return (AE_BAD_CHECKSUM); + } + + return (AE_OK); +} + /******************************************************************************* * @@ -130,7 +190,8 @@ * * PARAMETERS: Signature - String with ACPI table signature * OemId - String with the table OEM ID - * OemTableId - String with the OEM Table ID. + * OemTableId - String with the OEM Table ID + * TablePtr - Where the table pointer is returned * * RETURN: Status * @@ -175,7 +236,6 @@ AcpiTbFindTable ( { return_ACPI_STATUS (AE_NO_ACPI_TABLES); } - Table = AcpiGbl_DSDT; } else @@ -183,7 +243,7 @@ AcpiTbFindTable ( /* Find the table */ Status = AcpiGetFirmwareTable (Signature, 1, - ACPI_LOGICAL_ADDRESSING, &Table); + ACPI_LOGICAL_ADDRESSING, &Table); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -192,13 +252,20 @@ AcpiTbFindTable ( /* Check OemId and OemTableId */ - if ((OemId[0] && ACPI_STRCMP (OemId, Table->OemId)) || - (OemTableId[0] && ACPI_STRCMP (OemTableId, Table->OemTableId))) + if ((OemId[0] && ACPI_STRNCMP ( + OemId, Table->OemId, + sizeof (Table->OemId))) || + + (OemTableId[0] && ACPI_STRNCMP ( + OemTableId, Table->OemTableId, + sizeof (Table->OemTableId)))) { return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND); } - ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", Table->Signature)); + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", + Table->Signature)); + *TablePtr = Table; return_ACPI_STATUS (AE_OK); } @@ -272,8 +339,8 @@ AcpiGetFirmwareTable ( if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { - Status = AcpiOsMapMemory (Address.Pointer.Physical, sizeof (RSDP_DESCRIPTOR), - (void *) &AcpiGbl_RSDP); + Status = AcpiOsMapMemory (Address.Pointer.Physical, + sizeof (RSDP_DESCRIPTOR), (void *) &AcpiGbl_RSDP); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); @@ -284,20 +351,12 @@ AcpiGetFirmwareTable ( AcpiGbl_RSDP = Address.Pointer.Logical; } - /* The signature and checksum must both be correct */ - - if (ACPI_STRNCMP ((char *) AcpiGbl_RSDP, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) - { - /* Nope, BAD Signature */ - - return_ACPI_STATUS (AE_BAD_SIGNATURE); - } + /* The RDSP signature and checksum must both be correct */ - if (AcpiTbChecksum (AcpiGbl_RSDP, ACPI_RSDP_CHECKSUM_LENGTH) != 0) + Status = AcpiTbValidateRsdp (AcpiGbl_RSDP); + if (ACPI_FAILURE (Status)) { - /* Nope, BAD Checksum */ - - return_ACPI_STATUS (AE_BAD_CHECKSUM); + return_ACPI_STATUS (Status); } } @@ -305,7 +364,7 @@ AcpiGetFirmwareTable ( AcpiTbGetRsdtAddress (&Address); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", + "RSDP located at %p, RSDT physical=%8.8X%8.8X\n", AcpiGbl_RSDP, ACPI_FORMAT_UINT64 (Address.Pointer.Value))); @@ -360,9 +419,11 @@ AcpiGetFirmwareTable ( */ for (i = 0, j = 0; i < TableCount; i++) { - /* Get the next table pointer, handle RSDT vs. XSDT */ - - if (AcpiGbl_RSDP->Revision < 2) + /* + * Get the next table pointer, handle RSDT vs. XSDT + * RSDT pointers are 32 bits, XSDT pointers are 64 bits + */ + if (AcpiGbl_RootTableType == ACPI_TABLE_TYPE_RSDT) { Address.Pointer.Value = (ACPI_CAST_PTR ( RSDT_DESCRIPTOR, RsdtInfo->Pointer))->TableOffsetEntry[i]; @@ -410,7 +471,11 @@ AcpiGetFirmwareTable ( Cleanup: - AcpiOsUnmapMemory (RsdtInfo->Pointer, (ACPI_SIZE) RsdtInfo->Pointer->Length); + if (RsdtInfo->Pointer) + { + AcpiOsUnmapMemory (RsdtInfo->Pointer, + (ACPI_SIZE) RsdtInfo->Pointer->Length); + } ACPI_MEM_FREE (RsdtInfo); if (Header) @@ -433,8 +498,8 @@ Cleanup: * * FUNCTION: AcpiFindRootPointer * - * PARAMETERS: **RsdpAddress - Where to place the RSDP address - * Flags - Logical/Physical addressing + * PARAMETERS: Flags - Logical/Physical addressing + * RsdpAddress - Where to place the RSDP address * * RETURN: Status, Physical address of the RSDP * @@ -459,8 +524,10 @@ AcpiFindRootPointer ( Status = AcpiTbFindRsdp (&TableInfo, Flags); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "RSDP structure not found, %s Flags=%X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "RSDP structure not found, %s Flags=%X\n", AcpiFormatException (Status), Flags)); + return_ACPI_STATUS (AE_NO_ACPI_TABLES); } @@ -483,14 +550,14 @@ AcpiFindRootPointer ( * ******************************************************************************/ -UINT8 * +static UINT8 * AcpiTbScanMemoryForRsdp ( UINT8 *StartAddress, UINT32 Length) { + ACPI_STATUS Status; UINT8 *MemRover; UINT8 *EndAddress; - UINT8 Checksum; ACPI_FUNCTION_TRACE ("TbScanMemoryForRsdp"); @@ -503,48 +570,26 @@ AcpiTbScanMemoryForRsdp ( for (MemRover = StartAddress; MemRover < EndAddress; MemRover += ACPI_RSDP_SCAN_STEP) { - /* The signature and checksum must both be correct */ + /* The RSDP signature and checksum must both be correct */ - if (ACPI_STRNCMP ((char *) MemRover, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) + Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (RSDP_DESCRIPTOR, MemRover)); + if (ACPI_SUCCESS (Status)) { - /* 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 */ + /* Sig and checksum valid, we have found a real RSDP */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "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)); + /* No sig match or bad checksum, keep searching */ } /* Searched entire block, no RSDP was found */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "Searched entire block, no valid RSDP was found.\n")); + "Searched entire block from %p, valid RSDP was not found\n", + StartAddress)); return_PTR (NULL); } @@ -553,7 +598,7 @@ AcpiTbScanMemoryForRsdp ( * * FUNCTION: AcpiTbFindRsdp * - * PARAMETERS: *TableInfo - Where the table info is returned + * PARAMETERS: TableInfo - Where the table info is returned * Flags - Current memory mode (logical vs. * physical addressing) * @@ -571,7 +616,7 @@ AcpiTbScanMemoryForRsdp ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiTbFindRsdp ( ACPI_TABLE_DESC *TableInfo, UINT32 Flags) @@ -586,25 +631,29 @@ AcpiTbFindRsdp ( /* - * Scan supports either 1) Logical addressing or 2) Physical addressing + * Scan supports either logical addressing or physical addressing */ if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { - /* - * 1a) Get the location of the EBDA - */ - Status = AcpiOsMapMemory ((ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION, - ACPI_EBDA_PTR_LENGTH, - (void *) &TablePtr); + /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ + + Status = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION, + ACPI_EBDA_PTR_LENGTH, (void *) &TablePtr); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X for length %X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not map memory at %8.8X for length %X\n", ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); + return_ACPI_STATUS (Status); } ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr); - PhysicalAddress <<= 4; /* Convert segment to physical address */ + + /* Convert segment part to physical address */ + + PhysicalAddress <<= 4; AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH); /* EBDA present? */ @@ -612,28 +661,33 @@ AcpiTbFindRsdp ( if (PhysicalAddress > 0x400) { /* - * 1b) Search EBDA paragraphs (EBDA is required to be a minimum of 1K length) + * 1b) Search EBDA paragraphs (EBDA is required to be a + * minimum of 1K length) */ - Status = AcpiOsMapMemory ((ACPI_PHYSICAL_ADDRESS) PhysicalAddress, - ACPI_EBDA_WINDOW_SIZE, - (void *) &TablePtr); + Status = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) PhysicalAddress, + ACPI_EBDA_WINDOW_SIZE, (void *) &TablePtr); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X for length %X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not map memory at %8.8X for length %X\n", PhysicalAddress, ACPI_EBDA_WINDOW_SIZE)); + return_ACPI_STATUS (Status); } - MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE); + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, + ACPI_EBDA_WINDOW_SIZE); AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE); if (MemRover) { - /* Found it, return the physical address */ + /* Return the physical address */ PhysicalAddress += ACPI_PTR_DIFF (MemRover, TablePtr); - TableInfo->PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) PhysicalAddress; + TableInfo->PhysicalAddress = + (ACPI_PHYSICAL_ADDRESS) PhysicalAddress; return_ACPI_STATUS (AE_OK); } } @@ -641,13 +695,16 @@ AcpiTbFindRsdp ( /* * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */ - Status = AcpiOsMapMemory ((ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE, - ACPI_HI_RSDP_WINDOW_SIZE, - (void *) &TablePtr); + Status = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE, + ACPI_HI_RSDP_WINDOW_SIZE, (void *) &TablePtr); + if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X for length %X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Could not map memory at %8.8X for length %X\n", ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); + return_ACPI_STATUS (Status); } @@ -656,11 +713,13 @@ AcpiTbFindRsdp ( if (MemRover) { - /* Found it, return the physical address */ + /* Return the physical address */ - PhysicalAddress = ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr); + PhysicalAddress = + ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr); - TableInfo->PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) PhysicalAddress; + TableInfo->PhysicalAddress = + (ACPI_PHYSICAL_ADDRESS) PhysicalAddress; return_ACPI_STATUS (AE_OK); } } @@ -670,9 +729,8 @@ AcpiTbFindRsdp ( */ else { - /* - * 1a) Get the location of the EBDA - */ + /* 1a) Get the location of the EBDA */ + ACPI_MOVE_16_TO_32 (&PhysicalAddress, ACPI_EBDA_PTR_LOCATION); PhysicalAddress <<= 4; /* Convert segment to physical address */ @@ -681,23 +739,25 @@ AcpiTbFindRsdp ( if (PhysicalAddress > 0x400) { /* - * 1b) Search EBDA paragraphs (EBDA is required to be a minimum of 1K length) + * 1b) Search EBDA paragraphs (EBDA is required to be a minimum of + * 1K length) */ - MemRover = AcpiTbScanMemoryForRsdp (ACPI_PHYSADDR_TO_PTR (PhysicalAddress), + MemRover = AcpiTbScanMemoryForRsdp ( + ACPI_PHYSADDR_TO_PTR (PhysicalAddress), ACPI_EBDA_WINDOW_SIZE); if (MemRover) { - /* Found it, return the physical address */ + /* Return the physical address */ TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover); return_ACPI_STATUS (AE_OK); } } - /* - * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh - */ - MemRover = AcpiTbScanMemoryForRsdp (ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE), + /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */ + + MemRover = AcpiTbScanMemoryForRsdp ( + ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE), ACPI_HI_RSDP_WINDOW_SIZE); if (MemRover) { @@ -708,8 +768,9 @@ AcpiTbFindRsdp ( } } - /* RSDP signature was not found */ + /* A valid RSDP was not found */ + ACPI_REPORT_ERROR (("No valid RSDP was found\n")); return_ACPI_STATUS (AE_NOT_FOUND); } diff --git a/sys/contrib/dev/acpica/utalloc.c b/sys/contrib/dev/acpica/utalloc.c index 4592236..4f6e15f 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: 138 $ + * Module Name: utalloc - local memory allocation routines + * $Revision: 1.149 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -121,179 +121,139 @@ #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utalloc") +/* Local prototypes */ -/****************************************************************************** - * - * FUNCTION: AcpiUtReleaseToCache - * - * PARAMETERS: ListId - Memory list/cache ID - * Object - The object to be released - * - * RETURN: None - * - * DESCRIPTION: Release an object to the specified cache. If cache is full, - * the object is deleted. - * - ******************************************************************************/ - -void -AcpiUtReleaseToCache ( - UINT32 ListId, - void *Object) -{ - ACPI_MEMORY_LIST *CacheInfo; - - - ACPI_FUNCTION_ENTRY (); - - - /* If walk cache is full, just free this wallkstate object */ - - CacheInfo = &AcpiGbl_MemoryLists[ListId]; - if (CacheInfo->CacheDepth >= CacheInfo->MaxCacheDepth) - { - ACPI_MEM_FREE (Object); - ACPI_MEM_TRACKING (CacheInfo->TotalFreed++); - } - - /* Otherwise put this object back into the cache */ - - else - { - if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES))) - { - return; - } - - /* Mark the object as cached */ - - ACPI_MEMSET (Object, 0xCA, CacheInfo->ObjectSize); - ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED); +static ACPI_DEBUG_MEM_BLOCK * +AcpiUtFindAllocation ( + void *Allocation); - /* Put the object at the head of the cache list */ +static ACPI_STATUS +AcpiUtTrackAllocation ( + ACPI_DEBUG_MEM_BLOCK *Address, + ACPI_SIZE Size, + UINT8 AllocType, + UINT32 Component, + char *Module, + UINT32 Line); - * (ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset]))) = CacheInfo->ListHead; - CacheInfo->ListHead = Object; - CacheInfo->CacheDepth++; +static ACPI_STATUS +AcpiUtRemoveAllocation ( + ACPI_DEBUG_MEM_BLOCK *Address, + UINT32 Component, + char *Module, + UINT32 Line); - (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); - } -} +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +static ACPI_STATUS +AcpiUtCreateList ( + char *ListName, + UINT16 ObjectSize, + ACPI_MEMORY_LIST **ReturnCache); +#endif -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiUtAcquireFromCache + * FUNCTION: AcpiUtCreateCaches * - * PARAMETERS: ListId - Memory list ID + * PARAMETERS: None * - * RETURN: A requested object. NULL if the object could not be - * allocated. + * RETURN: Status * - * DESCRIPTION: Get an object from the specified cache. If cache is empty, - * the object is allocated. + * DESCRIPTION: Create all local caches * ******************************************************************************/ -void * -AcpiUtAcquireFromCache ( - UINT32 ListId) +ACPI_STATUS +AcpiUtCreateCaches ( + void) { - ACPI_MEMORY_LIST *CacheInfo; - void *Object; + ACPI_STATUS Status; - ACPI_FUNCTION_NAME ("UtAcquireFromCache"); +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + /* Memory allocation lists */ - CacheInfo = &AcpiGbl_MemoryLists[ListId]; - if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES))) + Status = AcpiUtCreateList ("Acpi-Global", 0, + &AcpiGbl_GlobalList); + if (ACPI_FAILURE (Status)) { - return (NULL); + return (Status); } - ACPI_MEM_TRACKING (CacheInfo->CacheRequests++); - - /* Check the cache first */ - - if (CacheInfo->ListHead) + Status = AcpiUtCreateList ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE), + &AcpiGbl_NsNodeList); + if (ACPI_FAILURE (Status)) { - /* There is an object available, use it */ - - Object = CacheInfo->ListHead; - CacheInfo->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset]))); - - ACPI_MEM_TRACKING (CacheInfo->CacheHits++); - CacheInfo->CacheDepth--; - -#ifdef ACPI_DBG_TRACK_ALLOCATIONS - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p from %s\n", - Object, AcpiGbl_MemoryLists[ListId].ListName)); + return (Status); + } #endif - if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES))) - { - return (NULL); - } + /* Object Caches, for frequently used objects */ - /* Clear (zero) the previously used Object */ - - ACPI_MEMSET (Object, 0, CacheInfo->ObjectSize); + Status = AcpiOsCreateCache ("Acpi-State", sizeof (ACPI_GENERIC_STATE), + ACPI_MAX_STATE_CACHE_DEPTH, &AcpiGbl_StateCache); + if (ACPI_FAILURE (Status)) + { + return (Status); } - else + Status = AcpiOsCreateCache ("Acpi-Parse", sizeof (ACPI_PARSE_OBJ_COMMON), + ACPI_MAX_PARSE_CACHE_DEPTH, &AcpiGbl_PsNodeCache); + if (ACPI_FAILURE (Status)) { - /* The cache is empty, create a new object */ - - /* Avoid deadlock with ACPI_MEM_CALLOCATE */ + return (Status); + } - if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES))) - { - return (NULL); - } + Status = AcpiOsCreateCache ("Acpi-ParseExt", sizeof (ACPI_PARSE_OBJ_NAMED), + ACPI_MAX_EXTPARSE_CACHE_DEPTH, &AcpiGbl_PsNodeExtCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } - Object = ACPI_MEM_CALLOCATE (CacheInfo->ObjectSize); - ACPI_MEM_TRACKING (CacheInfo->TotalAllocated++); + Status = AcpiOsCreateCache ("Acpi-Operand", sizeof (ACPI_OPERAND_OBJECT), + ACPI_MAX_OBJECT_CACHE_DEPTH, &AcpiGbl_OperandCache); + if (ACPI_FAILURE (Status)) + { + return (Status); } - return (Object); + return (AE_OK); } -/****************************************************************************** +/******************************************************************************* * - * FUNCTION: AcpiUtDeleteGenericCache + * FUNCTION: AcpiUtDeleteCaches * - * PARAMETERS: ListId - Memory list ID + * PARAMETERS: None * - * RETURN: None + * RETURN: Status * - * DESCRIPTION: Free all objects within the requested cache. + * DESCRIPTION: Purge and delete all local caches * ******************************************************************************/ -void -AcpiUtDeleteGenericCache ( - UINT32 ListId) +ACPI_STATUS +AcpiUtDeleteCaches ( + void) { - ACPI_MEMORY_LIST *CacheInfo; - char *Next; - - ACPI_FUNCTION_ENTRY (); + (void) AcpiOsDeleteCache (AcpiGbl_StateCache); + AcpiGbl_StateCache = NULL; + (void) AcpiOsDeleteCache (AcpiGbl_OperandCache); + AcpiGbl_OperandCache = NULL; - CacheInfo = &AcpiGbl_MemoryLists[ListId]; - while (CacheInfo->ListHead) - { - /* Delete one cached state object */ + (void) AcpiOsDeleteCache (AcpiGbl_PsNodeCache); + AcpiGbl_PsNodeCache = NULL; - Next = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) CacheInfo->ListHead)[CacheInfo->LinkOffset]))); - ACPI_MEM_FREE (CacheInfo->ListHead); + (void) AcpiOsDeleteCache (AcpiGbl_PsNodeExtCache); + AcpiGbl_PsNodeExtCache = NULL; - CacheInfo->ListHead = Next; - CacheInfo->CacheDepth--; - } + return (AE_OK); } @@ -455,7 +415,7 @@ AcpiUtAllocate ( if (!Size) { _ACPI_REPORT_ERROR (Module, Line, Component, - ("UtAllocate: Attempt to allocate zero bytes\n")); + ("UtAllocate: Attempt to allocate zero bytes, allocating 1 byte\n")); Size = 1; } @@ -507,8 +467,8 @@ AcpiUtCallocate ( if (!Size) { _ACPI_REPORT_ERROR (Module, Line, Component, - ("UtCallocate: Attempt to allocate zero bytes\n")); - return_PTR (NULL); + ("UtCallocate: Attempt to allocate zero bytes, allocating 1 byte\n")); + Size = 1; } Allocation = AcpiOsAllocate (Size); @@ -540,6 +500,44 @@ AcpiUtCallocate ( * occurs in the body of AcpiUtFree. */ +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateList + * + * PARAMETERS: CacheName - Ascii name for the cache + * ObjectSize - Size of each cached object + * ReturnCache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a local memory list for tracking purposed + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCreateList ( + char *ListName, + UINT16 ObjectSize, + ACPI_MEMORY_LIST **ReturnCache) +{ + ACPI_MEMORY_LIST *Cache; + + + Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST)); + if (!Cache) + { + return (AE_NO_MEMORY); + } + + ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); + + Cache->ListName = ListName; + Cache->ObjectSize = ObjectSize; + + *ReturnCache = Cache; + return (AE_OK); +} + /******************************************************************************* * @@ -567,14 +565,14 @@ AcpiUtAllocateAndTrack ( ACPI_STATUS Status; - Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), Component, - Module, Line); + Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), + Component, Module, Line); if (!Allocation) { return (NULL); } - Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size, + Status = AcpiUtTrackAllocation (Allocation, Size, ACPI_MEM_MALLOC, Component, Module, Line); if (ACPI_FAILURE (Status)) { @@ -582,8 +580,8 @@ AcpiUtAllocateAndTrack ( return (NULL); } - AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++; - AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += (UINT32) Size; + AcpiGbl_GlobalList->TotalAllocated++; + AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; return ((void *) &Allocation->UserSpace); } @@ -615,8 +613,8 @@ AcpiUtCallocateAndTrack ( ACPI_STATUS Status; - Allocation = AcpiUtCallocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), Component, - Module, Line); + Allocation = AcpiUtCallocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), + Component, Module, Line); if (!Allocation) { /* Report allocation error */ @@ -626,7 +624,7 @@ AcpiUtCallocateAndTrack ( return (NULL); } - Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size, + Status = AcpiUtTrackAllocation (Allocation, Size, ACPI_MEM_CALLOC, Component, Module, Line); if (ACPI_FAILURE (Status)) { @@ -634,8 +632,8 @@ AcpiUtCallocateAndTrack ( return (NULL); } - AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++; - AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += (UINT32) Size; + AcpiGbl_GlobalList->TotalAllocated++; + AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; return ((void *) &Allocation->UserSpace); } @@ -681,10 +679,10 @@ AcpiUtFreeAndTrack ( DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK, (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER))); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalFreed++; - AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize -= DebugBlock->Size; + AcpiGbl_GlobalList->TotalFreed++; + AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size; - Status = AcpiUtRemoveAllocation (ACPI_MEM_LIST_GLOBAL, DebugBlock, + Status = AcpiUtRemoveAllocation (DebugBlock, Component, Module, Line); if (ACPI_FAILURE (Status)) { @@ -704,8 +702,7 @@ AcpiUtFreeAndTrack ( * * FUNCTION: AcpiUtFindAllocation * - * PARAMETERS: ListId - Memory list to search - * Allocation - Address of allocated memory + * PARAMETERS: Allocation - Address of allocated memory * * RETURN: A list element if found; NULL otherwise. * @@ -713,9 +710,8 @@ AcpiUtFreeAndTrack ( * ******************************************************************************/ -ACPI_DEBUG_MEM_BLOCK * +static ACPI_DEBUG_MEM_BLOCK * AcpiUtFindAllocation ( - UINT32 ListId, void *Allocation) { ACPI_DEBUG_MEM_BLOCK *Element; @@ -724,12 +720,7 @@ AcpiUtFindAllocation ( ACPI_FUNCTION_ENTRY (); - if (ListId > ACPI_MEM_LIST_MAX) - { - return (NULL); - } - - Element = AcpiGbl_MemoryLists[ListId].ListHead; + Element = AcpiGbl_GlobalList->ListHead; /* Search for the address. */ @@ -751,8 +742,7 @@ AcpiUtFindAllocation ( * * FUNCTION: AcpiUtTrackAllocation * - * PARAMETERS: ListId - Memory list to search - * Allocation - Address of allocated memory + * PARAMETERS: Allocation - Address of allocated memory * Size - Size of the allocation * AllocType - MEM_MALLOC or MEM_CALLOC * Component - Component type of caller @@ -765,9 +755,8 @@ AcpiUtFindAllocation ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtTrackAllocation ( - UINT32 ListId, ACPI_DEBUG_MEM_BLOCK *Allocation, ACPI_SIZE Size, UINT8 AllocType, @@ -783,12 +772,7 @@ AcpiUtTrackAllocation ( ACPI_FUNCTION_TRACE_PTR ("UtTrackAllocation", Allocation); - if (ListId > ACPI_MEM_LIST_MAX) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - MemList = &AcpiGbl_MemoryLists[ListId]; + MemList = AcpiGbl_GlobalList; Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); if (ACPI_FAILURE (Status)) { @@ -799,14 +783,15 @@ AcpiUtTrackAllocation ( * Search list for this address to make sure it is not already on the list. * This will catch several kinds of problems. */ - - Element = AcpiUtFindAllocation (ListId, Allocation); + Element = AcpiUtFindAllocation (Allocation); if (Element) { - ACPI_REPORT_ERROR (("UtTrackAllocation: Allocation already present in list! (%p)\n", + ACPI_REPORT_ERROR (( + "UtTrackAllocation: Allocation already present in list! (%p)\n", Allocation)); - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", Element, Allocation)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", + Element, Allocation)); goto UnlockAndExit; } @@ -844,8 +829,7 @@ UnlockAndExit: * * FUNCTION: AcpiUtRemoveAllocation * - * PARAMETERS: ListId - Memory list to search - * Allocation - Address of allocated memory + * PARAMETERS: Allocation - Address of allocated memory * Component - Component type of caller * Module - Source file name of caller * Line - Line number of caller @@ -856,9 +840,8 @@ UnlockAndExit: * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtRemoveAllocation ( - UINT32 ListId, ACPI_DEBUG_MEM_BLOCK *Allocation, UINT32 Component, char *Module, @@ -871,18 +854,13 @@ AcpiUtRemoveAllocation ( ACPI_FUNCTION_TRACE ("UtRemoveAllocation"); - if (ListId > ACPI_MEM_LIST_MAX) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - MemList = &AcpiGbl_MemoryLists[ListId]; + MemList = AcpiGbl_GlobalList; if (NULL == MemList->ListHead) { /* No allocations! */ _ACPI_REPORT_ERROR (Module, Line, Component, - ("UtRemoveAllocation: Empty allocation list, nothing to free!\n")); + ("UtRemoveAllocation: Empty allocation list, nothing to free!\n")); return_ACPI_STATUS (AE_OK); } @@ -913,7 +891,8 @@ AcpiUtRemoveAllocation ( ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size); - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", Allocation->Size)); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", + Allocation->Size)); Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); return_ACPI_STATUS (Status); @@ -973,7 +952,8 @@ AcpiUtDumpAllocationInfo ( ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, ("%30s: %4d (%3d Kb)\n", "Max Nodes", AcpiGbl_MaxConcurrentNodeCount, - ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * sizeof (ACPI_NAMESPACE_NODE))))); + ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * + sizeof (ACPI_NAMESPACE_NODE))))); */ return_VOID; } @@ -1013,7 +993,7 @@ AcpiUtDumpAllocations ( return; } - Element = AcpiGbl_MemoryLists[0].ListHead; + Element = AcpiGbl_GlobalList->ListHead; while (Element) { if ((Element->Component & Component) && @@ -1025,8 +1005,8 @@ AcpiUtDumpAllocations ( if (Descriptor->DescriptorId != ACPI_DESC_TYPE_CACHED) { AcpiOsPrintf ("%p Len %04X %9.9s-%d [%s] ", - Descriptor, Element->Size, Element->Module, - Element->Line, AcpiUtGetDescriptorName (Descriptor)); + Descriptor, Element->Size, Element->Module, + Element->Line, AcpiUtGetDescriptorName (Descriptor)); /* Most of the elements will be Operand objects. */ @@ -1034,18 +1014,18 @@ AcpiUtDumpAllocations ( { case ACPI_DESC_TYPE_OPERAND: AcpiOsPrintf ("%12.12s R%hd", - AcpiUtGetTypeName (Descriptor->Object.Common.Type), - Descriptor->Object.Common.ReferenceCount); + AcpiUtGetTypeName (Descriptor->Object.Common.Type), + Descriptor->Object.Common.ReferenceCount); break; case ACPI_DESC_TYPE_PARSER: AcpiOsPrintf ("AmlOpcode %04hX", - Descriptor->Op.Asl.AmlOpcode); + Descriptor->Op.Asl.AmlOpcode); break; case ACPI_DESC_TYPE_NAMED: AcpiOsPrintf ("%4.4s", - AcpiUtGetNodeName (&Descriptor->Node)); + AcpiUtGetNodeName (&Descriptor->Node)); break; default: @@ -1066,7 +1046,7 @@ AcpiUtDumpAllocations ( if (!NumOutstanding) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "No outstanding allocations.\n")); + "No outstanding allocations\n")); } else { @@ -1078,6 +1058,5 @@ AcpiUtDumpAllocations ( return_VOID; } - #endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */ diff --git a/sys/contrib/dev/acpica/utcache.c b/sys/contrib/dev/acpica/utcache.c new file mode 100644 index 0000000..8e568a5 --- /dev/null +++ b/sys/contrib/dev/acpica/utcache.c @@ -0,0 +1,418 @@ +/****************************************************************************** + * + * Module Name: utcache - local cache allocation routines + * $Revision: 1.2 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#define __UTCACHE_C__ + +#include <contrib/dev/acpica/acpi.h> + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utcache") + + +#ifdef ACPI_USE_LOCAL_CACHE +/******************************************************************************* + * + * FUNCTION: AcpiOsCreateCache + * + * PARAMETERS: CacheName - Ascii name for the cache + * ObjectSize - Size of each cached object + * MaxDepth - Maximum depth of the cache (in objects) + * ReturnCache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a cache object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_MEMORY_LIST **ReturnCache) +{ + ACPI_MEMORY_LIST *Cache; + + + ACPI_FUNCTION_ENTRY (); + + + if (!CacheName || !ReturnCache || (ObjectSize < 16)) + { + return (AE_BAD_PARAMETER); + } + + /* Create the cache object */ + + Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST)); + if (!Cache) + { + return (AE_NO_MEMORY); + } + + /* Populate the cache object and return it */ + + ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); + Cache->LinkOffset = 8; + Cache->ListName = CacheName; + Cache->ObjectSize = ObjectSize; + Cache->MaxDepth = MaxDepth; + + *ReturnCache = Cache; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsPurgeCache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_MEMORY_LIST *Cache) +{ + char *Next; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Cache) + { + return (AE_BAD_PARAMETER); + } + + /* Walk the list of objects in this cache */ + + while (Cache->ListHead) + { + /* Delete and unlink one cached state object */ + + Next = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Cache->ListHead)[Cache->LinkOffset]))); + ACPI_MEM_FREE (Cache->ListHead); + + Cache->ListHead = Next; + Cache->CurrentDepth--; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsDeleteCache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache and delete the + * cache object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_MEMORY_LIST *Cache) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + /* Purge all objects in the cache */ + + Status = AcpiOsPurgeCache (Cache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Now we can delete the cache object */ + + AcpiOsFree (Cache); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsReleaseObject + * + * PARAMETERS: Cache - Handle to cache object + * Object - The object to be released + * + * RETURN: None + * + * DESCRIPTION: Release an object to the specified cache. If cache is full, + * the object is deleted. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_MEMORY_LIST *Cache, + void *Object) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Cache || !Object) + { + return (AE_BAD_PARAMETER); + } + + /* If cache is full, just free this object */ + + if (Cache->CurrentDepth >= Cache->MaxDepth) + { + ACPI_MEM_FREE (Object); + ACPI_MEM_TRACKING (Cache->TotalFreed++); + } + + /* Otherwise put this object back into the cache */ + + else + { + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Mark the object as cached */ + + ACPI_MEMSET (Object, 0xCA, Cache->ObjectSize); + ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED); + + /* Put the object at the head of the cache list */ + + * (ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Object)[Cache->LinkOffset]))) = Cache->ListHead; + Cache->ListHead = Object; + Cache->CurrentDepth++; + + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsAcquireObject + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: the acquired object. NULL on error + * + * DESCRIPTION: Get an object from the specified cache. If cache is empty, + * the object is allocated. + * + ******************************************************************************/ + +void * +AcpiOsAcquireObject ( + ACPI_MEMORY_LIST *Cache) +{ + ACPI_STATUS Status; + void *Object; + + + ACPI_FUNCTION_NAME ("OsAcquireObject"); + + + if (!Cache) + { + return (NULL); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (NULL); + } + + ACPI_MEM_TRACKING (Cache->Requests++); + + /* Check the cache first */ + + if (Cache->ListHead) + { + /* There is an object available, use it */ + + Object = Cache->ListHead; + Cache->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Object)[Cache->LinkOffset]))); + + Cache->CurrentDepth--; + + ACPI_MEM_TRACKING (Cache->Hits++); + ACPI_MEM_TRACKING (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Object %p from %s cache\n", Object, Cache->ListName))); + + Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (NULL); + } + + /* Clear (zero) the previously used Object */ + + ACPI_MEMSET (Object, 0, Cache->ObjectSize); + } + else + { + /* The cache is empty, create a new object */ + + ACPI_MEM_TRACKING (Cache->TotalAllocated++); + + /* Avoid deadlock with ACPI_MEM_CALLOCATE */ + + Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (NULL); + } + + Object = ACPI_MEM_CALLOCATE (Cache->ObjectSize); + if (!Object) + { + return (NULL); + } + } + + return (Object); +} +#endif /* ACPI_USE_LOCAL_CACHE */ + + diff --git a/sys/contrib/dev/acpica/utclib.c b/sys/contrib/dev/acpica/utclib.c index cf1edd9..3aba44c 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: 53 $ + * $Revision: 1.58 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -131,9 +131,113 @@ #ifndef ACPI_USE_SYSTEM_CLIBRARY +#define NEGATIVE 1 +#define POSITIVE 0 + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemcmp (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: AcpiUtMemcpy (memcpy) + * + * PARAMETERS: Dest - Target of the copy + * Src - Source buffer to copy + * Count - Number of bytes to copy + * + * RETURN: Dest + * + * DESCRIPTION: Copy arbitrary bytes of memory + * + ******************************************************************************/ + +void * +AcpiUtMemcpy ( + void *Dest, + const void *Src, + ACPI_SIZE Count) +{ + char *New = (char *) Dest; + char *Old = (char *) Src; + + + while (Count) + { + *New = *Old; + New++; + Old++; + Count--; + } + + return (Dest); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemset (memset) + * + * PARAMETERS: Dest - Buffer to set + * Value - Value to set each byte of memory + * Count - Number of bytes to set + * + * RETURN: Dest + * + * DESCRIPTION: Initialize a buffer to a known value. + * + ******************************************************************************/ + +void * +AcpiUtMemset ( + void *Dest, + ACPI_NATIVE_UINT Value, + ACPI_SIZE Count) +{ + char *New = (char *) Dest; + + + while (Count) + { + *New = (char) Value; + New++; + Count--; + } + + return (Dest); +} + + /******************************************************************************* * - * FUNCTION: strlen + * FUNCTION: AcpiUtStrlen (strlen) * * PARAMETERS: String - Null terminated string * @@ -165,7 +269,7 @@ AcpiUtStrlen ( /******************************************************************************* * - * FUNCTION: strcpy + * FUNCTION: AcpiUtStrcpy (strcpy) * * PARAMETERS: DstString - Target of the copy * SrcString - The source string to copy @@ -203,7 +307,7 @@ AcpiUtStrcpy ( /******************************************************************************* * - * FUNCTION: strncpy + * FUNCTION: AcpiUtStrncpy (strncpy) * * PARAMETERS: DstString - Target of the copy * SrcString - The source string to copy @@ -246,7 +350,7 @@ AcpiUtStrncpy ( /******************************************************************************* * - * FUNCTION: strcmp + * FUNCTION: AcpiUtStrcmp (strcmp) * * PARAMETERS: String1 - First string * String2 - Second string @@ -276,39 +380,43 @@ AcpiUtStrcmp ( } +#ifdef ACPI_FUTURE_IMPLEMENTATION +/* Not used at this time */ /******************************************************************************* * - * FUNCTION: memcmp + * FUNCTION: AcpiUtStrchr (strchr) * - * PARAMETERS: Buffer1 - First Buffer - * Buffer2 - Second Buffer - * Count - Maximum # of bytes to compare + * PARAMETERS: String - Search string + * ch - character to search for * - * RETURN: Index where Buffers mismatched, or 0 if Buffers matched + * RETURN: Ptr to char or NULL if not found * - * DESCRIPTION: Compare two Buffers, with a maximum length + * DESCRIPTION: Search a string for a character * ******************************************************************************/ -int -AcpiUtMemcmp ( - const char *Buffer1, - const char *Buffer2, - ACPI_SIZE Count) +char * +AcpiUtStrchr ( + const char *String, + int ch) { - for ( ; Count-- && (*Buffer1 == *Buffer2); Buffer1++, Buffer2++) + + for ( ; (*String); String++) { + if ((*String) == (char) ch) + { + return ((char *) String); + } } - return ((Count == ACPI_SIZE_MAX) ? 0 : ((unsigned char) *Buffer1 - - (unsigned char) *Buffer2)); + return (NULL); } - +#endif /******************************************************************************* * - * FUNCTION: strncmp + * FUNCTION: AcpiUtStrncmp (strncmp) * * PARAMETERS: String1 - First string * String2 - Second string @@ -343,7 +451,7 @@ AcpiUtStrncmp ( /******************************************************************************* * - * FUNCTION: Strcat + * FUNCTION: AcpiUtStrcat (Strcat) * * PARAMETERS: DstString - Target of the copy * SrcString - The source string to copy @@ -378,7 +486,7 @@ AcpiUtStrcat ( /******************************************************************************* * - * FUNCTION: strncat + * FUNCTION: AcpiUtStrncat (strncat) * * PARAMETERS: DstString - Target of the copy * SrcString - The source string to copy @@ -426,274 +534,12 @@ AcpiUtStrncat ( /******************************************************************************* * - * FUNCTION: memcpy - * - * PARAMETERS: Dest - Target of the copy - * Src - Source buffer to copy - * Count - Number of bytes to copy - * - * RETURN: Dest - * - * DESCRIPTION: Copy arbitrary bytes of memory - * - ******************************************************************************/ - -void * -AcpiUtMemcpy ( - void *Dest, - const void *Src, - ACPI_SIZE Count) -{ - char *New = (char *) Dest; - char *Old = (char *) Src; - - - while (Count) - { - *New = *Old; - New++; - Old++; - Count--; - } - - return (Dest); -} - - -/******************************************************************************* - * - * FUNCTION: memset - * - * PARAMETERS: Dest - Buffer to set - * Value - Value to set each byte of memory - * Count - Number of bytes to set - * - * RETURN: Dest - * - * DESCRIPTION: Initialize a buffer to a known value. - * - ******************************************************************************/ - -void * -AcpiUtMemset ( - void *Dest, - ACPI_NATIVE_UINT Value, - ACPI_SIZE Count) -{ - char *New = (char *) Dest; - - - while (Count) - { - *New = (char) Value; - New++; - Count--; - } - - return (Dest); -} - - -#define NEGATIVE 1 -#define POSITIVE 0 - -const UINT8 _acpi_ctype[257] = { - _ACPI_CN, /* 0x0 0. */ - _ACPI_CN, /* 0x1 1. */ - _ACPI_CN, /* 0x2 2. */ - _ACPI_CN, /* 0x3 3. */ - _ACPI_CN, /* 0x4 4. */ - _ACPI_CN, /* 0x5 5. */ - _ACPI_CN, /* 0x6 6. */ - _ACPI_CN, /* 0x7 7. */ - _ACPI_CN, /* 0x8 8. */ - _ACPI_CN|_ACPI_SP, /* 0x9 9. */ - _ACPI_CN|_ACPI_SP, /* 0xA 10. */ - _ACPI_CN|_ACPI_SP, /* 0xB 11. */ - _ACPI_CN|_ACPI_SP, /* 0xC 12. */ - _ACPI_CN|_ACPI_SP, /* 0xD 13. */ - _ACPI_CN, /* 0xE 14. */ - _ACPI_CN, /* 0xF 15. */ - _ACPI_CN, /* 0x10 16. */ - _ACPI_CN, /* 0x11 17. */ - _ACPI_CN, /* 0x12 18. */ - _ACPI_CN, /* 0x13 19. */ - _ACPI_CN, /* 0x14 20. */ - _ACPI_CN, /* 0x15 21. */ - _ACPI_CN, /* 0x16 22. */ - _ACPI_CN, /* 0x17 23. */ - _ACPI_CN, /* 0x18 24. */ - _ACPI_CN, /* 0x19 25. */ - _ACPI_CN, /* 0x1A 26. */ - _ACPI_CN, /* 0x1B 27. */ - _ACPI_CN, /* 0x1C 28. */ - _ACPI_CN, /* 0x1D 29. */ - _ACPI_CN, /* 0x1E 30. */ - _ACPI_CN, /* 0x1F 31. */ - _ACPI_XS|_ACPI_SP, /* 0x20 32. ' ' */ - _ACPI_PU, /* 0x21 33. '!' */ - _ACPI_PU, /* 0x22 34. '"' */ - _ACPI_PU, /* 0x23 35. '#' */ - _ACPI_PU, /* 0x24 36. '$' */ - _ACPI_PU, /* 0x25 37. '%' */ - _ACPI_PU, /* 0x26 38. '&' */ - _ACPI_PU, /* 0x27 39. ''' */ - _ACPI_PU, /* 0x28 40. '(' */ - _ACPI_PU, /* 0x29 41. ')' */ - _ACPI_PU, /* 0x2A 42. '*' */ - _ACPI_PU, /* 0x2B 43. '+' */ - _ACPI_PU, /* 0x2C 44. ',' */ - _ACPI_PU, /* 0x2D 45. '-' */ - _ACPI_PU, /* 0x2E 46. '.' */ - _ACPI_PU, /* 0x2F 47. '/' */ - _ACPI_XD|_ACPI_DI, /* 0x30 48. '0' */ - _ACPI_XD|_ACPI_DI, /* 0x31 49. '1' */ - _ACPI_XD|_ACPI_DI, /* 0x32 50. '2' */ - _ACPI_XD|_ACPI_DI, /* 0x33 51. '3' */ - _ACPI_XD|_ACPI_DI, /* 0x34 52. '4' */ - _ACPI_XD|_ACPI_DI, /* 0x35 53. '5' */ - _ACPI_XD|_ACPI_DI, /* 0x36 54. '6' */ - _ACPI_XD|_ACPI_DI, /* 0x37 55. '7' */ - _ACPI_XD|_ACPI_DI, /* 0x38 56. '8' */ - _ACPI_XD|_ACPI_DI, /* 0x39 57. '9' */ - _ACPI_PU, /* 0x3A 58. ':' */ - _ACPI_PU, /* 0x3B 59. ';' */ - _ACPI_PU, /* 0x3C 60. '<' */ - _ACPI_PU, /* 0x3D 61. '=' */ - _ACPI_PU, /* 0x3E 62. '>' */ - _ACPI_PU, /* 0x3F 63. '?' */ - _ACPI_PU, /* 0x40 64. '@' */ - _ACPI_XD|_ACPI_UP, /* 0x41 65. 'A' */ - _ACPI_XD|_ACPI_UP, /* 0x42 66. 'B' */ - _ACPI_XD|_ACPI_UP, /* 0x43 67. 'C' */ - _ACPI_XD|_ACPI_UP, /* 0x44 68. 'D' */ - _ACPI_XD|_ACPI_UP, /* 0x45 69. 'E' */ - _ACPI_XD|_ACPI_UP, /* 0x46 70. 'F' */ - _ACPI_UP, /* 0x47 71. 'G' */ - _ACPI_UP, /* 0x48 72. 'H' */ - _ACPI_UP, /* 0x49 73. 'I' */ - _ACPI_UP, /* 0x4A 74. 'J' */ - _ACPI_UP, /* 0x4B 75. 'K' */ - _ACPI_UP, /* 0x4C 76. 'L' */ - _ACPI_UP, /* 0x4D 77. 'M' */ - _ACPI_UP, /* 0x4E 78. 'N' */ - _ACPI_UP, /* 0x4F 79. 'O' */ - _ACPI_UP, /* 0x50 80. 'P' */ - _ACPI_UP, /* 0x51 81. 'Q' */ - _ACPI_UP, /* 0x52 82. 'R' */ - _ACPI_UP, /* 0x53 83. 'S' */ - _ACPI_UP, /* 0x54 84. 'T' */ - _ACPI_UP, /* 0x55 85. 'U' */ - _ACPI_UP, /* 0x56 86. 'V' */ - _ACPI_UP, /* 0x57 87. 'W' */ - _ACPI_UP, /* 0x58 88. 'X' */ - _ACPI_UP, /* 0x59 89. 'Y' */ - _ACPI_UP, /* 0x5A 90. 'Z' */ - _ACPI_PU, /* 0x5B 91. '[' */ - _ACPI_PU, /* 0x5C 92. '\' */ - _ACPI_PU, /* 0x5D 93. ']' */ - _ACPI_PU, /* 0x5E 94. '^' */ - _ACPI_PU, /* 0x5F 95. '_' */ - _ACPI_PU, /* 0x60 96. '`' */ - _ACPI_XD|_ACPI_LO, /* 0x61 97. 'a' */ - _ACPI_XD|_ACPI_LO, /* 0x62 98. 'b' */ - _ACPI_XD|_ACPI_LO, /* 0x63 99. 'c' */ - _ACPI_XD|_ACPI_LO, /* 0x64 100. 'd' */ - _ACPI_XD|_ACPI_LO, /* 0x65 101. 'e' */ - _ACPI_XD|_ACPI_LO, /* 0x66 102. 'f' */ - _ACPI_LO, /* 0x67 103. 'g' */ - _ACPI_LO, /* 0x68 104. 'h' */ - _ACPI_LO, /* 0x69 105. 'i' */ - _ACPI_LO, /* 0x6A 106. 'j' */ - _ACPI_LO, /* 0x6B 107. 'k' */ - _ACPI_LO, /* 0x6C 108. 'l' */ - _ACPI_LO, /* 0x6D 109. 'm' */ - _ACPI_LO, /* 0x6E 110. 'n' */ - _ACPI_LO, /* 0x6F 111. 'o' */ - _ACPI_LO, /* 0x70 112. 'p' */ - _ACPI_LO, /* 0x71 113. 'q' */ - _ACPI_LO, /* 0x72 114. 'r' */ - _ACPI_LO, /* 0x73 115. 's' */ - _ACPI_LO, /* 0x74 116. 't' */ - _ACPI_LO, /* 0x75 117. 'u' */ - _ACPI_LO, /* 0x76 118. 'v' */ - _ACPI_LO, /* 0x77 119. 'w' */ - _ACPI_LO, /* 0x78 120. 'x' */ - _ACPI_LO, /* 0x79 121. 'y' */ - _ACPI_LO, /* 0x7A 122. 'z' */ - _ACPI_PU, /* 0x7B 123. '{' */ - _ACPI_PU, /* 0x7C 124. '|' */ - _ACPI_PU, /* 0x7D 125. '}' */ - _ACPI_PU, /* 0x7E 126. '~' */ - _ACPI_CN, /* 0x7F 127. */ - - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80 to 0x8F */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90 to 0x9F */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xA0 to 0xAF */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xB0 to 0xBF */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xC0 to 0xCF */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xD0 to 0xDF */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xE0 to 0xEF */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xF0 to 0x100 */ -}; - -#define IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) -#define IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) -#define IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI)) -#define IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP)) -#define IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD)) - - -/******************************************************************************* - * - * FUNCTION: AcpiUtToUpper - * - * PARAMETERS: - * - * RETURN: - * - * DESCRIPTION: Convert character to uppercase - * - ******************************************************************************/ - -int -AcpiUtToUpper ( - int c) -{ - - return (IS_LOWER(c) ? ((c)-0x20) : (c)); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtToLower - * - * PARAMETERS: + * FUNCTION: AcpiUtStrstr (strstr) * - * RETURN: + * PARAMETERS: String1 - Target string + * String2 - Substring to search for * - * DESCRIPTION: Convert character to lowercase - * - ******************************************************************************/ - -int -AcpiUtToLower ( - int c) -{ - - return (IS_UPPER(c) ? ((c)+0x20) : (c)); -} - - -/******************************************************************************* - * - * FUNCTION: strstr - * - * PARAMETERS: String1 - - * String2 - * - * RETURN: + * RETURN: Where substring match starts, Null if no match found * * DESCRIPTION: Checks if String2 occurs in String1. This is not really a * full implementation of strstr, only sufficient for command @@ -733,15 +579,17 @@ AcpiUtStrstr ( /******************************************************************************* * - * FUNCTION: strtoul + * FUNCTION: AcpiUtStrtoul (strtoul) * * PARAMETERS: String - Null terminated string - * Terminater - Where a pointer to the terminating byte is returned + * Terminater - Where a pointer to the terminating byte is + * returned * Base - Radix of the string * * RETURN: Converted value * - * DESCRIPTION: Convert a string into an unsigned value. + * DESCRIPTION: Convert a string into a 32-bit unsigned value. + * Note: use AcpiUtStrtoul64 for 64-bit integers. * ******************************************************************************/ @@ -765,7 +613,7 @@ AcpiUtStrtoul ( * skip over any white space in the buffer: */ StringStart = String; - while (IS_SPACE (*String) || *String == '\t') + while (ACPI_IS_SPACE (*String) || *String == '\t') { ++String; } @@ -837,20 +685,19 @@ AcpiUtStrtoul ( String++; } - /* * Main loop: convert the string to an unsigned long: */ while (*String) { - if (IS_DIGIT (*String)) + if (ACPI_IS_DIGIT (*String)) { index = (UINT32) ((UINT8) *String - '0'); } else { index = (UINT32) AcpiUtToUpper (*String); - if (IS_UPPER (index)) + if (ACPI_IS_UPPER (index)) { index = index - 'A' + 10; } @@ -918,5 +765,197 @@ done: return (ReturnValue); } + +/******************************************************************************* + * + * FUNCTION: AcpiUtToUpper (TOUPPER) + * + * PARAMETERS: c - Character to convert + * + * RETURN: Converted character as an int + * + * DESCRIPTION: Convert character to uppercase + * + ******************************************************************************/ + +int +AcpiUtToUpper ( + int c) +{ + + return (ACPI_IS_LOWER(c) ? ((c)-0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtToLower (TOLOWER) + * + * PARAMETERS: c - Character to convert + * + * RETURN: Converted character as an int + * + * DESCRIPTION: Convert character to lowercase + * + ******************************************************************************/ + +int +AcpiUtToLower ( + int c) +{ + + return (ACPI_IS_UPPER(c) ? ((c)+0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: is* functions + * + * DESCRIPTION: is* functions use the ctype table below + * + ******************************************************************************/ + +const UINT8 _acpi_ctype[257] = { + _ACPI_CN, /* 0x0 0. */ + _ACPI_CN, /* 0x1 1. */ + _ACPI_CN, /* 0x2 2. */ + _ACPI_CN, /* 0x3 3. */ + _ACPI_CN, /* 0x4 4. */ + _ACPI_CN, /* 0x5 5. */ + _ACPI_CN, /* 0x6 6. */ + _ACPI_CN, /* 0x7 7. */ + _ACPI_CN, /* 0x8 8. */ + _ACPI_CN|_ACPI_SP, /* 0x9 9. */ + _ACPI_CN|_ACPI_SP, /* 0xA 10. */ + _ACPI_CN|_ACPI_SP, /* 0xB 11. */ + _ACPI_CN|_ACPI_SP, /* 0xC 12. */ + _ACPI_CN|_ACPI_SP, /* 0xD 13. */ + _ACPI_CN, /* 0xE 14. */ + _ACPI_CN, /* 0xF 15. */ + _ACPI_CN, /* 0x10 16. */ + _ACPI_CN, /* 0x11 17. */ + _ACPI_CN, /* 0x12 18. */ + _ACPI_CN, /* 0x13 19. */ + _ACPI_CN, /* 0x14 20. */ + _ACPI_CN, /* 0x15 21. */ + _ACPI_CN, /* 0x16 22. */ + _ACPI_CN, /* 0x17 23. */ + _ACPI_CN, /* 0x18 24. */ + _ACPI_CN, /* 0x19 25. */ + _ACPI_CN, /* 0x1A 26. */ + _ACPI_CN, /* 0x1B 27. */ + _ACPI_CN, /* 0x1C 28. */ + _ACPI_CN, /* 0x1D 29. */ + _ACPI_CN, /* 0x1E 30. */ + _ACPI_CN, /* 0x1F 31. */ + _ACPI_XS|_ACPI_SP, /* 0x20 32. ' ' */ + _ACPI_PU, /* 0x21 33. '!' */ + _ACPI_PU, /* 0x22 34. '"' */ + _ACPI_PU, /* 0x23 35. '#' */ + _ACPI_PU, /* 0x24 36. '$' */ + _ACPI_PU, /* 0x25 37. '%' */ + _ACPI_PU, /* 0x26 38. '&' */ + _ACPI_PU, /* 0x27 39. ''' */ + _ACPI_PU, /* 0x28 40. '(' */ + _ACPI_PU, /* 0x29 41. ')' */ + _ACPI_PU, /* 0x2A 42. '*' */ + _ACPI_PU, /* 0x2B 43. '+' */ + _ACPI_PU, /* 0x2C 44. ',' */ + _ACPI_PU, /* 0x2D 45. '-' */ + _ACPI_PU, /* 0x2E 46. '.' */ + _ACPI_PU, /* 0x2F 47. '/' */ + _ACPI_XD|_ACPI_DI, /* 0x30 48. '0' */ + _ACPI_XD|_ACPI_DI, /* 0x31 49. '1' */ + _ACPI_XD|_ACPI_DI, /* 0x32 50. '2' */ + _ACPI_XD|_ACPI_DI, /* 0x33 51. '3' */ + _ACPI_XD|_ACPI_DI, /* 0x34 52. '4' */ + _ACPI_XD|_ACPI_DI, /* 0x35 53. '5' */ + _ACPI_XD|_ACPI_DI, /* 0x36 54. '6' */ + _ACPI_XD|_ACPI_DI, /* 0x37 55. '7' */ + _ACPI_XD|_ACPI_DI, /* 0x38 56. '8' */ + _ACPI_XD|_ACPI_DI, /* 0x39 57. '9' */ + _ACPI_PU, /* 0x3A 58. ':' */ + _ACPI_PU, /* 0x3B 59. ';' */ + _ACPI_PU, /* 0x3C 60. '<' */ + _ACPI_PU, /* 0x3D 61. '=' */ + _ACPI_PU, /* 0x3E 62. '>' */ + _ACPI_PU, /* 0x3F 63. '?' */ + _ACPI_PU, /* 0x40 64. '@' */ + _ACPI_XD|_ACPI_UP, /* 0x41 65. 'A' */ + _ACPI_XD|_ACPI_UP, /* 0x42 66. 'B' */ + _ACPI_XD|_ACPI_UP, /* 0x43 67. 'C' */ + _ACPI_XD|_ACPI_UP, /* 0x44 68. 'D' */ + _ACPI_XD|_ACPI_UP, /* 0x45 69. 'E' */ + _ACPI_XD|_ACPI_UP, /* 0x46 70. 'F' */ + _ACPI_UP, /* 0x47 71. 'G' */ + _ACPI_UP, /* 0x48 72. 'H' */ + _ACPI_UP, /* 0x49 73. 'I' */ + _ACPI_UP, /* 0x4A 74. 'J' */ + _ACPI_UP, /* 0x4B 75. 'K' */ + _ACPI_UP, /* 0x4C 76. 'L' */ + _ACPI_UP, /* 0x4D 77. 'M' */ + _ACPI_UP, /* 0x4E 78. 'N' */ + _ACPI_UP, /* 0x4F 79. 'O' */ + _ACPI_UP, /* 0x50 80. 'P' */ + _ACPI_UP, /* 0x51 81. 'Q' */ + _ACPI_UP, /* 0x52 82. 'R' */ + _ACPI_UP, /* 0x53 83. 'S' */ + _ACPI_UP, /* 0x54 84. 'T' */ + _ACPI_UP, /* 0x55 85. 'U' */ + _ACPI_UP, /* 0x56 86. 'V' */ + _ACPI_UP, /* 0x57 87. 'W' */ + _ACPI_UP, /* 0x58 88. 'X' */ + _ACPI_UP, /* 0x59 89. 'Y' */ + _ACPI_UP, /* 0x5A 90. 'Z' */ + _ACPI_PU, /* 0x5B 91. '[' */ + _ACPI_PU, /* 0x5C 92. '\' */ + _ACPI_PU, /* 0x5D 93. ']' */ + _ACPI_PU, /* 0x5E 94. '^' */ + _ACPI_PU, /* 0x5F 95. '_' */ + _ACPI_PU, /* 0x60 96. '`' */ + _ACPI_XD|_ACPI_LO, /* 0x61 97. 'a' */ + _ACPI_XD|_ACPI_LO, /* 0x62 98. 'b' */ + _ACPI_XD|_ACPI_LO, /* 0x63 99. 'c' */ + _ACPI_XD|_ACPI_LO, /* 0x64 100. 'd' */ + _ACPI_XD|_ACPI_LO, /* 0x65 101. 'e' */ + _ACPI_XD|_ACPI_LO, /* 0x66 102. 'f' */ + _ACPI_LO, /* 0x67 103. 'g' */ + _ACPI_LO, /* 0x68 104. 'h' */ + _ACPI_LO, /* 0x69 105. 'i' */ + _ACPI_LO, /* 0x6A 106. 'j' */ + _ACPI_LO, /* 0x6B 107. 'k' */ + _ACPI_LO, /* 0x6C 108. 'l' */ + _ACPI_LO, /* 0x6D 109. 'm' */ + _ACPI_LO, /* 0x6E 110. 'n' */ + _ACPI_LO, /* 0x6F 111. 'o' */ + _ACPI_LO, /* 0x70 112. 'p' */ + _ACPI_LO, /* 0x71 113. 'q' */ + _ACPI_LO, /* 0x72 114. 'r' */ + _ACPI_LO, /* 0x73 115. 's' */ + _ACPI_LO, /* 0x74 116. 't' */ + _ACPI_LO, /* 0x75 117. 'u' */ + _ACPI_LO, /* 0x76 118. 'v' */ + _ACPI_LO, /* 0x77 119. 'w' */ + _ACPI_LO, /* 0x78 120. 'x' */ + _ACPI_LO, /* 0x79 121. 'y' */ + _ACPI_LO, /* 0x7A 122. 'z' */ + _ACPI_PU, /* 0x7B 123. '{' */ + _ACPI_PU, /* 0x7C 124. '|' */ + _ACPI_PU, /* 0x7D 125. '}' */ + _ACPI_PU, /* 0x7E 126. '~' */ + _ACPI_CN, /* 0x7F 127. */ + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80 to 0x8F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90 to 0x9F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xA0 to 0xAF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xB0 to 0xBF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xC0 to 0xCF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xD0 to 0xDF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xE0 to 0xEF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xF0 to 0x100 */ +}; + + #endif /* ACPI_USE_SYSTEM_CLIBRARY */ diff --git a/sys/contrib/dev/acpica/utcopy.c b/sys/contrib/dev/acpica/utcopy.c index 73413a4..b282987 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: 115 $ + * $Revision: 1.122 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -123,21 +123,69 @@ #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utcopy") +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtCopyIsimpleToEsimple ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_OBJECT *ExternalObject, + UINT8 *DataSpace, + ACPI_SIZE *BufferSpaceUsed); + +static ACPI_STATUS +AcpiUtCopyIelementToIelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + +static ACPI_STATUS +AcpiUtCopyIpackageToEpackage ( + ACPI_OPERAND_OBJECT *InternalObject, + UINT8 *Buffer, + ACPI_SIZE *SpaceUsed); + +static ACPI_STATUS +AcpiUtCopyEsimpleToIsimple( + ACPI_OBJECT *UserObj, + ACPI_OPERAND_OBJECT **ReturnObj); + +static ACPI_STATUS +AcpiUtCopySimpleObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc); + +static ACPI_STATUS +AcpiUtCopyIelementToEelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + +static ACPI_STATUS +AcpiUtCopyIpackageToIpackage ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState); + /******************************************************************************* * * FUNCTION: AcpiUtCopyIsimpleToEsimple * - * PARAMETERS: *InternalObject - Pointer to the object we are examining - * *Buffer - Where the object is returned - * *SpaceUsed - Where the data length is returned + * PARAMETERS: InternalObject - Source object to be copied + * ExternalObject - Where to return the copied object + * DataSpace - Where object data is returned (such as + * buffer and string data) + * BufferSpaceUsed - Length of DataSpace that was used * * RETURN: Status * - * DESCRIPTION: This function is called to place a simple object in a user - * buffer. + * DESCRIPTION: This function is called to copy a simple internal object to + * an external object. * - * The buffer is assumed to have sufficient space for the object. + * The DataSpace buffer is assumed to have sufficient space for + * the object. * ******************************************************************************/ @@ -183,10 +231,12 @@ AcpiUtCopyIsimpleToEsimple ( ExternalObject->String.Pointer = (char *) DataSpace; ExternalObject->String.Length = InternalObject->String.Length; - *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ((ACPI_SIZE) InternalObject->String.Length + 1); + *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( + (ACPI_SIZE) InternalObject->String.Length + 1); - ACPI_MEMCPY ((void *) DataSpace, (void *) InternalObject->String.Pointer, - (ACPI_SIZE) InternalObject->String.Length + 1); + ACPI_MEMCPY ((void *) DataSpace, + (void *) InternalObject->String.Pointer, + (ACPI_SIZE) InternalObject->String.Length + 1); break; @@ -194,10 +244,12 @@ AcpiUtCopyIsimpleToEsimple ( ExternalObject->Buffer.Pointer = DataSpace; ExternalObject->Buffer.Length = InternalObject->Buffer.Length; - *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD (InternalObject->String.Length); + *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( + InternalObject->String.Length); - ACPI_MEMCPY ((void *) DataSpace, (void *) InternalObject->Buffer.Pointer, - InternalObject->Buffer.Length); + ACPI_MEMCPY ((void *) DataSpace, + (void *) InternalObject->Buffer.Pointer, + InternalObject->Buffer.Length); break; @@ -271,7 +323,7 @@ AcpiUtCopyIsimpleToEsimple ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtCopyIelementToEelement ( UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, @@ -290,7 +342,7 @@ AcpiUtCopyIelementToEelement ( ThisIndex = State->Pkg.Index; TargetObject = (ACPI_OBJECT *) - &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; + &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; switch (ObjectType) { @@ -315,7 +367,8 @@ AcpiUtCopyIelementToEelement ( */ TargetObject->Type = ACPI_TYPE_PACKAGE; TargetObject->Package.Count = SourceObject->Package.Count; - TargetObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace); + TargetObject->Package.Elements = + ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace); /* * Pass the new package object back to the package walk routine @@ -327,7 +380,8 @@ AcpiUtCopyIelementToEelement ( * update the buffer length counter */ ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD ( - (ACPI_SIZE) TargetObject->Package.Count * sizeof (ACPI_OBJECT)); + (ACPI_SIZE) TargetObject->Package.Count * + sizeof (ACPI_OBJECT)); break; @@ -345,9 +399,9 @@ AcpiUtCopyIelementToEelement ( * * FUNCTION: AcpiUtCopyIpackageToEpackage * - * PARAMETERS: *InternalObject - Pointer to the object we are returning - * *Buffer - Where the object is returned - * *SpaceUsed - Where the object length is returned + * PARAMETERS: InternalObject - Pointer to the object we are returning + * Buffer - Where the object is returned + * SpaceUsed - Where the object length is returned * * RETURN: Status * @@ -383,13 +437,15 @@ AcpiUtCopyIpackageToEpackage ( * Free space begins right after the first package */ Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); - Info.FreeSpace = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + Info.FreeSpace = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD ( + sizeof (ACPI_OBJECT)); Info.ObjectSpace = 0; Info.NumPackages = 1; ExternalObject->Type = ACPI_GET_OBJECT_TYPE (InternalObject); ExternalObject->Package.Count = InternalObject->Package.Count; - ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, Info.FreeSpace); + ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, + Info.FreeSpace); /* * Leave room for an array of ACPI_OBJECTS in the buffer @@ -401,7 +457,7 @@ AcpiUtCopyIpackageToEpackage ( ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject, - AcpiUtCopyIelementToEelement, &Info); + AcpiUtCopyIelementToEelement, &Info); *SpaceUsed = Info.Length; return_ACPI_STATUS (Status); @@ -412,8 +468,8 @@ AcpiUtCopyIpackageToEpackage ( * * FUNCTION: AcpiUtCopyIobjectToEobject * - * PARAMETERS: *InternalObject - The internal object to be converted - * *BufferPtr - Where the object is returned + * PARAMETERS: InternalObject - The internal object to be converted + * BufferPtr - Where the object is returned * * RETURN: Status * @@ -448,10 +504,10 @@ AcpiUtCopyIobjectToEobject ( * Build a simple object (no nested objects) */ Status = AcpiUtCopyIsimpleToEsimple (InternalObject, - (ACPI_OBJECT *) RetBuffer->Pointer, - ((UINT8 *) RetBuffer->Pointer + - ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), - &RetBuffer->Length); + (ACPI_OBJECT *) RetBuffer->Pointer, + ((UINT8 *) RetBuffer->Pointer + + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), + &RetBuffer->Length); /* * build simple does not include the object size in the length * so we add it in here @@ -467,8 +523,8 @@ AcpiUtCopyIobjectToEobject ( * * FUNCTION: AcpiUtCopyEsimpleToIsimple * - * PARAMETERS: *ExternalObject - The external object to be converted - * *InternalObject - Where the internal object is returned + * PARAMETERS: ExternalObject - The external object to be converted + * RetInternalObject - Where the internal object is returned * * RETURN: Status * @@ -479,7 +535,7 @@ AcpiUtCopyIobjectToEobject ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtCopyEsimpleToIsimple ( ACPI_OBJECT *ExternalObject, ACPI_OPERAND_OBJECT **RetInternalObject) @@ -499,7 +555,8 @@ AcpiUtCopyEsimpleToIsimple ( case ACPI_TYPE_BUFFER: case ACPI_TYPE_INTEGER: - InternalObject = AcpiUtCreateInternalObject ((UINT8) ExternalObject->Type); + InternalObject = AcpiUtCreateInternalObject ( + (UINT8) ExternalObject->Type); if (!InternalObject) { return_ACPI_STATUS (AE_NO_MEMORY); @@ -572,7 +629,6 @@ ErrorExit: #ifdef ACPI_FUTURE_IMPLEMENTATION - /* Code to convert packages that are parameters to control methods */ /******************************************************************************* @@ -702,7 +758,7 @@ AcpiUtCopyEobjectToIobject ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtCopySimpleObject ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc) @@ -726,66 +782,68 @@ AcpiUtCopySimpleObject ( DestDesc->Common.ReferenceCount = ReferenceCount; DestDesc->Common.NextObject = NextObject; + /* New object is not static, regardless of source */ + + DestDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; + /* Handle the objects with extra data */ switch (ACPI_GET_OBJECT_TYPE (DestDesc)) { case ACPI_TYPE_BUFFER: - - DestDesc->Buffer.Node = NULL; - DestDesc->Common.Flags = SourceDesc->Common.Flags; - /* * Allocate and copy the actual buffer if and only if: * 1) There is a valid buffer pointer - * 2) The buffer is not static (not in an ACPI table) (in this case, - * the actual pointer was already copied above) + * 2) The buffer has a length > 0 */ if ((SourceDesc->Buffer.Pointer) && - (!(SourceDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) + (SourceDesc->Buffer.Length)) { - DestDesc->Buffer.Pointer = NULL; - - /* Create an actual buffer only if length > 0 */ - - if (SourceDesc->Buffer.Length) + DestDesc->Buffer.Pointer = + ACPI_MEM_ALLOCATE (SourceDesc->Buffer.Length); + if (!DestDesc->Buffer.Pointer) { - DestDesc->Buffer.Pointer = ACPI_MEM_ALLOCATE (SourceDesc->Buffer.Length); - if (!DestDesc->Buffer.Pointer) - { - return (AE_NO_MEMORY); - } + return (AE_NO_MEMORY); + } - /* Copy the actual buffer data */ + /* Copy the actual buffer data */ - ACPI_MEMCPY (DestDesc->Buffer.Pointer, SourceDesc->Buffer.Pointer, - SourceDesc->Buffer.Length); - } + ACPI_MEMCPY (DestDesc->Buffer.Pointer, + SourceDesc->Buffer.Pointer, + SourceDesc->Buffer.Length); } break; case ACPI_TYPE_STRING: - /* * Allocate and copy the actual string if and only if: * 1) There is a valid string pointer - * 2) The string is not static (not in an ACPI table) (in this case, - * the actual pointer was already copied above) + * (Pointer to a NULL string is allowed) */ - if ((SourceDesc->String.Pointer) && - (!(SourceDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) + if (SourceDesc->String.Pointer) { - DestDesc->String.Pointer = ACPI_MEM_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1); + DestDesc->String.Pointer = + ACPI_MEM_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1); if (!DestDesc->String.Pointer) { return (AE_NO_MEMORY); } + /* Copy the actual string data */ + ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer, (ACPI_SIZE) SourceDesc->String.Length + 1); } break; + case ACPI_TYPE_LOCAL_REFERENCE: + /* + * We copied the reference object, so we now must add a reference + * to the object pointed to by the reference + */ + AcpiUtAddReference (SourceDesc->Reference.Object); + break; + default: /* Nothing to do for other simple objects */ break; @@ -807,7 +865,7 @@ AcpiUtCopySimpleObject ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtCopyIelementToIelement ( UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, @@ -927,7 +985,7 @@ ErrorExit: * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtCopyIpackageToIpackage ( ACPI_OPERAND_OBJECT *SourceObj, ACPI_OPERAND_OBJECT *DestObj, diff --git a/sys/contrib/dev/acpica/utdebug.c b/sys/contrib/dev/acpica/utdebug.c index 783e53c..7d78a4c 100644 --- a/sys/contrib/dev/acpica/utdebug.c +++ b/sys/contrib/dev/acpica/utdebug.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utdebug - Debug print routines - * $Revision: 111 $ + * $Revision: 1.126 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -128,8 +128,14 @@ static UINT32 AcpiGbl_PrevThreadId = 0xFFFFFFFF; static char *AcpiGbl_FnEntryStr = "----Entry"; static char *AcpiGbl_FnExitStr = "----Exit-"; +/* Local prototypes */ -/***************************************************************************** +static const char * +AcpiUtTrimFunctionName ( + const char *FunctionName); + + +/******************************************************************************* * * FUNCTION: AcpiUtInitStackPtrTrace * @@ -137,22 +143,22 @@ static char *AcpiGbl_FnExitStr = "----Exit-"; * * RETURN: None * - * DESCRIPTION: Save the current stack pointer + * DESCRIPTION: Save the current CPU stack pointer at subsystem startup * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtInitStackPtrTrace ( void) { - UINT32 CurrentSp; + UINT32 CurrentSp; AcpiGbl_EntryStackPointer = ACPI_PTR_DIFF (&CurrentSp, NULL); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtTrackStackPtr * @@ -160,15 +166,15 @@ AcpiUtInitStackPtrTrace ( * * RETURN: None * - * DESCRIPTION: Save the current stack pointer + * DESCRIPTION: Save the current CPU stack pointer * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtTrackStackPtr ( void) { - ACPI_SIZE CurrentSp; + ACPI_SIZE CurrentSp; CurrentSp = ACPI_PTR_DIFF (&CurrentSp, NULL); @@ -185,16 +191,54 @@ AcpiUtTrackStackPtr ( } -/***************************************************************************** +/******************************************************************************* + * + * FUNCTION: AcpiUtTrimFunctionName + * + * PARAMETERS: FunctionName - Ascii string containing a procedure name + * + * RETURN: Updated pointer to the function name + * + * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present. + * This allows compiler macros such as __FUNCTION__ to be used + * with no change to the debug output. + * + ******************************************************************************/ + +static const char * +AcpiUtTrimFunctionName ( + const char *FunctionName) +{ + + /* All Function names are longer than 4 chars, check is safe */ + + if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_MIXED) + { + /* This is the case where the original source has not been modified */ + + return (FunctionName + 4); + } + + if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_LOWER) + { + /* This is the case where the source has been 'linuxized' */ + + return (FunctionName + 5); + } + + return (FunctionName); +} + + +/******************************************************************************* * * FUNCTION: AcpiUtDebugPrint * - * PARAMETERS: DebugLevel - Requested debug print level - * ProcName - Caller's procedure name - * ModuleName - Caller's module name (for error output) + * PARAMETERS: RequestedDebugLevel - Requested debug print level * LineNumber - Caller's line number (for error output) - * ComponentId - Caller's component ID (for error output) - * + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID * Format - Printf format field * ... - Optional printf arguments * @@ -203,13 +247,15 @@ AcpiUtTrackStackPtr ( * DESCRIPTION: Print error message with prefix consisting of the module name, * line number, and component ID. * - ****************************************************************************/ + ******************************************************************************/ void ACPI_INTERNAL_VAR_XFACE AcpiUtDebugPrint ( UINT32 RequestedDebugLevel, UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, char *Format, ...) { @@ -221,7 +267,7 @@ AcpiUtDebugPrint ( * Stay silent if the debug level or component ID is disabled */ if (!(RequestedDebugLevel & AcpiDbgLevel) || - !(DbgInfo->ComponentId & AcpiDbgLayer)) + !(ComponentId & AcpiDbgLayer)) { return; } @@ -235,7 +281,8 @@ AcpiUtDebugPrint ( { if (ACPI_LV_THREADS & AcpiDbgLevel) { - AcpiOsPrintf ("\n**** Context Switch from TID %X to TID %X ****\n\n", + AcpiOsPrintf ( + "\n**** Context Switch from TID %X to TID %X ****\n\n", AcpiGbl_PrevThreadId, ThreadId); } @@ -246,30 +293,30 @@ AcpiUtDebugPrint ( * Display the module name, current line number, thread ID (if requested), * current procedure nesting level, and the current procedure name */ - AcpiOsPrintf ("%8s-%04ld ", DbgInfo->ModuleName, LineNumber); + AcpiOsPrintf ("%8s-%04ld ", ModuleName, LineNumber); if (ACPI_LV_THREADS & AcpiDbgLevel) { AcpiOsPrintf ("[%04lX] ", ThreadId); } - AcpiOsPrintf ("[%02ld] %-22.22s: ", AcpiGbl_NestingLevel, DbgInfo->ProcName); + AcpiOsPrintf ("[%02ld] %-22.22s: ", + AcpiGbl_NestingLevel, AcpiUtTrimFunctionName (FunctionName)); va_start (args, Format); AcpiOsVprintf (Format, args); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtDebugPrintRaw * * PARAMETERS: RequestedDebugLevel - Requested debug print level * LineNumber - Caller's line number - * DbgInfo - Contains: - * ProcName - Caller's procedure name - * ModuleName - Caller's module name - * ComponentId - Caller's component ID + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID * Format - Printf format field * ... - Optional printf arguments * @@ -278,13 +325,15 @@ AcpiUtDebugPrint ( * DESCRIPTION: Print message with no headers. Has same interface as * DebugPrint so that the same macros can be used. * - ****************************************************************************/ + ******************************************************************************/ void ACPI_INTERNAL_VAR_XFACE AcpiUtDebugPrintRaw ( UINT32 RequestedDebugLevel, UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, char *Format, ...) { @@ -292,7 +341,7 @@ AcpiUtDebugPrintRaw ( if (!(RequestedDebugLevel & AcpiDbgLevel) || - !(DbgInfo->ComponentId & AcpiDbgLayer)) + !(ComponentId & AcpiDbgLayer)) { return; } @@ -302,46 +351,47 @@ AcpiUtDebugPrintRaw ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtTrace * * PARAMETERS: LineNumber - Caller's line number - * DbgInfo - Contains: - * ProcName - Caller's procedure name - * ModuleName - Caller's module name - * ComponentId - Caller's component ID + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID * * RETURN: None * * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtTrace ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo) + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId) { AcpiGbl_NestingLevel++; AcpiUtTrackStackPtr (); - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, - "%s\n", AcpiGbl_FnEntryStr); + AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s\n", AcpiGbl_FnEntryStr); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtTracePtr * * PARAMETERS: LineNumber - Caller's line number - * DbgInfo - Contains: - * ProcName - Caller's procedure name - * ModuleName - Caller's module name - * ComponentId - Caller's component ID + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID * Pointer - Pointer to display * * RETURN: None @@ -349,31 +399,33 @@ AcpiUtTrace ( * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtTracePtr ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, void *Pointer) { AcpiGbl_NestingLevel++; AcpiUtTrackStackPtr (); - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, - "%s %p\n", AcpiGbl_FnEntryStr, Pointer); + AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %p\n", AcpiGbl_FnEntryStr, Pointer); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtTraceStr * * PARAMETERS: LineNumber - Caller's line number - * DbgInfo - Contains: - * ProcName - Caller's procedure name - * ModuleName - Caller's module name - * ComponentId - Caller's component ID + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID * String - Additional string to display * * RETURN: None @@ -381,32 +433,34 @@ AcpiUtTracePtr ( * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtTraceStr ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, char *String) { AcpiGbl_NestingLevel++; AcpiUtTrackStackPtr (); - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, - "%s %s\n", AcpiGbl_FnEntryStr, String); + AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %s\n", AcpiGbl_FnEntryStr, String); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtTraceU32 * * PARAMETERS: LineNumber - Caller's line number - * DbgInfo - Contains: - * ProcName - Caller's procedure name - * ModuleName - Caller's module name - * ComponentId - Caller's component ID + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID * Integer - Integer to display * * RETURN: None @@ -414,62 +468,66 @@ AcpiUtTraceStr ( * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtTraceU32 ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, UINT32 Integer) { AcpiGbl_NestingLevel++; AcpiUtTrackStackPtr (); - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, - "%s %08X\n", AcpiGbl_FnEntryStr, Integer); + AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %08X\n", AcpiGbl_FnEntryStr, Integer); } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtExit * * PARAMETERS: LineNumber - Caller's line number - * DbgInfo - Contains: - * ProcName - Caller's procedure name - * ModuleName - Caller's module name - * ComponentId - Caller's component ID + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID * * RETURN: None * * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtExit ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo) + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId) { - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, - "%s\n", AcpiGbl_FnExitStr); + AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s\n", AcpiGbl_FnExitStr); AcpiGbl_NestingLevel--; } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtStatusExit * * PARAMETERS: LineNumber - Caller's line number - * DbgInfo - Contains: - * ProcName - Caller's procedure name - * ModuleName - Caller's module name - * ComponentId - Caller's component ID + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID * Status - Exit status code * * RETURN: None @@ -477,41 +535,44 @@ AcpiUtExit ( * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel. Prints exit status also. * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtStatusExit ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, ACPI_STATUS Status) { if (ACPI_SUCCESS (Status)) { - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, - "%s %s\n", AcpiGbl_FnExitStr, - AcpiFormatException (Status)); + AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %s\n", AcpiGbl_FnExitStr, + AcpiFormatException (Status)); } else { - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, - "%s ****Exception****: %s\n", AcpiGbl_FnExitStr, - AcpiFormatException (Status)); + AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s ****Exception****: %s\n", AcpiGbl_FnExitStr, + AcpiFormatException (Status)); } AcpiGbl_NestingLevel--; } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtValueExit * * PARAMETERS: LineNumber - Caller's line number - * DbgInfo - Contains: - * ProcName - Caller's procedure name - * ModuleName - Caller's module name - * ComponentId - Caller's component ID + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID * Value - Value to be printed with exit msg * * RETURN: None @@ -519,50 +580,55 @@ AcpiUtStatusExit ( * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel. Prints exit value also. * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtValueExit ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, ACPI_INTEGER Value) { - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, - "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr, - ACPI_FORMAT_UINT64 (Value)); + AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr, + ACPI_FORMAT_UINT64 (Value)); AcpiGbl_NestingLevel--; } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtPtrExit * * PARAMETERS: LineNumber - Caller's line number - * DbgInfo - Contains: - * ProcName - Caller's procedure name - * ModuleName - Caller's module name - * ComponentId - Caller's component ID - * Value - Value to be printed with exit msg + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Ptr - Pointer to display * * RETURN: None * * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is * set in DebugLevel. Prints exit value also. * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtPtrExit ( UINT32 LineNumber, - ACPI_DEBUG_PRINT_INFO *DbgInfo, + const char *FunctionName, + char *ModuleName, + UINT32 ComponentId, UINT8 *Ptr) { - AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo, - "%s %p\n", AcpiGbl_FnExitStr, Ptr); + AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %p\n", AcpiGbl_FnExitStr, Ptr); AcpiGbl_NestingLevel--; } @@ -570,7 +636,7 @@ AcpiUtPtrExit ( #endif -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtDumpBuffer * @@ -583,7 +649,7 @@ AcpiUtPtrExit ( * * DESCRIPTION: Generic dump buffer in both hex and ascii. * - ****************************************************************************/ + ******************************************************************************/ void AcpiUtDumpBuffer ( @@ -611,16 +677,13 @@ AcpiUtDumpBuffer ( Display = DB_BYTE_DISPLAY; } - AcpiOsPrintf ("\nOffset Value\n"); + /* Nasty little dump buffer routine! */ - /* - * Nasty little dump buffer routine! - */ while (i < Count) { /* Print current offset */ - AcpiOsPrintf ("%05X ", (UINT32) i); + AcpiOsPrintf ("%6.4X: ", (UINT32) i); /* Print 16 hex chars */ @@ -628,21 +691,18 @@ AcpiUtDumpBuffer ( { if (i + j >= Count) { - AcpiOsPrintf ("\n"); - return; - } + /* Dump fill spaces */ - /* Make sure that the INT8 doesn't get sign-extended! */ + AcpiOsPrintf ("%*s", ((Display * 2) + 1), " "); + j += (ACPI_NATIVE_UINT) Display; + continue; + } switch (Display) { - /* Default is BYTE display */ + default: /* Default is BYTE display */ - default: - - AcpiOsPrintf ("%02X ", - *((UINT8 *) &Buffer[i + j])); - j += 1; + AcpiOsPrintf ("%02X ", Buffer[i + j]); break; @@ -650,7 +710,6 @@ AcpiUtDumpBuffer ( ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[i + j]); AcpiOsPrintf ("%04X ", Temp32); - j += 2; break; @@ -658,7 +717,6 @@ AcpiUtDumpBuffer ( ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[i + j]); AcpiOsPrintf ("%08X ", Temp32); - j += 4; break; @@ -669,15 +727,17 @@ AcpiUtDumpBuffer ( ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[i + j + 4]); AcpiOsPrintf ("%08X ", Temp32); - j += 8; break; } + + j += (ACPI_NATIVE_UINT) Display; } /* - * Print the ASCII equivalent characters - * But watch out for the bad unprintable ones... + * Print the ASCII equivalent characters but watch out for the bad + * unprintable ones (printable chars are 0x20 through 0x7E) */ + AcpiOsPrintf (" "); for (j = 0; j < 16; j++) { if (i + j >= Count) @@ -687,9 +747,7 @@ AcpiUtDumpBuffer ( } BufChar = Buffer[i + j]; - if ((BufChar > 0x1F && BufChar < 0x2E) || - (BufChar > 0x2F && BufChar < 0x61) || - (BufChar > 0x60 && BufChar < 0x7F)) + if (ACPI_IS_PRINT (BufChar)) { AcpiOsPrintf ("%c", BufChar); } diff --git a/sys/contrib/dev/acpica/utdelete.c b/sys/contrib/dev/acpica/utdelete.c index 7714901..95d1feb 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: 100 $ + * $Revision: 1.107 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -120,16 +120,28 @@ #include <contrib/dev/acpica/acinterp.h> #include <contrib/dev/acpica/acnamesp.h> #include <contrib/dev/acpica/acevents.h> +#include <contrib/dev/acpica/amlcode.h> #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utdelete") +/* Local prototypes */ + +static void +AcpiUtDeleteInternalObj ( + ACPI_OPERAND_OBJECT *Object); + +static void +AcpiUtUpdateRefCount ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Action); + /******************************************************************************* * * FUNCTION: AcpiUtDeleteInternalObj * - * PARAMETERS: *Object - Pointer to the list to be deleted + * PARAMETERS: Object - Object to be deleted * * RETURN: None * @@ -138,7 +150,7 @@ * ******************************************************************************/ -void +static void AcpiUtDeleteInternalObj ( ACPI_OPERAND_OBJECT *Object) { @@ -231,7 +243,8 @@ AcpiUtDeleteInternalObj ( case ACPI_TYPE_MUTEX: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Mutex %p, Semaphore %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Mutex %p, Semaphore %p\n", Object, Object->Mutex.Semaphore)); AcpiExUnlinkMutex (Object); @@ -241,7 +254,8 @@ AcpiUtDeleteInternalObj ( case ACPI_TYPE_EVENT: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Event %p, Semaphore %p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Event %p, Semaphore %p\n", Object, Object->Event.Semaphore)); (void) AcpiOsDeleteSemaphore (Object->Event.Semaphore); @@ -251,7 +265,8 @@ AcpiUtDeleteInternalObj ( case ACPI_TYPE_METHOD: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Method %p\n", Object)); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Method %p\n", Object)); /* Delete the method semaphore if it exists */ @@ -265,7 +280,8 @@ AcpiUtDeleteInternalObj ( case ACPI_TYPE_REGION: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Region %p\n", Object)); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Region %p\n", Object)); SecondDesc = AcpiNsGetSecondaryObject (Object); if (SecondDesc) @@ -295,7 +311,8 @@ AcpiUtDeleteInternalObj ( case ACPI_TYPE_BUFFER_FIELD: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Buffer Field %p\n", Object)); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Buffer Field %p\n", Object)); SecondDesc = AcpiNsGetSecondaryObject (Object); if (SecondDesc) @@ -332,7 +349,7 @@ AcpiUtDeleteInternalObj ( * * FUNCTION: AcpiUtDeleteInternalObjectList * - * PARAMETERS: *ObjList - Pointer to the list to be deleted + * PARAMETERS: ObjList - Pointer to the list to be deleted * * RETURN: None * @@ -369,7 +386,7 @@ AcpiUtDeleteInternalObjectList ( * * FUNCTION: AcpiUtUpdateRefCount * - * PARAMETERS: *Object - Object whose ref count is to be updated + * PARAMETERS: Object - Object whose ref count is to be updated * Action - What to do * * RETURN: New ref count @@ -399,7 +416,8 @@ AcpiUtUpdateRefCount ( NewCount = Count; /* - * Perform the reference count action (increment, decrement, or force delete) + * Perform the reference count action + * (increment, decrement, or force delete) */ switch (Action) { @@ -409,7 +427,8 @@ AcpiUtUpdateRefCount ( NewCount++; Object->Common.ReferenceCount = NewCount; - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, [Incremented]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Incremented]\n", Object, NewCount)); break; @@ -418,7 +437,8 @@ AcpiUtUpdateRefCount ( if (Count < 1) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, can't decrement! (Set to 0)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, can't decrement! (Set to 0)\n", Object, NewCount)); NewCount = 0; @@ -427,13 +447,15 @@ AcpiUtUpdateRefCount ( { NewCount--; - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, [Decremented]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Decremented]\n", Object, NewCount)); } if (ACPI_GET_OBJECT_TYPE (Object) == ACPI_TYPE_METHOD) { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Method Obj %p Refs=%X, [Decremented]\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Method Obj %p Refs=%X, [Decremented]\n", Object, NewCount)); } @@ -448,7 +470,8 @@ AcpiUtUpdateRefCount ( case REF_FORCE_DELETE: - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, Force delete! (Set to 0)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, Force delete! (Set to 0)\n", Object, Count)); NewCount = 0; @@ -483,7 +506,7 @@ AcpiUtUpdateRefCount ( * * FUNCTION: AcpiUtUpdateObjectReference * - * PARAMETERS: *Object - Increment ref count for this object + * PARAMETERS: Object - Increment ref count for this object * and all sub-objects * Action - Either REF_INCREMENT or REF_DECREMENT or * REF_FORCE_DELETE @@ -506,37 +529,26 @@ AcpiUtUpdateObjectReference ( ACPI_OPERAND_OBJECT *Object, UINT16 Action) { - ACPI_STATUS Status; - UINT32 i; - ACPI_GENERIC_STATE *StateList = NULL; - ACPI_GENERIC_STATE *State; + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *StateList = NULL; + ACPI_OPERAND_OBJECT *NextObject = NULL; + ACPI_GENERIC_STATE *State; + ACPI_NATIVE_UINT i; ACPI_FUNCTION_TRACE_PTR ("UtUpdateObjectReference", Object); - /* Ignore a null object ptr */ - - if (!Object) + while (Object) { - return_ACPI_STATUS (AE_OK); - } - - /* Make sure that this isn't a namespace handle */ + /* Make sure that this isn't a namespace handle */ - if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p is NS handle\n", Object)); - return_ACPI_STATUS (AE_OK); - } - - State = AcpiUtCreateUpdateState (Object, Action); - - while (State) - { - Object = State->Update.Object; - Action = State->Update.Value; - AcpiUtDeleteGenericState (State); + if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Object %p is NS handle\n", Object)); + return_ACPI_STATUS (AE_OK); + } /* * All sub-objects must have their reference count incremented also. @@ -550,12 +562,10 @@ AcpiUtUpdateObjectReference ( AcpiUtUpdateRefCount (Object->Device.DeviceNotify, Action); break; - case ACPI_TYPE_PACKAGE: - /* - * We must update all the sub-objects of the package - * (Each of whom may have their own sub-objects, etc. + * We must update all the sub-objects of the package, + * each of whom may have their own sub-objects. */ for (i = 0; i < Object->Package.Count; i++) { @@ -573,38 +583,19 @@ AcpiUtUpdateObjectReference ( } break; - case ACPI_TYPE_BUFFER_FIELD: - Status = AcpiUtCreateUpdateStateAndPush ( - Object->BufferField.BufferObj, Action, &StateList); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } + NextObject = Object->BufferField.BufferObj; break; - case ACPI_TYPE_LOCAL_REGION_FIELD: - Status = AcpiUtCreateUpdateStateAndPush ( - Object->Field.RegionObj, Action, &StateList); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - break; - + NextObject = Object->Field.RegionObj; + break; case ACPI_TYPE_LOCAL_BANK_FIELD: - Status = AcpiUtCreateUpdateStateAndPush ( - Object->BankField.BankObj, Action, &StateList); - if (ACPI_FAILURE (Status)) - { - goto ErrorExit; - } - + NextObject = Object->BankField.BankObj; Status = AcpiUtCreateUpdateStateAndPush ( Object->BankField.RegionObj, Action, &StateList); if (ACPI_FAILURE (Status)) @@ -613,31 +604,31 @@ AcpiUtUpdateObjectReference ( } break; - case ACPI_TYPE_LOCAL_INDEX_FIELD: + NextObject = Object->IndexField.IndexObj; Status = AcpiUtCreateUpdateStateAndPush ( - Object->IndexField.IndexObj, Action, &StateList); + Object->IndexField.DataObj, Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; } + break; - Status = AcpiUtCreateUpdateStateAndPush ( - Object->IndexField.DataObj, Action, &StateList); - if (ACPI_FAILURE (Status)) + case ACPI_TYPE_LOCAL_REFERENCE: + /* + * The target of an Index (a package, string, or buffer) must track + * changes to the ref count of the index. + */ + if (Object->Reference.Opcode == AML_INDEX_OP) { - goto ErrorExit; + NextObject = Object->Reference.Object; } break; - case ACPI_TYPE_REGION: - case ACPI_TYPE_LOCAL_REFERENCE: default: - - /* No subobjects */ - break; + break;/* No subobjects */ } /* @@ -646,15 +637,25 @@ AcpiUtUpdateObjectReference ( * main object to be deleted. */ AcpiUtUpdateRefCount (Object, Action); + Object = NULL; /* Move on to the next object to be updated */ - State = AcpiUtPopGenericState (&StateList); + if (NextObject) + { + Object = NextObject; + NextObject = NULL; + } + else if (StateList) + { + State = AcpiUtPopGenericState (&StateList); + Object = State->Update.Object; + AcpiUtDeleteGenericState (State); + } } return_ACPI_STATUS (AE_OK); - ErrorExit: ACPI_REPORT_ERROR (("Could not update object reference count, %s\n", @@ -668,8 +669,8 @@ ErrorExit: * * FUNCTION: AcpiUtAddReference * - * PARAMETERS: *Object - Object whose reference count is to be - * incremented + * PARAMETERS: Object - Object whose reference count is to be + * incremented * * RETURN: None * @@ -707,7 +708,7 @@ AcpiUtAddReference ( * * FUNCTION: AcpiUtRemoveReference * - * PARAMETERS: *Object - Object whose ref count will be decremented + * PARAMETERS: Object - Object whose ref count will be decremented * * RETURN: None * diff --git a/sys/contrib/dev/acpica/uteval.c b/sys/contrib/dev/acpica/uteval.c index 8969ad1..c1fd6d8 100644 --- a/sys/contrib/dev/acpica/uteval.c +++ b/sys/contrib/dev/acpica/uteval.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: uteval - Object evaluation - * $Revision: 54 $ + * $Revision: 1.59 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,6 +124,19 @@ #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("uteval") +/* Local prototypes */ + +static void +AcpiUtCopyIdString ( + char *Destination, + char *Source, + ACPI_SIZE MaxLength); + +static ACPI_STATUS +AcpiUtTranslateOneCid ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_COMPATIBLE_ID *OneCid); + /******************************************************************************* * @@ -282,6 +295,18 @@ AcpiUtEvaluateObject ( break; } + if ((AcpiGbl_EnableInterpreterSlack) && + (!ExpectedReturnBtypes)) + { + /* + * We received a return object, but one was not expected. This can + * happen frequently if the "implicit return" feature is enabled. + * Just delete the return object and return AE_OK. + */ + AcpiUtRemoveReference (Info.ReturnObject); + return_ACPI_STATUS (AE_OK); + } + /* Is the return object one of the expected types? */ if (!(ExpectedReturnBtypes & ReturnBtype)) @@ -290,8 +315,9 @@ AcpiUtEvaluateObject ( PrefixNode, Path, AE_TYPE); ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Type returned from %s was incorrect: %X\n", - Path, ACPI_GET_OBJECT_TYPE (Info.ReturnObject))); + "Type returned from %s was incorrect: %s, expected Btypes: %X\n", + Path, AcpiUtGetObjectTypeName (Info.ReturnObject), + ExpectedReturnBtypes)); /* On error exit, we must delete the return object */ @@ -310,9 +336,9 @@ AcpiUtEvaluateObject ( * * FUNCTION: AcpiUtEvaluateNumericObject * - * PARAMETERS: *ObjectName - Object name to be evaluated + * PARAMETERS: ObjectName - Object name to be evaluated * DeviceNode - Node for the device - * *Address - Where the value is returned + * Address - Where the value is returned * * RETURN: Status * @@ -377,7 +403,6 @@ AcpiUtCopyIdString ( ACPI_SIZE MaxLength) { - /* * Workaround for ID strings that have a leading asterisk. This construct * is not allowed by the ACPI specification (ID strings must be @@ -400,7 +425,7 @@ AcpiUtCopyIdString ( * FUNCTION: AcpiUtExecute_HID * * PARAMETERS: DeviceNode - Node for the device - * *Hid - Where the HID is returned + * Hid - Where the HID is returned * * RETURN: Status * @@ -509,7 +534,7 @@ AcpiUtTranslateOneCid ( * FUNCTION: AcpiUtExecute_CID * * PARAMETERS: DeviceNode - Node for the device - * *Cid - Where the CID is returned + * ReturnCidList - Where the CID list is returned * * RETURN: Status * @@ -571,10 +596,10 @@ AcpiUtExecute_CID ( CidList->Size = Size; /* - * A _CID can return either a single compatible ID or a package of compatible - * IDs. Each compatible ID can be one of the following: - * -- Number (32 bit compressed EISA ID) or - * -- String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss"). + * A _CID can return either a single compatible ID or a package of + * compatible IDs. Each compatible ID can be one of the following: + * 1) Integer (32 bit compressed EISA ID) or + * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss") */ /* The _CID object can be either a single CID or a package (list) of CIDs */ @@ -623,7 +648,7 @@ AcpiUtExecute_CID ( * FUNCTION: AcpiUtExecute_UID * * PARAMETERS: DeviceNode - Node for the device - * *Uid - Where the UID is returned + * Uid - Where the UID is returned * * RETURN: Status * @@ -679,7 +704,7 @@ AcpiUtExecute_UID ( * FUNCTION: AcpiUtExecute_STA * * PARAMETERS: DeviceNode - Node for the device - * *Flags - Where the status flags are returned + * Flags - Where the status flags are returned * * RETURN: Status * @@ -735,7 +760,7 @@ AcpiUtExecute_STA ( * FUNCTION: AcpiUtExecute_Sxds * * PARAMETERS: DeviceNode - Node for the device - * *Flags - Where the status flags are returned + * Flags - Where the status flags are returned * * RETURN: Status * diff --git a/sys/contrib/dev/acpica/utglobal.c b/sys/contrib/dev/acpica/utglobal.c index 3668a1c..c8378b4 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: 202 $ + * $Revision: 1.216 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,13 +124,14 @@ ACPI_MODULE_NAME ("utglobal") -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiFormatException * * PARAMETERS: Status - The ACPI_STATUS code to be formatted * - * RETURN: A string containing the exception text + * RETURN: A string containing the exception text. A valid pointer is + * always returned. * * DESCRIPTION: This function translates an ACPI exception into an ASCII string. * @@ -140,8 +141,8 @@ const char * AcpiFormatException ( ACPI_STATUS Status) { - const char *Exception = "UNKNOWN_STATUS_CODE"; ACPI_STATUS SubStatus; + const char *Exception = NULL; ACPI_FUNCTION_NAME ("FormatException"); @@ -156,61 +157,60 @@ AcpiFormatException ( if (SubStatus <= AE_CODE_ENV_MAX) { Exception = AcpiGbl_ExceptionNames_Env [SubStatus]; - break; } - goto Unknown; + break; case AE_CODE_PROGRAMMER: if (SubStatus <= AE_CODE_PGM_MAX) { Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus -1]; - break; } - goto Unknown; + break; case AE_CODE_ACPI_TABLES: if (SubStatus <= AE_CODE_TBL_MAX) { Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1]; - break; } - goto Unknown; + break; case AE_CODE_AML: if (SubStatus <= AE_CODE_AML_MAX) { Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1]; - break; } - goto Unknown; + break; case AE_CODE_CONTROL: if (SubStatus <= AE_CODE_CTRL_MAX) { Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1]; - break; } - goto Unknown; + break; default: - goto Unknown; + break; } + if (!Exception) + { + /* Exception code was not recognized */ - return ((const char *) Exception); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Unknown exception code: 0x%8.8X\n", Status)); -Unknown: + return ((const char *) "UNKNOWN_STATUS_CODE"); + } - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown exception code: 0x%8.8X\n", Status)); return ((const char *) Exception); } -/****************************************************************************** +/******************************************************************************* * * Static global variable initialization. * @@ -275,6 +275,8 @@ const char *AcpiGbl_HighestDstateNames[4] = */ const char *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS] = { + /* Operating System Vendor Strings */ + "Linux", "Windows 2000", "Windows 2001", @@ -283,23 +285,28 @@ const char *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS] = "Windows 2001 SP1", "Windows 2001 SP2", "Windows 2001 SP3", - "Windows 2001 SP4" + "Windows 2001 SP4", + + /* Feature Group Strings */ + + "Extended Address Space Descriptor" }; -/****************************************************************************** +/******************************************************************************* * * Namespace globals * ******************************************************************************/ - /* * Predefined ACPI Names (Built-in to the Interpreter) * * NOTES: * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run * during the initialization sequence. + * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to + * perform a Notify() operation on it. */ const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = { @@ -308,16 +315,18 @@ const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = {"_SB_", ACPI_TYPE_DEVICE, NULL}, {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, {"_TZ_", ACPI_TYPE_THERMAL, NULL}, - {"_REV", ACPI_TYPE_INTEGER, "2"}, + {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, - {"_GL_", ACPI_TYPE_MUTEX, "0"}, + {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) - {"_OSI", ACPI_TYPE_METHOD, "1"}, + {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, #endif - {NULL, ACPI_TYPE_ANY, NULL} /* Table terminator */ -}; + /* Table terminator */ + + {NULL, ACPI_TYPE_ANY, NULL} +}; /* * Properties of the ACPI Object Types, both internal and external. @@ -362,22 +371,25 @@ const UINT8 AcpiGbl_NsProperties[] = /* Hex to ASCII conversion table */ static const char AcpiGbl_HexToAscii[] = - {'0','1','2','3','4','5','6','7', - '8','9','A','B','C','D','E','F'}; +{ + '0','1','2','3','4','5','6','7', + '8','9','A','B','C','D','E','F' +}; + -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtHexToAsciiChar * * PARAMETERS: Integer - Contains the hex digit * Position - bit position of the digit within the - * integer + * integer (multiple of 4) * - * RETURN: Ascii character + * RETURN: The converted Ascii character * - * DESCRIPTION: Convert a hex digit to an ascii character + * DESCRIPTION: Convert a hex digit to an Ascii character * - ****************************************************************************/ + ******************************************************************************/ char AcpiUtHexToAsciiChar ( @@ -389,7 +401,7 @@ AcpiUtHexToAsciiChar ( } -/****************************************************************************** +/******************************************************************************* * * Table name globals * @@ -398,7 +410,7 @@ AcpiUtHexToAsciiChar ( * that are not used by the subsystem are simply ignored. * * Do NOT add any table to this list that is not consumed directly by this - * subsystem. + * subsystem (No MADT, ECDT, SBST, etc.) * ******************************************************************************/ @@ -435,6 +447,7 @@ ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, + /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, @@ -442,6 +455,7 @@ ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, + /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, @@ -463,7 +477,7 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, }; -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetRegionName * @@ -473,7 +487,7 @@ ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = * * DESCRIPTION: Translate a Space ID into a name string (Debug only) * - ****************************************************************************/ + ******************************************************************************/ /* Region type decoding */ @@ -501,7 +515,6 @@ AcpiUtGetRegionName ( { return ("UserDefinedRegion"); } - else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) { return ("InvalidSpaceId"); @@ -511,7 +524,7 @@ AcpiUtGetRegionName ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetEventName * @@ -521,17 +534,19 @@ AcpiUtGetRegionName ( * * DESCRIPTION: Translate a Event ID into a name string (Debug only) * - ****************************************************************************/ + ******************************************************************************/ /* Event type decoding */ static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] = { +/*! [Begin] no source code translation (keep these strings as-is) */ "PM_Timer", "GlobalLock", "PowerButton", "SleepButton", "RealTimeClock", +/*! [End] no source code translation !*/ }; @@ -549,7 +564,7 @@ AcpiUtGetEventName ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetTypeName * @@ -559,21 +574,23 @@ AcpiUtGetEventName ( * * DESCRIPTION: Translate a Type ID into a name string (Debug only) * - ****************************************************************************/ + ******************************************************************************/ /* * Elements of AcpiGbl_NsTypeNames below must match * one-to-one with values of ACPI_OBJECT_TYPE * - * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when - * stored in a table it really means that we have thus far seen no evidence to - * indicate what type is actually going to be stored for this entry. + * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; + * when stored in a table it really means that we have thus far seen no + * evidence to indicate what type is actually going to be stored for this entry. */ static const char AcpiGbl_BadType[] = "UNDEFINED"; -#define TYPE_NAME_LENGTH 12 /* Maximum length of each string */ -static const char *AcpiGbl_NsTypeNames[] = /* printable names of ACPI types */ +/* Printable names of the ACPI object types */ + +static const char *AcpiGbl_NsTypeNames[] = { +/*! [Begin] no source code translation (keep these strings as-is) */ /* 00 */ "Untyped", /* 01 */ "Integer", /* 02 */ "String", @@ -605,6 +622,7 @@ static const char *AcpiGbl_NsTypeNames[] = /* printable names of AC /* 28 */ "Extra", /* 29 */ "Data", /* 30 */ "Invalid" +/*! [End] no source code translation !*/ }; @@ -636,7 +654,7 @@ AcpiUtGetObjectTypeName ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetNodeName * @@ -646,7 +664,7 @@ AcpiUtGetObjectTypeName ( * * DESCRIPTION: Validate the node and return the node's ACPI name. * - ****************************************************************************/ + ******************************************************************************/ char * AcpiUtGetNodeName ( @@ -690,7 +708,7 @@ AcpiUtGetNodeName ( } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetDescriptorName * @@ -700,10 +718,13 @@ AcpiUtGetNodeName ( * * DESCRIPTION: Validate object and return the descriptor type * - ****************************************************************************/ + ******************************************************************************/ -static const char *AcpiGbl_DescTypeNames[] = /* printable names of descriptor types */ +/* Printable names of object descriptor types */ + +static const char *AcpiGbl_DescTypeNames[] = { +/*! [Begin] no source code translation (keep these ASL Keywords as-is) */ /* 00 */ "Invalid", /* 01 */ "Cached", /* 02 */ "State-Generic", @@ -720,6 +741,7 @@ static const char *AcpiGbl_DescTypeNames[] = /* printable names of /* 13 */ "Parser", /* 14 */ "Operand", /* 15 */ "Node" +/*! [End] no source code translation !*/ }; @@ -748,17 +770,18 @@ AcpiUtGetDescriptorName ( * Strings and procedures used for debug only */ -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtGetMutexName * - * PARAMETERS: None. + * PARAMETERS: MutexId - The predefined ID for this mutex. * - * RETURN: Status + * RETURN: String containing the name of the mutex. Always returns a valid + * pointer. * * DESCRIPTION: Translate a mutex ID into a name string (Debug only) * - ****************************************************************************/ + ******************************************************************************/ char * AcpiUtGetMutexName ( @@ -772,21 +795,20 @@ AcpiUtGetMutexName ( return (AcpiGbl_MutexNames[MutexId]); } - #endif -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtValidObjectType * * PARAMETERS: Type - Object type to be validated * - * RETURN: TRUE if valid object type + * RETURN: TRUE if valid object type, FALSE otherwise * * DESCRIPTION: Validate an object type * - ****************************************************************************/ + ******************************************************************************/ BOOLEAN AcpiUtValidObjectType ( @@ -804,121 +826,37 @@ AcpiUtValidObjectType ( } -/**************************************************************************** - * - * FUNCTION: AcpiUtAllocateOwnerId - * - * PARAMETERS: IdType - Type of ID (method or table) - * - * DESCRIPTION: Allocate a table or method owner id - * - ***************************************************************************/ - -ACPI_OWNER_ID -AcpiUtAllocateOwnerId ( - UINT32 IdType) -{ - ACPI_OWNER_ID OwnerId = 0xFFFF; - - - ACPI_FUNCTION_TRACE ("UtAllocateOwnerId"); - - - if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES))) - { - return (0); - } - - switch (IdType) - { - case ACPI_OWNER_TYPE_TABLE: - - OwnerId = AcpiGbl_NextTableOwnerId; - AcpiGbl_NextTableOwnerId++; - - /* Check for wraparound */ - - if (AcpiGbl_NextTableOwnerId == ACPI_FIRST_METHOD_ID) - { - AcpiGbl_NextTableOwnerId = ACPI_FIRST_TABLE_ID; - ACPI_REPORT_WARNING (("Table owner ID wraparound\n")); - } - break; - - - case ACPI_OWNER_TYPE_METHOD: - - OwnerId = AcpiGbl_NextMethodOwnerId; - AcpiGbl_NextMethodOwnerId++; - - if (AcpiGbl_NextMethodOwnerId == ACPI_FIRST_TABLE_ID) - { - /* Check for wraparound */ - - AcpiGbl_NextMethodOwnerId = ACPI_FIRST_METHOD_ID; - } - break; - - default: - break; - } - - (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); - return_VALUE (OwnerId); -} - - -/**************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiUtInitGlobals * - * PARAMETERS: none + * PARAMETERS: None + * + * RETURN: None * * DESCRIPTION: Init library globals. All globals that require specific * initialization should be initialized here! * - ***************************************************************************/ + ******************************************************************************/ void AcpiUtInitGlobals ( void) { + ACPI_STATUS Status; UINT32 i; ACPI_FUNCTION_TRACE ("UtInitGlobals"); - /* Memory allocation and cache lists */ - - ACPI_MEMSET (AcpiGbl_MemoryLists, 0, sizeof (ACPI_MEMORY_LIST) * ACPI_NUM_MEM_LISTS); + /* Create all memory caches */ - AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_GENERIC_STATE *) NULL)->Common.Next), NULL); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_OPERAND_OBJECT *) NULL)->Cache.Next), NULL); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_WALK_STATE *) NULL)->Next), NULL); - - AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ObjectSize = sizeof (ACPI_NAMESPACE_NODE); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ObjectSize = sizeof (ACPI_GENERIC_STATE); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ObjectSize = sizeof (ACPI_PARSE_OBJ_COMMON); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ObjectSize = sizeof (ACPI_PARSE_OBJ_NAMED); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ObjectSize = sizeof (ACPI_OPERAND_OBJECT); - AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ObjectSize = sizeof (ACPI_WALK_STATE); - - AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].MaxCacheDepth = ACPI_MAX_STATE_CACHE_DEPTH; - AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].MaxCacheDepth = ACPI_MAX_PARSE_CACHE_DEPTH; - AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].MaxCacheDepth = ACPI_MAX_EXTPARSE_CACHE_DEPTH; - AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].MaxCacheDepth = ACPI_MAX_OBJECT_CACHE_DEPTH; - AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].MaxCacheDepth = ACPI_MAX_WALK_CACHE_DEPTH; - - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].ListName = "Global Memory Allocation"); - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ListName = "Namespace Nodes"); - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ListName = "State Object Cache"); - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ListName = "Parse Node Cache"); - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ListName = "Extended Parse Node Cache"); - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ListName = "Operand Object Cache"); - ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ListName = "Tree Walk Node Cache"); + Status = AcpiUtCreateCaches (); + if (ACPI_FAILURE (Status)) + { + return; + } /* ACPI table structure */ @@ -933,7 +871,7 @@ AcpiUtInitGlobals ( for (i = 0; i < NUM_MUTEX; i++) { AcpiGbl_MutexInfo[i].Mutex = NULL; - AcpiGbl_MutexInfo[i].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; + AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; AcpiGbl_MutexInfo[i].UseCount = 0; } @@ -974,8 +912,10 @@ AcpiUtInitGlobals ( AcpiGbl_NsLookupCount = 0; AcpiGbl_PsFindCount = 0; AcpiGbl_AcpiHardwarePresent = TRUE; - AcpiGbl_NextTableOwnerId = ACPI_FIRST_TABLE_ID; - AcpiGbl_NextMethodOwnerId = ACPI_FIRST_METHOD_ID; + AcpiGbl_OwnerIdMask = 0; + AcpiGbl_TraceMethodName = 0; + AcpiGbl_TraceDbgLevel = 0; + AcpiGbl_TraceDbgLayer = 0; AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; diff --git a/sys/contrib/dev/acpica/utinit.c b/sys/contrib/dev/acpica/utinit.c index fc337e2..f346eea 100644 --- a/sys/contrib/dev/acpica/utinit.c +++ b/sys/contrib/dev/acpica/utinit.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utinit - Common ACPI subsystem initialization - * $Revision: 118 $ + * $Revision: 1.123 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,19 +124,29 @@ #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utinit") +/* Local prototypes */ + +static void +AcpiUtFadtRegisterError ( + char *RegisterName, + UINT32 Value, + ACPI_SIZE Offset); + +static void AcpiUtTerminate ( + void); + /******************************************************************************* * * FUNCTION: AcpiUtFadtRegisterError * - * PARAMETERS: *RegisterName - Pointer to string identifying register + * PARAMETERS: RegisterName - Pointer to string identifying register * Value - Actual register contents value - * AcpiTestSpecSection - TDS section containing assertion - * AcpiAssertion - Assertion number being tested + * Offset - Byte offset in the FADT * * RETURN: AE_BAD_VALUE * - * DESCRIPTION: Display failure message and link failure to TDS assertion + * DESCRIPTION: Display failure message * ******************************************************************************/ @@ -250,12 +260,13 @@ AcpiUtValidateFadt ( * * RETURN: none * - * DESCRIPTION: free global memory + * DESCRIPTION: Free global memory * ******************************************************************************/ -void -AcpiUtTerminate (void) +static void +AcpiUtTerminate ( + void) { ACPI_GPE_BLOCK_INFO *GpeBlock; ACPI_GPE_BLOCK_INFO *NextGpeBlock; @@ -267,8 +278,6 @@ AcpiUtTerminate (void) /* Free global tables, etc. */ - - /* Free global GPE blocks and related info structures */ GpeXruptInfo = AcpiGbl_GpeXruptListHead; @@ -307,7 +316,8 @@ AcpiUtTerminate (void) ******************************************************************************/ void -AcpiUtSubsystemShutdown (void) +AcpiUtSubsystemShutdown ( + void) { ACPI_FUNCTION_TRACE ("UtSubsystemShutdown"); @@ -316,14 +326,16 @@ AcpiUtSubsystemShutdown (void) if (AcpiGbl_Shutdown) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "ACPI Subsystem is already terminated\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "ACPI Subsystem is already terminated\n")); return_VOID; } /* Subsystem appears active, go ahead and shut it down */ AcpiGbl_Shutdown = TRUE; - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Shutting down ACPI Subsystem...\n")); /* Close the AcpiEvent Handling */ @@ -339,7 +351,7 @@ AcpiUtSubsystemShutdown (void) /* Purge the local caches */ - (void) AcpiPurgeCachedObjects (); + (void) AcpiUtDeleteCaches (); /* Debug only - display leftover memory allocation, if any */ diff --git a/sys/contrib/dev/acpica/utmath.c b/sys/contrib/dev/acpica/utmath.c index 2edd552..eeee80a 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: 14 $ + * $Revision: 1.17 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -349,6 +349,8 @@ AcpiUtDivide ( * * FUNCTION: AcpiUtShortDivide, AcpiUtDivide * + * PARAMETERS: See function headers above + * * DESCRIPTION: Native versions of the UtDivide functions. Use these if either * 1) The target is a 64-bit platform and therefore 64-bit * integer math is supported directly by the machine. diff --git a/sys/contrib/dev/acpica/utmisc.c b/sys/contrib/dev/acpica/utmisc.c index 0ebb3bc..81b75db 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: 101 $ + * $Revision: 1.125 $ * ******************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -119,6 +119,7 @@ #include <contrib/dev/acpica/acpi.h> #include <contrib/dev/acpica/acnamesp.h> +#include <contrib/dev/acpica/amlresrc.h> #define _COMPONENT ACPI_UTILITIES @@ -127,9 +128,186 @@ /******************************************************************************* * + * FUNCTION: AcpiUtAllocateOwnerId + * + * PARAMETERS: OwnerId - Where the new owner ID is returned + * + * RETURN: Status + * + * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to + * track objects created by the table or method, to be deleted + * when the method exits or the table is unloaded. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAllocateOwnerId ( + ACPI_OWNER_ID *OwnerId) +{ + ACPI_NATIVE_UINT i; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("UtAllocateOwnerId"); + + + /* Guard against multiple allocations of ID to the same location */ + + if (*OwnerId) + { + ACPI_REPORT_ERROR (("Owner ID [%2.2X] already exists\n", *OwnerId)); + return_ACPI_STATUS (AE_ALREADY_EXISTS); + } + + /* Mutex for the global ID mask */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Find a free owner ID */ + + for (i = 0; i < 32; i++) + { + if (!(AcpiGbl_OwnerIdMask & (1 << i))) + { + ACPI_DEBUG_PRINT ((ACPI_DB_VALUES, + "Current OwnerId mask: %8.8X New ID: %2.2X\n", + AcpiGbl_OwnerIdMask, (unsigned int) (i + 1))); + + AcpiGbl_OwnerIdMask |= (1 << i); + *OwnerId = (ACPI_OWNER_ID) (i + 1); + goto Exit; + } + } + + /* + * If we are here, all OwnerIds have been allocated. This probably should + * not happen since the IDs are reused after deallocation. The IDs are + * allocated upon table load (one per table) and method execution, and + * they are released when a table is unloaded or a method completes + * execution. + */ + *OwnerId = 0; + Status = AE_OWNER_ID_LIMIT; + ACPI_REPORT_ERROR (( + "Could not allocate new OwnerId (32 max), AE_OWNER_ID_LIMIT\n")); + +Exit: + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtReleaseOwnerId + * + * PARAMETERS: OwnerIdPtr - Pointer to a previously allocated OwnerID + * + * RETURN: None. No error is returned because we are either exiting a + * control method or unloading a table. Either way, we would + * ignore any error anyway. + * + * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 32 + * + ******************************************************************************/ + +void +AcpiUtReleaseOwnerId ( + ACPI_OWNER_ID *OwnerIdPtr) +{ + ACPI_OWNER_ID OwnerId = *OwnerIdPtr; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_U32 ("UtReleaseOwnerId", OwnerId); + + + /* Always clear the input OwnerId (zero is an invalid ID) */ + + *OwnerIdPtr = 0; + + /* Zero is not a valid OwnerID */ + + if ((OwnerId == 0) || (OwnerId > 32)) + { + ACPI_REPORT_ERROR (("Invalid OwnerId: %2.2X\n", OwnerId)); + return_VOID; + } + + /* Mutex for the global ID mask */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + /* Normalize the ID to zero */ + + OwnerId--; + + /* Free the owner ID only if it is valid */ + + if (AcpiGbl_OwnerIdMask & (1 << OwnerId)) + { + AcpiGbl_OwnerIdMask ^= (1 << OwnerId); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrupr (strupr) + * + * PARAMETERS: SrcString - The source string to convert + * + * RETURN: None + * + * DESCRIPTION: Convert string to uppercase + * + * NOTE: This is not a POSIX function, so it appears here, not in utclib.c + * + ******************************************************************************/ + +void +AcpiUtStrupr ( + char *SrcString) +{ + char *String; + + + ACPI_FUNCTION_ENTRY (); + + + if (!SrcString) + { + return; + } + + /* Walk entire string, uppercasing the letters */ + + for (String = SrcString; *String; String++) + { + *String = (char) ACPI_TOUPPER (*String); + } + + return; +} + + +/******************************************************************************* + * * FUNCTION: AcpiUtPrintString * * PARAMETERS: String - Null terminated ASCII string + * MaxLength - Maximum output length * * RETURN: None * @@ -227,6 +405,8 @@ AcpiUtPrintString ( * * PARAMETERS: Value - Value to be converted * + * RETURN: UINT32 integer with bytes swapped + * * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) * ******************************************************************************/ @@ -240,7 +420,6 @@ AcpiUtDwordByteSwap ( UINT32 Value; UINT8 Bytes[4]; } Out; - union { UINT32 Value; @@ -302,7 +481,8 @@ AcpiUtSetIntegerWidth ( * * FUNCTION: AcpiUtDisplayInitPathname * - * PARAMETERS: ObjHandle - Handle whose pathname will be displayed + * PARAMETERS: Type - Object type of the node + * ObjHandle - Handle whose pathname will be displayed * Path - Additional path string to be appended. * (NULL if no extra path) * @@ -356,7 +536,8 @@ AcpiUtDisplayInitPathname ( /* Print the object type and pathname */ - AcpiOsPrintf ("%-12s %s", AcpiUtGetTypeName (Type), (char *) Buffer.Pointer); + AcpiOsPrintf ("%-12s %s", + AcpiUtGetTypeName (Type), (char *) Buffer.Pointer); /* Extra path is used to append names like _STA, _INI, etc. */ @@ -375,9 +556,9 @@ AcpiUtDisplayInitPathname ( * * FUNCTION: AcpiUtValidAcpiName * - * PARAMETERS: Character - The character to be examined + * PARAMETERS: Name - The name to be examined * - * RETURN: 1 if Character may appear in a name, else 0 + * RETURN: TRUE if the name is valid, FALSE otherwise * * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: * 1) Upper case alpha @@ -461,7 +642,7 @@ AcpiUtStrtoul64 ( UINT32 Base, ACPI_INTEGER *RetInteger) { - UINT32 ThisDigit; + UINT32 ThisDigit = 0; ACPI_INTEGER ReturnValue = 0; ACPI_INTEGER Quotient; @@ -469,6 +650,11 @@ AcpiUtStrtoul64 ( ACPI_FUNCTION_TRACE ("UtStroul64"); + if ((!String) || !(*String)) + { + goto ErrorExit; + } + switch (Base) { case ACPI_ANY_BASE: @@ -485,7 +671,7 @@ AcpiUtStrtoul64 ( while (ACPI_IS_SPACE (*String) || *String == '\t') { - ++String; + String++; } /* @@ -495,10 +681,10 @@ AcpiUtStrtoul64 ( if (Base == 0) { if ((*String == '0') && - (ACPI_TOLOWER (*(++String)) == 'x')) + (ACPI_TOLOWER (*(String + 1)) == 'x')) { Base = 16; - ++String; + String += 2; } else { @@ -510,11 +696,18 @@ AcpiUtStrtoul64 ( * For hexadecimal base, skip over the leading * 0 or 0x, if they are present. */ - if (Base == 16 && - *String == '0' && - ACPI_TOLOWER (*(++String)) == 'x') + if ((Base == 16) && + (*String == '0') && + (ACPI_TOLOWER (*(String + 1)) == 'x')) { - String++; + String += 2; + } + + /* Any string left? */ + + if (!(*String)) + { + goto ErrorExit; } /* Main loop: convert the string to a 64-bit integer */ @@ -529,8 +722,15 @@ AcpiUtStrtoul64 ( } else { + if (Base == 10) + { + /* Digit is out of range */ + + goto ErrorExit; + } + ThisDigit = (UINT8) ACPI_TOUPPER (*String); - if (ACPI_IS_UPPER ((char) ThisDigit)) + if (ACPI_IS_XDIGIT ((char) ThisDigit)) { /* Convert ASCII Hex char to value */ @@ -538,17 +738,14 @@ AcpiUtStrtoul64 ( } else { - goto ErrorExit; + /* + * We allow non-hex chars, just stop now, same as end-of-string. + * See ACPI spec, string-to-integer conversion. + */ + break; } } - /* Check to see if digit is out of range */ - - if (ThisDigit >= Base) - { - goto ErrorExit; - } - /* Divide the digit into the correct position */ (void) AcpiUtShortDivide ((ACPI_INTEGER_MAX - (ACPI_INTEGER) ThisDigit), @@ -560,9 +757,11 @@ AcpiUtStrtoul64 ( ReturnValue *= Base; ReturnValue += ThisDigit; - ++String; + String++; } + /* All done, normal exit */ + *RetInteger = ReturnValue; return_ACPI_STATUS (AE_OK); @@ -583,372 +782,13 @@ ErrorExit: /******************************************************************************* * - * FUNCTION: AcpiUtStrupr - * - * PARAMETERS: SrcString - The source string to convert to - * - * RETURN: SrcString - * - * DESCRIPTION: Convert string to uppercase - * - ******************************************************************************/ - -char * -AcpiUtStrupr ( - char *SrcString) -{ - char *String; - - - ACPI_FUNCTION_ENTRY (); - - - /* Walk entire string, uppercasing the letters */ - - for (String = SrcString; *String; ) - { - *String = (char) ACPI_TOUPPER (*String); - String++; - } - - return (SrcString); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtMutexInitialize - * - * PARAMETERS: None. - * - * RETURN: Status - * - * DESCRIPTION: Create the system mutex objects. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtMutexInitialize ( - void) -{ - UINT32 i; - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE ("UtMutexInitialize"); - - - /* - * Create each of the predefined mutex objects - */ - for (i = 0; i < NUM_MUTEX; i++) - { - Status = AcpiUtCreateMutex (i); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } - } - - Status = AcpiOsCreateLock (&AcpiGbl_GpeLock); - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtMutexTerminate - * - * PARAMETERS: None. - * - * RETURN: None. - * - * DESCRIPTION: Delete all of the system mutex objects. - * - ******************************************************************************/ - -void -AcpiUtMutexTerminate ( - void) -{ - UINT32 i; - - - ACPI_FUNCTION_TRACE ("UtMutexTerminate"); - - - /* - * Delete each predefined mutex object - */ - for (i = 0; i < NUM_MUTEX; i++) - { - (void) AcpiUtDeleteMutex (i); - } - - AcpiOsDeleteLock (AcpiGbl_GpeLock); - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtCreateMutex - * - * PARAMETERS: MutexID - ID of the mutex to be created - * - * RETURN: Status - * - * DESCRIPTION: Create a mutex object. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtCreateMutex ( - ACPI_MUTEX_HANDLE MutexId) -{ - ACPI_STATUS Status = AE_OK; - - - ACPI_FUNCTION_TRACE_U32 ("UtCreateMutex", MutexId); - - - if (MutexId > MAX_MUTEX) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - if (!AcpiGbl_MutexInfo[MutexId].Mutex) - { - Status = AcpiOsCreateSemaphore (1, 1, - &AcpiGbl_MutexInfo[MutexId].Mutex); - AcpiGbl_MutexInfo[MutexId].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; - AcpiGbl_MutexInfo[MutexId].UseCount = 0; - } - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtDeleteMutex - * - * PARAMETERS: MutexID - ID of the mutex to be deleted - * - * RETURN: Status - * - * DESCRIPTION: Delete a mutex object. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtDeleteMutex ( - ACPI_MUTEX_HANDLE MutexId) -{ - ACPI_STATUS Status; - - - ACPI_FUNCTION_TRACE_U32 ("UtDeleteMutex", MutexId); - - - if (MutexId > MAX_MUTEX) - { - return_ACPI_STATUS (AE_BAD_PARAMETER); - } - - Status = AcpiOsDeleteSemaphore (AcpiGbl_MutexInfo[MutexId].Mutex); - - AcpiGbl_MutexInfo[MutexId].Mutex = NULL; - AcpiGbl_MutexInfo[MutexId].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; - - return_ACPI_STATUS (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtAcquireMutex - * - * PARAMETERS: MutexID - ID of the mutex to be acquired - * - * RETURN: Status - * - * DESCRIPTION: Acquire a mutex object. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtAcquireMutex ( - ACPI_MUTEX_HANDLE MutexId) -{ - ACPI_STATUS Status; - UINT32 i; - UINT32 ThisThreadId; - - - ACPI_FUNCTION_NAME ("UtAcquireMutex"); - - - if (MutexId > MAX_MUTEX) - { - return (AE_BAD_PARAMETER); - } - - ThisThreadId = AcpiOsGetThreadId (); - - /* - * Deadlock prevention. Check if this thread owns any mutexes of value - * greater than or equal to this one. If so, the thread has violated - * the mutex ordering rule. This indicates a coding error somewhere in - * the ACPI subsystem code. - */ - for (i = MutexId; i < MAX_MUTEX; i++) - { - if (AcpiGbl_MutexInfo[i].OwnerId == ThisThreadId) - { - if (i == MutexId) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Mutex [%s] already acquired by this thread [%X]\n", - AcpiUtGetMutexName (MutexId), ThisThreadId)); - - return (AE_ALREADY_ACQUIRED); - } - - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", - ThisThreadId, AcpiUtGetMutexName (i), - AcpiUtGetMutexName (MutexId))); - - return (AE_ACQUIRE_DEADLOCK); - } - } - - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %X attempting to acquire Mutex [%s]\n", - ThisThreadId, AcpiUtGetMutexName (MutexId))); - - Status = AcpiOsWaitSemaphore (AcpiGbl_MutexInfo[MutexId].Mutex, - 1, ACPI_WAIT_FOREVER); - if (ACPI_SUCCESS (Status)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", - ThisThreadId, AcpiUtGetMutexName (MutexId))); - - AcpiGbl_MutexInfo[MutexId].UseCount++; - AcpiGbl_MutexInfo[MutexId].OwnerId = ThisThreadId; - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not acquire Mutex [%s] %s\n", - ThisThreadId, AcpiUtGetMutexName (MutexId), - AcpiFormatException (Status))); - } - - return (Status); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtReleaseMutex - * - * PARAMETERS: MutexID - ID of the mutex to be released - * - * RETURN: Status - * - * DESCRIPTION: Release a mutex object. - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtReleaseMutex ( - ACPI_MUTEX_HANDLE MutexId) -{ - ACPI_STATUS Status; - UINT32 i; - UINT32 ThisThreadId; - - - ACPI_FUNCTION_NAME ("UtReleaseMutex"); - - - ThisThreadId = AcpiOsGetThreadId (); - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, - "Thread %X releasing Mutex [%s]\n", ThisThreadId, - AcpiUtGetMutexName (MutexId))); - - if (MutexId > MAX_MUTEX) - { - return (AE_BAD_PARAMETER); - } - - /* - * Mutex must be acquired in order to release it! - */ - if (AcpiGbl_MutexInfo[MutexId].OwnerId == ACPI_MUTEX_NOT_ACQUIRED) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Mutex [%s] is not acquired, cannot release\n", - AcpiUtGetMutexName (MutexId))); - - return (AE_NOT_ACQUIRED); - } - - /* - * Deadlock prevention. Check if this thread owns any mutexes of value - * greater than this one. If so, the thread has violated the mutex - * ordering rule. This indicates a coding error somewhere in - * the ACPI subsystem code. - */ - for (i = MutexId; i < MAX_MUTEX; i++) - { - if (AcpiGbl_MutexInfo[i].OwnerId == ThisThreadId) - { - if (i == MutexId) - { - continue; - } - - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Invalid release order: owns [%s], releasing [%s]\n", - AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId))); - - return (AE_RELEASE_DEADLOCK); - } - } - - /* Mark unlocked FIRST */ - - AcpiGbl_MutexInfo[MutexId].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; - - Status = AcpiOsSignalSemaphore (AcpiGbl_MutexInfo[MutexId].Mutex, 1); - - if (ACPI_FAILURE (Status)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Thread %X could not release Mutex [%s] %s\n", - ThisThreadId, AcpiUtGetMutexName (MutexId), - AcpiFormatException (Status))); - } - else - { - ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", - ThisThreadId, AcpiUtGetMutexName (MutexId))); - } - - return (Status); -} - - -/******************************************************************************* - * * FUNCTION: AcpiUtCreateUpdateStateAndPush * - * PARAMETERS: *Object - Object to be added to the new state + * PARAMETERS: Object - Object to be added to the new state * Action - Increment/Decrement * StateList - List the state will be added to * - * RETURN: None + * RETURN: Status * * DESCRIPTION: Create a new state and push it * @@ -986,369 +826,12 @@ AcpiUtCreateUpdateStateAndPush ( /******************************************************************************* * - * FUNCTION: AcpiUtCreatePkgStateAndPush - * - * PARAMETERS: *Object - Object to be added to the new state - * Action - Increment/Decrement - * StateList - List the state will be added to - * - * RETURN: None - * - * DESCRIPTION: Create a new state and push it - * - ******************************************************************************/ - -ACPI_STATUS -AcpiUtCreatePkgStateAndPush ( - void *InternalObject, - void *ExternalObject, - UINT16 Index, - ACPI_GENERIC_STATE **StateList) -{ - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_ENTRY (); - - - State = AcpiUtCreatePkgState (InternalObject, ExternalObject, Index); - if (!State) - { - return (AE_NO_MEMORY); - } - - AcpiUtPushGenericState (StateList, State); - return (AE_OK); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtPushGenericState - * - * PARAMETERS: ListHead - Head of the state stack - * State - State object to push - * - * RETURN: Status - * - * DESCRIPTION: Push a state object onto a state stack - * - ******************************************************************************/ - -void -AcpiUtPushGenericState ( - ACPI_GENERIC_STATE **ListHead, - ACPI_GENERIC_STATE *State) -{ - ACPI_FUNCTION_TRACE ("UtPushGenericState"); - - - /* Push the state object onto the front of the list (stack) */ - - State->Common.Next = *ListHead; - *ListHead = State; - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtPopGenericState - * - * PARAMETERS: ListHead - Head of the state stack - * - * RETURN: Status - * - * DESCRIPTION: Pop a state object from a state stack - * - ******************************************************************************/ - -ACPI_GENERIC_STATE * -AcpiUtPopGenericState ( - ACPI_GENERIC_STATE **ListHead) -{ - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_TRACE ("UtPopGenericState"); - - - /* Remove the state object at the head of the list (stack) */ - - State = *ListHead; - if (State) - { - /* Update the list head */ - - *ListHead = State->Common.Next; - } - - return_PTR (State); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtCreateGenericState - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Create a generic state object. Attempt to obtain one from - * the global state cache; If none available, create a new one. - * - ******************************************************************************/ - -ACPI_GENERIC_STATE * -AcpiUtCreateGenericState (void) -{ - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_ENTRY (); - - - State = AcpiUtAcquireFromCache (ACPI_MEM_LIST_STATE); - - /* Initialize */ - - if (State) - { - State->Common.DataType = ACPI_DESC_TYPE_STATE; - } - - return (State); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtCreateThreadState - * - * PARAMETERS: None - * - * RETURN: Thread State - * - * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used - * to track per-thread info during method execution - * - ******************************************************************************/ - -ACPI_THREAD_STATE * -AcpiUtCreateThreadState ( - void) -{ - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_TRACE ("UtCreateThreadState"); - - - /* Create the generic state object */ - - State = AcpiUtCreateGenericState (); - if (!State) - { - return_PTR (NULL); - } - - /* Init fields specific to the update struct */ - - State->Common.DataType = ACPI_DESC_TYPE_STATE_THREAD; - State->Thread.ThreadId = AcpiOsGetThreadId (); - - return_PTR ((ACPI_THREAD_STATE *) State); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtCreateUpdateState - * - * PARAMETERS: Object - Initial Object to be installed in the - * state - * Action - Update action to be performed - * - * RETURN: Status - * - * DESCRIPTION: Create an "Update State" - a flavor of the generic state used - * to update reference counts and delete complex objects such - * as packages. - * - ******************************************************************************/ - -ACPI_GENERIC_STATE * -AcpiUtCreateUpdateState ( - ACPI_OPERAND_OBJECT *Object, - UINT16 Action) -{ - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_TRACE_PTR ("UtCreateUpdateState", Object); - - - /* Create the generic state object */ - - State = AcpiUtCreateGenericState (); - if (!State) - { - return_PTR (NULL); - } - - /* Init fields specific to the update struct */ - - State->Common.DataType = ACPI_DESC_TYPE_STATE_UPDATE; - State->Update.Object = Object; - State->Update.Value = Action; - - return_PTR (State); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtCreatePkgState - * - * PARAMETERS: Object - Initial Object to be installed in the - * state - * Action - Update action to be performed - * - * RETURN: Status - * - * DESCRIPTION: Create a "Package State" - * - ******************************************************************************/ - -ACPI_GENERIC_STATE * -AcpiUtCreatePkgState ( - void *InternalObject, - void *ExternalObject, - UINT16 Index) -{ - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_TRACE_PTR ("UtCreatePkgState", InternalObject); - - - /* Create the generic state object */ - - State = AcpiUtCreateGenericState (); - if (!State) - { - return_PTR (NULL); - } - - /* Init fields specific to the update struct */ - - State->Common.DataType = ACPI_DESC_TYPE_STATE_PACKAGE; - State->Pkg.SourceObject = (ACPI_OPERAND_OBJECT *) InternalObject; - State->Pkg.DestObject = ExternalObject; - State->Pkg.Index = Index; - State->Pkg.NumPackages = 1; - - return_PTR (State); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtCreateControlState - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Create a "Control State" - a flavor of the generic state used - * to support nested IF/WHILE constructs in the AML. - * - ******************************************************************************/ - -ACPI_GENERIC_STATE * -AcpiUtCreateControlState ( - void) -{ - ACPI_GENERIC_STATE *State; - - - ACPI_FUNCTION_TRACE ("UtCreateControlState"); - - - /* Create the generic state object */ - - State = AcpiUtCreateGenericState (); - if (!State) - { - return_PTR (NULL); - } - - /* Init fields specific to the control struct */ - - State->Common.DataType = ACPI_DESC_TYPE_STATE_CONTROL; - State->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; - - return_PTR (State); -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtDeleteGenericState - * - * PARAMETERS: State - The state object to be deleted - * - * RETURN: Status - * - * DESCRIPTION: Put a state object back into the global state cache. The object - * is not actually freed at this time. - * - ******************************************************************************/ - -void -AcpiUtDeleteGenericState ( - ACPI_GENERIC_STATE *State) -{ - ACPI_FUNCTION_TRACE ("UtDeleteGenericState"); - - - AcpiUtReleaseToCache (ACPI_MEM_LIST_STATE, State); - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtDeleteGenericStateCache - * - * PARAMETERS: None - * - * RETURN: Status - * - * DESCRIPTION: Purge the global state object cache. Used during subsystem - * termination. - * - ******************************************************************************/ - -void -AcpiUtDeleteGenericStateCache ( - void) -{ - ACPI_FUNCTION_TRACE ("UtDeleteGenericStateCache"); - - - AcpiUtDeleteGenericCache (ACPI_MEM_LIST_STATE); - return_VOID; -} - - -/******************************************************************************* - * * FUNCTION: AcpiUtWalkPackageTree * - * PARAMETERS: ObjDesc - The Package object on which to resolve refs + * PARAMETERS: SourceObject - The package to walk + * TargetObject - Target object (if package is being copied) + * WalkCallback - Called once for each package element + * Context - Passed to the callback function * * RETURN: Status * @@ -1476,7 +959,7 @@ AcpiUtWalkPackageTree ( * PARAMETERS: Buffer - Buffer to be scanned * Length - number of bytes to examine * - * RETURN: checksum + * RETURN: The generated checksum * * DESCRIPTION: Generate a checksum on a raw buffer * @@ -1502,13 +985,143 @@ AcpiUtGenerateChecksum ( /******************************************************************************* * + * FUNCTION: AcpiUtGetResourceType + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: The Resource Type with no extraneous bits (except the + * Large/Small descriptor bit -- this is left alone) + * + * DESCRIPTION: Extract the Resource Type/Name from the first byte of + * a resource descriptor. + * + ******************************************************************************/ + +UINT8 +AcpiUtGetResourceType ( + void *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Determine if this is a small or large resource + */ + if (*((UINT8 *) Aml) & ACPI_RESOURCE_NAME_LARGE) + { + /* Large Resource Type -- bits 6:0 contain the name */ + + return (*((UINT8 *) Aml)); + } + else + { + /* Small Resource Type -- bits 6:3 contain the name */ + + return ((UINT8) (*((UINT8 *) Aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceLength + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte Length + * + * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By + * definition, this does not include the size of the descriptor + * header or the length field itself. + * + ******************************************************************************/ + +UINT16 +AcpiUtGetResourceLength ( + void *Aml) +{ + UINT16 ResourceLength; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Determine if this is a small or large resource + */ + if (*((UINT8 *) Aml) & ACPI_RESOURCE_NAME_LARGE) + { + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ + + ACPI_MOVE_16_TO_16 (&ResourceLength, &((UINT8 *) Aml)[1]); + + } + else + { + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ + + ResourceLength = (UINT16) (*((UINT8 *) Aml) & + ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); + } + + return (ResourceLength); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetDescriptorLength + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte length + * + * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the + * length of the descriptor header and the length field itself. + * Used to walk descriptor lists. + * + ******************************************************************************/ + +UINT32 +AcpiUtGetDescriptorLength ( + void *Aml) +{ + UINT32 DescriptorLength; + + + ACPI_FUNCTION_ENTRY (); + + + /* First get the Resource Length (Does not include header length) */ + + DescriptorLength = AcpiUtGetResourceLength (Aml); + + /* Determine if this is a small or large resource */ + + if (*((UINT8 *) Aml) & ACPI_RESOURCE_NAME_LARGE) + { + DescriptorLength += sizeof (AML_RESOURCE_LARGE_HEADER); + } + else + { + DescriptorLength += sizeof (AML_RESOURCE_SMALL_HEADER); + } + + return (DescriptorLength); +} + + +/******************************************************************************* + * * FUNCTION: AcpiUtGetResourceEndTag * * PARAMETERS: ObjDesc - The resource template buffer object * * RETURN: Pointer to the end tag * - * DESCRIPTION: Find the END_TAG resource descriptor in a resource template + * DESCRIPTION: Find the END_TAG resource descriptor in an AML resource template * ******************************************************************************/ @@ -1517,41 +1130,30 @@ UINT8 * AcpiUtGetResourceEndTag ( ACPI_OPERAND_OBJECT *ObjDesc) { - UINT8 BufferByte; - UINT8 *Buffer; - UINT8 *EndBuffer; + UINT8 *Aml; + UINT8 *EndAml; + + Aml = ObjDesc->Buffer.Pointer; + EndAml = Aml + ObjDesc->Buffer.Length; - Buffer = ObjDesc->Buffer.Pointer; - EndBuffer = Buffer + ObjDesc->Buffer.Length; + /* Walk the resource template, one descriptor per loop */ - while (Buffer < EndBuffer) + while (Aml < EndAml) { - BufferByte = *Buffer; - if (BufferByte & ACPI_RDESC_TYPE_MASK) + if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG) { - /* Large Descriptor - Length is next 2 bytes */ + /* Found the end_tag descriptor, all done */ - Buffer += ((*(Buffer+1) | (*(Buffer+2) << 8)) + 3); + return (Aml); } - else - { - /* Small Descriptor. End Tag will be found here */ - - if ((BufferByte & ACPI_RDESC_SMALL_MASK) == ACPI_RDESC_TYPE_END_TAG) - { - /* Found the end tag descriptor, all done. */ - - return (Buffer); - } - /* Length is in the header */ + /* Point to the next resource descriptor */ - Buffer += ((BufferByte & 0x07) + 1); - } + Aml += AcpiUtGetResourceLength (Aml); } - /* End tag not found */ + /* End tag was not found */ return (NULL); } @@ -1564,7 +1166,6 @@ AcpiUtGetResourceEndTag ( * PARAMETERS: ModuleName - Caller's module name (for error output) * LineNumber - Caller's line number (for error output) * ComponentId - Caller's component ID (for error output) - * Message - Error message to use on failure * * RETURN: None * @@ -1579,7 +1180,6 @@ AcpiUtReportError ( UINT32 ComponentId) { - AcpiOsPrintf ("%8s-%04d: *** Error: ", ModuleName, LineNumber); } @@ -1591,7 +1191,6 @@ AcpiUtReportError ( * PARAMETERS: ModuleName - Caller's module name (for error output) * LineNumber - Caller's line number (for error output) * ComponentId - Caller's component ID (for error output) - * Message - Error message to use on failure * * RETURN: None * @@ -1617,7 +1216,6 @@ AcpiUtReportWarning ( * PARAMETERS: ModuleName - Caller's module name (for error output) * LineNumber - Caller's line number (for error output) * ComponentId - Caller's component ID (for error output) - * Message - Error message to use on failure * * RETURN: None * diff --git a/sys/contrib/dev/acpica/utmutex.c b/sys/contrib/dev/acpica/utmutex.c new file mode 100644 index 0000000..e685511 --- /dev/null +++ b/sys/contrib/dev/acpica/utmutex.c @@ -0,0 +1,474 @@ +/******************************************************************************* + * + * Module Name: utmutex - local mutex support + * $Revision: 1.3 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTMUTEX_C__ + +#include <contrib/dev/acpica/acpi.h> + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utmutex") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtCreateMutex ( + ACPI_MUTEX_HANDLE MutexId); + +static ACPI_STATUS +AcpiUtDeleteMutex ( + ACPI_MUTEX_HANDLE MutexId); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMutexInitialize + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Create the system mutex objects. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtMutexInitialize ( + void) +{ + UINT32 i; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE ("UtMutexInitialize"); + + + /* + * Create each of the predefined mutex objects + */ + for (i = 0; i < NUM_MUTEX; i++) + { + Status = AcpiUtCreateMutex (i); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + Status = AcpiOsCreateLock (&AcpiGbl_GpeLock); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMutexTerminate + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete all of the system mutex objects. + * + ******************************************************************************/ + +void +AcpiUtMutexTerminate ( + void) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE ("UtMutexTerminate"); + + + /* + * Delete each predefined mutex object + */ + for (i = 0; i < NUM_MUTEX; i++) + { + (void) AcpiUtDeleteMutex (i); + } + + AcpiOsDeleteLock (AcpiGbl_GpeLock); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateMutex + * + * PARAMETERS: MutexID - ID of the mutex to be created + * + * RETURN: Status + * + * DESCRIPTION: Create a mutex object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCreateMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_U32 ("UtCreateMutex", MutexId); + + + if (MutexId > MAX_MUTEX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!AcpiGbl_MutexInfo[MutexId].Mutex) + { + Status = AcpiOsCreateSemaphore (1, 1, + &AcpiGbl_MutexInfo[MutexId].Mutex); + AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + AcpiGbl_MutexInfo[MutexId].UseCount = 0; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteMutex + * + * PARAMETERS: MutexID - ID of the mutex to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Delete a mutex object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtDeleteMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_U32 ("UtDeleteMutex", MutexId); + + + if (MutexId > MAX_MUTEX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiOsDeleteSemaphore (AcpiGbl_MutexInfo[MutexId].Mutex); + + AcpiGbl_MutexInfo[MutexId].Mutex = NULL; + AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAcquireMutex + * + * PARAMETERS: MutexID - ID of the mutex to be acquired + * + * RETURN: Status + * + * DESCRIPTION: Acquire a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAcquireMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status; + UINT32 ThisThreadId; + + + ACPI_FUNCTION_NAME ("UtAcquireMutex"); + + + if (MutexId > MAX_MUTEX) + { + return (AE_BAD_PARAMETER); + } + + ThisThreadId = AcpiOsGetThreadId (); + +#ifdef ACPI_MUTEX_DEBUG + { + UINT32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than or equal to this one. If so, the thread has violated + * the mutex ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = MutexId; i < MAX_MUTEX; i++) + { + if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId) + { + if (i == MutexId) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Mutex [%s] already acquired by this thread [%X]\n", + AcpiUtGetMutexName (MutexId), ThisThreadId)); + + return (AE_ALREADY_ACQUIRED); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid acquire order: Thread %X owns [%s], wants [%s]\n", + ThisThreadId, AcpiUtGetMutexName (i), + AcpiUtGetMutexName (MutexId))); + + return (AE_ACQUIRE_DEADLOCK); + } + } + } +#endif + + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, + "Thread %X attempting to acquire Mutex [%s]\n", + ThisThreadId, AcpiUtGetMutexName (MutexId))); + + Status = AcpiOsWaitSemaphore (AcpiGbl_MutexInfo[MutexId].Mutex, + 1, ACPI_WAIT_FOREVER); + if (ACPI_SUCCESS (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", + ThisThreadId, AcpiUtGetMutexName (MutexId))); + + AcpiGbl_MutexInfo[MutexId].UseCount++; + AcpiGbl_MutexInfo[MutexId].ThreadId = ThisThreadId; + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Thread %X could not acquire Mutex [%s] %s\n", + ThisThreadId, AcpiUtGetMutexName (MutexId), + AcpiFormatException (Status))); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtReleaseMutex + * + * PARAMETERS: MutexID - ID of the mutex to be released + * + * RETURN: Status + * + * DESCRIPTION: Release a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtReleaseMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status; + UINT32 ThisThreadId; + + + ACPI_FUNCTION_NAME ("UtReleaseMutex"); + + + ThisThreadId = AcpiOsGetThreadId (); + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, + "Thread %X releasing Mutex [%s]\n", ThisThreadId, + AcpiUtGetMutexName (MutexId))); + + if (MutexId > MAX_MUTEX) + { + return (AE_BAD_PARAMETER); + } + + /* + * Mutex must be acquired in order to release it! + */ + if (AcpiGbl_MutexInfo[MutexId].ThreadId == ACPI_MUTEX_NOT_ACQUIRED) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Mutex [%s] is not acquired, cannot release\n", + AcpiUtGetMutexName (MutexId))); + + return (AE_NOT_ACQUIRED); + } + +#ifdef ACPI_MUTEX_DEBUG + { + UINT32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than this one. If so, the thread has violated the mutex + * ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = MutexId; i < MAX_MUTEX; i++) + { + if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId) + { + if (i == MutexId) + { + continue; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Invalid release order: owns [%s], releasing [%s]\n", + AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId))); + + return (AE_RELEASE_DEADLOCK); + } + } + } +#endif + + /* Mark unlocked FIRST */ + + AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + + Status = AcpiOsSignalSemaphore (AcpiGbl_MutexInfo[MutexId].Mutex, 1); + + if (ACPI_FAILURE (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Thread %X could not release Mutex [%s] %s\n", + ThisThreadId, AcpiUtGetMutexName (MutexId), + AcpiFormatException (Status))); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X released Mutex [%s]\n", + ThisThreadId, AcpiUtGetMutexName (MutexId))); + } + + return (Status); +} + + diff --git a/sys/contrib/dev/acpica/utobject.c b/sys/contrib/dev/acpica/utobject.c index b7b69cf..d63250b 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: 90 $ + * $Revision: 1.97 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -124,6 +124,25 @@ #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utobject") +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtGetSimpleObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_SIZE *ObjLength); + +static ACPI_STATUS +AcpiUtGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_SIZE *ObjLength); + +static ACPI_STATUS +AcpiUtGetElementLength ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + /******************************************************************************* * @@ -134,7 +153,7 @@ * ComponentId - Component type of caller * Type - ACPI Type of the new object * - * RETURN: Object - The new object. Null on failure + * RETURN: A new internal object, null on failure * * DESCRIPTION: Create and initialize a new internal object. * @@ -157,7 +176,8 @@ AcpiUtCreateInternalObjectDbg ( ACPI_OPERAND_OBJECT *SecondObject; - ACPI_FUNCTION_TRACE_STR ("UtCreateInternalObjectDbg", AcpiUtGetTypeName (Type)); + ACPI_FUNCTION_TRACE_STR ("UtCreateInternalObjectDbg", + AcpiUtGetTypeName (Type)); /* Allocate the raw object descriptor */ @@ -175,7 +195,8 @@ AcpiUtCreateInternalObjectDbg ( /* These types require a secondary object */ - SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId); + SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName, + LineNumber, ComponentId); if (!SecondObject) { AcpiUtDeleteObjectDesc (Object); @@ -215,7 +236,7 @@ AcpiUtCreateInternalObjectDbg ( * * PARAMETERS: BufferSize - Size of buffer to be created * - * RETURN: Pointer to a new Buffer object + * RETURN: Pointer to a new Buffer object, null on failure * * DESCRIPTION: Create a fully initialized buffer object * @@ -272,9 +293,9 @@ AcpiUtCreateBufferObject ( * * FUNCTION: AcpiUtCreateStringObject * - * PARAMETERS: StringSize - Size of string to be created. Does not - * include NULL terminator, this is added - * automatically. + * PARAMETERS: StringSize - Size of string to be created. Does not + * include NULL terminator, this is added + * automatically. * * RETURN: Pointer to a new String object * @@ -331,7 +352,9 @@ AcpiUtCreateStringObject ( * * PARAMETERS: Object - Object to be validated * - * RETURN: Validate a pointer to be an ACPI_OPERAND_OBJECT + * RETURN: TRUE if object is valid, FALSE otherwise + * + * DESCRIPTION: Validate a pointer to be an ACPI_OPERAND_OBJECT * ******************************************************************************/ @@ -399,7 +422,7 @@ AcpiUtAllocateObjectDescDbg ( ACPI_FUNCTION_TRACE ("UtAllocateObjectDescDbg"); - Object = AcpiUtAcquireFromCache (ACPI_MEM_LIST_OPERAND); + Object = AcpiOsAcquireObject (AcpiGbl_OperandCache); if (!Object) { _ACPI_REPORT_ERROR (ModuleName, LineNumber, ComponentId, @@ -448,33 +471,7 @@ AcpiUtDeleteObjectDesc ( return_VOID; } - AcpiUtReleaseToCache (ACPI_MEM_LIST_OPERAND, Object); - - return_VOID; -} - - -/******************************************************************************* - * - * FUNCTION: AcpiUtDeleteObjectCache - * - * PARAMETERS: None - * - * RETURN: None - * - * DESCRIPTION: Purge the global state object cache. Used during subsystem - * termination. - * - ******************************************************************************/ - -void -AcpiUtDeleteObjectCache ( - void) -{ - ACPI_FUNCTION_TRACE ("UtDeleteObjectCache"); - - - AcpiUtDeleteGenericCache (ACPI_MEM_LIST_OPERAND); + (void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object); return_VOID; } @@ -483,8 +480,8 @@ AcpiUtDeleteObjectCache ( * * FUNCTION: AcpiUtGetSimpleObjectSize * - * PARAMETERS: *InternalObject - Pointer to the object we are examining - * *ObjLength - Where the length is returned + * PARAMETERS: InternalObject - An ACPI operand object + * ObjLength - Where the length is returned * * RETURN: Status * @@ -496,7 +493,7 @@ AcpiUtDeleteObjectCache ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtGetSimpleObjectSize ( ACPI_OPERAND_OBJECT *InternalObject, ACPI_SIZE *ObjLength) @@ -508,8 +505,10 @@ AcpiUtGetSimpleObjectSize ( ACPI_FUNCTION_TRACE_PTR ("UtGetSimpleObjectSize", InternalObject); - /* Handle a null object (Could be a uninitialized package element -- which is legal) */ - + /* + * Handle a null object (Could be a uninitialized package + * element -- which is legal) + */ if (!InternalObject) { *ObjLength = 0; @@ -568,7 +567,8 @@ AcpiUtGetSimpleObjectSize ( * Get the actual length of the full pathname to this object. * The reference will be converted to the pathname to the object */ - Length += ACPI_ROUND_UP_TO_NATIVE_WORD (AcpiNsGetPathnameLength (InternalObject->Reference.Node)); + Length += ACPI_ROUND_UP_TO_NATIVE_WORD ( + AcpiNsGetPathnameLength (InternalObject->Reference.Node)); break; default: @@ -618,7 +618,7 @@ AcpiUtGetSimpleObjectSize ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtGetElementLength ( UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, @@ -672,8 +672,8 @@ AcpiUtGetElementLength ( * * FUNCTION: AcpiUtGetPackageObjectSize * - * PARAMETERS: *InternalObject - Pointer to the object we are examining - * *ObjLength - Where the length is returned + * PARAMETERS: InternalObject - An ACPI internal object + * ObjLength - Where the length is returned * * RETURN: Status * @@ -685,7 +685,7 @@ AcpiUtGetElementLength ( * ******************************************************************************/ -ACPI_STATUS +static ACPI_STATUS AcpiUtGetPackageObjectSize ( ACPI_OPERAND_OBJECT *InternalObject, ACPI_SIZE *ObjLength) @@ -727,8 +727,8 @@ AcpiUtGetPackageObjectSize ( * * FUNCTION: AcpiUtGetObjectSize * - * PARAMETERS: *InternalObject - Pointer to the object we are examining - * *ObjLength - Where the length will be returned + * PARAMETERS: InternalObject - An ACPI internal object + * ObjLength - Where the length will be returned * * RETURN: Status * @@ -738,7 +738,7 @@ AcpiUtGetPackageObjectSize ( ******************************************************************************/ ACPI_STATUS -AcpiUtGetObjectSize( +AcpiUtGetObjectSize ( ACPI_OPERAND_OBJECT *InternalObject, ACPI_SIZE *ObjLength) { diff --git a/sys/contrib/dev/acpica/utstate.c b/sys/contrib/dev/acpica/utstate.c new file mode 100644 index 0000000..bd049ec --- /dev/null +++ b/sys/contrib/dev/acpica/utstate.c @@ -0,0 +1,457 @@ +/******************************************************************************* + * + * Module Name: utstate - state object support procedures + * $Revision: 1.2 $ + * + ******************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + + +#define __UTSTATE_C__ + +#include <contrib/dev/acpica/acpi.h> + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utstate") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreatePkgStateAndPush + * + * PARAMETERS: Object - Object to be added to the new state + * Action - Increment/Decrement + * StateList - List the state will be added to + * + * RETURN: Status + * + * DESCRIPTION: Create a new state and push it + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreatePkgStateAndPush ( + void *InternalObject, + void *ExternalObject, + UINT16 Index, + ACPI_GENERIC_STATE **StateList) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_ENTRY (); + + + State = AcpiUtCreatePkgState (InternalObject, ExternalObject, Index); + if (!State) + { + return (AE_NO_MEMORY); + } + + AcpiUtPushGenericState (StateList, State); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPushGenericState + * + * PARAMETERS: ListHead - Head of the state stack + * State - State object to push + * + * RETURN: None + * + * DESCRIPTION: Push a state object onto a state stack + * + ******************************************************************************/ + +void +AcpiUtPushGenericState ( + ACPI_GENERIC_STATE **ListHead, + ACPI_GENERIC_STATE *State) +{ + ACPI_FUNCTION_TRACE ("UtPushGenericState"); + + + /* Push the state object onto the front of the list (stack) */ + + State->Common.Next = *ListHead; + *ListHead = State; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPopGenericState + * + * PARAMETERS: ListHead - Head of the state stack + * + * RETURN: The popped state object + * + * DESCRIPTION: Pop a state object from a state stack + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtPopGenericState ( + ACPI_GENERIC_STATE **ListHead) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE ("UtPopGenericState"); + + + /* Remove the state object at the head of the list (stack) */ + + State = *ListHead; + if (State) + { + /* Update the list head */ + + *ListHead = State->Common.Next; + } + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateGenericState + * + * PARAMETERS: None + * + * RETURN: The new state object. NULL on failure. + * + * DESCRIPTION: Create a generic state object. Attempt to obtain one from + * the global state cache; If none available, create a new one. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreateGenericState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_ENTRY (); + + + State = AcpiOsAcquireObject (AcpiGbl_StateCache); + if (State) + { + /* Initialize */ + State->Common.DataType = ACPI_DESC_TYPE_STATE; + } + + return (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateThreadState + * + * PARAMETERS: None + * + * RETURN: New Thread State. NULL on failure + * + * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used + * to track per-thread info during method execution + * + ******************************************************************************/ + +ACPI_THREAD_STATE * +AcpiUtCreateThreadState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE ("UtCreateThreadState"); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + State->Common.DataType = ACPI_DESC_TYPE_STATE_THREAD; + State->Thread.ThreadId = AcpiOsGetThreadId (); + + return_PTR ((ACPI_THREAD_STATE *) State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateUpdateState + * + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create an "Update State" - a flavor of the generic state used + * to update reference counts and delete complex objects such + * as packages. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreateUpdateState ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE_PTR ("UtCreateUpdateState", Object); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + State->Common.DataType = ACPI_DESC_TYPE_STATE_UPDATE; + State->Update.Object = Object; + State->Update.Value = Action; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreatePkgState + * + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create a "Package State" + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreatePkgState ( + void *InternalObject, + void *ExternalObject, + UINT16 Index) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE_PTR ("UtCreatePkgState", InternalObject); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + State->Common.DataType = ACPI_DESC_TYPE_STATE_PACKAGE; + State->Pkg.SourceObject = (ACPI_OPERAND_OBJECT *) InternalObject; + State->Pkg.DestObject = ExternalObject; + State->Pkg.Index = Index; + State->Pkg.NumPackages = 1; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateControlState + * + * PARAMETERS: None + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create a "Control State" - a flavor of the generic state used + * to support nested IF/WHILE constructs in the AML. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreateControlState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE ("UtCreateControlState"); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the control struct */ + + State->Common.DataType = ACPI_DESC_TYPE_STATE_CONTROL; + State->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteGenericState + * + * PARAMETERS: State - The state object to be deleted + * + * RETURN: None + * + * DESCRIPTION: Put a state object back into the global state cache. The object + * is not actually freed at this time. + * + ******************************************************************************/ + +void +AcpiUtDeleteGenericState ( + ACPI_GENERIC_STATE *State) +{ + ACPI_FUNCTION_TRACE ("UtDeleteGenericState"); + + + (void) AcpiOsReleaseObject (AcpiGbl_StateCache, State); + return_VOID; +} + + diff --git a/sys/contrib/dev/acpica/utxface.c b/sys/contrib/dev/acpica/utxface.c index fb79651..b6f5076 100644 --- a/sys/contrib/dev/acpica/utxface.c +++ b/sys/contrib/dev/acpica/utxface.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: utxface - External interfaces for "global" ACPI functions - * $Revision: 106 $ + * $Revision: 1.112 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. * All rights reserved. * * 2. License @@ -120,8 +120,6 @@ #include <contrib/dev/acpica/acpi.h> #include <contrib/dev/acpica/acevents.h> #include <contrib/dev/acpica/acnamesp.h> -#include <contrib/dev/acpica/acparser.h> -#include <contrib/dev/acpica/acdispat.h> #include <contrib/dev/acpica/acdebug.h> #define _COMPONENT ACPI_UTILITIES @@ -147,16 +145,12 @@ AcpiInitializeSubsystem ( { ACPI_STATUS Status; + ACPI_FUNCTION_TRACE ("AcpiInitializeSubsystem"); ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ()); - - /* Initialize all globals used by the subsystem */ - - AcpiUtInitGlobals (); - /* Initialize the OS-Dependent layer */ Status = AcpiOsInitialize (); @@ -167,6 +161,10 @@ AcpiInitializeSubsystem ( return_ACPI_STATUS (Status); } + /* Initialize all globals used by the subsystem */ + + AcpiUtInitGlobals (); + /* Create the default mutex objects */ Status = AcpiUtMutexInitialize (); @@ -181,7 +179,6 @@ AcpiInitializeSubsystem ( * Initialize the namespace manager and * the root of the namespace tree */ - Status = AcpiNsRootInitialize (); if (ACPI_FAILURE (Status)) { @@ -190,7 +187,6 @@ AcpiInitializeSubsystem ( return_ACPI_STATUS (Status); } - /* If configured, initialize the AML debugger */ ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ()); @@ -228,7 +224,8 @@ AcpiEnableSubsystem ( */ if (!(Flags & ACPI_NO_HARDWARE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI hardware\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI hardware\n")); Status = AcpiHwInitialize (); if (ACPI_FAILURE (Status)) @@ -260,7 +257,8 @@ AcpiEnableSubsystem ( */ if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Installing default address space handlers\n")); Status = AcpiEvInstallRegionHandlers (); if (ACPI_FAILURE (Status)) @@ -272,13 +270,15 @@ AcpiEnableSubsystem ( /* * Initialize ACPI Event handling (Fixed and General Purpose) * - * NOTE: We must have the hardware AND events initialized before we can execute - * ANY control methods SAFELY. Any control method can require ACPI hardware - * support, so the hardware MUST be initialized before execution! + * NOTE: We must have the hardware AND events initialized before we can + * execute ANY control methods SAFELY. Any control method can require + * ACPI hardware support, so the hardware MUST be initialized before + * execution! */ if (!(Flags & ACPI_NO_EVENT_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI events\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI events\n")); Status = AcpiEvInitializeEvents (); if (ACPI_FAILURE (Status)) @@ -291,7 +291,8 @@ AcpiEnableSubsystem ( if (!(Flags & ACPI_NO_HANDLER_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL handlers\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Installing SCI/GL handlers\n")); Status = AcpiEvInstallXruptHandlers (); if (ACPI_FAILURE (Status)) @@ -335,7 +336,8 @@ AcpiInitializeObjects ( */ if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Executing _REG OpRegion methods\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Executing _REG OpRegion methods\n")); Status = AcpiEvInitializeOpRegions (); if (ACPI_FAILURE (Status)) @@ -351,7 +353,8 @@ AcpiInitializeObjects ( */ if (!(Flags & ACPI_NO_OBJECT_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Completing Initialization of ACPI Objects\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Completing Initialization of ACPI Objects\n")); Status = AcpiNsInitializeObjects (); if (ACPI_FAILURE (Status)) @@ -366,7 +369,8 @@ AcpiInitializeObjects ( */ if (!(Flags & ACPI_NO_DEVICE_INIT)) { - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI Devices\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI Devices\n")); Status = AcpiNsInitializeDevices (); if (ACPI_FAILURE (Status)) @@ -400,7 +404,8 @@ AcpiInitializeObjects ( ******************************************************************************/ ACPI_STATUS -AcpiTerminate (void) +AcpiTerminate ( + void) { ACPI_STATUS Status; @@ -436,7 +441,7 @@ AcpiTerminate (void) } -/***************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiSubsystemStatus * @@ -445,14 +450,16 @@ AcpiTerminate (void) * RETURN: Status of the ACPI subsystem * * DESCRIPTION: Other drivers that use the ACPI subsystem should call this - * before making any other calls, to ensure the subsystem initial- - * ized successfully. + * before making any other calls, to ensure the subsystem + * initialized successfully. * - ****************************************************************************/ + ******************************************************************************/ ACPI_STATUS -AcpiSubsystemStatus (void) +AcpiSubsystemStatus ( + void) { + if (AcpiGbl_StartupFlags & ACPI_INITIALIZED_OK) { return (AE_OK); @@ -464,13 +471,12 @@ AcpiSubsystemStatus (void) } -/****************************************************************************** +/******************************************************************************* * * FUNCTION: AcpiGetSystemInfo * - * PARAMETERS: OutBuffer - a pointer to a buffer to receive the - * resources for the device - * BufferLength - the number of bytes available in the buffer + * PARAMETERS: OutBuffer - A buffer to receive the resources for the + * device * * RETURN: Status - the status of the call * @@ -488,8 +494,8 @@ AcpiGetSystemInfo ( ACPI_BUFFER *OutBuffer) { ACPI_SYSTEM_INFO *InfoPtr; - UINT32 i; ACPI_STATUS Status; + UINT32 i; ACPI_FUNCTION_TRACE ("AcpiGetSystemInfo"); @@ -564,6 +570,7 @@ AcpiGetSystemInfo ( * FUNCTION: AcpiInstallInitializationHandler * * PARAMETERS: Handler - Callback procedure + * Function - Not (currently) used, see below * * RETURN: Status * @@ -607,15 +614,14 @@ AcpiInstallInitializationHandler ( ****************************************************************************/ ACPI_STATUS -AcpiPurgeCachedObjects (void) +AcpiPurgeCachedObjects ( + void) { ACPI_FUNCTION_TRACE ("AcpiPurgeCachedObjects"); - - AcpiUtDeleteGenericStateCache (); - AcpiUtDeleteObjectCache (); - AcpiDsDeleteWalkStateCache (); - AcpiPsDeleteParseCache (); - + (void) AcpiOsPurgeCache (AcpiGbl_StateCache); + (void) AcpiOsPurgeCache (AcpiGbl_OperandCache); + (void) AcpiOsPurgeCache (AcpiGbl_PsNodeCache); + (void) AcpiOsPurgeCache (AcpiGbl_PsNodeExtCache); return_ACPI_STATUS (AE_OK); } |