diff --git a/sys/contrib/dev/acpica/CHANGES.txt b/sys/contrib/dev/acpica/CHANGES.txt index f87c9685600d..3b82a1573124 100644 --- a/sys/contrib/dev/acpica/CHANGES.txt +++ b/sys/contrib/dev/acpica/CHANGES.txt @@ -1,2930 +1,3203 @@ +---------------------------------------- +15 November 2002. Summary of changes for version 20021115. + +1) ACPI CA Core Subsystem: + +Fixed a memory leak problem where an error during resolution +of method arguments during a method invocation from another +method failed to cleanup properly by deleting all successfully +resolved argument objects. + +Fixed a problem where the target of the Index() operator was +not correctly constructed if the source object was a package. +This problem has not been detected because the use of a target +operand with Index() is very rare. + +Fixed a problem with the Index() operator where an attempt was +made to delete the operand objects twice. + +Fixed a problem where an attempt was made to delete an operand +twice during execution of the CondRefOf() operator if the +target did not exist. + +Implemented the first of perhaps several internal create +object functions that create and initialize a specific object +type. This consolidates duplicated code wherever the object +is created, thus shrinking the size of the subsystem. + +Implemented improved debug/error messages for errors that +occur during nested method invocations. All executing method +pathnames are displayed (with the error) as the call stack is +unwound - thus simplifying debug. + +Fixed a problem introduced in the 10/02 release that caused +premature deletion of a buffer object if a buffer was used as +an ASL operand where an integer operand is required (Thus +causing an implicit object conversion from Buffer to Integer.) +The change in the 10/02 release was attempting to fix a memory +leak (albeit incorrectly.) + +Code and Data Size: Current 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: 71.9K Code, 9.1K Data, 81.0K Total + Debug Version: 153.1K Code, 63.3K Data, 216.4K Total + Current Release: + Non-Debug Version: 71.3K Code, 9.0K Data, 80.3K Total + Debug Version: 152.7K Code, 63.2K Data, 215.5K Total + + +2) Linux + +Changed the implementation of the ACPI semaphores to use +down() instead of down_interruptable(). It is important that +the execution of ACPI control methods not be interrupted by +signals. Methods must run to completion, or the system may be +left in an unknown/unstable state. + +Fixed a compilation error when CONFIG_SOFTWARE_SUSPEND is not +set. (Shawn Starr) + + +3) iASL Compiler/Disassembler + +Changed the default location of output files. All output +files are now placed in the current directory by default +instead of in the directory of the source file. This change +may affect some existing makefiles, but it brings the behavior +of the compiler in line with other similar tools. The +location of the output files can be overridden with the -p +command line switch. + + +---------------------------------------- +11 November 2002. Summary of changes for version 20021111. + + +0) ACPI Specification 2.0B is released and is now available +at: http://www.acpi.info/index.html + + +1) ACPI CA Core Subsystem: + +Implemented support for the ACPI 2.0 SMBus Operation Regions. +This includes the early detection and handoff of the request +to the SMBus region handler (avoiding all of the complex field +support code), and support for the bidirectional return packet +from an SMBus write operation. This paves the way for the +development of SMBus drivers in each host operating system. + +Fixed a problem where the semaphore WAIT_FOREVER constant was +defined as 32 bits, but must be 16 bits according to the ACPI +specification. This had the side effect of causing ASL +Mutex/Event timeouts even though the ASL code requested a wait +forever. Changed all internal references to the ACPI timeout +parameter to 16 bits to prevent future problems. Changed the +name of WAIT_FOREVER to ACPI_WAIT_FOREVER. + +Code and Data Size: Current 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: 71.4K Code, 9.0K Data, 80.4K Total + Debug Version: 152.3K Code, 63.0K Data, 215.3K Total + Current Release: + Non-Debug Version: 71.9K Code, 9.1K Data, 81.0K Total + Debug Version: 153.1K Code, 63.3K Data, 216.4K Total + + +2) Linux + +Module loading/unloading fixes (John Cagle) + + +3) iASL Compiler/Disassembler + +Added support for the SMBBlockProcessCall keyword (ACPI 2.0) + +Implemented support for the disassembly of all SMBus protocol +keywords (SMBQuick, SMBWord, etc.) + +---------------------------------------- +01 November 2002. Summary of changes for version 20021101. + + +1) ACPI CA Core Subsystem: + +Fixed a problem where platforms that have a GPE1 block but no +GPE0 block were not handled correctly. This resulted in a +"GPE overlap" error message. GPE0 is no longer required. + +Removed code added in the previous release that inserted nodes +into the namespace in alphabetical order. This caused some +side-effects on various machines. The root cause of the +problem is still under investigation since in theory, the +internal ordering of the namespace nodes should not matter. + +Enhanced error reporting for the case where a named object is +not found during control method execution. The full ACPI +namepath (name reference) of the object that was not found is +displayed in this case. + +Note: as a result of the overhaul of the namespace object +types in the previous release, the namespace nodes for the +predefined scopes (_TZ, _PR, etc.) are now of the type +ACPI_TYPE_LOCAL_SCOPE instead of ACPI_TYPE_ANY. This +simplifies the namespace management code but may affect code +that walks the namespace tree looking for specific object +types. + +Code and Data Size: Current 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: 70.7K Code, 8.6K Data, 79.3K Total + Debug Version: 151.7K Code, 62.4K Data, 214.1K Total + Current Release: + Non-Debug Version: 71.4K Code, 9.0K Data, 80.4K Total + Debug Version: 152.3K Code, 63.0K Data, 215.3K Total + + +2) Linux + +Fixed a problem introduced in the previous release where the +Processor and Thermal objects were not recognized and +installed in /proc. This was related to the scope type change +described above. + + +3) iASL Compiler/Disassembler + +Implemented the -g option to get all of the required ACPI +tables from the registry and save them to files (Windows +version of the compiler only.) The required tables are the +FADT, FACS, and DSDT. + +Added ACPI table checksum validation during table disassembly +in order to catch corrupted tables. + + +---------------------------------------- +22 October 2002. Summary of changes for version 20021022. + +1) ACPI CA Core Subsystem: + +Implemented a restriction on the Scope operator that the +target must already exist in the namespace at the time the +operator is encountered (during table load or method +execution). In other words, forward references are not +allowed and Scope() cannot create a new object. This changes +the previous behavior where the interpreter would create the +name if not found. This new behavior correctly enables the +search-to-root algorithm during namespace lookup of the target +name. Because of this upsearch, this fixes the known Compaq +_SB_.OKEC problem and makes both the AML interpreter and iASL +compiler compatible with other ACPI implementations. + +Completed a major overhaul of the internal ACPI object types +for the ACPI Namespace and the associated operand objects. +Many of these types had become obsolete with the introduction +of the two-pass namespace load. This cleanup simplifies the +code and makes the entire namespace load mechanism much +clearer and easier to understand. + +Improved debug output for tracking scope opening/closing to +help diagnose scoping issues. The old scope name as well as +the new scope name are displayed. Also improved error +messages for problems with ASL Mutex objects and error +messages for GPE problems. + +Cleaned up the namespace dump code, removed obsolete code. + +All string output (for all namespace/object dumps) now uses +the common ACPI string output procedure which handles escapes +properly and does not emit non-printable characters. + +Fixed some issues with constants in the 64-bit version of the +local C library (utclib.c) + + +2) Linux + +EC Driver: No longer attempts to acquire the Global Lock at +interrupt level. + + +3) iASL Compiler/Disassembler + +Implemented ACPI 2.0B grammar change that disallows all Type 1 +and 2 opcodes outside of a control method. This means that +the "executable" operators (versus the "namespace" operators) +cannot be used at the table level; they can only be used +within a control method. + +Implemented the restriction on the Scope() operator where the +target must already exist in the namespace at the time the +operator is encountered (during ASL compilation). In other +words, forward references are not allowed and Scope() cannot +create a new object. This makes the iASL compiler compatible +with other ACPI implementations and makes the Scope() +implementation adhere to the ACPI specification. + +Fixed a problem where namepath optimization for the Alias +operator was optimizing the wrong path (of the two namepaths.) +This caused a "Missing alias link" error message. + +Fixed a problem where an "unknown reserved name" warning could +be incorrectly generated for names like "_SB" when the +trailing underscore is not used in the original ASL. + +Fixed a problem where the reserved name check did not handle +NamePaths with multiple NameSegs correctly. The first nameseg +of the NamePath was examined instead of the last NameSeg. + + ---------------------------------------- 02 October 2002. Summary of changes for this release. 1) ACPI CA Core Subsystem version 20021002: Fixed a problem where a store/copy of a string to an existing string did not always set the string length properly in the String object. Fixed a reported problem with the ToString operator where the behavior was identical to the ToHexString operator instead of just simply converting a raw buffer to a string data type. Fixed a problem where CopyObject and the other "explicit" conversion operators were not updating the internal namespace node type as part of the store operation. Fixed a memory leak during implicit source operand conversion where the original object was not deleted if it was converted to a new object of a different type. Enhanced error messages for all problems associated with namespace lookups. Common procedure generates and prints the lookup name as well as the formatted status. Completed implementation of a new design for the Alias support within the namespace. The existing design did not handle the case where a new object was assigned to one of the two names due to the use of an explicit conversion operator, resulting in the two names pointing to two different objects. The new design simply points the Alias name to the original name node - not to the object. This results in a level of indirection that must be handled in the name resolution mechanism. Code and Data Size: Current 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 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: 69.6K Code, 8.3K Data, 77.9K Total Debug Version: 150.0K Code, 61.7K Data, 211.7K Total Current Release: Non-Debug Version: 70.7K Code, 8.6K Data, 79.3K Total Debug Version: 151.7K Code, 62.4K Data, 214.1K Total 2) Linux Initialize thermal driver's timer before it is used. (Knut Neumann) Allow handling negative celsius values. (Kochi Takayoshi) Fix thermal management and make trip points. R/W (Pavel Machek) Fix /proc/acpi/sleep. (P. Christeas) IA64 fixes. (David Mosberger) Fix reversed logic in blacklist code. (Sergio Monteiro Basto) Replace ACPI_DEBUG define with ACPI_DEBUG_OUTPUT. (Dominik Brodowski) 3) iASL Compiler/Disassembler Clarified some warning/error messages. ---------------------------------------- 18 September 2002. Summary of changes for this release. 1) ACPI CA Core Subsystem version 20020918: Fixed a reported problem with reference chaining (via the Index() and RefOf() operators) in the ObjectType() and SizeOf() operators. The definition of these operators includes the dereferencing of all chained references to return information on the base object. Fixed a problem with stores to indexed package elements - the existing code would not complete the store if an "implicit conversion" was not performed. In other words, if the existing object (package element) was to be replaced completely, the code didn't handle this case. Relaxed typechecking on the ASL "Scope" operator to allow the target name to refer to an object of type Integer, String, or Buffer, in addition to the scoping object types (Device, predefined Scopes, Processor, PowerResource, and ThermalZone.) This allows existing AML code that has workarounds for a bug in Windows to function properly. A warning is issued, however. This affects both the AML interpreter and the iASL compiler. Below is an example of this type of ASL code: Name(DEB,0x00) Scope(DEB) { Fixed some reported problems with 64-bit integer support in the local implementation of C library functions (clib.c) 2) Linux Use ACPI fix map region instead of IOAPIC region, since it is undefined in non-SMP. Ensure that the SCI has the proper polarity and trigger, even on systems that do not have an interrupt override entry in the MADT. 2.5 big driver reorganization (Pat Mochel) Use early table mapping code from acpitable.c (Andi Kleen) New blacklist entries (Andi Kleen) Blacklist improvements. Split blacklist code out into a separate file. Move checking the blacklist to very early. Previously, we would use ACPI tables, and then halfway through init, check the blacklist -- too late. Now, it's early enough to completely fall-back to non-ACPI. 3) iASL Compiler/Disassembler version 20020918: Fixed a problem where the typechecking code didn't know that an alias could point to a method. In other words, aliases were not being dereferenced during typechecking. ---------------------------------------- 29 August 2002. Summary of changes for this release. 1) ACPI CA Core Subsystem Version 20020829: If the target of a Scope() operator already exists, it must be an object type that actually opens a scope -- such as a Device, Method, Scope, etc. This is a fatal runtime error. Similar error check has been added to the iASL compiler also. Tightened up the namespace load to disallow multiple names in the same scope. This previously was allowed if both objects were of the same type. (i.e., a lookup was the same as entering a new name). 2) Linux Ensure that the ACPI interrupt has the proper trigger and polarity. local_irq_disable is extraneous. (Matthew Wilcox) Make "acpi=off" actually do what it says, and not use the ACPI interpreter *or* the tables. Added arch-neutral support for parsing SLIT and SRAT tables (Kochi Takayoshi) 3) iASL Compiler/Disassembler Version 20020829: Implemented namepath optimization for name declarations. For example, a declaration like "Method (\_SB_.ABCD)" would get optimized to "Method (ABCD)" if the declaration is within the \_SB_ scope. This optimization is in addition to the named reference path optimization first released in the previous version. This would seem to complete all possible optimizations for namepaths within the ASL/AML. If the target of a Scope() operator already exists, it must be an object type that actually opens a scope -- such as a Device, Method, Scope, etc. Implemented a check and warning for unreachable code in the same block below a Return() statement. Fixed a problem where the listing file was not generated if the compiler aborted if the maximum error count was exceeded (200). Fixed a problem where the typechecking of method return values was broken. This includes the check for a return value when the method is invoked as a TermArg (a return value is expected.) Fixed a reported problem where EOF conditions during a quoted string or comment caused a fault. ---------------------------------------- 15 August 2002. Summary of changes for this release. 1) ACPI CA Core Subsystem Version 20020815: Fixed a reported problem where a Store to a method argument that contains a reference did not perform the indirect store correctly. This problem was created during the conversion to the new reference object model - the indirect store to a method argument code was not updated to reflect the new model. Reworked the ACPI mode change code to better conform to ACPI 2.0, handle corner cases, and improve code legibility (Kochi Takayoshi) Fixed a problem with the pathname parsing for the carat (^) prefix. The heavy use of the carat operator by the new namepath optimization in the iASL compiler uncovered a problem with the AML interpreter handling of this prefix. In the case where one or more carats precede a single nameseg, the nameseg was treated as standalone and the search rule (to root) was inadvertently applied. This could cause both the iASL compiler and the interpreter to find the wrong object or to miss the error that should occur if the object does not exist at that exact pathname. Found and fixed the problem where the HP Pavilion DSDT would not load. This was a relatively minor tweak to the table loading code (a problem caused by the unexpected encounter with a method invocation not within a control method), but it does not solve the overall issue of the execution of AML code at the table level. This investigation is still ongoing. Code and Data Size: Current 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 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: 69.1K Code, 8.2K Data, 77.3K Total Debug Version: 149.4K Code, 61.6K Data, 211.0K Total Current Release: Non-Debug Version: 69.6K Code, 8.3K Data, 77.9K Total Debug Version: 150.0K Code, 61.7K Data, 211.7K Total 2) Linux Remove redundant slab.h include (Brad Hards) Fix several bugs in thermal.c (Herbert Nachtnebel) Make CONFIG_ACPI_BOOT work properly (Pavel Machek) Change acpi_system_suspend to use updated irq functions (Pavel Machek) Export acpi_get_firmware_table (Matthew Wilcox) Use proper root proc entry for ACPI (Kochi Takayoshi) Fix early-boot table parsing (Bjorn Helgaas) 3) iASL Compiler/Disassembler Reworked the compiler options to make them more consistent and to use two-letter options where appropriate. We were running out of sensible letters. This may break some makefiles, so check the current options list by invoking the compiler with no parameters. Completed the design and implementation of the ASL namepath optimization option for the compiler. This option optimizes all references to named objects to the shortest possible path. The first attempt tries to utilize a single nameseg (4 characters) and the "search-to-root" algorithm used by the interpreter. If that cannot be used (because either the name is not in the search path or there is a conflict with another object with the same name), the pathname is optimized using the carat prefix (usually a shorter string than specifying the entire path from the root.) Implemented support to obtain the DSDT from the Windows registry (when the disassembly option is specified with no input file). Added this code as the implementation for AcpiOsTableOverride in the Windows OSL. Migrated the 16-bit code (used in the AcpiDump utility) to scan memory for the DSDT to the AcpiOsTableOverride function in the DOS OSL to make the disassembler truly OS independent. Implemented a new option to disassemble and compile in one step. When used without an input filename, this option will grab the DSDT from the local machine, disassemble it, and compile it in one step. Added a warning message for invalid escapes (a backslash followed by any character other than the allowable escapes). This catches the quoted string error "\_SB_" (which should be "\\_SB_" ). Also, there are numerous instances in the ACPI specification where this error occurs. Added a compiler option to disable all optimizations. This is basically the "compatibility mode" because by using this option, the AML code will come out exactly the same as other ASL compilers. Added error messages for incorrectly ordered dependent resource functions. This includes: missing EndDependentFn macro at end of dependent resource list, nested dependent function macros (both start and end), and missing StartDependentFn macro. These are common errors that should be caught at compile time. Implemented _OSI support for the disassembler and compiler. _OSI must be included in the namespace for proper disassembly (because the disassembler must know the number of arguments.) Added an "optimization" message type that is optional (off by default). This message is used for all optimizations - including constant folding, integer optimization, and namepath optimization. ---------------------------------------- 25 July 2002. Summary of changes for this release. 1) ACPI CA Core Subsystem Version 20020725: The AML Disassembler has been enhanced to produce compilable ASL code and has been integrated into the iASL compiler (see below) as well as the single-step disassembly for the AML debugger and the disassembler for the AcpiDump utility. All ACPI 2.0A opcodes, resource templates and macros are fully supported. The disassembler has been tested on over 30 different AML files, producing identical AML when the resulting disassembled ASL file is recompiled with the same ASL compiler. Modified the Resource Manager to allow zero interrupts and zero dma channels during the GetCurrentResources call. This was causing problems on some platforms. Added the AcpiOsRedirectOutput interface to the OSL to simplify output redirection for the AcpiOsPrintf and AcpiOsVprintf interfaces. Code and Data Size: Current 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 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: 68.7K Code, 7.4K Data, 76.1K Total Debug Version: 142.9K Code, 58.7K Data, 201.6K Total Current Release: Non-Debug Version: 69.1K Code, 8.2K Data, 77.3K Total Debug Version: 149.4K Code, 61.6K Data, 211.0K Total 2) Linux Fixed a panic in the EC driver (Dominik Brodowski) Implemented checksum of the R/XSDT itself during Linux table scan (Richard Schaal) 3) iASL compiler The AML disassembler is integrated into the compiler. The "- d" option invokes the disassembler to completely disassemble an input AML file, producing as output a text ASL file with the extension ".dsl" (to avoid name collisions with existing .asl source files.) A future enhancement will allow the disassembler to obtain the BIOS DSDT from the registry under Windows. Fixed a problem with the VendorShort and VendorLong resource descriptors where an invalid AML sequence was created. Implemented a fix for BufferData term in the ASL parser. It was inadvertently defined twice, allowing invalid syntax to pass and causing reduction conflicts. Fixed a problem where the Ones opcode could get converted to a value of zero if "Ones" was used where a byte, word or dword value was expected. The 64-bit value is now truncated to the correct size with the correct value. ---------------------------------------- 02 July 2002. Summary of changes for this release. 1) ACPI CA Core Subsystem Version 20020702: The Table Manager code has been restructured to add several new features. Tables that are not required by the core subsystem (other than the FADT, DSDT, FACS, PSDTs, etc.) are no longer validated in any way and are returned from AcpiGetFirmwareTable if requested. The AcpiOsTableOverride interface is now called for each table that is loaded by the subsystem in order to allow the host to override any table it chooses. Previously, only the DSDT could be overridden. Added one new files, tbrsdt.c and tbgetall.c. Fixed a problem with the conversion of internal package objects to external objects (when a package is returned from a control method.) The return buffer length was set to zero instead of the proper length of the package object. Fixed a reported problem with the use of the RefOf and DeRefOf operators when passing reference arguments to control methods. A new type of Reference object is used internally for references produced by the RefOf operator. Added additional error messages in the Resource Manager to explain AE_BAD_DATA errors when they occur during resource parsing. Split the AcpiEnableSubsystem into two primitives to enable a finer granularity initialization sequence. These two calls should be called in this order: AcpiEnableSubsystem (flags), AcpiInitializeObjects (flags). The flags parameter remains the same. 2) Linux Updated the ACPI utilities module to understand the new style of fully resolved package objects that are now returned from the core subsystem. This eliminates errors of the form: ACPI: PCI Interrupt Routing Table [\_SB_.PCI0.PPB_._PRT] acpi_utils-0430 [145] acpi_evaluate_reference: Invalid element in package (not a device reference) The method evaluation utility uses the new buffer allocation scheme instead of calling AcpiEvaluate Object twice. Added support for ECDT. This allows the use of the Embedded Controller before the namespace has been fully initialized, which is necessary for ACPI 2.0 support, and for some laptops to initialize properly. (Laptops using ECDT are still rare, so only limited testing was performed of the added functionality.) Fixed memory leaks in the EC driver. Eliminated a brittle code structure in acpi_bus_init(). Eliminated the acpi_evaluate() helper function in utils.c. It is no longer needed since acpi_evaluate_object can optionally allocate memory for the return object. Implemented fix for keyboard hang when getting battery readings on some systems (Stephen White) PCI IRQ routing update (Dominik Brodowski) Fix an ifdef to allow compilation on UP with LAPIC but no IOAPIC support ---------------------------------------- 11 June 2002. Summary of changes for this release. 1) ACPI CA Core Subsystem Version 20020611: Fixed a reported problem where constants such as Zero and One appearing within _PRT packages were not handled correctly within the resource manager code. Originally reported against the ASL compiler because the code generator now optimizes integers to their minimal AML representation (i.e. AML constants if possible.) The _PRT code now handles all AML constant opcodes correctly (Zero, One, Ones, Revision). Fixed a problem with the Concatenate operator in the AML interpreter where a buffer result object was incorrectly marked as not fully evaluated, causing a run-time error of AE_AML_INTERNAL. All package sub-objects are now fully resolved before they are returned from the external ACPI interfaces. This means that name strings are resolved to object handles, and constant operators (Zero, One, Ones, Revision) are resolved to Integers. Implemented immediate resolution of the AML Constant opcodes (Zero, One, Ones, Revision) to Integer objects upon detection within the AML stream. This has simplified and reduced the generated code size of the subsystem by eliminating about 10 switch statements for these constants (which previously were contained in Reference objects.) The complicating issues are that the Zero opcode is used as a "placeholder" for unspecified optional target operands and stores to constants are defined to be no-ops. Code and Data Size: Current 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 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: 69.3K Code, 7.4K Data, 76.7K Total Debug Version: 143.8K Code, 58.8K Data, 202.6K Total Current Release: Non-Debug Version: 68.7K Code, 7.4K Data, 76.1K Total Debug Version: 142.9K Code, 58.7K Data, 201.6K Total 2) Linux Added preliminary support for obtaining _TRA data for PCI root bridges (Bjorn Helgaas). 3) iASL Compiler Version X2046: Fixed a problem where the "_DDN" reserved name was defined to be a control method with one argument. There are no arguments, and _DDN does not have to be a control method. Fixed a problem with the Linux version of the compiler where the source lines printed with error messages were the wrong lines. This turned out to be the "LF versus CR/LF" difference between Windows and Unix. This appears to be the longstanding issue concerning listing output and error messages. Fixed a problem with the Linux version of compiler where opcode names within error messages were wrong. This was caused by a slight difference in the output of the Flex tool on Linux versus Windows. Fixed a problem with the Linux compiler where the hex output files contained some garbage data caused by an internal buffer overrun. ---------------------------------------- 17 May 2002. Summary of changes for this release. 1) ACPI CA Core Subsystem Version 20020517: Implemented a workaround to an BIOS bug discovered on the HP OmniBook where the FADT revision number and the table size are inconsistent (ACPI 2.0 revision vs. ACPI 1.0 table size). The new behavior is to fallback to using only the ACPI 1.0 fields of the FADT if the table is too small to be a ACPI 2.0 table as claimed by the revision number. Although this is a BIOS bug, this is a case where the workaround is simple enough and with no side effects, so it seemed prudent to add it. A warning message is issued, however. Implemented minimum size checks for the fixed-length ACPI tables -- the FADT and FACS, as well as consistency checks between the revision number and the table size. Fixed a reported problem in the table override support where the new table pointer was incorrectly treated as a physical address instead of a logical address. Eliminated the use of the AE_AML_ERROR exception and replaced it with more descriptive codes. Fixed a problem where an exception would occur if an ASL Field was defined with no named Field Units underneath it (used by some index fields). Code and Data Size: Current 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 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: 68.8K Code, 7.1K Data, 75.9K Total Debug Version: 142.9K Code, 58.4K Data, 201.3K Total Current Release: Non-Debug Version: 69.3K Code, 7.4K Data, 76.7K Total Debug Version: 143.8K Code, 58.8K Data, 202.6K Total 2) Linux Much work done on ACPI init (MADT and PCI IRQ routing support). (Paul D. and Dominik Brodowski) Fix PCI IRQ-related panic on boot (Sam Revitch) Set BM_ARB_DIS when entering a sleep state (Ducrot Bruno) Fix "MHz" typo (Dominik Brodowski) Fix RTC year 2000 issue (Dominik Brodowski) Preclude multiple button proc entries (Eric Brunet) Moved arch-specific code out of include/platform/aclinux.h 3) iASL Compiler Version X2044: Implemented error checking for the string used in the EISAID macro (Usually used in the definition of the _HID object.) The code now strictly enforces the PnP format - exactly 7 characters, 3 uppercase letters and 4 hex digits. If a raw string is used in the definition of the _HID object (instead of the EISAID macro), the string must contain all alphanumeric characters (e.g., "*PNP0011" is not allowed because of the asterisk.) Implemented checking for invalid use of ACPI reserved names for most of the name creation operators (Name, Device, Event, Mutex, OperationRegion, PowerResource, Processor, and ThermalZone.) Previously, this check was only performed for control methods. Implemented an additional check on the Name operator to emit an error if a reserved name that must be implemented in ASL as a control method is used. We know that a reserved name must be a method if it is defined with input arguments. The warning emitted when a namespace object reference is not found during the cross reference phase has been changed into an error. The "External" directive should be used for names defined in other modules. 4) Tools and Utilities The 16-bit tools (adump16 and aexec16) have been regenerated and tested. Fixed a problem with the output of both acpidump and adump16 where the indentation of closing parentheses and brackets was not aligned properly with the parent block. ---------------------------------------- 03 May 2002. Summary of changes for this release. 1) ACPI CA Core Subsystem Version 20020503: Added support a new OSL interface that allows the host operating system software to override the DSDT found in the firmware - AcpiOsTableOverride. With this interface, the OSL can examine the version of the firmware DSDT and replace it with a different one if desired. Added new external interfaces for accessing ACPI registers from device drivers and other system software - AcpiGetRegister and AcpiSetRegister. This was simply an externalization of the existing AcpiHwBitRegister interfaces. Fixed a regression introduced in the previous build where the ASL/AML CreateField operator always returned an error, "destination must be a NS Node". Extended the maximum time (before failure) to successfully enable ACPI mode to 3 seconds. Code and Data Size: Current 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 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: 68.5K Code, 7.0K Data, 75.5K Total Debug Version: 142.4K Code, 58.3K Data, 200.7K Total Current Release: Non-Debug Version: 68.8K Code, 7.1K Data, 75.9K Total Debug Version: 142.9K Code, 58.4K Data, 201.3K Total 2) Linux Enhanced ACPI init code for SMP. We are now fully MPS and $PIR- free. While 3 out of 4 of our in-house systems work fine, the last one still hangs when testing the LAPIC timer. Renamed many files in 2.5 kernel release to omit "acpi_" from the name. Added warning on boot for Presario 711FR. Sleep improvements (Pavel Machek) ACPI can now be built without CONFIG_PCI enabled. IA64: Fixed memory map functions (JI Lee) 3) iASL Compiler Version X2043: Added support to allow the compiler to be integrated into the MS VC++ development environment for one-button compilation of single files or entire projects -- with error-to-source-line mapping. Implemented support for compile-time constant folding for the Type3, Type4, and Type5 opcodes first defined in the ACPI 2.0 specification. This allows the ASL writer to use expressions instead of Integer/Buffer/String constants in terms that must evaluate to constants at compile time and will also simplify the emitted AML in any such sub-expressions that can be folded (evaluated at compile-time.) This increases the size of the compiler significantly because a portion of the ACPI CA AML interpreter is included within the compiler in order to pre- evaluate constant expressions. Fixed a problem with the "Unicode" ASL macro that caused the compiler to fault. (This macro is used in conjunction with the _STR reserved name.) Implemented an AML opcode optimization to use the Zero, One, and Ones opcodes where possible to further reduce the size of integer constants and thus reduce the overall size of the generated AML code. Implemented error checking for new reserved terms for ACPI version 2.0A. Implemented the -qr option to display the current list of ACPI reserved names known to the compiler. Implemented the -qc option to display the current list of ASL operators that are allowed within constant expressions and can therefore be folded at compile time if the operands are constants. 4) Documentation Updated the Programmer's Reference for new interfaces, data types, and memory allocation model options. Updated the iASL Compiler User Reference to apply new format and add information about new features and options. ---------------------------------------- 19 April 2002. Summary of changes for this release. 1) ACPI CA Core Subsystem Version 20020419: The source code base for the Core Subsystem has been completely cleaned with PC-lint (FlexLint) for both 32-bit and 64-bit versions. The Lint option files used are included in the /acpi/generate/lint directory. Implemented enhanced status/error checking across the entire Hardware manager subsystem. Any hardware errors (reported from the OSL) are now bubbled up and will abort a running control method. Fixed a problem where the per-ACPI-table integer width (32 or 64) was stored only with control method nodes, causing a fault when non-control method code was executed during table loading. The solution implemented uses a global variable to indicate table width across the entire ACPI subsystem. Therefore, ACPI CA does not support mixed integer widths across different ACPI tables (DSDT, SSDT). Fixed a problem where NULL extended fields (X fields) in an ACPI 2.0 ACPI FADT caused the table load to fail. Although the existing ACPI specification is a bit fuzzy on this topic, the new behavior is to fall back on a ACPI 1.0 field if the corresponding ACPI 2.0 X field is zero (even though the table revision indicates a full ACPI 2.0 table.) The ACPI specification will be updated to clarify this issue. Fixed a problem with the SystemMemory operation region handler where memory was always accessed byte-wise even if the AML- specified access width was larger than a byte. This caused problems on systems with memory-mapped I/O. Memory is now accessed with the width specified. On systems that do not support non-aligned transfers, a check is made to guarantee proper address alignment before proceeding in order to avoid an AML-caused alignment fault within the kernel. Fixed a problem with the ExtendedIrq resource where only one byte of the 4-byte Irq field was extracted. Fixed the AcpiExDigitsNeeded() procedure to support _UID. This function was out of date and required a rewrite. Code and Data Size: Current 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 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: 66.6K Code, 6.5K Data, 73.1K Total Debug Version: 139.8K Code, 57.4K Data, 197.2K Total Current Release: Non-Debug Version: 68.5K Code, 7.0K Data, 75.5K Total Debug Version: 142.4K Code, 58.3K Data, 200.7K Total 2) Linux PCI IRQ routing fixes (Dominik Brodowski) 3) iASL Compiler Version X2042: Implemented an additional compile-time error check for a field unit whose size + minimum access width would cause a run-time access beyond the end-of-region. Previously, only the field size itself was checked. The Core subsystem and iASL compiler now share a common parse object in preparation for compile-time evaluation of the type 3/4/5 ASL operators. ---------------------------------------- Summary of changes for this release: 03_29_02 1) ACPI CA Core Subsystem Version 20020329: Implemented support for late evaluation of TermArg operands to Buffer and Package objects. This allows complex expressions to be used in the declarations of these object types. Fixed an ACPI 1.0 compatibility issue when reading Fields. In ACPI 1.0, if the field was larger than 32 bits, it was returned as a buffer - otherwise it was returned as an integer. In ACPI 2.0, the field is returned as a buffer only if the field is larger than 64 bits. The TableRevision is now considered when making this conversion to avoid incompatibility with existing ASL code. Implemented logical addressing for AcpiOsGetRootPointer. This allows an RSDP with either a logical or physical address. With this support, the host OS can now override all ACPI tables with one logical RSDP. Includes implementation of "typed" pointer support to allow a common data type for both physical and logical pointers internally. This required a change to the AcpiOsGetRootPointer interface. Implemented the use of ACPI 2.0 Generic Address Structures for all GPE, Fixed Event, and PM Timer I/O. This allows the use of memory mapped I/O for these ACPI features. Initialization now ignores not only non-required tables (All tables other than the FADT, FACS, DSDT, and SSDTs), but also does not validate the table headers of unrecognized tables. Fixed a problem where a notify handler could only be installed/removed on an object of type Device. All "notify" objects are now supported -- Devices, Processor, Power, and Thermal. Removed most verbosity from the ACPI_DB_INFO debug level. Only critical information is returned when this debug level is enabled. Code and Data Size: Current 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 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: 65.4K Code, 6.2K Data, 71.6K Total Debug Version: 138.0K Code, 56.6K Data, 194.6K Total Current Release: Non-Debug Version: 66.6K Code, 6.5K Data, 73.1K Total Debug Version: 139.8K Code, 57.4K Data, 197.2K Total 2) Linux: The processor driver (acpi_processor.c) now fully supports ACPI 2.0-based processor performance control (e.g. Intel(R) SpeedStep(TM) technology) Note that older laptops that only have the Intel "applet" interface are not supported through this. The 'limit' and 'performance' interface (/proc) are fully functional. [Note that basic policy for controlling performance state transitions will be included in the next version of ospmd.] The idle handler was modified to more aggressively use C2, and PIIX4 errata handling underwent a complete overhaul (big thanks to Dominik Brodowski). Added support for ACPI-PCI device binding (acpi_pci_root.c). _ADR-based devices in the ACPI namespace are now dynamically bound (associated) with their PCI counterparts (e.g. PCI1- >01:00.0). This allows, among other things, ACPI to resolve bus numbers for subordinate PCI bridges. Enhanced PCI IRQ routing to get the proper bus number for _PRT entries defined underneath PCI bridges. Added IBM 600E to bad bios list due to invalid _ADR value for PIIX4 PCI-ISA bridge, resulting in improper PCI IRQ routing. In the process of adding full MADT support (e.g. IOAPIC) for IA32 (acpi.c, mpparse.c) -- stay tuned. Added back visual differentiation between fixed-feature and control-method buttons in dmesg. Buttons are also subtyped (e.g. button/power/PWRF) to simplify button identification. We no longer use -Wno-unused when compiling debug. Please ignore any "_THIS_MODULE defined but not used" messages. Can now shut down the system using "magic sysrq" key. 3) iASL Compiler version 2041: Fixed a problem where conversion errors for hex/octal/decimal constants were not reported. Implemented a fix for the General Register template Address field. This field was 8 bits when it should be 64. Fixed a problem where errors/warnings were no longer being emitted within the listing output file. Implemented the ACPI 2.0A restriction on ACPI Table Signatures to exactly 4 characters, alphanumeric only. ---------------------------------------- Summary of changes for this release: 03_08_02 1) ACPI CA Core Subsystem Version 20020308: Fixed a problem with AML Fields where the use of the "AccessAny" keyword could cause an interpreter error due to attempting to read or write beyond the end of the parent Operation Region. Fixed a problem in the SystemMemory Operation Region handler where an attempt was made to map memory beyond the end of the region. This was the root cause of the "AE_ERROR" and "AE_NO_MEMORY" errors on some Linux systems. Fixed a problem where the interpreter/namespace "search to root" algorithm was not functioning for some object types. Relaxed the internal restriction on the search to allow upsearches for all external object types as well as most internal types. 2) Linux: We now use safe_halt() macro versus individual calls to sti | hlt. Writing to the processor limit interface should now work. "echo 1" will increase the limit, 2 will decrease, and 0 will reset to the default. 3) ASL compiler: Fixed segfault on Linux version. ---------------------------------------- Summary of changes for this release: 02_25_02 1) ACPI CA Core Subsystem: Fixed a problem where the GPE bit masks were not initialized properly, causing erratic GPE behavior. Implemented limited support for multiple calling conventions. The code can be generated with either the VPL (variable parameter list, or "C") convention, or the FPL (fixed parameter list, or "Pascal") convention. The core subsystem is about 3.4% smaller when generated with FPL. 2) Linux Re-add some /proc/acpi/event functionality that was lost during the rewrite Resolved issue with /proc events for fixed-feature buttons showing up as the system device. Fixed checks on C2/C3 latencies to be inclusive of maximum values. Replaced AE_ERRORs in acpi_osl.c with more specific error codes. Changed ACPI PRT option from "pci=noacpi-routing" to "pci=noacpi" Fixed limit interface & usage to fix bugs with passive cooling hysterisis. Restructured PRT support. ---------------------------------------- Summary of changes for this label: 02_14_02 1) ACPI CA Core Subsystem: Implemented support in AcpiLoadTable to allow loading of FACS and FADT tables. Suport for the now-obsolete interim 0.71 64-bit ACPI tables has been removed. All 64-bit platforms should be migrated to the ACPI 2.0 tables. The actbl71.h header has been removed from the source tree. All C macros defined within the subsystem have been prefixed with "ACPI_" to avoid collision with other system include files. Removed the return value for the two AcpiOsPrint interfaces, since it is never used and causes lint warnings for ignoring the return value. Added error checking to all internal mutex acquire and release calls. Although a failure from one of these interfaces is probably a fatal system error, these checks will cause the immediate abort of the currently executing method or interface. Fixed a problem where the AcpiSetCurrentResources interface could fault. This was a side effect of the deployment of the new memory allocation model. Fixed a couple of problems with the Global Lock support introduced in the last major build. The "common" (1.0/2.0) internal FACS was being overwritten with the FACS signature and clobbering the Global Lock pointer. Also, the actual firmware FACS was being unmapped after construction of the "common" FACS, preventing access to the actual Global Lock field within it. The "common" internal FACS is no longer installed as an actual ACPI table; it is used simply as a global. Code and Data Size: Current 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 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 (02_07_01) Non-Debug Version: 65.2K Code, 6.2K Data, 71.4K Total Debug Version: 136.9K Code, 56.4K Data, 193.3K Total Current Release: Non-Debug Version: 65.4K Code, 6.2K Data, 71.6K Total Debug Version: 138.0K Code, 56.6K Data, 194.6K Total 2) Linux Updated Linux-specific code for core macro and OSL interface changes described above. Improved /proc/acpi/event. It now can be opened only once and has proper poll functionality. Fixed and restructured power management (acpi_bus). Only create /proc "view by type" when devices of that class exist. Fixed "charging/discharging" bug (and others) in acpi_battery. Improved thermal zone code. 3) ASL Compiler, version X2039: Implemented the new compiler restriction on ASL String hex/octal escapes to non-null, ASCII values. An error results if an invalid value is used. (This will require an ACPI 2.0 specification change.) AML object labels that are output to the optional C and ASM source are now prefixed with both the ACPI table signature and table ID to help guarantee uniqueness within a large BIOS project. ---------------------------------------- Summary of changes for this label: 02_01_02 1) ACPI CA Core Subsystem: ACPI 2.0 support is complete in the entire Core Subsystem and the ASL compiler. All new ACPI 2.0 operators are implemented and all other changes for ACPI 2.0 support are complete. With simultaneous code and data optimizations throughout the subsystem, ACPI 2.0 support has been implemented with almost no additional cost in terms of code and data size. Implemented a new mechanism for allocation of return buffers. If the buffer length is set to ACPI_ALLOCATE_BUFFER, the buffer will be allocated on behalf of the caller. Consolidated all return buffer validation and allocation to a common procedure. Return buffers will be allocated via the primary OSL allocation interface since it appears that a separate pool is not needed by most users. If a separate pool is required for these buffers, the caller can still use the original mechanism and pre-allocate the buffer(s). Implemented support for string operands within the DerefOf operator. Restructured the Hardware and Event managers to be table driven, simplifying the source code and reducing the amount of generated code. Split the common read/write low-level ACPI register bitfield procedure into a separate read and write, simplifying the code considerably. Obsoleted the AcpiOsCallocate OSL interface. This interface was used only a handful of times and didn't have enough critical mass for a separate interface. Replaced with a common calloc procedure in the core. Fixed a reported problem with the GPE number mapping mechanism that allows GPE1 numbers to be non-contiguous with GPE0. Reorganized the GPE information and shrunk a large array that was originally large enough to hold info for all possible GPEs (256) to simply large enough to hold all GPEs up to the largest GPE number on the machine. Fixed a reported problem with resource structure alignment on 64-bit platforms. Changed the AcpiEnableEvent and AcpiDisableEvent external interfaces to not require any flags for the common case of enabling/disabling a GPE. Implemented support to allow a "Notify" on a Processor object. Most TBDs in comments within the source code have been resolved and eliminated. Fixed a problem in the interpreter where a standalone parent prefix (^) was not handled correctly in the interpreter and debugger. Removed obsolete and unnecessary GPE save/restore code. Implemented Field support in the ASL Load operator. This allows a table to be loaded from a named field, in addition to loading a table directly from an Operation Region. Implemented timeout and handle support in the external Global Lock interfaces. Fixed a problem in the AcpiDump utility where pathnames were no longer being generated correctly during the dump of named objects. Modified the AML debugger to give a full display of if/while predicates instead of just one AML opcode at a time. (The predicate can have several nested ASL statements.) The old method was confusing during single stepping. Code and Data Size: Current 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 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 (12_18_01) Non-Debug Version: 66.1K Code, 5.5K Data, 71.6K Total Debug Version: 138.3K Code, 55.9K Data, 194.2K Total Current Release: Non-Debug Version: 65.2K Code, 6.2K Data, 71.4K Total Debug Version: 136.9K Code, 56.4K Data, 193.3K Total 2) Linux Implemented fix for PIIX reverse throttling errata (Processor driver) Added new Limit interface (Processor and Thermal drivers) New thermal policy (Thermal driver) Many updates to /proc Battery "low" event support (Battery driver) Supports ACPI PCI IRQ routing (PCI Link and PCI root drivers) IA32 - IA64 initialization unification, no longer experimental Menuconfig options redesigned 3) ASL Compiler, version X2037: Implemented several new output features to simplify integration of AML code into firmware: 1) Output the AML in C source code with labels for each named ASL object. The original ASL source code is interleaved as C comments. 2) Output the AML in ASM source code with labels and interleaved ASL source. 3) Output the AML in raw hex table form, in either C or ASM. Implemented support for optional string parameters to the LoadTable operator. Completed support for embedded escape sequences within string literals. The compiler now supports all single character escapes as well as the Octal and Hex escapes. Note: the insertion of a null byte into a string literal (via the hex/octal escape) causes the string to be immediately terminated. A warning is issued. Fixed a problem where incorrect AML was generated for the case where an ASL namepath consists of a single parent prefix ( ) with no trailing name segments. The compiler has been successfully generated with a 64-bit C compiler. ---------------------------------------- Summary of changes for this label: 12_18_01 1) Linux Enhanced blacklist with reason and severity fields. Any table's signature may now be used to identify a blacklisted system. Call _PIC control method to inform the firmware which interrupt model the OS is using. Turn on any disabled link devices. Cleaned up busmgr /proc error handling (Andreas Dilger) 2) ACPI CA Core Subsystem: Implemented ACPI 2.0 semantics for the "Break" operator (Exit from while loop) Completed implementation of the ACPI 2.0 "Continue", "ConcatenateResTemplate", "DataTableRegion", and "LoadTable" operators. All new ACPI 2.0 operators are now implemented in both the ASL compiler and the AML interpreter. The only remaining ACPI 2.0 task is support for the String data type in the DerefOf operator. Fixed a problem with AcquireMutex where the status code was lost if the caller had to actually wait for the mutex. Increased the maximum ASL Field size from 64K bits to 4G bits. Completed implementation of the external Global Lock interfaces -- AcpiAcquireGlobalLock and AcpiReleaseGlobalLock. The Timeout and Handler parameters were added. Completed another pass at removing warnings and issues when compiling with 64-bit compilers. The code now compiles cleanly with the Intel 64-bit C/C++ compiler. Most notably, the pointer add and subtract (diff) macros have changed considerably. Created and deployed a new ACPI_SIZE type that is 64-bits wide on 64-bit platforms, 32-bits on all others. This type is used wherever memory allocation and/or the C sizeof() operator is used, and affects the OSL memory allocation interfaces AcpiOsAllocate and AcpiOsCallocate. Implemented sticky user breakpoints in the AML debugger. Code and Data Size: Current 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 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 (12_05_01) Non-Debug Version: 64.7K Code, 5.3K Data, 70.0K Total Debug Version: 136.2K Code, 55.6K Data, 191.8K Total Current Release: Non-Debug Version: 66.1K Code, 5.5K Data, 71.6K Total Debug Version: 138.3K Code, 55.9K Data, 194.2K Total 3) ASL Compiler, version X2034: Now checks for (and generates an error if detected) the use of a Break or Continue statement without an enclosing While statement. Successfully generated the compiler with the Intel 64-bit C compiler. ---------------------------------------- Summary of changes for this label: 12_05_01 1) ACPI CA Core Subsystem: The ACPI 2.0 CopyObject operator is fully implemented. This operator creates a new copy of an object (and is also used to bypass the "implicit conversion" mechanism of the Store operator.) The ACPI 2.0 semantics for the SizeOf operator are fully implemented. The change is that performing a SizeOf on a reference object causes an automatic dereference of the object to tha actual value before the size is evaluated. This behavior was undefined in ACPI 1.0. The ACPI 2.0 semantics for the Extended IRQ resource descriptor have been implemented. The interrupt polarity and mode are now independently set. Fixed a problem where ASL Constants (Zero, One, Ones, Revision) appearing in Package objects were not properly converted to integers when the internal Package was converted to an external object (via the AcpiEvaluateObject interface.) Fixed a problem with the namespace object deletion mechanism for objects created by control methods. There were two parts to this problem: 1) Objects created during the initialization phase method parse were not being deleted, and 2) The object owner ID mechanism to track objects was broken. Fixed a problem where the use of the ASL Scope operator within a control method would result in an invalid opcode exception. Fixed a problem introduced in the previous label where the buffer length required for the _PRT structure was not being returned correctly. Code and Data Size: Current 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 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 (11_20_01) Non-Debug Version: 64.1K Code, 5.3K Data, 69.4K Total Debug Version: 135.1K Code, 55.4K Data, 190.5K Total Current Release: Non-Debug Version: 64.7K Code, 5.3K Data, 70.0K Total Debug Version: 136.2K Code, 55.6K Data, 191.8K Total 2) Linux: Updated all files to apply cleanly against 2.4.16. Added basic PCI Interrupt Routing Table (PRT) support for IA32 (acpi_pci.c), and unified the PRT code for IA32 and IA64. This version supports both static and dyanmic PRT entries, but dynamic entries are treated as if they were static (not yet reconfigurable). Architecture- specific code to use this data is absent on IA32 but should be available shortly. Changed the initialization sequence to start the ACPI interpreter (acpi_init) prior to initialization of the PCI driver (pci_init) in init/main.c. This ordering is required to support PRT and facilitate other (future) enhancement. A side effect is that the ACPI bus driver and certain device drivers can no longer be loaded as modules. Modified the 'make menuconfig' options to allow PCI Interrupt Routing support to be included without the ACPI Bus and other device drivers. 3) ASL Compiler, version X2033: Fixed some issues with the use of the new CopyObject and DataTableRegion operators. Both are fully functional. ---------------------------------------- Summary of changes for this label: 11_20_01 20 November 2001. Summary of changes for this release. 1) ACPI CA Core Subsystem: Updated Index support to match ACPI 2.0 semantics. Storing a Integer, String, or Buffer to an Index of a Buffer will store only the least-significant byte of the source to the Indexed buffer byte. Multiple writes are not performed. Fixed a problem where the access type used in an AccessAs ASL operator was not recorded correctly into the field object. Fixed a problem where ASL Event objects were created in a signalled state. Events are now created in an unsignalled state. The internal object cache is now purged after table loading and initialization to reduce the use of dynamic kernel memory -- on the assumption that object use is greatest during the parse phase of the entire table (versus the run-time use of individual control methods.) ACPI 2.0 variable-length packages are now fully operational. Code and Data Size: Code and Data optimizations have permitted new feature development with an actual reduction in the library size. Current 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 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 (11_09_01): Non-Debug Version: 63.7K Code, 5.2K Data, 68.9K Total Debug Version: 134.5K Code, 55.4K Data, 189.9K Total Current Release: Non-Debug Version: 64.1K Code, 5.3K Data, 69.4K Total Debug Version: 135.1K Code, 55.4K Data, 190.5K Total 2) Linux: Enhanced the ACPI boot-time initialization code to allow the use of Local APIC tables for processor enumeration on IA-32, and to pave the way for a fully MPS-free boot (on SMP systems) in the near future. This functionality replaces arch/i386/kernel/acpitables.c, which was introduced in an earlier 2.4.15-preX release. To enable this feature you must add "acpi_boot=on" to the kernel command line -- see the help entry for CONFIG_ACPI_BOOT for more information. An IA-64 release is in the works... Restructured the configuration options to allow boot-time table parsing support without inclusion of the ACPI Interpreter (and other) code. NOTE: This release does not include fixes for the reported events, power-down, and thermal passive cooling issues (coming soon). 3) ASL Compiler: Added additional typechecking for Fields within restricted access Operation Regions. All fields within EC and CMOS regions must be declared with ByteAcc. All fields withing SMBus regions must be declared with the BufferAcc access type. Fixed a problem where the listing file output of control methods no longer interleaved the actual AML code with the ASL source code. ---------------------------------------- Summary of changes for this label: 11_09_01 1) ACPI CA Core Subsystem: Implemented ACPI 2.0-defined support for writes to fields with a Buffer, String, or Integer source operand that is smaller than the target field. In these cases, the source operand is zero-extended to fill the target field. Fixed a problem where a Field starting bit offset (within the parent operation region) was calculated incorrectly if the alignment of the field differed from the access width. This affected CreateWordField, CreateDwordField, CreateQwordField, and possibly other fields that use the "AccessAny" keyword. Fixed a problem introduced in the 11_02_01 release where indirect stores through method arguments did not operate correctly. 2) Linux: Implemented boot-time ACPI table parsing support (CONFIG_ACPI_BOOT) for IA32 and IA64 UP/SMP systems. This code facilitates the use of ACPI tables (e.g. MADT, SRAT) rather than legacy BIOS interfaces (e.g. MPS) for the configuration of system processors, memory, and interrupts during setup_arch(). Note that this patch does not include the required architecture-specific changes required to apply this information -- subsequent patches will be posted for both IA32 and IA64 to achieve this. Added low-level sleep support for IA32 platforms, courtesy of Pat Mochel. This allows IA32 systems to transition to/from various sleeping states (e.g. S1, S3), although the lack of a centralized driver model and power-manageable drivers will prevent its (successful) use on most systems. Revamped the ACPI 'menuconfig' layout: created new "ACPI Support" submenu, unified IA32 and IA64 options, added new "Boot using ACPI tables" option, etc. Increased the default timeout for the EC driver from 1ms to 10ms (1000 cycles of 10us) to try to address AE_TIME errors during EC transactions. ---------------------------------------- Summary of changes for this label: 11_02_01 1) ACPI CA Core Subsystem: ACPI 2.0 Support: Implemented ACPI 2.0 64-bit Field access (QWordAcc keyword). All ACPI 2.0 64-bit support is now implemented. OSL Interfaces: Several of the OSL (AcpiOs*) interfaces required changes to support ACPI 2.0 Qword field access. Read/Write PciConfiguration(), Read/Write Memory(), and Read/Write Port() now accept an ACPI_INTEGER (64 bits) as the value parameter. Also, the value parameter for the address space handler interface is now an ACPI_INTEGER. OSL implementations of these interfaces must now handle the case where the Width parameter is 64. Index Fields: Fixed a problem where unaligned bit assembly and disassembly for IndexFields was not supported correctly. Index and Bank Fields: Nested Index and Bank Fields are now supported. During field access, a check is performed to ensure that the value written to an Index or Bank register is not out of the range of the register. The Index (or Bank) register is written before each access to the field data. Future support will include allowing individual IndexFields to be wider than the DataRegister width. Fields: Fixed a problem where the AML interpreter was incorrectly attempting to write beyond the end of a Field/OpRegion. This was a boundary case that occurred when a DWORD field was written to a BYTE access OpRegion, forcing multiple writes and causing the interpreter to write one datum too many. Fields: Fixed a problem with Field/OpRegion access where the starting bit address of a field was incorrectly calculated if the current access type was wider than a byte (WordAcc, DwordAcc, or QwordAcc). Fields: Fixed a problem where forward references to individual FieldUnits (individual Field names within a Field definition) were not resolved during the AML table load. Fields: Fixed a problem where forward references from a Field definition to the parent Operation Region definition were not resolved during the AML table load. Fields: Duplicate FieldUnit names within a scope are now detected during AML table load. Acpi Interfaces: Fixed a problem where the AcpiGetName() interface returned an incorrect name for the root node. Code and Data Size: Code and Data optimizations have permitted new feature development with an actual reduction in the library size. Current 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 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 (10_18_01): Non-Debug Version: 63.9K Code, 5.1K Data, 69.0K Total Debug Version: 136.7K Code, 57.4K Data, 194.2K Total Current Release: Non-Debug Version: 63.7K Code, 5.2K Data, 68.9K Total Debug Version: 134.5K Code, 55.4K Data, 189.9K Total 2) Linux: Improved /proc processor output (Pavel Machek) Re-added MODULE_LICENSE("GPL") to all modules. 3) ASL Compiler version X2030: Duplicate FieldUnit names within a scope are now detected and flagged as errors. 4) Documentation: Programmer Reference updated to reflect OSL and address space handler interface changes described above. ---------------------------------------- Summary of changes for this label: 10_18_01 ACPI CA Core Subsystem: Fixed a problem with the internal object reference count mechanism that occasionally caused premature object deletion. This resolves all of the outstanding problem reports where an object is deleted in the middle of an interpreter evaluation. Although this problem only showed up in rather obscure cases, the solution to the problem involved an adjustment of all reference counts involving objects attached to namespace nodes. Fixed a problem with Field support in the interpreter where writing to an aligned field whose length is an exact multiple (2 or greater) of the field access granularity would cause an attempt to write beyond the end of the field. The top level AML opcode execution functions within the interpreter have been renamed with a more meaningful and consistent naming convention. The modules exmonad.c and exdyadic.c were eliminated. New modules are exoparg1.c, exoparg2.c, exoparg3.c, and exoparg6.c. Support for the ACPI 2.0 "Mid" ASL operator has been implemented. Fixed a problem where the AML debugger was causing some internal objects to not be deleted during subsystem termination. Fixed a problem with the external AcpiEvaluateObject interface where the subsystem would fault if the named object to be evaluated refered to a constant such as Zero, Ones, etc. Fixed a problem with IndexFields and BankFields where the subsystem would fault if the index, data, or bank registers were not defined in the same scope as the field itself. Added printf format string checking for compilers that support this feature. Corrected more than 50 instances of issues with format specifiers within invocations of ACPI_DEBUG_PRINT throughout the core subsystem code. The ASL "Revision" operator now returns the ACPI support level implemented in the core - the value "2" since the ACPI 2.0 support is more than 50% implemented. Enhanced the output of the AML debugger "dump namespace" command to output in a more human-readable form. Current core subsystem library code 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 full debug trace mechanism -- leading to 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 Label (09_20_01): Non-Debug Version: 65K Code, 5K Data, 70K Total Debug Version: 138K Code, 58K Data, 196K Total This Label: Non-Debug Version: 63.9K Code, 5.1K Data, 69.0K Total Debug Version: 136.7K Code, 57.4K Data, 194.2K Total Linux: Implemented a "Bad BIOS Blacklist" to track machines that have known ASL/AML problems. Enhanced the /proc interface for the thermal zone driver and added support for _HOT (the critical suspend trip point). The 'info' file now includes threshold/policy information, and allows setting of _SCP (cooling preference) and _TZP (polling frequency) values to the 'info' file. Examples: "echo tzp=5 > info" sets the polling frequency to 5 seconds, and "echo scp=1 > info" sets the cooling preference to the passive/quiet mode (if supported by the ASL). Implemented a workaround for a gcc bug that resuted in an OOPs when loading the control method battery driver. ---------------------------------------- Summary of changes for this label: 09_20_01 ACPI CA Core Subsystem: The AcpiEnableEvent and AcpiDisableEvent interfaces have been modified to allow individual GPE levels to be flagged as wake- enabled (i.e., these GPEs are to remain enabled when the platform sleeps.) The AcpiEnterSleepState and AcpiLeaveSleepState interfaces now support wake-enabled GPEs. This means that upon entering the sleep state, all GPEs that are not wake-enabled are disabled. When leaving the sleep state, these GPEs are reenabled. A local double-precision divide/modulo module has been added to enhance portability to OS kernels where a 64-bit math library is not available. The new module is "utmath.c". Several optimizations have been made to reduce the use of CPU stack. Originally over 2K, the maximum stack usage is now below 2K at 1860 bytes (1.82k) Fixed a problem with the AcpiGetFirmwareTable interface where the root table pointer was not mapped into a logical address properly. Fixed a problem where a NULL pointer was being dereferenced in the interpreter code for the ASL Notify operator. Fixed a problem where the use of the ASL Revision operator returned an error. This operator now returns the current version of the ACPI CA core subsystem. Fixed a problem where objects passed as control method parameters to AcpiEvaluateObject were always deleted at method termination. However, these objects may end up being stored into the namespace by the called method. The object reference count mechanism was applied to these objects instead of a force delete. Fixed a problem where static strings or buffers (contained in the AML code) that are declared as package elements within the ASL code could cause a fault because the interpreter would attempt to delete them. These objects are now marked with the "static object" flag to prevent any attempt to delete them. Implemented an interpreter optimization to use operands directly from the state object instead of extracting the operands to local variables. This reduces stack use and code size, and improves performance. The module exxface.c was eliminated as it was an unnecessary extra layer of code. Current core subsystem library code 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 full debug trace mechanism -- leading to 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. Non-Debug Version: 65K Code, 5K Data, 70K Total (Previously 69K) Debug Version: 138K Code, 58K Data, 196K Total (Previously 195K) Linux: Support for ACPI 2.0 64-bit integers has been added. All ACPI Integer objects are now 64 bits wide All Acpi data types and structures are now in lower case. Only Acpi macros are upper case for differentiation. Documentation: Changes to the external interfaces as described above. ---------------------------------------- Summary of changes for this label: 08_31_01 ACPI CA Core Subsystem: A bug with interpreter implementation of the ASL Divide operator was found and fixed. The implicit function return value (not the explicit store operands) was returning the remainder instead of the quotient. This was a longstanding bug and it fixes several known outstanding issues on various platforms. The ACPI_DEBUG_PRINT and function trace entry/exit macros have been further optimized for size. There are 700 invocations of the DEBUG_PRINT macro alone, so each optimization reduces the size of the debug version of the subsystem significantly. A stack trace mechanism has been implemented. The maximum stack usage is about 2K on 32-bit platforms. The debugger command "stat stack" will display the current maximum stack usage. All public symbols and global variables within the subsystem are now prefixed with the string "Acpi". This keeps all of the symbols grouped together in a kernel map, and avoids conflicts with other kernel subsystems. Most of the internal fixed lookup tables have been moved into the code segment via the const operator. Several enhancements have been made to the interpreter to both reduce the code size and improve performance. Current core subsystem library code 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 full debug trace mechanism which contains over 700 invocations of the DEBUG_PRINT macro, 500 function entry macro invocations, and over 900 function exit macro invocations -- leading to 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. Non-Debug Version: 64K Code, 5K Data, 69K Total Debug Version: 137K Code, 58K Data, 195K Total Linux: Implemented wbinvd() macro, pending a kernel-wide definition. Fixed /proc/acpi/event to handle poll() and short reads. ASL Compiler, version X2026: Fixed a problem introduced in the previous label where the AML code emitted for package objects produced packages with zero length. ---------------------------------------- Summary of changes for this label: 08_16_01 ACPI CA Core Subsystem: The following ACPI 2.0 ASL operators have been implemented in the AML interpreter (These are already supported by the Intel ASL compiler): ToDecimalString, ToHexString, ToString, ToInteger, and ToBuffer. Support for 64-bit AML constants is implemented in the AML parser, debugger, and disassembler. The internal memory tracking mechanism (leak detection code) has been upgraded to reduce the memory overhead (a separate tracking block is no longer allocated for each memory allocation), and now supports all of the internal object caches. The data structures and code for the internal object caches have been coelesced and optimized so that there is a single cache and memory list data structure and a single group of functions that implement generic cache management. This has reduced the code size in both the debug and release versions of the subsystem. The DEBUG_PRINT macro(s) have been optimized for size and replaced by ACPI_DEBUG_PRINT. The syntax for this macro is slightly different, because it generates a single call to an internal function. This results in a savings of about 90 bytes per invocation, resulting in an overall code and data savings of about 16% in the debug version of the subsystem. Linux: Fixed C3 disk corruption problems and re-enabled C3 on supporting machines. Integrated low-level sleep code by Patrick Mochel. Further tweaked source code Linuxization. Other minor fixes. ASL Compiler: Support for ACPI 2.0 variable length packages is fixed/completed. Fixed a problem where the optional length parameter for the ACPI 2.0 ToString operator. Fixed multiple extraneous error messages when a syntax error is detected within the declaration line of a control method. ---------------------------------------- Summary of changes for this label: 07_17_01 ACPI CA Core Subsystem: Added a new interface named AcpiGetFirmwareTable to obtain any ACPI table via the ACPI signature. The interface can be called at any time during kernel initialization, even before the kernel virtual memory manager is initialized and paging is enabled. This allows kernel subsystems to obtain ACPI tables very early, even before the ACPI CA subsystem is initialized. Fixed a problem where Fields defined with the AnyAcc attribute could be resolved to the incorrect address under the following conditions: 1) the field width is larger than 8 bits and 2) the parent operation region is not defined on a DWORD boundary. Fixed a problem where the interpreter is not being locked during namespace initialization (during execution of the _INI control methods), causing an error when an attempt is made to release it later. ACPI 2.0 support in the AML Interpreter has begun and will be ongoing throughout the rest of this year. In this label, The Mod operator is implemented. Added a new data type to contain full PCI addresses named ACPI_PCI_ID. This structure contains the PCI Segment, Bus, Device, and Function values. Linux: Enhanced the Linux version of the source code to change most capitalized ACPI type names to lowercase. For example, all instances of ACPI_STATUS are changed to acpi_status. This will result in a large diff, but the change is strictly cosmetic and aligns the CA code closer to the Linux coding standard. OSL Interfaces: The interfaces to the PCI configuration space have been changed to add the PCI Segment number and to split the single 32-bit combined DeviceFunction field into two 16-bit fields. This was accomplished by moving the four values that define an address in PCI configuration space (segment, bus, device, and function) to the new ACPI_PCI_ID structure. The changes to the PCI configuration space interfaces led to a reexamination of the complete set of address space access interfaces for PCI, I/O, and Memory. The previously existing 18 interfaces have proven difficult to maintain (any small change must be propagated across at least 6 interfaces) and do not easily allow for future expansion to 64 bits if necessary. Also, on some systems, it would not be appropriate to demultiplex the access width (8, 16, 32,or 64) before calling the OSL if the corresponding native OS interfaces contain a similar access width parameter. For these reasons, the 18 address space interfaces have been replaced by these 6 new ones: AcpiOsReadPciConfiguration AcpiOsWritePciConfiguration AcpiOsReadMemory AcpiOsWriteMemory AcpiOsReadPort AcpiOsWritePort Added a new interface named AcpiOsGetRootPointer to allow the OSL to perform the platform and/or OS-specific actions necessary to obtain the ACPI RSDP table pointer. On IA-32 platforms, this interface will simply call down to the CA core to perform the low-memory search for the table. On IA-64, the RSDP is obtained from EFI. Migrating this interface to the OSL allows the CA core to remain OS and platform independent. Added a new interface named AcpiOsSignal to provide a generic "function code and pointer" interface for various miscellaneous signals and notifications that must be made to the host OS. The first such signals are intended to support the ASL Fatal and Breakpoint operators. In the latter case, the AcpiOsBreakpoint interface has been obsoleted. The definition of the AcpiFormatException interface has been changed to simplify its use. The caller no longer must supply a buffer to the call; A pointer to a const string is now returned directly. This allows the call to be easily used in printf statements, etc. since the caller does not have to manage a local buffer. ASL Compiler, Version X2025: The ACPI 2.0 Switch/Case/Default operators have been implemented and are fully functional. They will work with all ACPI 1.0 interpreters, since the operators are simply translated to If/Else pairs. The ACPI 2.0 ElseIf operator is implemented and will also work with 1.0 interpreters, for the same reason. Implemented support for ACPI 2.0 variable-length packages. These packages have a separate opcode, and their size is determined by the interpreter at run-time. Documentation The ACPI CA Programmer Reference has been updated to reflect the new interfaces and changes to existing interfaces. ------------------------------------------ Summary of changes for this label: 06_15_01 ACPI CA Core Subsystem: Fixed a problem where a DWORD-accessed field within a Buffer object would get its byte address inadvertently rounded down to the nearest DWORD. Buffers are always Byte-accessible. ASL Compiler, version X2024: Fixed a problem where the Switch() operator would either fault or hang the compiler. Note however, that the AML code for this ACPI 2.0 operator is not yet implemented. Compiler uses the new AcpiOsGetTimer interface to obtain compile timings. Implementation of the CreateField operator automatically converts a reference to a named field within a resource descriptor from a byte offset to a bit offset if required. Added some missing named fields from the resource descriptor support. These are the names that are automatically created by the compiler to reference fields within a descriptor. They are only valid at compile time and are not passed through to the AML interpreter. Resource descriptor named fields are now typed as Integers and subject to compile-time typechecking when used in expressions. ------------------------------------------ Summary of changes for this label: 05_18_01 ACPI CA Core Subsystem: Fixed a couple of problems in the Field support code where bits from adjacent fields could be returned along with the proper field bits. Restructured the field support code to improve performance, readability and maintainability. New DEBUG_PRINTP macro automatically inserts the procedure name into the output, saving hundreds of copies of procedure name strings within the source, shrinking the memory footprint of the debug version of the core subsystem. Source Code Structure: The source code directory tree was restructured to reflect the current organization of the component architecture. Some files and directories have been moved and/or renamed. Linux: Fixed leaking kacpidpc processes. Fixed queueing event data even when /proc/acpi/event is not opened. ASL Compiler, version X2020: Memory allocation performance enhancement - over 24X compile time improvement on large ASL files. Parse nodes and namestring buffers are now allocated from a large internal compiler buffer. The temporary .SRC file is deleted unless the "-s" option is specified The "-d" debug output option now sends all output to the .DBG file instead of the console. "External" second parameter is now optional "ElseIf" syntax now properly allows the predicate Last operand to "Load" now recognized as a Target operand Debug object can now be used anywhere as a normal object. ResourceTemplate now returns an object of type BUFFER EISAID now returns an object of type INTEGER "Index" now works with a STRING operand "LoadTable" now accepts optional parameters "ToString" length parameter is now optional "Interrupt (ResourceType," parse error fixed. "Register" with a user-defined region space parse error fixed Escaped backslash at the end of a string ("\\") scan/parse error fixed "Revision" is now an object of type INTEGER. ------------------------------------------ Summary of changes for this label: 05_02_01 Linux: /proc/acpi/event now blocks properly. Removed /proc/sys/acpi. You can still dump your DSDT from /proc/acpi/dsdt. ACPI CA Core Subsystem: Fixed a problem introduced in the previous label where some of the "small" resource descriptor types were not recognized. Improved error messages for the case where an ASL Field is outside the range of the parent operation region. ASL Compiler, version X2018: Added error detection for ASL Fields that extend beyond the length of the parent operation region (only if the length of the region is known at compile time.) This includes fields that have a minimum access width that is smaller than the parent region, and individual field units that are partially or entirely beyond the extent of the parent. ------------------------------------------ Summary of changes for this label: 04_27_01 ACPI CA Core Subsystem: Fixed a problem where the namespace mutex could be released at the wrong time during execution of AcpiRemoveAddressSpaceHandler. Added optional thread ID output for debug traces, to simplify debugging of multiple threads. Added context switch notification when the debug code realizes that a different thread is now executing ACPI code. Some additional external data types have been prefixed with the string "ACPI_" for consistency. This may effect existing code. The data types affected are the external callback typedefs - e.g., WALK_CALLBACK becomes ACPI_WALK_CALLBACK. Linux: Fixed an issue with the OSL semaphore implementation where a thread was waking up with an error from receiving a SIGCHLD signal. Linux version of ACPI CA now uses the system C library for string manipulation routines instead of a local implementation. Cleaned up comments and removed TBDs. ASL Compiler, version X2017: Enhanced error detection and reporting for all file I/O operations. Documentation: Programmer Reference updated to version 1.06. ------------------------------------------ Summary of changes for this label: 04_13_01 ACPI CA Core Subsystem: Restructured support for BufferFields and RegionFields. BankFields support is now fully operational. All known 32-bit limitations on field sizes have been removed. Both BufferFields and (Operation) RegionFields are now supported by the same field management code. Resource support now supports QWORD address and IO resources. The 16/32/64 bit address structures and the Extended IRQ structure have been changed to properly handle Source Resource strings. A ThreadId of -1 is now used to indicate a "mutex not acquired" condition internally and must never be returned by AcpiOsThreadId. This reserved value was changed from 0 since Unix systems allow a thread ID of 0. Linux: Driver code reorganized to enhance portability Added a kernel configuration option to control ACPI_DEBUG Fixed the EC driver to honor _GLK. ASL Compiler, version X2016: Fixed support for the "FixedHw" keyword. Previously, the FixedHw address space was set to 0, not 0x7f as it should be. ------------------------------------------ Summary of changes for this label: 03_13_01 ACPI CA Core Subsystem: During ACPI initialization, the _SB_._INI method is now run if present. Notify handler fix - notifies are deferred until the parent method completes execution. This fixes the "mutex already acquired" issue seen occasionally. Part of the "implicit conversion" rules in ACPI 2.0 have been found to cause compatibility problems with existing ASL/AML. The convert "result-to-target-type" implementation has been removed for stores to method Args and Locals. Source operand conversion is still fully implemented. Possible changes to ACPI 2.0 specification pending. Fix to AcpiRsCalculatePciRoutingTableLength to return correct length. Fix for compiler warnings for 64-bit compiles. Linux: /proc output aligned for easier parsing. Release-version compile problem fixed. New kernel configuration options documented in Configure.help. IBM 600E - Fixed Sleep button may generate "Invalid context" message. OSPM: Power resource driver integrated with bus manager. Fixed kernel fault during active cooling for thermal zones. Source Code: The source code tree has been restructured. ------------------------------------------ Summary of changes for this label: 03_02_01 Linux OS Services Layer (OSL): Major revision of all Linux-specific code. Modularized all ACPI-specific drivers. Added new thermal zone and power resource drivers. Revamped /proc interface (new functionality is under /proc/acpi). New kernel configuration options. Linux known issues: New kernel configuration options not documented in Configure.help yet. Module dependencies not currently implemented. If used, they should be loaded in this order: busmgr, power, ec, system, processor, battery, ac_adapter, button, thermal. Modules will not load if CONFIG_MODVERSION is set. IBM 600E - entering S5 may reboot instead of shutting down. IBM 600E - Sleep button may generate "Invalid context" message. Some systems may fail with "execution mutex already acquired" message. ACPI CA Core Subsystem: Added a new OSL Interface, AcpiOsGetThreadId. This was required for the deadlock detection code. Defined to return a non-zero, 32-bit thread ID for the currently executing thread. May be a non-zero constant integer on single-thread systems. Implemented deadlock detection for internal subsystem mutexes. We may add conditional compilation for this code (debug only) later. ASL/AML Mutex object semantics are now fully supported. This includes multiple acquires/releases by owner and support for the Mutex SyncLevel parameter. A new "Force Release" mechanism automatically frees all ASL Mutexes that have been acquired but not released when a thread exits the interpreter. This forces conformance to the ACPI spec ("All mutexes must be released when an invocation exits") and prevents deadlocked ASL threads. This mechanism can be expanded (later) to monitor other resource acquisitions if OEM ASL code continues to misbehave (which it will). Several new ACPI exception codes have been added for the Mutex support. Recursive method calls are now allowed and supported (the ACPI spec does in fact allow recursive method calls.) The number of recursive calls is subject to the restrictions imposed by the SERIALIZED method keyword and SyncLevel (ACPI 2.0) method parameter. Implemented support for the SyncLevel parameter for control methods (ACPI 2.0 feature) Fixed a deadlock problem when multiple threads attempted to use the interpreter. Fixed a problem where the string length of a String package element was not always set in a package returned from AcpiEvaluateObject. Fixed a problem where the length of a String package element was not always included in the length of the overall package returned from AcpiEvaluateObject. Added external interfaces (Acpi*) to the ACPI debug memory manager. This manager keeps a list of all outstanding allocations, and can therefore detect memory leaks and attempts to free memory blocks more than once. Useful for code such as the power manager, etc. May not be appropriate for device drivers. Performance with the debug code enabled is slow. The ACPI Global Lock is now an optional hardware element. ASL Compiler Version X2015: Integrated changes to allow the compiler to be generated on multiple platforms. Linux makefile added to generate the compiler on Linux Source Code: All platform-specific headers have been moved to their own subdirectory, Include/Platform. New source file added, Interpreter/ammutex.c New header file, Include/acstruct.h Documentation: The programmer reference has been updated for the following new interfaces: AcpiOsGetThreadId AcpiAllocate AcpiCallocate AcpiFree ------------------------------------------ Summary of changes for this label: 02_08_01 Core ACPI CA Subsystem: Fixed a problem where an error was incorrectly returned if the return resource buffer was larger than the actual data (in the resource interfaces). References to named objects within packages are resolved to the full pathname string before packages are returned directly (via the AcpiEvaluateObject interface) or indirectly via the resource interfaces. Linux OS Services Layer (OSL): Improved /proc battery interface. Added C-state debugging output and other miscellaneous fixes. ASL Compiler Version X2014: All defined method arguments can now be used as local variables, including the ones that are not actually passed in as parameters. The compiler tracks initialization of the arguments and issues an exception if they are used without prior assignment (just like locals). The -o option now specifies a filename prefix that is used for all output files, including the AML output file. Otherwise, the default behavior is as follows: 1) the AML goes to the file specified in the DSDT. 2) all other output files use the input source filename as the base. ------------------------------------------ Summary of changes for this label: 01_25_01 Core ACPI CA Subsystem: Restructured the implementation of object store support within the interpreter. This includes support for the Store operator as well as any ASL operators that include a target operand. Partially implemented support for Implicit Result-to-Target conversion. This is when a result object is converted on the fly to the type of an existing target object. Completion of this support is pending further analysis of the ACPI specification concerning this matter. CPU-specific code has been removed from the subsystem (hardware directory). New Power Management Timer functions added Linux OS Services Layer (OSL): Moved system state transition code to the core, fixed it, and modified Linux OSL accordingly. Fixed C2 and C3 latency calculations. We no longer use the compilation date for the version message on initialization, but retrieve the version from AcpiGetSystemInfo(). Incorporated for fix Sony VAIO machines. Documentation: The Programmer Reference has been updated and reformatted. ASL Compiler: Version X2013: Fixed a problem where the line numbering and error reporting could get out of sync in the presence of multiple include files. ------------------------------------------ Summary of changes for this label: 01_15_01 Core ACPI CA Subsystem: Implemented support for type conversions in the execution of the ASL Concatenate operator (The second operand is converted to match the type of the first operand before concatenation.) Support for implicit source operand conversion is partially implemented. The ASL source operand types Integer, Buffer, and String are freely interchangeable for most ASL operators and are converted by the interpreter on the fly as required. Implicit Target operand conversion (where the result is converted to the target type before storing) is not yet implemented. Support for 32-bit and 64-bit BCD integers is implemented. Problem fixed where a field read on an aligned field could cause a read past the end of the field. New exception, AE_AML_NO_RETURN_VALUE, is returned when a method does not return a value, but the caller expects one. (The ASL compiler flags this as a warning.) ASL Compiler: Version X2011: 1. Static typechecking of all operands is implemented. This prevents the use of invalid objects (such as using a Package where an Integer is required) at compile time instead of at interpreter run-time. 2. The ASL source line is printed with ALL errors and warnings. 3. Bug fix for source EOF without final linefeed. 4. Debug option is split into a parse trace and a namespace trace. 5. Namespace output option (-n) includes initial values for integers and strings. 6. Parse-only option added for quick syntax checking. 7. Compiler checks for duplicate ACPI name declarations Version X2012: 1. Relaxed typechecking to allow interchangeability between strings, integers, and buffers. These types are now converted by the interpreter at runtime. 2. Compiler reports time taken by each internal subsystem in the debug output file. ------------------------------------------ Summary of changes for this label: 12_14_00 ASL Compiler: This is the first official release of the compiler. Since the compiler requires elements of the Core Subsystem, this label synchronizes everything. ------------------------------------------ Summary of changes for this label: 12_08_00 Fixed a problem where named references within the ASL definition of both OperationRegions and CreateXXXFields did not work properly. The symptom was an AE_AML_OPERAND_TYPE during initialization of the region/field. This is similar (but not related internally) to the problem that was fixed in the last label. Implemented both 32-bit and 64-bit support for the BCD ASL functions ToBCD and FromBCD. Updated all legal headers to include "2000" in the copyright years. ------------------------------------------ Summary of changes for this label: 12_01_00 Fixed a problem where method invocations within the ASL definition of both OperationRegions and CreateXXXFields did not work properly. The symptom was an AE_AML_OPERAND_TYPE during initialization of the region/field: nsinit-0209: AE_AML_OPERAND_TYPE while getting region arguments [DEBG] ammonad-0284: Exec_monadic2_r/Not: bad operand(s) (0x3005) Fixed a problem where operators with more than one nested subexpression would fail. The symptoms were varied, by mostly AE_AML_OPERAND_TYPE errors. This was actually a rather serious problem that has gone unnoticed until now. Subtract (Add (1,2), Multiply (3,4)) Fixed a problem where AcpiGetHandle didn't quite get fixed in the previous build (The prefix part of a relative path was handled incorrectly). Fixed a problem where Operation Region initialization failed if the operation region name was a "namepath" instead of a simple "nameseg". Symptom was an AE_NO_OPERAND error. Fixed a problem where an assignment to a local variable via the indirect RefOf mechanism only worked for the first such assignment. Subsequent assignments were ignored. ------------------------------------------ Summary of changes for this label: 11_15_00 ACPI 2.0 table support with backwards support for ACPI 1.0 and the 0.71 extensions. Note: although we can read ACPI 2.0 BIOS tables, the AML interpreter does NOT have support for the new 2.0 ASL grammar terms at this time. All ACPI hardware access is via the GAS structures in the ACPI 2.0 FADT. All physical memory addresses across all platforms are now 64 bits wide. Logical address width remains dependent on the platform (i.e., "void *"). AcpiOsMapMemory interface changed to a 64-bit physical address. The AML interpreter integer size is now 64 bits, as per the ACPI 2.0 specification. For backwards compatibility with ACPI 1.0, ACPI tables with a revision number less than 2 use 32-bit integers only. Fixed a problem where the evaluation of OpRegion operands did not always resolve them to numbers properly. ------------------------------------------ Summary of changes for this label: 10_20_00 Fix for CBN_._STA issue. This fix will allow correct access to CBN_ OpRegions when the _STA returns 0x8. Support to convert ACPI constants (Ones, Zeros, One) to actual values before a package object is returned Fix for method call as predicate to if/while construct causing incorrect if/while behavior Fix for Else block package lengths sometimes calculated wrong (if block > 63 bytes) Fix for Processor object length field, was always zero Table load abort if FACP sanity check fails Fix for problem with Scope(name) if name already exists Warning emitted if a named object referenced cannot be found (resolved) during method execution. ------------------------------------------ Summary of changes for this label: 9_29_00 New table initialization interfaces: AcpiInitializeSubsystem no longer has any parameters AcpiFindRootPointer - Find the RSDP (if necessary) AcpiLoadTables (RSDP) - load all tables found at RSDP->RSDT Obsolete Interfaces AcpiLoadFirmwareTables - replaced by AcpiLoadTables Note: These interface changes require changes to all existing OSDs The PCI_Config default address space handler is always installed at the root namespace object. ------------------------------------------- Summary of changes for this label: 09_15_00 The new initialization architecture is implemented. New interfaces are: AcpiInitializeSubsystem (replaces AcpiInitialize) AcpiEnableSubsystem Obsolete Interfaces: AcpiLoadNamespace (Namespace is automatically loaded when a table is loaded) The ACPI_OPERAND_OBJECT has been optimized to shrink its size from 52 bytes to 32 bytes. There is usually one of these for every namespace object, so the memory savings is significant. Implemented just-in-time evaluation of the CreateField operators. Bug fixes for IA-64 support have been integrated. Additional code review comments have been implemented The so-called "third pass parse" has been replaced by a final walk through the namespace to initialize all operation regions (address spaces) and fields that have not yet been initialized during the execution of the various _INI and REG methods. New file - namespace/nsinit.c ------------------------------------------- Summary of changes for this label: 09_01_00 Namespace manager data structures have been reworked to change the primary object from a table to a single object. This has resulted in dynamic memory savings of 3X within the namespace and 2X overall in the ACPI CA subsystem. Fixed problem where the call to AcpiEvFindPciRootBuses was inadvertently left commented out. Reduced the warning count when generating the source with the GCC compiler. Revision numbers added to each module header showing the SourceSafe version of the file. Please refer to this version number when giving us feedback or comments on individual modules. The main object types within the subsystem have been renamed to clarify their purpose: ACPI_INTERNAL_OBJECT -> ACPI_OPERAND_OBJECT ACPI_GENERIC_OP -> ACPI_PARSE_OBJECT ACPI_NAME_TABLE_ENTRY -> ACPI_NAMESPACE_NODE NOTE: no changes to the initialization sequence are included in this label. ------------------------------------------- Summary of changes for this label: 08_23_00 Fixed problem where TerminateControlMethod was being called multiple times per method Fixed debugger problem where single stepping caused a semaphore to be oversignalled Improved performance through additional parse object caching - added ACPI_EXTENDED_OP type ------------------------------------------- Summary of changes for this label: 08_10_00 Parser/Interpreter integration: Eliminated the creation of complete parse trees for ACPI tables and control methods. Instead, parse subtrees are created and then deleted as soon as they are processed (Either entered into the namespace or executed by the interpreter). This reduces the use of dynamic kernel memory significantly. (about 10X) Exception codes broken into classes and renumbered. Be sure to recompile all code that includes acexcep.h. Hopefully we won't have to renumber the codes again now that they are split into classes (environment, programmer, AML code, ACPI table, and internal). Fixed some additional alignment issues in the Resource Manager subcomponent Implemented semaphore tracking in the AcpiExec utility, and fixed several places where mutexes/semaphores were being unlocked without a corresponding lock operation. There are no known semaphore or mutex "leaks" at this time. Fixed the case where an ASL Return operator is used to return an unnamed package. ------------------------------------------- Summary of changes for this label: 07_28_00 Fixed a problem with the way addresses were calculated in AcpiAmlReadFieldData() and AcpiAmlWriteFieldData(). This problem manifested itself when a Field was created with WordAccess or DwordAccess, but the field unit defined within the Field was less than a Word or Dword. Fixed a problem in AmlDumpOperands() module's loop to pull operands off of the operand stack to display information. The problem manifested itself as a TLB error on 64-bit systems when accessing an operand stack with two or more operands. Fixed a problem with the PCI configuration space handlers where context was getting confused between accesses. This required a change to the generic address space handler and address space setup definitions. Handlers now get both a global handler context (this is the one passed in by the user when executing AcpiInstallAddressSpaceHandler() and a specific region context that is unique to each region (For example, the _ADR, _SEG and _BBN values associated with a specific region). The generic function definitions have changed to the following: typedef ACPI_STATUS (*ADDRESS_SPACE_HANDLER) ( UINT32 Function, UINT32 Address, UINT32 BitWidth, UINT32 *Value, void *HandlerContext, // This used to be void *Context void *RegionContext); // This is an additional parameter typedef ACPI_STATUS (*ADDRESS_SPACE_SETUP) ( ACPI_HANDLE RegionHandle, UINT32 Function, void *HandlerContext, void **RegionContext); // This used to be **ReturnContext ------------------------------------------- Summary of changes for this label: 07_21_00 Major file consolidation and rename. All files within the interpreter have been renamed as well as most header files. This was done to prevent collisions with existing files in the host OSs -- filenames such as "config.h" and "global.h" seem to be quite common. The VC project files have been updated. All makefiles will require modification. The parser/interpreter integration continues in Phase 5 with the implementation of a complete 2-pass parse (the AML is parsed twice) for each table; This avoids the construction of a huge parse tree and therefore reduces the amount of dynamic memory required by the subsystem. Greater use of the parse object cache means that performance is unaffected. Many comments from the two code reviews have been rolled in. The 64-bit alignment support is complete. ------------------------------------------- Summary of changes for this label: 06_30_00 With a nod and a tip of the hat to the technology of yesteryear, we've added support in the source code for 80 column output devices. The code is now mostly constrained to 80 columns or less to support environments and editors that 1) cannot display or print more than 80 characters on a single line, and 2) cannot disable line wrapping. A major restructuring of the namespace data structure has been completed. The result is 1) cleaner and more understandable/maintainable code, and 2) a significant reduction in the dynamic memory requirement for each named ACPI object (almost half). ------------------------------------------- Summary of changes for this label: 06_23_00 Linux support has been added. In order to obtain approval to get the ACPI CA subsystem into the Linux kernel, we've had to make quite a few changes to the base subsystem that will affect all users (all the changes are generic and OS- independent). The effects of these global changes have been somewhat far reaching. Files have been merged and/or renamed and interfaces have been renamed. The major changes are described below. Osd* interfaces renamed to AcpiOs* to eliminate namespace pollution/confusion within our target kernels. All OSD interfaces must be modified to match the new naming convention. Files merged across the subsystem. A number of the smaller source and header files have been merged to reduce the file count and increase the density of the existing files. There are too many to list here. In general, makefiles that call out individual files will require rebuilding. Interpreter files renamed. All interpreter files now have the prefix am* instead of ie* and is*. Header files renamed: The acapi.h file is now acpixf.h. The acpiosd.h file is now acpiosxf.h. We are removing references to the acronym "API" since it is somewhat windowsy. The new name is "external interface" or xface or xf in the filenames.j All manifest constants have been forced to upper case (some were mixed case.) Also, the string "ACPI_" has been prepended to many (not all) of the constants, typedefs, and structs. The globals "DebugLevel" and "DebugLayer" have been renamed "AcpiDbgLevel" and "AcpiDbgLayer" respectively. All other globals within the subsystem are now prefixed with "AcpiGbl_" Internal procedures within the subsystem are now prefixed with "Acpi" (with only a few exceptions). The original two-letter abbreviation for the subcomponent remains after "Acpi" - for example, CmCallocate became AcpiCmCallocate. Added a source code translation/conversion utility. Used to generate the Linux source code, it can be modified to generate other types of source as well. Can also be used to cleanup existing source by removing extraneous spaces and blank lines. Found in tools/acpisrc/* OsdUnMapMemory was renamed to OsdUnmapMemory and then AcpiOsUnmapMemory. (UnMap became Unmap). A "MaxUnits" parameter has been added to AcpiOsCreateSemaphore. When set to one, this indicates that the caller wants to use the semaphore as a mutex, not a counting semaphore. ACPI CA uses both types. However, implementers of this call may want to use different OS primitives depending on the type of semaphore requested. For example, some operating systems provide separate "mutex" and "semaphore" interfaces - where the mutex interface is much faster because it doesn't have all the overhead of a full semaphore implementation. Fixed a deadlock problem where a method that accesses the PCI address space can block forever if it is the first access to the space. ------------------------------------------- Summary of changes for this label: 06_02_00 Support for environments that cannot handle unaligned data accesses (e.g. firmware and OS environments devoid of alignment handler technology namely SAL/EFI and the IA-64 Linux kernel) has been added (via configurable macros) in these three areas: - Transfer of data from the raw AML byte stream is done via byte moves instead of word/dword/qword moves. - External objects are aligned within the user buffer, including package elements (sub-objects). - Conversion of name strings to UINT32 Acpi Names is now done byte-wise. The Store operator was modified to mimic Microsoft's implementation when storing to a Buffer Field. Added a check of the BM_STS bit before entering C3. The methods subdirectory has been obsoleted and removed. A new file, cmeval.c subsumes the functionality. A 16-bit (DOS) version of AcpiExec has been developed. The makefile is under the acpiexec directory. diff --git a/sys/contrib/dev/acpica/acapps.h b/sys/contrib/dev/acpica/acapps.h index 7dd9b48c3b5a..458ba4d6dfc6 100644 --- a/sys/contrib/dev/acpica/acapps.h +++ b/sys/contrib/dev/acpica/acapps.h @@ -1,181 +1,190 @@ /****************************************************************************** * * Module Name: acapps - common include for ACPI applications/tools * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 _ACAPPS #define _ACAPPS #ifdef _MSC_VER /* disable some level-4 warnings */ #pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */ #endif extern UINT8 *DsdtPtr; extern UINT32 AcpiDsdtLength; extern UINT8 *AmlStart; extern UINT32 AmlLength; extern int AcpiGbl_Optind; extern NATIVE_CHAR *AcpiGbl_Optarg; int AcpiGetopt( int argc, char **argv, char *opts); ACPI_STATUS AdInitialize ( void); char * FlGenerateFilename ( char *InputFilename, char *Suffix); +ACPI_STATUS +FlSplitInputPathname ( + char *InputPath, + char **OutDirectoryPath, + char **OutFilename); + ACPI_STATUS AdAmlDisassemble ( BOOLEAN OutToFile, char *Filename, - char **OutFilename); + char *Prefix, + char **OutFilename, + BOOLEAN GetAllTables); void AdPrintStatistics (void); ACPI_STATUS AdFindDsdt( UINT8 **DsdtPtr, UINT32 *DsdtLength); void AdDumpTables (void); ACPI_STATUS AdGetTables ( - char *Filename); + char *Filename, + BOOLEAN GetAllTables); ACPI_STATUS AdParseTables (void); ACPI_STATUS AdDisplayTables ( char *Filename); ACPI_STATUS AdDisplayStatistics (void); #endif /* _ACAPPS */ diff --git a/sys/contrib/dev/acpica/acdisasm.h b/sys/contrib/dev/acpica/acdisasm.h index 00401d254224..f0eb26b42030 100644 --- a/sys/contrib/dev/acpica/acdisasm.h +++ b/sys/contrib/dev/acpica/acdisasm.h @@ -1,453 +1,452 @@ /****************************************************************************** * * Name: acdisasm.h - AML disassembler - * $Revision: 3 $ + * $Revision: 5 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __ACDISASM_H__ #define __ACDISASM_H__ #include "amlresrc.h" #define BLOCK_NONE 0 #define BLOCK_PAREN 1 #define BLOCK_BRACE 2 #define BLOCK_COMMA_LIST 4 extern const char *AcpiGbl_IoDecode[2]; extern const char *AcpiGbl_WordDecode[4]; extern const char *AcpiGbl_ConsumeDecode[2]; extern const char *AcpiGbl_MinDecode[2]; extern const char *AcpiGbl_MaxDecode[2]; extern const char *AcpiGbl_DECDecode[2]; extern const char *AcpiGbl_RNGDecode[4]; extern const char *AcpiGbl_MEMDecode[4]; extern const char *AcpiGbl_RWDecode[2]; extern const char *AcpiGbl_IrqDecode[2]; extern const char *AcpiGbl_HEDecode[2]; extern const char *AcpiGbl_LLDecode[2]; 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 NATIVE_CHAR *AcpiGbl_LockRule[NUM_LOCK_RULES]; extern const NATIVE_CHAR *AcpiGbl_AccessTypes[NUM_ACCESS_TYPES]; extern const NATIVE_CHAR *AcpiGbl_UpdateRules[NUM_UPDATE_RULES]; extern const NATIVE_CHAR *AcpiGbl_MatchOps[NUM_MATCH_OPS]; typedef struct acpi_op_walk_info { UINT32 Level; UINT32 BitOffset; } ACPI_OP_WALK_INFO; typedef ACPI_STATUS (*ASL_WALK_CALLBACK) ( ACPI_PARSE_OBJECT *Op, UINT32 Level, void *Context); /* * 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 -AcpiDmString ( - char *String); - void AcpiDmUnicode ( ACPI_PARSE_OBJECT *Op); void AcpiDmDisassemble ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Origin, UINT32 NumOpcodes); void AcpiDmNamestring ( NATIVE_CHAR *Name); void AcpiDmDisplayPath ( ACPI_PARSE_OBJECT *Op); void AcpiDmDisassembleOneOp ( ACPI_WALK_STATE *WalkState, ACPI_OP_WALK_INFO *Info, ACPI_PARSE_OBJECT *Op); void AcpiDmDecodeInternalObject ( ACPI_OPERAND_OBJECT *ObjDesc); void AcpiDmDecodeNode ( ACPI_NAMESPACE_NODE *Node); 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); void AcpiDmFieldFlags ( ACPI_PARSE_OBJECT *Op); void AcpiDmAddressSpace ( UINT8 SpaceId); void AcpiDmRegionFlags ( ACPI_PARSE_OBJECT *Op); void AcpiDmMatchOp ( ACPI_PARSE_OBJECT *Op); void AcpiDmMatchKeyword ( ACPI_PARSE_OBJECT *Op); BOOLEAN AcpiDmCommaIfListMember ( ACPI_PARSE_OBJECT *Op); void AcpiDmCommaIfFieldMember ( ACPI_PARSE_OBJECT *Op); /* * dmbuffer */ void AcpiIsEisaId ( ACPI_PARSE_OBJECT *Op); void AcpiDmEisaId ( UINT32 EncodedId); BOOLEAN AcpiDmIsUnicodeBuffer ( ACPI_PARSE_OBJECT *Op); BOOLEAN AcpiDmIsStringBuffer ( ACPI_PARSE_OBJECT *Op); /* * dmresrc */ void AcpiDmDisasmByteList ( UINT32 Level, UINT8 *ByteData, UINT32 ByteCount); void AcpiDmByteList ( ACPI_OP_WALK_INFO *Info, ACPI_PARSE_OBJECT *Op); void AcpiDmResourceDescriptor ( ACPI_OP_WALK_INFO *Info, UINT8 *ByteData, UINT32 ByteCount); BOOLEAN AcpiDmIsResourceDescriptor ( ACPI_PARSE_OBJECT *Op); void AcpiDmIndent ( UINT32 Level); void AcpiDmBitList ( UINT16 Mask); +void +AcpiDmDecodeAttribute ( + UINT8 Attribute); /* * dmresrcl */ void AcpiDmIoFlags ( UINT8 Flags); void AcpiDmMemoryFlags ( UINT8 Flags, UINT8 SpecificFlags); void AcpiDmWordDescriptor ( ASL_WORD_ADDRESS_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmDwordDescriptor ( ASL_DWORD_ADDRESS_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmQwordDescriptor ( ASL_QWORD_ADDRESS_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmMemory24Descriptor ( ASL_MEMORY_24_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmMemory32Descriptor ( ASL_MEMORY_32_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmFixedMem32Descriptor ( ASL_FIXED_MEMORY_32_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmGenericRegisterDescriptor ( ASL_GENERAL_REGISTER_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmInterruptDescriptor ( ASL_EXTENDED_XRUPT_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmVendorLargeDescriptor ( ASL_LARGE_VENDOR_DESC *Resource, UINT32 Length, UINT32 Level); /* * dmresrcs */ void AcpiDmIrqDescriptor ( ASL_IRQ_FORMAT_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmDmaDescriptor ( ASL_DMA_FORMAT_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmIoDescriptor ( ASL_IO_PORT_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmFixedIoDescriptor ( ASL_FIXED_IO_PORT_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmStartDependentDescriptor ( ASL_START_DEPENDENT_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmEndDependentDescriptor ( ASL_START_DEPENDENT_DESC *Resource, UINT32 Length, UINT32 Level); void AcpiDmVendorSmallDescriptor ( ASL_SMALL_VENDOR_DESC *Resource, UINT32 Length, UINT32 Level); #endif /* __ACDISASM_H__ */ diff --git a/sys/contrib/dev/acpica/acdispat.h b/sys/contrib/dev/acpica/acdispat.h index 453bbc9b8cd9..9ac94e1a769d 100644 --- a/sys/contrib/dev/acpica/acdispat.h +++ b/sys/contrib/dev/acpica/acdispat.h @@ -1,582 +1,586 @@ /****************************************************************************** * * Name: acdispat.h - dispatcher (parser to interpreter interface) - * $Revision: 54 $ + * $Revision: 55 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 _ACDISPAT_H_ #define _ACDISPAT_H_ #define NAMEOF_LOCAL_NTE "__L0" #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); ACPI_STATUS AcpiDsGetBufferFieldArguments ( ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS AcpiDsGetRegionArguments ( ACPI_OPERAND_OBJECT *RgnDesc); ACPI_STATUS AcpiDsGetBufferArguments ( ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS 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); ACPI_STATUS AcpiDsEvalRegionOperands ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op); ACPI_STATUS AcpiDsEvalDataObjectOperands ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS AcpiDsInitializeRegion ( ACPI_HANDLE ObjHandle); /* dsctrl - Parser/Interpreter interface, control stack routines */ ACPI_STATUS AcpiDsExecBeginControlOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op); ACPI_STATUS AcpiDsExecEndControlOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op); /* dsexec - Parser/Interpreter interface, method execution callbacks */ ACPI_STATUS AcpiDsGetPredicateValue ( ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ResultObj); ACPI_STATUS AcpiDsExecBeginOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp); ACPI_STATUS 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); ACPI_STATUS AcpiDsCreateField ( ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *RegionNode, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsCreateBankField ( ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *RegionNode, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsCreateIndexField ( ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *RegionNode, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsCreateBufferField ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsInitFieldObjects ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState); /* dsload - Parser/Interpreter interface, namespace load callbacks */ ACPI_STATUS AcpiDsLoad1BeginOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp); ACPI_STATUS AcpiDsLoad1EndOp ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsLoad2BeginOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp); ACPI_STATUS AcpiDsLoad2EndOp ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsInitCallbacks ( ACPI_WALK_STATE *WalkState, UINT32 PassNumber); /* dsmthdat - method data (locals/args) */ ACPI_STATUS AcpiDsStoreObjectToLocal ( UINT16 Opcode, UINT32 Index, ACPI_OPERAND_OBJECT *SrcDesc, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsMethodDataGetEntry ( UINT16 Opcode, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT ***Node); void AcpiDsMethodDataDeleteAll ( ACPI_WALK_STATE *WalkState); BOOLEAN AcpiDsIsMethodValue ( ACPI_OPERAND_OBJECT *ObjDesc); ACPI_OBJECT_TYPE AcpiDsMethodDataGetType ( UINT16 Opcode, UINT32 Index, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsMethodDataGetValue ( UINT16 Opcode, UINT32 Index, 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, UINT32 MaxParamCount, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsMethodDataGetNode ( UINT16 Opcode, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **Node); 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 */ ACPI_STATUS AcpiDsParseMethod ( ACPI_HANDLE ObjHandle); ACPI_STATUS AcpiDsCallControlMethod ( ACPI_THREAD_STATE *Thread, ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op); ACPI_STATUS AcpiDsRestartControlMethod ( ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ReturnDesc); ACPI_STATUS AcpiDsTerminateControlMethod ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsBeginMethodExecution ( ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_NAMESPACE_NODE *CallingMethodNode); /* dsobj - Parser/Interpreter interface - object initialization and conversion */ ACPI_STATUS AcpiDsInitOneObject ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue); ACPI_STATUS AcpiDsInitializeObjects ( ACPI_TABLE_DESC *TableDesc, ACPI_NAMESPACE_NODE *StartNode); ACPI_STATUS AcpiDsBuildInternalBufferObj ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, UINT32 BufferLength, ACPI_OPERAND_OBJECT **ObjDescPtr); ACPI_STATUS AcpiDsBuildInternalPackageObj ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *op, UINT32 PackageLength, 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, UINT16 Opcode, ACPI_OPERAND_OBJECT **ObjDesc); ACPI_STATUS AcpiDsCreateNode ( ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE *Node, ACPI_PARSE_OBJECT *Op); /* dsutils - Parser/Interpreter interface utility routines */ BOOLEAN AcpiDsIsResultUsed ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState); void AcpiDsDeleteResultIfNotUsed ( ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT *ResultObj, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsCreateOperand ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Arg, UINT32 ArgsRemaining); ACPI_STATUS AcpiDsCreateOperands ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *FirstArg); ACPI_STATUS AcpiDsResolveOperands ( ACPI_WALK_STATE *WalkState); +void +AcpiDsClearOperands ( + ACPI_WALK_STATE *WalkState); + /* * dswscope - Scope Stack manipulation */ ACPI_STATUS AcpiDsScopeStackPush ( ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsScopeStackPop ( ACPI_WALK_STATE *WalkState); void AcpiDsScopeStackClear ( ACPI_WALK_STATE *WalkState); /* dswstate - parser WALK_STATE management routines */ ACPI_WALK_STATE * AcpiDsCreateWalkState ( ACPI_OWNER_ID OwnerId, ACPI_PARSE_OBJECT *Origin, ACPI_OPERAND_OBJECT *MthDesc, ACPI_THREAD_STATE *Thread); ACPI_STATUS AcpiDsInitAmlWalk ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *MethodNode, UINT8 *AmlStart, UINT32 AmlLength, ACPI_OPERAND_OBJECT **Params, ACPI_OPERAND_OBJECT **ReturnObjDesc, UINT32 PassNumber); ACPI_STATUS AcpiDsObjStackDeleteAll ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsObjStackPopAndDelete ( UINT32 PopCount, ACPI_WALK_STATE *WalkState); void AcpiDsDeleteWalkState ( ACPI_WALK_STATE *WalkState); ACPI_WALK_STATE * AcpiDsPopWalkState ( ACPI_THREAD_STATE *Thread); void AcpiDsPushWalkState ( ACPI_WALK_STATE *WalkState, ACPI_THREAD_STATE *Thread); ACPI_STATUS AcpiDsResultStackPop ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsResultStackPush ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsResultStackClear ( ACPI_WALK_STATE *WalkState); 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, UINT32 Index, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsResultPop ( ACPI_OPERAND_OBJECT **Object, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsResultPush ( ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiDsResultPopFromBottom ( ACPI_OPERAND_OBJECT **Object, ACPI_WALK_STATE *WalkState); #endif /* _ACDISPAT_H_ */ diff --git a/sys/contrib/dev/acpica/acevents.h b/sys/contrib/dev/acpica/acevents.h index db6f709cb1ec..baa7cb85d324 100644 --- a/sys/contrib/dev/acpica/acevents.h +++ b/sys/contrib/dev/acpica/acevents.h @@ -1,313 +1,313 @@ /****************************************************************************** * * Name: acevents.h - Event subcomponent prototypes and defines - * $Revision: 79 $ + * $Revision: 80 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __ACEVENTS_H__ #define __ACEVENTS_H__ ACPI_STATUS AcpiEvInitialize ( void); ACPI_STATUS AcpiEvHandlerInitialize ( void); /* * Evfixed - Fixed event handling */ ACPI_STATUS AcpiEvFixedEventInitialize ( void); UINT32 AcpiEvFixedEventDetect ( void); UINT32 AcpiEvFixedEventDispatch ( UINT32 Event); /* * Evmisc */ BOOLEAN AcpiEvIsNotifyObject ( ACPI_NAMESPACE_NODE *Node); ACPI_STATUS AcpiEvAcquireGlobalLock( - UINT32 Timeout); + UINT16 Timeout); ACPI_STATUS AcpiEvReleaseGlobalLock( void); ACPI_STATUS AcpiEvInitGlobalLockHandler ( void); UINT32 AcpiEvGetGpeRegisterIndex ( UINT32 GpeNumber); UINT32 AcpiEvGetGpeNumberIndex ( UINT32 GpeNumber); ACPI_STATUS AcpiEvQueueNotifyRequest ( ACPI_NAMESPACE_NODE *Node, UINT32 NotifyValue); void ACPI_SYSTEM_XFACE AcpiEvNotifyDispatch ( void *Context); /* * Evgpe - GPE handling and dispatch */ ACPI_STATUS AcpiEvGpeInitialize ( void); ACPI_STATUS AcpiEvInitGpeControlMethods ( void); UINT32 AcpiEvGpeDispatch ( UINT32 GpeNumber); UINT32 AcpiEvGpeDetect ( void); /* * Evregion - Address Space handling */ ACPI_STATUS AcpiEvInitAddressSpaces ( void); ACPI_STATUS AcpiEvAddressSpaceDispatch ( ACPI_OPERAND_OBJECT *RegionObj, UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, void *Value); ACPI_STATUS AcpiEvAddrHandlerHelper ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue); ACPI_STATUS AcpiEvAttachRegion ( ACPI_OPERAND_OBJECT *HandlerObj, ACPI_OPERAND_OBJECT *RegionObj, BOOLEAN AcpiNsIsLocked); void AcpiEvDetachRegion ( ACPI_OPERAND_OBJECT *RegionObj, BOOLEAN AcpiNsIsLocked); /* * Evregini - Region initialization and setup */ ACPI_STATUS AcpiEvSystemMemoryRegionSetup ( ACPI_HANDLE Handle, UINT32 Function, void *HandlerContext, void **RegionContext); ACPI_STATUS AcpiEvIoSpaceRegionSetup ( ACPI_HANDLE Handle, UINT32 Function, void *HandlerContext, void **RegionContext); ACPI_STATUS AcpiEvPciConfigRegionSetup ( ACPI_HANDLE Handle, UINT32 Function, void *HandlerContext, void **RegionContext); ACPI_STATUS AcpiEvCmosRegionSetup ( ACPI_HANDLE Handle, UINT32 Function, void *HandlerContext, void **RegionContext); ACPI_STATUS AcpiEvPciBarRegionSetup ( ACPI_HANDLE Handle, UINT32 Function, void *HandlerContext, void **RegionContext); ACPI_STATUS AcpiEvDefaultRegionSetup ( ACPI_HANDLE Handle, UINT32 Function, void *HandlerContext, void **RegionContext); ACPI_STATUS AcpiEvInitializeRegion ( ACPI_OPERAND_OBJECT *RegionObj, BOOLEAN AcpiNsLocked); /* * Evsci - SCI (System Control Interrupt) handling/dispatch */ UINT32 AcpiEvInstallSciHandler ( void); ACPI_STATUS AcpiEvRemoveSciHandler ( void); UINT32 AcpiEvInitializeSCI ( UINT32 ProgramSCI); void AcpiEvTerminate ( void); #endif /* __ACEVENTS_H__ */ diff --git a/sys/contrib/dev/acpica/acglobal.h b/sys/contrib/dev/acpica/acglobal.h index 7615f891069c..0153dfa5b5b1 100644 --- a/sys/contrib/dev/acpica/acglobal.h +++ b/sys/contrib/dev/acpica/acglobal.h @@ -1,389 +1,389 @@ /****************************************************************************** * * Name: acglobal.h - Declarations for global variables - * $Revision: 131 $ + * $Revision: 132 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __ACGLOBAL_H__ #define __ACGLOBAL_H__ /* * Ensure that the globals are actually defined only once. * * The use of these defines allows a single list of globals (here) in order * to simplify maintenance of the code. */ #ifdef DEFINE_ACPI_GLOBALS #define ACPI_EXTERN #else #define ACPI_EXTERN extern #endif /***************************************************************************** * * Debug support * ****************************************************************************/ /* Runtime configuration of debug print levels */ extern UINT32 AcpiDbgLevel; extern UINT32 AcpiDbgLayer; /* Procedure nesting level for debug output */ extern UINT32 AcpiGbl_NestingLevel; /***************************************************************************** * * ACPI Table globals * ****************************************************************************/ /* * Table pointers. * Although these pointers are somewhat redundant with the global AcpiTable, * they are convenient because they are typed pointers. * * These tables are single-table only; meaning that there can be at most one * of each in the system. Each global points to the actual table. * */ ACPI_EXTERN UINT32 AcpiGbl_TableFlags; ACPI_EXTERN UINT32 AcpiGbl_RsdtTableCount; ACPI_EXTERN RSDP_DESCRIPTOR *AcpiGbl_RSDP; ACPI_EXTERN XSDT_DESCRIPTOR *AcpiGbl_XSDT; ACPI_EXTERN FADT_DESCRIPTOR *AcpiGbl_FADT; ACPI_EXTERN ACPI_TABLE_HEADER *AcpiGbl_DSDT; ACPI_EXTERN FACS_DESCRIPTOR *AcpiGbl_FACS; ACPI_EXTERN ACPI_COMMON_FACS AcpiGbl_CommonFACS; /* * 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. */ ACPI_EXTERN UINT8 AcpiGbl_IntegerBitWidth; ACPI_EXTERN UINT8 AcpiGbl_IntegerByteWidth; /* * Since there may be multiple SSDTs and PSDTS, a single pointer is not * sufficient; Therefore, there isn't one! */ /* * ACPI Table info arrays */ extern ACPI_TABLE_DESC AcpiGbl_AcpiTables[NUM_ACPI_TABLES]; extern ACPI_TABLE_SUPPORT AcpiGbl_AcpiTableData[NUM_ACPI_TABLES]; /* * Predefined mutex objects. This array contains the * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. * (The table maps local handles to the real OS handles) */ ACPI_EXTERN ACPI_MUTEX_INFO AcpiGbl_AcpiMutexInfo [NUM_MTX]; /***************************************************************************** * * Miscellaneous globals * ****************************************************************************/ ACPI_EXTERN ACPI_MEMORY_LIST AcpiGbl_MemoryLists[ACPI_NUM_MEM_LISTS]; ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_DrvNotify; ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_SysNotify; ACPI_EXTERN ACPI_INIT_HANDLER AcpiGbl_InitHandler; ACPI_EXTERN ACPI_WALK_STATE *AcpiGbl_BreakpointWalk; ACPI_EXTERN ACPI_HANDLE AcpiGbl_GlobalLockSemaphore; 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 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; ACPI_EXTERN BOOLEAN AcpiGbl_StepToNextCall; ACPI_EXTERN BOOLEAN AcpiGbl_AcpiHardwarePresent; ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockPresent; ACPI_EXTERN BOOLEAN AcpiGbl_EventsInitialized; extern BOOLEAN AcpiGbl_Shutdown; extern UINT32 AcpiGbl_StartupFlags; extern const UINT8 AcpiGbl_DecodeTo8bit[8]; extern const NATIVE_CHAR *AcpiGbl_DbSleepStates[ACPI_NUM_SLEEP_STATES]; extern const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES]; extern const NATIVE_CHAR *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS]; /***************************************************************************** * * Namespace globals * ****************************************************************************/ -#define NUM_NS_TYPES INTERNAL_TYPE_INVALID+1 +#define NUM_NS_TYPES ACPI_TYPE_INVALID+1 #if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) #define NUM_PREDEFINED_NAMES 10 #else #define NUM_PREDEFINED_NAMES 9 #endif ACPI_EXTERN ACPI_NAMESPACE_NODE AcpiGbl_RootNodeStruct; ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_RootNode; extern const UINT8 AcpiGbl_NsProperties[NUM_NS_TYPES]; extern const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames [NUM_PREDEFINED_NAMES]; #ifdef ACPI_DEBUG_OUTPUT ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeCount; ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeSize; ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentNodeCount; ACPI_EXTERN ACPI_SIZE AcpiGbl_EntryStackPointer; ACPI_EXTERN ACPI_SIZE AcpiGbl_LowestStackPointer; ACPI_EXTERN UINT32 AcpiGbl_DeepestNesting; #endif /***************************************************************************** * * Interpreter globals * ****************************************************************************/ ACPI_EXTERN ACPI_THREAD_STATE *AcpiGbl_CurrentWalkList; /* Control method single step flag */ ACPI_EXTERN UINT8 AcpiGbl_CmSingleStep; /***************************************************************************** * * Parser globals * ****************************************************************************/ ACPI_EXTERN ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot; /***************************************************************************** * * Hardware globals * ****************************************************************************/ extern ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG]; ACPI_EXTERN UINT8 AcpiGbl_SleepTypeA; ACPI_EXTERN UINT8 AcpiGbl_SleepTypeB; /***************************************************************************** * * Event and GPE globals * ****************************************************************************/ extern ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS]; ACPI_EXTERN ACPI_FIXED_EVENT_HANDLER AcpiGbl_FixedEventHandlers[ACPI_NUM_FIXED_EVENTS]; ACPI_EXTERN ACPI_HANDLE AcpiGbl_GpeObjHandle; ACPI_EXTERN UINT32 AcpiGbl_GpeRegisterCount; ACPI_EXTERN UINT32 AcpiGbl_GpeNumberMax; ACPI_EXTERN ACPI_GPE_REGISTER_INFO *AcpiGbl_GpeRegisterInfo; ACPI_EXTERN ACPI_GPE_NUMBER_INFO *AcpiGbl_GpeNumberInfo; ACPI_EXTERN ACPI_GPE_BLOCK_INFO AcpiGbl_GpeBlockInfo[ACPI_MAX_GPE_BLOCKS]; /* * GPE translation table * Indexed by the GPE number, returns a valid index into the global GPE tables. * * This table is needed because the GPE numbers supported by block 1 do not * have to be contiguous with the GPE numbers supported by block 0. */ ACPI_EXTERN ACPI_GPE_INDEX_INFO *AcpiGbl_GpeNumberToIndex; /***************************************************************************** * * Debugger globals * ****************************************************************************/ ACPI_EXTERN UINT8 AcpiGbl_DbOutputFlags; #ifdef ACPI_DISASSEMBLER ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_disasm; ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_verbose; #endif #ifdef ACPI_DEBUGGER extern BOOLEAN AcpiGbl_MethodExecuting; extern BOOLEAN AcpiGbl_DbTerminateThreads; ACPI_EXTERN int optind; ACPI_EXTERN NATIVE_CHAR *optarg; ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_tables; ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_stats; ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_ini_methods; ACPI_EXTERN NATIVE_CHAR *AcpiGbl_DbArgs[ACPI_DEBUGGER_MAX_ARGS]; ACPI_EXTERN NATIVE_CHAR AcpiGbl_DbLineBuf[80]; ACPI_EXTERN NATIVE_CHAR AcpiGbl_DbParsedBuf[80]; ACPI_EXTERN NATIVE_CHAR AcpiGbl_DbScopeBuf[40]; ACPI_EXTERN NATIVE_CHAR AcpiGbl_DbDebugFilename[40]; ACPI_EXTERN BOOLEAN AcpiGbl_DbOutputToFile; ACPI_EXTERN NATIVE_CHAR *AcpiGbl_DbBuffer; ACPI_EXTERN NATIVE_CHAR *AcpiGbl_DbFilename; ACPI_EXTERN UINT32 AcpiGbl_DbDebugLevel; ACPI_EXTERN UINT32 AcpiGbl_DbConsoleDebugLevel; ACPI_EXTERN ACPI_TABLE_HEADER *AcpiGbl_DbTablePtr; ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_DbScopeNode; /* * Statistic globals */ -ACPI_EXTERN UINT16 AcpiGbl_ObjTypeCount[INTERNAL_TYPE_NODE_MAX+1]; -ACPI_EXTERN UINT16 AcpiGbl_NodeTypeCount[INTERNAL_TYPE_NODE_MAX+1]; +ACPI_EXTERN UINT16 AcpiGbl_ObjTypeCount[ACPI_TYPE_NS_NODE_MAX+1]; +ACPI_EXTERN UINT16 AcpiGbl_NodeTypeCount[ACPI_TYPE_NS_NODE_MAX+1]; ACPI_EXTERN UINT16 AcpiGbl_ObjTypeCountMisc; ACPI_EXTERN UINT16 AcpiGbl_NodeTypeCountMisc; ACPI_EXTERN UINT32 AcpiGbl_NumNodes; ACPI_EXTERN UINT32 AcpiGbl_NumObjects; ACPI_EXTERN UINT32 AcpiGbl_SizeOfParseTree; ACPI_EXTERN UINT32 AcpiGbl_SizeOfMethodTrees; ACPI_EXTERN UINT32 AcpiGbl_SizeOfNodeEntries; ACPI_EXTERN UINT32 AcpiGbl_SizeOfAcpiObjects; #endif /* ACPI_DEBUGGER */ #endif /* __ACGLOBAL_H__ */ diff --git a/sys/contrib/dev/acpica/acinterp.h b/sys/contrib/dev/acpica/acinterp.h index 1f9f9d38e49c..be9c0875ebed 100644 --- a/sys/contrib/dev/acpica/acinterp.h +++ b/sys/contrib/dev/acpica/acinterp.h @@ -1,811 +1,808 @@ /****************************************************************************** * * Name: acinterp.h - Interpreter subcomponent prototypes and defines - * $Revision: 139 $ + * $Revision: 142 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __ACINTERP_H__ #define __ACINTERP_H__ #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, ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExConvertToBuffer ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExConvertToString ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, UINT32 Base, UINT32 MaxLength, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExConvertToTargetType ( ACPI_OBJECT_TYPE DestinationType, ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState); UINT32 AcpiExConvertToAscii ( ACPI_INTEGER Integer, UINT32 Base, UINT8 *String); /* * exfield - ACPI AML (p-code) execution - field manipulation */ 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, ACPI_INTEGER FieldValue, UINT32 FieldDatumByteOffset); void AcpiExGetBufferDatum( ACPI_INTEGER *Datum, void *Buffer, UINT32 ByteGranularity, UINT32 Offset); void AcpiExSetBufferDatum ( ACPI_INTEGER MergedDatum, void *Buffer, UINT32 ByteGranularity, UINT32 Offset); ACPI_STATUS AcpiExReadDataFromField ( ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **RetBufferDesc); ACPI_STATUS AcpiExWriteDataToField ( ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *ObjDesc); + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc); /* * exmisc - ACPI AML (p-code) execution - specific opcodes */ ACPI_STATUS AcpiExOpcode_3A_0T_0R ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExOpcode_3A_1T_1R ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExOpcode_6A_0T_1R ( ACPI_WALK_STATE *WalkState); BOOLEAN AcpiExDoMatch ( UINT32 MatchOp, ACPI_INTEGER PackageValue, ACPI_INTEGER MatchValue); ACPI_STATUS AcpiExGetObjectReference ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ReturnDesc, 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, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExDoConcatenate ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT *ObjDesc2, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState); BOOLEAN AcpiExDoLogicalOp ( UINT16 Opcode, ACPI_INTEGER Operand0, ACPI_INTEGER Operand1); ACPI_INTEGER AcpiExDoMathOp ( UINT16 Opcode, ACPI_INTEGER Operand0, ACPI_INTEGER Operand1); ACPI_STATUS AcpiExCreateMutex ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExCreateProcessor ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExCreatePowerResource ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExCreateRegion ( UINT8 *AmlStart, UINT32 AmlLength, UINT8 RegionSpace, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExCreateTableRegion ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExCreateEvent ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExCreateAlias ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExCreateMethod ( UINT8 *AmlStart, UINT32 AmlLength, ACPI_WALK_STATE *WalkState); /* * 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, ACPI_OPERAND_OBJECT *Target, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExLoadTableOp ( ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **ReturnDesc); ACPI_STATUS AcpiExUnloadTable ( ACPI_OPERAND_OBJECT *DdbHandle); /* * exmutex - mutex support */ ACPI_STATUS AcpiExAcquireMutex ( ACPI_OPERAND_OBJECT *TimeDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExReleaseMutex ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState); void AcpiExReleaseAllMutexes ( ACPI_THREAD_STATE *Thread); void AcpiExUnlinkMutex ( ACPI_OPERAND_OBJECT *ObjDesc); void AcpiExLinkMutex ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_THREAD_STATE *Thread); /* * exprep - ACPI AML (p-code) execution - prep utilities */ ACPI_STATUS AcpiExPrepCommonFieldObject ( ACPI_OPERAND_OBJECT *ObjDesc, UINT8 FieldFlags, UINT8 FieldAttribute, UINT32 FieldBitPosition, UINT32 FieldBitLength); ACPI_STATUS AcpiExPrepFieldValue ( ACPI_CREATE_FIELD_INFO *Info); /* * exsystem - Interface to OS services */ ACPI_STATUS AcpiExSystemDoNotifyOp ( ACPI_OPERAND_OBJECT *Value, ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS AcpiExSystemDoSuspend( UINT32 Time); ACPI_STATUS AcpiExSystemDoStall ( UINT32 Time); ACPI_STATUS AcpiExSystemAcquireMutex( ACPI_OPERAND_OBJECT *Time, ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS AcpiExSystemReleaseMutex( ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS AcpiExSystemSignalEvent( ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS AcpiExSystemWaitEvent( ACPI_OPERAND_OBJECT *Time, ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS AcpiExSystemResetEvent( ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS AcpiExSystemWaitSemaphore ( ACPI_HANDLE Semaphore, - UINT32 Timeout); + UINT16 Timeout); /* * exmonadic - ACPI AML (p-code) execution, monadic operators */ ACPI_STATUS AcpiExOpcode_1A_0T_0R ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExOpcode_1A_0T_1R ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExOpcode_1A_1T_1R ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExOpcode_1A_1T_0R ( ACPI_WALK_STATE *WalkState); /* * exdyadic - ACPI AML (p-code) execution, dyadic operators */ ACPI_STATUS AcpiExOpcode_2A_0T_0R ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExOpcode_2A_0T_1R ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExOpcode_2A_1T_1R ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExOpcode_2A_2T_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 AcpiExResolveNodeToValue ( ACPI_NAMESPACE_NODE **StackPtr, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExResolveObjectToValue ( ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState); /* * exdump - Scanner debug output routines */ void AcpiExDumpOperand ( ACPI_OPERAND_OBJECT *EntryDesc); void AcpiExDumpOperands ( ACPI_OPERAND_OBJECT **Operands, ACPI_INTERPRETER_MODE InterpreterMode, NATIVE_CHAR *Ident, UINT32 NumLevels, NATIVE_CHAR *Note, NATIVE_CHAR *ModuleName, UINT32 LineNumber); void AcpiExDumpObjectDescriptor ( ACPI_OPERAND_OBJECT *Object, UINT32 Flags); void 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 */ NATIVE_CHAR * AcpiExAllocateNameString ( UINT32 PrefixCount, UINT32 NumNameSegs); UINT32 AcpiExGoodChar ( UINT32 Character); ACPI_STATUS AcpiExNameSegment ( UINT8 **InAmlAddress, NATIVE_CHAR *NameString); ACPI_STATUS AcpiExGetNameString ( ACPI_OBJECT_TYPE DataType, UINT8 *InAmlAddress, NATIVE_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, ACPI_OPERAND_OBJECT *DestDesc, 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, ACPI_WALK_STATE *WalkState); /* * exstoren */ ACPI_STATUS AcpiExResolveObject ( ACPI_OPERAND_OBJECT **SourceDescPtr, ACPI_OBJECT_TYPE TargetType, ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiExStoreObjectToObject ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc, ACPI_OPERAND_OBJECT **NewDesc, ACPI_WALK_STATE *WalkState); /* * excopy - object copy */ ACPI_STATUS AcpiExStoreBufferToBuffer ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc); ACPI_STATUS AcpiExStoreStringToString ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc); ACPI_STATUS AcpiExCopyIntegerToIndexField ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc); ACPI_STATUS AcpiExCopyIntegerToBankField ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc); ACPI_STATUS AcpiExCopyDataToNamedField ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_NAMESPACE_NODE *Node); ACPI_STATUS AcpiExCopyIntegerToBufferField ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc); /* * exutils - interpreter/scanner utilities */ ACPI_STATUS AcpiExEnterInterpreter ( void); void AcpiExExitInterpreter ( void); void AcpiExTruncateFor32bitTable ( ACPI_OPERAND_OBJECT *ObjDesc); -BOOLEAN -AcpiExValidateObjectType ( - ACPI_OBJECT_TYPE Type); - BOOLEAN AcpiExAcquireGlobalLock ( UINT32 Rule); void AcpiExReleaseGlobalLock ( BOOLEAN Locked); UINT32 AcpiExDigitsNeeded ( ACPI_INTEGER Value, UINT32 Base); void AcpiExEisaIdToString ( UINT32 NumericId, NATIVE_CHAR *OutString); void AcpiExUnsignedIntegerToString ( ACPI_INTEGER Value, NATIVE_CHAR *OutString); /* * exregion - default OpRegion handlers */ ACPI_STATUS AcpiExSystemMemorySpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, ACPI_INTEGER *Value, void *HandlerContext, void *RegionContext); ACPI_STATUS AcpiExSystemIoSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, ACPI_INTEGER *Value, void *HandlerContext, void *RegionContext); ACPI_STATUS AcpiExPciConfigSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, ACPI_INTEGER *Value, void *HandlerContext, void *RegionContext); ACPI_STATUS AcpiExCmosSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, ACPI_INTEGER *Value, void *HandlerContext, void *RegionContext); ACPI_STATUS AcpiExPciBarSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, ACPI_INTEGER *Value, void *HandlerContext, void *RegionContext); ACPI_STATUS AcpiExEmbeddedControllerSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, ACPI_INTEGER *Value, void *HandlerContext, void *RegionContext); ACPI_STATUS AcpiExSmBusSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, ACPI_INTEGER *Value, void *HandlerContext, void *RegionContext); ACPI_STATUS AcpiExDataTableSpaceHandler ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, ACPI_INTEGER *Value, void *HandlerContext, void *RegionContext); #endif /* __INTERP_H__ */ diff --git a/sys/contrib/dev/acpica/aclocal.h b/sys/contrib/dev/acpica/aclocal.h index dd714d888808..f2baeb80f0ba 100644 --- a/sys/contrib/dev/acpica/aclocal.h +++ b/sys/contrib/dev/acpica/aclocal.h @@ -1,1079 +1,1079 @@ /****************************************************************************** * * Name: aclocal.h - Internal data types used across the ACPI subsystem - * $Revision: 176 $ + * $Revision: 179 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __ACLOCAL_H__ #define __ACLOCAL_H__ -#define WAIT_FOREVER ((UINT32) -1) +#define ACPI_WAIT_FOREVER 0xFFFF /* UINT16, as per ACPI spec */ typedef void* ACPI_MUTEX; typedef UINT32 ACPI_MUTEX_HANDLE; /* Total number of aml opcodes defined */ #define AML_NUM_OPCODES 0x7E /***************************************************************************** * * Mutex typedefs and structs * ****************************************************************************/ /* * Predefined handles for the mutex objects used within the subsystem * All mutex objects are automatically created by AcpiUtMutexInitialize. * * The acquire/release ordering protocol is implied via this list. Mutexes * with a lower value must be acquired before mutexes with a higher value. * * 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 #define ACPI_MTX_DISPATCHER 3 #define ACPI_MTX_TABLES 4 #define ACPI_MTX_OP_REGIONS 5 #define ACPI_MTX_NAMESPACE 6 #define ACPI_MTX_EVENTS 7 #define ACPI_MTX_HARDWARE 8 #define ACPI_MTX_CACHES 9 #define ACPI_MTX_MEMORY 10 #define ACPI_MTX_DEBUG_CMD_COMPLETE 11 #define ACPI_MTX_DEBUG_CMD_READY 12 #define MAX_MTX 12 #define NUM_MTX MAX_MTX+1 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) #ifdef DEFINE_ACPI_GLOBALS /* Names for the mutexes used in the subsystem */ static NATIVE_CHAR *AcpiGbl_MutexNames[] = { "ACPI_MTX_Execute", "ACPI_MTX_Interpreter", "ACPI_MTX_Parser", "ACPI_MTX_Dispatcher", "ACPI_MTX_Tables", "ACPI_MTX_OpRegions", "ACPI_MTX_Namespace", "ACPI_MTX_Events", "ACPI_MTX_Hardware", "ACPI_MTX_Caches", "ACPI_MTX_Memory", "ACPI_MTX_DebugCmdComplete", "ACPI_MTX_DebugCmdReady", }; #endif #endif /* Table for the global mutexes */ typedef struct AcpiMutexInfo { ACPI_MUTEX Mutex; UINT32 UseCount; UINT32 OwnerId; } 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 */ #define ACPI_MTX_DO_NOT_LOCK 0 #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 0x0000 #define ACPI_FIRST_TABLE_ID 0x8000 /* TBD: [Restructure] get rid of the need for this! */ #define TABLE_ID_DSDT (ACPI_OWNER_ID) 0x8000 /* Field access granularities */ #define ACPI_FIELD_BYTE_GRANULARITY 1 #define ACPI_FIELD_WORD_GRANULARITY 2 #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 { ACPI_IMODE_LOAD_PASS1 = 0x01, ACPI_IMODE_LOAD_PASS2 = 0x02, ACPI_IMODE_EXECUTE = 0x0E } ACPI_INTERPRETER_MODE; /* * The Node describes a named object that appears in the AML * An AcpiNode is used to store Nodes. * * DataType is used to differentiate between internal descriptors, and MUST * be the first byte in this structure. */ typedef union acpi_name_union { UINT32 Integer; char Ascii[4]; } ACPI_NAME_UNION; typedef struct acpi_node { UINT8 Descriptor; /* Used to differentiate object descriptor types */ UINT8 Type; /* Type associated with this name */ UINT16 OwnerId; ACPI_NAME_UNION Name; /* ACPI Name, always 4 chars per ACPI spec */ union acpi_operand_obj *Object; /* Pointer to attached ACPI object (optional) */ struct acpi_node *Child; /* first child */ struct acpi_node *Peer; /* Next peer*/ UINT16 ReferenceCount; /* Current count of references and children */ UINT8 Flags; } ACPI_NAMESPACE_NODE; #define ACPI_ENTRY_NOT_FOUND NULL /* Node flags */ #define ANOBJ_RESERVED 0x01 #define ANOBJ_END_OF_PEER_LIST 0x02 #define ANOBJ_DATA_WIDTH_32 0x04 /* Parent table is 64-bits */ #define ANOBJ_METHOD_ARG 0x08 #define ANOBJ_METHOD_LOCAL 0x10 #define ANOBJ_METHOD_NO_RETVAL 0x20 #define ANOBJ_METHOD_SOME_NO_RETVAL 0x40 #define ANOBJ_IS_BIT_OFFSET 0x80 /* * ACPI Table Descriptor. One per ACPI table */ typedef struct AcpiTableDesc { struct AcpiTableDesc *Prev; struct AcpiTableDesc *Next; struct AcpiTableDesc *InstalledDesc; ACPI_TABLE_HEADER *Pointer; - void *BasePointer; UINT8 *AmlStart; UINT64 PhysicalAddress; UINT32 AmlLength; ACPI_SIZE Length; UINT32 Count; ACPI_OWNER_ID TableId; UINT8 Type; UINT8 Allocation; BOOLEAN LoadedIntoNamespace; } ACPI_TABLE_DESC; typedef struct { NATIVE_CHAR *SearchFor; ACPI_HANDLE *List; UINT32 *Count; } ACPI_FIND_CONTEXT; typedef struct { ACPI_NAMESPACE_NODE *Node; } ACPI_NS_SEARCH_DATA; /* * Predefined Namespace items */ typedef struct { NATIVE_CHAR *Name; UINT8 Type; NATIVE_CHAR *Val; } ACPI_PREDEFINED_NAMES; /* Object types used during package copies */ #define ACPI_COPY_TYPE_SIMPLE 0 #define ACPI_COPY_TYPE_PACKAGE 1 /* Info structure used to convert external<->internal namestrings */ typedef struct acpi_namestring_info { NATIVE_CHAR *ExternalName; NATIVE_CHAR *NextExternalChar; NATIVE_CHAR *InternalName; UINT32 Length; UINT32 NumSegments; UINT32 NumCarats; BOOLEAN FullyQualified; } ACPI_NAMESTRING_INFO; /* Field creation info */ typedef struct { ACPI_NAMESPACE_NODE *RegionNode; ACPI_NAMESPACE_NODE *FieldNode; ACPI_NAMESPACE_NODE *RegisterNode; ACPI_NAMESPACE_NODE *DataRegisterNode; UINT32 BankValue; UINT32 FieldBitPosition; UINT32 FieldBitLength; UINT8 FieldFlags; UINT8 Attribute; UINT8 FieldType; } ACPI_CREATE_FIELD_INFO; /***************************************************************************** * * Event typedefs and structs * ****************************************************************************/ /* Information about each GPE register block */ typedef struct { UINT8 AddressSpaceId; ACPI_GENERIC_ADDRESS *BlockAddress; UINT16 RegisterCount; UINT8 BlockBaseNumber; } ACPI_GPE_BLOCK_INFO; /* Information about a particular GPE register pair */ typedef struct { ACPI_GENERIC_ADDRESS StatusAddress; /* Address of status reg */ ACPI_GENERIC_ADDRESS EnableAddress; /* Address of enable reg */ UINT8 Status; /* Current value of status reg */ UINT8 Enable; /* Current value of enable reg */ UINT8 WakeEnable; /* Mask of bits to keep enabled when sleeping */ UINT8 BaseGpeNumber; /* Base GPE number for this register */ } ACPI_GPE_REGISTER_INFO; #define ACPI_GPE_LEVEL_TRIGGERED 1 #define ACPI_GPE_EDGE_TRIGGERED 2 /* Information about each particular GPE level */ typedef struct { ACPI_HANDLE MethodHandle; /* Method handle for direct (fast) execution */ ACPI_GPE_HANDLER Handler; /* Address of handler, if any */ void *Context; /* Context to be passed to handler */ UINT8 Type; /* Level or Edge */ UINT8 BitMask; } ACPI_GPE_NUMBER_INFO; typedef struct { UINT8 NumberIndex; } ACPI_GPE_INDEX_INFO; /* Information about each particular fixed event */ typedef struct { ACPI_EVENT_HANDLER Handler; /* Address of handler. */ void *Context; /* Context to be passed to handler */ } ACPI_FIXED_EVENT_HANDLER; typedef struct { UINT8 StatusRegisterId; UINT8 EnableRegisterId; UINT16 StatusBitMask; UINT16 EnableBitMask; } ACPI_FIXED_EVENT_INFO; /* Information used during field processing */ typedef struct { UINT8 SkipField; UINT8 FieldFlag; UINT32 PkgLength; } ACPI_FIELD_INFO; /***************************************************************************** * * Generic "state" object for stacks * ****************************************************************************/ #define ACPI_CONTROL_NORMAL 0xC0 #define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1 #define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2 #define ACPI_CONTROL_PREDICATE_FALSE 0xC3 #define ACPI_CONTROL_PREDICATE_TRUE 0xC4 /* Forward declarations */ struct acpi_walk_state; struct acpi_obj_mutex; union acpi_parse_obj; #define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\ UINT8 DataType; /* To differentiate various internal objs */\ UINT8 Flags; \ UINT16 Value; \ UINT16 State; \ UINT16 Reserved; \ void *Next; \ typedef struct acpi_common_state { ACPI_STATE_COMMON } ACPI_COMMON_STATE; /* * Update state - used to traverse complex objects such as packages */ typedef struct acpi_update_state { ACPI_STATE_COMMON union acpi_operand_obj *Object; } ACPI_UPDATE_STATE; /* * Pkg state - used to traverse nested package structures */ typedef struct acpi_pkg_state { ACPI_STATE_COMMON union acpi_operand_obj *SourceObject; union acpi_operand_obj *DestObject; struct acpi_walk_state *WalkState; void *ThisTargetObj; UINT32 NumPackages; UINT16 Index; } ACPI_PKG_STATE; /* * Control state - one per if/else and while constructs. * Allows nesting of these constructs */ typedef struct acpi_control_state { ACPI_STATE_COMMON union acpi_parse_obj *PredicateOp; UINT8 *AmlPredicateStart; /* Start of if/while predicate */ UINT8 *PackageEnd; /* End of if/while block */ UINT16 Opcode; } ACPI_CONTROL_STATE; /* * Scope state - current scope during namespace lookups */ typedef struct acpi_scope_state { ACPI_STATE_COMMON ACPI_NAMESPACE_NODE *Node; } ACPI_SCOPE_STATE; typedef struct acpi_pscope_state { ACPI_STATE_COMMON union acpi_parse_obj *Op; /* current op being parsed */ UINT8 *ArgEnd; /* current argument end */ UINT8 *PkgEnd; /* current package end */ UINT32 ArgList; /* next argument to parse */ UINT32 ArgCount; /* Number of fixed arguments */ } ACPI_PSCOPE_STATE; /* * Thread state - one per thread across multiple walk states. Multiple walk * states are created when there are nested control methods executing. */ typedef struct acpi_thread_state { ACPI_STATE_COMMON struct acpi_walk_state *WalkStateList; /* Head of list of WalkStates for this thread */ union acpi_operand_obj *AcquiredMutexList; /* List of all currently acquired mutexes */ UINT32 ThreadId; /* Running thread ID */ UINT16 CurrentSyncLevel; /* Mutex Sync (nested acquire) level */ } ACPI_THREAD_STATE; /* * Result values - used to accumulate the results of nested * AML arguments */ typedef struct acpi_result_values { ACPI_STATE_COMMON union acpi_operand_obj *ObjDesc [OBJ_NUM_OPERANDS]; UINT8 NumResults; UINT8 LastInsert; } ACPI_RESULT_VALUES; typedef ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) ( struct acpi_walk_state *WalkState, union acpi_parse_obj **OutOp); typedef ACPI_STATUS (*ACPI_PARSE_UPWARDS) ( struct acpi_walk_state *WalkState); /* * Notify info - used to pass info to the deferred notify * handler/dispatcher. */ typedef struct acpi_notify_info { ACPI_STATE_COMMON ACPI_NAMESPACE_NODE *Node; union acpi_operand_obj *HandlerObj; } ACPI_NOTIFY_INFO; /* Generic state is union of structs above */ typedef union acpi_gen_state { ACPI_COMMON_STATE Common; ACPI_CONTROL_STATE Control; ACPI_UPDATE_STATE Update; ACPI_SCOPE_STATE Scope; ACPI_PSCOPE_STATE ParseScope; ACPI_PKG_STATE Pkg; ACPI_THREAD_STATE Thread; ACPI_RESULT_VALUES Results; ACPI_NOTIFY_INFO Notify; } ACPI_GENERIC_STATE; /***************************************************************************** * * Interpreter typedefs and structs * ****************************************************************************/ typedef ACPI_STATUS (*ACPI_EXECUTE_OP) ( struct acpi_walk_state *WalkState); /***************************************************************************** * * Parser typedefs and structs * ****************************************************************************/ /* * AML opcode, name, and argument layout */ typedef struct acpi_opcode_info { #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT) NATIVE_CHAR *Name; /* Opcode name (disassembler/debug only) */ #endif UINT32 ParseArgs; /* Grammar/Parse time arguments */ UINT32 RuntimeArgs; /* Interpret time arguments */ UINT32 Flags; /* Misc flags */ UINT8 ObjectType; /* Corresponding internal object type */ UINT8 Class; /* Opcode class */ UINT8 Type; /* Opcode type */ } ACPI_OPCODE_INFO; typedef union acpi_parse_val { ACPI_INTEGER Integer; /* integer constant (Up to 64 bits) */ UINT64_STRUCT Integer64; /* Structure overlay for 2 32-bit Dwords */ UINT32 Integer32; /* integer constant, 32 bits only */ UINT16 Integer16; /* integer constant, 16 bits only */ UINT8 Integer8; /* integer constant, 8 bits only */ UINT32 Size; /* bytelist or field size */ NATIVE_CHAR *String; /* NULL terminated string */ UINT8 *Buffer; /* buffer or string */ NATIVE_CHAR *Name; /* NULL terminated string */ union acpi_parse_obj *Arg; /* arguments and contained ops */ } ACPI_PARSE_VALUE; #define ACPI_PARSE_COMMON \ UINT8 DataType; /* To differentiate various internal objs */\ UINT8 Flags; /* Type of Op */\ UINT16 AmlOpcode; /* AML opcode */\ UINT32 AmlOffset; /* offset of declaration in AML */\ union acpi_parse_obj *Parent; /* parent op */\ union acpi_parse_obj *Next; /* next op */\ ACPI_DISASM_ONLY_MEMBERS (\ UINT8 DisasmFlags; /* Used during AML disassembly */\ UINT8 DisasmOpcode; /* Subtype used for disassembly */\ NATIVE_CHAR AmlOpName[16]) /* op name (debug only) */\ /* NON-DEBUG members below: */\ ACPI_NAMESPACE_NODE *Node; /* for use by interpreter */\ ACPI_PARSE_VALUE Value; /* Value or args associated with the opcode */\ #define ACPI_DASM_BUFFER 0x00 #define ACPI_DASM_RESOURCE 0x01 #define ACPI_DASM_STRING 0x02 #define ACPI_DASM_UNICODE 0x03 #define ACPI_DASM_EISAID 0x04 #define ACPI_DASM_MATCHOP 0x05 /* * generic operation (for example: If, While, Store) */ typedef struct acpi_parseobj_common { ACPI_PARSE_COMMON } ACPI_PARSE_OBJ_COMMON; /* * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and OpRegions), * and bytelists. */ typedef struct acpi_parseobj_named { ACPI_PARSE_COMMON UINT8 *Path; UINT8 *Data; /* AML body or bytelist data */ UINT32 Length; /* AML length */ UINT32 Name; /* 4-byte name or zero if no name */ } ACPI_PARSE_OBJ_NAMED; /* The parse node is the fundamental element of the parse tree */ typedef struct acpi_parseobj_asl { ACPI_PARSE_COMMON union acpi_parse_obj *Child; union acpi_parse_obj *ParentMethod; char *Filename; char *ExternalName; char *Namepath; + char NameSeg[4]; UINT32 ExtraValue; UINT32 Column; UINT32 LineNumber; UINT32 LogicalLineNumber; UINT32 LogicalByteOffset; UINT32 EndLine; UINT32 EndLogicalLine; UINT32 AcpiBtype; UINT32 AmlLength; UINT32 AmlSubtreeLength; UINT32 FinalAmlLength; UINT32 FinalAmlOffset; UINT32 CompileFlags; UINT16 ParseOpcode; UINT8 AmlOpcodeLength; UINT8 AmlPkgLenBytes; UINT8 Extra; char ParseOpName[12]; } ACPI_PARSE_OBJ_ASL; typedef union acpi_parse_obj { ACPI_PARSE_OBJ_COMMON Common; ACPI_PARSE_OBJ_NAMED Named; ACPI_PARSE_OBJ_ASL Asl; } ACPI_PARSE_OBJECT; /* * Parse state - one state per parser invocation and each control * method. */ typedef struct acpi_parse_state { UINT32 AmlSize; UINT8 *AmlStart; /* first AML byte */ UINT8 *Aml; /* next AML byte */ UINT8 *AmlEnd; /* (last + 1) AML byte */ UINT8 *PkgStart; /* current package begin */ UINT8 *PkgEnd; /* current package end */ union acpi_parse_obj *StartOp; /* root of parse tree */ struct acpi_node *StartNode; union acpi_gen_state *Scope; /* current scope */ union acpi_parse_obj *StartScope; } ACPI_PARSE_STATE; /* Parse object flags */ #define ACPI_PARSEOP_GENERIC 0x01 #define ACPI_PARSEOP_NAMED 0x02 #define ACPI_PARSEOP_DEFERRED 0x04 #define ACPI_PARSEOP_BYTELIST 0x08 #define ACPI_PARSEOP_IN_CACHE 0x80 /* Parse object DisasmFlags */ #define ACPI_PARSEOP_IGNORE 0x01 #define ACPI_PARSEOP_PARAMLIST 0x02 #define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 #define ACPI_PARSEOP_SPECIAL 0x10 /***************************************************************************** * * Hardware (ACPI registers) and PNP * ****************************************************************************/ #define PCI_ROOT_HID_STRING "PNP0A03" typedef struct { UINT8 ParentRegister; UINT8 BitPosition; UINT16 AccessBitMask; } ACPI_BIT_REGISTER_INFO; /* * Register IDs * These are the full ACPI registers */ #define ACPI_REGISTER_PM1_STATUS 0x01 #define ACPI_REGISTER_PM1_ENABLE 0x02 #define ACPI_REGISTER_PM1_CONTROL 0x03 #define ACPI_REGISTER_PM1A_CONTROL 0x04 #define ACPI_REGISTER_PM1B_CONTROL 0x05 #define ACPI_REGISTER_PM2_CONTROL 0x06 #define ACPI_REGISTER_PM_TIMER 0x07 #define ACPI_REGISTER_PROCESSOR_BLOCK 0x08 #define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x09 /* Masks used to access the BitRegisters */ #define ACPI_BITMASK_TIMER_STATUS 0x0001 #define ACPI_BITMASK_BUS_MASTER_STATUS 0x0010 #define ACPI_BITMASK_GLOBAL_LOCK_STATUS 0x0020 #define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100 #define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200 #define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400 #define ACPI_BITMASK_WAKE_STATUS 0x8000 #define ACPI_BITMASK_ALL_FIXED_STATUS (ACPI_BITMASK_TIMER_STATUS | \ ACPI_BITMASK_BUS_MASTER_STATUS | \ ACPI_BITMASK_GLOBAL_LOCK_STATUS | \ ACPI_BITMASK_POWER_BUTTON_STATUS | \ ACPI_BITMASK_SLEEP_BUTTON_STATUS | \ ACPI_BITMASK_RT_CLOCK_STATUS | \ ACPI_BITMASK_WAKE_STATUS) #define ACPI_BITMASK_TIMER_ENABLE 0x0001 #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020 #define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100 #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200 #define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400 #define ACPI_BITMASK_SCI_ENABLE 0x0001 #define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004 #define ACPI_BITMASK_SLEEP_TYPE_X 0x1C00 #define ACPI_BITMASK_SLEEP_ENABLE 0x2000 #define ACPI_BITMASK_ARB_DISABLE 0x0001 /* Raw bit position of each BitRegister */ #define ACPI_BITPOSITION_TIMER_STATUS 0x00 #define ACPI_BITPOSITION_BUS_MASTER_STATUS 0x04 #define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS 0x05 #define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08 #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09 #define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A #define ACPI_BITPOSITION_WAKE_STATUS 0x0F #define ACPI_BITPOSITION_TIMER_ENABLE 0x00 #define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE 0x05 #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08 #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09 #define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A #define ACPI_BITPOSITION_SCI_ENABLE 0x00 #define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02 #define ACPI_BITPOSITION_SLEEP_TYPE_X 0x0A #define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D #define ACPI_BITPOSITION_ARB_DISABLE 0x00 /***************************************************************************** * * Resource descriptors * ****************************************************************************/ /* ResourceType values */ #define ACPI_RESOURCE_TYPE_MEMORY_RANGE 0 #define ACPI_RESOURCE_TYPE_IO_RANGE 1 #define ACPI_RESOURCE_TYPE_BUS_NUMBER_RANGE 2 /* Resource descriptor types and masks */ #define ACPI_RDESC_TYPE_LARGE 0x80 #define ACPI_RDESC_TYPE_SMALL 0x00 #define ACPI_RDESC_TYPE_MASK 0x80 #define ACPI_RDESC_SMALL_MASK 0x78 /* Only bits 6:3 contain the type */ /* * Small resource descriptor types * Note: The 3 length bits (2:0) must be zero */ #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 /* * Large resource descriptor types */ #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 /* String version of device HIDs and UIDs */ #define ACPI_DEVICE_ID_LENGTH 0x09 typedef struct { char Buffer[ACPI_DEVICE_ID_LENGTH]; } ACPI_DEVICE_ID; /***************************************************************************** * * Miscellaneous * ****************************************************************************/ #define ACPI_ASCII_ZERO 0x30 /***************************************************************************** * * Debugger * ****************************************************************************/ typedef struct dbmethodinfo { ACPI_HANDLE ThreadGate; NATIVE_CHAR *Name; NATIVE_CHAR **Args; UINT32 Flags; UINT32 NumLoops; NATIVE_CHAR Pathname[128]; } ACPI_DB_METHOD_INFO; #define ACPI_DB_REDIRECTABLE_OUTPUT 0x01 #define ACPI_DB_CONSOLE_OUTPUT 0x02 #define ACPI_DB_DUPLICATE_OUTPUT 0x03 /***************************************************************************** * * Debug * ****************************************************************************/ typedef struct { UINT32 ComponentId; NATIVE_CHAR *ProcName; NATIVE_CHAR *ModuleName; } ACPI_DEBUG_PRINT_INFO; /* Entry for a memory allocation (debug only) */ #define ACPI_MEM_MALLOC 0 #define ACPI_MEM_CALLOC 1 #define ACPI_MAX_MODULE_NAME 16 #define ACPI_COMMON_DEBUG_MEM_HEADER \ struct AcpiDebugMemBlock *Previous; \ struct AcpiDebugMemBlock *Next; \ UINT32 Size; \ UINT32 Component; \ UINT32 Line; \ NATIVE_CHAR Module[ACPI_MAX_MODULE_NAME]; \ UINT8 AllocType; typedef struct { ACPI_COMMON_DEBUG_MEM_HEADER } ACPI_DEBUG_MEM_HEADER; typedef struct AcpiDebugMemBlock { ACPI_COMMON_DEBUG_MEM_HEADER UINT64 UserSpace; } 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 typedef struct { void *ListHead; UINT16 LinkOffset; UINT16 MaxCacheDepth; UINT16 CacheDepth; UINT16 ObjectSize; #ifdef ACPI_DBG_TRACK_ALLOCATIONS /* Statistics for debug memory tracking only */ UINT32 TotalAllocated; UINT32 TotalFreed; UINT32 CurrentTotalSize; UINT32 CacheRequests; UINT32 CacheHits; char *ListName; #endif } ACPI_MEMORY_LIST; #endif /* __ACLOCAL_H__ */ diff --git a/sys/contrib/dev/acpica/acnamesp.h b/sys/contrib/dev/acpica/acnamesp.h index e14ef80ffd5a..d38183d7aa4b 100644 --- a/sys/contrib/dev/acpica/acnamesp.h +++ b/sys/contrib/dev/acpica/acnamesp.h @@ -1,566 +1,566 @@ /****************************************************************************** * * Name: acnamesp.h - Namespace subcomponent prototypes and defines - * $Revision: 127 $ + * $Revision: 129 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __ACNAMESP_H__ #define __ACNAMESP_H__ /* To search the entire name space, pass this as SearchBase */ #define ACPI_NS_ALL ((ACPI_HANDLE)0) /* * Elements of AcpiNsProperties are bit significant * and should be one-to-one with values of ACPI_OBJECT_TYPE */ #define ACPI_NS_NORMAL 0 #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 #define ACPI_NS_SEARCH_PARENT 0x01 #define ACPI_NS_DONT_OPEN_SCOPE 0x02 #define ACPI_NS_NO_PEER_SEARCH 0x04 #define ACPI_NS_ERROR_IF_FOUND 0x08 #define ACPI_NS_WALK_UNLOCK TRUE #define ACPI_NS_WALK_NO_UNLOCK FALSE ACPI_STATUS AcpiNsLoadNamespace ( void); ACPI_STATUS AcpiNsInitializeObjects ( void); ACPI_STATUS AcpiNsInitializeDevices ( void); /* Namespace init - nsxfinit */ ACPI_STATUS AcpiNsInitOneDevice ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue); ACPI_STATUS AcpiNsInitOneObject ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue); ACPI_STATUS AcpiNsWalkNamespace ( ACPI_OBJECT_TYPE Type, ACPI_HANDLE StartObject, UINT32 MaxDepth, BOOLEAN UnlockBeforeCallback, ACPI_WALK_CALLBACK UserFunction, void *Context, void **ReturnValue); ACPI_NAMESPACE_NODE * AcpiNsGetNextNode ( ACPI_OBJECT_TYPE Type, ACPI_NAMESPACE_NODE *Parent, ACPI_NAMESPACE_NODE *Child); void AcpiNsDeleteNamespaceByOwner ( UINT16 TableId); /* Namespace loading - nsload */ ACPI_STATUS AcpiNsOneCompleteParse ( UINT32 PassNumber, ACPI_TABLE_DESC *TableDesc); 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); /* * Top-level namespace access - nsaccess */ ACPI_STATUS AcpiNsRootInitialize ( void); ACPI_STATUS AcpiNsLookup ( ACPI_GENERIC_STATE *ScopeInfo, NATIVE_CHAR *Name, ACPI_OBJECT_TYPE Type, ACPI_INTERPRETER_MODE InterpreterMode, UINT32 Flags, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **RetNode); /* * Named object allocation/deallocation - nsalloc */ ACPI_NAMESPACE_NODE * AcpiNsCreateNode ( UINT32 Name); void AcpiNsDeleteNode ( ACPI_NAMESPACE_NODE *Node); void AcpiNsDeleteNamespaceSubtree ( ACPI_NAMESPACE_NODE *ParentHandle); void AcpiNsDetachObject ( ACPI_NAMESPACE_NODE *Node); void AcpiNsDeleteChildren ( ACPI_NAMESPACE_NODE *Parent); +int +AcpiNsCompareNames ( + char *Name1, + char *Name2); /* * Namespace modification - nsmodify */ ACPI_STATUS AcpiNsUnloadNamespace ( ACPI_HANDLE Handle); ACPI_STATUS AcpiNsDeleteSubtree ( ACPI_HANDLE StartHandle); /* * Namespace dump/print utilities - nsdump */ void AcpiNsDumpTables ( ACPI_HANDLE SearchBase, UINT32 MaxDepth); void AcpiNsDumpEntry ( ACPI_HANDLE Handle, UINT32 DebugLevel); ACPI_STATUS AcpiNsDumpPathname ( ACPI_HANDLE Handle, NATIVE_CHAR *Msg, UINT32 Level, UINT32 Component); void AcpiNsPrintPathname ( UINT32 NumSegments, 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, void *Context, void **ReturnValue); void AcpiNsDumpObjects ( ACPI_OBJECT_TYPE Type, UINT8 DisplayType, UINT32 MaxDepth, UINT32 OwnderId, ACPI_HANDLE StartHandle); /* * Namespace evaluation functions - nseval */ ACPI_STATUS AcpiNsEvaluateByHandle ( ACPI_NAMESPACE_NODE *PrefixNode, ACPI_OPERAND_OBJECT **Params, ACPI_OPERAND_OBJECT **ReturnObject); ACPI_STATUS AcpiNsEvaluateByName ( NATIVE_CHAR *Pathname, ACPI_OPERAND_OBJECT **Params, ACPI_OPERAND_OBJECT **ReturnObject); ACPI_STATUS AcpiNsEvaluateRelative ( ACPI_NAMESPACE_NODE *PrefixNode, NATIVE_CHAR *Pathname, ACPI_OPERAND_OBJECT **Params, ACPI_OPERAND_OBJECT **ReturnObject); ACPI_STATUS AcpiNsExecuteControlMethod ( ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT **Params, ACPI_OPERAND_OBJECT **ReturnObjDesc); ACPI_STATUS AcpiNsGetObjectValue ( ACPI_NAMESPACE_NODE *ObjectNode, ACPI_OPERAND_OBJECT **ReturnObjDesc); /* - * Parent/Child/Peer utility functions - nsfamily + * Parent/Child/Peer utility functions */ ACPI_NAME AcpiNsFindParentName ( ACPI_NAMESPACE_NODE *NodeToSearch); -BOOLEAN -AcpiNsExistDownstreamSibling ( - ACPI_NAMESPACE_NODE *ThisNode); - /* * Name and Scope manipulation - nsnames */ UINT32 AcpiNsOpensScope ( ACPI_OBJECT_TYPE Type); void AcpiNsBuildExternalPath ( ACPI_NAMESPACE_NODE *Node, ACPI_SIZE Size, NATIVE_CHAR *NameBuffer); NATIVE_CHAR * AcpiNsGetExternalPathname ( ACPI_NAMESPACE_NODE *Node); NATIVE_CHAR * AcpiNsNameOfCurrentScope ( ACPI_WALK_STATE *WalkState); ACPI_STATUS AcpiNsHandleToPathname ( ACPI_HANDLE TargetHandle, ACPI_BUFFER *Buffer); BOOLEAN AcpiNsPatternMatch ( ACPI_NAMESPACE_NODE *ObjNode, NATIVE_CHAR *SearchFor); ACPI_STATUS AcpiNsGetNodeByPath ( NATIVE_CHAR *ExternalPathname, ACPI_NAMESPACE_NODE *InPrefixNode, UINT32 Flags, ACPI_NAMESPACE_NODE **OutNode); ACPI_SIZE AcpiNsGetPathnameLength ( ACPI_NAMESPACE_NODE *Node); /* * Object management for namespace nodes - nsobject */ ACPI_STATUS AcpiNsAttachObject ( ACPI_NAMESPACE_NODE *Node, ACPI_OPERAND_OBJECT *Object, ACPI_OBJECT_TYPE Type); ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject ( ACPI_NAMESPACE_NODE *Node); ACPI_OPERAND_OBJECT * AcpiNsGetSecondaryObject ( ACPI_OPERAND_OBJECT *ObjDesc); ACPI_STATUS AcpiNsAttachData ( ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_HANDLER Handler, void *Data); ACPI_STATUS AcpiNsDetachData ( ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_HANDLER Handler); ACPI_STATUS AcpiNsGetAttachedData ( ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_HANDLER Handler, void **Data); /* * Namespace searching and entry - nssearch */ ACPI_STATUS AcpiNsSearchAndEnter ( UINT32 EntryName, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE *Node, ACPI_INTERPRETER_MODE InterpreterMode, ACPI_OBJECT_TYPE Type, UINT32 Flags, ACPI_NAMESPACE_NODE **RetNode); ACPI_STATUS AcpiNsSearchNode ( UINT32 EntryName, ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, ACPI_NAMESPACE_NODE **RetNode); void AcpiNsInstallNode ( ACPI_WALK_STATE *WalkState, - ACPI_NAMESPACE_NODE *ParentNode, /* Parent */ - ACPI_NAMESPACE_NODE *Node, /* New Child*/ + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type); /* * Utility functions - nsutils */ BOOLEAN AcpiNsValidRootPrefix ( NATIVE_CHAR Prefix); BOOLEAN AcpiNsValidPathSeparator ( NATIVE_CHAR Sep); ACPI_OBJECT_TYPE AcpiNsGetType ( ACPI_NAMESPACE_NODE *Node); UINT32 AcpiNsLocal ( ACPI_OBJECT_TYPE Type); void AcpiNsReportError ( NATIVE_CHAR *ModuleName, UINT32 LineNumber, UINT32 ComponentId, char *InternalName, ACPI_STATUS LookupStatus); ACPI_STATUS AcpiNsBuildInternalName ( ACPI_NAMESTRING_INFO *Info); void AcpiNsGetInternalNameLength ( ACPI_NAMESTRING_INFO *Info); ACPI_STATUS AcpiNsInternalizeName ( NATIVE_CHAR *DottedName, NATIVE_CHAR **ConvertedName); ACPI_STATUS AcpiNsExternalizeName ( UINT32 InternalNameLength, NATIVE_CHAR *InternalName, UINT32 *ConvertedNameLength, NATIVE_CHAR **ConvertedName); ACPI_NAMESPACE_NODE * AcpiNsMapHandleToNode ( ACPI_HANDLE Handle); ACPI_HANDLE AcpiNsConvertEntryToHandle( ACPI_NAMESPACE_NODE *Node); void AcpiNsTerminate ( void); ACPI_NAMESPACE_NODE * AcpiNsGetParentNode ( ACPI_NAMESPACE_NODE *Node); 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 007e548963fd..566758de9037 100644 --- a/sys/contrib/dev/acpica/acobject.h +++ b/sys/contrib/dev/acpica/acobject.h @@ -1,613 +1,614 @@ /****************************************************************************** * * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only) - * $Revision: 113 $ + * $Revision: 114 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 _ACOBJECT_H #define _ACOBJECT_H /* * The ACPI_OPERAND_OBJECT is used to pass AML operands from the dispatcher * to the interpreter, and to keep track of the various handlers such as * address space handlers and notify handlers. The object is a constant * size in order to allow it to be cached and reused. */ /******************************************************************************* * * Common Descriptors * ******************************************************************************/ /* * Common area for all objects. * * DataType is used to differentiate between internal descriptors, and MUST * be the first byte in this structure. */ #define ACPI_OBJECT_COMMON_HEADER /* SIZE/ALIGNMENT: 32 bits, one ptr plus trailing 8-bit flag */\ UINT8 Descriptor; /* To differentiate various internal objs */\ UINT8 Type; /* ACPI_OBJECT_TYPE */\ UINT16 ReferenceCount; /* For object deletion management */\ union acpi_operand_obj *NextObject; /* Objects linked to parent NS node */\ UINT8 Flags; \ /* Values for flag byte above */ #define AOPOBJ_AML_CONSTANT 0x01 #define AOPOBJ_STATIC_POINTER 0x02 #define AOPOBJ_DATA_VALID 0x04 #define AOPOBJ_OBJECT_INITIALIZED 0x08 #define AOPOBJ_SETUP_COMPLETE 0x10 #define AOPOBJ_SINGLE_DATUM 0x20 /* * Common bitfield for the field objects * "Field Datum" -- a datum from the actual field object * "Buffer Datum" -- a datum from a user buffer, read from or to be written to the field */ #define ACPI_COMMON_FIELD_INFO /* SIZE/ALIGNMENT: 24 bits + three 32-bit values */\ UINT8 FieldFlags; /* Access, update, and lock bits */\ UINT8 Attribute; /* From AccessAs keyword */\ UINT8 AccessByteWidth; /* Read/Write size in bytes */\ 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" */\ UINT32 Value; /* Value to store into the Bank or Index register */\ ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ /* * Fields common to both Strings and Buffers */ #define ACPI_COMMON_BUFFER_INFO \ UINT32 Length; /* * Common fields for objects that support ASL notifications */ #define ACPI_COMMON_NOTIFY_INFO \ union acpi_operand_obj *SysHandler; /* Handler for system notifies */\ union acpi_operand_obj *DrvHandler; /* Handler for driver notifies */\ union acpi_operand_obj *AddrHandler; /* Handler for Address space */ /****************************************************************************** * * Basic data types * *****************************************************************************/ typedef struct AcpiObjectCommon { ACPI_OBJECT_COMMON_HEADER } ACPI_OBJECT_COMMON; typedef struct AcpiObjectInteger { ACPI_OBJECT_COMMON_HEADER ACPI_INTEGER Value; } ACPI_OBJECT_INTEGER; typedef struct AcpiObjectString /* Null terminated, ASCII characters only */ { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_BUFFER_INFO NATIVE_CHAR *Pointer; /* String in AML stream or allocated string */ } ACPI_OBJECT_STRING; typedef struct AcpiObjectBuffer { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_BUFFER_INFO UINT8 *Pointer; /* Buffer in AML stream or allocated buffer */ ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ UINT8 *AmlStart; UINT32 AmlLength; } ACPI_OBJECT_BUFFER; typedef struct AcpiObjectPackage { ACPI_OBJECT_COMMON_HEADER UINT32 Count; /* # of elements in package */ UINT32 AmlLength; UINT8 *AmlStart; ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ union acpi_operand_obj **Elements; /* Array of pointers to AcpiObjects */ } ACPI_OBJECT_PACKAGE; /****************************************************************************** * * Complex data types * *****************************************************************************/ typedef struct AcpiObjectEvent { ACPI_OBJECT_COMMON_HEADER void *Semaphore; } ACPI_OBJECT_EVENT; #define INFINITE_CONCURRENCY 0xFF typedef struct AcpiObjectMethod { ACPI_OBJECT_COMMON_HEADER UINT8 MethodFlags; UINT8 ParamCount; UINT32 AmlLength; void *Semaphore; UINT8 *AmlStart; UINT8 Concurrency; UINT8 ThreadCount; ACPI_OWNER_ID OwningId; } ACPI_OBJECT_METHOD; typedef struct AcpiObjectMutex { ACPI_OBJECT_COMMON_HEADER UINT16 SyncLevel; UINT16 AcquisitionDepth; struct acpi_thread_state *OwnerThread; void *Semaphore; union acpi_operand_obj *Prev; /* Link for list of acquired mutexes */ union acpi_operand_obj *Next; /* Link for list of acquired mutexes */ + ACPI_NAMESPACE_NODE *Node; /* containing object */ } ACPI_OBJECT_MUTEX; typedef struct AcpiObjectRegion { ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId; union acpi_operand_obj *AddrHandler; /* Handler for system notifies */ ACPI_NAMESPACE_NODE *Node; /* containing object */ union acpi_operand_obj *Next; UINT32 Length; ACPI_PHYSICAL_ADDRESS Address; } ACPI_OBJECT_REGION; /****************************************************************************** * * Objects that can be notified. All share a common NotifyInfo area. * *****************************************************************************/ typedef struct AcpiObjectNotifyCommon /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */ { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO } ACPI_OBJECT_NOTIFY_COMMON; typedef struct AcpiObjectDevice { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO } ACPI_OBJECT_DEVICE; typedef struct AcpiObjectPowerResource { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO UINT32 SystemLevel; UINT32 ResourceOrder; } ACPI_OBJECT_POWER_RESOURCE; typedef struct AcpiObjectProcessor { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO UINT32 ProcId; UINT32 Length; ACPI_IO_ADDRESS Address; } ACPI_OBJECT_PROCESSOR; typedef struct AcpiObjectThermalZone { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO } ACPI_OBJECT_THERMAL_ZONE; /****************************************************************************** * * Fields. All share a common header/info field. * *****************************************************************************/ typedef struct AcpiObjectFieldCommon /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */ { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_obj *RegionObj; /* Containing Operation Region object */ /* (REGION/BANK fields only) */ } ACPI_OBJECT_FIELD_COMMON; typedef struct AcpiObjectRegionField { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_obj *RegionObj; /* Containing OpRegion object */ } ACPI_OBJECT_REGION_FIELD; typedef struct AcpiObjectBankField { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_obj *RegionObj; /* Containing OpRegion object */ union acpi_operand_obj *BankObj; /* BankSelect Register object */ } ACPI_OBJECT_BANK_FIELD; typedef struct AcpiObjectIndexField { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO /* * No "RegionObj" pointer needed since the Index and Data registers * are each field definitions unto themselves. */ union acpi_operand_obj *IndexObj; /* Index register */ union acpi_operand_obj *DataObj; /* Data register */ } ACPI_OBJECT_INDEX_FIELD; /* The BufferField is different in that it is part of a Buffer, not an OpRegion */ typedef struct AcpiObjectBufferField { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO union acpi_operand_obj *BufferObj; /* Containing Buffer object */ } ACPI_OBJECT_BUFFER_FIELD; /****************************************************************************** * * Objects for handlers * *****************************************************************************/ typedef struct AcpiObjectNotifyHandler { ACPI_OBJECT_COMMON_HEADER ACPI_NAMESPACE_NODE *Node; /* Parent device */ ACPI_NOTIFY_HANDLER Handler; void *Context; } ACPI_OBJECT_NOTIFY_HANDLER; /* Flags for address handler */ #define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED 0x1 typedef struct AcpiObjectAddrHandler { ACPI_OBJECT_COMMON_HEADER UINT8 SpaceId; UINT16 Hflags; ACPI_ADR_SPACE_HANDLER Handler; ACPI_NAMESPACE_NODE *Node; /* Parent device */ void *Context; ACPI_ADR_SPACE_SETUP Setup; union acpi_operand_obj *RegionList; /* regions using this handler */ union acpi_operand_obj *Next; } ACPI_OBJECT_ADDR_HANDLER; /****************************************************************************** * * Special internal objects * *****************************************************************************/ /* * The Reference object type is used for these opcodes: * Arg[0-6], Local[0-7], IndexOp, NameOp, ZeroOp, OneOp, OnesOp, DebugOp */ typedef struct AcpiObjectReference { ACPI_OBJECT_COMMON_HEADER UINT8 TargetType; /* Used for IndexOp */ UINT16 Opcode; UINT32 Offset; /* Used for ArgOp, LocalOp, and IndexOp */ void *Object; /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT */ ACPI_NAMESPACE_NODE *Node; union acpi_operand_obj **Where; } ACPI_OBJECT_REFERENCE; /* * Extra object is used as additional storage for types that * have AML code in their declarations (TermArgs) that must be * evaluated at run time. * * Currently: Region and FieldUnit types */ typedef struct AcpiObjectExtra { ACPI_OBJECT_COMMON_HEADER UINT8 ByteFill1; UINT16 WordFill1; UINT32 AmlLength; UINT8 *AmlStart; ACPI_NAMESPACE_NODE *Method_REG; /* _REG method for this region (if any) */ void *RegionContext; /* Region-specific data */ } ACPI_OBJECT_EXTRA; /* Additional data that can be attached to namespace nodes */ typedef struct AcpiObjectData { ACPI_OBJECT_COMMON_HEADER ACPI_OBJECT_HANDLER Handler; void *Pointer; } ACPI_OBJECT_DATA; /* Structure used when objects are cached for reuse */ typedef struct AcpiObjectCacheList { ACPI_OBJECT_COMMON_HEADER union acpi_operand_obj *Next; /* Link for object cache and internal lists*/ } ACPI_OBJECT_CACHE_LIST; /****************************************************************************** * * ACPI_OPERAND_OBJECT Descriptor - a giant union of all of the above * *****************************************************************************/ typedef union acpi_operand_obj { ACPI_OBJECT_COMMON Common; ACPI_OBJECT_INTEGER Integer; ACPI_OBJECT_STRING String; ACPI_OBJECT_BUFFER Buffer; ACPI_OBJECT_PACKAGE Package; ACPI_OBJECT_EVENT Event; ACPI_OBJECT_METHOD Method; ACPI_OBJECT_MUTEX Mutex; ACPI_OBJECT_REGION Region; ACPI_OBJECT_NOTIFY_COMMON CommonNotify; ACPI_OBJECT_DEVICE Device; ACPI_OBJECT_POWER_RESOURCE PowerResource; ACPI_OBJECT_PROCESSOR Processor; ACPI_OBJECT_THERMAL_ZONE ThermalZone; ACPI_OBJECT_FIELD_COMMON CommonField; ACPI_OBJECT_REGION_FIELD Field; ACPI_OBJECT_BUFFER_FIELD BufferField; ACPI_OBJECT_BANK_FIELD BankField; ACPI_OBJECT_INDEX_FIELD IndexField; ACPI_OBJECT_NOTIFY_HANDLER NotifyHandler; ACPI_OBJECT_ADDR_HANDLER AddrHandler; ACPI_OBJECT_REFERENCE Reference; ACPI_OBJECT_EXTRA Extra; ACPI_OBJECT_DATA Data; ACPI_OBJECT_CACHE_LIST Cache; } ACPI_OPERAND_OBJECT; /****************************************************************************** * * ACPI_DESCRIPTOR - objects that share a common descriptor identifier * *****************************************************************************/ /* Object descriptor types */ #define ACPI_DESC_TYPE_CACHED 0x11 /* Used only when object is cached */ #define ACPI_DESC_TYPE_STATE 0x20 #define ACPI_DESC_TYPE_STATE_UPDATE 0x21 #define ACPI_DESC_TYPE_STATE_PACKAGE 0x22 #define ACPI_DESC_TYPE_STATE_CONTROL 0x23 #define ACPI_DESC_TYPE_STATE_RPSCOPE 0x24 #define ACPI_DESC_TYPE_STATE_PSCOPE 0x25 #define ACPI_DESC_TYPE_STATE_WSCOPE 0x26 #define ACPI_DESC_TYPE_STATE_RESULT 0x27 #define ACPI_DESC_TYPE_STATE_NOTIFY 0x28 #define ACPI_DESC_TYPE_STATE_THREAD 0x29 #define ACPI_DESC_TYPE_WALK 0x44 #define ACPI_DESC_TYPE_PARSER 0x66 #define ACPI_DESC_TYPE_OPERAND 0x88 #define ACPI_DESC_TYPE_NAMED 0xAA typedef union acpi_desc { UINT8 DescriptorId; /* To differentiate various internal objs */\ ACPI_OPERAND_OBJECT Object; ACPI_NAMESPACE_NODE Node; ACPI_PARSE_OBJECT Op; } ACPI_DESCRIPTOR; #endif /* _ACOBJECT_H */ diff --git a/sys/contrib/dev/acpica/acparser.h b/sys/contrib/dev/acpica/acparser.h index 5df55df7251b..36bba92682fe 100644 --- a/sys/contrib/dev/acpica/acparser.h +++ b/sys/contrib/dev/acpica/acparser.h @@ -1,420 +1,420 @@ /****************************************************************************** * * Module Name: acparser.h - AML Parser subcomponent prototypes and defines - * $Revision: 62 $ + * $Revision: 63 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __ACPARSER_H__ #define __ACPARSER_H__ #define OP_HAS_RETURN_VALUE 1 /* variable # arguments */ #define ACPI_VAR_ARGS ACPI_UINT32_MAX #define ACPI_PARSE_DELETE_TREE 0x0001 #define ACPI_PARSE_NO_TREE_DELETE 0x0000 #define ACPI_PARSE_TREE_MASK 0x0001 #define ACPI_PARSE_LOAD_PASS1 0x0010 #define ACPI_PARSE_LOAD_PASS2 0x0020 #define ACPI_PARSE_EXECUTE 0x0030 #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_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT **Params, ACPI_OPERAND_OBJECT **ReturnObjDesc); /****************************************************************************** * * Parser interfaces * *****************************************************************************/ /* psargs - Parse AML opcode arguments */ UINT8 * AcpiPsGetNextPackageEnd ( ACPI_PARSE_STATE *ParserState); UINT32 AcpiPsGetNextPackageLength ( ACPI_PARSE_STATE *ParserState); NATIVE_CHAR * AcpiPsGetNextNamestring ( ACPI_PARSE_STATE *ParserState); void AcpiPsGetNextSimpleArg ( ACPI_PARSE_STATE *ParserState, UINT32 ArgType, ACPI_PARSE_OBJECT *Arg); ACPI_STATUS AcpiPsGetNextNamepath ( + ACPI_WALK_STATE *WalkState, ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT *Arg, - UINT32 *ArgCount, BOOLEAN MethodCall); ACPI_PARSE_OBJECT * AcpiPsGetNextField ( ACPI_PARSE_STATE *ParserState); ACPI_STATUS AcpiPsGetNextArg ( + ACPI_WALK_STATE *WalkState, ACPI_PARSE_STATE *ParserState, UINT32 ArgType, - UINT32 *ArgCount, ACPI_PARSE_OBJECT **ReturnArg); /* psfind */ ACPI_PARSE_OBJECT * AcpiPsFindName ( ACPI_PARSE_OBJECT *Scope, UINT32 Name, UINT32 Opcode); ACPI_PARSE_OBJECT* AcpiPsGetParent ( ACPI_PARSE_OBJECT *Op); /* psopcode - AML Opcode information */ const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo ( UINT16 Opcode); NATIVE_CHAR * AcpiPsGetOpcodeName ( UINT16 Opcode); /* psparse - top level parsing routines */ UINT32 AcpiPsGetOpcodeSize ( UINT32 Opcode); void AcpiPsCompleteThisOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op); ACPI_STATUS AcpiPsNextParseState ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_STATUS CallbackStatus); ACPI_STATUS AcpiPsFindObject ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp); void AcpiPsDeleteParseTree ( ACPI_PARSE_OBJECT *root); 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 */ ACPI_STATUS AcpiPsInitScope ( ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT *Root); ACPI_PARSE_OBJECT * AcpiPsGetParentScope ( ACPI_PARSE_STATE *state); BOOLEAN AcpiPsHasCompletedScope ( ACPI_PARSE_STATE *ParserState); void AcpiPsPopScope ( ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT **Op, UINT32 *ArgList, UINT32 *ArgCount); ACPI_STATUS AcpiPsPushScope ( ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT *Op, UINT32 RemainingArgs, UINT32 ArgCount); void AcpiPsCleanupScope ( ACPI_PARSE_STATE *state); /* pstree - parse tree manipulation routines */ void AcpiPsAppendArg( ACPI_PARSE_OBJECT *op, ACPI_PARSE_OBJECT *arg); ACPI_PARSE_OBJECT* AcpiPsFind ( ACPI_PARSE_OBJECT *Scope, NATIVE_CHAR *Path, UINT16 Opcode, UINT32 Create); ACPI_PARSE_OBJECT * AcpiPsGetArg( ACPI_PARSE_OBJECT *op, 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 */ ACPI_STATUS AcpiPsWalkParsedAml ( ACPI_PARSE_OBJECT *StartOp, ACPI_PARSE_OBJECT *EndOp, ACPI_OPERAND_OBJECT *MthDesc, ACPI_NAMESPACE_NODE *StartNode, ACPI_OPERAND_OBJECT **Params, ACPI_OPERAND_OBJECT **CallerReturnDesc, ACPI_OWNER_ID OwnerId, ACPI_PARSE_DOWNWARDS DescendingCallback, ACPI_PARSE_UPWARDS AscendingCallback); ACPI_STATUS AcpiPsGetNextWalkOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_PARSE_UPWARDS AscendingCallback); ACPI_STATUS AcpiPsDeleteCompletedOp ( ACPI_WALK_STATE *WalkState); /* psutils - parser utilities */ ACPI_PARSE_OBJECT * AcpiPsCreateScopeOp ( void); void AcpiPsInitOp ( ACPI_PARSE_OBJECT *op, UINT16 opcode); ACPI_PARSE_OBJECT * AcpiPsAllocOp ( UINT16 opcode); void AcpiPsFreeOp ( ACPI_PARSE_OBJECT *Op); void AcpiPsDeleteParseCache ( void); BOOLEAN AcpiPsIsLeadingChar ( UINT32 c); BOOLEAN AcpiPsIsPrefixChar ( UINT32 c); UINT32 AcpiPsGetName( ACPI_PARSE_OBJECT *op); void AcpiPsSetName( ACPI_PARSE_OBJECT *op, UINT32 name); /* psdump - display parser tree */ UINT32 AcpiPsSprintPath ( NATIVE_CHAR *BufferStart, UINT32 BufferSize, ACPI_PARSE_OBJECT *Op); UINT32 AcpiPsSprintOp ( NATIVE_CHAR *BufferStart, UINT32 BufferSize, ACPI_PARSE_OBJECT *Op); void AcpiPsShow ( ACPI_PARSE_OBJECT *op); #endif /* __ACPARSER_H__ */ diff --git a/sys/contrib/dev/acpica/acstruct.h b/sys/contrib/dev/acpica/acstruct.h index 30323a69bd00..7b12f76aa505 100644 --- a/sys/contrib/dev/acpica/acstruct.h +++ b/sys/contrib/dev/acpica/acstruct.h @@ -1,281 +1,283 @@ /****************************************************************************** * * Name: acstruct.h - Internal structs - * $Revision: 19 $ + * $Revision: 20 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __ACSTRUCT_H__ #define __ACSTRUCT_H__ /***************************************************************************** * * Tree walking typedefs and structs * ****************************************************************************/ /* * 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 #define ACPI_WALK_NON_METHOD 0 #define ACPI_WALK_METHOD 1 #define ACPI_WALK_METHOD_RESTART 2 #define ACPI_WALK_CONST_REQUIRED 3 #define ACPI_WALK_CONST_OPTIONAL 4 typedef struct acpi_walk_state { UINT8 DataType; /* To differentiate various internal objs MUST BE FIRST!*/\ ACPI_OWNER_ID OwnerId; /* Owner of objects created during the walk */ BOOLEAN LastPredicate; /* Result of last predicate */ UINT8 CurrentResult; /* */ UINT8 NextOpInfo; /* Info about NextOp */ UINT8 NumOperands; /* Stack pointer for Operands[] array */ UINT8 ReturnUsed; UINT8 WalkType; UINT16 Opcode; /* Current AML opcode */ + UINT8 ScopeDepth; + UINT8 Reserved1; UINT32 ArgCount; /* push for fixed or var args */ UINT32 AmlOffset; UINT32 ArgTypes; UINT32 MethodBreakpoint; /* For single stepping */ UINT32 UserBreakpoint; /* User AML breakpoint */ UINT32 ParseFlags; UINT32 PrevArgTypes; UINT8 *AmlLastWhile; struct acpi_node Arguments[MTH_NUM_ARGS]; /* Control method arguments */ union acpi_operand_obj **CallerReturnDesc; ACPI_GENERIC_STATE *ControlState; /* List of control states (nested IFs) */ struct acpi_node LocalVariables[MTH_NUM_LOCALS]; /* Control method locals */ struct acpi_node *MethodCallNode; /* Called method Node*/ ACPI_PARSE_OBJECT *MethodCallOp; /* MethodCall Op if running a method */ union acpi_operand_obj *MethodDesc; /* Method descriptor if running a method */ struct acpi_node *MethodNode; /* Method Node if running a method */ ACPI_PARSE_OBJECT *Op; /* Current parser op */ union acpi_operand_obj *Operands[OBJ_NUM_OPERANDS+1]; /* Operands passed to the interpreter (+1 for NULL terminator) */ const ACPI_OPCODE_INFO *OpInfo; /* Info on current opcode */ ACPI_PARSE_OBJECT *Origin; /* Start of walk [Obsolete] */ union acpi_operand_obj **Params; ACPI_PARSE_STATE ParserState; /* Current state of parser */ union acpi_operand_obj *ResultObj; ACPI_GENERIC_STATE *Results; /* Stack of accumulated results */ union acpi_operand_obj *ReturnDesc; /* Return object, if any */ ACPI_GENERIC_STATE *ScopeInfo; /* Stack of nested scopes */ ACPI_PARSE_OBJECT *PrevOp; /* Last op that was processed */ ACPI_PARSE_OBJECT *NextOp; /* next op to be processed */ ACPI_PARSE_DOWNWARDS DescendingCallback; ACPI_PARSE_UPWARDS AscendingCallback; ACPI_THREAD_STATE *Thread; struct acpi_walk_state *Next; /* Next WalkState in list */ } ACPI_WALK_STATE; /* Info used by AcpiPsInitObjects */ typedef struct acpi_init_walk_info { UINT16 MethodCount; UINT16 DeviceCount; UINT16 OpRegionCount; UINT16 FieldCount; UINT16 BufferCount; UINT16 PackageCount; UINT16 OpRegionInit; UINT16 FieldInit; UINT16 BufferInit; UINT16 PackageInit; UINT16 ObjectCount; ACPI_TABLE_DESC *TableDesc; } ACPI_INIT_WALK_INFO; /* Info used by AcpiNsInitializeDevices */ typedef struct acpi_device_walk_info { UINT16 DeviceCount; UINT16 Num_STA; UINT16 Num_INI; ACPI_TABLE_DESC *TableDesc; } ACPI_DEVICE_WALK_INFO; /* TBD: [Restructure] Merge with struct above */ typedef struct acpi_walk_info { UINT32 DebugLevel; UINT32 OwnerId; UINT8 DisplayType; } ACPI_WALK_INFO; /* Display Types */ #define ACPI_DISPLAY_SUMMARY 0 #define ACPI_DISPLAY_OBJECTS 1 typedef struct acpi_get_devices_info { ACPI_WALK_CALLBACK UserFunction; void *Context; NATIVE_CHAR *Hid; } ACPI_GET_DEVICES_INFO; typedef union acpi_aml_operands { ACPI_OPERAND_OBJECT *Operands[7]; struct { ACPI_OBJECT_INTEGER *Type; ACPI_OBJECT_INTEGER *Code; ACPI_OBJECT_INTEGER *Argument; } Fatal; struct { ACPI_OPERAND_OBJECT *Source; ACPI_OBJECT_INTEGER *Index; ACPI_OPERAND_OBJECT *Target; } Index; struct { ACPI_OPERAND_OBJECT *Source; ACPI_OBJECT_INTEGER *Index; ACPI_OBJECT_INTEGER *Length; ACPI_OPERAND_OBJECT *Target; } Mid; } ACPI_AML_OPERANDS; #endif diff --git a/sys/contrib/dev/acpica/actypes.h b/sys/contrib/dev/acpica/actypes.h index 95233717e444..420ac3be5b5d 100644 --- a/sys/contrib/dev/acpica/actypes.h +++ b/sys/contrib/dev/acpica/actypes.h @@ -1,1337 +1,1317 @@ /****************************************************************************** * * Name: actypes.h - Common data types for the entire ACPI subsystem - * $Revision: 239 $ + * $Revision: 241 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __ACTYPES_H__ #define __ACTYPES_H__ /*! [Begin] no source code translation (keep the typedefs) */ /* * Data type ranges */ #define ACPI_UINT8_MAX (UINT8) 0xFF #define ACPI_UINT16_MAX (UINT16) 0xFFFF #define ACPI_UINT32_MAX (UINT32) 0xFFFFFFFF #define ACPI_UINT64_MAX (UINT64) 0xFFFFFFFFFFFFFFFF #define ACPI_ASCII_MAX 0x7F /* - * Data types - Fixed across all compilation models + * Data types - Fixed across all compilation models (16/32/64) * * BOOLEAN Logical Boolean. * INT8 8-bit (1 byte) signed value * UINT8 8-bit (1 byte) unsigned value * INT16 16-bit (2 byte) signed value * UINT16 16-bit (2 byte) unsigned value * INT32 32-bit (4 byte) signed value * UINT32 32-bit (4 byte) unsigned value * INT64 64-bit (8 byte) signed value * UINT64 64-bit (8 byte) unsigned value * NATIVE_INT 32-bit on IA-32, 64-bit on IA-64 signed value * NATIVE_UINT 32-bit on IA-32, 64-bit on IA-64 unsigned value */ #ifndef ACPI_MACHINE_WIDTH #error ACPI_MACHINE_WIDTH not defined #endif #if ACPI_MACHINE_WIDTH == 64 /* * 64-bit type definitions */ typedef unsigned char UINT8; typedef unsigned char BOOLEAN; typedef unsigned short UINT16; typedef int INT32; typedef unsigned int UINT32; typedef COMPILER_DEPENDENT_INT64 INT64; typedef COMPILER_DEPENDENT_UINT64 UINT64; typedef INT64 NATIVE_INT; typedef UINT64 NATIVE_UINT; typedef UINT32 NATIVE_UINT_MAX32; typedef UINT64 NATIVE_UINT_MIN32; typedef UINT64 ACPI_TBLPTR; typedef UINT64 ACPI_IO_ADDRESS; typedef UINT64 ACPI_PHYSICAL_ADDRESS; typedef UINT64 ACPI_SIZE; #define ALIGNED_ADDRESS_BOUNDARY 0x00000008 /* No hardware alignment support in IA64 */ #define ACPI_USE_NATIVE_DIVIDE /* Native 64-bit integer support */ #define ACPI_MAX_PTR ACPI_UINT64_MAX #define ACPI_SIZE_MAX ACPI_UINT64_MAX #elif ACPI_MACHINE_WIDTH == 16 + /* * 16-bit type definitions */ typedef unsigned char UINT8; typedef unsigned char BOOLEAN; typedef unsigned int UINT16; typedef long INT32; typedef int INT16; typedef unsigned long UINT32; typedef struct { UINT32 Lo; UINT32 Hi; } UINT64; typedef UINT16 NATIVE_UINT; typedef INT16 NATIVE_INT; typedef UINT16 NATIVE_UINT_MAX32; typedef UINT32 NATIVE_UINT_MIN32; typedef UINT32 ACPI_TBLPTR; typedef UINT32 ACPI_IO_ADDRESS; typedef char *ACPI_PHYSICAL_ADDRESS; typedef UINT16 ACPI_SIZE; #define ALIGNED_ADDRESS_BOUNDARY 0x00000002 #define _HW_ALIGNMENT_SUPPORT #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 /* * (16-bit only) internal integers must be 32-bits, so * 64-bit integers cannot be supported */ #define ACPI_NO_INTEGER64_SUPPORT #elif ACPI_MACHINE_WIDTH == 32 + /* * 32-bit type definitions (default) */ typedef unsigned char UINT8; typedef unsigned char BOOLEAN; typedef unsigned short UINT16; typedef int INT32; typedef unsigned int UINT32; typedef COMPILER_DEPENDENT_INT64 INT64; typedef COMPILER_DEPENDENT_UINT64 UINT64; typedef INT32 NATIVE_INT; typedef UINT32 NATIVE_UINT; typedef UINT32 NATIVE_UINT_MAX32; typedef UINT32 NATIVE_UINT_MIN32; typedef UINT64 ACPI_TBLPTR; typedef UINT32 ACPI_IO_ADDRESS; typedef UINT64 ACPI_PHYSICAL_ADDRESS; typedef UINT32 ACPI_SIZE; #define ALIGNED_ADDRESS_BOUNDARY 0x00000004 #define _HW_ALIGNMENT_SUPPORT #define ACPI_MAX_PTR ACPI_UINT32_MAX #define ACPI_SIZE_MAX ACPI_UINT32_MAX #else #error unknown ACPI_MACHINE_WIDTH #endif /* * Miscellaneous common types */ - typedef UINT32 UINT32_BIT; typedef NATIVE_UINT ACPI_PTRDIFF; typedef char NATIVE_CHAR; #ifdef DEFINE_ALTERNATE_TYPES /* * Types used only in translated source, defined here to enable * cross-platform compilation only. */ typedef INT32 s32; typedef UINT8 u8; typedef UINT16 u16; typedef UINT32 u32; typedef UINT64 u64; #endif /*! [End] no source code translation !*/ /* * Pointer overlays to avoid lots of typecasting for * code that accepts both physical and logical pointers. */ typedef union acpi_ptrs { ACPI_PHYSICAL_ADDRESS Physical; void *Logical; ACPI_TBLPTR Value; } ACPI_POINTERS; typedef struct AcpiPointer { UINT32 PointerType; union acpi_ptrs Pointer; } ACPI_POINTER; /* PointerTypes for above */ #define ACPI_PHYSICAL_POINTER 0x01 #define ACPI_LOGICAL_POINTER 0x02 /* Processor mode */ #define ACPI_PHYSICAL_ADDRESSING 0x04 #define ACPI_LOGICAL_ADDRESSING 0x08 #define ACPI_MEMORY_MODE 0x0C #define ACPI_PHYSMODE_PHYSPTR ACPI_PHYSICAL_ADDRESSING | ACPI_PHYSICAL_POINTER #define ACPI_LOGMODE_PHYSPTR ACPI_LOGICAL_ADDRESSING | ACPI_PHYSICAL_POINTER #define ACPI_LOGMODE_LOGPTR ACPI_LOGICAL_ADDRESSING | ACPI_LOGICAL_POINTER /* * Useful defines */ - #ifdef FALSE #undef FALSE #endif #define FALSE (1 == 0) #ifdef TRUE #undef TRUE #endif #define TRUE (1 == 1) #ifndef NULL #define NULL (void *) 0 #endif /* * Local datatypes */ - typedef UINT32 ACPI_STATUS; /* All ACPI Exceptions */ typedef UINT32 ACPI_NAME; /* 4-byte ACPI name */ typedef char* ACPI_STRING; /* Null terminated ASCII string */ typedef void* ACPI_HANDLE; /* Actually a ptr to an Node */ typedef struct { UINT32 Lo; UINT32 Hi; } UINT64_STRUCT; typedef union { UINT64 Full; UINT64_STRUCT Part; } UINT64_OVERLAY; typedef struct { UINT32 Lo; UINT32 Hi; } UINT32_STRUCT; /* * Acpi integer width. In ACPI version 1, integers are * 32 bits. In ACPI version 2, integers are 64 bits. * Note that this pertains to the ACPI integer type only, not * other integers used in the implementation of the ACPI CA * subsystem. */ #ifdef ACPI_NO_INTEGER64_SUPPORT /* 32-bit integers only, no 64-bit support */ typedef UINT32 ACPI_INTEGER; #define ACPI_INTEGER_MAX ACPI_UINT32_MAX #define ACPI_INTEGER_BIT_SIZE 32 #define ACPI_MAX_BCD_VALUE 99999999 #define ACPI_MAX_BCD_DIGITS 8 #define ACPI_MAX_DECIMAL_DIGITS 10 #define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 32-bit divide */ #else /* 64-bit integers */ typedef UINT64 ACPI_INTEGER; #define ACPI_INTEGER_MAX ACPI_UINT64_MAX #define ACPI_INTEGER_BIT_SIZE 64 #define ACPI_MAX_BCD_VALUE 9999999999999999 #define ACPI_MAX_BCD_DIGITS 16 #define ACPI_MAX_DECIMAL_DIGITS 19 #if ACPI_MACHINE_WIDTH == 64 #define ACPI_USE_NATIVE_DIVIDE /* Use compiler native 64-bit divide */ #endif #endif /* * Constants with special meanings */ - #define ACPI_ROOT_OBJECT (ACPI_HANDLE) ACPI_PTR_ADD (char, NULL, ACPI_MAX_PTR) /* * Initialization sequence */ #define ACPI_FULL_INITIALIZATION 0x00 #define ACPI_NO_ADDRESS_SPACE_INIT 0x01 #define ACPI_NO_HARDWARE_INIT 0x02 #define ACPI_NO_EVENT_INIT 0x04 #define ACPI_NO_HANDLER_INIT 0x08 #define ACPI_NO_ACPI_ENABLE 0x10 #define ACPI_NO_DEVICE_INIT 0x20 #define ACPI_NO_OBJECT_INIT 0x40 /* * Initialization state */ #define ACPI_INITIALIZED_OK 0x01 /* * Power state values */ #define ACPI_STATE_UNKNOWN (UINT8) 0xFF #define ACPI_STATE_S0 (UINT8) 0 #define ACPI_STATE_S1 (UINT8) 1 #define ACPI_STATE_S2 (UINT8) 2 #define ACPI_STATE_S3 (UINT8) 3 #define ACPI_STATE_S4 (UINT8) 4 #define ACPI_STATE_S5 (UINT8) 5 #define ACPI_S_STATES_MAX ACPI_STATE_S5 #define ACPI_S_STATE_COUNT 6 #define ACPI_STATE_D0 (UINT8) 0 #define ACPI_STATE_D1 (UINT8) 1 #define ACPI_STATE_D2 (UINT8) 2 #define ACPI_STATE_D3 (UINT8) 3 #define ACPI_D_STATES_MAX ACPI_STATE_D3 #define ACPI_D_STATE_COUNT 4 #define ACPI_STATE_C0 (UINT8) 0 #define ACPI_STATE_C1 (UINT8) 1 #define ACPI_STATE_C2 (UINT8) 2 #define ACPI_STATE_C3 (UINT8) 3 #define ACPI_C_STATES_MAX ACPI_STATE_C3 #define ACPI_C_STATE_COUNT 4 /* * Sleep type invalid value */ #define ACPI_SLEEP_TYPE_MAX 0x7 #define ACPI_SLEEP_TYPE_INVALID 0xFF /* * Standard notify values */ #define ACPI_NOTIFY_BUS_CHECK (UINT8) 0 #define ACPI_NOTIFY_DEVICE_CHECK (UINT8) 1 #define ACPI_NOTIFY_DEVICE_WAKE (UINT8) 2 #define ACPI_NOTIFY_EJECT_REQUEST (UINT8) 3 #define ACPI_NOTIFY_DEVICE_CHECK_LIGHT (UINT8) 4 #define ACPI_NOTIFY_FREQUENCY_MISMATCH (UINT8) 5 #define ACPI_NOTIFY_BUS_MODE_MISMATCH (UINT8) 6 #define ACPI_NOTIFY_POWER_FAULT (UINT8) 7 /* * Table types. These values are passed to the table related APIs */ - typedef UINT32 ACPI_TABLE_TYPE; #define ACPI_TABLE_RSDP (ACPI_TABLE_TYPE) 0 #define ACPI_TABLE_DSDT (ACPI_TABLE_TYPE) 1 #define ACPI_TABLE_FADT (ACPI_TABLE_TYPE) 2 #define ACPI_TABLE_FACS (ACPI_TABLE_TYPE) 3 #define ACPI_TABLE_PSDT (ACPI_TABLE_TYPE) 4 #define ACPI_TABLE_SSDT (ACPI_TABLE_TYPE) 5 #define ACPI_TABLE_XSDT (ACPI_TABLE_TYPE) 6 #define ACPI_TABLE_MAX 6 #define NUM_ACPI_TABLES (ACPI_TABLE_MAX+1) /* - * Types associated with names. The first group of - * values correspond to the definition of the ACPI - * ObjectType operator (See the ACPI Spec). Therefore, + * Types associated with ACPI names and objects. The first group of + * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition + * of the ACPI ObjectType() operator (See the ACPI Spec). Therefore, * only add to the first group if the spec changes. * - * Types must be kept in sync with the AcpiNsProperties - * and AcpiNsTypeNames arrays + * Types must be kept in sync with the global AcpiNsProperties + * and AcpiNsTypeNames arrays. */ - typedef UINT32 ACPI_OBJECT_TYPE; #define ACPI_TYPE_ANY 0x00 #define ACPI_TYPE_INTEGER 0x01 /* Byte/Word/Dword/Zero/One/Ones */ #define ACPI_TYPE_STRING 0x02 #define ACPI_TYPE_BUFFER 0x03 #define ACPI_TYPE_PACKAGE 0x04 /* ByteConst, multiple DataTerm/Constant/SuperName */ #define ACPI_TYPE_FIELD_UNIT 0x05 #define ACPI_TYPE_DEVICE 0x06 /* Name, multiple Node */ #define ACPI_TYPE_EVENT 0x07 #define ACPI_TYPE_METHOD 0x08 /* Name, ByteConst, multiple Code */ #define ACPI_TYPE_MUTEX 0x09 #define ACPI_TYPE_REGION 0x0A #define ACPI_TYPE_POWER 0x0B /* Name,ByteConst,WordConst,multi Node */ #define ACPI_TYPE_PROCESSOR 0x0C /* Name,ByteConst,DWordConst,ByteConst,multi NmO */ #define ACPI_TYPE_THERMAL 0x0D /* Name, multiple Node */ #define ACPI_TYPE_BUFFER_FIELD 0x0E #define ACPI_TYPE_DDB_HANDLE 0x0F #define ACPI_TYPE_DEBUG_OBJECT 0x10 -#define ACPI_TYPE_MAX 0x10 +#define ACPI_TYPE_EXTERNAL_MAX 0x10 /* - * This section contains object types that do not relate to the ACPI ObjectType operator. - * They are used for various internal purposes only. If new predefined ACPI_TYPEs are - * added (via the ACPI specification), these internal types must move upwards. - * Also, values exceeding the largest official ACPI ObjectType must not overlap with - * defined AML opcodes. + * These are object types that do not map directly to the ACPI + * ObjectType() operator. They are used for various internal purposes only. + * If new predefined ACPI_TYPEs are added (via the ACPI specification), these + * internal types must move upwards. (There is code that depends on these + * values being contiguous with the external types above.) */ -#define INTERNAL_TYPE_BEGIN 0x11 - -#define INTERNAL_TYPE_REGION_FIELD 0x11 -#define INTERNAL_TYPE_BANK_FIELD 0x12 -#define INTERNAL_TYPE_INDEX_FIELD 0x13 -#define INTERNAL_TYPE_REFERENCE 0x14 /* Arg#, Local#, Name, Debug; used only in descriptors */ -#define INTERNAL_TYPE_ALIAS 0x15 -#define INTERNAL_TYPE_NOTIFY 0x16 -#define INTERNAL_TYPE_ADDRESS_HANDLER 0x17 -#define INTERNAL_TYPE_RESOURCE 0x18 -#define INTERNAL_TYPE_RESOURCE_FIELD 0x19 - +#define ACPI_TYPE_LOCAL_REGION_FIELD 0x11 +#define ACPI_TYPE_LOCAL_BANK_FIELD 0x12 +#define ACPI_TYPE_LOCAL_INDEX_FIELD 0x13 +#define ACPI_TYPE_LOCAL_REFERENCE 0x14 /* Arg#, Local#, Name, Debug, RefOf, Index */ +#define ACPI_TYPE_LOCAL_ALIAS 0x15 +#define ACPI_TYPE_LOCAL_NOTIFY 0x16 +#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x17 +#define ACPI_TYPE_LOCAL_RESOURCE 0x18 +#define ACPI_TYPE_LOCAL_RESOURCE_FIELD 0x19 +#define ACPI_TYPE_LOCAL_SCOPE 0x1A /* 1 Name, multiple ObjectList Nodes */ + +#define ACPI_TYPE_NS_NODE_MAX 0x1A /* Last typecode used within a NS Node */ -#define INTERNAL_TYPE_NODE_MAX 0x19 - -/* These are pseudo-types because there are never any namespace nodes with these types */ +/* + * These are special object types that never appear in + * a Namespace node, only in an ACPI_OPERAND_OBJECT + */ +#define ACPI_TYPE_LOCAL_EXTRA 0x1B +#define ACPI_TYPE_LOCAL_DATA 0x1C -#define INTERNAL_TYPE_FIELD_DEFN 0x1A /* Name, ByteConst, multiple FieldElement */ -#define INTERNAL_TYPE_BANK_FIELD_DEFN 0x1B /* 2 Name,DWordConst,ByteConst,multi FieldElement */ -#define INTERNAL_TYPE_INDEX_FIELD_DEFN 0x1C /* 2 Name, ByteConst, multiple FieldElement */ -#define INTERNAL_TYPE_IF 0x1D -#define INTERNAL_TYPE_ELSE 0x1E -#define INTERNAL_TYPE_WHILE 0x1F -#define INTERNAL_TYPE_SCOPE 0x20 /* Name, multiple Node */ -#define INTERNAL_TYPE_DEF_ANY 0x21 /* type is Any, suppress search of enclosing scopes */ -#define INTERNAL_TYPE_EXTRA 0x22 -#define INTERNAL_TYPE_DATA 0x23 +#define ACPI_TYPE_LOCAL_MAX 0x1C -#define INTERNAL_TYPE_MAX 0x23 +/* All types above here are invalid */ -#define INTERNAL_TYPE_INVALID 0x24 +#define ACPI_TYPE_INVALID 0x1D #define ACPI_TYPE_NOT_FOUND 0xFF /* - * Bitmapped ACPI types - * Used internally only + * Bitmapped ACPI types. Used internally only */ #define ACPI_BTYPE_ANY 0x00000000 #define ACPI_BTYPE_INTEGER 0x00000001 #define ACPI_BTYPE_STRING 0x00000002 #define ACPI_BTYPE_BUFFER 0x00000004 #define ACPI_BTYPE_PACKAGE 0x00000008 #define ACPI_BTYPE_FIELD_UNIT 0x00000010 #define ACPI_BTYPE_DEVICE 0x00000020 #define ACPI_BTYPE_EVENT 0x00000040 #define ACPI_BTYPE_METHOD 0x00000080 #define ACPI_BTYPE_MUTEX 0x00000100 #define ACPI_BTYPE_REGION 0x00000200 #define ACPI_BTYPE_POWER 0x00000400 #define ACPI_BTYPE_PROCESSOR 0x00000800 #define ACPI_BTYPE_THERMAL 0x00001000 #define ACPI_BTYPE_BUFFER_FIELD 0x00002000 #define ACPI_BTYPE_DDB_HANDLE 0x00004000 #define ACPI_BTYPE_DEBUG_OBJECT 0x00008000 #define ACPI_BTYPE_REFERENCE 0x00010000 #define ACPI_BTYPE_RESOURCE 0x00020000 #define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER) #define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE) #define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE) #define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR) #define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ #define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF /* * All I/O */ #define ACPI_READ 0 #define ACPI_WRITE 1 +#define ACPI_IO_MASK 1 /* * AcpiEvent Types: Fixed & General Purpose */ - typedef UINT32 ACPI_EVENT_TYPE; #define ACPI_EVENT_FIXED 0 #define ACPI_EVENT_GPE 1 /* * Fixed events */ - #define ACPI_EVENT_PMTIMER 0 #define ACPI_EVENT_GLOBAL 1 #define ACPI_EVENT_POWER_BUTTON 2 #define ACPI_EVENT_SLEEP_BUTTON 3 #define ACPI_EVENT_RTC 4 #define ACPI_EVENT_MAX 4 #define ACPI_NUM_FIXED_EVENTS ACPI_EVENT_MAX + 1 #define ACPI_GPE_INVALID 0xFF #define ACPI_GPE_MAX 0xFF #define ACPI_NUM_GPE 256 #define ACPI_EVENT_LEVEL_TRIGGERED 1 #define ACPI_EVENT_EDGE_TRIGGERED 2 /* * GPEs */ - #define ACPI_EVENT_WAKE_ENABLE 0x1 - #define ACPI_EVENT_WAKE_DISABLE 0x1 /* * AcpiEvent Status: * ------------- * The encoding of ACPI_EVENT_STATUS is illustrated below. * Note that a set bit (1) indicates the property is TRUE * (e.g. if bit 0 is set then the event is enabled). * +-------------+-+-+-+ * | Bits 31:3 |2|1|0| * +-------------+-+-+-+ * | | | | * | | | +- Enabled? * | | +--- Enabled for wake? * | +----- Set? * +----------- */ typedef UINT32 ACPI_EVENT_STATUS; #define ACPI_EVENT_FLAG_DISABLED (ACPI_EVENT_STATUS) 0x00 #define ACPI_EVENT_FLAG_ENABLED (ACPI_EVENT_STATUS) 0x01 #define ACPI_EVENT_FLAG_WAKE_ENABLED (ACPI_EVENT_STATUS) 0x02 #define ACPI_EVENT_FLAG_SET (ACPI_EVENT_STATUS) 0x04 /* Notify types */ #define ACPI_SYSTEM_NOTIFY 0 #define ACPI_DEVICE_NOTIFY 1 #define ACPI_MAX_NOTIFY_HANDLER_TYPE 1 -#define ACPI_MAX_SYS_NOTIFY 0x7f +#define ACPI_MAX_SYS_NOTIFY 0x7f /* Address Space (Operation Region) Types */ typedef UINT8 ACPI_ADR_SPACE_TYPE; #define ACPI_ADR_SPACE_SYSTEM_MEMORY (ACPI_ADR_SPACE_TYPE) 0 #define ACPI_ADR_SPACE_SYSTEM_IO (ACPI_ADR_SPACE_TYPE) 1 #define ACPI_ADR_SPACE_PCI_CONFIG (ACPI_ADR_SPACE_TYPE) 2 #define ACPI_ADR_SPACE_EC (ACPI_ADR_SPACE_TYPE) 3 #define ACPI_ADR_SPACE_SMBUS (ACPI_ADR_SPACE_TYPE) 4 #define ACPI_ADR_SPACE_CMOS (ACPI_ADR_SPACE_TYPE) 5 #define ACPI_ADR_SPACE_PCI_BAR_TARGET (ACPI_ADR_SPACE_TYPE) 6 #define ACPI_ADR_SPACE_DATA_TABLE (ACPI_ADR_SPACE_TYPE) 7 /* * BitRegister IDs * These are bitfields defined within the full ACPI registers */ #define ACPI_BITREG_TIMER_STATUS 0x00 #define ACPI_BITREG_BUS_MASTER_STATUS 0x01 #define ACPI_BITREG_GLOBAL_LOCK_STATUS 0x02 #define ACPI_BITREG_POWER_BUTTON_STATUS 0x03 #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_NUM_BITREG ACPI_BITREG_MAX + 1 + /* * External ACPI object definition */ - typedef union AcpiObj { ACPI_OBJECT_TYPE Type; /* See definition of AcpiNsType for values */ struct { ACPI_OBJECT_TYPE Type; ACPI_INTEGER Value; /* The actual number */ } Integer; struct { ACPI_OBJECT_TYPE Type; UINT32 Length; /* # of bytes in string, excluding trailing null */ NATIVE_CHAR *Pointer; /* points to the string value */ } String; struct { ACPI_OBJECT_TYPE Type; UINT32 Length; /* # of bytes in buffer */ UINT8 *Pointer; /* points to the buffer */ } Buffer; struct { ACPI_OBJECT_TYPE Type; UINT32 Fill1; ACPI_HANDLE Handle; /* object reference */ } Reference; struct { ACPI_OBJECT_TYPE Type; UINT32 Count; /* # of elements in package */ union AcpiObj *Elements; /* Pointer to an array of ACPI_OBJECTs */ } Package; struct { ACPI_OBJECT_TYPE Type; UINT32 ProcId; ACPI_IO_ADDRESS PblkAddress; UINT32 PblkLength; } Processor; struct { ACPI_OBJECT_TYPE Type; UINT32 SystemLevel; UINT32 ResourceOrder; } PowerResource; } ACPI_OBJECT; /* * List of objects, used as a parameter list for control method evaluation */ - typedef struct AcpiObjList { UINT32 Count; ACPI_OBJECT *Pointer; } ACPI_OBJECT_LIST; /* * Miscellaneous common Data Structures used by the interfaces */ - #define ACPI_NO_BUFFER 0 #define ACPI_ALLOCATE_BUFFER (ACPI_SIZE) (-1) #define ACPI_ALLOCATE_LOCAL_BUFFER (ACPI_SIZE) (-2) typedef struct { ACPI_SIZE Length; /* Length in bytes of the buffer */ void *Pointer; /* pointer to buffer */ } ACPI_BUFFER; /* * NameType for AcpiGetName */ - #define ACPI_FULL_PATHNAME 0 #define ACPI_SINGLE_NAME 1 #define ACPI_NAME_TYPE_MAX 1 /* * Structure and flags for AcpiGetSystemInfo */ - #define ACPI_SYS_MODE_UNKNOWN 0x0000 #define ACPI_SYS_MODE_ACPI 0x0001 #define ACPI_SYS_MODE_LEGACY 0x0002 #define ACPI_SYS_MODES_MASK 0x0003 /* * ACPI Table Info. One per ACPI table _type_ */ typedef struct AcpiTableInfo { UINT32 Count; } ACPI_TABLE_INFO; /* * System info returned by AcpiGetSystemInfo() */ - typedef struct _AcpiSysInfo { UINT32 AcpiCaVersion; UINT32 Flags; UINT32 TimerResolution; UINT32 Reserved1; UINT32 Reserved2; UINT32 DebugLevel; UINT32 DebugLayer; UINT32 NumTableTypes; ACPI_TABLE_INFO TableInfo [NUM_ACPI_TABLES]; } ACPI_SYSTEM_INFO; /* * Various handlers and callback procedures */ - typedef UINT32 (*ACPI_EVENT_HANDLER) ( void *Context); typedef void (*ACPI_GPE_HANDLER) ( void *Context); typedef void (*ACPI_NOTIFY_HANDLER) ( ACPI_HANDLE Device, UINT32 Value, void *Context); typedef void (*ACPI_OBJECT_HANDLER) ( ACPI_HANDLE Object, UINT32 Function, void *Data); typedef ACPI_STATUS (*ACPI_INIT_HANDLER) ( ACPI_HANDLE Object, UINT32 Function); #define ACPI_INIT_DEVICE_INI 1 /* Address Spaces (Operation Regions */ typedef ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) ( UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 BitWidth, ACPI_INTEGER *Value, void *HandlerContext, void *RegionContext); #define ACPI_DEFAULT_HANDLER NULL typedef ACPI_STATUS (*ACPI_ADR_SPACE_SETUP) ( ACPI_HANDLE RegionHandle, UINT32 Function, void *HandlerContext, void **RegionContext); #define ACPI_REGION_ACTIVATE 0 #define ACPI_REGION_DEACTIVATE 1 typedef ACPI_STATUS (*ACPI_WALK_CALLBACK) ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue); /* Interrupt handler return values */ #define ACPI_INTERRUPT_NOT_HANDLED 0x00 #define ACPI_INTERRUPT_HANDLED 0x01 /* Structure and flags for AcpiGetDeviceInfo */ #define ACPI_VALID_HID 0x1 #define ACPI_VALID_UID 0x2 #define ACPI_VALID_ADR 0x4 #define ACPI_VALID_STA 0x8 #define ACPI_COMMON_OBJ_INFO \ ACPI_OBJECT_TYPE Type; /* ACPI object type */ \ ACPI_NAME Name /* ACPI object Name */ typedef struct { ACPI_COMMON_OBJ_INFO; } ACPI_OBJ_INFO_HEADER; typedef struct { ACPI_COMMON_OBJ_INFO; UINT32 Valid; /* Are the next bits legit? */ NATIVE_CHAR HardwareId[9]; /* _HID value if any */ NATIVE_CHAR UniqueId[9]; /* _UID value if any */ ACPI_INTEGER Address; /* _ADR value if any */ UINT32 CurrentStatus; /* _STA value */ } ACPI_DEVICE_INFO; /* Context structs for address space handlers */ typedef struct { UINT16 Segment; UINT16 Bus; UINT16 Device; UINT16 Function; } ACPI_PCI_ID; typedef struct { UINT32 Length; ACPI_PHYSICAL_ADDRESS Address; ACPI_PHYSICAL_ADDRESS MappedPhysicalAddress; UINT8 *MappedLogicalAddress; ACPI_SIZE MappedLength; } ACPI_MEM_SPACE_CONTEXT; /* Sleep states */ #define ACPI_NUM_SLEEP_STATES 7 /* * Definitions for Resource Attributes */ /* * Memory Attributes */ #define ACPI_READ_ONLY_MEMORY (UINT8) 0x00 #define ACPI_READ_WRITE_MEMORY (UINT8) 0x01 #define ACPI_NON_CACHEABLE_MEMORY (UINT8) 0x00 #define ACPI_CACHABLE_MEMORY (UINT8) 0x01 #define ACPI_WRITE_COMBINING_MEMORY (UINT8) 0x02 #define ACPI_PREFETCHABLE_MEMORY (UINT8) 0x03 /* * IO Attributes * The ISA IO ranges are: n000-n0FFh, n400-n4FFh, n800-n8FFh, nC00-nCFFh. * The non-ISA IO ranges are: n100-n3FFh, n500-n7FFh, n900-nBFFh, nCD0-nFFFh. */ #define ACPI_NON_ISA_ONLY_RANGES (UINT8) 0x01 #define ACPI_ISA_ONLY_RANGES (UINT8) 0x02 #define ACPI_ENTIRE_RANGE (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES) /* * IO Port Descriptor Decode */ #define ACPI_DECODE_10 (UINT8) 0x00 /* 10-bit IO address decode */ #define ACPI_DECODE_16 (UINT8) 0x01 /* 16-bit IO address decode */ /* * IRQ Attributes */ #define ACPI_EDGE_SENSITIVE (UINT8) 0x00 #define ACPI_LEVEL_SENSITIVE (UINT8) 0x01 #define ACPI_ACTIVE_HIGH (UINT8) 0x00 #define ACPI_ACTIVE_LOW (UINT8) 0x01 #define ACPI_EXCLUSIVE (UINT8) 0x00 #define ACPI_SHARED (UINT8) 0x01 /* * DMA Attributes */ #define ACPI_COMPATIBILITY (UINT8) 0x00 #define ACPI_TYPE_A (UINT8) 0x01 #define ACPI_TYPE_B (UINT8) 0x02 #define ACPI_TYPE_F (UINT8) 0x03 #define ACPI_NOT_BUS_MASTER (UINT8) 0x00 #define ACPI_BUS_MASTER (UINT8) 0x01 #define ACPI_TRANSFER_8 (UINT8) 0x00 #define ACPI_TRANSFER_8_16 (UINT8) 0x01 #define ACPI_TRANSFER_16 (UINT8) 0x02 /* * Start Dependent Functions Priority definitions */ #define ACPI_GOOD_CONFIGURATION (UINT8) 0x00 #define ACPI_ACCEPTABLE_CONFIGURATION (UINT8) 0x01 #define ACPI_SUB_OPTIMAL_CONFIGURATION (UINT8) 0x02 /* * 16, 32 and 64-bit Address Descriptor resource types */ #define ACPI_MEMORY_RANGE (UINT8) 0x00 #define ACPI_IO_RANGE (UINT8) 0x01 #define ACPI_BUS_NUMBER_RANGE (UINT8) 0x02 #define ACPI_ADDRESS_NOT_FIXED (UINT8) 0x00 #define ACPI_ADDRESS_FIXED (UINT8) 0x01 #define ACPI_POS_DECODE (UINT8) 0x00 #define ACPI_SUB_DECODE (UINT8) 0x01 #define ACPI_PRODUCER (UINT8) 0x00 #define ACPI_CONSUMER (UINT8) 0x01 /* * Structures used to describe device resources */ typedef struct { UINT32 EdgeLevel; UINT32 ActiveHighLow; UINT32 SharedExclusive; UINT32 NumberOfInterrupts; UINT32 Interrupts[1]; } ACPI_RESOURCE_IRQ; typedef struct { UINT32 Type; UINT32 BusMaster; UINT32 Transfer; UINT32 NumberOfChannels; UINT32 Channels[1]; } ACPI_RESOURCE_DMA; typedef struct { UINT32 CompatibilityPriority; UINT32 PerformanceRobustness; } ACPI_RESOURCE_START_DPF; /* * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not - * needed because it has no fields + * needed because it has no fields */ typedef struct { UINT32 IoDecode; UINT32 MinBaseAddress; UINT32 MaxBaseAddress; UINT32 Alignment; UINT32 RangeLength; } ACPI_RESOURCE_IO; typedef struct { UINT32 BaseAddress; UINT32 RangeLength; } ACPI_RESOURCE_FIXED_IO; typedef struct { UINT32 Length; UINT8 Reserved[1]; } ACPI_RESOURCE_VENDOR; typedef struct { UINT8 Checksum; } ACPI_RESOURCE_END_TAG; typedef struct { UINT32 ReadWriteAttribute; UINT32 MinBaseAddress; UINT32 MaxBaseAddress; UINT32 Alignment; UINT32 RangeLength; } ACPI_RESOURCE_MEM24; typedef struct { UINT32 ReadWriteAttribute; UINT32 MinBaseAddress; UINT32 MaxBaseAddress; UINT32 Alignment; UINT32 RangeLength; } ACPI_RESOURCE_MEM32; typedef struct { UINT32 ReadWriteAttribute; UINT32 RangeBaseAddress; UINT32 RangeLength; } ACPI_RESOURCE_FIXED_MEM32; typedef struct { UINT16 CacheAttribute; UINT16 ReadWriteAttribute; } ACPI_MEMORY_ATTRIBUTE; typedef struct { UINT16 RangeAttribute; UINT16 Reserved; } ACPI_IO_ATTRIBUTE; typedef struct { UINT16 Reserved1; UINT16 Reserved2; } ACPI_BUS_ATTRIBUTE; typedef union { ACPI_MEMORY_ATTRIBUTE Memory; ACPI_IO_ATTRIBUTE Io; ACPI_BUS_ATTRIBUTE Bus; } ACPI_RESOURCE_ATTRIBUTE; typedef struct { UINT32 Index; UINT32 StringLength; NATIVE_CHAR *StringPtr; } ACPI_RESOURCE_SOURCE; typedef struct { 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_SOURCE ResourceSource; } ACPI_RESOURCE_ADDRESS16; typedef struct { 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_SOURCE ResourceSource; } ACPI_RESOURCE_ADDRESS32; typedef struct { UINT32 ResourceType; UINT32 ProducerConsumer; UINT32 Decode; UINT32 MinAddressFixed; UINT32 MaxAddressFixed; ACPI_RESOURCE_ATTRIBUTE Attribute; UINT64 Granularity; UINT64 MinAddressRange; UINT64 MaxAddressRange; UINT64 AddressTranslationOffset; UINT64 AddressLength; ACPI_RESOURCE_SOURCE ResourceSource; } ACPI_RESOURCE_ADDRESS64; typedef struct { UINT32 ProducerConsumer; UINT32 EdgeLevel; UINT32 ActiveHighLow; UINT32 SharedExclusive; UINT32 NumberOfInterrupts; ACPI_RESOURCE_SOURCE ResourceSource; UINT32 Interrupts[1]; } ACPI_RESOURCE_EXT_IRQ; /* 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; typedef union { 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_DATA; typedef struct AcpiResource { ACPI_RESOURCE_TYPE Id; UINT32 Length; ACPI_RESOURCE_DATA Data; } ACPI_RESOURCE; #define ACPI_RESOURCE_LENGTH 12 #define ACPI_RESOURCE_LENGTH_NO_DATA 8 /* Id + Length fields */ #define ACPI_SIZEOF_RESOURCE(Type) (ACPI_RESOURCE_LENGTH_NO_DATA + sizeof (Type)) #define ACPI_NEXT_RESOURCE(Res) (ACPI_RESOURCE *)((UINT8 *) Res + Res->Length) #ifdef _HW_ALIGNMENT_SUPPORT #define ACPI_ALIGN_RESOURCE_SIZE(Length) (Length) #else #define ACPI_ALIGN_RESOURCE_SIZE(Length) ACPI_ROUND_UP_TO_NATIVE_WORD(Length) #endif /* * END: of definitions for Resource Attributes */ typedef struct acpi_pci_routing_table { UINT32 Length; UINT32 Pin; ACPI_INTEGER Address; /* here for 64-bit alignment */ UINT32 SourceIndex; NATIVE_CHAR Source[4]; /* pad to 64 bits so sizeof() works in all cases */ } ACPI_PCI_ROUTING_TABLE; /* * END: of definitions for PCI Routing tables */ #endif /* __ACTYPES_H__ */ diff --git a/sys/contrib/dev/acpica/amlcode.h b/sys/contrib/dev/acpica/amlcode.h index 093ab0fd6567..024b914591d4 100644 --- a/sys/contrib/dev/acpica/amlcode.h +++ b/sys/contrib/dev/acpica/amlcode.h @@ -1,568 +1,569 @@ /****************************************************************************** * * Name: amlcode.h - Definitions for AML, as included in "definition blocks" * Declarations and definitions contained herein are derived * directly from the ACPI specification. - * $Revision: 70 $ + * $Revision: 71 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __AMLCODE_H__ #define __AMLCODE_H__ /* primary opcodes */ #define AML_NULL_CHAR (UINT16) 0x00 #define AML_ZERO_OP (UINT16) 0x00 #define AML_ONE_OP (UINT16) 0x01 #define AML_UNASSIGNED (UINT16) 0x02 #define AML_ALIAS_OP (UINT16) 0x06 #define AML_NAME_OP (UINT16) 0x08 #define AML_BYTE_OP (UINT16) 0x0a #define AML_WORD_OP (UINT16) 0x0b #define AML_DWORD_OP (UINT16) 0x0c #define AML_STRING_OP (UINT16) 0x0d #define AML_QWORD_OP (UINT16) 0x0e /* ACPI 2.0 */ #define AML_SCOPE_OP (UINT16) 0x10 #define AML_BUFFER_OP (UINT16) 0x11 #define AML_PACKAGE_OP (UINT16) 0x12 #define AML_VAR_PACKAGE_OP (UINT16) 0x13 /* ACPI 2.0 */ #define AML_METHOD_OP (UINT16) 0x14 #define AML_DUAL_NAME_PREFIX (UINT16) 0x2e #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_ROOT_PREFIX (UINT16) 0x5c #define AML_PARENT_PREFIX (UINT16) 0x5e #define AML_LOCAL_OP (UINT16) 0x60 #define AML_LOCAL0 (UINT16) 0x60 #define AML_LOCAL1 (UINT16) 0x61 #define AML_LOCAL2 (UINT16) 0x62 #define AML_LOCAL3 (UINT16) 0x63 #define AML_LOCAL4 (UINT16) 0x64 #define AML_LOCAL5 (UINT16) 0x65 #define AML_LOCAL6 (UINT16) 0x66 #define AML_LOCAL7 (UINT16) 0x67 #define AML_ARG_OP (UINT16) 0x68 #define AML_ARG0 (UINT16) 0x68 #define AML_ARG1 (UINT16) 0x69 #define AML_ARG2 (UINT16) 0x6a #define AML_ARG3 (UINT16) 0x6b #define AML_ARG4 (UINT16) 0x6c #define AML_ARG5 (UINT16) 0x6d #define AML_ARG6 (UINT16) 0x6e #define AML_STORE_OP (UINT16) 0x70 #define AML_REF_OF_OP (UINT16) 0x71 #define AML_ADD_OP (UINT16) 0x72 #define AML_CONCAT_OP (UINT16) 0x73 #define AML_SUBTRACT_OP (UINT16) 0x74 #define AML_INCREMENT_OP (UINT16) 0x75 #define AML_DECREMENT_OP (UINT16) 0x76 #define AML_MULTIPLY_OP (UINT16) 0x77 #define AML_DIVIDE_OP (UINT16) 0x78 #define AML_SHIFT_LEFT_OP (UINT16) 0x79 #define AML_SHIFT_RIGHT_OP (UINT16) 0x7a #define AML_BIT_AND_OP (UINT16) 0x7b #define AML_BIT_NAND_OP (UINT16) 0x7c #define AML_BIT_OR_OP (UINT16) 0x7d #define AML_BIT_NOR_OP (UINT16) 0x7e #define AML_BIT_XOR_OP (UINT16) 0x7f #define AML_BIT_NOT_OP (UINT16) 0x80 #define AML_FIND_SET_LEFT_BIT_OP (UINT16) 0x81 #define AML_FIND_SET_RIGHT_BIT_OP (UINT16) 0x82 #define AML_DEREF_OF_OP (UINT16) 0x83 #define AML_CONCAT_RES_OP (UINT16) 0x84 /* ACPI 2.0 */ #define AML_MOD_OP (UINT16) 0x85 /* ACPI 2.0 */ #define AML_NOTIFY_OP (UINT16) 0x86 #define AML_SIZE_OF_OP (UINT16) 0x87 #define AML_INDEX_OP (UINT16) 0x88 #define AML_MATCH_OP (UINT16) 0x89 #define AML_CREATE_DWORD_FIELD_OP (UINT16) 0x8a #define AML_CREATE_WORD_FIELD_OP (UINT16) 0x8b #define AML_CREATE_BYTE_FIELD_OP (UINT16) 0x8c #define AML_CREATE_BIT_FIELD_OP (UINT16) 0x8d #define AML_TYPE_OP (UINT16) 0x8e #define AML_CREATE_QWORD_FIELD_OP (UINT16) 0x8f /* ACPI 2.0 */ #define AML_LAND_OP (UINT16) 0x90 #define AML_LOR_OP (UINT16) 0x91 #define AML_LNOT_OP (UINT16) 0x92 #define AML_LEQUAL_OP (UINT16) 0x93 #define AML_LGREATER_OP (UINT16) 0x94 #define AML_LLESS_OP (UINT16) 0x95 #define AML_TO_BUFFER_OP (UINT16) 0x96 /* ACPI 2.0 */ #define AML_TO_DECSTRING_OP (UINT16) 0x97 /* ACPI 2.0 */ #define AML_TO_HEXSTRING_OP (UINT16) 0x98 /* ACPI 2.0 */ #define AML_TO_INTEGER_OP (UINT16) 0x99 /* ACPI 2.0 */ #define AML_TO_STRING_OP (UINT16) 0x9c /* ACPI 2.0 */ #define AML_COPY_OP (UINT16) 0x9d /* ACPI 2.0 */ #define AML_MID_OP (UINT16) 0x9e /* ACPI 2.0 */ #define AML_CONTINUE_OP (UINT16) 0x9f /* ACPI 2.0 */ #define AML_IF_OP (UINT16) 0xa0 #define AML_ELSE_OP (UINT16) 0xa1 #define AML_WHILE_OP (UINT16) 0xa2 #define AML_NOOP_OP (UINT16) 0xa3 #define AML_RETURN_OP (UINT16) 0xa4 #define AML_BREAK_OP (UINT16) 0xa5 #define AML_BREAK_POINT_OP (UINT16) 0xcc #define AML_ONES_OP (UINT16) 0xff /* prefixed opcodes */ #define AML_EXTOP (UINT16) 0x005b #define AML_MUTEX_OP (UINT16) 0x5b01 #define AML_EVENT_OP (UINT16) 0x5b02 #define AML_SHIFT_RIGHT_BIT_OP (UINT16) 0x5b10 #define AML_SHIFT_LEFT_BIT_OP (UINT16) 0x5b11 #define AML_COND_REF_OF_OP (UINT16) 0x5b12 #define AML_CREATE_FIELD_OP (UINT16) 0x5b13 #define AML_LOAD_TABLE_OP (UINT16) 0x5b1f /* ACPI 2.0 */ #define AML_LOAD_OP (UINT16) 0x5b20 #define AML_STALL_OP (UINT16) 0x5b21 #define AML_SLEEP_OP (UINT16) 0x5b22 #define AML_ACQUIRE_OP (UINT16) 0x5b23 #define AML_SIGNAL_OP (UINT16) 0x5b24 #define AML_WAIT_OP (UINT16) 0x5b25 #define AML_RESET_OP (UINT16) 0x5b26 #define AML_RELEASE_OP (UINT16) 0x5b27 #define AML_FROM_BCD_OP (UINT16) 0x5b28 #define AML_TO_BCD_OP (UINT16) 0x5b29 #define AML_UNLOAD_OP (UINT16) 0x5b2a #define AML_REVISION_OP (UINT16) 0x5b30 #define AML_DEBUG_OP (UINT16) 0x5b31 #define AML_FATAL_OP (UINT16) 0x5b32 #define AML_REGION_OP (UINT16) 0x5b80 #define AML_FIELD_OP (UINT16) 0x5b81 #define AML_DEVICE_OP (UINT16) 0x5b82 #define AML_PROCESSOR_OP (UINT16) 0x5b83 #define AML_POWER_RES_OP (UINT16) 0x5b84 #define AML_THERMAL_ZONE_OP (UINT16) 0x5b85 #define AML_INDEX_FIELD_OP (UINT16) 0x5b86 #define AML_BANK_FIELD_OP (UINT16) 0x5b87 #define AML_DATA_REGION_OP (UINT16) 0x5b88 /* ACPI 2.0 */ /* Bogus opcodes (they are actually two separate opcodes) */ #define AML_LGREATEREQUAL_OP (UINT16) 0x9295 #define AML_LLESSEQUAL_OP (UINT16) 0x9294 #define AML_LNOTEQUAL_OP (UINT16) 0x9293 /* * Internal opcodes * 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 #define AML_INT_ACCESSFIELD_OP (UINT16) 0x0032 #define AML_INT_BYTELIST_OP (UINT16) 0x0033 #define AML_INT_STATICSTRING_OP (UINT16) 0x0034 #define AML_INT_METHODCALL_OP (UINT16) 0x0035 #define AML_INT_RETURN_VALUE_OP (UINT16) 0x0036 #define AML_INT_EVAL_SUBTREE_OP (UINT16) 0x0037 #define ARG_NONE 0x0 /* * Argument types for the AML Parser * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments. * There can be up to 31 unique argument types */ #define ARGP_BYTEDATA 0x01 #define ARGP_BYTELIST 0x02 #define ARGP_CHARLIST 0x03 #define ARGP_DATAOBJ 0x04 #define ARGP_DATAOBJLIST 0x05 #define ARGP_DWORDDATA 0x06 #define ARGP_FIELDLIST 0x07 #define ARGP_NAME 0x08 #define ARGP_NAMESTRING 0x09 #define ARGP_OBJLIST 0x0A #define ARGP_PKGLENGTH 0x0B #define ARGP_SUPERNAME 0x0C #define ARGP_TARGET 0x0D #define ARGP_TERMARG 0x0E #define ARGP_TERMLIST 0x0F #define ARGP_WORDDATA 0x10 #define ARGP_QWORDDATA 0x11 #define ARGP_SIMPLENAME 0x12 /* * Resolved argument types for the AML Interpreter * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments. * There can be up to 31 unique argument types (0 is end-of-arg-list indicator) * * Note: If and when 5 bits becomes insufficient, it would probably be best * to convert to a 6-byte array of argument types, allowing 8 bits per argument. */ /* "Standard" ACPI types are 1-15 (0x0F) */ #define ARGI_INTEGER ACPI_TYPE_INTEGER /* 1 */ #define ARGI_STRING ACPI_TYPE_STRING /* 2 */ #define ARGI_BUFFER ACPI_TYPE_BUFFER /* 3 */ #define ARGI_PACKAGE ACPI_TYPE_PACKAGE /* 4 */ #define ARGI_EVENT ACPI_TYPE_EVENT #define ARGI_MUTEX ACPI_TYPE_MUTEX #define ARGI_REGION ACPI_TYPE_REGION #define ARGI_DDBHANDLE ACPI_TYPE_DDB_HANDLE /* Custom types are 0x10 through 0x1F */ #define ARGI_IF 0x10 #define ARGI_ANYOBJECT 0x11 #define ARGI_ANYTYPE 0x12 #define ARGI_COMPUTEDATA 0x13 /* Buffer, String, or Integer */ #define ARGI_DATAOBJECT 0x14 /* Buffer, String, package or reference to a Node - Used only by SizeOf operator*/ #define ARGI_COMPLEXOBJ 0x15 /* Buffer, String, or package (Used by INDEX op only) */ #define ARGI_INTEGER_REF 0x16 #define ARGI_OBJECT_REF 0x17 #define ARGI_DEVICE_REF 0x18 #define ARGI_REFERENCE 0x19 #define ARGI_TARGETREF 0x1A /* Target, subject to implicit conversion */ #define ARGI_FIXED_TARGET 0x1B /* Target, no implicit conversion */ #define ARGI_SIMPLE_TARGET 0x1C /* Name, Local, Arg -- no implicit conversion */ #define ARGI_BUFFERSTRING 0x1D #define ARGI_REF_OR_STRING 0x1E /* Reference or String (Used by DEREFOF op only) */ #define ARGI_INVALID_OPCODE 0xFFFFFFFF /* * hash offsets */ #define AML_EXTOP_HASH_OFFSET 22 #define AML_LNOT_HASH_OFFSET 19 /* * opcode groups and types */ #define OPGRP_NAMED 0x01 #define OPGRP_FIELD 0x02 #define OPGRP_BYTELIST 0x04 /* * Opcode information */ /* Opcode flags */ #define AML_HAS_ARGS 0x0800 #define AML_HAS_TARGET 0x0400 #define AML_HAS_RETVAL 0x0200 #define AML_NSOBJECT 0x0100 #define AML_NSOPCODE 0x0080 #define AML_NSNODE 0x0040 #define AML_NAMED 0x0020 #define AML_DEFER 0x0010 #define AML_FIELD 0x0008 #define AML_CREATE 0x0004 #define AML_MATH 0x0002 #define AML_LOGICAL 0x0001 #define AML_CONSTANT 0x1000 /* Convenient flag groupings */ #define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */ #define AML_FLAGS_EXEC_1A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Monadic2 */ #define AML_FLAGS_EXEC_1A_1T_0R AML_HAS_ARGS | AML_HAS_TARGET #define AML_FLAGS_EXEC_1A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Monadic2R */ #define AML_FLAGS_EXEC_2A_0T_0R AML_HAS_ARGS /* Dyadic1 */ #define AML_FLAGS_EXEC_2A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Dyadic2 */ #define AML_FLAGS_EXEC_2A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Dyadic2R */ #define AML_FLAGS_EXEC_2A_2T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL #define AML_FLAGS_EXEC_3A_0T_0R AML_HAS_ARGS #define AML_FLAGS_EXEC_3A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL #define AML_FLAGS_EXEC_6A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* * The opcode Type is used in a dispatch table, do not change * without updating the table. */ #define AML_TYPE_EXEC_1A_0T_0R 0x00 /* Monadic1 */ #define AML_TYPE_EXEC_1A_0T_1R 0x01 /* Monadic2 */ #define AML_TYPE_EXEC_1A_1T_0R 0x02 #define AML_TYPE_EXEC_1A_1T_1R 0x03 /* Monadic2R */ #define AML_TYPE_EXEC_2A_0T_0R 0x04 /* Dyadic1 */ #define AML_TYPE_EXEC_2A_0T_1R 0x05 /* Dyadic2 */ #define AML_TYPE_EXEC_2A_1T_1R 0x06 /* Dyadic2R */ #define AML_TYPE_EXEC_2A_2T_1R 0x07 #define AML_TYPE_EXEC_3A_0T_0R 0x08 #define AML_TYPE_EXEC_3A_1T_1R 0x09 #define AML_TYPE_EXEC_6A_0T_1R 0x0A /* End of types used in dispatch table */ #define AML_TYPE_LITERAL 0x0B #define AML_TYPE_CONSTANT 0x0C #define AML_TYPE_METHOD_ARGUMENT 0x0D #define AML_TYPE_LOCAL_VARIABLE 0x0E #define AML_TYPE_DATA_TERM 0x0F /* Generic for an op that returns a value */ #define AML_TYPE_METHOD_CALL 0x10 /* Misc */ #define AML_TYPE_CREATE_FIELD 0x11 #define AML_TYPE_CREATE_OBJECT 0x12 #define AML_TYPE_CONTROL 0x13 #define AML_TYPE_NAMED_NO_OBJ 0x14 #define AML_TYPE_NAMED_FIELD 0x15 #define AML_TYPE_NAMED_SIMPLE 0x16 #define AML_TYPE_NAMED_COMPLEX 0x17 #define AML_TYPE_RETURN 0x18 #define AML_TYPE_UNDEFINED 0x19 #define AML_TYPE_BOGUS 0x1A /* * Opcode classes */ #define AML_CLASS_EXECUTE 0x00 #define AML_CLASS_CREATE 0x01 #define AML_CLASS_ARGUMENT 0x02 #define AML_CLASS_NAMED_OBJECT 0x03 #define AML_CLASS_CONTROL 0x04 #define AML_CLASS_ASCII 0x05 #define AML_CLASS_PREFIX 0x06 #define AML_CLASS_INTERNAL 0x07 #define AML_CLASS_RETURN_VALUE 0x08 #define AML_CLASS_METHOD_CALL 0x09 #define AML_CLASS_UNKNOWN 0x0A /* Predefined Operation Region SpaceIDs */ typedef enum { REGION_MEMORY = 0, REGION_IO, REGION_PCI_CONFIG, REGION_EC, REGION_SMBUS, REGION_CMOS, REGION_PCI_BAR, REGION_DATA_TABLE, /* Internal use only */ REGION_FIXED_HW = 0x7F } AML_REGION_TYPES; /* Comparison operation codes for MatchOp operator */ typedef enum { MATCH_MTR = 0, MATCH_MEQ = 1, MATCH_MLE = 2, MATCH_MLT = 3, MATCH_MGE = 4, MATCH_MGT = 5 } AML_MATCH_OPERATOR; #define MAX_MATCH_OPERATOR 5 /* * FieldFlags * * This byte is extracted from the AML and includes three separate * pieces of information about the field: * 1) The field access type * 2) The field update rule * 3) The lock rule for the field * * Bits 00 - 03 : AccessType (AnyAcc, ByteAcc, etc.) * 04 : LockRule (1 == Lock) * 05 - 06 : UpdateRule */ #define AML_FIELD_ACCESS_TYPE_MASK 0x0F #define AML_FIELD_LOCK_RULE_MASK 0x10 #define AML_FIELD_UPDATE_RULE_MASK 0x60 /* 1) Field Access Types */ typedef enum { AML_FIELD_ACCESS_ANY = 0x00, AML_FIELD_ACCESS_BYTE = 0x01, AML_FIELD_ACCESS_WORD = 0x02, AML_FIELD_ACCESS_DWORD = 0x03, AML_FIELD_ACCESS_QWORD = 0x04, /* ACPI 2.0 */ AML_FIELD_ACCESS_BUFFER = 0x05 /* ACPI 2.0 */ } AML_ACCESS_TYPE; /* 2) Field Lock Rules */ typedef enum { AML_FIELD_LOCK_NEVER = 0x00, AML_FIELD_LOCK_ALWAYS = 0x10 } AML_LOCK_RULE; /* 3) Field Update Rules */ typedef enum { AML_FIELD_UPDATE_PRESERVE = 0x00, AML_FIELD_UPDATE_WRITE_AS_ONES = 0x20, AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40 } AML_UPDATE_RULE; /* * Field Access Attributes. * This byte is extracted from the AML via the * AccessAs keyword */ typedef enum { AML_FIELD_ATTRIB_SMB_QUICK = 0x02, AML_FIELD_ATTRIB_SMB_SEND_RCV = 0x04, AML_FIELD_ATTRIB_SMB_BYTE = 0x06, AML_FIELD_ATTRIB_SMB_WORD = 0x08, AML_FIELD_ATTRIB_SMB_BLOCK = 0x0A, - AML_FIELD_ATTRIB_SMB_CALL = 0x0E + AML_FIELD_ATTRIB_SMB_WORD_CALL = 0x0C, + AML_FIELD_ATTRIB_SMB_BLOCK_CALL = 0x0D } AML_ACCESS_ATTRIBUTE; /* bit fields in MethodFlags byte */ #define METHOD_FLAGS_ARG_COUNT 0x07 #define METHOD_FLAGS_SERIALIZED 0x08 #define METHOD_FLAGS_SYNCH_LEVEL 0xF0 #endif /* __AMLCODE_H__ */ diff --git a/sys/contrib/dev/acpica/dbdisply.c b/sys/contrib/dev/acpica/dbdisply.c index 9c0ad34c4432..9d6e7986fcae 100644 --- a/sys/contrib/dev/acpica/dbdisply.c +++ b/sys/contrib/dev/acpica/dbdisply.c @@ -1,1009 +1,1009 @@ /******************************************************************************* * * Module Name: dbdisply - debug display commands - * $Revision: 79 $ + * $Revision: 81 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License * * 2.1. This is your license from Intel Corp. under its intellectual property * rights. You may have additional license terms from the party that provided * you this software, covering your right to use that party's intellectual * property rights. * * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a * copy of the source code appearing in this file ("Covered Code") an * irrevocable, perpetual, worldwide license under Intel's copyrights in the * base code distributed originally by Intel ("Original Intel Code") to copy, * make derivatives, distribute, use and display any portion of the Covered * Code in any form, with the right to sublicense such rights; and * * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent * license (with the right to sublicense), under only those claims of Intel * patents that are infringed by the Original Intel Code, to make, use, sell, * offer to sell, and import the Covered Code and derivative works thereof * solely to the minimum extent necessary to exercise the above copyright * license, and in no event shall the patent license extend to any additions * to or modifications of the Original Intel Code. No other license or right * is granted directly or by implication, estoppel or otherwise; * * The above copyright and patent license is granted only if the following * conditions are met: * * 3. Conditions * * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, * and the following Disclaimer and Export Compliance provision. In addition, * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the * documentation and/or other materials provided with distribution. In * addition, Licensee may not authorize further sublicense of source of any * portion of the Covered Code, and must include terms to the effect that the * license from Licensee to its licensee is limited to the intellectual * property embodied in the software Licensee provides to its licensee, and * not to intellectual property embodied in modifications its licensee may * make. * * 3.3. Redistribution of Executable. Redistribution in executable form of any * substantial portion of the Covered Code or modification must reproduce the * above Copyright Notice, and the following Disclaimer and Export Compliance * provision in the documentation and/or other materials provided with the * distribution. * * 3.4. Intel retains all right, title, and interest in and to the Original * Intel Code. * * 3.5. Neither the name Intel nor any other trademark owned or controlled by * Intel shall be used in advertising or otherwise to promote the sale, use or * other dealings in products derived from or relating to the Covered Code * without prior written authorization from Intel. * * 4. Disclaimer and Export Compliance * * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY * LIMITED REMEDY. * * 4.3. Licensee shall not export, either directly or indirectly, any of this * software or system incorporating such software without first obtaining any * required license or other approval from the U. S. Department of Commerce or * any other agency or department of the United States Government. In the * event Licensee exports any such software from the United States or * re-exports any such software from a foreign destination, Licensee shall * ensure that the distribution and export/re-export of the software is in * compliance with all laws, regulations, orders, or other restrictions of the * U.S. Export Administration Regulations. Licensee agrees that neither it nor * any of its subsidiaries will export/re-export any technical data, process, * software, or service, directly or indirectly, to any country for which the * United States government or any agency thereof requires an export license, * other governmental approval, or letter of assurance, without first obtaining * such license, approval or letter. * *****************************************************************************/ #include "acpi.h" #include "amlcode.h" #include "acdispat.h" #include "acnamesp.h" #include "acparser.h" #include "acinterp.h" #include "acdebug.h" #ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbdisply") /****************************************************************************** * * FUNCTION: AcpiDbGetPointer * * PARAMETERS: Target - Pointer to string to be converted * * RETURN: Converted pointer * * DESCRIPTION: Convert an ascii pointer value to a real value * *****************************************************************************/ void * AcpiDbGetPointer ( void *Target) { void *ObjPtr; #if ACPI_MACHINE_WIDTH == 16 #include /* Have to handle 16-bit pointers of the form segment:offset */ if (!sscanf (Target, "%p", &ObjPtr)) { AcpiOsPrintf ("Invalid pointer: %s\n", Target); return (NULL); } #else /* Simple flat pointer */ ObjPtr = ACPI_TO_POINTER (ACPI_STRTOUL (Target, NULL, 16)); #endif return (ObjPtr); } /******************************************************************************* * * FUNCTION: AcpiDbDumpParserDescriptor * * PARAMETERS: Op - A parser Op descriptor * * RETURN: None * * DESCRIPTION: Display a formatted parser object * ******************************************************************************/ void AcpiDbDumpParserDescriptor ( ACPI_PARSE_OBJECT *Op) { const ACPI_OPCODE_INFO *Info; Info = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 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)); AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg); AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent); AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Common.Next); } /******************************************************************************* * * FUNCTION: AcpiDbDecodeAndDisplayObject * * PARAMETERS: Target - String with object to be displayed. Names * and hex pointers are supported. * OutputType - Byte, Word, Dword, or Qword (B|W|D|Q) * * RETURN: None * * DESCRIPTION: Display a formatted ACPI object * ******************************************************************************/ void AcpiDbDecodeAndDisplayObject ( NATIVE_CHAR *Target, NATIVE_CHAR *OutputType) { void *ObjPtr; ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *ObjDesc; UINT32 Display = DB_BYTE_DISPLAY; NATIVE_CHAR Buffer[80]; ACPI_BUFFER RetBuf; ACPI_STATUS Status; UINT32 Size; if (!Target) { return; } /* Decode the output type */ if (OutputType) { ACPI_STRUPR (OutputType); if (OutputType[0] == 'W') { Display = DB_WORD_DISPLAY; } else if (OutputType[0] == 'D') { Display = DB_DWORD_DISPLAY; } else if (OutputType[0] == 'Q') { Display = DB_QWORD_DISPLAY; } } RetBuf.Length = sizeof (Buffer); RetBuf.Pointer = Buffer; /* Differentiate between a number and a name */ if ((Target[0] >= 0x30) && (Target[0] <= 0x39)) { ObjPtr = AcpiDbGetPointer (Target); if (!AcpiOsReadable (ObjPtr, 16)) { AcpiOsPrintf ("Address %p is invalid in this address space\n", ObjPtr); return; } /* Decode the object type */ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr)) { case ACPI_DESC_TYPE_NAMED: /* This is a namespace Node */ if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE))) { AcpiOsPrintf ("Cannot read entire Named object at address %p\n", ObjPtr); return; } Node = ObjPtr; goto DumpNte; case ACPI_DESC_TYPE_OPERAND: /* This is a ACPI OPERAND OBJECT */ if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT))) { AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", ObjPtr); return; } AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); AcpiExDumpObjectDescriptor (ObjPtr, 1); break; case ACPI_DESC_TYPE_PARSER: /* This is a Parser Op object */ if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT))) { AcpiOsPrintf ("Cannot read entire Parser object at address %p\n", ObjPtr); return; } AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, ACPI_UINT32_MAX); AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr); break; default: /* Is not a recognizeable object */ Size = 16; if (AcpiOsReadable (ObjPtr, 64)) { Size = 64; } /* Just dump some memory */ AcpiUtDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX); break; } return; } /* The parameter is a name string that must be resolved to a Named obj */ Node = AcpiDbLocalNsLookup (Target); if (!Node) { return; } DumpNte: /* Now dump the Named obj */ Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not convert name to pathname\n"); } else { AcpiOsPrintf ("Object (%p) Pathname: %s\n", Node, (char *) RetBuf.Pointer); } if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) { AcpiOsPrintf ("Invalid Named object at address %p\n", Node); return; } AcpiUtDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), Display, ACPI_UINT32_MAX); AcpiExDumpNode (Node, 1); ObjDesc = AcpiNsGetAttachedObject (Node); if (ObjDesc) { AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc); if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT))) { AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", ObjDesc); return; } AcpiUtDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX); AcpiExDumpObjectDescriptor (ObjDesc, 1); } } /******************************************************************************* * * FUNCTION: AcpiDbDecodeInternalObject * * PARAMETERS: ObjDesc - Object to be displayed * * RETURN: None * * DESCRIPTION: Short display of an internal object. Numbers and Strings. * ******************************************************************************/ void AcpiDbDecodeInternalObject ( ACPI_OPERAND_OBJECT *ObjDesc) { UINT32 i; if (!ObjDesc) { AcpiOsPrintf (" Uninitialized"); return; } if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) { - AcpiOsPrintf ("%p", ObjDesc); + AcpiOsPrintf (" %p", ObjDesc); return; } AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc)); switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_INTEGER: AcpiOsPrintf (" %8.8X%8.8X", ACPI_HIDWORD (ObjDesc->Integer.Value), ACPI_LODWORD (ObjDesc->Integer.Value)); break; case ACPI_TYPE_STRING: AcpiOsPrintf ("(%d) \"%.24s", ObjDesc->String.Length, ObjDesc->String.Pointer); if (ObjDesc->String.Length > 24) { AcpiOsPrintf ("..."); } else { AcpiOsPrintf ("\""); } break; case ACPI_TYPE_BUFFER: AcpiOsPrintf ("(%d)", ObjDesc->Buffer.Length); for (i = 0; (i < 8) && (i < ObjDesc->Buffer.Length); i++) { AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]); } break; default: - AcpiOsPrintf ("%p", ObjDesc); + AcpiOsPrintf (" %p", ObjDesc); break; } } /******************************************************************************* * * FUNCTION: AcpiDbDecodeNode * * PARAMETERS: Node - Object to be displayed * * RETURN: None * * DESCRIPTION: Short display of a namespace node * ******************************************************************************/ void AcpiDbDecodeNode ( ACPI_NAMESPACE_NODE *Node) { - AcpiOsPrintf (" Name %4.4s Type-%s", - Node->Name.Ascii, AcpiUtGetTypeName (Node->Type)); + AcpiOsPrintf (" Name %4.4s", + Node->Name.Ascii); if (Node->Flags & ANOBJ_METHOD_ARG) { AcpiOsPrintf (" [Method Arg]"); } if (Node->Flags & ANOBJ_METHOD_LOCAL) { AcpiOsPrintf (" [Method Local]"); } AcpiDbDecodeInternalObject (AcpiNsGetAttachedObject (Node)); } /******************************************************************************* * * FUNCTION: AcpiDbDisplayInternalObject * * PARAMETERS: ObjDesc - Object to be displayed * WalkState - Current walk state * * RETURN: None * * DESCRIPTION: Short display of an internal object * ******************************************************************************/ void AcpiDbDisplayInternalObject ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { UINT8 Type; AcpiOsPrintf ("%p ", ObjDesc); if (!ObjDesc) { AcpiOsPrintf ("\n"); return; } /* Decode the object type */ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) { case ACPI_DESC_TYPE_PARSER: AcpiOsPrintf (" "); break; case ACPI_DESC_TYPE_NAMED: AcpiDbDecodeNode ((ACPI_NAMESPACE_NODE *) ObjDesc); break; case ACPI_DESC_TYPE_OPERAND: Type = ACPI_GET_OBJECT_TYPE (ObjDesc); - if (Type > INTERNAL_TYPE_MAX) + if (Type > ACPI_TYPE_LOCAL_MAX) { AcpiOsPrintf (" Type %X [Invalid Type]", (UINT32) Type); return; } /* Decode the ACPI object type */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: switch (ObjDesc->Reference.Opcode) { case AML_LOCAL_OP: AcpiOsPrintf ("[Local%d] ", ObjDesc->Reference.Offset); if (WalkState) { ObjDesc = WalkState->LocalVariables[ObjDesc->Reference.Offset].Object; AcpiOsPrintf ("%p", ObjDesc); AcpiDbDecodeInternalObject (ObjDesc); } break; case AML_ARG_OP: AcpiOsPrintf ("[Arg%d] ", ObjDesc->Reference.Offset); if (WalkState) { ObjDesc = WalkState->Arguments[ObjDesc->Reference.Offset].Object; AcpiOsPrintf ("%p", ObjDesc); AcpiDbDecodeInternalObject (ObjDesc); } break; case AML_DEBUG_OP: AcpiOsPrintf ("[Debug] "); break; case AML_INDEX_OP: AcpiOsPrintf ("[Index] "); if (!ObjDesc->Reference.Where) { AcpiOsPrintf ("Uninitialized WHERE ptr"); } else { AcpiDbDecodeInternalObject (*(ObjDesc->Reference.Where)); } break; case AML_REF_OF_OP: AcpiOsPrintf ("[RefOf] "); /* Reference can be to a Node or an Operand object */ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc->Reference.Object)) { case ACPI_DESC_TYPE_NAMED: AcpiDbDecodeNode (ObjDesc->Reference.Object); break; case ACPI_DESC_TYPE_OPERAND: AcpiDbDecodeInternalObject (ObjDesc->Reference.Object); break; default: break; } break; default: AcpiOsPrintf ("Unknown Reference opcode %X\n", ObjDesc->Reference.Opcode); break; } break; default: AcpiOsPrintf (" "); AcpiOsPrintf (" "); AcpiDbDecodeInternalObject (ObjDesc); break; } break; default: AcpiOsPrintf (" "); break; } AcpiOsPrintf ("\n"); } /******************************************************************************* * * FUNCTION: AcpiDbDisplayMethodInfo * * PARAMETERS: StartOp - Root of the control method parse tree * * RETURN: None * * DESCRIPTION: Display information about the current method * ******************************************************************************/ void AcpiDbDisplayMethodInfo ( ACPI_PARSE_OBJECT *StartOp) { ACPI_WALK_STATE *WalkState; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; ACPI_PARSE_OBJECT *RootOp; ACPI_PARSE_OBJECT *Op; const ACPI_OPCODE_INFO *OpInfo; UINT32 NumOps = 0; UINT32 NumOperands = 0; UINT32 NumOperators = 0; UINT32 NumRemainingOps = 0; UINT32 NumRemainingOperands = 0; UINT32 NumRemainingOperators = 0; UINT32 NumArgs; UINT32 Concurrency; BOOLEAN CountRemaining = FALSE; WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); if (!WalkState) { AcpiOsPrintf ("There is no method currently executing\n"); return; } ObjDesc = WalkState->MethodDesc; Node = WalkState->MethodNode; NumArgs = ObjDesc->Method.ParamCount; Concurrency = ObjDesc->Method.Concurrency; AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", Node->Name.Ascii); AcpiOsPrintf ("%X arguments, max concurrency = %X\n", NumArgs, Concurrency); RootOp = StartOp; while (RootOp->Common.Parent) { RootOp = RootOp->Common.Parent; } Op = RootOp; while (Op) { if (Op == StartOp) { CountRemaining = TRUE; } NumOps++; if (CountRemaining) { NumRemainingOps++; } /* Decode the opcode */ OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); switch (OpInfo->Class) { case AML_CLASS_ARGUMENT: if (CountRemaining) { NumRemainingOperands++; } NumOperands++; break; case AML_CLASS_UNKNOWN: /* Bad opcode or ASCII character */ continue; default: if (CountRemaining) { NumRemainingOperators++; } NumOperators++; break; } Op = AcpiPsGetDepthNext (StartOp, Op); } 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); } /******************************************************************************* * * FUNCTION: AcpiDbDisplayLocals * * PARAMETERS: None * * RETURN: None * * DESCRIPTION: Display all locals for the currently running control method * ******************************************************************************/ void AcpiDbDisplayLocals (void) { UINT32 i; ACPI_WALK_STATE *WalkState; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); if (!WalkState) { AcpiOsPrintf ("There is no method currently executing\n"); return; } ObjDesc = WalkState->MethodDesc; Node = WalkState->MethodNode; AcpiOsPrintf ("Local Variables for method [%4.4s]:\n", Node->Name.Ascii); for (i = 0; i < MTH_NUM_LOCALS; i++) { ObjDesc = WalkState->LocalVariables[i].Object; AcpiOsPrintf ("Local%d: ", i); AcpiDbDisplayInternalObject (ObjDesc, WalkState); } } /******************************************************************************* * * FUNCTION: AcpiDbDisplayArguments * * PARAMETERS: None * * RETURN: None * * DESCRIPTION: Display all arguments for the currently running control method * ******************************************************************************/ void AcpiDbDisplayArguments (void) { UINT32 i; ACPI_WALK_STATE *WalkState; ACPI_OPERAND_OBJECT *ObjDesc; UINT32 NumArgs; UINT32 Concurrency; ACPI_NAMESPACE_NODE *Node; WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); if (!WalkState) { AcpiOsPrintf ("There is no method currently executing\n"); return; } ObjDesc = WalkState->MethodDesc; Node = WalkState->MethodNode; NumArgs = ObjDesc->Method.ParamCount; Concurrency = ObjDesc->Method.Concurrency; AcpiOsPrintf ("Method [%4.4s] has %X arguments, max concurrency = %X\n", Node->Name.Ascii, NumArgs, Concurrency); for (i = 0; i < NumArgs; i++) { ObjDesc = WalkState->Arguments[i].Object; AcpiOsPrintf ("Arg%d: ", i); AcpiDbDisplayInternalObject (ObjDesc, WalkState); } } /******************************************************************************* * * FUNCTION: AcpiDbDisplayResults * * PARAMETERS: None * * RETURN: None * * DESCRIPTION: Display current contents of a method result stack * ******************************************************************************/ void AcpiDbDisplayResults (void) { UINT32 i; ACPI_WALK_STATE *WalkState; ACPI_OPERAND_OBJECT *ObjDesc; UINT32 NumResults = 0; ACPI_NAMESPACE_NODE *Node; WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); if (!WalkState) { AcpiOsPrintf ("There is no method currently executing\n"); return; } ObjDesc = WalkState->MethodDesc; Node = WalkState->MethodNode; if (WalkState->Results) { NumResults = WalkState->Results->Results.NumResults; } AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n", Node->Name.Ascii, NumResults); for (i = 0; i < NumResults; i++) { ObjDesc = WalkState->Results->Results.ObjDesc[i]; AcpiOsPrintf ("Result%d: ", i); AcpiDbDisplayInternalObject (ObjDesc, WalkState); } } /******************************************************************************* * * FUNCTION: AcpiDbDisplayCallingTree * * PARAMETERS: None * * RETURN: None * * DESCRIPTION: Display current calling tree of nested control methods * ******************************************************************************/ void AcpiDbDisplayCallingTree (void) { ACPI_WALK_STATE *WalkState; ACPI_NAMESPACE_NODE *Node; WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); if (!WalkState) { AcpiOsPrintf ("There is no method currently executing\n"); return; } Node = WalkState->MethodNode; AcpiOsPrintf ("Current Control Method Call Tree\n"); while (WalkState) { Node = WalkState->MethodNode; AcpiOsPrintf (" [%4.4s]\n", Node->Name.Ascii); WalkState = WalkState->Next; } } /******************************************************************************* * * FUNCTION: AcpiDbDisplayResultObject * * PARAMETERS: ObjDesc - Object to be displayed * WalkState - Current walk state * * RETURN: None * * DESCRIPTION: Display the result of an AML opcode * * Note: Curently only displays the result object if we are single stepping. * However, this output may be useful in other contexts and could be enabled * to do so if needed. * ******************************************************************************/ void AcpiDbDisplayResultObject ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { /* Only display if single stepping */ if (!AcpiGbl_CmSingleStep) { return; } AcpiOsPrintf ("ResultObj: "); AcpiDbDisplayInternalObject (ObjDesc, WalkState); AcpiOsPrintf ("\n"); } /******************************************************************************* * * FUNCTION: AcpiDbDisplayArgumentObject * * PARAMETERS: ObjDesc - Object to be displayed * WalkState - Current walk state * * RETURN: None * * DESCRIPTION: Display the result of an AML opcode * ******************************************************************************/ void AcpiDbDisplayArgumentObject ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { if (!AcpiGbl_CmSingleStep) { return; } AcpiOsPrintf ("ArgObj: "); AcpiDbDisplayInternalObject (ObjDesc, WalkState); } #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbexec.c b/sys/contrib/dev/acpica/dbexec.c index 5bb5edfaa369..d4ccd6434eda 100644 --- a/sys/contrib/dev/acpica/dbexec.c +++ b/sys/contrib/dev/acpica/dbexec.c @@ -1,519 +1,519 @@ /******************************************************************************* * * Module Name: dbexec - debugger control method execution - * $Revision: 45 $ + * $Revision: 46 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License * * 2.1. This is your license from Intel Corp. under its intellectual property * rights. You may have additional license terms from the party that provided * you this software, covering your right to use that party's intellectual * property rights. * * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a * copy of the source code appearing in this file ("Covered Code") an * irrevocable, perpetual, worldwide license under Intel's copyrights in the * base code distributed originally by Intel ("Original Intel Code") to copy, * make derivatives, distribute, use and display any portion of the Covered * Code in any form, with the right to sublicense such rights; and * * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent * license (with the right to sublicense), under only those claims of Intel * patents that are infringed by the Original Intel Code, to make, use, sell, * offer to sell, and import the Covered Code and derivative works thereof * solely to the minimum extent necessary to exercise the above copyright * license, and in no event shall the patent license extend to any additions * to or modifications of the Original Intel Code. No other license or right * is granted directly or by implication, estoppel or otherwise; * * The above copyright and patent license is granted only if the following * conditions are met: * * 3. Conditions * * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, * and the following Disclaimer and Export Compliance provision. In addition, * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the * documentation and/or other materials provided with distribution. In * addition, Licensee may not authorize further sublicense of source of any * portion of the Covered Code, and must include terms to the effect that the * license from Licensee to its licensee is limited to the intellectual * property embodied in the software Licensee provides to its licensee, and * not to intellectual property embodied in modifications its licensee may * make. * * 3.3. Redistribution of Executable. Redistribution in executable form of any * substantial portion of the Covered Code or modification must reproduce the * above Copyright Notice, and the following Disclaimer and Export Compliance * provision in the documentation and/or other materials provided with the * distribution. * * 3.4. Intel retains all right, title, and interest in and to the Original * Intel Code. * * 3.5. Neither the name Intel nor any other trademark owned or controlled by * Intel shall be used in advertising or otherwise to promote the sale, use or * other dealings in products derived from or relating to the Covered Code * without prior written authorization from Intel. * * 4. Disclaimer and Export Compliance * * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY * LIMITED REMEDY. * * 4.3. Licensee shall not export, either directly or indirectly, any of this * software or system incorporating such software without first obtaining any * required license or other approval from the U. S. Department of Commerce or * any other agency or department of the United States Government. In the * event Licensee exports any such software from the United States or * re-exports any such software from a foreign destination, Licensee shall * ensure that the distribution and export/re-export of the software is in * compliance with all laws, regulations, orders, or other restrictions of the * U.S. Export Administration Regulations. Licensee agrees that neither it nor * any of its subsidiaries will export/re-export any technical data, process, * software, or service, directly or indirectly, to any country for which the * United States government or any agency thereof requires an export license, * other governmental approval, or letter of assurance, without first obtaining * such license, approval or letter. * *****************************************************************************/ #include "acpi.h" #include "acdebug.h" #ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbexec") static ACPI_DB_METHOD_INFO AcpiGbl_DbMethodInfo; /******************************************************************************* * * FUNCTION: AcpiDbExecuteMethod * * PARAMETERS: Info - Valid info segment * ReturnObj - Where to put return object * * RETURN: Status * * DESCRIPTION: Execute a control method. * ******************************************************************************/ ACPI_STATUS AcpiDbExecuteMethod ( ACPI_DB_METHOD_INFO *Info, ACPI_BUFFER *ReturnObj) { ACPI_STATUS Status; ACPI_OBJECT_LIST ParamObjects; ACPI_OBJECT Params[MTH_NUM_ARGS]; UINT32 i; if (AcpiGbl_DbOutputToFile && !AcpiDbgLevel) { AcpiOsPrintf ("Warning: debug output is not enabled!\n"); } /* Are there arguments to the method? */ if (Info->Args && Info->Args[0]) { for (i = 0; Info->Args[i] && i < MTH_NUM_ARGS; i++) { Params[i].Type = ACPI_TYPE_INTEGER; Params[i].Integer.Value = ACPI_STRTOUL (Info->Args[i], NULL, 16); } ParamObjects.Pointer = Params; ParamObjects.Count = i; } else { /* Setup default parameters */ 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"; ParamObjects.Pointer = Params; ParamObjects.Count = 2; } /* Prepare for a return object of arbitrary size */ ReturnObj->Pointer = AcpiGbl_DbBuffer; ReturnObj->Length = ACPI_DEBUG_BUFFER_SIZE; /* Do the actual method execution */ Status = AcpiEvaluateObject (NULL, Info->Pathname, &ParamObjects, ReturnObj); AcpiGbl_CmSingleStep = FALSE; AcpiGbl_MethodExecuting = FALSE; return (Status); } /******************************************************************************* * * FUNCTION: AcpiDbExecuteSetup * * PARAMETERS: Info - Valid method info * * RETURN: Status * * DESCRIPTION: Setup info segment prior to method execution * ******************************************************************************/ void AcpiDbExecuteSetup ( ACPI_DB_METHOD_INFO *Info) { /* Catenate the current scope to the supplied name */ Info->Pathname[0] = 0; if ((Info->Name[0] != '\\') && (Info->Name[0] != '/')) { ACPI_STRCAT (Info->Pathname, AcpiGbl_DbScopeBuf); } ACPI_STRCAT (Info->Pathname, Info->Name); AcpiDbPrepNamestring (Info->Pathname); AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); AcpiOsPrintf ("Executing %s\n", Info->Pathname); if (Info->Flags & EX_SINGLE_STEP) { AcpiGbl_CmSingleStep = TRUE; AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); } else { /* No single step, allow redirection to a file */ AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); } } /******************************************************************************* * * FUNCTION: AcpiDbGetOutstandingAllocations * * PARAMETERS: None * * RETURN: Current global allocation count minus cache entries * * DESCRIPTION: Determine the current number of "outstanding" allocations -- * those allocations that have not been freed and also are not * in one of the various object caches. * ******************************************************************************/ 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); } #endif return (Outstanding); } /******************************************************************************* * * FUNCTION: AcpiDbExecute * * PARAMETERS: Name - Name of method to execute * Args - Parameters to the method * Flags - single step/no single step * * RETURN: Status * * DESCRIPTION: Execute a control method. Name is relative to the current * scope. * ******************************************************************************/ void AcpiDbExecute ( NATIVE_CHAR *Name, NATIVE_CHAR **Args, UINT32 Flags) { ACPI_STATUS Status; ACPI_BUFFER ReturnObj; #ifdef ACPI_DEBUG_OUTPUT UINT32 PreviousAllocations; UINT32 Allocations; /* Memory allocation tracking */ PreviousAllocations = AcpiDbGetOutstandingAllocations (); #endif AcpiGbl_DbMethodInfo.Name = Name; AcpiGbl_DbMethodInfo.Args = Args; AcpiGbl_DbMethodInfo.Flags = Flags; ReturnObj.Pointer = NULL; ReturnObj.Length = ACPI_ALLOCATE_BUFFER; AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, &ReturnObj); /* * Allow any handlers in separate threads to complete. * (Such as Notify handlers invoked from AML executed above). */ AcpiOsSleep (0, 10); #ifdef ACPI_DEBUG_OUTPUT /* Memory allocation tracking */ Allocations = AcpiDbGetOutstandingAllocations () - PreviousAllocations; AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); if (Allocations > 0) { AcpiOsPrintf ("Outstanding: %ld allocations after execution\n", Allocations); } #endif if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Execution of %s failed with status %s\n", AcpiGbl_DbMethodInfo.Pathname, AcpiFormatException (Status)); } else { /* Display a return object, if any */ if (ReturnObj.Length) { AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", AcpiGbl_DbMethodInfo.Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length); AcpiDbDumpObject (ReturnObj.Pointer, 1); } else { AcpiOsPrintf ("No return object from execution of %s\n", AcpiGbl_DbMethodInfo.Pathname); } } AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); } /******************************************************************************* * * FUNCTION: AcpiDbMethodThread * * PARAMETERS: Context - Execution info segment * * RETURN: None * * DESCRIPTION: Debugger execute thread. Waits for a command line, then * simply dispatches it. * ******************************************************************************/ void ACPI_SYSTEM_XFACE AcpiDbMethodThread ( void *Context) { ACPI_STATUS Status; ACPI_DB_METHOD_INFO *Info = Context; UINT32 i; ACPI_BUFFER ReturnObj; for (i = 0; i < Info->NumLoops; i++) { Status = AcpiDbExecuteMethod (Info, &ReturnObj); if (ACPI_SUCCESS (Status)) { if (ReturnObj.Length) { AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n", Info->Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length); AcpiDbDumpObject (ReturnObj.Pointer, 1); } } } /* Signal our completion */ Status = AcpiOsSignalSemaphore (Info->ThreadGate, 1); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not signal debugger semaphore\n"); } } /******************************************************************************* * * FUNCTION: AcpiDbCreateExecutionThreads * * PARAMETERS: NumThreadsArg - Number of threads to create * NumLoopsArg - Loop count for the thread(s) * MethodNameArg - Control method to execute * * RETURN: None * * DESCRIPTION: Create threads to execute method(s) * ******************************************************************************/ void AcpiDbCreateExecutionThreads ( NATIVE_CHAR *NumThreadsArg, NATIVE_CHAR *NumLoopsArg, NATIVE_CHAR *MethodNameArg) { ACPI_STATUS Status; UINT32 NumThreads; UINT32 NumLoops; UINT32 i; ACPI_HANDLE ThreadGate; /* Get the arguments */ NumThreads = ACPI_STRTOUL (NumThreadsArg, NULL, 0); NumLoops = ACPI_STRTOUL (NumLoopsArg, NULL, 0); if (!NumThreads || !NumLoops) { AcpiOsPrintf ("Bad argument: Threads %X, Loops %X\n", NumThreads, NumLoops); return; } /* Create the synchronization semaphore */ Status = AcpiOsCreateSemaphore (1, 0, &ThreadGate); if (ACPI_FAILURE (Status)) { AcpiOsPrintf ("Could not create semaphore, %s\n", AcpiFormatException (Status)); return; } /* Setup the context to be passed to each thread */ AcpiGbl_DbMethodInfo.Name = MethodNameArg; AcpiGbl_DbMethodInfo.Args = NULL; AcpiGbl_DbMethodInfo.Flags = 0; AcpiGbl_DbMethodInfo.NumLoops = NumLoops; AcpiGbl_DbMethodInfo.ThreadGate = ThreadGate; AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo); /* Create the threads */ 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); if (ACPI_FAILURE (Status)) { break; } } /* Wait for all threads to complete */ i = NumThreads; while (i) /* Brain damage for OSD implementations that only support wait of 1 unit */ { - Status = AcpiOsWaitSemaphore (ThreadGate, 1, WAIT_FOREVER); + Status = AcpiOsWaitSemaphore (ThreadGate, 1, ACPI_WAIT_FOREVER); i--; } /* Cleanup and exit */ (void) AcpiOsDeleteSemaphore (ThreadGate); AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); AcpiOsPrintf ("All threads (%X) have completed\n", NumThreads); AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); } #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbstats.c b/sys/contrib/dev/acpica/dbstats.c index fc95cc4e0261..37de8fbe999b 100644 --- a/sys/contrib/dev/acpica/dbstats.c +++ b/sys/contrib/dev/acpica/dbstats.c @@ -1,551 +1,558 @@ /******************************************************************************* * * Module Name: dbstats - Generation and display of ACPI table statistics - * $Revision: 63 $ + * $Revision: 64 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License * * 2.1. This is your license from Intel Corp. under its intellectual property * rights. You may have additional license terms from the party that provided * you this software, covering your right to use that party's intellectual * property rights. * * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a * copy of the source code appearing in this file ("Covered Code") an * irrevocable, perpetual, worldwide license under Intel's copyrights in the * base code distributed originally by Intel ("Original Intel Code") to copy, * make derivatives, distribute, use and display any portion of the Covered * Code in any form, with the right to sublicense such rights; and * * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent * license (with the right to sublicense), under only those claims of Intel * patents that are infringed by the Original Intel Code, to make, use, sell, * offer to sell, and import the Covered Code and derivative works thereof * solely to the minimum extent necessary to exercise the above copyright * license, and in no event shall the patent license extend to any additions * to or modifications of the Original Intel Code. No other license or right * is granted directly or by implication, estoppel or otherwise; * * The above copyright and patent license is granted only if the following * conditions are met: * * 3. Conditions * * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, * and the following Disclaimer and Export Compliance provision. In addition, * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the * documentation and/or other materials provided with distribution. In * addition, Licensee may not authorize further sublicense of source of any * portion of the Covered Code, and must include terms to the effect that the * license from Licensee to its licensee is limited to the intellectual * property embodied in the software Licensee provides to its licensee, and * not to intellectual property embodied in modifications its licensee may * make. * * 3.3. Redistribution of Executable. Redistribution in executable form of any * substantial portion of the Covered Code or modification must reproduce the * above Copyright Notice, and the following Disclaimer and Export Compliance * provision in the documentation and/or other materials provided with the * distribution. * * 3.4. Intel retains all right, title, and interest in and to the Original * Intel Code. * * 3.5. Neither the name Intel nor any other trademark owned or controlled by * Intel shall be used in advertising or otherwise to promote the sale, use or * other dealings in products derived from or relating to the Covered Code * without prior written authorization from Intel. * * 4. Disclaimer and Export Compliance * * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY * LIMITED REMEDY. * * 4.3. Licensee shall not export, either directly or indirectly, any of this * software or system incorporating such software without first obtaining any * required license or other approval from the U. S. Department of Commerce or * any other agency or department of the United States Government. In the * event Licensee exports any such software from the United States or * re-exports any such software from a foreign destination, Licensee shall * ensure that the distribution and export/re-export of the software is in * compliance with all laws, regulations, orders, or other restrictions of the * U.S. Export Administration Regulations. Licensee agrees that neither it nor * any of its subsidiaries will export/re-export any technical data, process, * software, or service, directly or indirectly, to any country for which the * United States government or any agency thereof requires an export license, * other governmental approval, or letter of assurance, without first obtaining * such license, approval or letter. * *****************************************************************************/ #include "acpi.h" #include "acdebug.h" #include "acnamesp.h" #ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbstats") /* * Statistics subcommands */ static ARGUMENT_INFO AcpiDbStatTypes [] = { {"ALLOCATIONS"}, {"OBJECTS"}, {"MEMORY"}, {"MISC"}, {"TABLES"}, {"SIZES"}, {"STACK"}, {NULL} /* Must be null terminated */ }; #define CMD_STAT_ALLOCATIONS 0 #define CMD_STAT_OBJECTS 1 #define CMD_STAT_MEMORY 2 #define CMD_STAT_MISC 3 #define CMD_STAT_TABLES 4 #define CMD_STAT_SIZES 5 #define CMD_STAT_STACK 6 /******************************************************************************* * * FUNCTION: AcpiDbEnumerateObject * * PARAMETERS: ObjDesc - Object to be counted * * RETURN: None * * DESCRIPTION: Add this object to the global counts, by object type. * Limited recursion handles subobjects and packages, and this * is probably acceptable within the AML debugger only. * ******************************************************************************/ void AcpiDbEnumerateObject ( ACPI_OPERAND_OBJECT *ObjDesc) { UINT32 i; if (!ObjDesc) { return; } /* Enumerate this object first */ AcpiGbl_NumObjects++; - if (ACPI_GET_OBJECT_TYPE (ObjDesc) > INTERNAL_TYPE_NODE_MAX) + if (ACPI_GET_OBJECT_TYPE (ObjDesc) > ACPI_TYPE_NS_NODE_MAX) { AcpiGbl_ObjTypeCountMisc++; } else { AcpiGbl_ObjTypeCount [ACPI_GET_OBJECT_TYPE (ObjDesc)]++; } /* Count the sub-objects */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_PACKAGE: + for (i = 0; i < ObjDesc->Package.Count; i++) { AcpiDbEnumerateObject (ObjDesc->Package.Elements[i]); } break; case ACPI_TYPE_DEVICE: + AcpiDbEnumerateObject (ObjDesc->Device.SysHandler); AcpiDbEnumerateObject (ObjDesc->Device.DrvHandler); AcpiDbEnumerateObject (ObjDesc->Device.AddrHandler); break; case ACPI_TYPE_BUFFER_FIELD: + if (AcpiNsGetSecondaryObject (ObjDesc)) { AcpiGbl_ObjTypeCount [ACPI_TYPE_BUFFER_FIELD]++; } break; case ACPI_TYPE_REGION: - AcpiGbl_ObjTypeCount [INTERNAL_TYPE_REGION_FIELD ]++; + + AcpiGbl_ObjTypeCount [ACPI_TYPE_LOCAL_REGION_FIELD ]++; AcpiDbEnumerateObject (ObjDesc->Region.AddrHandler); break; case ACPI_TYPE_POWER: + AcpiDbEnumerateObject (ObjDesc->PowerResource.SysHandler); AcpiDbEnumerateObject (ObjDesc->PowerResource.DrvHandler); break; case ACPI_TYPE_PROCESSOR: + AcpiDbEnumerateObject (ObjDesc->Processor.SysHandler); AcpiDbEnumerateObject (ObjDesc->Processor.DrvHandler); AcpiDbEnumerateObject (ObjDesc->Processor.AddrHandler); break; case ACPI_TYPE_THERMAL: + AcpiDbEnumerateObject (ObjDesc->ThermalZone.SysHandler); AcpiDbEnumerateObject (ObjDesc->ThermalZone.DrvHandler); AcpiDbEnumerateObject (ObjDesc->ThermalZone.AddrHandler); break; default: break; } } /******************************************************************************* * * FUNCTION: AcpiDbClassifyOneObject * * PARAMETERS: Callback for WalkNamespace * * RETURN: Status * * DESCRIPTION: Enumerate both the object descriptor (including subobjects) and * the parent namespace node. * ******************************************************************************/ ACPI_STATUS AcpiDbClassifyOneObject ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue) { ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *ObjDesc; UINT32 Type; AcpiGbl_NumNodes++; Node = (ACPI_NAMESPACE_NODE *) ObjHandle; ObjDesc = AcpiNsGetAttachedObject (Node); AcpiDbEnumerateObject (ObjDesc); Type = Node->Type; - if (Type > INTERNAL_TYPE_NODE_MAX) + if (Type > ACPI_TYPE_NS_NODE_MAX) { AcpiGbl_NodeTypeCountMisc++; } else { AcpiGbl_NodeTypeCount [Type]++; } return AE_OK; /* TBD: These need to be counted during the initial parsing phase */ /* if (AcpiPsIsNamedOp (Op->Opcode)) { NumNodes++; } if (IsMethod) { NumMethodElements++; } 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); */ } /******************************************************************************* * * FUNCTION: AcpiDbCountNamespaceObjects * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Count and classify the entire namespace, including all * namespace nodes and attached objects. * ******************************************************************************/ void AcpiDbCountNamespaceObjects ( void) { UINT32 i; AcpiGbl_NumNodes = 0; AcpiGbl_NumObjects = 0; AcpiGbl_ObjTypeCountMisc = 0; - for (i = 0; i < (INTERNAL_TYPE_NODE_MAX -1); i++) + for (i = 0; i < (ACPI_TYPE_NS_NODE_MAX -1); i++) { AcpiGbl_ObjTypeCount [i] = 0; AcpiGbl_NodeTypeCount [i] = 0; } (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, FALSE, AcpiDbClassifyOneObject, NULL, NULL); } /******************************************************************************* * * FUNCTION: AcpiDbDisplayStatistics * * PARAMETERS: TypeArg - Subcommand * * RETURN: Status * * DESCRIPTION: Display various statistics * ******************************************************************************/ ACPI_STATUS AcpiDbDisplayStatistics ( NATIVE_CHAR *TypeArg) { UINT32 i; UINT32 Type; UINT32 Size; #ifdef ACPI_DBG_TRACK_ALLOCATIONS UINT32 Outstanding; #endif if (!AcpiGbl_DSDT) { AcpiOsPrintf ("*** Warning: There is no DSDT loaded\n"); } if (!TypeArg) { AcpiOsPrintf ("The following subcommands are available:\n ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n"); return (AE_OK); } ACPI_STRUPR (TypeArg); Type = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes); if (Type == (UINT32) -1) { AcpiOsPrintf ("Invalid or unsupported argument\n"); return (AE_OK); } switch (Type) { case CMD_STAT_ALLOCATIONS: #ifdef ACPI_DBG_TRACK_ALLOCATIONS AcpiUtDumpAllocationInfo (); #endif break; case CMD_STAT_TABLES: AcpiOsPrintf ("ACPI Table Information:\n\n"); if (AcpiGbl_DSDT) { AcpiOsPrintf ("DSDT Length:................% 7ld (%X)\n", AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length); } break; case CMD_STAT_OBJECTS: AcpiDbCountNamespaceObjects (); AcpiOsPrintf ("\nObjects defined in the current namespace:\n\n"); AcpiOsPrintf ("%16.16s %10.10s %10.10s\n", "ACPI_TYPE", "NODES", "OBJECTS"); - for (i = 0; i < INTERNAL_TYPE_NODE_MAX; i++) + for (i = 0; i < ACPI_TYPE_NS_NODE_MAX; i++) { AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", AcpiUtGetTypeName (i), AcpiGbl_NodeTypeCount [i], AcpiGbl_ObjTypeCount [i]); } AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", "Misc/Unknown", AcpiGbl_NodeTypeCountMisc, AcpiGbl_ObjTypeCountMisc); AcpiOsPrintf ("%16.16s % 10ld% 10ld\n", "TOTALS:", AcpiGbl_NumNodes, AcpiGbl_NumObjects); break; case CMD_STAT_MEMORY: #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); } #endif break; 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 ("\n"); AcpiOsPrintf ("Mutex usage:\n\n"); for (i = 0; i < NUM_MTX; i++) { AcpiOsPrintf ("%-28s: % 7ld\n", AcpiUtGetMutexName (i), AcpiGbl_AcpiMutexInfo[i].UseCount); } break; case CMD_STAT_SIZES: AcpiOsPrintf ("\nInternal object sizes:\n\n"); AcpiOsPrintf ("Common %3d\n", sizeof (ACPI_OBJECT_COMMON)); AcpiOsPrintf ("Number %3d\n", sizeof (ACPI_OBJECT_INTEGER)); AcpiOsPrintf ("String %3d\n", sizeof (ACPI_OBJECT_STRING)); AcpiOsPrintf ("Buffer %3d\n", sizeof (ACPI_OBJECT_BUFFER)); AcpiOsPrintf ("Package %3d\n", sizeof (ACPI_OBJECT_PACKAGE)); AcpiOsPrintf ("BufferField %3d\n", sizeof (ACPI_OBJECT_BUFFER_FIELD)); AcpiOsPrintf ("Device %3d\n", sizeof (ACPI_OBJECT_DEVICE)); AcpiOsPrintf ("Event %3d\n", sizeof (ACPI_OBJECT_EVENT)); AcpiOsPrintf ("Method %3d\n", sizeof (ACPI_OBJECT_METHOD)); AcpiOsPrintf ("Mutex %3d\n", sizeof (ACPI_OBJECT_MUTEX)); AcpiOsPrintf ("Region %3d\n", sizeof (ACPI_OBJECT_REGION)); AcpiOsPrintf ("PowerResource %3d\n", sizeof (ACPI_OBJECT_POWER_RESOURCE)); AcpiOsPrintf ("Processor %3d\n", sizeof (ACPI_OBJECT_PROCESSOR)); AcpiOsPrintf ("ThermalZone %3d\n", sizeof (ACPI_OBJECT_THERMAL_ZONE)); AcpiOsPrintf ("RegionField %3d\n", sizeof (ACPI_OBJECT_REGION_FIELD)); AcpiOsPrintf ("BankField %3d\n", sizeof (ACPI_OBJECT_BANK_FIELD)); AcpiOsPrintf ("IndexField %3d\n", sizeof (ACPI_OBJECT_INDEX_FIELD)); AcpiOsPrintf ("Reference %3d\n", sizeof (ACPI_OBJECT_REFERENCE)); AcpiOsPrintf ("NotifyHandler %3d\n", sizeof (ACPI_OBJECT_NOTIFY_HANDLER)); AcpiOsPrintf ("AddrHandler %3d\n", sizeof (ACPI_OBJECT_ADDR_HANDLER)); AcpiOsPrintf ("Extra %3d\n", sizeof (ACPI_OBJECT_EXTRA)); AcpiOsPrintf ("Data %3d\n", sizeof (ACPI_OBJECT_DATA)); AcpiOsPrintf ("\n"); AcpiOsPrintf ("ParseObject %3d\n", sizeof (ACPI_PARSE_OBJ_COMMON)); AcpiOsPrintf ("ParseObjectNamed %3d\n", sizeof (ACPI_PARSE_OBJ_NAMED)); AcpiOsPrintf ("ParseObjectAsl %3d\n", sizeof (ACPI_PARSE_OBJ_ASL)); AcpiOsPrintf ("OperandObject %3d\n", sizeof (ACPI_OPERAND_OBJECT)); AcpiOsPrintf ("NamespaceNode %3d\n", sizeof (ACPI_NAMESPACE_NODE)); break; case CMD_STAT_STACK: #if defined(ACPI_DEBUG_OUTPUT) Size = (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 ("Deepest Procedure Nesting %d\n", AcpiGbl_DeepestNesting); #endif break; default: break; } AcpiOsPrintf ("\n"); return (AE_OK); } #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dbutils.c b/sys/contrib/dev/acpica/dbutils.c index 5ecdc63f874a..cd4f435b02f2 100644 --- a/sys/contrib/dev/acpica/dbutils.c +++ b/sys/contrib/dev/acpica/dbutils.c @@ -1,491 +1,491 @@ /******************************************************************************* * * Module Name: dbutils - AML debugger utilities - * $Revision: 56 $ + * $Revision: 57 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License * * 2.1. This is your license from Intel Corp. under its intellectual property * rights. You may have additional license terms from the party that provided * you this software, covering your right to use that party's intellectual * property rights. * * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a * copy of the source code appearing in this file ("Covered Code") an * irrevocable, perpetual, worldwide license under Intel's copyrights in the * base code distributed originally by Intel ("Original Intel Code") to copy, * make derivatives, distribute, use and display any portion of the Covered * Code in any form, with the right to sublicense such rights; and * * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent * license (with the right to sublicense), under only those claims of Intel * patents that are infringed by the Original Intel Code, to make, use, sell, * offer to sell, and import the Covered Code and derivative works thereof * solely to the minimum extent necessary to exercise the above copyright * license, and in no event shall the patent license extend to any additions * to or modifications of the Original Intel Code. No other license or right * is granted directly or by implication, estoppel or otherwise; * * The above copyright and patent license is granted only if the following * conditions are met: * * 3. Conditions * * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, * and the following Disclaimer and Export Compliance provision. In addition, * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the * documentation and/or other materials provided with distribution. In * addition, Licensee may not authorize further sublicense of source of any * portion of the Covered Code, and must include terms to the effect that the * license from Licensee to its licensee is limited to the intellectual * property embodied in the software Licensee provides to its licensee, and * not to intellectual property embodied in modifications its licensee may * make. * * 3.3. Redistribution of Executable. Redistribution in executable form of any * substantial portion of the Covered Code or modification must reproduce the * above Copyright Notice, and the following Disclaimer and Export Compliance * provision in the documentation and/or other materials provided with the * distribution. * * 3.4. Intel retains all right, title, and interest in and to the Original * Intel Code. * * 3.5. Neither the name Intel nor any other trademark owned or controlled by * Intel shall be used in advertising or otherwise to promote the sale, use or * other dealings in products derived from or relating to the Covered Code * without prior written authorization from Intel. * * 4. Disclaimer and Export Compliance * * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY * LIMITED REMEDY. * * 4.3. Licensee shall not export, either directly or indirectly, any of this * software or system incorporating such software without first obtaining any * required license or other approval from the U. S. Department of Commerce or * any other agency or department of the United States Government. In the * event Licensee exports any such software from the United States or * re-exports any such software from a foreign destination, Licensee shall * ensure that the distribution and export/re-export of the software is in * compliance with all laws, regulations, orders, or other restrictions of the * U.S. Export Administration Regulations. Licensee agrees that neither it nor * any of its subsidiaries will export/re-export any technical data, process, * software, or service, directly or indirectly, to any country for which the * United States government or any agency thereof requires an export license, * other governmental approval, or letter of assurance, without first obtaining * such license, approval or letter. * *****************************************************************************/ #include "acpi.h" #include "acparser.h" #include "amlcode.h" #include "acnamesp.h" #include "acdebug.h" #include "acdispat.h" #ifdef ACPI_DEBUGGER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dbutils") /******************************************************************************* * * FUNCTION: AcpiDbSetOutputDestination * * PARAMETERS: OutputFlags - Current flags word * * RETURN: None * * DESCRIPTION: Set the current destination for debugger output. Alos sets * the debug output level accordingly. * ******************************************************************************/ void AcpiDbSetOutputDestination ( UINT32 OutputFlags) { AcpiGbl_DbOutputFlags = (UINT8) OutputFlags; if ((OutputFlags & ACPI_DB_REDIRECTABLE_OUTPUT) && AcpiGbl_DbOutputToFile) { AcpiDbgLevel = AcpiGbl_DbDebugLevel; } else { AcpiDbgLevel = AcpiGbl_DbConsoleDebugLevel; } } /******************************************************************************* * * 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 * * PARAMETERS: ObjDesc - External ACPI object to dump * Level - Nesting level. * * RETURN: None * * DESCRIPTION: Dump the contents of an ACPI external object * ******************************************************************************/ void AcpiDbDumpObject ( ACPI_OBJECT *ObjDesc, UINT32 Level) { UINT32 i; if (!ObjDesc) { AcpiOsPrintf ("[Null Object]\n"); return; } for (i = 0; i < Level; i++) { AcpiOsPrintf (" "); } switch (ObjDesc->Type) { case ACPI_TYPE_ANY: AcpiOsPrintf ("[Object Reference] = %p\n", ObjDesc->Reference.Handle); break; case ACPI_TYPE_INTEGER: AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n", ACPI_HIDWORD (ObjDesc->Integer.Value), ACPI_LODWORD (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); AcpiUtDumpBuffer ((UINT8 *) ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); break; case ACPI_TYPE_PACKAGE: AcpiOsPrintf ("[Package] Contains %d Elements: \n", ObjDesc->Package.Count); for (i = 0; i < ObjDesc->Package.Count; i++) { AcpiDbDumpObject (&ObjDesc->Package.Elements[i], Level+1); } break; - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: AcpiOsPrintf ("[Object Reference] = %p\n", ObjDesc->Reference.Handle); break; case ACPI_TYPE_PROCESSOR: AcpiOsPrintf ("[Processor]\n"); break; case ACPI_TYPE_POWER: AcpiOsPrintf ("[Power Resource]\n"); break; default: AcpiOsPrintf ("[Unknown Type] %X \n", ObjDesc->Type); break; } } /******************************************************************************* * * FUNCTION: AcpiDbPrepNamestring * * PARAMETERS: Name - String to prepare * * RETURN: None * * DESCRIPTION: Translate all forward slashes and dots to backslashes. * ******************************************************************************/ void AcpiDbPrepNamestring ( NATIVE_CHAR *Name) { if (!Name) { return; } ACPI_STRUPR (Name); /* Convert a leading forward slash to a backslash */ if (*Name == '/') { *Name = '\\'; } /* Ignore a leading backslash, this is the root prefix */ if (*Name == '\\') { Name++; } /* Convert all slash path separators to dots */ while (*Name) { if ((*Name == '/') || (*Name == '\\')) { *Name = '.'; } Name++; } } /******************************************************************************* * * FUNCTION: AcpiDbSecondPassParse * * PARAMETERS: Root - Root of the parse tree * * RETURN: Status * * DESCRIPTION: Second pass parse of the ACPI tables. We need to wait until * second pass to parse the control methods * ******************************************************************************/ ACPI_STATUS AcpiDbSecondPassParse ( ACPI_PARSE_OBJECT *Root) { ACPI_PARSE_OBJECT *Op = Root; ACPI_PARSE_OBJECT *Method; ACPI_PARSE_OBJECT *SearchOp; ACPI_PARSE_OBJECT *StartOp; ACPI_STATUS Status = AE_OK; UINT32 BaseAmlOffset; ACPI_WALK_STATE *WalkState; ACPI_FUNCTION_ENTRY (); AcpiOsPrintf ("Pass two parse ....\n"); while (Op) { if (Op->Common.AmlOpcode == AML_METHOD_OP) { Method = Op; /* Create a new walk state for the parse */ WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, NULL); if (!WalkState) { return (AE_NO_MEMORY); } /* Init the Walk State */ WalkState->ParserState.Aml = WalkState->ParserState.AmlStart = Method->Named.Data; WalkState->ParserState.AmlEnd = WalkState->ParserState.PkgEnd = Method->Named.Data + Method->Named.Length; WalkState->ParserState.StartScope = Op; WalkState->DescendingCallback = AcpiDsLoad1BeginOp; WalkState->AscendingCallback = AcpiDsLoad1EndOp; /* Perform the AML parse */ Status = AcpiPsParseAml (WalkState); BaseAmlOffset = (Method->Common.Value.Arg)->Common.AmlOffset + 1; StartOp = (Method->Common.Value.Arg)->Common.Next; SearchOp = StartOp; while (SearchOp) { SearchOp->Common.AmlOffset += BaseAmlOffset; SearchOp = AcpiPsGetDepthNext (StartOp, SearchOp); } } if (Op->Common.AmlOpcode == AML_REGION_OP) { /* TBD: [Investigate] this isn't quite the right thing to do! */ /* * * Method = (ACPI_DEFERRED_OP *) Op; * Status = AcpiPsParseAml (Op, Method->Body, Method->BodyLength); */ } if (ACPI_FAILURE (Status)) { break; } Op = AcpiPsGetDepthNext (Root, Op); } return (Status); } /******************************************************************************* * * FUNCTION: AcpiDbLocalNsLookup * * PARAMETERS: Name - Name to lookup * * RETURN: Pointer to a namespace node * * 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 ( NATIVE_CHAR *Name) { NATIVE_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); } #endif /* ACPI_DEBUGGER */ diff --git a/sys/contrib/dev/acpica/dmbuffer.c b/sys/contrib/dev/acpica/dmbuffer.c index 8d88136bbcdb..32271db7aeb3 100644 --- a/sys/contrib/dev/acpica/dmbuffer.c +++ b/sys/contrib/dev/acpica/dmbuffer.c @@ -1,627 +1,537 @@ /******************************************************************************* * * Module Name: dmbuffer - AML disassembler, buffer and string support - * $Revision: 7 $ + * $Revision: 8 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License * * 2.1. This is your license from Intel Corp. under its intellectual property * rights. You may have additional license terms from the party that provided * you this software, covering your right to use that party's intellectual * property rights. * * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a * copy of the source code appearing in this file ("Covered Code") an * irrevocable, perpetual, worldwide license under Intel's copyrights in the * base code distributed originally by Intel ("Original Intel Code") to copy, * make derivatives, distribute, use and display any portion of the Covered * Code in any form, with the right to sublicense such rights; and * * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent * license (with the right to sublicense), under only those claims of Intel * patents that are infringed by the Original Intel Code, to make, use, sell, * offer to sell, and import the Covered Code and derivative works thereof * solely to the minimum extent necessary to exercise the above copyright * license, and in no event shall the patent license extend to any additions * to or modifications of the Original Intel Code. No other license or right * is granted directly or by implication, estoppel or otherwise; * * The above copyright and patent license is granted only if the following * conditions are met: * * 3. Conditions * * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, * and the following Disclaimer and Export Compliance provision. In addition, * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the * documentation and/or other materials provided with distribution. In * addition, Licensee may not authorize further sublicense of source of any * portion of the Covered Code, and must include terms to the effect that the * license from Licensee to its licensee is limited to the intellectual * property embodied in the software Licensee provides to its licensee, and * not to intellectual property embodied in modifications its licensee may * make. * * 3.3. Redistribution of Executable. Redistribution in executable form of any * substantial portion of the Covered Code or modification must reproduce the * above Copyright Notice, and the following Disclaimer and Export Compliance * provision in the documentation and/or other materials provided with the * distribution. * * 3.4. Intel retains all right, title, and interest in and to the Original * Intel Code. * * 3.5. Neither the name Intel nor any other trademark owned or controlled by * Intel shall be used in advertising or otherwise to promote the sale, use or * other dealings in products derived from or relating to the Covered Code * without prior written authorization from Intel. * * 4. Disclaimer and Export Compliance * * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY * LIMITED REMEDY. * * 4.3. Licensee shall not export, either directly or indirectly, any of this * software or system incorporating such software without first obtaining any * required license or other approval from the U. S. Department of Commerce or * any other agency or department of the United States Government. In the * event Licensee exports any such software from the United States or * re-exports any such software from a foreign destination, Licensee shall * ensure that the distribution and export/re-export of the software is in * compliance with all laws, regulations, orders, or other restrictions of the * U.S. Export Administration Regulations. Licensee agrees that neither it nor * any of its subsidiaries will export/re-export any technical data, process, * software, or service, directly or indirectly, to any country for which the * United States government or any agency thereof requires an export license, * other governmental approval, or letter of assurance, without first obtaining * such license, approval or letter. * *****************************************************************************/ #include "acpi.h" #include "acdisasm.h" #include "acparser.h" #include "amlcode.h" #ifdef ACPI_DISASSEMBLER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmbuffer") /******************************************************************************* * * FUNCTION: AcpiDmDisasmByteList * * PARAMETERS: Level - Current source code indentation level * ByteData - Pointer to the byte list * ByteCount - Length of the byte list * * RETURN: None * * DESCRIPTION: Dump a list of bytes in Hex format * ******************************************************************************/ void AcpiDmDisasmByteList ( UINT32 Level, UINT8 *ByteData, UINT32 ByteCount) { UINT32 i; AcpiDmIndent (Level); /* Dump the byte list */ for (i = 0; i < ByteCount; i++) { AcpiOsPrintf ("0x%2.2X", (UINT32) ByteData[i]); /* Add comma if there are more bytes to display */ if (i < (ByteCount -1)) { AcpiOsPrintf (", "); } /* New line every 8 bytes */ if ((((i+1) % 8) == 0) && ((i+1) < ByteCount)) { AcpiOsPrintf ("\n"); AcpiDmIndent (Level); } } if (Level) { AcpiOsPrintf ("\n"); } } /******************************************************************************* * * FUNCTION: AcpiDmByteList * * PARAMETERS: Info - Parse tree walk info * Op - Byte list op * * RETURN: None * * DESCRIPTION: Dump a buffer byte list, handling the various types of buffers. * Buffer type must be already set in the Op DisasmOpcode. * ******************************************************************************/ void AcpiDmByteList ( ACPI_OP_WALK_INFO *Info, ACPI_PARSE_OBJECT *Op) { UINT8 *ByteData; UINT32 ByteCount; ByteData = Op->Named.Data; ByteCount = Op->Common.Value.Integer32; /* * The byte list belongs to a buffer, and can be produced by either * a ResourceTemplate, Unicode, quoted string, or a plain byte list. */ switch (Op->Common.Parent->Common.DisasmOpcode) { case ACPI_DASM_RESOURCE: AcpiDmResourceDescriptor (Info, ByteData, ByteCount); break; case ACPI_DASM_STRING: AcpiDmIndent (Info->Level); - AcpiDmString ((char *) ByteData); + AcpiUtPrintString ((char *) ByteData, ACPI_UINT8_MAX); AcpiOsPrintf ("\n"); break; case ACPI_DASM_UNICODE: AcpiDmUnicode (Op); break; case ACPI_DASM_BUFFER: default: /* * Not a resource, string, or unicode string. * Just dump the buffer */ AcpiDmDisasmByteList (Info->Level, ByteData, ByteCount); break; } } /******************************************************************************* * * FUNCTION: AcpiDmIsUnicodeBuffer * * PARAMETERS: Op - Buffer Object to be examined * * RETURN: TRUE if buffer contains a UNICODE string * * DESCRIPTION: Determine if a buffer Op contains a Unicode string * ******************************************************************************/ BOOLEAN AcpiDmIsUnicodeBuffer ( ACPI_PARSE_OBJECT *Op) { UINT8 *ByteData; UINT32 ByteCount; UINT32 WordCount; ACPI_PARSE_OBJECT *SizeOp; ACPI_PARSE_OBJECT *NextOp; NATIVE_UINT i; /* Buffer size is the buffer argument */ SizeOp = Op->Common.Value.Arg; /* Next, the initializer byte list to examine */ NextOp = SizeOp->Common.Next; if (!NextOp) { return (FALSE); } /* Extract the byte list info */ ByteData = NextOp->Named.Data; ByteCount = NextOp->Common.Value.Integer32; WordCount = ACPI_DIV_2 (ByteCount); /* * Unicode string must have an even number of bytes and last * word must be zero */ if ((!ByteCount) || (ByteCount < 4) || (ByteCount & 1) || ((UINT16 *) (void *) ByteData)[WordCount - 1] != 0) { return (FALSE); } /* For each word, 1st byte must be ascii, 2nd byte must be zero */ for (i = 0; i < (ByteCount - 2); i += 2) { if ((!ACPI_IS_PRINT (ByteData[i])) || (ByteData[i + 1] != 0)) { return (FALSE); } } /* Ignore the Size argument in the disassembly of this buffer op */ SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; return (TRUE); } /******************************************************************************* * * FUNCTION: AcpiDmIsStringBuffer * * PARAMETERS: Op - Buffer Object to be examined * * RETURN: TRUE if buffer contains a ASCII string * * DESCRIPTION: Determine if a buffer Op contains a ASCII string * ******************************************************************************/ BOOLEAN AcpiDmIsStringBuffer ( ACPI_PARSE_OBJECT *Op) { UINT8 *ByteData; UINT32 ByteCount; ACPI_PARSE_OBJECT *SizeOp; ACPI_PARSE_OBJECT *NextOp; UINT32 i; /* Buffer size is the buffer argument */ SizeOp = Op->Common.Value.Arg; /* Next, the initializer byte list to examine */ NextOp = SizeOp->Common.Next; if (!NextOp) { return (FALSE); } /* Extract the byte list info */ ByteData = NextOp->Named.Data; ByteCount = NextOp->Common.Value.Integer32; /* Last byte must be the null terminator */ if ((!ByteCount) || (ByteCount < 2) || (ByteData[ByteCount-1] != 0)) { return (FALSE); } for (i = 0; i < (ByteCount - 1); i++) { /* TBD: allow some escapes (non-ascii chars). * they will be handled in the string output routine */ if (!ACPI_IS_PRINT (ByteData[i])) { return (FALSE); } } return (TRUE); } -/******************************************************************************* - * - * FUNCTION: AcpiDmString - * - * PARAMETERS: String - Null terminated ASCII string - * - * RETURN: None - * - * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape - * sequences. - * - ******************************************************************************/ - -void -AcpiDmString ( - char *String) -{ - UINT32 i; - - - if (!String) - { - AcpiOsPrintf ("<\"NULL STRING PTR\">"); - return; - } - - AcpiOsPrintf ("\""); - for (i = 0; String[i]; i++) - { - /* Escape sequences */ - - switch (String[i]) - { - case 0x07: - AcpiOsPrintf ("\\a"); /* BELL */ - break; - - case 0x08: - AcpiOsPrintf ("\\b"); /* BACKSPACE */ - break; - - case 0x0C: - AcpiOsPrintf ("\\f"); /* FORMFEED */ - break; - - case 0x0A: - AcpiOsPrintf ("\\n"); /* LINEFEED */ - break; - - case 0x0D: - AcpiOsPrintf ("\\r"); /* CARRIAGE RETURN*/ - break; - - case 0x09: - AcpiOsPrintf ("\\t"); /* HORIZONTAL TAB */ - break; - - case 0x0B: - AcpiOsPrintf ("\\v"); /* VERTICAL TAB */ - break; - - case '\'': /* Single Quote */ - case '\"': /* Double Quote */ - case '\\': /* Backslash */ - AcpiOsPrintf ("\\%c", (int) String[i]); - break; - - default: - - /* Check for printable character or hex escape */ - - if (ACPI_IS_PRINT (String[i])) - { - /* This is a normal character */ - - AcpiOsPrintf ("%c", (int) String[i]); - } - else - { - /* All others will be Hex escapes */ - - AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]); - } - break; - } - } - AcpiOsPrintf ("\""); -} - - /******************************************************************************* * * FUNCTION: AcpiDmUnicode * * PARAMETERS: Op - Byte List op containing Unicode string * * RETURN: None * * DESCRIPTION: Dump Unicode string as a standard ASCII string. (Remove * the extra zero bytes). * ******************************************************************************/ void AcpiDmUnicode ( ACPI_PARSE_OBJECT *Op) { UINT16 *WordData; UINT32 WordCount; UINT32 i; /* Extract the buffer info as a WORD buffer */ WordData = ACPI_CAST_PTR (UINT16, Op->Named.Data); WordCount = ACPI_DIV_2 (Op->Common.Value.Integer32); AcpiOsPrintf ("\""); /* Write every other byte as an ASCII character */ for (i = 0; i < (WordCount - 1); i++) { AcpiOsPrintf ("%c", (int) WordData[i]); } AcpiOsPrintf ("\")"); } /******************************************************************************* * * FUNCTION: AcpiIsEisaId * * PARAMETERS: Op - Op to be examined * * RETURN: None * * DESCRIPTION: Determine if an Op can be converted to an EisaId. * ******************************************************************************/ void AcpiIsEisaId ( ACPI_PARSE_OBJECT *Op) { UINT32 Name; UINT32 BigEndianId; ACPI_PARSE_OBJECT *NextOp; NATIVE_UINT i; UINT32 Prefix[3]; /* Get the NameSegment */ Name = AcpiPsGetName (Op); if (!Name) { return; } /* We are looking for _HID */ if (ACPI_STRNCMP ((char *) &Name, "_HID", 4)) { return; } /* The parameter must be either a word or a dword */ NextOp = AcpiPsGetDepthNext (NULL, Op); if ((NextOp->Common.AmlOpcode != AML_DWORD_OP) && (NextOp->Common.AmlOpcode != AML_WORD_OP)) { return; } /* Swap from little-endian to big-endian to simplify conversion */ BigEndianId = AcpiUtDwordByteSwap (NextOp->Common.Value.Integer32); /* Create the 3 leading ASCII letters */ Prefix[0] = ((BigEndianId >> 26) & 0x1F) + 0x40; Prefix[1] = ((BigEndianId >> 21) & 0x1F) + 0x40; Prefix[2] = ((BigEndianId >> 16) & 0x1F) + 0x40; /* Verify that all 3 are ascii and alpha */ for (i = 0; i < 3; i++) { if (!ACPI_IS_ASCII (Prefix[i]) || !ACPI_IS_ALPHA (Prefix[i])) { return; } } /* OK - mark this node as convertable to an EISA ID */ NextOp->Common.DisasmOpcode = ACPI_DASM_EISAID; } /******************************************************************************* * * FUNCTION: AcpiDmEisaId * * PARAMETERS: EncodedId - Raw encoded EISA ID. * * RETURN: None * * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String. * ******************************************************************************/ void AcpiDmEisaId ( UINT32 EncodedId) { UINT32 BigEndianId; /* Swap from little-endian to big-endian to simplify conversion */ BigEndianId = AcpiUtDwordByteSwap (EncodedId); /* Split to form "AAANNNN" string */ AcpiOsPrintf ("EisaId (\"%c%c%c%4.4X\")", /* Three Alpha characters (AAA), 5 bits each */ (int) ((BigEndianId >> 26) & 0x1F) + 0x40, (int) ((BigEndianId >> 21) & 0x1F) + 0x40, (int) ((BigEndianId >> 16) & 0x1F) + 0x40, /* Numeric part (NNNN) is simply the lower 16 bits */ (UINT32) (BigEndianId & 0xFFFF)); } #endif diff --git a/sys/contrib/dev/acpica/dmopcode.c b/sys/contrib/dev/acpica/dmopcode.c index 2a35fd3433a0..8f89c663792e 100644 --- a/sys/contrib/dev/acpica/dmopcode.c +++ b/sys/contrib/dev/acpica/dmopcode.c @@ -1,601 +1,602 @@ /******************************************************************************* * * Module Name: dmopcode - AML disassembler, specific AML opcodes - * $Revision: 77 $ + * $Revision: 79 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License * * 2.1. This is your license from Intel Corp. under its intellectual property * rights. You may have additional license terms from the party that provided * you this software, covering your right to use that party's intellectual * property rights. * * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a * copy of the source code appearing in this file ("Covered Code") an * irrevocable, perpetual, worldwide license under Intel's copyrights in the * base code distributed originally by Intel ("Original Intel Code") to copy, * make derivatives, distribute, use and display any portion of the Covered * Code in any form, with the right to sublicense such rights; and * * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent * license (with the right to sublicense), under only those claims of Intel * patents that are infringed by the Original Intel Code, to make, use, sell, * offer to sell, and import the Covered Code and derivative works thereof * solely to the minimum extent necessary to exercise the above copyright * license, and in no event shall the patent license extend to any additions * to or modifications of the Original Intel Code. No other license or right * is granted directly or by implication, estoppel or otherwise; * * The above copyright and patent license is granted only if the following * conditions are met: * * 3. Conditions * * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, * and the following Disclaimer and Export Compliance provision. In addition, * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the * documentation and/or other materials provided with distribution. In * addition, Licensee may not authorize further sublicense of source of any * portion of the Covered Code, and must include terms to the effect that the * license from Licensee to its licensee is limited to the intellectual * property embodied in the software Licensee provides to its licensee, and * not to intellectual property embodied in modifications its licensee may * make. * * 3.3. Redistribution of Executable. Redistribution in executable form of any * substantial portion of the Covered Code or modification must reproduce the * above Copyright Notice, and the following Disclaimer and Export Compliance * provision in the documentation and/or other materials provided with the * distribution. * * 3.4. Intel retains all right, title, and interest in and to the Original * Intel Code. * * 3.5. Neither the name Intel nor any other trademark owned or controlled by * Intel shall be used in advertising or otherwise to promote the sale, use or * other dealings in products derived from or relating to the Covered Code * without prior written authorization from Intel. * * 4. Disclaimer and Export Compliance * * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY * LIMITED REMEDY. * * 4.3. Licensee shall not export, either directly or indirectly, any of this * software or system incorporating such software without first obtaining any * required license or other approval from the U. S. Department of Commerce or * any other agency or department of the United States Government. In the * event Licensee exports any such software from the United States or * re-exports any such software from a foreign destination, Licensee shall * ensure that the distribution and export/re-export of the software is in * compliance with all laws, regulations, orders, or other restrictions of the * U.S. Export Administration Regulations. Licensee agrees that neither it nor * any of its subsidiaries will export/re-export any technical data, process, * software, or service, directly or indirectly, to any country for which the * United States government or any agency thereof requires an export license, * other governmental approval, or letter of assurance, without first obtaining * such license, approval or letter. * *****************************************************************************/ #include "acpi.h" #include "acparser.h" #include "amlcode.h" #include "acdisasm.h" #include "acdebug.h" #ifdef ACPI_DISASSEMBLER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmopcode") /******************************************************************************* * * FUNCTION: AcpiDmMethodFlags * * PARAMETERS: Op - Method Object to be examined * * RETURN: None * * DESCRIPTION: Decode control method flags * ******************************************************************************/ void AcpiDmMethodFlags ( ACPI_PARSE_OBJECT *Op) { UINT32 Flags; UINT32 Args; /* The next Op contains the flags */ Op = AcpiPsGetDepthNext (NULL, Op); Flags = Op->Common.Value.Integer8; Args = Flags & 0x07; /* Mark the Op as completed */ Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; /* 1) Method argument count */ AcpiOsPrintf (", %d, ", Args); /* 2) Serialize rule */ if (!(Flags & 0x08)) { AcpiOsPrintf ("Not"); } AcpiOsPrintf ("Serialized"); /* 3) SyncLevel */ if (Flags & 0xF0) { AcpiOsPrintf (", %d", Flags >> 4); } } /******************************************************************************* * * FUNCTION: AcpiDmFieldFlags * * PARAMETERS: Op - Field Object to be examined * * RETURN: None * * DESCRIPTION: Decode Field definition flags * ******************************************************************************/ void AcpiDmFieldFlags ( ACPI_PARSE_OBJECT *Op) { UINT32 Flags; /* The next Op contains the flags */ Op = AcpiPsGetDepthNext (NULL, Op); Flags = Op->Common.Value.Integer8; /* Mark the Op as completed */ Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; AcpiOsPrintf ("%s, ", AcpiGbl_AccessTypes [Flags & 0x0F]); AcpiOsPrintf ("%s, ", AcpiGbl_LockRule [(Flags & 0x10) >> 4]); AcpiOsPrintf ("%s)", AcpiGbl_UpdateRules [(Flags & 0x60) >> 5]); } /******************************************************************************* * * FUNCTION: AcpiDmAddressSpace * * PARAMETERS: SpaceId - ID to be translated * * RETURN: None * * DESCRIPTION: Decode a SpaceId to an AddressSpaceKeyword * ******************************************************************************/ void AcpiDmAddressSpace ( UINT8 SpaceId) { if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) { if (SpaceId == 0x7F) { AcpiOsPrintf ("FFixedHW, "); } else { AcpiOsPrintf ("0x%.2X, ", SpaceId); } } else { AcpiOsPrintf ("%s, ", AcpiGbl_RegionTypes [SpaceId]); } } /******************************************************************************* * * FUNCTION: AcpiDmRegionFlags * * PARAMETERS: Op - Object to be examined * * RETURN: None * * DESCRIPTION: Decode OperationRegion flags * ******************************************************************************/ void AcpiDmRegionFlags ( ACPI_PARSE_OBJECT *Op) { /* The next Op contains the SpaceId */ Op = AcpiPsGetDepthNext (NULL, Op); /* Mark the Op as completed */ Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; AcpiOsPrintf (", "); AcpiDmAddressSpace (Op->Common.Value.Integer8); } /******************************************************************************* * * FUNCTION: AcpiDmMatchOp * * PARAMETERS: Op - Match Object to be examined * * RETURN: None * * DESCRIPTION: Decode Match opcode operands * ******************************************************************************/ void AcpiDmMatchOp ( ACPI_PARSE_OBJECT *Op) { ACPI_PARSE_OBJECT *NextOp; NextOp = AcpiPsGetDepthNext (NULL, Op); NextOp = NextOp->Common.Next; if (!NextOp) { /* Handle partial tree during single-step */ return; } /* Mark the two nodes that contain the encoding for the match keywords */ NextOp->Common.DisasmOpcode = ACPI_DASM_MATCHOP; NextOp = NextOp->Common.Next; NextOp = NextOp->Common.Next; NextOp->Common.DisasmOpcode = ACPI_DASM_MATCHOP; } /******************************************************************************* * * FUNCTION: AcpiDmMatchKeyword * * PARAMETERS: Op - Match Object to be examined * * RETURN: None * * DESCRIPTION: Decode Match opcode operands * ******************************************************************************/ void AcpiDmMatchKeyword ( ACPI_PARSE_OBJECT *Op) { if (Op->Common.Value.Integer32 >= NUM_MATCH_OPS) { AcpiOsPrintf ("/* Unknown Match Keyword encoding */"); } else { AcpiOsPrintf ("%s", (char *) AcpiGbl_MatchOps[Op->Common.Value.Integer32]); } } /******************************************************************************* * * FUNCTION: AcpiDmDisassembleOneOp * * PARAMETERS: WalkState - Current walk info * Info - Parse tree walk info * Op - Op that is to be printed * * RETURN: None * * DESCRIPTION: Disassemble a single AML opcode * ******************************************************************************/ void AcpiDmDisassembleOneOp ( ACPI_WALK_STATE *WalkState, ACPI_OP_WALK_INFO *Info, ACPI_PARSE_OBJECT *Op) { const ACPI_OPCODE_INFO *OpInfo = NULL; UINT32 Offset; UINT32 Length; if (!Op) { AcpiOsPrintf (""); return; } switch (Op->Common.DisasmOpcode) { case ACPI_DASM_MATCHOP: AcpiDmMatchKeyword (Op); return; default: break; } /* op and arguments */ switch (Op->Common.AmlOpcode) { case AML_ZERO_OP: AcpiOsPrintf ("Zero"); break; case AML_ONE_OP: AcpiOsPrintf ("One"); break; case AML_ONES_OP: AcpiOsPrintf ("Ones"); break; case AML_REVISION_OP: AcpiOsPrintf ("Revision"); break; case AML_BYTE_OP: AcpiOsPrintf ("0x%2.2X", (UINT32) Op->Common.Value.Integer8); break; case AML_WORD_OP: if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID) { AcpiDmEisaId (Op->Common.Value.Integer32); } else { AcpiOsPrintf ("0x%4.4X", (UINT32) Op->Common.Value.Integer16); } break; case AML_DWORD_OP: if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID) { AcpiDmEisaId (Op->Common.Value.Integer32); } else { AcpiOsPrintf ("0x%8.8X", Op->Common.Value.Integer32); } break; case AML_QWORD_OP: AcpiOsPrintf ("0x%8.8X%8.8X", Op->Common.Value.Integer64.Hi, Op->Common.Value.Integer64.Lo); break; case AML_STRING_OP: - AcpiDmString (Op->Common.Value.String); + AcpiUtPrintString (Op->Common.Value.String, ACPI_UINT8_MAX); break; case AML_BUFFER_OP: /* * Determine the type of buffer. We can have one of the following: * * 1) ResourceTemplate containing Resource Descriptors. * 2) Unicode String buffer * 3) ASCII String buffer * 4) Raw data buffer (if none of the above) * * Since there are no special AML opcodes to differentiate these * types of buffers, we have to closely look at the data in the * buffer to determine the type. */ if (AcpiDmIsResourceDescriptor (Op)) { Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE; AcpiOsPrintf ("ResourceTemplate"); } else if (AcpiDmIsUnicodeBuffer (Op)) { Op->Common.DisasmOpcode = ACPI_DASM_UNICODE; AcpiOsPrintf ("Unicode ("); } else if (AcpiDmIsStringBuffer (Op)) { Op->Common.DisasmOpcode = ACPI_DASM_STRING; AcpiOsPrintf ("Buffer"); } else { Op->Common.DisasmOpcode = ACPI_DASM_BUFFER; AcpiOsPrintf ("Buffer"); } break; case AML_INT_STATICSTRING_OP: if (Op->Common.Value.String) { AcpiOsPrintf ("%s", Op->Common.Value.String); } else { AcpiOsPrintf ("\"\""); } break; 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), " ", Op->Common.Value.Integer32); AcpiDmCommaIfFieldMember (Op); Info->BitOffset += Op->Common.Value.Integer32; break; case AML_INT_RESERVEDFIELD_OP: /* Offset() -- Must account for previous offsets */ Offset = Op->Common.Value.Integer32; Info->BitOffset += Offset; if (Info->BitOffset % 8 == 0) { AcpiOsPrintf ("Offset (0x%.2X)", ACPI_DIV_8 (Info->BitOffset)); } else { AcpiOsPrintf (" , %d", Offset); } AcpiDmCommaIfFieldMember (Op); break; case AML_INT_ACCESSFIELD_OP: - AcpiOsPrintf ("AccessAs (%s, 0x%.2X)", - AcpiGbl_AccessTypes [Op->Common.Value.Integer32 >> 8], - Op->Common.Value.Integer32 & 0x0F); + AcpiOsPrintf ("AccessAs (%s, ", + AcpiGbl_AccessTypes [Op->Common.Value.Integer32 >> 8]); + AcpiDmDecodeAttribute ((UINT8) Op->Common.Value.Integer32); + AcpiOsPrintf (")"); AcpiDmCommaIfFieldMember (Op); break; case AML_INT_BYTELIST_OP: AcpiDmByteList (Info, Op); break; case AML_INT_METHODCALL_OP: OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); Op = AcpiPsGetDepthNext (NULL, Op); Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; AcpiDmNamestring (Op->Common.Value.Name); break; default: /* Just get the opcode name and print it */ OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); AcpiOsPrintf ("%s", OpInfo->Name); #ifdef ACPI_DEBUGGER if ((Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) && (WalkState) && (WalkState->Results) && (WalkState->Results->Results.NumResults)) { AcpiDbDecodeInternalObject ( WalkState->Results->Results.ObjDesc [WalkState->Results->Results.NumResults-1]); } #endif break; } } #endif /* ACPI_DISASSEMBLER */ diff --git a/sys/contrib/dev/acpica/dmutils.c b/sys/contrib/dev/acpica/dmutils.c index bb6fca0ec937..add77805f237 100644 --- a/sys/contrib/dev/acpica/dmutils.c +++ b/sys/contrib/dev/acpica/dmutils.c @@ -1,402 +1,464 @@ /******************************************************************************* * * Module Name: dmutils - AML disassembler utilities - * $Revision: 4 $ + * $Revision: 5 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License * * 2.1. This is your license from Intel Corp. under its intellectual property * rights. You may have additional license terms from the party that provided * you this software, covering your right to use that party's intellectual * property rights. * * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a * copy of the source code appearing in this file ("Covered Code") an * irrevocable, perpetual, worldwide license under Intel's copyrights in the * base code distributed originally by Intel ("Original Intel Code") to copy, * make derivatives, distribute, use and display any portion of the Covered * Code in any form, with the right to sublicense such rights; and * * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent * license (with the right to sublicense), under only those claims of Intel * patents that are infringed by the Original Intel Code, to make, use, sell, * offer to sell, and import the Covered Code and derivative works thereof * solely to the minimum extent necessary to exercise the above copyright * license, and in no event shall the patent license extend to any additions * to or modifications of the Original Intel Code. No other license or right * is granted directly or by implication, estoppel or otherwise; * * The above copyright and patent license is granted only if the following * conditions are met: * * 3. Conditions * * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, * and the following Disclaimer and Export Compliance provision. In addition, * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the * documentation and/or other materials provided with distribution. In * addition, Licensee may not authorize further sublicense of source of any * portion of the Covered Code, and must include terms to the effect that the * license from Licensee to its licensee is limited to the intellectual * property embodied in the software Licensee provides to its licensee, and * not to intellectual property embodied in modifications its licensee may * make. * * 3.3. Redistribution of Executable. Redistribution in executable form of any * substantial portion of the Covered Code or modification must reproduce the * above Copyright Notice, and the following Disclaimer and Export Compliance * provision in the documentation and/or other materials provided with the * distribution. * * 3.4. Intel retains all right, title, and interest in and to the Original * Intel Code. * * 3.5. Neither the name Intel nor any other trademark owned or controlled by * Intel shall be used in advertising or otherwise to promote the sale, use or * other dealings in products derived from or relating to the Covered Code * without prior written authorization from Intel. * * 4. Disclaimer and Export Compliance * * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY * LIMITED REMEDY. * * 4.3. Licensee shall not export, either directly or indirectly, any of this * software or system incorporating such software without first obtaining any * required license or other approval from the U. S. Department of Commerce or * any other agency or department of the United States Government. In the * event Licensee exports any such software from the United States or * re-exports any such software from a foreign destination, Licensee shall * ensure that the distribution and export/re-export of the software is in * compliance with all laws, regulations, orders, or other restrictions of the * U.S. Export Administration Regulations. Licensee agrees that neither it nor * any of its subsidiaries will export/re-export any technical data, process, * software, or service, directly or indirectly, to any country for which the * United States government or any agency thereof requires an export license, * other governmental approval, or letter of assurance, without first obtaining * such license, approval or letter. * *****************************************************************************/ #include "acpi.h" #include "amlcode.h" #include "acdisasm.h" #ifdef ACPI_DISASSEMBLER #define _COMPONENT ACPI_CA_DEBUGGER ACPI_MODULE_NAME ("dmutils") /* Data used in keeping track of fields */ #if 0 const NATIVE_CHAR *AcpiGbl_FENames[NUM_FIELD_NAMES] = { "skip", "?access?" }; /* FE = Field Element */ #endif const NATIVE_CHAR *AcpiGbl_MatchOps[NUM_MATCH_OPS] = { "MTR", "MEQ", "MLE", "MLT", "MGE", "MGT" }; /* Access type decoding */ const NATIVE_CHAR *AcpiGbl_AccessTypes[NUM_ACCESS_TYPES] = { "AnyAcc", "ByteAcc", "WordAcc", "DWordAcc", "QWordAcc", "BufferAcc", }; /* Lock rule decoding */ const NATIVE_CHAR *AcpiGbl_LockRule[NUM_LOCK_RULES] = { "NoLock", "Lock" }; /* Update rule decoding */ const NATIVE_CHAR *AcpiGbl_UpdateRules[NUM_UPDATE_RULES] = { "Preserve", "WriteAsOnes", "WriteAsZeros" }; /* * Strings used to decode resource descriptors */ const char *AcpiGbl_IoDecode[2] = { "Decode10", "Decode16" }; const char *AcpiGbl_WordDecode[4] = { "WordMemory", "WordIO", "WordBusNumber", "Unknown-resource-type" }; const char *AcpiGbl_ConsumeDecode[2] = { "ResourceProducer", "ResourceConsumer" }; const char *AcpiGbl_MinDecode[2] = { "MinNotFixed", "MinFixed" }; const char *AcpiGbl_MaxDecode[2] = { "MaxNotFixed", "MaxFixed" }; const char *AcpiGbl_DECDecode[2] = { "PosDecode", "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", "IRQ" }; const char *AcpiGbl_HEDecode[2] = { "Level", "Edge" }; const char *AcpiGbl_LLDecode[2] = { "ActiveHigh", "ActiveLow" }; const char *AcpiGbl_SHRDecode[2] = { "Exclusive", "Shared" }; const char *AcpiGbl_TYPDecode[4] = { "Compatibility", "TypeA", "TypeB", "TypeF" }; const char *AcpiGbl_BMDecode[2] = { "NotBusMaster", "BusMaster" }; const char *AcpiGbl_SIZDecode[4] = { "Transfer8", "Transfer8_16", "Transfer16", "InvalidSize" }; +/******************************************************************************* + * + * FUNCTION: AcpiDmDecodeAttribute + * + * PARAMETERS: Attribute - Attribute field of AccessAs keyword + * + * RETURN: None + * + * DESCRIPTION: Decode the AccessAs attribute byte. (Mostly SMBus stuff) + * + ******************************************************************************/ + +void +AcpiDmDecodeAttribute ( + UINT8 Attribute) +{ + + switch (Attribute) + { + case AML_FIELD_ATTRIB_SMB_QUICK: + + AcpiOsPrintf ("SMBQuick"); + break; + + case AML_FIELD_ATTRIB_SMB_SEND_RCV: + + AcpiOsPrintf ("SMBSendReceive"); + break; + + case AML_FIELD_ATTRIB_SMB_BYTE: + + AcpiOsPrintf ("SMBByte"); + break; + + case AML_FIELD_ATTRIB_SMB_WORD: + + AcpiOsPrintf ("SMBWord"); + break; + + case AML_FIELD_ATTRIB_SMB_WORD_CALL: + + AcpiOsPrintf ("SMBProcessCall"); + break; + + case AML_FIELD_ATTRIB_SMB_BLOCK: + + AcpiOsPrintf ("SMBBlock"); + break; + + case AML_FIELD_ATTRIB_SMB_BLOCK_CALL: + + AcpiOsPrintf ("SMBBlockProcessCall"); + break; + + default: + + AcpiOsPrintf ("0x%.2X", Attribute); + break; + } +} + + /******************************************************************************* * * FUNCTION: AcpiDmIndent * * PARAMETERS: Level - Current source code indentation level * * RETURN: None * * DESCRIPTION: Indent 4 spaces per indentation level. * ******************************************************************************/ void AcpiDmIndent ( UINT32 Level) { if (!Level) { return; } AcpiOsPrintf ("%*.s", ACPI_MUL_4 (Level), " "); } /******************************************************************************* * * FUNCTION: AcpiDmCommaIfListMember * * PARAMETERS: Op - Current operator/operand * * RETURN: TRUE if a comma was inserted * * DESCRIPTION: Insert a comma if this Op is a member of an argument list. * ******************************************************************************/ BOOLEAN AcpiDmCommaIfListMember ( ACPI_PARSE_OBJECT *Op) { if (!Op->Common.Next) { return FALSE; } if (AcpiDmListType (Op->Common.Parent) & BLOCK_COMMA_LIST) { /* Check for a NULL target operand */ if ((Op->Common.Next->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && (!Op->Common.Next->Common.Value.String)) { /* * To handle the Divide() case where there are two optional * targets, look ahead one more op. If null, this null target * is the one and only target -- no comma needed. Otherwise, * we need a comma to prepare for the next target. */ if (!Op->Common.Next->Common.Next) { return FALSE; } } if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) && (!(Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST))) { return FALSE; } AcpiOsPrintf (", "); return (TRUE); } else if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) && (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) { AcpiOsPrintf (", "); return (TRUE); } return (FALSE); } /******************************************************************************* * * FUNCTION: AcpiDmCommaIfFieldMember * * PARAMETERS: Op - Current operator/operand * * RETURN: None * * DESCRIPTION: Insert a comma if this Op is a member of a Field argument list. * ******************************************************************************/ void AcpiDmCommaIfFieldMember ( ACPI_PARSE_OBJECT *Op) { if (Op->Common.Next) { AcpiOsPrintf (", "); } } #endif diff --git a/sys/contrib/dev/acpica/dsfield.c b/sys/contrib/dev/acpica/dsfield.c index 22359ef8d9d2..13c7bb239b34 100644 --- a/sys/contrib/dev/acpica/dsfield.c +++ b/sys/contrib/dev/acpica/dsfield.c @@ -1,698 +1,698 @@ /****************************************************************************** * * Module Name: dsfield - Dispatcher field routines - * $Revision: 68 $ + * $Revision: 69 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __DSFIELD_C__ #include "acpi.h" #include "amlcode.h" #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" #include "acparser.h" #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsfield") /******************************************************************************* * * FUNCTION: AcpiDsCreateBufferField * * PARAMETERS: Opcode - The opcode to be executed * Operands - List of operands for the opcode * WalkState - Current state * * RETURN: Status * * DESCRIPTION: Execute the CreateField operators: * CreateBitFieldOp, * CreateByteFieldOp, * CreateWordFieldOp, * CreateDWordFieldOp, * CreateQWordFieldOp, * CreateFieldOp (all of which define fields in buffers) * ******************************************************************************/ ACPI_STATUS AcpiDsCreateBufferField ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState) { ACPI_PARSE_OBJECT *Arg; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *SecondDesc = NULL; UINT32 Flags; ACPI_FUNCTION_TRACE ("DsCreateBufferField"); /* Get the NameString argument */ if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) { Arg = AcpiPsGetArg (Op, 3); } else { /* Create Bit/Byte/Word/Dword field */ Arg = AcpiPsGetArg (Op, 2); } if (!Arg) { return_ACPI_STATUS (AE_AML_NO_OPERAND); } /* * During the load phase, we want to enter the name of the field into * the namespace. During the execute phase (when we evaluate the size * operand), we want to lookup the name */ if (WalkState->ParseFlags & ACPI_PARSE_EXECUTE) { Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE; } else { Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND; } /* * Enter the NameString into the namespace */ Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, - INTERNAL_TYPE_DEF_ANY, ACPI_IMODE_LOAD_PASS1, + ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node)); if (ACPI_FAILURE (Status)) { ACPI_REPORT_NSERROR (Arg->Common.Value.String, Status); return_ACPI_STATUS (Status); } /* 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. */ ObjDesc = AcpiNsGetAttachedObject (Node); if (ObjDesc) { return_ACPI_STATUS (AE_OK); } /* * The Field definition is not fully parsed at this time. * (We must save the address of the AML for the buffer and index operands) */ /* Create the buffer field object */ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER_FIELD); if (!ObjDesc) { Status = AE_NO_MEMORY; goto Cleanup; } /* * Remember location in AML stream of the field unit * opcode and operands -- since the buffer and index * operands must be evaluated. */ SecondDesc = ObjDesc->Common.NextObject; SecondDesc->Extra.AmlStart = Op->Named.Data; SecondDesc->Extra.AmlLength = Op->Named.Length; ObjDesc->BufferField.Node = Node; /* Attach constructed field descriptors to parent node */ Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_BUFFER_FIELD); if (ACPI_FAILURE (Status)) { goto Cleanup; } Cleanup: /* Remove local reference to the object */ AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiDsGetFieldNames * * PARAMETERS: Info - CreateField info structure * ` WalkState - Current method state * Arg - First parser arg for the field name list * * RETURN: Status * * DESCRIPTION: Process all named fields in a field declaration. Names are * entered into the namespace. * ******************************************************************************/ ACPI_STATUS AcpiDsGetFieldNames ( ACPI_CREATE_FIELD_INFO *Info, ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Arg) { ACPI_STATUS Status; ACPI_INTEGER Position; ACPI_FUNCTION_TRACE_PTR ("DsGetFieldNames", Info); /* First field starts at bit zero */ Info->FieldBitPosition = 0; /* Process all elements in the field list (of parse nodes) */ while (Arg) { /* * Three types of field elements are handled: * 1) Offset - specifies a bit offset * 2) AccessAs - changes the access mode * 3) Name - Enters a new named field into the namespace */ switch (Arg->Common.AmlOpcode) { case AML_INT_RESERVEDFIELD_OP: Position = (ACPI_INTEGER) Info->FieldBitPosition + (ACPI_INTEGER) Arg->Common.Value.Size; if (Position > ACPI_UINT32_MAX) { ACPI_REPORT_ERROR (("Bit offset within field too large (> 0xFFFFFFFF)\n")); return_ACPI_STATUS (AE_SUPPORT); } Info->FieldBitPosition = (UINT32) Position; break; case AML_INT_ACCESSFIELD_OP: /* * Get a new AccessType and AccessAttribute -- to be used for all * field units that follow, until field end or another AccessAs keyword. * * In FieldFlags, preserve the flag bits other than the ACCESS_TYPE bits */ Info->FieldFlags = (UINT8) ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | ((UINT8) (Arg->Common.Value.Integer32 >> 8))); Info->Attribute = (UINT8) (Arg->Common.Value.Integer32); break; case AML_INT_NAMEDFIELD_OP: /* Lookup the name */ Status = AcpiNsLookup (WalkState->ScopeInfo, (NATIVE_CHAR *) &Arg->Named.Name, Info->FieldType, ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, WalkState, &Info->FieldNode); if (ACPI_FAILURE (Status)) { ACPI_REPORT_NSERROR ((char *) &Arg->Named.Name, Status); if (Status != AE_ALREADY_EXISTS) { return_ACPI_STATUS (Status); } /* Already exists, ignore error */ } else { Arg->Common.Node = Info->FieldNode; Info->FieldBitLength = Arg->Common.Value.Size; /* Create and initialize an object for the new Field Node */ Status = AcpiExPrepFieldValue (Info); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* Keep track of bit position for the next field */ Position = (ACPI_INTEGER) Info->FieldBitPosition + (ACPI_INTEGER) Arg->Common.Value.Size; if (Position > ACPI_UINT32_MAX) { ACPI_REPORT_ERROR (("Field [%4.4s] bit offset too large (> 0xFFFFFFFF)\n", (char *) &Info->FieldNode->Name)); return_ACPI_STATUS (AE_SUPPORT); } Info->FieldBitPosition += Info->FieldBitLength; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid opcode in field list: %X\n", Arg->Common.AmlOpcode)); return_ACPI_STATUS (AE_AML_BAD_OPCODE); } Arg = Arg->Common.Next; } return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiDsCreateField * * PARAMETERS: Op - Op containing the Field definition and args * RegionNode - Object for the containing Operation Region * ` WalkState - Current method state * * RETURN: Status * * DESCRIPTION: Create a new field in the specified operation region * ******************************************************************************/ ACPI_STATUS AcpiDsCreateField ( ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *RegionNode, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_PARSE_OBJECT *Arg; ACPI_CREATE_FIELD_INFO Info; ACPI_FUNCTION_TRACE_PTR ("DsCreateField", Op); /* First arg is the name of the parent OpRegion (must already exist) */ Arg = Op->Common.Value.Arg; if (!RegionNode) { Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); if (ACPI_FAILURE (Status)) { ACPI_REPORT_NSERROR (Arg->Common.Value.Name, Status); return_ACPI_STATUS (Status); } } /* Second arg is the field flags */ Arg = Arg->Common.Next; Info.FieldFlags = Arg->Common.Value.Integer8; Info.Attribute = 0; /* Each remaining arg is a Named Field */ - Info.FieldType = INTERNAL_TYPE_REGION_FIELD; + Info.FieldType = ACPI_TYPE_LOCAL_REGION_FIELD; Info.RegionNode = RegionNode; Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiDsInitFieldObjects * * PARAMETERS: Op - Op containing the Field definition and args * ` WalkState - Current method state * * RETURN: Status * * DESCRIPTION: For each "Field Unit" name in the argument list that is * part of the field declaration, enter the name into the * namespace. * ******************************************************************************/ ACPI_STATUS AcpiDsInitFieldObjects ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_PARSE_OBJECT *Arg = NULL; ACPI_NAMESPACE_NODE *Node; UINT8 Type = 0; ACPI_FUNCTION_TRACE_PTR ("DsInitFieldObjects", Op); switch (WalkState->Opcode) { case AML_FIELD_OP: Arg = AcpiPsGetArg (Op, 2); - Type = INTERNAL_TYPE_REGION_FIELD; + Type = ACPI_TYPE_LOCAL_REGION_FIELD; break; case AML_BANK_FIELD_OP: Arg = AcpiPsGetArg (Op, 4); - Type = INTERNAL_TYPE_BANK_FIELD; + Type = ACPI_TYPE_LOCAL_BANK_FIELD; break; case AML_INDEX_FIELD_OP: Arg = AcpiPsGetArg (Op, 3); - Type = INTERNAL_TYPE_INDEX_FIELD; + Type = ACPI_TYPE_LOCAL_INDEX_FIELD; break; default: return_ACPI_STATUS (AE_BAD_PARAMETER); } /* * Walk the list of entries in the FieldList */ while (Arg) { /* Ignore OFFSET and ACCESSAS terms here */ if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) { Status = AcpiNsLookup (WalkState->ScopeInfo, (NATIVE_CHAR *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1, ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, WalkState, &Node); if (ACPI_FAILURE (Status)) { ACPI_REPORT_NSERROR ((char *) &Arg->Named.Name, Status); if (Status != AE_ALREADY_EXISTS) { return_ACPI_STATUS (Status); } /* Name already exists, just ignore this error */ Status = AE_OK; } Arg->Common.Node = Node; } /* Move to next field in the list */ Arg = Arg->Common.Next; } return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiDsCreateBankField * * PARAMETERS: Op - Op containing the Field definition and args * RegionNode - Object for the containing Operation Region * ` WalkState - Current method state * * RETURN: Status * * DESCRIPTION: Create a new bank field in the specified operation region * ******************************************************************************/ ACPI_STATUS AcpiDsCreateBankField ( ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *RegionNode, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_PARSE_OBJECT *Arg; ACPI_CREATE_FIELD_INFO Info; ACPI_FUNCTION_TRACE_PTR ("DsCreateBankField", Op); /* First arg is the name of the parent OpRegion (must already exist) */ Arg = Op->Common.Value.Arg; if (!RegionNode) { Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); if (ACPI_FAILURE (Status)) { ACPI_REPORT_NSERROR (Arg->Common.Value.Name, Status); return_ACPI_STATUS (Status); } } - /* Second arg is the Bank Register (must already exist) */ + /* Second arg is the Bank Register (Field) (must already exist) */ Arg = Arg->Common.Next; Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, - INTERNAL_TYPE_BANK_FIELD_DEFN, ACPI_IMODE_EXECUTE, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); if (ACPI_FAILURE (Status)) { ACPI_REPORT_NSERROR (Arg->Common.Value.String, Status); return_ACPI_STATUS (Status); } /* Third arg is the BankValue */ Arg = Arg->Common.Next; Info.BankValue = Arg->Common.Value.Integer32; /* Fourth arg is the field flags */ Arg = Arg->Common.Next; Info.FieldFlags = Arg->Common.Value.Integer8; /* Each remaining arg is a Named Field */ - Info.FieldType = INTERNAL_TYPE_BANK_FIELD; + Info.FieldType = ACPI_TYPE_LOCAL_BANK_FIELD; Info.RegionNode = RegionNode; Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiDsCreateIndexField * * PARAMETERS: Op - Op containing the Field definition and args * RegionNode - Object for the containing Operation Region * ` WalkState - Current method state * * RETURN: Status * * DESCRIPTION: Create a new index field in the specified operation region * ******************************************************************************/ ACPI_STATUS AcpiDsCreateIndexField ( ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *RegionNode, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_PARSE_OBJECT *Arg; ACPI_CREATE_FIELD_INFO Info; ACPI_FUNCTION_TRACE_PTR ("DsCreateIndexField", Op); /* First arg is the name of the Index register (must already exist) */ Arg = Op->Common.Value.Arg; Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); if (ACPI_FAILURE (Status)) { ACPI_REPORT_NSERROR (Arg->Common.Value.String, Status); return_ACPI_STATUS (Status); } /* Second arg is the data register (must already exist) */ Arg = Arg->Common.Next; Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, - INTERNAL_TYPE_INDEX_FIELD_DEFN, ACPI_IMODE_EXECUTE, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode); if (ACPI_FAILURE (Status)) { ACPI_REPORT_NSERROR (Arg->Common.Value.String, Status); return_ACPI_STATUS (Status); } /* Next arg is the field flags */ Arg = Arg->Common.Next; Info.FieldFlags = Arg->Common.Value.Integer8; /* Each remaining arg is a Named Field */ - Info.FieldType = INTERNAL_TYPE_INDEX_FIELD; + Info.FieldType = ACPI_TYPE_LOCAL_INDEX_FIELD; Info.RegionNode = RegionNode; Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/dsmethod.c b/sys/contrib/dev/acpica/dsmethod.c index 6de47cfd5cb9..967653933ee3 100644 --- a/sys/contrib/dev/acpica/dsmethod.c +++ b/sys/contrib/dev/acpica/dsmethod.c @@ -1,649 +1,649 @@ /****************************************************************************** * * Module Name: dsmethod - Parser/Interpreter interface - control method parsing - * $Revision: 88 $ + * $Revision: 89 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __DSMETHOD_C__ #include "acpi.h" #include "acparser.h" #include "amlcode.h" #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsmethod") /******************************************************************************* * * FUNCTION: AcpiDsParseMethod * * PARAMETERS: ObjHandle - Node of the method * Level - Current nesting level * Context - Points to a method counter * ReturnValue - Not used * * RETURN: Status * * DESCRIPTION: Call the parser and parse the AML that is * associated with the method. * * MUTEX: Assumes parser is locked * ******************************************************************************/ ACPI_STATUS AcpiDsParseMethod ( ACPI_HANDLE ObjHandle) { 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); /* Parameter Validation */ if (!ObjHandle) { return_ACPI_STATUS (AE_NULL_ENTRY); } ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Parsing [%4.4s] **** NamedObj=%p\n", ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii, ObjHandle)); /* Extract the method object from the method Node */ Node = (ACPI_NAMESPACE_NODE *) ObjHandle; ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { return_ACPI_STATUS (AE_NULL_OBJECT); } /* Create a mutex for the method if there is a concurrency limit */ if ((ObjDesc->Method.Concurrency != INFINITE_CONCURRENCY) && (!ObjDesc->Method.Semaphore)) { Status = AcpiOsCreateSemaphore (ObjDesc->Method.Concurrency, ObjDesc->Method.Concurrency, &ObjDesc->Method.Semaphore); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* * Allocate a new parser op to be the root of the parsed * method tree */ Op = AcpiPsAllocOp (AML_METHOD_OP); if (!Op) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Init new op with the method name and pointer back to the Node */ AcpiPsSetName (Op, Node->Name.Integer); Op->Common.Node = Node; /* * Get a new OwnerId for objects created by this method. Namespace * objects (such as Operation Regions) can be created during the * first pass parse. */ OwnerId = AcpiUtAllocateOwnerId (ACPI_OWNER_TYPE_METHOD); ObjDesc->Method.OwningId = OwnerId; /* Create and initialize a new walk state */ WalkState = AcpiDsCreateWalkState (OwnerId, NULL, NULL, NULL); if (!WalkState) { return_ACPI_STATUS (AE_NO_MEMORY); } Status = AcpiDsInitAmlWalk (WalkState, Op, Node, ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, NULL, NULL, 1); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); return_ACPI_STATUS (Status); } /* * 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. */ Status = AcpiPsParseAml (WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** [%4.4s] Parsed **** NamedObj=%p Op=%p\n", ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii, ObjHandle, Op)); AcpiPsDeleteParseTree (Op); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiDsBeginMethodExecution * * PARAMETERS: MethodNode - Node of the method * ObjDesc - The method object * CallingMethodNode - Caller of this method (if non-null) * * RETURN: Status * * DESCRIPTION: Prepare a method for execution. Parses the method if necessary, * increments the thread count, and waits at the method semaphore * for clearance to execute. * * MUTEX: Locks/unlocks parser. * ******************************************************************************/ ACPI_STATUS AcpiDsBeginMethodExecution ( ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_NAMESPACE_NODE *CallingMethodNode) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE_PTR ("DsBeginMethodExecution", MethodNode); if (!MethodNode) { return_ACPI_STATUS (AE_NULL_ENTRY); } /* * If there is a concurrency limit on this method, we need to * obtain a unit from the method semaphore. */ if (ObjDesc->Method.Semaphore) { /* * Allow recursive method calls, up to the reentrancy/concurrency * limit imposed by the SERIALIZED rule and the SyncLevel method * parameter. * * The point of this code is to avoid permanently blocking a * thread that is making recursive method calls. */ if (MethodNode == CallingMethodNode) { if (ObjDesc->Method.ThreadCount >= ObjDesc->Method.Concurrency) { return_ACPI_STATUS (AE_AML_METHOD_LIMIT); } } /* * Get a unit from the method semaphore. This releases the * interpreter if we block */ Status = AcpiExSystemWaitSemaphore (ObjDesc->Method.Semaphore, - WAIT_FOREVER); + ACPI_WAIT_FOREVER); } /* * Increment the method parse tree thread count since it has been * reentered one more time (even if it is the same thread) */ ObjDesc->Method.ThreadCount++; return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiDsCallControlMethod * * PARAMETERS: WalkState - Current state of the walk * Op - Current Op to be walked * * RETURN: Status * * DESCRIPTION: Transfer execution to a called control method * ******************************************************************************/ ACPI_STATUS AcpiDsCallControlMethod ( ACPI_THREAD_STATE *Thread, ACPI_WALK_STATE *ThisWalkState, ACPI_PARSE_OBJECT *Op) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *MethodNode; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_WALK_STATE *NextWalkState; UINT32 i; ACPI_FUNCTION_TRACE_PTR ("DsCallControlMethod", ThisWalkState); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Execute method %p, currentstate=%p\n", ThisWalkState->PrevOp, ThisWalkState)); /* * Get the namespace entry for the control method we are about to call */ MethodNode = ThisWalkState->MethodCallNode; if (!MethodNode) { return_ACPI_STATUS (AE_NULL_ENTRY); } ObjDesc = AcpiNsGetAttachedObject (MethodNode); if (!ObjDesc) { return_ACPI_STATUS (AE_NULL_OBJECT); } /* Init for new method, wait on concurrency semaphore */ Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc, ThisWalkState->MethodNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* 1) Parse: Create a new walk state for the preempting walk */ NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwningId, Op, ObjDesc, NULL); if (!NextWalkState) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Create and init a Root Node */ Op = AcpiPsCreateScopeOp (); if (!Op) { Status = AE_NO_MEMORY; goto Cleanup; } Status = AcpiDsInitAmlWalk (NextWalkState, Op, MethodNode, ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, NULL, NULL, 1); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (NextWalkState); goto Cleanup; } /* Begin AML parse */ Status = AcpiPsParseAml (NextWalkState); AcpiPsDeleteParseTree (Op); /* 2) Execute: Create a new state for the preempting walk */ NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwningId, NULL, ObjDesc, Thread); if (!NextWalkState) { Status = AE_NO_MEMORY; goto Cleanup; } /* * 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 */ ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL; Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode, ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, &ThisWalkState->Operands[0], NULL, 3); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* * Delete the operands on the previous walkstate operand stack * (they were copied to new objects) */ for (i = 0; i < ObjDesc->Method.ParamCount; i++) { AcpiUtRemoveReference (ThisWalkState->Operands [i]); ThisWalkState->Operands [i] = NULL; } /* Clear the operand stack */ ThisWalkState->NumOperands = 0; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Starting nested execution, newstate=%p\n", NextWalkState)); return_ACPI_STATUS (AE_OK); /* On error, we must delete the new walk state */ Cleanup: (void) AcpiDsTerminateControlMethod (NextWalkState); AcpiDsDeleteWalkState (NextWalkState); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiDsRestartControlMethod * * PARAMETERS: WalkState - State of the method when it was preempted * Op - Pointer to new current op * * RETURN: Status * * DESCRIPTION: Restart a method that was preempted * ******************************************************************************/ ACPI_STATUS AcpiDsRestartControlMethod ( ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ReturnDesc) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE_PTR ("DsRestartControlMethod", WalkState); if (ReturnDesc) { if (WalkState->ReturnUsed) { /* * Get the return value (if any) from the previous method. * NULL if no return value */ Status = AcpiDsResultPush (ReturnDesc, WalkState); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ReturnDesc); return_ACPI_STATUS (Status); } } else { /* * Delete the return value if it will not be used by the * calling method */ AcpiUtRemoveReference (ReturnDesc); } } ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method=%p Return=%p ReturnUsed?=%X ResStack=%p State=%p\n", WalkState->MethodCallOp, ReturnDesc, WalkState->ReturnUsed, WalkState->Results, WalkState)); return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiDsTerminateControlMethod * * PARAMETERS: WalkState - State of the method * * RETURN: Status * * DESCRIPTION: Terminate a control method. Delete everything that the method * created, delete all locals and arguments, and delete the parse * tree if requested. * ******************************************************************************/ ACPI_STATUS AcpiDsTerminateControlMethod ( ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *MethodNode; ACPI_STATUS Status; ACPI_FUNCTION_TRACE_PTR ("DsTerminateControlMethod", WalkState); if (!WalkState) { return (AE_BAD_PARAMETER); } /* The current method object was saved in the walk state */ ObjDesc = WalkState->MethodDesc; if (!ObjDesc) { return_ACPI_STATUS (AE_OK); } /* Delete all arguments and locals */ AcpiDsMethodDataDeleteAll (WalkState); /* * Lock the parser while we terminate this method. * If this is the last thread executing the method, * we have additional cleanup to perform */ Status = AcpiUtAcquireMutex (ACPI_MTX_PARSER); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Signal completion of the execution of this method if necessary */ if (WalkState->MethodDesc->Method.Semaphore) { Status = AcpiOsSignalSemaphore ( WalkState->MethodDesc->Method.Semaphore, 1); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("Could not signal method semaphore\n")); Status = AE_OK; /* Ignore error and continue cleanup */ } } /* Decrement the thread count on the method parse tree */ WalkState->MethodDesc->Method.ThreadCount--; if (!WalkState->MethodDesc->Method.ThreadCount) { /* * There are no more threads executing this method. Perform * additional cleanup. * * The method Node is stored in the walk state */ MethodNode = WalkState->MethodNode; /* * Delete any namespace entries created immediately underneath * the method */ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } if (MethodNode->Child) { AcpiNsDeleteNamespaceSubtree (MethodNode); } /* * Delete any namespace entries created anywhere else within * the namespace */ AcpiNsDeleteNamespaceByOwner (WalkState->MethodDesc->Method.OwningId); Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } Status = AcpiUtReleaseMutex (ACPI_MTX_PARSER); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/dsmthdat.c b/sys/contrib/dev/acpica/dsmthdat.c index e466158c5750..301cadbb1d65 100644 --- a/sys/contrib/dev/acpica/dsmthdat.c +++ b/sys/contrib/dev/acpica/dsmthdat.c @@ -1,763 +1,763 @@ /******************************************************************************* * * Module Name: dsmthdat - control method arguments and local variables - * $Revision: 63 $ + * $Revision: 64 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __DSMTHDAT_C__ #include "acpi.h" #include "acdispat.h" #include "amlcode.h" #include "acnamesp.h" #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsmthdat") /******************************************************************************* * * FUNCTION: AcpiDsMethodDataInit * * PARAMETERS: WalkState - Current walk state object * * 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 * special data types. * * NOTES: WalkState fields are initialized to zero by the * ACPI_MEM_CALLOCATE(). * * A pseudo-Namespace Node is assigned to each argument and local * so that RefOf() can return a pointer to the Node. * ******************************************************************************/ void AcpiDsMethodDataInit ( ACPI_WALK_STATE *WalkState) { UINT32 i; ACPI_FUNCTION_TRACE ("DsMethodDataInit"); /* Init the method arguments */ for (i = 0; i < MTH_NUM_ARGS; i++) { ACPI_MOVE_UNALIGNED32_TO_32 (&WalkState->Arguments[i].Name, NAMEOF_ARG_NTE); 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; } /* Init the method locals */ for (i = 0; i < MTH_NUM_LOCALS; i++) { ACPI_MOVE_UNALIGNED32_TO_32 (&WalkState->LocalVariables[i].Name, NAMEOF_LOCAL_NTE); 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; } return_VOID; } /******************************************************************************* * * FUNCTION: AcpiDsMethodDataDeleteAll * * PARAMETERS: WalkState - Current walk state object * * RETURN: None * * DESCRIPTION: Delete method locals and arguments. Arguments are only * deleted if this method was called from another method. * ******************************************************************************/ void AcpiDsMethodDataDeleteAll ( ACPI_WALK_STATE *WalkState) { UINT32 Index; ACPI_FUNCTION_TRACE ("DsMethodDataDeleteAll"); /* Detach the locals */ for (Index = 0; Index < MTH_NUM_LOCALS; Index++) { if (WalkState->LocalVariables[Index].Object) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", Index, WalkState->LocalVariables[Index].Object)); /* Detach object (if present) and remove a reference */ AcpiNsDetachObject (&WalkState->LocalVariables[Index]); } } /* Detach the arguments */ for (Index = 0; Index < MTH_NUM_ARGS; Index++) { if (WalkState->Arguments[Index].Object) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", Index, WalkState->Arguments[Index].Object)); /* Detach object (if present) and remove a reference */ AcpiNsDetachObject (&WalkState->Arguments[Index]); } } return_VOID; } /******************************************************************************* * * FUNCTION: AcpiDsMethodDataInitArgs * * PARAMETERS: *Params - Pointer to a parameter list for the method * MaxParamCount - The arg count for this method * WalkState - Current walk state object * * RETURN: Status * * DESCRIPTION: Initialize arguments for a method. The parameter list is a list * of ACPI operand objects, either null terminated or whose length * is defined by MaxParamCount. * ******************************************************************************/ ACPI_STATUS AcpiDsMethodDataInitArgs ( ACPI_OPERAND_OBJECT **Params, UINT32 MaxParamCount, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; UINT32 Index = 0; ACPI_FUNCTION_TRACE_PTR ("DsMethodDataInitArgs", Params); if (!Params) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); return_ACPI_STATUS (AE_OK); } /* Copy passed parameters into the new method stack frame */ while ((Index < MTH_NUM_ARGS) && (Index < MaxParamCount) && Params[Index]) { /* * A valid parameter. * Store the argument in the method/walk descriptor */ Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, Params[Index], WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Index++; } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Index)); return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiDsMethodDataGetNode * * 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: Get the Node associated with a local or arg. * ******************************************************************************/ ACPI_STATUS AcpiDsMethodDataGetNode ( UINT16 Opcode, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **Node) { ACPI_FUNCTION_TRACE ("DsMethodDataGetNode"); /* * Method Locals and Arguments are supported */ switch (Opcode) { case AML_LOCAL_OP: if (Index > MTH_MAX_LOCAL) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n", Index, MTH_MAX_LOCAL)); return_ACPI_STATUS (AE_AML_INVALID_INDEX); } /* Return a pointer to the pseudo-node */ *Node = &WalkState->LocalVariables[Index]; break; case AML_ARG_OP: if (Index > MTH_MAX_ARG) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n", Index, MTH_MAX_ARG)); return_ACPI_STATUS (AE_AML_INVALID_INDEX); } /* Return a pointer to the pseudo-node */ *Node = &WalkState->Arguments[Index]; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", Opcode)); return_ACPI_STATUS (AE_AML_BAD_OPCODE); } return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiDsMethodDataSetValue * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which localVar or argument to get * Object - Object to be inserted into the stack entry * WalkState - Current walk state object * * RETURN: Status * * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. * ******************************************************************************/ ACPI_STATUS AcpiDsMethodDataSetValue ( UINT16 Opcode, UINT32 Index, ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; ACPI_FUNCTION_TRACE ("DsMethodDataSetValue"); /* Get the namespace node for the arg/local */ Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Increment ref count so object can't be deleted while installed */ AcpiUtAddReference (Object); /* Install the object into the stack entry */ Node->Object = Object; return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * 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 * * RETURN: Status * * DESCRIPTION: Retrieve value of selected Arg or Local from the method frame * at the current top of the method stack. * Used only in AcpiExResolveToValue(). * ******************************************************************************/ ACPI_STATUS AcpiDsMethodDataGetValue ( UINT16 Opcode, UINT32 Index, ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **DestDesc) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *Object; ACPI_FUNCTION_TRACE ("DsMethodDataGetValue"); /* Validate the object descriptor */ if (!DestDesc) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n")); return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Get the namespace node for the arg/local */ Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Get the object from the node */ Object = Node->Object; /* Examine the returned object, it must be valid. */ if (!Object) { /* * Index points to uninitialized object. * This means that either 1) The expected argument was * not passed to the method, or 2) A local variable * was referenced by the method (via the ASL) * before it was initialized. Either case is an error. */ switch (Opcode) { case AML_ARG_OP: 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", Index, Node)); return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); default: return_ACPI_STATUS (AE_AML_INTERNAL); } } /* * The Index points to an initialized and valid object. * Return an additional reference to the object */ *DestDesc = Object; AcpiUtAddReference (Object); return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiDsMethodDataDeleteValue * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which localVar or argument to delete * WalkState - Current walk state object * * RETURN: None * * DESCRIPTION: Delete the entry at Opcode:Index on the method stack. Inserts * a null into the stack slot after the object is deleted. * ******************************************************************************/ void AcpiDsMethodDataDeleteValue ( UINT16 Opcode, UINT32 Index, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *Object; ACPI_FUNCTION_TRACE ("DsMethodDataDeleteValue"); /* Get the namespace node for the arg/local */ Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_VOID; } /* Get the associated object */ Object = AcpiNsGetAttachedObject (Node); /* * Undefine the Arg or Local by setting its descriptor * pointer to NULL. Locals/Args can contain both * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs */ Node->Object = NULL; if ((Object) && (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND)) { /* * There is a valid object. * Decrement the reference count by one to balance the * increment when the object was stored. */ AcpiUtRemoveReference (Object); } return_VOID; } /******************************************************************************* * * FUNCTION: AcpiDsStoreObjectToLocal * * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP * Index - Which localVar or argument to set * ObjDesc - Value to be stored * WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed * as the new value for the Arg or Local and the reference count * for ObjDesc is incremented. * ******************************************************************************/ ACPI_STATUS AcpiDsStoreObjectToLocal ( UINT16 Opcode, UINT32 Index, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *CurrentObjDesc; ACPI_FUNCTION_TRACE ("DsStoreObjectToLocal"); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%d Idx=%d Obj=%p\n", Opcode, Index, ObjDesc)); /* Parameter validation */ if (!ObjDesc) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Get the namespace node for the arg/local */ Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } CurrentObjDesc = AcpiNsGetAttachedObject (Node); if (CurrentObjDesc == ObjDesc) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", ObjDesc)); return_ACPI_STATUS (Status); } /* * If there is an object already in this slot, we either * have to delete it, or if this is an argument and there * is an object reference stored there, we have to do * an indirect store! */ if (CurrentObjDesc) { /* * Check for an indirect store if an argument * contains an object reference (stored as an Node). * We don't allow this automatic dereferencing for * locals, since a store to a local should overwrite * anything there, including an object reference. * * If both Arg0 and Local0 contain RefOf (Local4): * * Store (1, Arg0) - Causes indirect store to local4 * Store (1, Local0) - Stores 1 in local0, overwriting * the reference to local4 * Store (1, DeRefof (Local0)) - Causes indirect store to local4 * * Weird, but true. */ 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: %X\n", CurrentObjDesc->Common.Type)); return_ACPI_STATUS (AE_AML_INTERNAL); } /* * If we have a valid reference object that came from RefOf(), do the * indirect store */ - if ((CurrentObjDesc->Common.Type == INTERNAL_TYPE_REFERENCE) && + if ((CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && (CurrentObjDesc->Reference.Opcode == AML_REF_OF_OP)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Arg (%p) is an ObjRef(Node), storing in node %p\n", ObjDesc, CurrentObjDesc)); /* Detach an existing object from the referenced Node */ AcpiNsDetachObject (CurrentObjDesc->Reference.Object); /* * Store this object into the Node * (perform the indirect store) */ Status = AcpiNsAttachObject (CurrentObjDesc->Reference.Object, ObjDesc, ACPI_GET_OBJECT_TYPE (ObjDesc)); return_ACPI_STATUS (Status); } } /* * Delete the existing object * before storing the new one */ AcpiDsMethodDataDeleteValue (Opcode, Index, WalkState); } /* * Install the ObjStack descriptor (*ObjDesc) into * the descriptor for the Arg or Local. * Install the new object in the stack entry * (increments the object reference count by one) */ Status = AcpiDsMethodDataSetValue (Opcode, Index, ObjDesc, WalkState); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/dsobject.c b/sys/contrib/dev/acpica/dsobject.c index 569023cbe347..a81a830c572c 100644 --- a/sys/contrib/dev/acpica/dsobject.c +++ b/sys/contrib/dev/acpica/dsobject.c @@ -1,907 +1,907 @@ /****************************************************************************** * * Module Name: dsobject - Dispatcher object management routines - * $Revision: 108 $ + * $Revision: 110 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __DSOBJECT_C__ #include "acpi.h" #include "acparser.h" #include "amlcode.h" #include "acdispat.h" #include "acnamesp.h" #include "acinterp.h" #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsobject") #ifndef ACPI_NO_METHOD_EXECUTION /******************************************************************************* * * FUNCTION: AcpiDsInitOneObject * * PARAMETERS: ObjHandle - Node * Level - Current nesting level * Context - Points to a init info struct * ReturnValue - Not used * * RETURN: Status * * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object * within the namespace. * * Currently, the only objects that require initialization are: * 1) Methods * 2) Operation Regions * ******************************************************************************/ ACPI_STATUS AcpiDsInitOneObject ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue) { 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 * was just loaded */ if (((ACPI_NAMESPACE_NODE *) ObjHandle)->OwnerId != Info->TableDesc->TableId) { return (AE_OK); } Info->ObjectCount++; /* And even then, we are only interested in a few object types */ Type = AcpiNsGetType (ObjHandle); switch (Type) { case ACPI_TYPE_REGION: Status = AcpiDsInitializeRegion (ObjHandle); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %p [%4.4s] - Init failure, %s\n", ObjHandle, ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii, AcpiFormatException (Status))); } Info->OpRegionCount++; break; case ACPI_TYPE_METHOD: Info->MethodCount++; if (!(AcpiDbgLevel & ACPI_LV_INIT)) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, ".")); } /* * Set the execution data width (32 or 64) based upon the * revision number of the parent ACPI table. * TBD: This is really for possible future support of integer width * on a per-table basis. Currently, we just use a global for the width. */ if (Info->TableDesc->Pointer->Revision == 1) { ((ACPI_NAMESPACE_NODE *) ObjHandle)->Flags |= ANOBJ_DATA_WIDTH_32; } /* * Always parse methods to detect errors, we may delete * the parse tree below */ Status = AcpiDsParseMethod (ObjHandle); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n", ObjHandle, ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii, AcpiFormatException (Status))); /* This parse failed, but we will continue parsing more methods */ break; } /* * Delete the parse tree. We simple re-parse the method * for every execution since there isn't much overhead */ AcpiNsDeleteNamespaceSubtree (ObjHandle); AcpiNsDeleteNamespaceByOwner (((ACPI_NAMESPACE_NODE *) ObjHandle)->Object->Method.OwningId); break; case ACPI_TYPE_DEVICE: Info->DeviceCount++; break; default: break; } /* * We ignore errors from above, and always return OK, since * we don't want to abort the walk on a single error. */ return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiDsInitializeObjects * * PARAMETERS: TableDesc - Descriptor for parent ACPI table * StartNode - Root of subtree to be initialized. * * RETURN: Status * * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any * necessary initialization on the objects found therein * ******************************************************************************/ ACPI_STATUS AcpiDsInitializeObjects ( ACPI_TABLE_DESC *TableDesc, ACPI_NAMESPACE_NODE *StartNode) { ACPI_STATUS Status; ACPI_INIT_WALK_INFO Info; ACPI_FUNCTION_TRACE ("DsInitializeObjects"); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "**** Starting initialization of namespace objects ****\n")); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "Parsing Methods:")); Info.MethodCount = 0; Info.OpRegionCount = 0; Info.ObjectCount = 0; Info.DeviceCount = 0; Info.TableDesc = TableDesc; /* Walk entire namespace from the supplied root */ Status = AcpiWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX, AcpiDsInitOneObject, &Info, NULL); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "WalkNamespace failed, %s\n", AcpiFormatException (Status))); } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "\nTable [%4.4s] - %hd Objects with %hd Devices %hd Methods %hd Regions\n", TableDesc->Pointer->Signature, Info.ObjectCount, Info.DeviceCount, Info.MethodCount, Info.OpRegionCount)); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "%hd Methods, %hd Regions\n", Info.MethodCount, Info.OpRegionCount)); return_ACPI_STATUS (AE_OK); } /***************************************************************************** * * FUNCTION: AcpiDsBuildInternalObject * * PARAMETERS: WalkState - Current walk state * Op - Parser object to be translated * ObjDescPtr - Where the ACPI internal object is returned * * RETURN: Status * * DESCRIPTION: Translate a parser Op object to the equivalent namespace object * Simple objects are any objects other than a package object! * ****************************************************************************/ ACPI_STATUS AcpiDsBuildInternalObject ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT **ObjDescPtr) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("DsBuildInternalObject"); *ObjDescPtr = NULL; if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) { /* * This is an named object reference. If this name was * previously looked up in the namespace, it was stored in this op. * Otherwise, go ahead and look it up now */ if (!Op->Common.Node) { 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_NAMESPACE_NODE **) &(Op->Common.Node)); if (ACPI_FAILURE (Status)) { ACPI_REPORT_NSERROR (Op->Common.Value.String, Status); return_ACPI_STATUS (Status); } } } /* Create and init the internal ACPI object */ ObjDesc = AcpiUtCreateInternalObject ((AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Common.AmlOpcode, &ObjDesc); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } *ObjDescPtr = ObjDesc; return_ACPI_STATUS (AE_OK); } /***************************************************************************** * * FUNCTION: AcpiDsBuildInternalBufferObj * * PARAMETERS: WalkState - Current walk state * Op - Parser object to be translated * BufferLength - Length of the buffer * ObjDescPtr - Where the ACPI internal object is returned * * RETURN: Status * * DESCRIPTION: Translate a parser Op package object to the equivalent * namespace object * ****************************************************************************/ ACPI_STATUS AcpiDsBuildInternalBufferObj ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, UINT32 BufferLength, ACPI_OPERAND_OBJECT **ObjDescPtr) { ACPI_PARSE_OBJECT *Arg; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_PARSE_OBJECT *ByteList; UINT32 ByteListLength = 0; ACPI_FUNCTION_TRACE ("DsBuildInternalBufferObj"); ObjDesc = *ObjDescPtr; if (ObjDesc) { /* * We are evaluating a Named buffer object "Name (xxxx, Buffer)". * The buffer object already exists (from the NS node) */ } else { /* Create a new buffer object */ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); *ObjDescPtr = ObjDesc; if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } } /* * Second arg is the buffer data (optional) ByteList can be either * individual bytes or a string initializer. In either case, a * ByteList appears in the AML. */ Arg = Op->Common.Value.Arg; /* skip first arg */ ByteList = Arg->Named.Next; if (ByteList) { if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Expecting bytelist, got AML opcode %X in op %p\n", ByteList->Common.AmlOpcode, ByteList)); AcpiUtRemoveReference (ObjDesc); return (AE_TYPE); } ByteListLength = ByteList->Common.Value.Integer32; } /* * The buffer length (number of bytes) will be the larger of: * 1) The specified buffer length and * 2) The length of the initializer byte list */ ObjDesc->Buffer.Length = BufferLength; if (ByteListLength > BufferLength) { ObjDesc->Buffer.Length = ByteListLength; } /* Allocate the buffer */ if (ObjDesc->Buffer.Length == 0) { ObjDesc->Buffer.Pointer = NULL; ACPI_REPORT_WARNING (("Buffer created with zero length in AML\n")); return_ACPI_STATUS (AE_OK); } ObjDesc->Buffer.Pointer = ACPI_MEM_CALLOCATE ( ObjDesc->Buffer.Length); if (!ObjDesc->Buffer.Pointer) { AcpiUtDeleteObjectDesc (ObjDesc); return_ACPI_STATUS (AE_NO_MEMORY); } /* Initialize buffer from the ByteList (if present) */ if (ByteList) { ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Named.Data, ByteListLength); } ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; Op->Common.Node = (ACPI_NAMESPACE_NODE *) ObjDesc; return_ACPI_STATUS (AE_OK); } /***************************************************************************** * * FUNCTION: AcpiDsBuildInternalPackageObj * * PARAMETERS: WalkState - Current walk state * Op - Parser object to be translated * PackageLength - Number of elements in the package * ObjDescPtr - Where the ACPI internal object is returned * * RETURN: Status * * DESCRIPTION: Translate a parser Op package object to the equivalent * namespace object * ****************************************************************************/ ACPI_STATUS AcpiDsBuildInternalPackageObj ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, UINT32 PackageLength, ACPI_OPERAND_OBJECT **ObjDescPtr) { ACPI_PARSE_OBJECT *Arg; ACPI_PARSE_OBJECT *Parent; ACPI_OPERAND_OBJECT *ObjDesc = NULL; UINT32 PackageListLength; ACPI_STATUS Status = AE_OK; UINT32 i; ACPI_FUNCTION_TRACE ("DsBuildInternalPackageObj"); /* Find the parent of a possibly nested package */ Parent = Op->Common.Parent; while ((Parent->Common.AmlOpcode == AML_PACKAGE_OP) || (Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) { Parent = Parent->Common.Parent; } ObjDesc = *ObjDescPtr; if (ObjDesc) { /* * We are evaluating a Named package object "Name (xxxx, Package)". * Get the existing package object from the NS node */ } else { ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); *ObjDescPtr = ObjDesc; if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } ObjDesc->Package.Node = Parent->Common.Node; } ObjDesc->Package.Count = PackageLength; /* Count the number of items in the package list */ PackageListLength = 0; Arg = Op->Common.Value.Arg; Arg = Arg->Common.Next; while (Arg) { PackageListLength++; Arg = Arg->Common.Next; } /* * The package length (number of elements) will be the greater * of the specified length and the length of the initializer list */ if (PackageListLength > PackageLength) { ObjDesc->Package.Count = PackageListLength; } /* * Allocate the pointer array (array of pointers to the * individual objects). Add an extra pointer slot so * that the list is always null terminated. */ ObjDesc->Package.Elements = ACPI_MEM_CALLOCATE ( ((ACPI_SIZE) ObjDesc->Package.Count + 1) * sizeof (void *)); if (!ObjDesc->Package.Elements) { AcpiUtDeleteObjectDesc (ObjDesc); return_ACPI_STATUS (AE_NO_MEMORY); } /* * Now init the elements of the package */ i = 0; Arg = Op->Common.Value.Arg; Arg = Arg->Common.Next; while (Arg) { if (Arg->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) { /* Object (package or buffer) is already built */ ObjDesc->Package.Elements[i] = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node); } else { Status = AcpiDsBuildInternalObject (WalkState, Arg, &ObjDesc->Package.Elements[i]); } i++; Arg = Arg->Common.Next; } ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID; Op->Common.Node = (ACPI_NAMESPACE_NODE *) ObjDesc; return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiDsCreateNode * * PARAMETERS: WalkState - Current walk state * Node - NS Node to be initialized * Op - Parser object to be translated * * RETURN: Status * * DESCRIPTION: Create the object to be associated with a namespace node * ****************************************************************************/ ACPI_STATUS AcpiDsCreateNode ( ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE *Node, ACPI_PARSE_OBJECT *Op) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_TRACE_PTR ("DsCreateNode", Op); /* * Because of the execution pass through the non-control-method * parts of the table, we can arrive here twice. Only init * the named object node the first time through */ if (AcpiNsGetAttachedObject (Node)) { return_ACPI_STATUS (AE_OK); } if (!Op->Common.Value.Arg) { /* No arguments, there is nothing to do */ return_ACPI_STATUS (AE_OK); } /* Build an internal object for the argument(s) */ Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Re-type the object according to it's argument */ Node->Type = ACPI_GET_OBJECT_TYPE (ObjDesc); /* Attach obj to node */ Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type); /* Remove local reference to the object */ AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } #endif /* ACPI_NO_METHOD_EXECUTION */ /***************************************************************************** * * FUNCTION: AcpiDsInitObjectFromOp * * PARAMETERS: WalkState - Current walk state * Op - Parser op used to init the internal object * Opcode - AML opcode associated with the object * RetObjDesc - Namespace object to be initialized * * RETURN: Status * * DESCRIPTION: Initialize a namespace object from a parser Op and its * associated arguments. The namespace object is a more compact * representation of the Op and its arguments. * ****************************************************************************/ ACPI_STATUS AcpiDsInitObjectFromOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, UINT16 Opcode, ACPI_OPERAND_OBJECT **RetObjDesc) { const ACPI_OPCODE_INFO *OpInfo; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("DsInitObjectFromOp"); ObjDesc = *RetObjDesc; OpInfo = AcpiPsGetOpcodeInfo (Opcode); if (OpInfo->Class == AML_CLASS_UNKNOWN) { /* Unknown opcode */ return_ACPI_STATUS (AE_TYPE); } /* Perform per-object initialization */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_BUFFER: /* * Defer evaluation of Buffer TermArg operand */ ObjDesc->Buffer.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; ObjDesc->Buffer.AmlStart = Op->Named.Data; ObjDesc->Buffer.AmlLength = Op->Named.Length; break; case ACPI_TYPE_PACKAGE: /* * Defer evaluation of Package TermArg operand */ ObjDesc->Package.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; ObjDesc->Package.AmlStart = Op->Named.Data; ObjDesc->Package.AmlLength = Op->Named.Length; break; case ACPI_TYPE_INTEGER: switch (OpInfo->Type) { case AML_TYPE_CONSTANT: /* * 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.) */ ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT; switch (Opcode) { case AML_ZERO_OP: ObjDesc->Integer.Value = 0; break; case AML_ONE_OP: ObjDesc->Integer.Value = 1; break; case AML_ONES_OP: ObjDesc->Integer.Value = ACPI_INTEGER_MAX; /* Truncate value if we are executing from a 32-bit ACPI table */ #ifndef ACPI_NO_METHOD_EXECUTION AcpiExTruncateFor32bitTable (ObjDesc); #endif break; case AML_REVISION_OP: ObjDesc->Integer.Value = ACPI_CA_SUPPORT_LEVEL; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown constant opcode %X\n", Opcode)); Status = AE_AML_OPERAND_TYPE; break; } break; case AML_TYPE_LITERAL: ObjDesc->Integer.Value = Op->Common.Value.Integer; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", OpInfo->Type)); Status = AE_AML_OPERAND_TYPE; break; } break; case ACPI_TYPE_STRING: ObjDesc->String.Pointer = Op->Common.Value.String; - ObjDesc->String.Length = ACPI_STRLEN (Op->Common.Value.String); + ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Op->Common.Value.String); /* * The string is contained in the ACPI table, don't ever try * to delete it */ ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; break; case ACPI_TYPE_METHOD: break; - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: switch (OpInfo->Type) { case AML_TYPE_LOCAL_VARIABLE: /* Split the opcode into a base opcode + offset */ ObjDesc->Reference.Opcode = AML_LOCAL_OP; 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); #endif break; case AML_TYPE_METHOD_ARGUMENT: /* Split the opcode into a base opcode + offset */ ObjDesc->Reference.Opcode = AML_ARG_OP; ObjDesc->Reference.Offset = Opcode - AML_ARG_OP; break; default: /* Other literals, etc.. */ if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) { /* Node was saved in Op */ ObjDesc->Reference.Node = Op->Common.Node; } ObjDesc->Reference.Opcode = Opcode; break; } break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented data type: %X\n", ACPI_GET_OBJECT_TYPE (ObjDesc))); Status = AE_AML_OPERAND_TYPE; break; } return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/dsopcode.c b/sys/contrib/dev/acpica/dsopcode.c index 8be92c84cbc7..4262bb4c7113 100644 --- a/sys/contrib/dev/acpica/dsopcode.c +++ b/sys/contrib/dev/acpica/dsopcode.c @@ -1,1263 +1,1263 @@ /****************************************************************************** * * Module Name: dsopcode - Dispatcher Op Region support and handling of * "control" opcodes - * $Revision: 82 $ + * $Revision: 83 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __DSOPCODE_C__ #include "acpi.h" #include "acparser.h" #include "amlcode.h" #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" #include "acevents.h" #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsopcode") /***************************************************************************** * * FUNCTION: AcpiDsExecuteArguments * * PARAMETERS: Node - Parent NS node * AmlLength - Length of executable AML * AmlStart - Pointer to the AML * * RETURN: Status. * * DESCRIPTION: Late execution of region or field arguments * ****************************************************************************/ ACPI_STATUS AcpiDsExecuteArguments ( ACPI_NAMESPACE_NODE *Node, ACPI_NAMESPACE_NODE *ScopeNode, UINT32 AmlLength, UINT8 *AmlStart) { ACPI_STATUS Status; ACPI_PARSE_OBJECT *Op; ACPI_WALK_STATE *WalkState; ACPI_PARSE_OBJECT *Arg; ACPI_FUNCTION_TRACE ("AcpiDsExecuteArguments"); /* * Allocate a new parser op to be the root of the parsed tree */ Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); if (!Op) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Save the Node for use in AcpiPsParseAml */ Op->Common.Node = ScopeNode; /* Create and initialize a new parser state */ WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, NULL); if (!WalkState) { return_ACPI_STATUS (AE_NO_MEMORY); } Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, AmlLength, NULL, NULL, 1); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); return_ACPI_STATUS (Status); } WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP; /* Pass1: Parse the entire declaration */ Status = AcpiPsParseAml (WalkState); if (ACPI_FAILURE (Status)) { AcpiPsDeleteParseTree (Op); return_ACPI_STATUS (Status); } /* Get and init the Op created above */ Arg = Op->Common.Value.Arg; Op->Common.Node = Node; Arg->Common.Node = Node; AcpiPsDeleteParseTree (Op); /* Evaluate the address and length arguments for the Buffer Field */ Op = AcpiPsAllocOp (AML_INT_EVAL_SUBTREE_OP); if (!Op) { return_ACPI_STATUS (AE_NO_MEMORY); } Op->Common.Node = ScopeNode; /* Create and initialize a new parser state */ WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, NULL); if (!WalkState) { return_ACPI_STATUS (AE_NO_MEMORY); } Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart, AmlLength, NULL, NULL, 3); if (ACPI_FAILURE (Status)) { AcpiDsDeleteWalkState (WalkState); return_ACPI_STATUS (Status); } Status = AcpiPsParseAml (WalkState); AcpiPsDeleteParseTree (Op); return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiDsGetBufferFieldArguments * * PARAMETERS: ObjDesc - A valid BufferField object * * RETURN: Status. * * DESCRIPTION: Get BufferField Buffer and Index. This implements the late * evaluation of these field attributes. * ****************************************************************************/ ACPI_STATUS AcpiDsGetBufferFieldArguments ( ACPI_OPERAND_OBJECT *ObjDesc) { ACPI_OPERAND_OBJECT *ExtraDesc; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_FUNCTION_TRACE_PTR ("DsGetBufferFieldArguments", ObjDesc); if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) { return_ACPI_STATUS (AE_OK); } /* Get the AML pointer (method object) and BufferField node */ ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); Node = ObjDesc->BufferField.Node; ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (Node, " [Field]")); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BufferField JIT Init\n", Node->Name.Ascii)); /* Execute the AML code for the TermArg arguments */ Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiDsGetBufferArguments * * PARAMETERS: ObjDesc - A valid Bufferobject * * RETURN: Status. * * DESCRIPTION: Get Buffer length and initializer byte list. This implements * the late evaluation of these attributes. * ****************************************************************************/ ACPI_STATUS AcpiDsGetBufferArguments ( ACPI_OPERAND_OBJECT *ObjDesc) { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_FUNCTION_TRACE_PTR ("DsGetBufferArguments", ObjDesc); if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) { return_ACPI_STATUS (AE_OK); } /* Get the Buffer node */ Node = ObjDesc->Buffer.Node; if (!Node) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No pointer back to NS node in buffer %p\n", ObjDesc)); return_ACPI_STATUS (AE_AML_INTERNAL); } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer JIT Init\n")); /* Execute the AML code for the TermArg arguments */ Status = AcpiDsExecuteArguments (Node, Node, ObjDesc->Buffer.AmlLength, ObjDesc->Buffer.AmlStart); return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiDsGetPackageArguments * * PARAMETERS: ObjDesc - A valid Packageobject * * RETURN: Status. * * DESCRIPTION: Get Package length and initializer byte list. This implements * the late evaluation of these attributes. * ****************************************************************************/ ACPI_STATUS AcpiDsGetPackageArguments ( ACPI_OPERAND_OBJECT *ObjDesc) { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_FUNCTION_TRACE_PTR ("DsGetPackageArguments", ObjDesc); if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) { return_ACPI_STATUS (AE_OK); } /* Get the Package node */ Node = ObjDesc->Package.Node; if (!Node) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No pointer back to NS node in package %p\n", ObjDesc)); return_ACPI_STATUS (AE_AML_INTERNAL); } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package JIT Init\n")); /* Execute the AML code for the TermArg arguments */ Status = AcpiDsExecuteArguments (Node, Node, ObjDesc->Package.AmlLength, ObjDesc->Package.AmlStart); return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiDsGetRegionArguments * * PARAMETERS: ObjDesc - A valid region object * * RETURN: Status. * * DESCRIPTION: Get region address and length. This implements the late * evaluation of these region attributes. * ****************************************************************************/ ACPI_STATUS AcpiDsGetRegionArguments ( ACPI_OPERAND_OBJECT *ObjDesc) { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ExtraDesc; ACPI_FUNCTION_TRACE_PTR ("DsGetRegionArguments", ObjDesc); if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) { return_ACPI_STATUS (AE_OK); } ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc); if (!ExtraDesc) { return_ACPI_STATUS (AE_NOT_EXIST); } /* Get the Region node */ Node = ObjDesc->Region.Node; ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (Node, " [Operation Region]")); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] OpRegion Init at AML %p\n", Node->Name.Ascii, ExtraDesc->Extra.AmlStart)); Status = AcpiDsExecuteArguments (Node, AcpiNsGetParentNode (Node), ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart); return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiDsInitializeRegion * * PARAMETERS: Op - A valid region Op object * * RETURN: Status * * DESCRIPTION: Front end to EvInitializeRegion * ****************************************************************************/ ACPI_STATUS AcpiDsInitializeRegion ( ACPI_HANDLE ObjHandle) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; ObjDesc = AcpiNsGetAttachedObject (ObjHandle); /* Namespace is NOT locked */ Status = AcpiEvInitializeRegion (ObjDesc, FALSE); return (Status); } /***************************************************************************** * * FUNCTION: AcpiDsInitBufferField * * PARAMETERS: AmlOpcode - CreateXxxField * ObjDesc - BufferField object * BufferDesc - Host Buffer * OffsetDesc - Offset into buffer * Length - Length of field (CREATE_FIELD_OP only) * Result - Where to store the result * * RETURN: Status * * DESCRIPTION: Perform actual initialization of a buffer field * ****************************************************************************/ 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) { UINT32 Offset; UINT32 BitOffset; UINT32 BitCount; UINT8 FieldFlags; ACPI_STATUS Status; ACPI_FUNCTION_TRACE_PTR ("DsInitBufferField", ObjDesc); /* Host object must be a Buffer */ if (ACPI_GET_OBJECT_TYPE (BufferDesc) != ACPI_TYPE_BUFFER) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Target of Create Field is not a Buffer object - %s\n", AcpiUtGetObjectTypeName (BufferDesc))); Status = AE_AML_OPERAND_TYPE; goto Cleanup; } /* * The last parameter to all of these opcodes (ResultDesc) started * out as a NameString, and should therefore now be a NS node * after resolution in AcpiExResolveOperands(). */ if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) destination must be a NS Node\n", AcpiPsGetOpcodeName (AmlOpcode))); Status = AE_AML_OPERAND_TYPE; goto Cleanup; } Offset = (UINT32) OffsetDesc->Integer.Value; /* * Setup the Bit offsets and counts, according to the opcode */ switch (AmlOpcode) { case AML_CREATE_FIELD_OP: /* Offset is in bits, count is in bits */ BitOffset = Offset; BitCount = (UINT32) LengthDesc->Integer.Value; FieldFlags = AML_FIELD_ACCESS_BYTE; break; case AML_CREATE_BIT_FIELD_OP: /* Offset is in bits, Field is one bit */ BitOffset = Offset; BitCount = 1; FieldFlags = AML_FIELD_ACCESS_BYTE; break; case AML_CREATE_BYTE_FIELD_OP: /* Offset is in bytes, field is one byte */ BitOffset = 8 * Offset; BitCount = 8; FieldFlags = AML_FIELD_ACCESS_BYTE; break; case AML_CREATE_WORD_FIELD_OP: /* Offset is in bytes, field is one word */ BitOffset = 8 * Offset; BitCount = 16; FieldFlags = AML_FIELD_ACCESS_WORD; break; case AML_CREATE_DWORD_FIELD_OP: /* Offset is in bytes, field is one dword */ BitOffset = 8 * Offset; BitCount = 32; FieldFlags = AML_FIELD_ACCESS_DWORD; break; case AML_CREATE_QWORD_FIELD_OP: /* Offset is in bytes, field is one qword */ BitOffset = 8 * Offset; BitCount = 64; FieldFlags = AML_FIELD_ACCESS_QWORD; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown field creation opcode %02x\n", AmlOpcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } /* Entire field must fit within the current length of the buffer */ if ((BitOffset + BitCount) > (8 * (UINT32) BufferDesc->Buffer.Length)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Field size %d exceeds Buffer size %d (bits)\n", BitOffset + BitCount, 8 * (UINT32) BufferDesc->Buffer.Length)); Status = AE_AML_BUFFER_LIMIT; goto Cleanup; } /* * 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) */ Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0, BitOffset, BitCount); if (ACPI_FAILURE (Status)) { goto Cleanup; } ObjDesc->BufferField.BufferObj = BufferDesc; /* Reference count for BufferDesc inherits ObjDesc count */ BufferDesc->Common.ReferenceCount = (UINT16) (BufferDesc->Common.ReferenceCount + ObjDesc->Common.ReferenceCount); Cleanup: /* Always delete the operands */ AcpiUtRemoveReference (OffsetDesc); AcpiUtRemoveReference (BufferDesc); if (AmlOpcode == AML_CREATE_FIELD_OP) { AcpiUtRemoveReference (LengthDesc); } /* On failure, delete the result descriptor */ if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ResultDesc); /* Result descriptor */ } else { /* Now the address and length are valid for this BufferField */ ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID; } return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiDsEvalBufferFieldOperands * * PARAMETERS: WalkState - Current walk * Op - A valid BufferField Op object * * RETURN: Status * * DESCRIPTION: Get BufferField Buffer and Index * Called from AcpiDsExecEndOp during BufferField parse tree walk * ****************************************************************************/ ACPI_STATUS AcpiDsEvalBufferFieldOperands ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; ACPI_PARSE_OBJECT *NextOp; ACPI_FUNCTION_TRACE_PTR ("DsEvalBufferFieldOperands", Op); /* * This is where we evaluate the address and length fields of the * CreateXxxField declaration */ Node = Op->Common.Node; /* NextOp points to the op that holds the Buffer */ NextOp = Op->Common.Value.Arg; /* Evaluate/create the address and length operands */ Status = AcpiDsCreateOperands (WalkState, NextOp); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { return_ACPI_STATUS (AE_NOT_EXIST); } /* Resolve the operands */ Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState->NumOperands, "after AcpiExResolveOperands"); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(%s) bad operand(s) (%X)\n", AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status)); return_ACPI_STATUS (Status); } /* Initialize the Buffer Field */ if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) { /* NOTE: Slightly different operands for this opcode */ Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, WalkState->Operands[0], WalkState->Operands[1], WalkState->Operands[2], WalkState->Operands[3]); } else { /* All other, CreateXxxField opcodes */ Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, WalkState->Operands[0], WalkState->Operands[1], NULL, WalkState->Operands[2]); } return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiDsEvalRegionOperands * * PARAMETERS: WalkState - Current walk * Op - A valid region Op object * * RETURN: Status * * DESCRIPTION: Get region address and length * Called from AcpiDsExecEndOp during OpRegion parse tree walk * ****************************************************************************/ ACPI_STATUS AcpiDsEvalRegionOperands ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *OperandDesc; ACPI_NAMESPACE_NODE *Node; ACPI_PARSE_OBJECT *NextOp; ACPI_FUNCTION_TRACE_PTR ("DsEvalRegionOperands", Op); /* * This is where we evaluate the address and length fields of the OpRegion declaration */ Node = Op->Common.Node; /* NextOp points to the op that holds the SpaceID */ NextOp = Op->Common.Value.Arg; /* NextOp points to address op */ NextOp = NextOp->Common.Next; /* Evaluate/create the address and length operands */ Status = AcpiDsCreateOperands (WalkState, NextOp); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Resolve the length and address operands to numbers */ Status = AcpiExResolveOperands (Op->Common.AmlOpcode, ACPI_WALK_OPERANDS, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, ACPI_IMODE_EXECUTE, AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 1, "after AcpiExResolveOperands"); ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { return_ACPI_STATUS (AE_NOT_EXIST); } /* * Get the length operand and save it * (at Top of stack) */ OperandDesc = WalkState->Operands[WalkState->NumOperands - 1]; ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value; AcpiUtRemoveReference (OperandDesc); /* * Get the address and save it * (at top of stack - 1) */ OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; 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", ObjDesc, ACPI_HIDWORD (ObjDesc->Region.Address), ACPI_LODWORD (ObjDesc->Region.Address), ObjDesc->Region.Length)); /* Now the address and length are valid for this opregion */ ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiDsEvalDataObjectOperands * * PARAMETERS: WalkState - Current walk * Op - A valid DataObject Op object * ObjDesc - DataObject * * RETURN: Status * * DESCRIPTION: Get the operands and complete the following data objec types: * Buffer * Package * ****************************************************************************/ ACPI_STATUS AcpiDsEvalDataObjectOperands ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT *ObjDesc) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ArgDesc; UINT32 Length; ACPI_FUNCTION_TRACE ("DsEvalDataObjectOperands"); /* The first operand (for all of these data objects) is the length */ Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiExResolveOperands (WalkState->Opcode, &(WalkState->Operands [WalkState->NumOperands -1]), WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Extract length operand */ ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; Length = (UINT32) ArgDesc->Integer.Value; /* Cleanup for length operand */ Status = AcpiDsObjStackPop (1, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } AcpiUtRemoveReference (ArgDesc); /* * Create the actual data object */ switch (Op->Common.AmlOpcode) { case AML_BUFFER_OP: Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc); break; case AML_PACKAGE_OP: case AML_VAR_PACKAGE_OP: Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc); break; default: return_ACPI_STATUS (AE_AML_BAD_OPCODE); } if (ACPI_SUCCESS (Status)) { /* * 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. */ if ((!Op->Common.Parent) || ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) && (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) && (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP))) { WalkState->ResultObj = ObjDesc; } } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiDsExecBeginControlOp * * PARAMETERS: WalkList - The list that owns the walk stack * Op - The control Op * * RETURN: Status * * DESCRIPTION: Handles all control ops encountered during control method * execution. * ******************************************************************************/ ACPI_STATUS AcpiDsExecBeginControlOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) { ACPI_STATUS Status = AE_OK; ACPI_GENERIC_STATE *ControlState; ACPI_FUNCTION_NAME ("DsExecBeginControlOp"); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n", Op, Op->Common.AmlOpcode, WalkState)); switch (Op->Common.AmlOpcode) { case AML_IF_OP: case AML_WHILE_OP: /* * IF/WHILE: Create a new control state to manage these * constructs. We need to manage these as a stack, in order * to handle nesting. */ ControlState = AcpiUtCreateControlState (); if (!ControlState) { Status = AE_NO_MEMORY; break; } /* * Save a pointer to the predicate for multiple executions * of a loop */ ControlState->Control.AmlPredicateStart = WalkState->ParserState.Aml - 1; ControlState->Control.PackageEnd = WalkState->ParserState.PkgEnd; ControlState->Control.Opcode = Op->Common.AmlOpcode; /* Push the control state on this walk's control stack */ AcpiUtPushGenericState (&WalkState->ControlState, ControlState); break; case AML_ELSE_OP: /* Predicate is in the state object */ /* If predicate is true, the IF was executed, ignore ELSE part */ if (WalkState->LastPredicate) { Status = AE_CTRL_TRUE; } break; case AML_RETURN_OP: break; default: break; } return (Status); } /******************************************************************************* * * FUNCTION: AcpiDsExecEndControlOp * * PARAMETERS: WalkList - The list that owns the walk stack * Op - The control Op * * RETURN: Status * * DESCRIPTION: Handles all control ops encountered during control method * execution. * ******************************************************************************/ ACPI_STATUS AcpiDsExecEndControlOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op) { ACPI_STATUS Status = AE_OK; ACPI_GENERIC_STATE *ControlState; ACPI_FUNCTION_NAME ("DsExecEndControlOp"); switch (Op->Common.AmlOpcode) { case AML_IF_OP: ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op)); /* * Save the result of the predicate in case there is an * ELSE to come */ WalkState->LastPredicate = (BOOLEAN) WalkState->ControlState->Common.Value; /* * Pop the control state that was created at the start * of the IF and free it */ ControlState = AcpiUtPopGenericState (&WalkState->ControlState); AcpiUtDeleteGenericState (ControlState); break; case AML_ELSE_OP: break; case AML_WHILE_OP: ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op)); if (WalkState->ControlState->Common.Value) { /* Predicate was true, go back and evaluate it again! */ Status = AE_CTRL_PENDING; } ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] termination! Op=%p\n", Op)); /* Pop this control state and free it */ ControlState = AcpiUtPopGenericState (&WalkState->ControlState); WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart; AcpiUtDeleteGenericState (ControlState); break; case AML_RETURN_OP: ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg)); /* * One optional operand -- the return value * It can be either an immediate operand or a result that * has been bubbled up the tree */ if (Op->Common.Value.Arg) { /* Return statement has an immediate operand */ Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); if (ACPI_FAILURE (Status)) { return (Status); } /* * If value being returned is a Reference (such as * an arg or local), resolve it now because it may * cease to exist at the end of the method. */ Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState); if (ACPI_FAILURE (Status)) { return (Status); } /* * Get the return value and save as the last result * value. This is the only place where WalkState->ReturnDesc * is set to anything other than zero! */ WalkState->ReturnDesc = WalkState->Operands[0]; } else if ((WalkState->Results) && (WalkState->Results->Results.NumResults > 0)) { /* * The return value has come from a previous calculation. * * If value being returned is a Reference (such as * an arg or local), resolve it now because it may * cease to exist at the end of the method. * * Allow references created by the Index operator to return unchanged. */ if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) == ACPI_DESC_TYPE_OPERAND) && - (ACPI_GET_OBJECT_TYPE (WalkState->Results->Results.ObjDesc [0]) == INTERNAL_TYPE_REFERENCE) && + (ACPI_GET_OBJECT_TYPE (WalkState->Results->Results.ObjDesc [0]) == ACPI_TYPE_LOCAL_REFERENCE) && ((WalkState->Results->Results.ObjDesc [0])->Reference.Opcode != AML_INDEX_OP)) { Status = AcpiExResolveToValue (&WalkState->Results->Results.ObjDesc [0], WalkState); if (ACPI_FAILURE (Status)) { return (Status); } } WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0]; } else { /* No return operand */ if (WalkState->NumOperands) { AcpiUtRemoveReference (WalkState->Operands [0]); } WalkState->Operands [0] = NULL; WalkState->NumOperands = 0; WalkState->ReturnDesc = NULL; } ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Completed RETURN_OP State=%p, RetVal=%p\n", WalkState, WalkState->ReturnDesc)); /* End the control method execution right now */ Status = AE_CTRL_TERMINATE; break; case AML_NOOP_OP: /* Just do nothing! */ break; case AML_BREAK_POINT_OP: /* Call up to the OS service layer to handle this */ Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT, "Executed AML Breakpoint opcode"); /* If and when it returns, all done. */ break; case AML_BREAK_OP: case AML_CONTINUE_OP: /* ACPI 2.0 */ /* Pop and delete control states until we find a while */ while (WalkState->ControlState && (WalkState->ControlState->Control.Opcode != AML_WHILE_OP)) { ControlState = AcpiUtPopGenericState (&WalkState->ControlState); AcpiUtDeleteGenericState (ControlState); } /* No while found? */ if (!WalkState->ControlState) { return (AE_AML_NO_WHILE); } /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */ WalkState->AmlLastWhile = WalkState->ControlState->Control.PackageEnd; /* Return status depending on opcode */ if (Op->Common.AmlOpcode == AML_BREAK_OP) { Status = AE_CTRL_BREAK; } else { Status = AE_CTRL_CONTINUE; } break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown control opcode=%X Op=%p\n", Op->Common.AmlOpcode, Op)); Status = AE_AML_BAD_OPCODE; break; } return (Status); } diff --git a/sys/contrib/dev/acpica/dsutils.c b/sys/contrib/dev/acpica/dsutils.c index 17cd17a32247..4c553d3e3c4d 100644 --- a/sys/contrib/dev/acpica/dsutils.c +++ b/sys/contrib/dev/acpica/dsutils.c @@ -1,680 +1,720 @@ /******************************************************************************* * * Module Name: dsutils - Dispatcher utilities - * $Revision: 95 $ + * $Revision: 97 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __DSUTILS_C__ #include "acpi.h" #include "acparser.h" #include "amlcode.h" #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" #include "acdebug.h" #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsutils") #ifndef ACPI_NO_METHOD_EXECUTION /******************************************************************************* * * FUNCTION: AcpiDsIsResultUsed * * PARAMETERS: Op * ResultObj * WalkState * * RETURN: Status * * DESCRIPTION: Check if a result object will be used by the parent * ******************************************************************************/ BOOLEAN AcpiDsIsResultUsed ( ACPI_PARSE_OBJECT *Op, ACPI_WALK_STATE *WalkState) { const ACPI_OPCODE_INFO *ParentInfo; ACPI_FUNCTION_TRACE_PTR ("DsIsResultUsed", Op); /* Must have both an Op and a Result Object */ if (!Op) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Op\n")); return_VALUE (TRUE); } /* * If there is no parent, the result can't possibly be used! * (An executing method typically has no parent, since each * method is parsed separately) However, a method that is * invoked from another method has a parent. */ if (!Op->Common.Parent) { return_VALUE (FALSE); } /* * Get info on the parent. The root Op is AML_SCOPE */ 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); } /* * Decide what to do with the result based on the parent. If * the parent opcode will not use the result, delete the object. * Otherwise leave it as is, it will be deleted when it is used * as an operand later. */ switch (ParentInfo->Class) { case AML_CLASS_CONTROL: switch (Op->Common.Parent->Common.AmlOpcode) { case AML_RETURN_OP: /* Never delete the return value associated with a return opcode */ goto ResultUsed; case AML_IF_OP: case AML_WHILE_OP: /* * If we are executing the predicate AND this is the predicate op, * we will use the return value */ if ((WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) && (WalkState->ControlState->Control.PredicateOp == Op)) { goto ResultUsed; } break; default: /* Ignore other control opcodes */ break; } /* The general control opcode returns no result */ goto ResultNotUsed; case AML_CLASS_CREATE: /* * These opcodes allow TermArg(s) as operands and therefore * the operands can be method calls. The result is used. */ goto ResultUsed; case AML_CLASS_NAMED_OBJECT: if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) || (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) || (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) || (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) || (Op->Common.Parent->Common.AmlOpcode == AML_INT_EVAL_SUBTREE_OP)) { /* * These opcodes allow TermArg(s) as operands and therefore * the operands can be method calls. The result is used. */ goto ResultUsed; } goto ResultNotUsed; default: /* * In all other cases. the parent will actually use the return * object, so keep it. */ goto ResultUsed; } 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)); return_VALUE (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)); return_VALUE (FALSE); } /******************************************************************************* * * FUNCTION: AcpiDsDeleteResultIfNotUsed * * PARAMETERS: Op * ResultObj * WalkState * * RETURN: Status * * DESCRIPTION: Used after interpretation of an opcode. If there is an internal * result descriptor, check if the parent opcode will actually use * this result. If not, delete the result now so that it will * not become orphaned. * ******************************************************************************/ void AcpiDsDeleteResultIfNotUsed ( ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT *ResultObj, ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; ACPI_FUNCTION_TRACE_PTR ("DsDeleteResultIfNotUsed", ResultObj); if (!Op) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Op\n")); return_VOID; } if (!ResultObj) { return_VOID; } if (!AcpiDsIsResultUsed (Op, WalkState)) { /* * Must pop the result stack (ObjDesc should be equal to ResultObj) */ Status = AcpiDsResultPop (&ObjDesc, WalkState); if (ACPI_SUCCESS (Status)) { AcpiUtRemoveReference (ResultObj); } } return_VOID; } /******************************************************************************* * * FUNCTION: AcpiDsResolveOperands * * PARAMETERS: WalkState - Current walk state with operands on stack * * RETURN: Status * * DESCRIPTION: Resolve all operands to their values. Used to prepare * arguments to a control method invocation (a call from one * method to another.) * ******************************************************************************/ ACPI_STATUS AcpiDsResolveOperands ( ACPI_WALK_STATE *WalkState) { UINT32 i; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE_PTR ("DsResolveOperands", WalkState); /* * Attempt to resolve each of the valid operands * Method arguments are passed by value, not by reference */ for (i = 0; i < WalkState->NumOperands; i++) { Status = AcpiExResolveToValue (&WalkState->Operands[i], WalkState); if (ACPI_FAILURE (Status)) { break; } } return_ACPI_STATUS (Status); } + + +/******************************************************************************* + * + * FUNCTION: AcpiDsClearOperands + * + * PARAMETERS: WalkState - Current walk state with operands on stack + * + * RETURN: None + * + * DESCRIPTION: Clear all operands on the current walk state operand stack. + * + ******************************************************************************/ + +void +AcpiDsClearOperands ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR ("AcpiDsClearOperands", WalkState); + + + /* + * Remove a reference on each operand on the stack + */ + for (i = 0; i < WalkState->NumOperands; i++) + { + /* + * Remove a reference to all operands, including both + * "Arguments" and "Targets". + */ + AcpiUtRemoveReference (WalkState->Operands[i]); + WalkState->Operands[i] = NULL; + } + + WalkState->NumOperands = 0; + return_VOID; +} #endif /******************************************************************************* * * FUNCTION: AcpiDsCreateOperand * * PARAMETERS: WalkState * Arg * * RETURN: Status * * DESCRIPTION: Translate a parse tree object that is an argument to an AML * opcode to the equivalent interpreter object. This may include * looking up a name or entering a new name into the internal * namespace. * ******************************************************************************/ ACPI_STATUS AcpiDsCreateOperand ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Arg, UINT32 ArgIndex) { ACPI_STATUS Status = AE_OK; NATIVE_CHAR *NameString; UINT32 NameLength; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_PARSE_OBJECT *ParentOp; UINT16 Opcode; ACPI_INTERPRETER_MODE InterpreterMode; const ACPI_OPCODE_INFO *OpInfo; ACPI_FUNCTION_TRACE_PTR ("DsCreateOperand", Arg); /* A valid name must be looked up in the namespace */ if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && (Arg->Common.Value.String)) { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", Arg)); /* Get the entire name string from the AML stream */ Status = AcpiExGetNameString (ACPI_TYPE_ANY, Arg->Common.Value.Buffer, &NameString, &NameLength); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * All prefixes have been handled, and the name is * in NameString */ /* * Differentiate between a namespace "create" operation * versus a "lookup" operation (IMODE_LOAD_PASS2 vs. * IMODE_EXECUTE) in order to support the creation of * namespace objects during the execution of control methods. */ ParentOp = Arg->Common.Parent; OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode); if ((OpInfo->Flags & AML_NSNODE) && (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) && (ParentOp->Common.AmlOpcode != AML_REGION_OP) && (ParentOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP)) { /* Enter name into namespace if not found */ InterpreterMode = ACPI_IMODE_LOAD_PASS2; } else { /* Return a failure if name not found */ InterpreterMode = ACPI_IMODE_EXECUTE; } 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)); /* * The only case where we pass through (ignore) a NOT_FOUND * error is for the CondRefOf opcode. */ if (Status == AE_NOT_FOUND) { if (ParentOp->Common.AmlOpcode == AML_COND_REF_OF_OP) { /* * For the Conditional Reference op, it's OK if * the name is not found; We just need a way to * indicate this to the interpreter, set the * object to the root */ ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, AcpiGbl_RootNode); Status = AE_OK; } else { /* * We just plain didn't find it -- which is a * very serious error at this point */ Status = AE_AML_NAME_NOT_FOUND; } } if (ACPI_FAILURE (Status)) { ACPI_REPORT_NSERROR (NameString, Status); } /* Free the namestring created above */ ACPI_MEM_FREE (NameString); /* Check status from the lookup */ if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Put the resulting object onto the current object stack */ Status = AcpiDsObjStackPush (ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); } else { /* Check for null name case */ if (Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) { /* * If the name is null, this means that this is an * optional result parameter that was not specified * in the original ASL. Create a Zero Constant for a * placeholder. (Store to a constant is a Noop.) */ Opcode = AML_ZERO_OP; /* Has no arguments! */ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Null namepath: Arg=%p\n", Arg)); } else { Opcode = Arg->Common.AmlOpcode; } /* Get the object type of the argument */ OpInfo = AcpiPsGetOpcodeInfo (Opcode); - if (OpInfo->ObjectType == INTERNAL_TYPE_INVALID) + if (OpInfo->ObjectType == ACPI_TYPE_INVALID) { return_ACPI_STATUS (AE_NOT_IMPLEMENTED); } if (OpInfo->Flags & AML_HAS_RETVAL) { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Argument previously created, already stacked \n")); ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject ( WalkState->Operands [WalkState->NumOperands - 1], WalkState)); /* * Use value that was already previously returned * by the evaluation of this argument */ Status = AcpiDsResultPopFromBottom (&ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { /* * Only error is underflow, and this indicates * a missing or null operand! */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Missing or null operand, %s\n", AcpiFormatException (Status))); return_ACPI_STATUS (Status); } } else { /* Create an ACPI_INTERNAL_OBJECT for the argument */ ObjDesc = AcpiUtCreateInternalObject (OpInfo->ObjectType); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Initialize the new object */ Status = AcpiDsInitObjectFromOp (WalkState, Arg, Opcode, &ObjDesc); if (ACPI_FAILURE (Status)) { AcpiUtDeleteObjectDesc (ObjDesc); return_ACPI_STATUS (Status); } } /* Put the operand object on the object stack */ Status = AcpiDsObjStackPush (ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); } return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiDsCreateOperands * * PARAMETERS: FirstArg - First argument of a parser argument tree * * RETURN: Status * * DESCRIPTION: Convert an operator's arguments from a parse tree format to * namespace objects and place those argument object on the object * stack in preparation for evaluation by the interpreter. * ******************************************************************************/ ACPI_STATUS AcpiDsCreateOperands ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *FirstArg) { ACPI_STATUS Status = AE_OK; ACPI_PARSE_OBJECT *Arg; UINT32 ArgCount = 0; ACPI_FUNCTION_TRACE_PTR ("DsCreateOperands", FirstArg); /* For all arguments in the list... */ Arg = FirstArg; while (Arg) { Status = AcpiDsCreateOperand (WalkState, Arg, ArgCount); if (ACPI_FAILURE (Status)) { goto Cleanup; } ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n", ArgCount, Arg, FirstArg)); /* Move on to next argument, if any */ Arg = Arg->Common.Next; ArgCount++; } return_ACPI_STATUS (Status); Cleanup: /* * We must undo everything done above; meaning that we must * pop everything off of the operand stack and delete those * objects */ (void) AcpiDsObjStackPopAndDelete (ArgCount, WalkState); ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While creating Arg %d - %s\n", (ArgCount + 1), AcpiFormatException (Status))); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/dswexec.c b/sys/contrib/dev/acpica/dswexec.c index 316442bb39c8..f90dd0856926 100644 --- a/sys/contrib/dev/acpica/dswexec.c +++ b/sys/contrib/dev/acpica/dswexec.c @@ -1,779 +1,772 @@ /****************************************************************************** * * Module Name: dswexec - Dispatcher method execution callbacks; * dispatch to interpreter. - * $Revision: 95 $ + * $Revision: 96 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __DSWEXEC_C__ #include "acpi.h" #include "acparser.h" #include "amlcode.h" #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" #include "acdebug.h" #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dswexec") /* * Dispatch table for opcode classes */ static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = { AcpiExOpcode_1A_0T_0R, AcpiExOpcode_1A_0T_1R, AcpiExOpcode_1A_1T_0R, AcpiExOpcode_1A_1T_1R, AcpiExOpcode_2A_0T_0R, AcpiExOpcode_2A_0T_1R, AcpiExOpcode_2A_1T_1R, AcpiExOpcode_2A_2T_1R, AcpiExOpcode_3A_0T_0R, AcpiExOpcode_3A_1T_1R, AcpiExOpcode_6A_0T_1R}; /***************************************************************************** * * FUNCTION: AcpiDsGetPredicateValue * * PARAMETERS: WalkState - Current state of the parse tree walk * * RETURN: Status * * DESCRIPTION: Get the result of a predicate evaluation * ****************************************************************************/ ACPI_STATUS AcpiDsGetPredicateValue ( ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ResultObj) { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_TRACE_PTR ("DsGetPredicateValue", WalkState); WalkState->ControlState->Common.State = 0; if (ResultObj) { Status = AcpiDsResultPop (&ObjDesc, WalkState); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get result from predicate evaluation, %s\n", AcpiFormatException (Status))); return_ACPI_STATUS (Status); } } else { Status = AcpiDsCreateOperand (WalkState, WalkState->Op, 0); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } ObjDesc = WalkState->Operands [0]; } if (!ObjDesc) { 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 */ if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad predicate (not a number) ObjDesc=%p State=%p Type=%X\n", ObjDesc, WalkState, ACPI_GET_OBJECT_TYPE (ObjDesc))); Status = AE_AML_OPERAND_TYPE; goto Cleanup; } /* Truncate the predicate to 32-bits if necessary */ AcpiExTruncateFor32bitTable (ObjDesc); /* * Save the result of the predicate evaluation on * the control stack */ if (ObjDesc->Integer.Value) { WalkState->ControlState->Common.Value = TRUE; } else { /* * Predicate is FALSE, we will just toss the * rest of the package */ WalkState->ControlState->Common.Value = FALSE; Status = AE_CTRL_FALSE; } Cleanup: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n", WalkState->ControlState->Common.Value, WalkState->Op)); /* Break to debugger to display result */ ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (ObjDesc, WalkState)); /* * Delete the predicate result object (we know that * we don't need it anymore) */ AcpiUtRemoveReference (ObjDesc); WalkState->ControlState->Common.State = ACPI_CONTROL_NORMAL; return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiDsExecBeginOp * * PARAMETERS: WalkState - Current state of the parse tree walk * OutOp - Return op if a new one is created * * RETURN: Status * * DESCRIPTION: Descending callback used during the execution of control * methods. This is where most operators and operands are * dispatched to the interpreter. * ****************************************************************************/ ACPI_STATUS AcpiDsExecBeginOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp) { ACPI_PARSE_OBJECT *Op; ACPI_STATUS Status = AE_OK; UINT32 OpcodeClass; ACPI_FUNCTION_TRACE_PTR ("DsExecBeginOp", WalkState); Op = WalkState->Op; if (!Op) { Status = AcpiDsLoad2BeginOp (WalkState, OutOp); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Op = *OutOp; WalkState->Op = Op; WalkState->Opcode = Op->Common.AmlOpcode; WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType)) { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op)); Status = AcpiDsScopeStackPop (WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } } if (Op == WalkState->Origin) { if (OutOp) { *OutOp = Op; } return_ACPI_STATUS (AE_OK); } /* * If the previous opcode was a conditional, this opcode * must be the beginning of the associated predicate. * Save this knowledge in the current scope descriptor */ if ((WalkState->ControlState) && (WalkState->ControlState->Common.State == ACPI_CONTROL_CONDITIONAL_EXECUTING)) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n", Op, WalkState)); WalkState->ControlState->Common.State = ACPI_CONTROL_PREDICATE_EXECUTING; /* Save start of predicate */ WalkState->ControlState->Control.PredicateOp = Op; } OpcodeClass = WalkState->OpInfo->Class; /* We want to send namepaths to the load code */ if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) { OpcodeClass = AML_CLASS_NAMED_OBJECT; } /* * Handle the opcode based upon the opcode type */ switch (OpcodeClass) { case AML_CLASS_CONTROL: Status = AcpiDsResultStackPush (WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiDsExecBeginControlOp (WalkState, Op); break; case AML_CLASS_NAMED_OBJECT: 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. */ Status = AcpiDsLoad2BeginOp (WalkState, NULL); } if (Op->Common.AmlOpcode == AML_REGION_OP) { Status = AcpiDsResultStackPush (WalkState); } break; case AML_CLASS_EXECUTE: case AML_CLASS_CREATE: /* most operators with arguments */ /* Start a new result/operand state */ Status = AcpiDsResultStackPush (WalkState); break; default: break; } /* Nothing to do here during method execution */ return_ACPI_STATUS (Status); } /***************************************************************************** * * 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 * * DESCRIPTION: Ascending callback used during the execution of control * methods. The only thing we really need to do here is to * notice the beginning of IF, ELSE, and WHILE blocks. * ****************************************************************************/ ACPI_STATUS AcpiDsExecEndOp ( ACPI_WALK_STATE *WalkState) { ACPI_PARSE_OBJECT *Op; ACPI_STATUS Status = AE_OK; UINT32 OpType; UINT32 OpClass; ACPI_PARSE_OBJECT *NextOp; ACPI_PARSE_OBJECT *FirstArg; - UINT32 i; ACPI_FUNCTION_TRACE_PTR ("DsExecEndOp", WalkState); Op = WalkState->Op; OpType = WalkState->OpInfo->Type; OpClass = WalkState->OpInfo->Class; if (OpClass == AML_CLASS_UNKNOWN) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode %X\n", Op->Common.AmlOpcode)); return_ACPI_STATUS (AE_NOT_IMPLEMENTED); } FirstArg = Op->Common.Value.Arg; /* Init the walk state */ WalkState->NumOperands = 0; WalkState->ReturnDesc = NULL; WalkState->ResultObj = NULL; /* Call debugger for single step support (DEBUG build only) */ ACPI_DEBUGGER_EXEC (Status = AcpiDbSingleStep (WalkState, Op, OpClass)); ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (Status)) {return_ACPI_STATUS (Status);}); /* Decode the Opcode Class */ switch (OpClass) { case AML_CLASS_ARGUMENT: /* constants, literals, etc. -- do nothing */ break; case AML_CLASS_EXECUTE: /* most operators with arguments */ /* Build resolved operand stack */ Status = AcpiDsCreateOperands (WalkState, FirstArg); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Done with this result state (Now that operand stack is built) */ Status = AcpiDsResultStackPop (WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Resolve all operands */ 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"); /* * Dispatch the request to the appropriate interpreter handler * routine. There is one routine per opcode "type" based upon the * number of opcode arguments and return type. */ Status = AcpiGbl_OpTypeDispatch [OpType] (WalkState); } else { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "[%s]: Could not resolve operands, %s\n", AcpiPsGetOpcodeName (WalkState->Opcode), AcpiFormatException (Status))); } /* Always delete the argument objects and clear the operand stack */ - for (i = 0; i < WalkState->NumOperands; i++) - { - /* - * Remove a reference to all operands, including both - * "Arguments" and "Targets". - */ - AcpiUtRemoveReference (WalkState->Operands[i]); - WalkState->Operands[i] = NULL; - } - WalkState->NumOperands = 0; + AcpiDsClearOperands (WalkState); /* * If a result object was returned from above, push it on the * current result stack */ if (ACPI_SUCCESS (Status) && WalkState->ResultObj) { Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); } break; default: switch (OpType) { case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */ /* 1 Operand, 0 ExternalResult, 0 InternalResult */ Status = AcpiDsExecEndControlOp (WalkState, Op); if (ACPI_FAILURE (Status)) { break; } Status = AcpiDsResultStackPop (WalkState); break; case AML_TYPE_METHOD_CALL: ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", Op)); /* * (AML_METHODCALL) Op->Value->Arg->Node contains * the method Node pointer */ /* NextOp points to the op that holds the method name */ NextOp = FirstArg; /* NextOp points to first argument op */ NextOp = NextOp->Common.Next; /* * Get the method's arguments and put them on the operand stack */ Status = AcpiDsCreateOperands (WalkState, NextOp); if (ACPI_FAILURE (Status)) { break; } /* * Since the operands will be passed to another control method, * we must resolve all local references here (Local variables, * arguments to *this* method, etc.) */ Status = AcpiDsResolveOperands (WalkState); if (ACPI_FAILURE (Status)) { + /* On error, clear all resolved operands */ + + AcpiDsClearOperands (WalkState); break; } /* * Tell the walk loop to preempt this running method and * execute the new method */ Status = AE_CTRL_TRANSFER; /* * Return now; we don't want to disturb anything, * especially the operand count! */ return_ACPI_STATUS (Status); case AML_TYPE_CREATE_FIELD: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Executing CreateField Buffer/Index Op=%p\n", Op)); Status = AcpiDsLoad2EndOp (WalkState); if (ACPI_FAILURE (Status)) { break; } Status = AcpiDsEvalBufferFieldOperands (WalkState, Op); break; case AML_TYPE_CREATE_OBJECT: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Executing CreateObject (Buffer/Package) Op=%p\n", Op)); switch (Op->Common.Parent->Common.AmlOpcode) { case AML_NAME_OP: /* * 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); if (ACPI_FAILURE (Status)) { break; } /* Fall through */ /*lint -fallthrough */ case AML_INT_EVAL_SUBTREE_OP: Status = AcpiDsEvalDataObjectOperands (WalkState, Op, AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node)); break; default: Status = AcpiDsEvalDataObjectOperands (WalkState, Op, NULL); break; } /* * If a result object was returned from above, push it on the * current result stack */ if (ACPI_SUCCESS (Status) && WalkState->ResultObj) { Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); } break; case AML_TYPE_NAMED_FIELD: case AML_TYPE_NAMED_COMPLEX: case AML_TYPE_NAMED_SIMPLE: case AML_TYPE_NAMED_NO_OBJ: Status = AcpiDsLoad2EndOp (WalkState); if (ACPI_FAILURE (Status)) { break; } if (Op->Common.AmlOpcode == AML_REGION_OP) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Executing OpRegion Address/Length Op=%p\n", Op)); Status = AcpiDsEvalRegionOperands (WalkState, Op); if (ACPI_FAILURE (Status)) { break; } Status = AcpiDsResultStackPop (WalkState); } break; case AML_TYPE_UNDEFINED: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Undefined opcode type Op=%p\n", Op)); return_ACPI_STATUS (AE_NOT_IMPLEMENTED); case AML_TYPE_BOGUS: ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Internal opcode=%X type Op=%p\n", WalkState->Opcode, Op)); break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p\n", OpClass, OpType, Op->Common.AmlOpcode, Op)); Status = AE_NOT_IMPLEMENTED; break; } } /* * ACPI 2.0 support for 64-bit integers: Truncate numeric * result value if we are executing from a 32-bit ACPI table */ AcpiExTruncateFor32bitTable (WalkState->ResultObj); /* * Check if we just completed the evaluation of a * conditional predicate */ if ((WalkState->ControlState) && (WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) && (WalkState->ControlState->Control.PredicateOp == Op)) { Status = AcpiDsGetPredicateValue (WalkState, WalkState->ResultObj); WalkState->ResultObj = NULL; } Cleanup: if (WalkState->ResultObj) { /* Break to debugger to display result */ ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj, WalkState)); /* * Delete the result op if and only if: * Parent will not use the result -- such as any * non-nested type2 op in a method (parent will be method) */ AcpiDsDeleteResultIfNotUsed (Op, WalkState->ResultObj, WalkState); } /* Always clear the object stack */ WalkState->NumOperands = 0; return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/dswload.c b/sys/contrib/dev/acpica/dswload.c index 852d40a1d6ac..1afd9cf8b7ac 100644 --- a/sys/contrib/dev/acpica/dswload.c +++ b/sys/contrib/dev/acpica/dswload.c @@ -1,1010 +1,1051 @@ /****************************************************************************** * * Module Name: dswload - Dispatcher namespace load callbacks - * $Revision: 75 $ + * $Revision: 78 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __DSWLOAD_C__ #include "acpi.h" #include "acparser.h" #include "amlcode.h" #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" #include "acevents.h" #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dswload") /******************************************************************************* * * FUNCTION: AcpiDsInitCallbacks * * PARAMETERS: WalkState - Current state of the parse tree walk * PassNumber - 1, 2, or 3 * * RETURN: Status * * DESCRIPTION: Init walk state callbacks * ******************************************************************************/ ACPI_STATUS AcpiDsInitCallbacks ( ACPI_WALK_STATE *WalkState, UINT32 PassNumber) { switch (PassNumber) { case 1: 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->DescendingCallback = AcpiDsLoad2BeginOp; WalkState->AscendingCallback = AcpiDsLoad2EndOp; break; case 3: #ifndef ACPI_NO_METHOD_EXECUTION WalkState->ParseFlags |= ACPI_PARSE_EXECUTE | ACPI_PARSE_DELETE_TREE; WalkState->DescendingCallback = AcpiDsExecBeginOp; WalkState->AscendingCallback = AcpiDsExecEndOp; #endif break; default: return (AE_BAD_PARAMETER); } return (AE_OK); } /******************************************************************************* * * 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. * * RETURN: Status * * DESCRIPTION: Descending callback used during the loading of ACPI tables. * ******************************************************************************/ ACPI_STATUS AcpiDsLoad1BeginOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp) { ACPI_PARSE_OBJECT *Op; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_OBJECT_TYPE ObjectType; NATIVE_CHAR *Path; UINT32 Flags; ACPI_FUNCTION_NAME ("DsLoad1BeginOp"); Op = WalkState->Op; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); /* We are only interested in opcodes that have an associated name */ if (Op) { 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); } /* Check if this object has already been installed in the namespace */ if (Op->Common.Node) { *OutOp = Op; return (AE_OK); } } Path = AcpiPsGetNextNamestring (&WalkState->ParserState); /* Map the raw opcode into an internal object type */ ObjectType = WalkState->OpInfo->ObjectType; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "State=%p Op=%p [%s] ", WalkState, Op, AcpiUtGetTypeName (ObjectType))); - /* - * Setup the search flags. - * - * Since we are entering a name into the namespace, we do not want to - * enable the search-to-root upsearch. - * - * There are only two conditions where it is acceptable that the name - * already exists: - * 1) the Scope() operator can reopen a scoping object that was - * previously defined (Scope, Method, Device, etc.) - * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer, - * BufferField, or Package), the name of the object is already - * in the namespace. - */ - Flags = ACPI_NS_NO_UPSEARCH; - if ((WalkState->Opcode != AML_SCOPE_OP) && - (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP))) + switch (WalkState->Opcode) { - Flags |= ACPI_NS_ERROR_IF_FOUND; - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "Cannot already exist\n")); - } - else - { - ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "Both Find or Create allowed\n")); - } + case AML_SCOPE_OP: - /* - * 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. - */ - Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, - ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node)); - if (ACPI_FAILURE (Status)) - { - ACPI_REPORT_NSERROR (Path, Status); - return (Status); - } + /* + * The target name of the Scope() operator must exist at this point so + * that we can actually open the scope to enter new names underneath it. + * Allow search-to-root for single namesegs. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); + if (ACPI_FAILURE (Status)) + { + ACPI_REPORT_NSERROR (Path, Status); + return (Status); + } - /* - * For the scope op, we must check to make sure that the target is - * one of the opcodes that actually opens a scope - */ - if (WalkState->Opcode == AML_SCOPE_OP) - { + /* + * Check to make sure that the target is + * one of the opcodes that actually opens a scope + */ switch (Node->Type) { - case ACPI_TYPE_ANY: /* Scope nodes are untyped (ANY) */ + case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ case ACPI_TYPE_DEVICE: case ACPI_TYPE_POWER: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_THERMAL: /* These are acceptable types */ break; case ACPI_TYPE_INTEGER: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: /* * These types we will allow, but we will change the type. This * enables some existing code of the form: * * Name (DEB, 0) * Scope (DEB) { ... } * * 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", Path, AcpiUtGetTypeName (Node->Type))); Node->Type = ACPI_TYPE_ANY; WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; break; - default: + default: /* All other types are an error */ 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); } + break; + + + default: + + /* + * 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 + * enable the search-to-root upsearch. + * + * There are only two conditions where it is acceptable that the name + * already exists: + * 1) the Scope() operator can reopen a scoping object that was + * previously defined (Scope, Method, Device, etc.) + * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer, + * BufferField, or Package), the name of the object is already + * in the namespace. + */ + Flags = ACPI_NS_NO_UPSEARCH; + if ((WalkState->Opcode != AML_SCOPE_OP) && + (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP))) + { + Flags |= ACPI_NS_ERROR_IF_FOUND; + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "Cannot already exist\n")); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DISPATCH, "Both Find or Create allowed\n")); + } + + /* + * 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. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, + ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &(Node)); + if (ACPI_FAILURE (Status)) + { + ACPI_REPORT_NSERROR (Path, Status); + return (Status); + } + break; } + + /* Common exit */ + if (!Op) { /* Create a new op */ Op = AcpiPsAllocOp (WalkState->Opcode); if (!Op) { return (AE_NO_MEMORY); } } /* Initialize */ Op->Named.Name = Node->Name.Integer; #if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) Op->Named.Path = (UINT8 *) Path; #endif /* * Put the Node in the "op" object that the parser uses, so we * can get it again quickly when this scope is closed */ Op->Common.Node = Node; AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op); *OutOp = Op; return (Status); } /******************************************************************************* * * 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 * * DESCRIPTION: Ascending callback used during the loading of the namespace, * both control methods and everything else. * ******************************************************************************/ ACPI_STATUS AcpiDsLoad1EndOp ( ACPI_WALK_STATE *WalkState) { ACPI_PARSE_OBJECT *Op; ACPI_OBJECT_TYPE ObjectType; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_NAME ("DsLoad1EndOp"); Op = WalkState->Op; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); /* We are only interested in opcodes that have an associated name */ if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD))) { return (AE_OK); } /* Get the object type to determine if we should pop the scope */ ObjectType = WalkState->OpInfo->ObjectType; #ifndef ACPI_NO_METHOD_EXECUTION if (WalkState->OpInfo->Flags & AML_FIELD) { if (WalkState->Opcode == AML_FIELD_OP || WalkState->Opcode == AML_BANK_FIELD_OP || WalkState->Opcode == AML_INDEX_FIELD_OP) { Status = AcpiDsInitFieldObjects (Op, WalkState); } return (Status); } 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); if (ACPI_FAILURE (Status)) { return (Status); } } #endif if (Op->Common.AmlOpcode == AML_NAME_OP) { /* For Name opcode, get the object type from the argument */ if (Op->Common.Value.Arg) { ObjectType = (AcpiPsGetOpcodeInfo ((Op->Common.Value.Arg)->Common.AmlOpcode))->ObjectType; Op->Common.Node->Type = (UINT8) ObjectType; } } /* Pop the scope stack */ if (AcpiNsOpensScope (ObjectType)) { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n", AcpiUtGetTypeName (ObjectType), Op)); Status = AcpiDsScopeStackPop (WalkState); } return (Status); } /******************************************************************************* * * 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. * * RETURN: Status * * DESCRIPTION: Descending callback used during the loading of ACPI tables. * ******************************************************************************/ ACPI_STATUS AcpiDsLoad2BeginOp ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT **OutOp) { ACPI_PARSE_OBJECT *Op; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_OBJECT_TYPE ObjectType; NATIVE_CHAR *BufferPtr; ACPI_FUNCTION_TRACE ("DsLoad2BeginOp"); Op = WalkState->Op; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); if (Op) { /* We only care about Namespace opcodes here */ if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) && (WalkState->Opcode != AML_INT_NAMEPATH_OP)) || (!(WalkState->OpInfo->Flags & AML_NAMED))) { return_ACPI_STATUS (AE_OK); } /* * 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 */ BufferPtr = Op->Common.Value.String; if (!BufferPtr) { /* No name, just exit */ return_ACPI_STATUS (AE_OK); } } else { /* Get name from the op */ BufferPtr = (NATIVE_CHAR *) &Op->Named.Name; } } else { /* Get the namestring from the raw AML */ BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState); } /* Map the opcode into an internal object type */ ObjectType = WalkState->OpInfo->ObjectType; ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType)); - if (WalkState->Opcode == AML_FIELD_OP || - WalkState->Opcode == AML_BANK_FIELD_OP || - WalkState->Opcode == AML_INDEX_FIELD_OP) + switch (WalkState->Opcode) { + case AML_FIELD_OP: + case AML_BANK_FIELD_OP: + case AML_INDEX_FIELD_OP: + Node = NULL; Status = AE_OK; - } - else if (WalkState->Opcode == AML_INT_NAMEPATH_OP) - { + break; + + 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 */ Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); - } - else - { - /* All other opcodes */ - - if (Op && Op->Common.Node) - { - /* This op/node was previously entered into the namespace */ - - Node = Op->Common.Node; - - if (AcpiNsOpensScope (ObjectType)) - { - Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); - if (ACPI_FAILURE (Status)) - { - return_ACPI_STATUS (Status); - } + break; - } - return_ACPI_STATUS (AE_OK); - } + case AML_SCOPE_OP: /* - * 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. + * 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_NO_UPSEARCH, WalkState, &(Node)); - } - - if (ACPI_FAILURE (Status)) - { - ACPI_REPORT_NSERROR (BufferPtr, Status); - return_ACPI_STATUS (Status); - } - - /* - * For the scope op, we must check to make sure that the target is - * one of the opcodes that actually opens a scope - */ - if (WalkState->Opcode == AML_SCOPE_OP) - { + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node)); + if (ACPI_FAILURE (Status)) + { + ACPI_REPORT_NSERROR (BufferPtr, Status); + return_ACPI_STATUS (Status); + } + /* + * We must check to make sure that the target is + * one of the opcodes that actually opens a scope + */ switch (Node->Type) { - case ACPI_TYPE_ANY: /* Scope nodes are untyped (ANY) */ + case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ case ACPI_TYPE_DEVICE: case ACPI_TYPE_POWER: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_THERMAL: /* These are acceptable types */ break; case ACPI_TYPE_INTEGER: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: /* * These types we will allow, but we will change the type. This * enables some existing code of the form: * * Name (DEB, 0) * Scope (DEB) { ... } */ 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; WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; break; - default: + default: /* All other types are an error */ ACPI_REPORT_ERROR (("Invalid type (%s) for target of Scope operator [%4.4s]\n", AcpiUtGetTypeName (Node->Type), BufferPtr)); return (AE_AML_OPERAND_TYPE); } + break; + + default: + + /* All other opcodes */ + + if (Op && Op->Common.Node) + { + /* This op/node was previously entered into the namespace */ + + Node = Op->Common.Node; + + if (AcpiNsOpensScope (ObjectType)) + { + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + } + return_ACPI_STATUS (AE_OK); + } + + /* + * 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. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, + ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, WalkState, &(Node)); + break; + } + + if (ACPI_FAILURE (Status)) + { + ACPI_REPORT_NSERROR (BufferPtr, Status); + return_ACPI_STATUS (Status); } + if (!Op) { /* Create a new op */ Op = AcpiPsAllocOp (WalkState->Opcode); if (!Op) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Initialize the new op */ if (Node) { Op->Named.Name = Node->Name.Integer; } if (OutOp) { *OutOp = Op; } } /* * Put the Node in the "op" object that the parser uses, so we * can get it again quickly when this scope is closed */ Op->Common.Node = Node; return_ACPI_STATUS (Status); } /******************************************************************************* * * 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 * * DESCRIPTION: Ascending callback used during the loading of the namespace, * both control methods and everything else. * ******************************************************************************/ ACPI_STATUS AcpiDsLoad2EndOp ( ACPI_WALK_STATE *WalkState) { ACPI_PARSE_OBJECT *Op; ACPI_STATUS Status = AE_OK; ACPI_OBJECT_TYPE ObjectType; ACPI_NAMESPACE_NODE *Node; ACPI_PARSE_OBJECT *Arg; ACPI_NAMESPACE_NODE *NewNode; #ifndef ACPI_NO_METHOD_EXECUTION UINT32 i; #endif ACPI_FUNCTION_TRACE ("DsLoad2EndOp"); Op = WalkState->Op; 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 */ if (!(WalkState->OpInfo->Flags & AML_NSOBJECT)) { return_ACPI_STATUS (AE_OK); } if (Op->Common.AmlOpcode == AML_SCOPE_OP) { ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Ending scope Op=%p State=%p\n", Op, WalkState)); } ObjectType = WalkState->OpInfo->ObjectType; /* * Get the Node/name from the earlier lookup * (It was saved in the *op structure) */ Node = Op->Common.Node; /* * Put the Node on the object stack (Contains the ACPI Name of * this object) */ WalkState->Operands[0] = (void *) Node; WalkState->NumOperands = 1; /* Pop the scope stack */ 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)); Status = AcpiDsScopeStackPop (WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* * Named operations are as follows: * * AML_ALIAS * AML_BANKFIELD * AML_CREATEBITFIELD * AML_CREATEBYTEFIELD * AML_CREATEDWORDFIELD * AML_CREATEFIELD * AML_CREATEQWORDFIELD * AML_CREATEWORDFIELD * AML_DATA_REGION * AML_DEVICE * AML_EVENT * AML_FIELD * AML_INDEXFIELD * AML_METHOD * AML_METHODCALL * AML_MUTEX * AML_NAME * AML_NAMEDFIELD * AML_OPREGION * AML_POWERRES * AML_PROCESSOR * AML_SCOPE * AML_THERMALZONE */ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Create-Load [%s] State=%p Op=%p NamedObj=%p\n", AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node)); /* Decode the opcode */ Arg = Op->Common.Value.Arg; switch (WalkState->OpInfo->Type) { #ifndef ACPI_NO_METHOD_EXECUTION case AML_TYPE_CREATE_FIELD: /* * Create the field object, but the field buffer and index must * be evaluated later during the execution phase */ Status = AcpiDsCreateBufferField (Op, WalkState); break; case AML_TYPE_NAMED_FIELD: switch (Op->Common.AmlOpcode) { case AML_INDEX_FIELD_OP: Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node, WalkState); break; case AML_BANK_FIELD_OP: Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState); break; case AML_FIELD_OP: Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState); break; default: /* All NAMED_FIELD opcodes must be handled above */ break; } break; case AML_TYPE_NAMED_SIMPLE: Status = AcpiDsCreateOperands (WalkState, Arg); if (ACPI_FAILURE (Status)) { goto Cleanup; } switch (Op->Common.AmlOpcode) { case AML_PROCESSOR_OP: Status = AcpiExCreateProcessor (WalkState); break; case AML_POWER_RES_OP: Status = AcpiExCreatePowerResource (WalkState); break; case AML_MUTEX_OP: Status = AcpiExCreateMutex (WalkState); break; case AML_EVENT_OP: Status = AcpiExCreateEvent (WalkState); break; case AML_DATA_REGION_OP: Status = AcpiExCreateTableRegion (WalkState); break; case AML_ALIAS_OP: Status = AcpiExCreateAlias (WalkState); break; default: /* Unknown opcode */ Status = AE_OK; goto Cleanup; } /* Delete operands */ for (i = 1; i < WalkState->NumOperands; i++) { AcpiUtRemoveReference (WalkState->Operands[i]); WalkState->Operands[i] = NULL; } break; #endif /* ACPI_NO_METHOD_EXECUTION */ case AML_TYPE_NAMED_COMPLEX: switch (Op->Common.AmlOpcode) { case AML_METHOD_OP: /* * MethodOp PkgLength NameString MethodFlags TermList */ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "LOADING-Method: State=%p Op=%p NamedObj=%p\n", WalkState, Op, Node)); if (!AcpiNsGetAttachedObject (Node)) { Status = AcpiDsCreateOperands (WalkState, Arg); if (ACPI_FAILURE (Status)) { goto Cleanup; } Status = AcpiExCreateMethod (Op->Named.Data, Op->Named.Length, WalkState); } break; #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) */ /* * If we have a valid region, initialize it * Namespace is NOT locked at this point. */ Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), FALSE); if (ACPI_FAILURE (Status)) { /* * If AE_NOT_EXIST is returned, it is not fatal * because many regions get created before a handler * is installed for said region. */ if (AE_NOT_EXIST == Status) { Status = AE_OK; } } break; case AML_NAME_OP: Status = AcpiDsCreateNode (WalkState, Node, Op); break; #endif /* ACPI_NO_METHOD_EXECUTION */ default: /* All NAMED_COMPLEX opcodes must be handled above */ break; } break; case AML_CLASS_INTERNAL: /* case AML_INT_NAMEPATH_OP: */ break; case AML_CLASS_METHOD_CALL: ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n", WalkState, Op, Node)); /* * Lookup the method name and save the Node */ Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2, ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(NewNode)); if (ACPI_SUCCESS (Status)) { /* * 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 */ 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 */ Op->Common.Node = NewNode; } else { ACPI_REPORT_NSERROR (Arg->Common.Value.String, Status); } break; default: break; } Cleanup: /* Remove the Node pushed at the very beginning */ WalkState->Operands[0] = NULL; WalkState->NumOperands = 0; return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/dswscope.c b/sys/contrib/dev/acpica/dswscope.c index 92736f575fab..60e06c5a3770 100644 --- a/sys/contrib/dev/acpica/dswscope.c +++ b/sys/contrib/dev/acpica/dswscope.c @@ -1,271 +1,315 @@ /****************************************************************************** * * Module Name: dswscope - Scope stack manipulation - * $Revision: 53 $ + * $Revision: 56 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __DSWSCOPE_C__ #include "acpi.h" -#include "acinterp.h" #include "acdispat.h" #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dswscope") #define STACK_POP(head) head /**************************************************************************** * * FUNCTION: AcpiDsScopeStackClear * * PARAMETERS: None * * DESCRIPTION: Pop (and free) everything on the scope stack except the * root scope object (which remains at the stack top.) * ***************************************************************************/ void AcpiDsScopeStackClear ( ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *ScopeInfo; ACPI_FUNCTION_NAME ("DsScopeStackClear"); while (WalkState->ScopeInfo) { /* Pop a scope off the stack */ ScopeInfo = WalkState->ScopeInfo; WalkState->ScopeInfo = ScopeInfo->Scope.Next; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Popped object type (%s)\n", AcpiUtGetTypeName (ScopeInfo->Common.Value))); AcpiUtDeleteGenericState (ScopeInfo); } } /**************************************************************************** * * FUNCTION: AcpiDsScopeStackPush * * PARAMETERS: *Node, - Name to be made current * Type, - Type of frame being pushed * * DESCRIPTION: Push the current scope on the scope stack, and make the * passed Node current. * ***************************************************************************/ ACPI_STATUS AcpiDsScopeStackPush ( ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *ScopeInfo; + ACPI_GENERIC_STATE *OldScopeInfo; ACPI_FUNCTION_TRACE ("DsScopeStackPush"); if (!Node) { /* Invalid scope */ ACPI_REPORT_ERROR (("DsScopeStackPush: null scope passed\n")); return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Make sure object type is valid */ - if (!AcpiExValidateObjectType (Type)) + if (!AcpiUtValidObjectType (Type)) { ACPI_REPORT_WARNING (("DsScopeStackPush: type code out of range\n")); } /* Allocate a new scope object */ ScopeInfo = AcpiUtCreateGenericState (); if (!ScopeInfo) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Init new scope object */ ScopeInfo->Common.DataType = ACPI_DESC_TYPE_STATE_WSCOPE; ScopeInfo->Scope.Node = Node; ScopeInfo->Common.Value = (UINT16) Type; + WalkState->ScopeDepth++; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[%.2d] Pushed scope ", (UINT32) WalkState->ScopeDepth)); + + OldScopeInfo = WalkState->ScopeInfo; + if (OldScopeInfo) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[%4.4s] (%10s)", + OldScopeInfo->Scope.Node->Name.Ascii, + AcpiUtGetTypeName (OldScopeInfo->Common.Value))); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[\\___] (%10s)", "ROOT")); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + ", New scope -> [%4.4s] (%s)\n", + ScopeInfo->Scope.Node->Name.Ascii, + AcpiUtGetTypeName (ScopeInfo->Common.Value))); + /* Push new scope object onto stack */ AcpiUtPushGenericState (&WalkState->ScopeInfo, ScopeInfo); return_ACPI_STATUS (AE_OK); } /**************************************************************************** * * FUNCTION: AcpiDsScopeStackPop * * PARAMETERS: Type - The type of frame to be found * * DESCRIPTION: Pop the scope stack until a frame of the requested type * is found. * * 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. * ***************************************************************************/ ACPI_STATUS AcpiDsScopeStackPop ( ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *ScopeInfo; + ACPI_GENERIC_STATE *NewScopeInfo; ACPI_FUNCTION_TRACE ("DsScopeStackPop"); /* * Pop scope info object off the stack. */ ScopeInfo = AcpiUtPopGenericState (&WalkState->ScopeInfo); if (!ScopeInfo) { return_ACPI_STATUS (AE_STACK_UNDERFLOW); } + WalkState->ScopeDepth--; + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, - "Popped object type (%s)\n", AcpiUtGetTypeName (ScopeInfo->Common.Value))); + "[%.2d] Popped scope [%4.4s] (%10s), New scope -> ", + (UINT32) WalkState->ScopeDepth, + ScopeInfo->Scope.Node->Name.Ascii, + AcpiUtGetTypeName (ScopeInfo->Common.Value))); + + NewScopeInfo = WalkState->ScopeInfo; + if (NewScopeInfo) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[%4.4s] (%s)\n", + NewScopeInfo->Scope.Node->Name.Ascii, + AcpiUtGetTypeName (NewScopeInfo->Common.Value))); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[\\___] (ROOT)\n")); + } AcpiUtDeleteGenericState (ScopeInfo); return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/dswstate.c b/sys/contrib/dev/acpica/dswstate.c index 8da290ae04da..e979a1e47f5d 100644 --- a/sys/contrib/dev/acpica/dswstate.c +++ b/sys/contrib/dev/acpica/dswstate.c @@ -1,1200 +1,1200 @@ /****************************************************************************** * * Module Name: dswstate - Dispatcher parse tree walk management routines - * $Revision: 68 $ + * $Revision: 70 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __DSWSTATE_C__ #include "acpi.h" #include "acparser.h" #include "acdispat.h" #include "acnamesp.h" #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dswstate") /******************************************************************************* * * FUNCTION: AcpiDsResultInsert * * PARAMETERS: Object - Object to push * WalkState - Current Walk state * * RETURN: Status * * DESCRIPTION: Push an object onto this walk's result stack * ******************************************************************************/ ACPI_STATUS AcpiDsResultInsert ( void *Object, UINT32 Index, ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *State; 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 >= 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: AcpiDsResultRemove * * PARAMETERS: Object - Where to return the popped object * WalkState - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In * other words, this is a FIFO. * ******************************************************************************/ ACPI_STATUS AcpiDsResultRemove ( ACPI_OPERAND_OBJECT **Object, UINT32 Index, ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *State; ACPI_FUNCTION_NAME ("DsResultRemove"); 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 >= OBJ_MAX_OPERAND) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index out of range: %X State=%p Num=%X\n", Index, WalkState, State->Results.NumResults)); } /* Check for a valid result object */ if (!State->Results.ObjDesc [Index]) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null operand! State=%p #Ops=%X, Index=%X\n", WalkState, State->Results.NumResults, Index)); return (AE_AML_NO_RETURN_VALUE); } /* Remove the object */ State->Results.NumResults--; *Object = State->Results.ObjDesc [Index]; State->Results.ObjDesc [Index] = NULL; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] Index=%X State=%p Num=%X\n", *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", Index, WalkState, State->Results.NumResults)); return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiDsResultPop * * PARAMETERS: Object - Where to return the popped object * WalkState - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In * other words, this is a FIFO. * ******************************************************************************/ ACPI_STATUS AcpiDsResultPop ( ACPI_OPERAND_OBJECT **Object, ACPI_WALK_STATE *WalkState) { - UINT32 Index; + NATIVE_UINT Index; ACPI_GENERIC_STATE *State; ACPI_FUNCTION_NAME ("DsResultPop"); State = WalkState->Results; if (!State) { return (AE_OK); } if (!State->Results.NumResults) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack is empty! State=%p\n", WalkState)); return (AE_AML_NO_RETURN_VALUE); } /* Remove top element */ State->Results.NumResults--; for (Index = OBJ_NUM_OPERANDS; Index; Index--) { /* Check for a valid result object */ if (State->Results.ObjDesc [Index -1]) { *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", - Index -1, WalkState, State->Results.NumResults)); + (UINT32) Index -1, WalkState, State->Results.NumResults)); return (AE_OK); } } ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState)); return (AE_AML_NO_RETURN_VALUE); } /******************************************************************************* * * FUNCTION: AcpiDsResultPopFromBottom * * PARAMETERS: Object - Where to return the popped object * WalkState - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop an object off the bottom of this walk's result stack. In * other words, this is a FIFO. * ******************************************************************************/ ACPI_STATUS AcpiDsResultPopFromBottom ( ACPI_OPERAND_OBJECT **Object, ACPI_WALK_STATE *WalkState) { NATIVE_UINT Index; ACPI_GENERIC_STATE *State; ACPI_FUNCTION_NAME ("DsResultPopFromBottom"); State = WalkState->Results; if (!State) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Warning: No result object pushed! State=%p\n", WalkState)); return (AE_NOT_EXIST); } if (!State->Results.NumResults) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result objects! State=%p\n", WalkState)); return (AE_AML_NO_RETURN_VALUE); } /* Remove Bottom element */ *Object = State->Results.ObjDesc [0]; /* Push entire stack down one element */ for (Index = 0; Index < State->Results.NumResults; Index++) { State->Results.ObjDesc [Index] = State->Results.ObjDesc [Index + 1]; } State->Results.NumResults--; /* Check for a valid result object */ if (!*Object) { 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", *Object, (*Object) ? AcpiUtGetObjectTypeName (*Object) : "NULL", State, WalkState)); return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiDsResultPush * * PARAMETERS: Object - Where to return the popped object * WalkState - Current Walk state * * RETURN: Status * * DESCRIPTION: Push an object onto the current result stack * ******************************************************************************/ ACPI_STATUS AcpiDsResultPush ( ACPI_OPERAND_OBJECT *Object, ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *State; ACPI_FUNCTION_NAME ("DsResultPush"); State = WalkState->Results; if (!State) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No result stack frame\n")); return (AE_AML_INTERNAL); } if (State->Results.NumResults == OBJ_NUM_OPERANDS) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Result stack overflow: Obj=%p State=%p Num=%X\n", Object, WalkState, State->Results.NumResults)); return (AE_STACK_OVERFLOW); } if (!Object) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Object! Obj=%p State=%p Num=%X\n", Object, WalkState, State->Results.NumResults)); return (AE_BAD_PARAMETER); } State->Results.ObjDesc [State->Results.NumResults] = 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: AcpiDsResultStackPush * * PARAMETERS: Object - Object to push * WalkState - Current Walk state * * RETURN: Status * - * DESCRIPTION: + * DESCRIPTION: Push an object onto the WalkState result stack. * ******************************************************************************/ ACPI_STATUS AcpiDsResultStackPush ( ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *State; ACPI_FUNCTION_NAME ("DsResultStackPush"); State = AcpiUtCreateGenericState (); if (!State) { return (AE_NO_MEMORY); } State->Common.DataType = ACPI_DESC_TYPE_STATE_RESULT; AcpiUtPushGenericState (&WalkState->Results, State); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n", State, WalkState)); return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiDsResultStackPop * * PARAMETERS: WalkState - Current Walk state * * RETURN: Status * - * DESCRIPTION: + * DESCRIPTION: Pop an object off of the WalkState result stack. * ******************************************************************************/ ACPI_STATUS AcpiDsResultStackPop ( ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *State; ACPI_FUNCTION_NAME ("DsResultStackPop"); /* Check for stack underflow */ if (WalkState->Results == NULL) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Underflow - State=%p\n", WalkState)); return (AE_AML_NO_OPERAND); } State = AcpiUtPopGenericState (&WalkState->Results); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Result=%p RemainingResults=%X State=%p\n", State, State->Results.NumResults, WalkState)); AcpiUtDeleteGenericState (State); 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 < 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 * WalkState - Current Walk state * * RETURN: Status * * DESCRIPTION: Push an object onto this walk's object/operand stack * ******************************************************************************/ ACPI_STATUS AcpiDsObjStackPush ( void *Object, ACPI_WALK_STATE *WalkState) { ACPI_FUNCTION_NAME ("DsObjStackPush"); /* Check for stack overflow */ if (WalkState->NumOperands >= OBJ_NUM_OPERANDS) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "overflow! Obj=%p State=%p #Ops=%X\n", Object, WalkState, WalkState->NumOperands)); return (AE_STACK_OVERFLOW); } /* Put the object onto the stack */ WalkState->Operands [WalkState->NumOperands] = Object; WalkState->NumOperands++; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), WalkState, WalkState->NumOperands)); return (AE_OK); } #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 * * 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 AcpiDsObjStackPop ( UINT32 PopCount, ACPI_WALK_STATE *WalkState) { UINT32 i; ACPI_FUNCTION_NAME ("DsObjStackPop"); for (i = 0; i < PopCount; i++) { /* Check for stack underflow */ if (WalkState->NumOperands == 0) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Underflow! Count=%X State=%p #Ops=%X\n", PopCount, WalkState, WalkState->NumOperands)); return (AE_STACK_UNDERFLOW); } /* Just set the stack entry to null */ WalkState->NumOperands--; WalkState->Operands [WalkState->NumOperands] = NULL; } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", PopCount, WalkState, WalkState->NumOperands)); return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiDsObjStackPopAndDelete * * PARAMETERS: PopCount - Number of objects/entries to pop * WalkState - Current Walk state * * RETURN: Status * * DESCRIPTION: Pop this walk's object stack and delete each object that is * popped off. * ******************************************************************************/ ACPI_STATUS AcpiDsObjStackPopAndDelete ( UINT32 PopCount, ACPI_WALK_STATE *WalkState) { UINT32 i; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_NAME ("DsObjStackPopAndDelete"); for (i = 0; i < PopCount; i++) { /* Check for stack underflow */ if (WalkState->NumOperands == 0) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Underflow! Count=%X State=%p #Ops=%X\n", PopCount, WalkState, WalkState->NumOperands)); return (AE_STACK_UNDERFLOW); } /* Pop the stack and delete an object if present in this stack entry */ WalkState->NumOperands--; ObjDesc = WalkState->Operands [WalkState->NumOperands]; if (ObjDesc) { AcpiUtRemoveReference (WalkState->Operands [WalkState->NumOperands]); WalkState->Operands [WalkState->NumOperands] = NULL; } } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", PopCount, 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: 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[(NATIVE_UINT)(WalkState->NumOperands - 1) - Index]); } /******************************************************************************* * * FUNCTION: AcpiDsGetCurrentWalkState * * PARAMETERS: Thread - Get current active state for this Thread * * RETURN: Pointer to the current walk state * * DESCRIPTION: Get the walk state that is at the head of the list (the "current" * walk state.) * ******************************************************************************/ ACPI_WALK_STATE * AcpiDsGetCurrentWalkState ( ACPI_THREAD_STATE *Thread) { ACPI_FUNCTION_NAME ("DsGetCurrentWalkState"); if (!Thread) { return (NULL); } ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "DsGetCurrentWalkState, =%p\n", Thread->WalkStateList)); return (Thread->WalkStateList); } /******************************************************************************* * * FUNCTION: AcpiDsPushWalkState * * PARAMETERS: WalkState - State to push * WalkList - The list that owns the walk stack * * RETURN: None * * DESCRIPTION: Place the WalkState at the head of the state list. * ******************************************************************************/ void AcpiDsPushWalkState ( ACPI_WALK_STATE *WalkState, ACPI_THREAD_STATE *Thread) { ACPI_FUNCTION_TRACE ("DsPushWalkState"); WalkState->Next = Thread->WalkStateList; Thread->WalkStateList = WalkState; return_VOID; } /******************************************************************************* * * FUNCTION: AcpiDsPopWalkState * * PARAMETERS: WalkList - The list that owns the walk stack * * RETURN: A WalkState object popped from the 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 * the list is empty. * ******************************************************************************/ ACPI_WALK_STATE * AcpiDsPopWalkState ( ACPI_THREAD_STATE *Thread) { ACPI_WALK_STATE *WalkState; ACPI_FUNCTION_TRACE ("DsPopWalkState"); WalkState = Thread->WalkStateList; if (WalkState) { /* Next walk state becomes the current walk state */ Thread->WalkStateList = WalkState->Next; /* * Don't clear the NEXT field, this serves as an indicator * that there is a parent WALK STATE * NO: WalkState->Next = NULL; */ } return_PTR (WalkState); } /******************************************************************************* * * FUNCTION: AcpiDsCreateWalkState * * PARAMETERS: Origin - Starting point for this walk * Thread - Current thread state * * RETURN: Pointer to the new walk state. * * DESCRIPTION: Allocate and initialize a new walk state. The current walk * state is set to this new state. * ******************************************************************************/ ACPI_WALK_STATE * AcpiDsCreateWalkState ( ACPI_OWNER_ID OwnerId, ACPI_PARSE_OBJECT *Origin, ACPI_OPERAND_OBJECT *MthDesc, ACPI_THREAD_STATE *Thread) { ACPI_WALK_STATE *WalkState; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("DsCreateWalkState"); WalkState = AcpiUtAcquireFromCache (ACPI_MEM_LIST_WALK); if (!WalkState) { return_PTR (NULL); } WalkState->DataType = ACPI_DESC_TYPE_WALK; WalkState->OwnerId = OwnerId; WalkState->Origin = Origin; WalkState->MethodDesc = MthDesc; WalkState->Thread = Thread; WalkState->ParserState.StartOp = Origin; /* Init the method args/local */ #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) AcpiDsMethodDataInit (WalkState); #endif /* Create an initial result stack entry */ Status = AcpiDsResultStackPush (WalkState); if (ACPI_FAILURE (Status)) { return_PTR (NULL); } /* Put the new state at the head of the walk list */ if (Thread) { AcpiDsPushWalkState (WalkState, Thread); } return_PTR (WalkState); } /******************************************************************************* * * FUNCTION: AcpiDsInitAmlWalk * * PARAMETERS: WalkState - New state to be initialized * * RETURN: None * * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk * ******************************************************************************/ ACPI_STATUS AcpiDsInitAmlWalk ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_NAMESPACE_NODE *MethodNode, UINT8 *AmlStart, UINT32 AmlLength, ACPI_OPERAND_OBJECT **Params, ACPI_OPERAND_OBJECT **ReturnObjDesc, UINT32 PassNumber) { ACPI_STATUS Status; ACPI_PARSE_STATE *ParserState = &WalkState->ParserState; ACPI_PARSE_OBJECT *ExtraOp; ACPI_FUNCTION_TRACE ("DsInitAmlWalk"); WalkState->ParserState.Aml = WalkState->ParserState.AmlStart = AmlStart; WalkState->ParserState.AmlEnd = WalkState->ParserState.PkgEnd = AmlStart + AmlLength; /* The NextOp of the NextWalk will be the beginning of the method */ WalkState->NextOp = NULL; WalkState->Params = Params; WalkState->CallerReturnDesc = ReturnObjDesc; Status = AcpiPsInitScope (&WalkState->ParserState, Op); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } if (MethodNode) { WalkState->ParserState.StartNode = MethodNode; WalkState->WalkType = ACPI_WALK_METHOD; WalkState->MethodNode = MethodNode; WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode); /* Push start scope on scope stack and make it current */ Status = AcpiDsScopeStackPush (MethodNode, ACPI_TYPE_METHOD, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Init the method arguments */ Status = AcpiDsMethodDataInitArgs (Params, MTH_NUM_ARGS, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } else { /* * Setup the current scope. * Find a Named Op that has a namespace node associated with it. * search upwards from this Op. Current scope is the first * Op with a namespace node. */ ExtraOp = ParserState->StartOp; while (ExtraOp && !ExtraOp->Common.Node) { ExtraOp = ExtraOp->Common.Parent; } if (!ExtraOp) { ParserState->StartNode = NULL; } else { ParserState->StartNode = ExtraOp->Common.Node; } if (ParserState->StartNode) { /* Push start scope on scope stack and make it current */ Status = AcpiDsScopeStackPush (ParserState->StartNode, ParserState->StartNode->Type, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } } Status = AcpiDsInitCallbacks (WalkState, PassNumber); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiDsDeleteWalkState * * PARAMETERS: WalkState - State to delete * * RETURN: Status * * DESCRIPTION: Delete a walk state including all internal data structures * ******************************************************************************/ void AcpiDsDeleteWalkState ( ACPI_WALK_STATE *WalkState) { ACPI_GENERIC_STATE *State; ACPI_FUNCTION_TRACE_PTR ("DsDeleteWalkState", WalkState); if (!WalkState) { return; } if (WalkState->DataType != ACPI_DESC_TYPE_WALK) { 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)); } /* Always must free any linked control states */ while (WalkState->ControlState) { State = WalkState->ControlState; WalkState->ControlState = State->Common.Next; AcpiUtDeleteGenericState (State); } /* Always must free any linked parse states */ while (WalkState->ScopeInfo) { State = WalkState->ScopeInfo; WalkState->ScopeInfo = State->Common.Next; AcpiUtDeleteGenericState (State); } /* Always must free any stacked result states */ while (WalkState->Results) { State = WalkState->Results; WalkState->Results = State->Common.Next; AcpiUtDeleteGenericState (State); } AcpiUtReleaseToCache (ACPI_MEM_LIST_WALK, WalkState); return_VOID; } /****************************************************************************** * * FUNCTION: AcpiDsDeleteWalkStateCache * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Purge the global state object cache. Used during subsystem * termination. * ******************************************************************************/ void AcpiDsDeleteWalkStateCache ( void) { ACPI_FUNCTION_TRACE ("DsDeleteWalkStateCache"); AcpiUtDeleteGenericCache (ACPI_MEM_LIST_WALK); return_VOID; } diff --git a/sys/contrib/dev/acpica/evevent.c b/sys/contrib/dev/acpica/evevent.c index 32af556ae8bb..fe4bc5656ed6 100644 --- a/sys/contrib/dev/acpica/evevent.c +++ b/sys/contrib/dev/acpica/evevent.c @@ -1,1075 +1,1095 @@ /****************************************************************************** * * Module Name: evevent - Fixed and General Purpose Even handling and dispatch - * $Revision: 92 $ + * $Revision: 96 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License * * 2.1. This is your license from Intel Corp. under its intellectual property * rights. You may have additional license terms from the party that provided * you this software, covering your right to use that party's intellectual * property rights. * * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a * copy of the source code appearing in this file ("Covered Code") an * irrevocable, perpetual, worldwide license under Intel's copyrights in the * base code distributed originally by Intel ("Original Intel Code") to copy, * make derivatives, distribute, use and display any portion of the Covered * Code in any form, with the right to sublicense such rights; and * * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent * license (with the right to sublicense), under only those claims of Intel * patents that are infringed by the Original Intel Code, to make, use, sell, * offer to sell, and import the Covered Code and derivative works thereof * solely to the minimum extent necessary to exercise the above copyright * license, and in no event shall the patent license extend to any additions * to or modifications of the Original Intel Code. No other license or right * is granted directly or by implication, estoppel or otherwise; * * The above copyright and patent license is granted only if the following * conditions are met: * * 3. Conditions * * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, * and the following Disclaimer and Export Compliance provision. In addition, * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the * documentation and/or other materials provided with distribution. In * addition, Licensee may not authorize further sublicense of source of any * portion of the Covered Code, and must include terms to the effect that the * license from Licensee to its licensee is limited to the intellectual * property embodied in the software Licensee provides to its licensee, and * not to intellectual property embodied in modifications its licensee may * make. * * 3.3. Redistribution of Executable. Redistribution in executable form of any * substantial portion of the Covered Code or modification must reproduce the * above Copyright Notice, and the following Disclaimer and Export Compliance * provision in the documentation and/or other materials provided with the * distribution. * * 3.4. Intel retains all right, title, and interest in and to the Original * Intel Code. * * 3.5. Neither the name Intel nor any other trademark owned or controlled by * Intel shall be used in advertising or otherwise to promote the sale, use or * other dealings in products derived from or relating to the Covered Code * without prior written authorization from Intel. * * 4. Disclaimer and Export Compliance * * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY * LIMITED REMEDY. * * 4.3. Licensee shall not export, either directly or indirectly, any of this * software or system incorporating such software without first obtaining any * required license or other approval from the U. S. Department of Commerce or * any other agency or department of the United States Government. In the * event Licensee exports any such software from the United States or * re-exports any such software from a foreign destination, Licensee shall * ensure that the distribution and export/re-export of the software is in * compliance with all laws, regulations, orders, or other restrictions of the * U.S. Export Administration Regulations. Licensee agrees that neither it nor * any of its subsidiaries will export/re-export any technical data, process, * software, or service, directly or indirectly, to any country for which the * United States government or any agency thereof requires an export license, * other governmental approval, or letter of assurance, without first obtaining * such license, approval or letter. * *****************************************************************************/ #include "acpi.h" #include "acevents.h" #include "acnamesp.h" #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evevent") /******************************************************************************* * * FUNCTION: AcpiEvInitialize * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Initialize global data structures for events. * ******************************************************************************/ ACPI_STATUS AcpiEvInitialize ( void) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("EvInitialize"); /* Make sure we have ACPI tables */ if (!AcpiGbl_DSDT) { ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No ACPI tables present!\n")); return_ACPI_STATUS (AE_NO_ACPI_TABLES); } /* * Initialize the Fixed and General Purpose AcpiEvents prior. This is * done prior to enabling SCIs to prevent interrupts from occuring * before handers are installed. */ Status = AcpiEvFixedEventInitialize (); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to initialize fixed events, %s\n", AcpiFormatException (Status))); return_ACPI_STATUS (Status); } Status = AcpiEvGpeInitialize (); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to initialize general purpose events, %s\n", AcpiFormatException (Status))); return_ACPI_STATUS (Status); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiEvHandlerInitialize * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Install handlers for the SCI, Global Lock, and GPEs. * ******************************************************************************/ ACPI_STATUS AcpiEvHandlerInitialize ( void) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("EvHandlerInitialize"); /* Install the SCI handler */ Status = AcpiEvInstallSciHandler (); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to install System Control Interrupt Handler, %s\n", AcpiFormatException (Status))); return_ACPI_STATUS (Status); } /* Install handlers for control method GPE handlers (_Lxx, _Exx) */ Status = AcpiEvInitGpeControlMethods (); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to initialize GPE control methods, %s\n", AcpiFormatException (Status))); return_ACPI_STATUS (Status); } /* Install the handler for the Global Lock */ Status = AcpiEvInitGlobalLockHandler (); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_FATAL, "Unable to initialize Global Lock handler, %s\n", AcpiFormatException (Status))); return_ACPI_STATUS (Status); } AcpiGbl_EventsInitialized = TRUE; return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiEvFixedEventInitialize * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Install the fixed event handlers and enable the fixed events. * ******************************************************************************/ ACPI_STATUS AcpiEvFixedEventInitialize ( void) { NATIVE_UINT i; ACPI_STATUS Status; /* * Initialize the structure that keeps track of fixed event handlers * and enable the fixed events. */ for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { AcpiGbl_FixedEventHandlers[i].Handler = NULL; AcpiGbl_FixedEventHandlers[i].Context = NULL; /* Enable the fixed event */ if (AcpiGbl_FixedEventInfo[i].EnableRegisterId != 0xFF) { Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[i].EnableRegisterId, 0, ACPI_MTX_LOCK); if (ACPI_FAILURE (Status)) { return (Status); } } } return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiEvFixedEventDetect * * PARAMETERS: None * * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED * * DESCRIPTION: Checks the PM status register for fixed events * ******************************************************************************/ UINT32 AcpiEvFixedEventDetect ( void) { UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; UINT32 FixedStatus; UINT32 FixedEnable; NATIVE_UINT_MAX32 i; ACPI_FUNCTION_NAME ("EvFixedEventDetect"); /* * 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); ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, "Fixed AcpiEvent Block: Enable %08X Status %08X\n", FixedEnable, FixedStatus)); /* * Check for all possible Fixed Events and dispatch those that are active */ for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { /* Both the status and enable bits must be on for this event */ if ((FixedStatus & AcpiGbl_FixedEventInfo[i].StatusBitMask) && (FixedEnable & AcpiGbl_FixedEventInfo[i].EnableBitMask)) { /* Found an active (signalled) event */ IntStatus |= AcpiEvFixedEventDispatch (i); } } return (IntStatus); } /******************************************************************************* * * FUNCTION: AcpiEvFixedEventDispatch * * PARAMETERS: Event - Event type * * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED * * DESCRIPTION: Clears the status bit for the requested event, calls the * handler that previously registered for the event. * ******************************************************************************/ UINT32 AcpiEvFixedEventDispatch ( UINT32 Event) { ACPI_FUNCTION_ENTRY (); /* Clear the status bit */ (void) AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].StatusRegisterId, 1, ACPI_MTX_DO_NOT_LOCK); /* * Make sure we've got a handler. If not, report an error. * The event is disabled to prevent further interrupts. */ if (NULL == AcpiGbl_FixedEventHandlers[Event].Handler) { (void) AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId, 0, ACPI_MTX_DO_NOT_LOCK); ACPI_REPORT_ERROR ( ("EvGpeDispatch: No installed handler for fixed event [%08X]\n", Event)); return (ACPI_INTERRUPT_NOT_HANDLED); } /* Invoke the Fixed Event handler */ return ((AcpiGbl_FixedEventHandlers[Event].Handler)( AcpiGbl_FixedEventHandlers[Event].Context)); } /******************************************************************************* * * FUNCTION: AcpiEvGpeInitialize * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Initialize the GPE data structures * ******************************************************************************/ ACPI_STATUS AcpiEvGpeInitialize (void) { NATIVE_UINT_MAX32 i; NATIVE_UINT_MAX32 j; UINT32 GpeBlock; UINT32 GpeRegister; UINT32 GpeNumberIndex; UINT32 GpeNumber; ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("EvGpeInitialize"); /* * Initialize the GPE Block globals * * Why the GPE register block lengths divided by 2: From the ACPI Spec, * section "General-Purpose Event Registers", we have: * * "Each register block contains two registers of equal length * GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the * GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN * The length of the GPE1_STS and GPE1_EN registers is equal to * half the GPE1_LEN. If a generic register block is not supported * then its respective block pointer and block length values in the * FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need * to be the same size." */ AcpiGbl_GpeBlockInfo[0].AddressSpaceId = AcpiGbl_FADT->XGpe0Blk.AddressSpaceId; AcpiGbl_GpeBlockInfo[1].AddressSpaceId = AcpiGbl_FADT->XGpe1Blk.AddressSpaceId; AcpiGbl_GpeBlockInfo[0].RegisterCount = (UINT16) ACPI_DIV_16 (AcpiGbl_FADT->XGpe0Blk.RegisterBitWidth); AcpiGbl_GpeBlockInfo[1].RegisterCount = (UINT16) ACPI_DIV_16 (AcpiGbl_FADT->XGpe1Blk.RegisterBitWidth); AcpiGbl_GpeBlockInfo[0].BlockAddress = &AcpiGbl_FADT->XGpe0Blk; AcpiGbl_GpeBlockInfo[1].BlockAddress = &AcpiGbl_FADT->XGpe1Blk; AcpiGbl_GpeBlockInfo[0].BlockBaseNumber = 0; AcpiGbl_GpeBlockInfo[1].BlockBaseNumber = AcpiGbl_FADT->Gpe1Base; + /* Warn and exit if there are no GPE registers */ + AcpiGbl_GpeRegisterCount = AcpiGbl_GpeBlockInfo[0].RegisterCount + AcpiGbl_GpeBlockInfo[1].RegisterCount; if (!AcpiGbl_GpeRegisterCount) { - ACPI_REPORT_WARNING (("Zero GPEs are defined in the FADT\n")); + ACPI_REPORT_WARNING (("There are no GPE blocks defined in the FADT\n")); return_ACPI_STATUS (AE_OK); } - /* Determine the maximum GPE number for this machine */ + /* + * Determine the maximum GPE number for this machine. + * Note: both GPE0 and GPE1 are optional, and either can exist without + * the other + */ + if (AcpiGbl_GpeBlockInfo[0].RegisterCount) + { + /* GPE block 0 exists */ - AcpiGbl_GpeNumberMax = ACPI_MUL_8 (AcpiGbl_GpeBlockInfo[0].RegisterCount) - 1; + AcpiGbl_GpeNumberMax = ACPI_MUL_8 (AcpiGbl_GpeBlockInfo[0].RegisterCount) - 1; + } if (AcpiGbl_GpeBlockInfo[1].RegisterCount) { - /* Check for GPE0/GPE1 overlap */ + /* GPE block 1 exists */ + + /* Check for GPE0/GPE1 overlap (if both banks exist) */ - if (AcpiGbl_GpeNumberMax >= AcpiGbl_FADT->Gpe1Base) + if ((AcpiGbl_GpeBlockInfo[0].RegisterCount) && + (AcpiGbl_GpeNumberMax >= AcpiGbl_FADT->Gpe1Base)) { - ACPI_REPORT_ERROR (("GPE0 block overlaps the GPE1 block\n")); + ACPI_REPORT_ERROR (( + "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d)\n", + AcpiGbl_GpeNumberMax, AcpiGbl_FADT->Gpe1Base, + AcpiGbl_FADT->Gpe1Base + (ACPI_MUL_8 (AcpiGbl_GpeBlockInfo[1].RegisterCount) - 1))); return_ACPI_STATUS (AE_BAD_VALUE); } - /* GPE0 and GPE1 do not have to be contiguous in the GPE number space */ - - AcpiGbl_GpeNumberMax = AcpiGbl_FADT->Gpe1Base + (ACPI_MUL_8 (AcpiGbl_GpeBlockInfo[1].RegisterCount) - 1); + /* + * GPE0 and GPE1 do not have to be contiguous in the GPE number space, + * But, GPE0 always starts at zero. + */ + AcpiGbl_GpeNumberMax = AcpiGbl_FADT->Gpe1Base + + (ACPI_MUL_8 (AcpiGbl_GpeBlockInfo[1].RegisterCount) - 1); } /* Check for Max GPE number out-of-range */ if (AcpiGbl_GpeNumberMax > ACPI_GPE_MAX) { - ACPI_REPORT_ERROR (("Maximum GPE number from FADT is too large: 0x%X\n", AcpiGbl_GpeNumberMax)); + ACPI_REPORT_ERROR (("Maximum GPE number from FADT is too large: 0x%X\n", + AcpiGbl_GpeNumberMax)); return_ACPI_STATUS (AE_BAD_VALUE); } - /* - * Allocate the GPE number-to-index translation table - */ + /* Allocate the GPE number-to-index translation table */ + AcpiGbl_GpeNumberToIndex = ACPI_MEM_CALLOCATE ( sizeof (ACPI_GPE_INDEX_INFO) * ((ACPI_SIZE) AcpiGbl_GpeNumberMax + 1)); if (!AcpiGbl_GpeNumberToIndex) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not allocate the GpeNumberToIndex table\n")); return_ACPI_STATUS (AE_NO_MEMORY); } /* Set the Gpe index table to GPE_INVALID */ ACPI_MEMSET (AcpiGbl_GpeNumberToIndex, (int) ACPI_GPE_INVALID, sizeof (ACPI_GPE_INDEX_INFO) * ((ACPI_SIZE) AcpiGbl_GpeNumberMax + 1)); - /* - * Allocate the GPE register information block - */ + /* Allocate the GPE register information block */ + AcpiGbl_GpeRegisterInfo = ACPI_MEM_CALLOCATE ( (ACPI_SIZE) AcpiGbl_GpeRegisterCount * sizeof (ACPI_GPE_REGISTER_INFO)); if (!AcpiGbl_GpeRegisterInfo) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not allocate the GpeRegisterInfo table\n")); goto ErrorExit1; } /* * Allocate the GPE dispatch handler block. There are eight distinct GPEs * per register. Initialization to zeros is sufficient. */ AcpiGbl_GpeNumberInfo = ACPI_MEM_CALLOCATE ( (ACPI_SIZE) ACPI_MUL_8 (AcpiGbl_GpeRegisterCount) * sizeof (ACPI_GPE_NUMBER_INFO)); if (!AcpiGbl_GpeNumberInfo) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not allocate the GpeNumberInfo table\n")); goto ErrorExit2; } /* * Initialize the GPE information and validation tables. A goal of these * tables is to hide the fact that there are two separate GPE register sets * in a given gpe hardware block, the status registers occupy the first half, * and the enable registers occupy the second half. Another goal is to hide * the fact that there may be multiple GPE hardware blocks. */ GpeRegister = 0; GpeNumberIndex = 0; for (GpeBlock = 0; GpeBlock < ACPI_MAX_GPE_BLOCKS; GpeBlock++) { for (i = 0; i < AcpiGbl_GpeBlockInfo[GpeBlock].RegisterCount; i++) { GpeRegisterInfo = &AcpiGbl_GpeRegisterInfo[GpeRegister]; /* Init the Register info for this entire GPE register (8 GPEs) */ GpeRegisterInfo->BaseGpeNumber = (UINT8) (AcpiGbl_GpeBlockInfo[GpeBlock].BlockBaseNumber + (ACPI_MUL_8 (i))); ACPI_STORE_ADDRESS (GpeRegisterInfo->StatusAddress.Address, (ACPI_GET_ADDRESS (AcpiGbl_GpeBlockInfo[GpeBlock].BlockAddress->Address) + i)); ACPI_STORE_ADDRESS (GpeRegisterInfo->EnableAddress.Address, (ACPI_GET_ADDRESS (AcpiGbl_GpeBlockInfo[GpeBlock].BlockAddress->Address) + i + AcpiGbl_GpeBlockInfo[GpeBlock].RegisterCount)); GpeRegisterInfo->StatusAddress.AddressSpaceId = AcpiGbl_GpeBlockInfo[GpeBlock].AddressSpaceId; GpeRegisterInfo->EnableAddress.AddressSpaceId = AcpiGbl_GpeBlockInfo[GpeBlock].AddressSpaceId; GpeRegisterInfo->StatusAddress.RegisterBitWidth = 8; GpeRegisterInfo->EnableAddress.RegisterBitWidth = 8; GpeRegisterInfo->StatusAddress.RegisterBitOffset = 8; GpeRegisterInfo->EnableAddress.RegisterBitOffset = 8; /* Init the Index mapping info for each GPE number within this register */ for (j = 0; j < 8; j++) { GpeNumber = GpeRegisterInfo->BaseGpeNumber + j; AcpiGbl_GpeNumberToIndex[GpeNumber].NumberIndex = (UINT8) GpeNumberIndex; AcpiGbl_GpeNumberInfo[GpeNumberIndex].BitMask = AcpiGbl_DecodeTo8bit[j]; GpeNumberIndex++; } /* * Clear the status/enable registers. Note that status registers * are cleared by writing a '1', while enable registers are cleared * by writing a '0'. */ - Status = AcpiHwLowLevelWrite (8, 0x00, &GpeRegisterInfo->EnableAddress, 0); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiHwLowLevelWrite (8, 0xFF, &GpeRegisterInfo->StatusAddress, 0); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } GpeRegister++; } - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "GPE Block%d: %X registers at %8.8X%8.8X\n", - (INT32) GpeBlock, AcpiGbl_GpeBlockInfo[0].RegisterCount, - ACPI_HIDWORD (ACPI_GET_ADDRESS (AcpiGbl_GpeBlockInfo[GpeBlock].BlockAddress->Address)), - ACPI_LODWORD (ACPI_GET_ADDRESS (AcpiGbl_GpeBlockInfo[GpeBlock].BlockAddress->Address)))); - - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "GPE Block%d Range GPE #%2.2X to GPE #%2.2X\n", - (INT32) GpeBlock, - AcpiGbl_GpeBlockInfo[GpeBlock].BlockBaseNumber, - AcpiGbl_GpeBlockInfo[GpeBlock].BlockBaseNumber + - ((AcpiGbl_GpeBlockInfo[GpeBlock].RegisterCount * 8) -1))); + if (i) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "GPE Block%d: %X registers at %8.8X%8.8X\n", + (INT32) GpeBlock, AcpiGbl_GpeBlockInfo[0].RegisterCount, + ACPI_HIDWORD (ACPI_GET_ADDRESS (AcpiGbl_GpeBlockInfo[GpeBlock].BlockAddress->Address)), + ACPI_LODWORD (ACPI_GET_ADDRESS (AcpiGbl_GpeBlockInfo[GpeBlock].BlockAddress->Address)))); + + ACPI_REPORT_INFO (("GPE Block%d defined as GPE%d to GPE%d\n", + (INT32) GpeBlock, + (UINT32) AcpiGbl_GpeBlockInfo[GpeBlock].BlockBaseNumber, + (UINT32) (AcpiGbl_GpeBlockInfo[GpeBlock].BlockBaseNumber + + ((AcpiGbl_GpeBlockInfo[GpeBlock].RegisterCount * 8) -1)))); + } } return_ACPI_STATUS (AE_OK); /* Error cleanup */ ErrorExit2: ACPI_MEM_FREE (AcpiGbl_GpeRegisterInfo); ErrorExit1: ACPI_MEM_FREE (AcpiGbl_GpeNumberToIndex); return_ACPI_STATUS (AE_NO_MEMORY); } /******************************************************************************* * * FUNCTION: AcpiEvSaveMethodInfo * * PARAMETERS: None * * RETURN: None * * DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a * control method under the _GPE portion of the namespace. * Extract the name and GPE type from the object, saving this * information for quick lookup during GPE dispatch * * The name of each GPE control method is of the form: * "_Lnn" or "_Enn" * Where: * L - means that the GPE is level triggered * E - means that the GPE is edge triggered * nn - is the GPE number [in HEX] * ******************************************************************************/ static ACPI_STATUS AcpiEvSaveMethodInfo ( ACPI_HANDLE ObjHandle, UINT32 Level, void *ObjDesc, void **ReturnValue) { UINT32 GpeNumber; UINT32 GpeNumberIndex; NATIVE_CHAR Name[ACPI_NAME_SIZE + 1]; UINT8 Type; ACPI_STATUS Status; ACPI_FUNCTION_NAME ("EvSaveMethodInfo"); /* Extract the name from the object and convert to a string */ ACPI_MOVE_UNALIGNED32_TO_32 (Name, &((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Integer); Name[ACPI_NAME_SIZE] = 0; /* * Edge/Level determination is based on the 2nd character of the method name */ switch (Name[1]) { case 'L': Type = ACPI_EVENT_LEVEL_TRIGGERED; break; case 'E': Type = ACPI_EVENT_EDGE_TRIGGERED; break; default: /* Unknown method type, just ignore it! */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown GPE method type: %s (name not of form _Lnn or _Enn)\n", Name)); return (AE_OK); } /* Convert the last two characters of the name to the GPE Number */ GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16); if (GpeNumber == ACPI_UINT32_MAX) { /* Conversion failed; invalid method, just ignore it */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not extract GPE number from name: %s (name not of form _Lnn or _Enn)\n", Name)); return (AE_OK); } /* Get GPE index and ensure that we have a valid GPE number */ GpeNumberIndex = AcpiEvGetGpeNumberIndex (GpeNumber); if (GpeNumberIndex == ACPI_GPE_INVALID) { /* Not valid, all we can do here is ignore it */ return (AE_OK); } /* * Now we can add this information to the GpeInfo block * for use during dispatch of this GPE. */ AcpiGbl_GpeNumberInfo [GpeNumberIndex].Type = Type; AcpiGbl_GpeNumberInfo [GpeNumberIndex].MethodHandle = ObjHandle; /* * Enable the GPE (SCIs should be disabled at this point) */ Status = AcpiHwEnableGpe (GpeNumber); if (ACPI_FAILURE (Status)) { return (Status); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Registered GPE method %s as GPE number %X\n", Name, GpeNumber)); return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiEvInitGpeControlMethods * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Obtain the control methods associated with the GPEs. * NOTE: Must be called AFTER namespace initialization! * ******************************************************************************/ ACPI_STATUS AcpiEvInitGpeControlMethods (void) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("EvInitGpeControlMethods"); /* Get a permanent handle to the _GPE object */ Status = AcpiGetHandle (NULL, "\\_GPE", &AcpiGbl_GpeObjHandle); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Traverse the namespace under \_GPE to find all methods there */ Status = AcpiWalkNamespace (ACPI_TYPE_METHOD, AcpiGbl_GpeObjHandle, ACPI_UINT32_MAX, AcpiEvSaveMethodInfo, NULL, NULL); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiEvGpeDetect * * PARAMETERS: None * * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED * * DESCRIPTION: Detect if any GP events have occurred. This function is * executed at interrupt level. * ******************************************************************************/ UINT32 AcpiEvGpeDetect (void) { UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; UINT32 i; UINT32 j; UINT8 EnabledStatusByte; UINT8 BitMask; ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; UINT32 InValue; ACPI_STATUS Status; ACPI_FUNCTION_NAME ("EvGpeDetect"); /* * Read all of the 8-bit GPE status and enable registers * in both of the register blocks, saving all of it. * Find all currently active GP events. */ for (i = 0; i < AcpiGbl_GpeRegisterCount; i++) { GpeRegisterInfo = &AcpiGbl_GpeRegisterInfo[i]; Status = AcpiHwLowLevelRead (8, &InValue, &GpeRegisterInfo->StatusAddress, 0); GpeRegisterInfo->Status = (UINT8) InValue; if (ACPI_FAILURE (Status)) { return (ACPI_INTERRUPT_NOT_HANDLED); } Status = AcpiHwLowLevelRead (8, &InValue, &GpeRegisterInfo->EnableAddress, 0); GpeRegisterInfo->Enable = (UINT8) InValue; if (ACPI_FAILURE (Status)) { return (ACPI_INTERRUPT_NOT_HANDLED); } ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, "GPE block at %8.8X%8.8X - Values: Enable %02X Status %02X\n", ACPI_HIDWORD (ACPI_GET_ADDRESS (GpeRegisterInfo->EnableAddress.Address)), ACPI_LODWORD (ACPI_GET_ADDRESS (GpeRegisterInfo->EnableAddress.Address)), GpeRegisterInfo->Enable, GpeRegisterInfo->Status)); /* First check if there is anything active at all in this register */ EnabledStatusByte = (UINT8) (GpeRegisterInfo->Status & GpeRegisterInfo->Enable); if (!EnabledStatusByte) { /* No active GPEs in this register, move on */ continue; } /* Now look at the individual GPEs in this byte register */ for (j = 0, BitMask = 1; j < 8; j++, BitMask <<= 1) { /* Examine one GPE bit */ if (EnabledStatusByte & BitMask) { /* * Found an active GPE. Dispatch the event to a handler * or method. */ IntStatus |= AcpiEvGpeDispatch ( GpeRegisterInfo->BaseGpeNumber + j); } } } return (IntStatus); } /******************************************************************************* * * FUNCTION: AcpiEvAsynchExecuteGpeMethod * * PARAMETERS: GpeNumber - The 0-based GPE number * * RETURN: None * * DESCRIPTION: Perform the actual execution of a GPE control method. This * function is called from an invocation of AcpiOsQueueForExecution * (and therefore does NOT execute at interrupt level) so that * the control method itself is not executed in the context of * the SCI interrupt handler. * ******************************************************************************/ static void ACPI_SYSTEM_XFACE AcpiEvAsynchExecuteGpeMethod ( void *Context) { UINT32 GpeNumber = (UINT32) ACPI_TO_INTEGER (Context); UINT32 GpeNumberIndex; ACPI_GPE_NUMBER_INFO GpeInfo; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("EvAsynchExecuteGpeMethod"); GpeNumberIndex = AcpiEvGetGpeNumberIndex (GpeNumber); if (GpeNumberIndex == ACPI_GPE_INVALID) { return_VOID; } /* * Take a snapshot of the GPE info for this level - we copy the * info to prevent a race condition with RemoveHandler. */ Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); if (ACPI_FAILURE (Status)) { return_VOID; } GpeInfo = AcpiGbl_GpeNumberInfo [GpeNumberIndex]; Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); if (ACPI_FAILURE (Status)) { return_VOID; } if (GpeInfo.MethodHandle) { /* * Invoke the GPE Method (_Lxx, _Exx): * (Evaluate the _Lxx/_Exx control method that corresponds to this GPE.) */ Status = AcpiNsEvaluateByHandle (GpeInfo.MethodHandle, NULL, NULL); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_ERROR (("%s while evaluated GPE%X method\n", + ACPI_REPORT_ERROR (("%s while evaluating GPE%X method\n", AcpiFormatException (Status), GpeNumber)); } } if (GpeInfo.Type & ACPI_EVENT_LEVEL_TRIGGERED) { /* * GPE is level-triggered, we clear the GPE status bit after handling * the event. */ Status = AcpiHwClearGpe (GpeNumber); if (ACPI_FAILURE (Status)) { return_VOID; } } /* * Enable the GPE. */ (void) AcpiHwEnableGpe (GpeNumber); return_VOID; } /******************************************************************************* * * FUNCTION: AcpiEvGpeDispatch * * PARAMETERS: GpeNumber - The 0-based GPE number * * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED * * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC) * or method (e.g. _Lxx/_Exx) handler. This function executes * at interrupt level. * ******************************************************************************/ UINT32 AcpiEvGpeDispatch ( UINT32 GpeNumber) { UINT32 GpeNumberIndex; ACPI_GPE_NUMBER_INFO *GpeInfo; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("EvGpeDispatch"); GpeNumberIndex = AcpiEvGetGpeNumberIndex (GpeNumber); if (GpeNumberIndex == ACPI_GPE_INVALID) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid event, GPE[%X].\n", GpeNumber)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "GPE[%X] is not a valid event\n", GpeNumber)); return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); } /* * We don't have to worry about mutex on GpeInfo because we are * executing at interrupt level. */ GpeInfo = &AcpiGbl_GpeNumberInfo [GpeNumberIndex]; /* * If edge-triggered, clear the GPE status bit now. Note that * level-triggered events are cleared after the GPE is serviced. */ if (GpeInfo->Type & ACPI_EVENT_EDGE_TRIGGERED) { Status = AcpiHwClearGpe (GpeNumber); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("AcpiEvGpeDispatch: Unable to clear GPE[%X]\n", GpeNumber)); return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); } } /* * Dispatch the GPE to either an installed handler, or the control * method associated with this GPE (_Lxx or _Exx). * If a handler exists, we invoke it and do not attempt to run the method. * If there is neither a handler nor a method, we disable the level to * prevent further events from coming in here. */ if (GpeInfo->Handler) { /* Invoke the installed handler (at interrupt level) */ GpeInfo->Handler (GpeInfo->Context); } else if (GpeInfo->MethodHandle) { /* * Disable GPE, so it doesn't keep firing before the method has a * chance to run. */ Status = AcpiHwDisableGpe (GpeNumber); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("AcpiEvGpeDispatch: Unable to disable GPE[%X]\n", GpeNumber)); return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); } /* * Execute the method associated with the GPE. */ if (ACPI_FAILURE (AcpiOsQueueForExecution (OSD_PRIORITY_GPE, AcpiEvAsynchExecuteGpeMethod, ACPI_TO_POINTER (GpeNumber)))) { ACPI_REPORT_ERROR (("AcpiEvGpeDispatch: Unable to queue handler for GPE[%X], event is disabled\n", GpeNumber)); } } else { /* No handler or method to run! */ ACPI_REPORT_ERROR (("AcpiEvGpeDispatch: No handler or method for GPE[%X], disabling event\n", GpeNumber)); /* * Disable the GPE. The GPE will remain disabled until the ACPI * Core Subsystem is restarted, or the handler is reinstalled. */ Status = AcpiHwDisableGpe (GpeNumber); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("AcpiEvGpeDispatch: Unable to disable GPE[%X]\n", GpeNumber)); return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); } } /* * It is now safe to clear level-triggered evnets. */ if (GpeInfo->Type & ACPI_EVENT_LEVEL_TRIGGERED) { Status = AcpiHwClearGpe (GpeNumber); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("AcpiEvGpeDispatch: Unable to clear GPE[%X]\n", GpeNumber)); return_VALUE (ACPI_INTERRUPT_NOT_HANDLED); } } return_VALUE (ACPI_INTERRUPT_HANDLED); } diff --git a/sys/contrib/dev/acpica/evmisc.c b/sys/contrib/dev/acpica/evmisc.c index 506211273b68..7213611ea441 100644 --- a/sys/contrib/dev/acpica/evmisc.c +++ b/sys/contrib/dev/acpica/evmisc.c @@ -1,763 +1,764 @@ /****************************************************************************** * * Module Name: evmisc - Miscellaneous event manager support functions - * $Revision: 57 $ + * $Revision: 59 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License * * 2.1. This is your license from Intel Corp. under its intellectual property * rights. You may have additional license terms from the party that provided * you this software, covering your right to use that party's intellectual * property rights. * * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a * copy of the source code appearing in this file ("Covered Code") an * irrevocable, perpetual, worldwide license under Intel's copyrights in the * base code distributed originally by Intel ("Original Intel Code") to copy, * make derivatives, distribute, use and display any portion of the Covered * Code in any form, with the right to sublicense such rights; and * * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent * license (with the right to sublicense), under only those claims of Intel * patents that are infringed by the Original Intel Code, to make, use, sell, * offer to sell, and import the Covered Code and derivative works thereof * solely to the minimum extent necessary to exercise the above copyright * license, and in no event shall the patent license extend to any additions * to or modifications of the Original Intel Code. No other license or right * is granted directly or by implication, estoppel or otherwise; * * The above copyright and patent license is granted only if the following * conditions are met: * * 3. Conditions * * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, * and the following Disclaimer and Export Compliance provision. In addition, * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the * documentation and/or other materials provided with distribution. In * addition, Licensee may not authorize further sublicense of source of any * portion of the Covered Code, and must include terms to the effect that the * license from Licensee to its licensee is limited to the intellectual * property embodied in the software Licensee provides to its licensee, and * not to intellectual property embodied in modifications its licensee may * make. * * 3.3. Redistribution of Executable. Redistribution in executable form of any * substantial portion of the Covered Code or modification must reproduce the * above Copyright Notice, and the following Disclaimer and Export Compliance * provision in the documentation and/or other materials provided with the * distribution. * * 3.4. Intel retains all right, title, and interest in and to the Original * Intel Code. * * 3.5. Neither the name Intel nor any other trademark owned or controlled by * Intel shall be used in advertising or otherwise to promote the sale, use or * other dealings in products derived from or relating to the Covered Code * without prior written authorization from Intel. * * 4. Disclaimer and Export Compliance * * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY * LIMITED REMEDY. * * 4.3. Licensee shall not export, either directly or indirectly, any of this * software or system incorporating such software without first obtaining any * required license or other approval from the U. S. Department of Commerce or * any other agency or department of the United States Government. In the * event Licensee exports any such software from the United States or * re-exports any such software from a foreign destination, Licensee shall * ensure that the distribution and export/re-export of the software is in * compliance with all laws, regulations, orders, or other restrictions of the * U.S. Export Administration Regulations. Licensee agrees that neither it nor * any of its subsidiaries will export/re-export any technical data, process, * software, or service, directly or indirectly, to any country for which the * United States government or any agency thereof requires an export license, * other governmental approval, or letter of assurance, without first obtaining * such license, approval or letter. * *****************************************************************************/ #include "acpi.h" #include "acevents.h" #include "acnamesp.h" #include "acinterp.h" #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evmisc") /******************************************************************************* * * FUNCTION: AcpiEvIsNotifyObject * * PARAMETERS: Node - Node to check * * RETURN: TRUE if notifies allowed on this object * * DESCRIPTION: Check type of node for a object that supports notifies. * * TBD: This could be replaced by a flag bit in the node. * ******************************************************************************/ BOOLEAN AcpiEvIsNotifyObject ( ACPI_NAMESPACE_NODE *Node) { switch (Node->Type) { case ACPI_TYPE_DEVICE: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: case ACPI_TYPE_THERMAL: /* * These are the ONLY objects that can receive ACPI notifications */ return (TRUE); default: return (FALSE); } } /******************************************************************************* * * FUNCTION: AcpiEvGetGpeRegisterIndex * * PARAMETERS: GpeNumber - Raw GPE number * * RETURN: None. * * DESCRIPTION: Returns the register index (index into the GPE register info * table) associated with this GPE. * ******************************************************************************/ UINT32 AcpiEvGetGpeRegisterIndex ( UINT32 GpeNumber) { if (GpeNumber > AcpiGbl_GpeNumberMax) { return (ACPI_GPE_INVALID); } return (ACPI_DIV_8 (AcpiGbl_GpeNumberToIndex[GpeNumber].NumberIndex)); } /******************************************************************************* * * FUNCTION: AcpiEvGetGpeNumberIndex * * PARAMETERS: GpeNumber - Raw GPE number * * RETURN: None. * * DESCRIPTION: Returns the number index (index into the GPE number info table) * associated with this GPE. * ******************************************************************************/ UINT32 AcpiEvGetGpeNumberIndex ( UINT32 GpeNumber) { if (GpeNumber > AcpiGbl_GpeNumberMax) { return (ACPI_GPE_INVALID); } return (AcpiGbl_GpeNumberToIndex[GpeNumber].NumberIndex); } /******************************************************************************* * * FUNCTION: AcpiEvQueueNotifyRequest * * PARAMETERS: * * RETURN: None. * * DESCRIPTION: Dispatch a device notification event to a previously * installed handler. * ******************************************************************************/ ACPI_STATUS AcpiEvQueueNotifyRequest ( ACPI_NAMESPACE_NODE *Node, UINT32 NotifyValue) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *HandlerObj = NULL; ACPI_GENERIC_STATE *NotifyInfo; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_NAME ("EvQueueNotifyRequest"); /* * For value 1 (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 0x80 (Status Change) on the power button or sleep button, * initiate soft-off or sleep operation? */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Dispatching Notify(%X) on node %p\n", NotifyValue, Node)); switch (NotifyValue) { case 0: ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Re-enumerate Devices\n")); break; case 1: ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Ejection Request\n")); break; case 2: ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Device Wake\n")); break; case 0x80: ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Notify value: Status Change\n")); break; default: ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Unknown Notify Value: %X \n", NotifyValue)); break; } /* * Get the notify object attached to the NS Node */ ObjDesc = AcpiNsGetAttachedObject (Node); if (ObjDesc) { /* We have the notify object, Get the right handler */ switch (Node->Type) { case ACPI_TYPE_DEVICE: case ACPI_TYPE_THERMAL: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) { HandlerObj = ObjDesc->CommonNotify.SysHandler; } else { HandlerObj = ObjDesc->CommonNotify.DrvHandler; } break; default: /* All other types are not supported */ return (AE_TYPE); } } /* If there is any handler to run, schedule the dispatcher */ if ((AcpiGbl_SysNotify.Handler && (NotifyValue <= ACPI_MAX_SYS_NOTIFY)) || (AcpiGbl_DrvNotify.Handler && (NotifyValue > ACPI_MAX_SYS_NOTIFY)) || HandlerObj) { NotifyInfo = AcpiUtCreateGenericState (); if (!NotifyInfo) { return (AE_NO_MEMORY); } NotifyInfo->Common.DataType = ACPI_DESC_TYPE_STATE_NOTIFY; NotifyInfo->Notify.Node = Node; NotifyInfo->Notify.Value = (UINT16) NotifyValue; NotifyInfo->Notify.HandlerObj = HandlerObj; Status = AcpiOsQueueForExecution (OSD_PRIORITY_HIGH, AcpiEvNotifyDispatch, NotifyInfo); if (ACPI_FAILURE (Status)) { AcpiUtDeleteGenericState (NotifyInfo); } } if (!HandlerObj) { /* There is no per-device notify handler for this device */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "No notify handler for node %p \n", Node)); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "No notify handler for [%4.4s] node %p\n", Node->Name.Ascii, Node)); } return (Status); } /******************************************************************************* * * FUNCTION: AcpiEvNotifyDispatch * * PARAMETERS: * * RETURN: None. * * DESCRIPTION: Dispatch a device notification event to a previously * installed handler. * ******************************************************************************/ void ACPI_SYSTEM_XFACE AcpiEvNotifyDispatch ( void *Context) { ACPI_GENERIC_STATE *NotifyInfo = (ACPI_GENERIC_STATE *) Context; ACPI_NOTIFY_HANDLER GlobalHandler = NULL; void *GlobalContext = NULL; ACPI_OPERAND_OBJECT *HandlerObj; ACPI_FUNCTION_ENTRY (); /* * We will invoke a global notify handler if installed. * This is done _before_ we invoke the per-device handler attached to the device. */ if (NotifyInfo->Notify.Value <= ACPI_MAX_SYS_NOTIFY) { /* Global system notification handler */ if (AcpiGbl_SysNotify.Handler) { GlobalHandler = AcpiGbl_SysNotify.Handler; GlobalContext = AcpiGbl_SysNotify.Context; } } else { /* Global driver notification handler */ if (AcpiGbl_DrvNotify.Handler) { GlobalHandler = AcpiGbl_DrvNotify.Handler; GlobalContext = AcpiGbl_DrvNotify.Context; } } /* Invoke the system handler first, if present */ if (GlobalHandler) { GlobalHandler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value, GlobalContext); } /* Now invoke the per-device handler, if present */ HandlerObj = NotifyInfo->Notify.HandlerObj; if (HandlerObj) { HandlerObj->NotifyHandler.Handler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value, HandlerObj->NotifyHandler.Context); } /* All done with the info object */ AcpiUtDeleteGenericState (NotifyInfo); } /******************************************************************************* * * FUNCTION: AcpiEvGlobalLockThread * * RETURN: None * * DESCRIPTION: Invoked by SCI interrupt handler upon acquisition of the * Global Lock. Simply signal all threads that are waiting * for the lock. * ******************************************************************************/ static void ACPI_SYSTEM_XFACE AcpiEvGlobalLockThread ( void *Context) { ACPI_STATUS Status; /* Signal threads that are waiting for the lock */ if (AcpiGbl_GlobalLockThreadCount) { /* Send sufficient units to the semaphore */ Status = AcpiOsSignalSemaphore (AcpiGbl_GlobalLockSemaphore, AcpiGbl_GlobalLockThreadCount); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("Could not signal Global Lock semaphore\n")); } } } /******************************************************************************* * * FUNCTION: AcpiEvGlobalLockHandler * * RETURN: Status * * DESCRIPTION: Invoked directly from the SCI handler when a global lock * release interrupt occurs. Grab the global lock and queue * the global lock thread for execution * ******************************************************************************/ static UINT32 AcpiEvGlobalLockHandler ( void *Context) { BOOLEAN Acquired = FALSE; ACPI_STATUS Status; /* * Attempt to get the lock * If we don't get it now, it will be marked pending and we will * take another interrupt when it becomes free. */ ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_CommonFACS.GlobalLock, Acquired); if (Acquired) { /* Got the lock, now wake all threads waiting for it */ AcpiGbl_GlobalLockAcquired = TRUE; /* Run the Global Lock thread which will signal all waiting threads */ Status = AcpiOsQueueForExecution (OSD_PRIORITY_HIGH, AcpiEvGlobalLockThread, Context); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("Could not queue Global Lock thread, %s\n", AcpiFormatException (Status))); return (ACPI_INTERRUPT_NOT_HANDLED); } } return (ACPI_INTERRUPT_HANDLED); } /******************************************************************************* * * FUNCTION: AcpiEvInitGlobalLockHandler * * RETURN: Status * * DESCRIPTION: Install a handler for the global lock release event * ******************************************************************************/ ACPI_STATUS AcpiEvInitGlobalLockHandler (void) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("EvInitGlobalLockHandler"); AcpiGbl_GlobalLockPresent = TRUE; Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, AcpiEvGlobalLockHandler, NULL); /* * If the global lock does not exist on this platform, the attempt * to enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick) * Map to AE_OK, but mark global lock as not present. * Any attempt to actually use the global lock will be flagged * with an error. */ if (Status == AE_NO_HARDWARE_RESPONSE) { AcpiGbl_GlobalLockPresent = FALSE; Status = AE_OK; } return_ACPI_STATUS (Status); } /****************************************************************************** * * FUNCTION: AcpiEvAcquireGlobalLock * * RETURN: Status * * DESCRIPTION: Attempt to gain ownership of the Global Lock. * *****************************************************************************/ ACPI_STATUS AcpiEvAcquireGlobalLock ( - UINT32 Timeout) + UINT16 Timeout) { ACPI_STATUS Status = AE_OK; BOOLEAN Acquired = FALSE; ACPI_FUNCTION_TRACE ("EvAcquireGlobalLock"); #ifndef ACPI_APPLICATION /* Make sure that we actually have a global lock */ if (!AcpiGbl_GlobalLockPresent) { return_ACPI_STATUS (AE_NO_GLOBAL_LOCK); } #endif /* One more thread wants the global lock */ AcpiGbl_GlobalLockThreadCount++; /* If we (OS side vs. BIOS side) have the hardware lock already, we are done */ if (AcpiGbl_GlobalLockAcquired) { return_ACPI_STATUS (AE_OK); } /* We must acquire the actual hardware lock */ ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_CommonFACS.GlobalLock, Acquired); if (Acquired) { /* We got the lock */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Acquired the HW Global Lock\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired the HW Global Lock\n")); AcpiGbl_GlobalLockAcquired = TRUE; return_ACPI_STATUS (AE_OK); } /* * Did not get the lock. The pending bit was set above, and we must now * wait until we get the global lock released interrupt. */ - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Waiting for the HW Global Lock\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for the HW Global Lock\n")); /* * Acquire the global lock semaphore first. * Since this wait will block, we must release the interpreter */ Status = AcpiExSystemWaitSemaphore (AcpiGbl_GlobalLockSemaphore, Timeout); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiEvReleaseGlobalLock * * DESCRIPTION: Releases ownership of the Global Lock. * ******************************************************************************/ ACPI_STATUS AcpiEvReleaseGlobalLock (void) { BOOLEAN Pending = FALSE; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("EvReleaseGlobalLock"); if (!AcpiGbl_GlobalLockThreadCount) { ACPI_REPORT_WARNING(("Cannot release HW Global Lock, it has not been acquired\n")); return_ACPI_STATUS (AE_NOT_ACQUIRED); } /* One fewer thread has the global lock */ AcpiGbl_GlobalLockThreadCount--; if (AcpiGbl_GlobalLockThreadCount) { /* There are still some threads holding the lock, cannot release */ return_ACPI_STATUS (AE_OK); } /* * No more threads holding lock, we can do the actual hardware * release */ ACPI_RELEASE_GLOBAL_LOCK (AcpiGbl_CommonFACS.GlobalLock, Pending); AcpiGbl_GlobalLockAcquired = FALSE; /* * If the pending bit was set, we must write GBL_RLS to the control * register */ if (Pending) { Status = AcpiSetRegister (ACPI_BITREG_GLOBAL_LOCK_RELEASE, 1, ACPI_MTX_LOCK); } return_ACPI_STATUS (Status); } /****************************************************************************** * * FUNCTION: AcpiEvTerminate * * PARAMETERS: none * * RETURN: none * * DESCRIPTION: Disable events and free memory allocated for table storage. * ******************************************************************************/ void AcpiEvTerminate (void) { NATIVE_UINT_MAX32 i; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("EvTerminate"); if (AcpiGbl_EventsInitialized) { /* * Disable all event-related functionality. * In all cases, on error, print a message but obviously we don't abort. */ /* * Disable all fixed events */ for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) { Status = AcpiDisableEvent(i, ACPI_EVENT_FIXED, 0); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not disable fixed event %d\n", i)); } } /* * Disable all GPEs */ for (i = 0; i < AcpiGbl_GpeNumberMax; i++) { if (AcpiEvGetGpeNumberIndex(i) != ACPI_GPE_INVALID) { Status = AcpiHwDisableGpe(i); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not disable GPE %d\n", i)); } } } /* * Remove SCI handler */ Status = AcpiEvRemoveSciHandler(); if (ACPI_FAILURE(Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not remove SCI handler\n")); } } /* * Return to original mode if necessary */ if (AcpiGbl_OriginalMode == ACPI_SYS_MODE_LEGACY) { Status = AcpiDisable (); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "AcpiDisable failed\n")); } } /* * Free global tables, etc. */ if (AcpiGbl_GpeRegisterInfo) { ACPI_MEM_FREE (AcpiGbl_GpeRegisterInfo); AcpiGbl_GpeRegisterInfo = NULL; } if (AcpiGbl_GpeNumberInfo) { ACPI_MEM_FREE (AcpiGbl_GpeNumberInfo); AcpiGbl_GpeNumberInfo = NULL; } if (AcpiGbl_GpeNumberToIndex) { ACPI_MEM_FREE (AcpiGbl_GpeNumberToIndex); AcpiGbl_GpeNumberToIndex = NULL; } return_VOID; } diff --git a/sys/contrib/dev/acpica/evxface.c b/sys/contrib/dev/acpica/evxface.c index cf8502cb572d..b50e19e7df36 100644 --- a/sys/contrib/dev/acpica/evxface.c +++ b/sys/contrib/dev/acpica/evxface.c @@ -1,817 +1,817 @@ /****************************************************************************** * * Module Name: evxface - External interfaces for ACPI events - * $Revision: 130 $ + * $Revision: 132 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 prton 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 __EVXFACE_C__ #include "acpi.h" #include "acnamesp.h" #include "acevents.h" #include "acinterp.h" #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evxface") /******************************************************************************* * * FUNCTION: AcpiInstallFixedEventHandler * * PARAMETERS: Event - Event type to enable. * Handler - Pointer to the handler function for the * event * Context - Value passed to the handler on each GPE * * RETURN: Status * * DESCRIPTION: Saves the pointer to the handler function and then enables the * event. * ******************************************************************************/ ACPI_STATUS AcpiInstallFixedEventHandler ( UINT32 Event, ACPI_EVENT_HANDLER Handler, void *Context) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("AcpiInstallFixedEventHandler"); /* Parameter validation */ if (Event > ACPI_EVENT_MAX) { return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Don't allow two handlers. */ if (NULL != AcpiGbl_FixedEventHandlers[Event].Handler) { Status = AE_ALREADY_EXISTS; goto Cleanup; } /* Install the handler before enabling the event */ AcpiGbl_FixedEventHandlers[Event].Handler = Handler; AcpiGbl_FixedEventHandlers[Event].Context = Context; Status = AcpiEnableEvent (Event, ACPI_EVENT_FIXED, 0); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Could not enable fixed event.\n")); /* Remove the handler */ AcpiGbl_FixedEventHandlers[Event].Handler = NULL; AcpiGbl_FixedEventHandlers[Event].Context = NULL; } else { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Enabled fixed event %X, Handler=%p\n", Event, Handler)); } Cleanup: (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiRemoveFixedEventHandler * * PARAMETERS: Event - Event type to disable. * Handler - Address of the handler * * RETURN: Status * * DESCRIPTION: Disables the event and unregisters the event handler. * ******************************************************************************/ ACPI_STATUS AcpiRemoveFixedEventHandler ( UINT32 Event, ACPI_EVENT_HANDLER Handler) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("AcpiRemoveFixedEventHandler"); /* Parameter validation */ if (Event > ACPI_EVENT_MAX) { return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Disable the event before removing the handler */ Status = AcpiDisableEvent(Event, ACPI_EVENT_FIXED, 0); /* Always Remove the handler */ AcpiGbl_FixedEventHandlers[Event].Handler = NULL; AcpiGbl_FixedEventHandlers[Event].Context = NULL; if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Could not write to fixed event enable register.\n")); } else { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X.\n", Event)); } (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiInstallNotifyHandler * * PARAMETERS: Device - The device for which notifies will be handled * HandlerType - The type of handler: * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) * Handler - Address of the handler * Context - Value passed to the handler on each GPE * * RETURN: Status * * DESCRIPTION: Install a handler for notifies on an ACPI device * ******************************************************************************/ ACPI_STATUS AcpiInstallNotifyHandler ( ACPI_HANDLE Device, UINT32 HandlerType, ACPI_NOTIFY_HANDLER Handler, void *Context) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *NotifyObj; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("AcpiInstallNotifyHandler"); /* Parameter validation */ if ((!Device) || (!Handler) || (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Convert and validate the device handle */ Node = AcpiNsMapHandleToNode (Device); if (!Node) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } /* * Root Object: * Registering a notify handler on the root object indicates that the * caller wishes to receive notifications for all objects. Note that * only one global handler can be regsitered (per notify type). */ if (Device == ACPI_ROOT_OBJECT) { /* Make sure the handler is not already installed */ if (((HandlerType == ACPI_SYSTEM_NOTIFY) && AcpiGbl_SysNotify.Handler) || ((HandlerType == ACPI_DEVICE_NOTIFY) && AcpiGbl_DrvNotify.Handler)) { Status = AE_ALREADY_EXISTS; goto UnlockAndExit; } if (HandlerType == ACPI_SYSTEM_NOTIFY) { AcpiGbl_SysNotify.Node = Node; AcpiGbl_SysNotify.Handler = Handler; AcpiGbl_SysNotify.Context = Context; } else /* ACPI_DEVICE_NOTIFY */ { AcpiGbl_DrvNotify.Node = Node; AcpiGbl_DrvNotify.Handler = Handler; AcpiGbl_DrvNotify.Context = Context; } /* Global notify handler installed */ } /* * All Other Objects: * Caller will only receive notifications specific to the target object. * Note that only certain object types can receive notifications. */ else { /* Notifies allowed on this object? */ if (!AcpiEvIsNotifyObject (Node)) { Status = AE_TYPE; goto UnlockAndExit; } /* Check for an existing internal object */ ObjDesc = AcpiNsGetAttachedObject (Node); if (ObjDesc) { /* Object exists - make sure there's no handler */ if (((HandlerType == ACPI_SYSTEM_NOTIFY) && ObjDesc->CommonNotify.SysHandler) || ((HandlerType == ACPI_DEVICE_NOTIFY) && ObjDesc->CommonNotify.DrvHandler)) { Status = AE_ALREADY_EXISTS; goto UnlockAndExit; } } else { /* Create a new object */ ObjDesc = AcpiUtCreateInternalObject (Node->Type); if (!ObjDesc) { Status = AE_NO_MEMORY; goto UnlockAndExit; } /* Attach new object to the Node */ Status = AcpiNsAttachObject (Device, ObjDesc, Node->Type); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } } /* Install the handler */ - NotifyObj = AcpiUtCreateInternalObject (INTERNAL_TYPE_NOTIFY); + NotifyObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_NOTIFY); if (!NotifyObj) { Status = AE_NO_MEMORY; goto UnlockAndExit; } NotifyObj->NotifyHandler.Node = Node; NotifyObj->NotifyHandler.Handler = Handler; NotifyObj->NotifyHandler.Context = Context; if (HandlerType == ACPI_SYSTEM_NOTIFY) { ObjDesc->CommonNotify.SysHandler = NotifyObj; } else /* ACPI_DEVICE_NOTIFY */ { ObjDesc->CommonNotify.DrvHandler = NotifyObj; } } UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiRemoveNotifyHandler * * PARAMETERS: Device - The device for which notifies will be handled * HandlerType - The type of handler: * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) * Handler - Address of the handler * RETURN: Status * * DESCRIPTION: Remove a handler for notifies on an ACPI device * ******************************************************************************/ ACPI_STATUS AcpiRemoveNotifyHandler ( ACPI_HANDLE Device, UINT32 HandlerType, ACPI_NOTIFY_HANDLER Handler) { ACPI_OPERAND_OBJECT *NotifyObj; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("AcpiRemoveNotifyHandler"); /* Parameter validation */ if ((!Device) || (!Handler) || (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Convert and validate the device handle */ Node = AcpiNsMapHandleToNode (Device); if (!Node) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } /* * Root Object */ if (Device == ACPI_ROOT_OBJECT) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Removing notify handler for ROOT object.\n")); if (((HandlerType == ACPI_SYSTEM_NOTIFY) && !AcpiGbl_SysNotify.Handler) || ((HandlerType == ACPI_DEVICE_NOTIFY) && !AcpiGbl_DrvNotify.Handler)) { Status = AE_NOT_EXIST; goto UnlockAndExit; } if (HandlerType == ACPI_SYSTEM_NOTIFY) { AcpiGbl_SysNotify.Node = NULL; AcpiGbl_SysNotify.Handler = NULL; AcpiGbl_SysNotify.Context = NULL; } else { AcpiGbl_DrvNotify.Node = NULL; AcpiGbl_DrvNotify.Handler = NULL; AcpiGbl_DrvNotify.Context = NULL; } } /* * All Other Objects */ else { /* Notifies allowed on this object? */ if (!AcpiEvIsNotifyObject (Node)) { Status = AE_TYPE; goto UnlockAndExit; } /* Check for an existing internal object */ ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { Status = AE_NOT_EXIST; goto UnlockAndExit; } /* Object exists - make sure there's an existing handler */ if (HandlerType == ACPI_SYSTEM_NOTIFY) { NotifyObj = ObjDesc->CommonNotify.SysHandler; } else { NotifyObj = ObjDesc->CommonNotify.DrvHandler; } if ((!NotifyObj) || (NotifyObj->NotifyHandler.Handler != Handler)) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } /* Remove the handler */ if (HandlerType == ACPI_SYSTEM_NOTIFY) { ObjDesc->CommonNotify.SysHandler = NULL; } else { ObjDesc->CommonNotify.DrvHandler = NULL; } AcpiUtRemoveReference (NotifyObj); } UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiInstallGpeHandler * * PARAMETERS: GpeNumber - The GPE number. The numbering scheme is * bank 0 first, then bank 1. * Type - Whether this GPE should be treated as an * edge- or level-triggered interrupt. * Handler - Address of the handler * Context - Value passed to the handler on each GPE * * RETURN: Status * * DESCRIPTION: Install a handler for a General Purpose Event. * ******************************************************************************/ ACPI_STATUS AcpiInstallGpeHandler ( UINT32 GpeNumber, UINT32 Type, ACPI_GPE_HANDLER Handler, void *Context) { ACPI_STATUS Status; UINT32 GpeNumberIndex; ACPI_FUNCTION_TRACE ("AcpiInstallGpeHandler"); /* Parameter validation */ if (!Handler) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Ensure that we have a valid GPE number */ GpeNumberIndex = AcpiEvGetGpeNumberIndex (GpeNumber); if (GpeNumberIndex == ACPI_GPE_INVALID) { return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Make sure that there isn't a handler there already */ if (AcpiGbl_GpeNumberInfo[GpeNumberIndex].Handler) { Status = AE_ALREADY_EXISTS; goto Cleanup; } /* Install the handler */ AcpiGbl_GpeNumberInfo[GpeNumberIndex].Handler = Handler; AcpiGbl_GpeNumberInfo[GpeNumberIndex].Context = Context; AcpiGbl_GpeNumberInfo[GpeNumberIndex].Type = (UINT8) Type; /* Clear the GPE (of stale events), the enable it */ Status = AcpiHwClearGpe (GpeNumber); if (ACPI_FAILURE (Status)) { goto Cleanup; } Status = AcpiHwEnableGpe (GpeNumber); Cleanup: (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiRemoveGpeHandler * * PARAMETERS: GpeNumber - The event to remove a handler * Handler - Address of the handler * * RETURN: Status * * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent. * ******************************************************************************/ ACPI_STATUS AcpiRemoveGpeHandler ( UINT32 GpeNumber, ACPI_GPE_HANDLER Handler) { ACPI_STATUS Status; UINT32 GpeNumberIndex; ACPI_FUNCTION_TRACE ("AcpiRemoveGpeHandler"); /* Parameter validation */ if (!Handler) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Ensure that we have a valid GPE number */ GpeNumberIndex = AcpiEvGetGpeNumberIndex (GpeNumber); if (GpeNumberIndex == ACPI_GPE_INVALID) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Disable the GPE before removing the handler */ Status = AcpiHwDisableGpe (GpeNumber); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Make sure that the installed handler is the same */ if (AcpiGbl_GpeNumberInfo[GpeNumberIndex].Handler != Handler) { (void) AcpiHwEnableGpe (GpeNumber); Status = AE_BAD_PARAMETER; goto Cleanup; } /* Remove the handler */ AcpiGbl_GpeNumberInfo[GpeNumberIndex].Handler = NULL; AcpiGbl_GpeNumberInfo[GpeNumberIndex].Context = NULL; Cleanup: (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiAcquireGlobalLock * * PARAMETERS: Timeout - How long the caller is willing to wait * OutHandle - A handle to the lock if acquired * * RETURN: Status * * DESCRIPTION: Acquire the ACPI Global Lock * ******************************************************************************/ ACPI_STATUS AcpiAcquireGlobalLock ( - UINT32 Timeout, + UINT16 Timeout, UINT32 *Handle) { ACPI_STATUS Status; if (!Handle) { return (AE_BAD_PARAMETER); } Status = AcpiExEnterInterpreter (); if (ACPI_FAILURE (Status)) { return (Status); } Status = AcpiEvAcquireGlobalLock (Timeout); AcpiExExitInterpreter (); if (ACPI_SUCCESS (Status)) { AcpiGbl_GlobalLockHandle++; *Handle = AcpiGbl_GlobalLockHandle; } return (Status); } /******************************************************************************* * * FUNCTION: AcpiReleaseGlobalLock * * PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock * * RETURN: Status * * DESCRIPTION: Release the ACPI Global Lock * ******************************************************************************/ ACPI_STATUS AcpiReleaseGlobalLock ( UINT32 Handle) { ACPI_STATUS Status; if (Handle != AcpiGbl_GlobalLockHandle) { return (AE_NOT_ACQUIRED); } Status = AcpiEvReleaseGlobalLock (); return (Status); } diff --git a/sys/contrib/dev/acpica/evxfregn.c b/sys/contrib/dev/acpica/evxfregn.c index 41721d6962d6..6f06b3ae8d6b 100644 --- a/sys/contrib/dev/acpica/evxfregn.c +++ b/sys/contrib/dev/acpica/evxfregn.c @@ -1,520 +1,520 @@ /****************************************************************************** * * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and * Address Spaces. - * $Revision: 50 $ + * $Revision: 52 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 prton 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 __EVXFREGN_C__ #include "acpi.h" #include "acnamesp.h" #include "acevents.h" #include "acinterp.h" #define _COMPONENT ACPI_EVENTS ACPI_MODULE_NAME ("evxfregn") /******************************************************************************* * * FUNCTION: AcpiInstallAddressSpaceHandler * * PARAMETERS: Device - Handle for the device * SpaceId - The address space ID * Handler - Address of the handler * Setup - Address of the setup function * Context - Value passed to the handler on each access * * RETURN: Status * * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId. * ******************************************************************************/ ACPI_STATUS AcpiInstallAddressSpaceHandler ( ACPI_HANDLE Device, ACPI_ADR_SPACE_TYPE SpaceId, ACPI_ADR_SPACE_HANDLER Handler, ACPI_ADR_SPACE_SETUP Setup, void *Context) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *HandlerObj; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_OBJECT_TYPE Type; UINT16 Flags = 0; ACPI_FUNCTION_TRACE ("AcpiInstallAddressSpaceHandler"); /* Parameter validation */ if (!Device) { return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Convert and validate the device handle */ Node = AcpiNsMapHandleToNode (Device); if (!Node) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } /* * This registration is valid for only the types below * and the root. This is where the default handlers * get placed. */ if ((Node->Type != ACPI_TYPE_DEVICE) && (Node->Type != ACPI_TYPE_PROCESSOR) && (Node->Type != ACPI_TYPE_THERMAL) && (Node != AcpiGbl_RootNode)) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } if (Handler == ACPI_DEFAULT_HANDLER) { Flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED; switch (SpaceId) { case ACPI_ADR_SPACE_SYSTEM_MEMORY: Handler = AcpiExSystemMemorySpaceHandler; Setup = AcpiEvSystemMemoryRegionSetup; break; case ACPI_ADR_SPACE_SYSTEM_IO: Handler = AcpiExSystemIoSpaceHandler; Setup = AcpiEvIoSpaceRegionSetup; break; case ACPI_ADR_SPACE_PCI_CONFIG: Handler = AcpiExPciConfigSpaceHandler; Setup = AcpiEvPciConfigRegionSetup; break; case ACPI_ADR_SPACE_CMOS: Handler = AcpiExCmosSpaceHandler; Setup = AcpiEvCmosRegionSetup; break; case ACPI_ADR_SPACE_PCI_BAR_TARGET: Handler = AcpiExPciBarSpaceHandler; Setup = AcpiEvPciBarRegionSetup; break; case ACPI_ADR_SPACE_DATA_TABLE: Handler = AcpiExDataTableSpaceHandler; Setup = NULL; break; default: Status = AE_NOT_EXIST; goto UnlockAndExit; } } /* * If the caller hasn't specified a setup routine, use the default */ if (!Setup) { Setup = AcpiEvDefaultRegionSetup; } /* * Check for an existing internal object */ ObjDesc = AcpiNsGetAttachedObject (Node); if (ObjDesc) { /* * The object exists. * Make sure the handler is not already installed. */ /* check the address handler the user requested */ HandlerObj = ObjDesc->Device.AddrHandler; while (HandlerObj) { /* * We have an Address handler, see if user requested this * address space. */ if(HandlerObj->AddrHandler.SpaceId == SpaceId) { Status = AE_ALREADY_EXISTS; goto UnlockAndExit; } /* * Move through the linked list of handlers */ HandlerObj = HandlerObj->AddrHandler.Next; } } else { ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "Creating object on Device %p while installing handler\n", Node)); /* ObjDesc does not exist, create one */ if (Node->Type == ACPI_TYPE_ANY) { Type = ACPI_TYPE_DEVICE; } else { Type = Node->Type; } ObjDesc = AcpiUtCreateInternalObject (Type); if (!ObjDesc) { Status = AE_NO_MEMORY; goto UnlockAndExit; } /* Init new descriptor */ ObjDesc->Common.Type = (UINT8) Type; /* Attach the new object to the Node */ Status = AcpiNsAttachObject (Node, ObjDesc, Type); if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ObjDesc); goto UnlockAndExit; } } ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, - "Installing address handler for region %s(%X) on Device %p(%p)\n", - AcpiUtGetRegionName (SpaceId), SpaceId, Node, ObjDesc)); + "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", + AcpiUtGetRegionName (SpaceId), SpaceId, Node->Name.Ascii, Node, ObjDesc)); /* * Now we can install the handler * * At this point we know that there is no existing handler. * So, we just allocate the object for the handler and link it * into the list. */ - HandlerObj = AcpiUtCreateInternalObject (INTERNAL_TYPE_ADDRESS_HANDLER); + HandlerObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_ADDRESS_HANDLER); if (!HandlerObj) { Status = AE_NO_MEMORY; goto UnlockAndExit; } HandlerObj->AddrHandler.SpaceId = (UINT8) SpaceId; HandlerObj->AddrHandler.Hflags = Flags; HandlerObj->AddrHandler.Next = ObjDesc->Device.AddrHandler; HandlerObj->AddrHandler.RegionList = NULL; HandlerObj->AddrHandler.Node = Node; HandlerObj->AddrHandler.Handler = Handler; HandlerObj->AddrHandler.Context = Context; HandlerObj->AddrHandler.Setup = Setup; /* * Now walk the namespace finding all of the regions this * handler will manage. * * We start at the device and search the branch toward * the leaf nodes until either the leaf is encountered or * a device is detected that has an address handler of the * same type. * * In either case we back up and search down the remainder * of the branch */ Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Device, ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, AcpiEvAddrHandlerHelper, HandlerObj, NULL); /* * Place this handler 1st on the list */ HandlerObj->Common.ReferenceCount = (UINT16) (HandlerObj->Common.ReferenceCount + ObjDesc->Common.ReferenceCount - 1); ObjDesc->Device.AddrHandler = HandlerObj; UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiRemoveAddressSpaceHandler * * PARAMETERS: SpaceId - The address space ID * Handler - Address of the handler * * RETURN: Status * * DESCRIPTION: Install a handler for accesses on an Operation Region * ******************************************************************************/ ACPI_STATUS AcpiRemoveAddressSpaceHandler ( ACPI_HANDLE Device, ACPI_ADR_SPACE_TYPE SpaceId, ACPI_ADR_SPACE_HANDLER Handler) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *HandlerObj; ACPI_OPERAND_OBJECT *RegionObj; ACPI_OPERAND_OBJECT **LastObjPtr; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("AcpiRemoveAddressSpaceHandler"); /* Parameter validation */ if (!Device) { return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Convert and validate the device handle */ Node = AcpiNsMapHandleToNode (Device); if (!Node) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } /* Make sure the internal object exists */ ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { Status = AE_NOT_EXIST; goto UnlockAndExit; } /* * find the address handler the user requested */ HandlerObj = ObjDesc->Device.AddrHandler; LastObjPtr = &ObjDesc->Device.AddrHandler; while (HandlerObj) { /* * We have a handler, see if user requested this one */ if (HandlerObj->AddrHandler.SpaceId == SpaceId) { /* * Got it, first dereference this in the Regions */ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "Removing address handler %p(%p) for region %s on Device %p(%p)\n", HandlerObj, Handler, AcpiUtGetRegionName (SpaceId), Node, ObjDesc)); RegionObj = HandlerObj->AddrHandler.RegionList; /* Walk the handler's region list */ while (RegionObj) { /* * First disassociate the handler from the region. * * NOTE: this doesn't mean that the region goes away * The region is just inaccessible as indicated to * the _REG method */ AcpiEvDetachRegion (RegionObj, TRUE); /* * Walk the list, since we took the first region and it * was removed from the list by the dissassociate call * we just get the first item on the list again */ RegionObj = HandlerObj->AddrHandler.RegionList; } /* * Remove this Handler object from the list */ *LastObjPtr = HandlerObj->AddrHandler.Next; /* * Now we can delete the handler object */ AcpiUtRemoveReference (HandlerObj); AcpiUtRemoveReference (HandlerObj); goto UnlockAndExit; } /* * Move through the linked list of handlers */ LastObjPtr = &HandlerObj->AddrHandler.Next; HandlerObj = HandlerObj->AddrHandler.Next; } /* * The handler does not exist */ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "Unable to remove address handler %p for %s(%X), DevNode %p, obj %p\n", Handler, AcpiUtGetRegionName (SpaceId), SpaceId, Node, ObjDesc)); Status = AE_NOT_EXIST; UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exconfig.c b/sys/contrib/dev/acpica/exconfig.c index e473771916fb..409f2d36024e 100644 --- a/sys/contrib/dev/acpica/exconfig.c +++ b/sys/contrib/dev/acpica/exconfig.c @@ -1,564 +1,563 @@ /****************************************************************************** * * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes) - * $Revision: 67 $ + * $Revision: 69 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXCONFIG_C__ #include "acpi.h" #include "acinterp.h" #include "amlcode.h" #include "acnamesp.h" #include "acevents.h" #include "actables.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exconfig") /******************************************************************************* * * FUNCTION: AcpiExAddTable * * PARAMETERS: Table - Pointer to raw table * ParentNode - Where to load the table (scope) * DdbHandle - Where to return the table handle. * * RETURN: Status * * DESCRIPTION: Common function to Install and Load an ACPI table with a * returned table handle. * ******************************************************************************/ ACPI_STATUS AcpiExAddTable ( ACPI_TABLE_HEADER *Table, ACPI_NAMESPACE_NODE *ParentNode, ACPI_OPERAND_OBJECT **DdbHandle) { ACPI_STATUS Status; ACPI_TABLE_DESC TableInfo; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_TRACE ("ExAddTable"); /* Create an object to be the table handle */ - ObjDesc = AcpiUtCreateInternalObject (INTERNAL_TYPE_REFERENCE); + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Install the new table into the local data structures */ TableInfo.Pointer = Table; TableInfo.Length = (ACPI_SIZE) Table->Length; TableInfo.Allocation = ACPI_MEM_ALLOCATED; - TableInfo.BasePointer = Table; Status = AcpiTbInstallTable (&TableInfo); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Add the table to the namespace */ Status = AcpiNsLoadTable (TableInfo.InstalledDesc, ParentNode); if (ACPI_FAILURE (Status)) { /* Uninstall table on error */ (void) AcpiTbUninstallTable (TableInfo.InstalledDesc); 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); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExLoadTableOp * * PARAMETERS: WalkState - Current state with operands * ReturnDesc - Where to store the return object * * RETURN: Status * * DESCRIPTION: Load an ACPI table * ******************************************************************************/ ACPI_STATUS AcpiExLoadTableOp ( ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT **ReturnDesc) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_TABLE_HEADER *Table; ACPI_NAMESPACE_NODE *ParentNode; ACPI_NAMESPACE_NODE *StartNode; ACPI_NAMESPACE_NODE *ParameterNode = NULL; ACPI_OPERAND_OBJECT *DdbHandle; ACPI_FUNCTION_TRACE ("ExLoadTableOp"); #if 0 /* * Make sure that the signature does not match one of the tables that * is already loaded. */ Status = AcpiTbMatchSignature (Operand[0]->String.Pointer, NULL); if (Status == AE_OK) { /* Signature matched -- don't allow override */ return_ACPI_STATUS (AE_ALREADY_EXISTS); } #endif /* Find the ACPI table */ Status = AcpiTbFindTable (Operand[0]->String.Pointer, Operand[1]->String.Pointer, Operand[2]->String.Pointer, &Table); if (ACPI_FAILURE (Status)) { if (Status != AE_NOT_FOUND) { return_ACPI_STATUS (Status); } /* Not found, return an Integer=0 and AE_OK */ DdbHandle = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!DdbHandle) { return_ACPI_STATUS (AE_NO_MEMORY); } DdbHandle->Integer.Value = 0; *ReturnDesc = DdbHandle; return_ACPI_STATUS (AE_OK); } /* Default nodes */ StartNode = WalkState->ScopeInfo->Scope.Node; ParentNode = AcpiGbl_RootNode; /* RootPath (optional parameter) */ if (Operand[3]->String.Length > 0) { /* * Find the node referenced by the RootPathString. This is the * location within the namespace where the table will be loaded. */ Status = AcpiNsGetNodeByPath (Operand[3]->String.Pointer, StartNode, ACPI_NS_SEARCH_PARENT, &ParentNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* ParameterPath (optional parameter) */ if (Operand[4]->String.Length > 0) { if ((Operand[4]->String.Pointer[0] != '\\') && (Operand[4]->String.Pointer[0] != '^')) { /* * Path is not absolute, so it will be relative to the node * referenced by the RootPathString (or the NS root if omitted) */ StartNode = ParentNode; } /* * Find the node referenced by the ParameterPathString */ Status = AcpiNsGetNodeByPath (Operand[4]->String.Pointer, StartNode, ACPI_NS_SEARCH_PARENT, &ParameterNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* Load the table into the namespace */ Status = AcpiExAddTable (Table, ParentNode, &DdbHandle); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Parameter Data (optional) */ if (ParameterNode) { /* Store the parameter data into the optional parameter object */ Status = AcpiExStore (Operand[5], ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), WalkState); if (ACPI_FAILURE (Status)) { (void) AcpiExUnloadTable (DdbHandle); } } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExLoadOp * * PARAMETERS: ObjDesc - Region or Field where the table will be * obtained * Target - Where a handle to the table will be stored * WalkState - Current state * * RETURN: Status * * DESCRIPTION: Load an ACPI table from a field or operation region * ******************************************************************************/ ACPI_STATUS AcpiExLoadOp ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT *Target, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *DdbHandle; ACPI_OPERAND_OBJECT *BufferDesc = NULL; ACPI_TABLE_HEADER *TablePtr = NULL; UINT8 *TableDataPtr; ACPI_TABLE_HEADER TableHeader; UINT32 i; ACPI_FUNCTION_TRACE ("ExLoadOp"); /* Object can be either an OpRegion or a Field */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_REGION: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Region %p %s\n", ObjDesc, AcpiUtGetObjectTypeName (ObjDesc))); /* Get the table header */ TableHeader.Length = 0; for (i = 0; i < sizeof (ACPI_TABLE_HEADER); i++) { Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, (ACPI_PHYSICAL_ADDRESS) i, 8, ((UINT8 *) &TableHeader) + i); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* Allocate a buffer for the entire table */ TablePtr = ACPI_MEM_ALLOCATE (TableHeader.Length); if (!TablePtr) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Copy the header to the buffer */ ACPI_MEMCPY (TablePtr, &TableHeader, sizeof (ACPI_TABLE_HEADER)); TableDataPtr = ACPI_PTR_ADD (UINT8, TablePtr, sizeof (ACPI_TABLE_HEADER)); /* Get the table from the op region */ for (i = 0; i < TableHeader.Length; i++) { Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, (ACPI_PHYSICAL_ADDRESS) i, 8, ((UINT8 *) TableDataPtr + i)); if (ACPI_FAILURE (Status)) { goto Cleanup; } } break; case ACPI_TYPE_BUFFER_FIELD: - case INTERNAL_TYPE_REGION_FIELD: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Load from Field %p %s\n", ObjDesc, AcpiUtGetObjectTypeName (ObjDesc))); /* * The length of the field must be at least as large as the table. * Read the entire field and thus the entire table. Buffer is * allocated during the read. */ Status = AcpiExReadDataFromField (WalkState, ObjDesc, &BufferDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; } TablePtr = ACPI_CAST_PTR (ACPI_TABLE_HEADER, BufferDesc->Buffer.Pointer); break; default: return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* The table must be either an SSDT or a PSDT */ if ((!ACPI_STRNCMP (TablePtr->Signature, AcpiGbl_AcpiTableData[ACPI_TABLE_PSDT].Signature, AcpiGbl_AcpiTableData[ACPI_TABLE_PSDT].SigLength)) && (!ACPI_STRNCMP (TablePtr->Signature, AcpiGbl_AcpiTableData[ACPI_TABLE_SSDT].Signature, AcpiGbl_AcpiTableData[ACPI_TABLE_SSDT].SigLength))) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Table has invalid signature [%4.4s], must be SSDT or PSDT\n", TablePtr->Signature)); Status = AE_BAD_SIGNATURE; goto Cleanup; } /* Install the new table into the local data structures */ Status = AcpiExAddTable (TablePtr, AcpiGbl_RootNode, &DdbHandle); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Store the DdbHandle into the Target operand */ Status = AcpiExStore (DdbHandle, Target, WalkState); if (ACPI_FAILURE (Status)) { (void) AcpiExUnloadTable (DdbHandle); } return_ACPI_STATUS (Status); Cleanup: if (BufferDesc) { AcpiUtRemoveReference (BufferDesc); } else { ACPI_MEM_FREE (TablePtr); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExUnloadTable * * PARAMETERS: DdbHandle - Handle to a previously loaded table * * RETURN: Status * * DESCRIPTION: Unload an ACPI table * ******************************************************************************/ ACPI_STATUS AcpiExUnloadTable ( ACPI_OPERAND_OBJECT *DdbHandle) { ACPI_STATUS Status = AE_NOT_IMPLEMENTED; ACPI_OPERAND_OBJECT *TableDesc = DdbHandle; ACPI_TABLE_DESC *TableInfo; ACPI_FUNCTION_TRACE ("ExUnloadTable"); /* * Validate the handle * Although the handle is partially validated in AcpiExReconfiguration(), * when it calls AcpiExResolveOperands(), the handle is more completely * validated here. */ if ((!DdbHandle) || (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) || - (ACPI_GET_OBJECT_TYPE (DdbHandle) != INTERNAL_TYPE_REFERENCE)) + (ACPI_GET_OBJECT_TYPE (DdbHandle) != ACPI_TYPE_LOCAL_REFERENCE)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Get the actual table descriptor from the DdbHandle */ TableInfo = (ACPI_TABLE_DESC *) TableDesc->Reference.Object; /* * Delete the entire namespace under this table Node * (Offset contains the TableId) */ AcpiNsDeleteNamespaceByOwner (TableInfo->TableId); /* Delete the table itself */ (void) AcpiTbUninstallTable (TableInfo->InstalledDesc); /* Delete the table descriptor (DdbHandle) */ AcpiUtRemoveReference (TableDesc); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exconvrt.c b/sys/contrib/dev/acpica/exconvrt.c index 6729a2745b63..f5937f159d59 100644 --- a/sys/contrib/dev/acpica/exconvrt.c +++ b/sys/contrib/dev/acpica/exconvrt.c @@ -1,821 +1,803 @@ /****************************************************************************** * * Module Name: exconvrt - Object conversion routines - * $Revision: 39 $ + * $Revision: 44 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXCONVRT_C__ #include "acpi.h" #include "acinterp.h" #include "amlcode.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exconvrt") /******************************************************************************* * * FUNCTION: AcpiExConvertToInteger * * PARAMETERS: *ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String * WalkState - Current method state * * RETURN: Status * * DESCRIPTION: Convert an ACPI Object to an integer. * ******************************************************************************/ ACPI_STATUS AcpiExConvertToInteger ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState) { UINT32 i; ACPI_OPERAND_OBJECT *RetDesc; UINT32 Count; UINT8 *Pointer; ACPI_INTEGER Result; ACPI_STATUS Status; ACPI_FUNCTION_TRACE_PTR ("ExConvertToInteger", ObjDesc); switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_INTEGER: *ResultDesc = ObjDesc; return_ACPI_STATUS (AE_OK); case ACPI_TYPE_STRING: Pointer = (UINT8 *) ObjDesc->String.Pointer; Count = ObjDesc->String.Length; break; case ACPI_TYPE_BUFFER: Pointer = ObjDesc->Buffer.Pointer; Count = ObjDesc->Buffer.Length; break; default: return_ACPI_STATUS (AE_TYPE); } /* * Convert the buffer/string to an integer. Note that both buffers and * strings are treated as raw data - we don't convert ascii to hex for * strings. * * There are two terminating conditions for the loop: * 1) The size of an integer has been reached, or * 2) The end of the buffer or string has been reached */ Result = 0; /* Transfer no more than an integer's worth of data */ if (Count > AcpiGbl_IntegerByteWidth) { Count = AcpiGbl_IntegerByteWidth; } /* * String conversion is different than Buffer conversion */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_STRING: /* * Convert string to an integer * String must be hexadecimal as per the ACPI specification */ Status = AcpiUtStrtoul64 ((char *) Pointer, 16, &Result); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } break; case ACPI_TYPE_BUFFER: /* * Buffer conversion - we simply grab enough raw data from the * buffer to fill an integer */ for (i = 0; i < Count; i++) { /* * Get next byte and shift it into the Result. * Little endian is used, meaning that the first byte of the buffer * is the LSB of the integer */ Result |= (((ACPI_INTEGER) Pointer[i]) << (i * 8)); } break; default: /* No other types can get here */ break; } /* * Create a new integer */ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!RetDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - /* Save the Result, delete original descriptor, store new descriptor */ + /* Save the Result */ RetDesc->Integer.Value = Result; + /* + * If we are about to overwrite the original object on the operand stack, + * we must remove a reference on the original object because we are + * essentially removing it from the stack. + */ if (*ResultDesc == ObjDesc) { if (WalkState->Opcode != AML_STORE_OP) { AcpiUtRemoveReference (ObjDesc); } } *ResultDesc = RetDesc; return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiExConvertToBuffer * * PARAMETERS: *ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String * WalkState - Current method state * * RETURN: Status * * DESCRIPTION: Convert an ACPI Object to a Buffer * ******************************************************************************/ ACPI_STATUS AcpiExConvertToBuffer ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT *RetDesc; UINT32 i; UINT8 *NewBuf; ACPI_FUNCTION_TRACE_PTR ("ExConvertToBuffer", ObjDesc); switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { + case ACPI_TYPE_BUFFER: + + /* No conversion necessary */ + + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); + + case ACPI_TYPE_INTEGER: /* - * Create a new Buffer object + * Create a new Buffer object. + * Need enough space for one integer */ - RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + RetDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth); if (!RetDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - /* Need enough space for one integer */ - - NewBuf = ACPI_MEM_CALLOCATE (AcpiGbl_IntegerByteWidth); - if (!NewBuf) - { - ACPI_REPORT_ERROR - (("ExConvertToBuffer: Buffer allocation failure\n")); - AcpiUtRemoveReference (RetDesc); - return_ACPI_STATUS (AE_NO_MEMORY); - } - /* Copy the integer to the buffer */ + NewBuf = RetDesc->Buffer.Pointer; for (i = 0; i < AcpiGbl_IntegerByteWidth; i++) { NewBuf[i] = (UINT8) (ObjDesc->Integer.Value >> (i * 8)); } - - /* Complete buffer object initialization */ - - RetDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; - RetDesc->Buffer.Pointer = NewBuf; - RetDesc->Buffer.Length = AcpiGbl_IntegerByteWidth; - - /* Return the new buffer descriptor */ - - *ResultDesc = RetDesc; break; case ACPI_TYPE_STRING: + /* * Create a new Buffer object + * Size will be the string length */ - RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + RetDesc = AcpiUtCreateBufferObject (ObjDesc->String.Length); if (!RetDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - /* Need enough space for one integer */ - - NewBuf = ACPI_MEM_CALLOCATE (ObjDesc->String.Length); - if (!NewBuf) - { - ACPI_REPORT_ERROR - (("ExConvertToBuffer: Buffer allocation failure\n")); - AcpiUtRemoveReference (RetDesc); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer, ObjDesc->String.Length); - RetDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; - RetDesc->Buffer.Pointer = NewBuf; - RetDesc->Buffer.Length = ObjDesc->String.Length; + /* Copy the string to the buffer */ - /* Return the new buffer descriptor */ - - *ResultDesc = RetDesc; - break; - - - case ACPI_TYPE_BUFFER: - *ResultDesc = ObjDesc; + NewBuf = RetDesc->Buffer.Pointer; + ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer, + ObjDesc->String.Length); break; default: return_ACPI_STATUS (AE_TYPE); } /* Mark buffer initialized */ - (*ResultDesc)->Common.Flags |= AOPOBJ_DATA_VALID; + RetDesc->Common.Flags |= AOPOBJ_DATA_VALID; + + /* + * If we are about to overwrite the original object on the operand stack, + * we must remove a reference on the original object because we are + * essentially removing it from the stack. + */ + if (*ResultDesc == ObjDesc) + { + if (WalkState->Opcode != AML_STORE_OP) + { + AcpiUtRemoveReference (ObjDesc); + } + } + + *ResultDesc = RetDesc; return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiExConvertAscii * * PARAMETERS: Integer - Value to be converted * Base - 10 or 16 * String - Where the string is returned * * RETURN: Actual string length * * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string * ******************************************************************************/ UINT32 AcpiExConvertToAscii ( ACPI_INTEGER Integer, UINT32 Base, UINT8 *String) { UINT32 i; UINT32 j; UINT32 k = 0; char HexDigit; ACPI_INTEGER Digit; UINT32 Remainder; UINT32 Length = sizeof (ACPI_INTEGER); BOOLEAN LeadingZero = TRUE; ACPI_FUNCTION_ENTRY (); switch (Base) { case 10: Remainder = 0; for (i = ACPI_MAX_DECIMAL_DIGITS; i > 0 ; i--) { /* Divide by nth factor of 10 */ Digit = Integer; for (j = 1; j < i; j++) { (void) AcpiUtShortDivide (&Digit, 10, &Digit, &Remainder); } /* Create the decimal digit */ if (Digit != 0) { LeadingZero = FALSE; } if (!LeadingZero) { String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder); k++; } } break; case 16: /* Copy the integer to the buffer */ for (i = 0, j = ((Length * 2) -1); i < (Length * 2); i++, j--) { HexDigit = AcpiUtHexToAsciiChar (Integer, (j * 4)); if (HexDigit != ACPI_ASCII_ZERO) { LeadingZero = FALSE; } if (!LeadingZero) { String[k] = (UINT8) HexDigit; k++; } } break; default: break; } /* * Since leading zeros are supressed, we must check for the case where * the integer equals 0. * * Finally, null terminate the string and return the length */ if (!k) { String [0] = ACPI_ASCII_ZERO; k = 1; } String [k] = 0; return (k); } /******************************************************************************* * * FUNCTION: AcpiExConvertToString * * PARAMETERS: *ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String * WalkState - Current method state * * RETURN: Status * * DESCRIPTION: Convert an ACPI Object to a string * ******************************************************************************/ ACPI_STATUS AcpiExConvertToString ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ResultDesc, UINT32 Base, UINT32 MaxLength, ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT *RetDesc; UINT32 i; UINT32 Index; UINT32 StringLength; UINT8 *NewBuf; UINT8 *Pointer; ACPI_FUNCTION_TRACE_PTR ("ExConvertToString", ObjDesc); switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { + case ACPI_TYPE_STRING: + + if (MaxLength >= ObjDesc->String.Length) + { + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); + } + else + { + /* Must copy the string first and then truncate it */ + + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + case ACPI_TYPE_INTEGER: StringLength = AcpiGbl_IntegerByteWidth * 2; if (Base == 10) { StringLength = ACPI_MAX_DECIMAL_DIGITS; } /* * Create a new String */ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); if (!RetDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Need enough space for one ASCII integer plus null terminator */ NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1); if (!NewBuf) { ACPI_REPORT_ERROR (("ExConvertToString: Buffer allocation failure\n")); AcpiUtRemoveReference (RetDesc); return_ACPI_STATUS (AE_NO_MEMORY); } /* Convert */ i = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, NewBuf); /* Null terminate at the correct place */ if (MaxLength < i) { NewBuf[MaxLength] = 0; RetDesc->String.Length = MaxLength; } else { NewBuf [i] = 0; RetDesc->String.Length = i; } RetDesc->Buffer.Pointer = NewBuf; - - /* Return the new buffer descriptor */ - - if (*ResultDesc == ObjDesc) - { - if (WalkState->Opcode != AML_STORE_OP) - { - AcpiUtRemoveReference (ObjDesc); - } - } - - *ResultDesc = RetDesc; break; case ACPI_TYPE_BUFFER: StringLength = ObjDesc->Buffer.Length * 3; if (Base == 10) { StringLength = ObjDesc->Buffer.Length * 4; } if (MaxLength > ACPI_MAX_STRING_CONVERSION) { if (StringLength > ACPI_MAX_STRING_CONVERSION) { return_ACPI_STATUS (AE_AML_STRING_LIMIT); } } /* * Create a new string object */ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); if (!RetDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* String length is the lesser of the Max or the actual length */ if (MaxLength < StringLength) { StringLength = MaxLength; } NewBuf = ACPI_MEM_CALLOCATE ((ACPI_SIZE) StringLength + 1); if (!NewBuf) { ACPI_REPORT_ERROR (("ExConvertToString: Buffer allocation failure\n")); AcpiUtRemoveReference (RetDesc); return_ACPI_STATUS (AE_NO_MEMORY); } /* * Convert each byte of the buffer to two ASCII characters plus a space. */ Pointer = ObjDesc->Buffer.Pointer; Index = 0; for (i = 0, Index = 0; i < ObjDesc->Buffer.Length; i++) { Index = AcpiExConvertToAscii ((ACPI_INTEGER) Pointer[i], Base, &NewBuf[Index]); NewBuf[Index] = ' '; Index++; } /* Null terminate */ NewBuf [Index-1] = 0; RetDesc->Buffer.Pointer = NewBuf; - RetDesc->String.Length = ACPI_STRLEN ((char *) NewBuf); - - /* Return the new buffer descriptor */ - - if (*ResultDesc == ObjDesc) - { - if (WalkState->Opcode != AML_STORE_OP) - { - AcpiUtRemoveReference (ObjDesc); - } - } - - *ResultDesc = RetDesc; + RetDesc->String.Length = (UINT32) ACPI_STRLEN ((char *) NewBuf); break; - case ACPI_TYPE_STRING: + default: + return_ACPI_STATUS (AE_TYPE); + } - if (MaxLength >= ObjDesc->String.Length) - { - *ResultDesc = ObjDesc; - } - else + /* + * If we are about to overwrite the original object on the operand stack, + * we must remove a reference on the original object because we are + * essentially removing it from the stack. + */ + if (*ResultDesc == ObjDesc) + { + if (WalkState->Opcode != AML_STORE_OP) { - /* Must copy the string first and then truncate it */ - - return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + AcpiUtRemoveReference (ObjDesc); } - break; - - - default: - return_ACPI_STATUS (AE_TYPE); } + *ResultDesc = RetDesc; return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiExConvertToTargetType * * PARAMETERS: DestinationType - Current type of the destination * SourceDesc - Source object to be converted. * WalkState - Current method state * * RETURN: Status * * DESCRIPTION: Implements "implicit conversion" rules for storing an object. * ******************************************************************************/ ACPI_STATUS AcpiExConvertToTargetType ( ACPI_OBJECT_TYPE DestinationType, ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT **ResultDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("ExConvertToTargetType"); /* Default behavior */ *ResultDesc = SourceDesc; /* * If required by the target, * perform implicit conversion on the source before we store it. */ switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs)) { case ARGI_SIMPLE_TARGET: case ARGI_FIXED_TARGET: case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */ switch (DestinationType) { - case INTERNAL_TYPE_REGION_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: /* * Named field can always handle conversions */ break; default: /* No conversion allowed for these types */ if (DestinationType != ACPI_GET_OBJECT_TYPE (SourceDesc)) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Explicit operator, will store (%s) over existing type (%s)\n", AcpiUtGetObjectTypeName (SourceDesc), AcpiUtGetTypeName (DestinationType))); Status = AE_TYPE; } } break; case ARGI_TARGETREF: switch (DestinationType) { case ACPI_TYPE_INTEGER: case ACPI_TYPE_BUFFER_FIELD: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: /* * These types require an Integer operand. We can convert * a Buffer or a String to an Integer if necessary. */ Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, WalkState); break; case ACPI_TYPE_STRING: /* * The operand must be a String. We can convert an * Integer or Buffer if necessary */ Status = AcpiExConvertToString (SourceDesc, ResultDesc, 16, ACPI_UINT32_MAX, WalkState); break; case ACPI_TYPE_BUFFER: /* * The operand must be a Buffer. We can convert an * Integer or String if necessary */ Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc, WalkState); break; default: Status = AE_AML_INTERNAL; break; } break; case ARGI_REFERENCE: /* * CreateXxxxField cases - we are storing the field object into the name */ break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Target type ID 0x%X Op %s DestType %s\n", GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs), WalkState->OpInfo->Name, AcpiUtGetTypeName (DestinationType))); Status = AE_AML_INTERNAL; } /* * Source-to-Target conversion semantics: * * If conversion to the target type cannot be performed, then simply * overwrite the target with the new object and type. */ if (Status == AE_TYPE) { Status = AE_OK; } return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/excreate.c b/sys/contrib/dev/acpica/excreate.c index 332f3b55dd60..75fec4460cb1 100644 --- a/sys/contrib/dev/acpica/excreate.c +++ b/sys/contrib/dev/acpica/excreate.c @@ -1,727 +1,728 @@ /****************************************************************************** * * Module Name: excreate - Named object creation - * $Revision: 94 $ + * $Revision: 97 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXCREATE_C__ #include "acpi.h" #include "acinterp.h" #include "amlcode.h" #include "acnamesp.h" #include "acevents.h" #include "actables.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("excreate") #ifndef ACPI_NO_METHOD_EXECUTION /***************************************************************************** * * FUNCTION: AcpiExCreateAlias * * PARAMETERS: WalkState - Current state, contains operands * * RETURN: Status * * DESCRIPTION: Create a new named alias * ****************************************************************************/ ACPI_STATUS AcpiExCreateAlias ( ACPI_WALK_STATE *WalkState) { ACPI_NAMESPACE_NODE *TargetNode; ACPI_NAMESPACE_NODE *AliasNode; - ACPI_STATUS Status; + ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("ExCreateAlias"); /* Get the source/alias operands (both namespace nodes) */ AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1]; - if (TargetNode->Type == INTERNAL_TYPE_ALIAS) + if (TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) { /* * Dereference an existing alias so that we don't create a chain * of aliases. With this code, we guarantee that an alias is * always exactly one level of indirection away from the * actual aliased name. */ TargetNode = (ACPI_NAMESPACE_NODE *) TargetNode->Object; } /* * For objects that can never change (i.e., the NS node will * permanently point to the same object), we can simply attach * the object to the new NS node. For other objects (such as * Integers, buffers, etc.), we have to point the Alias node * to the original Node. */ switch (TargetNode->Type) { case ACPI_TYPE_INTEGER: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: case ACPI_TYPE_PACKAGE: case ACPI_TYPE_BUFFER_FIELD: /* * The new alias has the type ALIAS and points to the original * NS node, not the object itself. This is because for these * types, the object can change dynamically via a Store. */ - AliasNode->Type = INTERNAL_TYPE_ALIAS; - AliasNode->Object = (ACPI_OPERAND_OBJECT *) TargetNode; + AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS; + AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); break; default: /* Attach the original source object to the new Alias Node */ /* * The new alias assumes the type of the target, and it points * to the same object. The reference count of the object has an * additional reference to prevent deletion out from under either the * target node or the alias Node */ Status = AcpiNsAttachObject (AliasNode, AcpiNsGetAttachedObject (TargetNode), TargetNode->Type); break; } /* Since both operands are Nodes, we don't need to delete them */ - return_ACPI_STATUS (AE_OK); + return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiExCreateEvent * * PARAMETERS: WalkState - Current state * * RETURN: Status * * DESCRIPTION: Create a new event object * ****************************************************************************/ ACPI_STATUS AcpiExCreateEvent ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_TRACE ("ExCreateEvent"); ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); if (!ObjDesc) { Status = AE_NO_MEMORY; goto Cleanup; } /* * Create the actual OS semaphore, with zero initial units -- meaning * that the event is created in an unsignalled state */ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &ObjDesc->Event.Semaphore); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Attach object to the Node */ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], ObjDesc, ACPI_TYPE_EVENT); Cleanup: /* * Remove local reference to the object (on error, will cause deletion * of both object and semaphore if present.) */ AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiExCreateMutex * * PARAMETERS: WalkState - Current state * * RETURN: Status * * DESCRIPTION: Create a new mutex object * * Mutex (Name[0], SyncLevel[1]) * ****************************************************************************/ ACPI_STATUS AcpiExCreateMutex ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_TRACE_PTR ("ExCreateMutex", ACPI_WALK_OPERANDS); /* Create the new mutex object */ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); if (!ObjDesc) { Status = AE_NO_MEMORY; goto Cleanup; } /* * Create the actual OS semaphore. * One unit max to make it a mutex, with one initial unit to allow * the mutex to be acquired. */ Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Init object and attach to NS node */ ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value; + ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; - Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], - ObjDesc, ACPI_TYPE_MUTEX); + Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, + ObjDesc, ACPI_TYPE_MUTEX); Cleanup: /* * Remove local reference to the object (on error, will cause deletion * of both object and semaphore if present.) */ AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiExCreateRegion * * PARAMETERS: AmlStart - Pointer to the region declaration AML * AmlLength - Max length of the declaration AML * Operands - List of operands for the opcode * WalkState - Current state * * RETURN: Status * * DESCRIPTION: Create a new operation region object * ****************************************************************************/ ACPI_STATUS AcpiExCreateRegion ( UINT8 *AmlStart, UINT32 AmlLength, UINT8 RegionSpace, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; ACPI_OPERAND_OBJECT *RegionObj2; ACPI_FUNCTION_TRACE ("ExCreateRegion"); /* Get the Node from the object stack */ Node = WalkState->Op->Common.Node; /* * If the region object is already attached to this node, * just return */ if (AcpiNsGetAttachedObject (Node)) { return_ACPI_STATUS (AE_OK); } /* * Space ID must be one of the predefined IDs, or in the user-defined * range */ if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) && (RegionSpace < ACPI_USER_REGION_BEGIN)) { ACPI_REPORT_ERROR (("Invalid AddressSpace type %X\n", RegionSpace)); return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); } ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", AcpiUtGetRegionName (RegionSpace), RegionSpace)); /* Create the region descriptor */ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); if (!ObjDesc) { Status = AE_NO_MEMORY; goto Cleanup; } /* * Remember location in AML stream of address & length * operands since they need to be evaluated at run time. */ RegionObj2 = ObjDesc->Common.NextObject; RegionObj2->Extra.AmlStart = AmlStart; RegionObj2->Extra.AmlLength = AmlLength; /* Init the region from the operands */ ObjDesc->Region.SpaceId = RegionSpace; ObjDesc->Region.Address = 0; ObjDesc->Region.Length = 0; ObjDesc->Region.Node = Node; /* Install the new region object in the parent Node */ Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); Cleanup: /* Remove local reference to the object */ AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiExCreateTableRegion * * PARAMETERS: WalkState - Current state * * RETURN: Status * * DESCRIPTION: Create a new DataTableRegion object * ****************************************************************************/ ACPI_STATUS AcpiExCreateTableRegion ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *Node; ACPI_TABLE_HEADER *Table; ACPI_OPERAND_OBJECT *RegionObj2; ACPI_FUNCTION_TRACE ("ExCreateTableRegion"); /* Get the Node from the object stack */ Node = WalkState->Op->Common.Node; /* * If the region object is already attached to this node, * just return */ if (AcpiNsGetAttachedObject (Node)) { return_ACPI_STATUS (AE_OK); } /* Find the ACPI table */ Status = AcpiTbFindTable (Operand[1]->String.Pointer, Operand[2]->String.Pointer, Operand[3]->String.Pointer, &Table); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Create the region descriptor */ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } RegionObj2 = ObjDesc->Common.NextObject; RegionObj2->Extra.RegionContext = NULL; /* Init the region from the operands */ ObjDesc->Region.SpaceId = REGION_DATA_TABLE; ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table); ObjDesc->Region.Length = Table->Length; ObjDesc->Region.Node = Node; ObjDesc->Region.Flags = AOPOBJ_DATA_VALID; /* Install the new region object in the parent Node */ Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); if (ACPI_FAILURE (Status)) { goto Cleanup; } Status = AcpiEvInitializeRegion (ObjDesc, FALSE); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_EXIST) { Status = AE_OK; } else { goto Cleanup; } } ObjDesc->Region.Flags |= AOPOBJ_SETUP_COMPLETE; Cleanup: /* Remove local reference to the object */ AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiExCreateProcessor * * PARAMETERS: WalkState - Current state * * RETURN: Status * * DESCRIPTION: Create a new processor object and populate the fields * * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) * ****************************************************************************/ ACPI_STATUS AcpiExCreateProcessor ( ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; ACPI_FUNCTION_TRACE_PTR ("ExCreateProcessor", WalkState); /* Create the processor object */ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* * 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; /* Install the processor object in the parent Node */ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], ObjDesc, ACPI_TYPE_PROCESSOR); /* Remove local reference to the object */ AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } /***************************************************************************** * * FUNCTION: AcpiExCreatePowerResource * * PARAMETERS: WalkState - Current state * * RETURN: Status * * DESCRIPTION: Create a new PowerResource object and populate the fields * * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) * ****************************************************************************/ ACPI_STATUS AcpiExCreatePowerResource ( ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_TRACE_PTR ("ExCreatePowerResource", WalkState); /* Create the power resource object */ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Initialize the power object from the operands */ ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value; ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value; /* Install the power resource object in the parent Node */ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], ObjDesc, ACPI_TYPE_POWER); /* Remove local reference to the object */ AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } #endif /***************************************************************************** * * FUNCTION: AcpiExCreateMethod * * PARAMETERS: AmlStart - First byte of the method's AML * AmlLength - AML byte count for this method * WalkState - Current state * * RETURN: Status * * DESCRIPTION: Create a new method object * ****************************************************************************/ ACPI_STATUS AcpiExCreateMethod ( UINT8 *AmlStart, UINT32 AmlLength, ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status; UINT8 MethodFlags; ACPI_FUNCTION_TRACE_PTR ("ExCreateMethod", WalkState); /* Create a new method object */ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Save the method's AML pointer and length */ ObjDesc->Method.AmlStart = AmlStart; ObjDesc->Method.AmlLength = AmlLength; /* disassemble the method flags */ MethodFlags = (UINT8) Operand[1]->Integer.Value; ObjDesc->Method.MethodFlags = MethodFlags; ObjDesc->Method.ParamCount = (UINT8) (MethodFlags & METHOD_FLAGS_ARG_COUNT); /* * Get the concurrency count. If required, a semaphore will be * created for this method when it is parsed. */ if (MethodFlags & METHOD_FLAGS_SERIALIZED) { /* * ACPI 1.0: Concurrency = 1 * ACPI 2.0: Concurrency = (SyncLevel (in method declaration) + 1) */ ObjDesc->Method.Concurrency = (UINT8) (((MethodFlags & METHOD_FLAGS_SYNCH_LEVEL) >> 4) + 1); } else { ObjDesc->Method.Concurrency = INFINITE_CONCURRENCY; } /* Attach the new object to the method Node */ Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], ObjDesc, ACPI_TYPE_METHOD); /* Remove local reference to the object */ AcpiUtRemoveReference (ObjDesc); /* Remove a reference to the operand */ AcpiUtRemoveReference (Operand[1]); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exdump.c b/sys/contrib/dev/acpica/exdump.c index 1a20823e4166..9e2be8070373 100644 --- a/sys/contrib/dev/acpica/exdump.c +++ b/sys/contrib/dev/acpica/exdump.c @@ -1,927 +1,901 @@ /****************************************************************************** * * Module Name: exdump - Interpreter debug output routines - * $Revision: 160 $ + * $Revision: 163 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXDUMP_C__ #include "acpi.h" #include "acinterp.h" #include "amlcode.h" #include "acnamesp.h" #include "acparser.h" #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) /***************************************************************************** * * FUNCTION: AcpiExDumpOperand * * PARAMETERS: *ObjDesc - Pointer to entry to be dumped * * RETURN: Status * * DESCRIPTION: Dump an operand object * ****************************************************************************/ void AcpiExDumpOperand ( ACPI_OPERAND_OBJECT *ObjDesc) { UINT8 *Buf = NULL; UINT32 Length; - UINT32 i; ACPI_OPERAND_OBJECT **Element; UINT16 ElementIndex; ACPI_FUNCTION_NAME ("ExDumpOperand") if (!((ACPI_LV_EXEC & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) { return; } if (!ObjDesc) { /* * This usually indicates that something serious is wrong -- * since most (if not all) * code that dumps the stack expects something to be there! */ AcpiOsPrintf ("Null stack entry ptr\n"); return; } if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p NS Node: ", ObjDesc)); ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_EXEC); return; } if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p is not a local object\n", ObjDesc)); ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)); return; } /* ObjDesc is a valid object */ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc)); switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: switch (ObjDesc->Reference.Opcode) { case AML_DEBUG_OP: AcpiOsPrintf ("Reference: Debug\n"); break; case AML_NAME_OP: ACPI_DUMP_PATHNAME (ObjDesc->Reference.Object, "Reference: Name: ", ACPI_LV_INFO, _COMPONENT); ACPI_DUMP_ENTRY (ObjDesc->Reference.Object, ACPI_LV_INFO); break; case AML_INDEX_OP: AcpiOsPrintf ("Reference: Index %p\n", ObjDesc->Reference.Object); break; case AML_REF_OF_OP: AcpiOsPrintf ("Reference: (RefOf) %p\n", ObjDesc->Reference.Object); break; case AML_ARG_OP: AcpiOsPrintf ("Reference: Arg%d", ObjDesc->Reference.Offset); if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { /* Value is a Number */ AcpiOsPrintf (" value is [%8.8X%8.8x]", ACPI_HIDWORD(ObjDesc->Integer.Value), ACPI_LODWORD(ObjDesc->Integer.Value)); } AcpiOsPrintf ("\n"); break; case AML_LOCAL_OP: AcpiOsPrintf ("Reference: Local%d", ObjDesc->Reference.Offset); if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) { /* Value is a Number */ AcpiOsPrintf (" value is [%8.8X%8.8x]", ACPI_HIDWORD(ObjDesc->Integer.Value), ACPI_LODWORD(ObjDesc->Integer.Value)); } AcpiOsPrintf ("\n"); break; case AML_INT_NAMEPATH_OP: AcpiOsPrintf ("Reference.Node->Name %X\n", ObjDesc->Reference.Node->Name.Integer); break; default: /* unknown opcode */ AcpiOsPrintf ("Unknown Reference opcode=%X\n", ObjDesc->Reference.Opcode); break; } break; case ACPI_TYPE_BUFFER: AcpiOsPrintf ("Buffer len %X @ %p \n", ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer); Length = ObjDesc->Buffer.Length; if (Length > 64) { Length = 64; } /* Debug only -- dump the buffer contents */ if (ObjDesc->Buffer.Pointer) { AcpiOsPrintf ("Buffer Contents: "); for (Buf = ObjDesc->Buffer.Pointer; Length--; ++Buf) { AcpiOsPrintf (" %02x", *Buf); } AcpiOsPrintf ("\n"); } break; case ACPI_TYPE_INTEGER: AcpiOsPrintf ("Integer %8.8X%8.8X\n", ACPI_HIDWORD (ObjDesc->Integer.Value), ACPI_LODWORD (ObjDesc->Integer.Value)); break; - case INTERNAL_TYPE_IF: - - AcpiOsPrintf ("If [Integer] %8.8X%8.8X\n", - ACPI_HIDWORD (ObjDesc->Integer.Value), - ACPI_LODWORD (ObjDesc->Integer.Value)); - break; - - - case INTERNAL_TYPE_WHILE: - - AcpiOsPrintf ("While [Integer] %8.8X%8.8X\n", - ACPI_HIDWORD (ObjDesc->Integer.Value), - ACPI_LODWORD (ObjDesc->Integer.Value)); - break; - - case ACPI_TYPE_PACKAGE: AcpiOsPrintf ("Package count %X @ %p\n", ObjDesc->Package.Count, ObjDesc->Package.Elements); /* * If elements exist, package vector pointer is valid, * and debug_level exceeds 1, dump package's elements. */ if (ObjDesc->Package.Count && ObjDesc->Package.Elements && AcpiDbgLevel > 1) { for (ElementIndex = 0, Element = ObjDesc->Package.Elements; ElementIndex < ObjDesc->Package.Count; ++ElementIndex, ++Element) { AcpiExDumpOperand (*Element); } } AcpiOsPrintf ("\n"); break; case ACPI_TYPE_REGION: AcpiOsPrintf ("Region %s (%X)", AcpiUtGetRegionName (ObjDesc->Region.SpaceId), ObjDesc->Region.SpaceId); /* * If the address and length have not been evaluated, * don't print them. */ if (!(ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)) { AcpiOsPrintf ("\n"); } else { AcpiOsPrintf (" base %8.8X%8.8X Length %X\n", ACPI_HIDWORD (ObjDesc->Region.Address), ACPI_LODWORD (ObjDesc->Region.Address), ObjDesc->Region.Length); } break; case ACPI_TYPE_STRING: - AcpiOsPrintf ("String length %X @ %p \"", + AcpiOsPrintf ("String length %X @ %p ", ObjDesc->String.Length, ObjDesc->String.Pointer); - - for (i = 0; i < ObjDesc->String.Length; i++) - { - AcpiOsPrintf ("%c", - ObjDesc->String.Pointer[i]); - } - AcpiOsPrintf ("\"\n"); + AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); + AcpiOsPrintf ("\n"); break; - case INTERNAL_TYPE_BANK_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: AcpiOsPrintf ("BankField\n"); break; - case INTERNAL_TYPE_REGION_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: 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.FieldFlags & AML_FIELD_LOCK_RULE_MASK, ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK, ObjDesc->Field.BaseByteOffset, ObjDesc->Field.StartFieldBitOffset); ACPI_DUMP_STACK_ENTRY (ObjDesc->Field.RegionObj); break; - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: AcpiOsPrintf ("IndexField\n"); break; case ACPI_TYPE_BUFFER_FIELD: AcpiOsPrintf ( "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")); } else if (ACPI_GET_OBJECT_TYPE (ObjDesc->BufferField.BufferObj) != ACPI_TYPE_BUFFER) { AcpiOsPrintf ("*not a Buffer* \n"); } else { ACPI_DUMP_STACK_ENTRY (ObjDesc->BufferField.BufferObj); } break; case ACPI_TYPE_EVENT: AcpiOsPrintf ("Event\n"); break; case ACPI_TYPE_METHOD: AcpiOsPrintf ( "Method(%X) @ %p:%X\n", ObjDesc->Method.ParamCount, ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength); break; case ACPI_TYPE_MUTEX: AcpiOsPrintf ("Mutex\n"); break; case ACPI_TYPE_DEVICE: AcpiOsPrintf ("Device\n"); break; case ACPI_TYPE_POWER: AcpiOsPrintf ("Power\n"); break; case ACPI_TYPE_PROCESSOR: AcpiOsPrintf ("Processor\n"); break; case ACPI_TYPE_THERMAL: AcpiOsPrintf ("Thermal\n"); break; default: /* Unknown Type */ AcpiOsPrintf ("Unknown Type %X\n", ACPI_GET_OBJECT_TYPE (ObjDesc)); break; } return; } /***************************************************************************** * * FUNCTION: AcpiExDumpOperands * * PARAMETERS: InterpreterMode - Load or Exec * *Ident - Identification * NumLevels - # of stack entries to dump above line * *Note - Output notation * * DESCRIPTION: Dump the object stack * ****************************************************************************/ void AcpiExDumpOperands ( ACPI_OPERAND_OBJECT **Operands, ACPI_INTERPRETER_MODE InterpreterMode, NATIVE_CHAR *Ident, UINT32 NumLevels, NATIVE_CHAR *Note, NATIVE_CHAR *ModuleName, UINT32 LineNumber) { NATIVE_UINT i; ACPI_OPERAND_OBJECT **ObjDesc; ACPI_FUNCTION_NAME ("ExDumpOperands"); if (!Ident) { Ident = "?"; } if (!Note) { Note = "?"; } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "************* Operand Stack Contents (Opcode [%s], %d Operands)\n", Ident, NumLevels)); if (NumLevels == 0) { NumLevels = 1; } /* Dump the operand stack starting at the top */ for (i = 0; NumLevels > 0; i--, NumLevels--) { ObjDesc = &Operands[i]; AcpiExDumpOperand (*ObjDesc); } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "************* Stack dump from %s(%d), %s\n", ModuleName, LineNumber, Note)); return; } /***************************************************************************** * * FUNCTION: AcpiExOut* * * PARAMETERS: Title - Descriptive text * Value - Value to be displayed * * DESCRIPTION: Object dump output formatting functions. These functions * reduce the number of format strings required and keeps them * all in one place for easy modification. * ****************************************************************************/ void AcpiExOutString ( char *Title, char *Value) { AcpiOsPrintf ("%20s : %s\n", Title, Value); } void AcpiExOutPointer ( char *Title, void *Value) { AcpiOsPrintf ("%20s : %p\n", Title, Value); } void AcpiExOutInteger ( char *Title, UINT32 Value) { AcpiOsPrintf ("%20s : %X\n", Title, Value); } void AcpiExOutAddress ( char *Title, ACPI_PHYSICAL_ADDRESS Value) { #if ACPI_MACHINE_WIDTH == 16 AcpiOsPrintf ("%20s : %p\n", Title, Value); #else AcpiOsPrintf ("%20s : %8.8X%8.8X\n", Title, ACPI_HIDWORD (Value), ACPI_LODWORD (Value)); #endif } /***************************************************************************** * * FUNCTION: AcpiExDumpNode * * PARAMETERS: *Node - Descriptor to dump * Flags - Force display * * DESCRIPTION: Dumps the members of the given.Node * ****************************************************************************/ void AcpiExDumpNode ( ACPI_NAMESPACE_NODE *Node, UINT32 Flags) { ACPI_FUNCTION_ENTRY (); if (!Flags) { if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) { return; } } AcpiOsPrintf ("%20s : %4.4s\n", "Name", Node->Name.Ascii); AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type)); AcpiExOutInteger ("Flags", Node->Flags); AcpiExOutInteger ("Owner Id", Node->OwnerId); AcpiExOutInteger ("Reference Count", Node->ReferenceCount); AcpiExOutPointer ("Attached Object", AcpiNsGetAttachedObject (Node)); AcpiExOutPointer ("ChildList", Node->Child); AcpiExOutPointer ("NextPeer", Node->Peer); AcpiExOutPointer ("Parent", AcpiNsGetParentNode (Node)); } /***************************************************************************** * * FUNCTION: AcpiExDumpObjectDescriptor * * PARAMETERS: *Object - Descriptor to dump * Flags - Force display * * DESCRIPTION: Dumps the members of the object descriptor given. * ****************************************************************************/ void AcpiExDumpObjectDescriptor ( ACPI_OPERAND_OBJECT *ObjDesc, UINT32 Flags) { UINT32 i; ACPI_FUNCTION_TRACE ("ExDumpObjectDescriptor"); if (!Flags) { if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) { return_VOID; } } if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) { AcpiExDumpNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags); AcpiOsPrintf ("\nAttached Object (%p):\n", ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object); AcpiExDumpObjectDescriptor (((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags); return; } if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) { AcpiOsPrintf ("ExDumpObjectDescriptor: %p is not a valid ACPI object\n", ObjDesc); return_VOID; } /* Common Fields */ AcpiExOutString ("Type", AcpiUtGetObjectTypeName (ObjDesc)); AcpiExOutInteger ("Reference Count", ObjDesc->Common.ReferenceCount); AcpiExOutInteger ("Flags", ObjDesc->Common.Flags); /* Object-specific Fields */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_INTEGER: AcpiOsPrintf ("%20s : %8.8X%8.8X\n", "Value", ACPI_HIDWORD (ObjDesc->Integer.Value), ACPI_LODWORD (ObjDesc->Integer.Value)); break; case ACPI_TYPE_STRING: AcpiExOutInteger ("Length", ObjDesc->String.Length); - AcpiExOutPointer ("Pointer", ObjDesc->String.Pointer); + + AcpiOsPrintf ("%20s : %p ", "Pointer", ObjDesc->String.Pointer); + AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); + AcpiOsPrintf ("\n"); break; case ACPI_TYPE_BUFFER: AcpiExOutInteger ("Length", ObjDesc->Buffer.Length); AcpiExOutPointer ("Pointer", ObjDesc->Buffer.Pointer); + ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); break; case ACPI_TYPE_PACKAGE: AcpiExOutInteger ("Flags", ObjDesc->Package.Flags); AcpiExOutInteger ("Count", ObjDesc->Package.Count); AcpiExOutPointer ("Elements", ObjDesc->Package.Elements); /* 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"); } } break; case ACPI_TYPE_DEVICE: AcpiExOutPointer ("AddrHandler", ObjDesc->Device.AddrHandler); AcpiExOutPointer ("SysHandler", ObjDesc->Device.SysHandler); AcpiExOutPointer ("DrvHandler", ObjDesc->Device.DrvHandler); break; case ACPI_TYPE_EVENT: AcpiExOutPointer ("Semaphore", ObjDesc->Event.Semaphore); break; case ACPI_TYPE_METHOD: AcpiExOutInteger ("ParamCount", ObjDesc->Method.ParamCount); AcpiExOutInteger ("Concurrency", ObjDesc->Method.Concurrency); AcpiExOutPointer ("Semaphore", ObjDesc->Method.Semaphore); AcpiExOutInteger ("OwningId", ObjDesc->Method.OwningId); AcpiExOutInteger ("AmlLength", ObjDesc->Method.AmlLength); AcpiExOutPointer ("AmlStart", ObjDesc->Method.AmlStart); break; case ACPI_TYPE_MUTEX: AcpiExOutInteger ("SyncLevel", ObjDesc->Mutex.SyncLevel); AcpiExOutPointer ("OwnerThread", ObjDesc->Mutex.OwnerThread); AcpiExOutInteger ("AcquisitionDepth",ObjDesc->Mutex.AcquisitionDepth); AcpiExOutPointer ("Semaphore", ObjDesc->Mutex.Semaphore); break; case ACPI_TYPE_REGION: AcpiExOutInteger ("SpaceId", ObjDesc->Region.SpaceId); AcpiExOutInteger ("Flags", ObjDesc->Region.Flags); AcpiExOutAddress ("Address", ObjDesc->Region.Address); AcpiExOutInteger ("Length", ObjDesc->Region.Length); AcpiExOutPointer ("AddrHandler", ObjDesc->Region.AddrHandler); AcpiExOutPointer ("Next", ObjDesc->Region.Next); break; case ACPI_TYPE_POWER: AcpiExOutInteger ("SystemLevel", ObjDesc->PowerResource.SystemLevel); AcpiExOutInteger ("ResourceOrder", ObjDesc->PowerResource.ResourceOrder); AcpiExOutPointer ("SysHandler", ObjDesc->PowerResource.SysHandler); AcpiExOutPointer ("DrvHandler", ObjDesc->PowerResource.DrvHandler); break; case ACPI_TYPE_PROCESSOR: AcpiExOutInteger ("Processor ID", ObjDesc->Processor.ProcId); AcpiExOutInteger ("Length", ObjDesc->Processor.Length); AcpiExOutAddress ("Address", (ACPI_PHYSICAL_ADDRESS) ObjDesc->Processor.Address); AcpiExOutPointer ("SysHandler", ObjDesc->Processor.SysHandler); AcpiExOutPointer ("DrvHandler", ObjDesc->Processor.DrvHandler); AcpiExOutPointer ("AddrHandler", ObjDesc->Processor.AddrHandler); break; case ACPI_TYPE_THERMAL: AcpiExOutPointer ("SysHandler", ObjDesc->ThermalZone.SysHandler); AcpiExOutPointer ("DrvHandler", ObjDesc->ThermalZone.DrvHandler); AcpiExOutPointer ("AddrHandler", ObjDesc->ThermalZone.AddrHandler); break; case ACPI_TYPE_BUFFER_FIELD: - case INTERNAL_TYPE_REGION_FIELD: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: AcpiExOutInteger ("FieldFlags", ObjDesc->CommonField.FieldFlags); AcpiExOutInteger ("AccessByteWidth", ObjDesc->CommonField.AccessByteWidth); AcpiExOutInteger ("BitLength", ObjDesc->CommonField.BitLength); AcpiExOutInteger ("FldBitOffset", ObjDesc->CommonField.StartFieldBitOffset); AcpiExOutInteger ("BaseByteOffset", ObjDesc->CommonField.BaseByteOffset); AcpiExOutInteger ("DatumValidBits", ObjDesc->CommonField.DatumValidBits); AcpiExOutInteger ("EndFldValidBits", ObjDesc->CommonField.EndFieldValidBits); AcpiExOutInteger ("EndBufValidBits", ObjDesc->CommonField.EndBufferValidBits); AcpiExOutPointer ("ParentNode", ObjDesc->CommonField.Node); switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_BUFFER_FIELD: AcpiExOutPointer ("BufferObj", ObjDesc->BufferField.BufferObj); break; - case INTERNAL_TYPE_REGION_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: AcpiExOutPointer ("RegionObj", ObjDesc->Field.RegionObj); break; - case INTERNAL_TYPE_BANK_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: AcpiExOutInteger ("Value", ObjDesc->BankField.Value); AcpiExOutPointer ("RegionObj", ObjDesc->BankField.RegionObj); AcpiExOutPointer ("BankObj", ObjDesc->BankField.BankObj); break; - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: AcpiExOutInteger ("Value", ObjDesc->IndexField.Value); AcpiExOutPointer ("Index", ObjDesc->IndexField.IndexObj); AcpiExOutPointer ("Data", ObjDesc->IndexField.DataObj); break; default: /* All object types covered above */ break; } break; - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: AcpiExOutInteger ("TargetType", ObjDesc->Reference.TargetType); AcpiExOutString ("Opcode", (AcpiPsGetOpcodeInfo (ObjDesc->Reference.Opcode))->Name); AcpiExOutInteger ("Offset", ObjDesc->Reference.Offset); AcpiExOutPointer ("ObjDesc", ObjDesc->Reference.Object); AcpiExOutPointer ("Node", ObjDesc->Reference.Node); AcpiExOutPointer ("Where", ObjDesc->Reference.Where); break; - case INTERNAL_TYPE_ADDRESS_HANDLER: + case ACPI_TYPE_LOCAL_ADDRESS_HANDLER: AcpiExOutInteger ("SpaceId", ObjDesc->AddrHandler.SpaceId); AcpiExOutPointer ("Next", ObjDesc->AddrHandler.Next); AcpiExOutPointer ("RegionList", ObjDesc->AddrHandler.RegionList); AcpiExOutPointer ("Node", ObjDesc->AddrHandler.Node); AcpiExOutPointer ("Context", ObjDesc->AddrHandler.Context); break; - case INTERNAL_TYPE_NOTIFY: + case ACPI_TYPE_LOCAL_NOTIFY: AcpiExOutPointer ("Node", ObjDesc->NotifyHandler.Node); AcpiExOutPointer ("Context", ObjDesc->NotifyHandler.Context); break; - case INTERNAL_TYPE_ALIAS: - case INTERNAL_TYPE_FIELD_DEFN: - case INTERNAL_TYPE_BANK_FIELD_DEFN: - case INTERNAL_TYPE_INDEX_FIELD_DEFN: - case INTERNAL_TYPE_IF: - case INTERNAL_TYPE_ELSE: - case INTERNAL_TYPE_WHILE: - case INTERNAL_TYPE_SCOPE: - case INTERNAL_TYPE_DEF_ANY: - case INTERNAL_TYPE_EXTRA: - case INTERNAL_TYPE_DATA: + case ACPI_TYPE_LOCAL_ALIAS: + case ACPI_TYPE_LOCAL_EXTRA: + case ACPI_TYPE_LOCAL_DATA: default: AcpiOsPrintf ("ExDumpObjectDescriptor: Display not implemented for object type %s\n", AcpiUtGetObjectTypeName (ObjDesc)); break; } return_VOID; } #endif diff --git a/sys/contrib/dev/acpica/exfield.c b/sys/contrib/dev/acpica/exfield.c index 7820a8acc3c7..63a93f315bfd 100644 --- a/sys/contrib/dev/acpica/exfield.c +++ b/sys/contrib/dev/acpica/exfield.c @@ -1,403 +1,463 @@ /****************************************************************************** * * Module Name: exfield - ACPI AML (p-code) execution - field manipulation - * $Revision: 112 $ + * $Revision: 115 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXFIELD_C__ #include "acpi.h" #include "acdispat.h" #include "acinterp.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exfield") /******************************************************************************* * * FUNCTION: AcpiExReadDataFromField * * PARAMETERS: WalkState - Current execution state * ObjDesc - The named field * RetBufferDesc - Where the return data object is stored * * RETURN: Status * * DESCRIPTION: Read from a named field. Returns either an Integer or a * Buffer, depending on the size of the field. * ******************************************************************************/ ACPI_STATUS AcpiExReadDataFromField ( ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **RetBufferDesc) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *BufferDesc; UINT32 Length; void *Buffer; BOOLEAN Locked; ACPI_FUNCTION_TRACE_PTR ("ExReadDataFromField", ObjDesc); /* Parameter validation */ if (!ObjDesc) { return_ACPI_STATUS (AE_AML_NO_OPERAND); } if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_BUFFER_FIELD) { /* * If the BufferField arguments have not been previously evaluated, * evaluate them now and save the results. */ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) { Status = AcpiDsGetBufferFieldArguments (ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } } + else if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_REGION_FIELD) && + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)) + { + /* + * This is an SMBus read. We must create a buffer to hold the data + * and directly access the region handler. + */ + BufferDesc = AcpiUtCreateBufferObject (ACPI_SMBUS_BUFFER_SIZE); + if (!BufferDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Lock entire transaction if requested */ + + Locked = AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* + * Perform the read. + * 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)); + AcpiExReleaseGlobalLock (Locked); + goto Exit; + } /* * Allocate a buffer for the contents of the field. * * If the field is larger than the size of an ACPI_INTEGER, create * a BUFFER to hold it. Otherwise, use an INTEGER. This allows * the use of arithmetic operators on the returned value if the * field size is equal or smaller than an Integer. * * Note: Field.length is in bits. */ Length = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength); if (Length > AcpiGbl_IntegerByteWidth) { /* Field is too large for an Integer, create a Buffer instead */ - BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + BufferDesc = AcpiUtCreateBufferObject (Length); if (!BufferDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } - - /* Create the actual read buffer */ - - BufferDesc->Buffer.Pointer = ACPI_MEM_CALLOCATE (Length); - if (!BufferDesc->Buffer.Pointer) - { - AcpiUtRemoveReference (BufferDesc); - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Complete the buffer object initialization */ - - BufferDesc->Common.Flags = AOPOBJ_DATA_VALID; - BufferDesc->Buffer.Length = Length; Buffer = BufferDesc->Buffer.Pointer; } else { /* Field will fit within an Integer (normal case) */ BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!BufferDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } Length = AcpiGbl_IntegerByteWidth; BufferDesc->Integer.Value = 0; Buffer = &BufferDesc->Integer.Value; } ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Obj=%p Type=%X Buf=%p Len=%X\n", ObjDesc, ACPI_GET_OBJECT_TYPE (ObjDesc), Buffer, Length)); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "FieldWrite: BitLen=%X BitOff=%X ByteOff=%X\n", ObjDesc->CommonField.BitLength, ObjDesc->CommonField.StartFieldBitOffset, ObjDesc->CommonField.BaseByteOffset)); + /* Lock entire transaction if requested */ + Locked = AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); /* Read from the field */ Status = AcpiExExtractFromField (ObjDesc, Buffer, Length); - - /* - * Release global lock if we acquired it earlier - */ AcpiExReleaseGlobalLock (Locked); + +Exit: if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (BufferDesc); } else if (RetBufferDesc) { *RetBufferDesc = BufferDesc; } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExWriteDataToField * * PARAMETERS: SourceDesc - Contains data to write * ObjDesc - The named field * * RETURN: Status * * DESCRIPTION: Write to a named field * ******************************************************************************/ ACPI_STATUS AcpiExWriteDataToField ( ACPI_OPERAND_OBJECT *SourceDesc, - ACPI_OPERAND_OBJECT *ObjDesc) + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc) { ACPI_STATUS Status; UINT32 Length; UINT32 RequiredLength; void *Buffer; void *NewBuffer; BOOLEAN Locked; + ACPI_OPERAND_OBJECT *BufferDesc; ACPI_FUNCTION_TRACE_PTR ("ExWriteDataToField", ObjDesc); /* Parameter validation */ if (!SourceDesc || !ObjDesc) { return_ACPI_STATUS (AE_AML_NO_OPERAND); } if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_BUFFER_FIELD) { /* * If the BufferField arguments have not been previously evaluated, * evaluate them now and save the results. */ if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) { Status = AcpiDsGetBufferFieldArguments (ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } } + else if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_REGION_FIELD) && + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)) + { + /* + * This is an SMBus write. We will bypass the entire field mechanism + * and handoff the buffer directly to the handler. + * + * Source must be a buffer of sufficient size (ACPI_SMBUS_BUFFER_SIZE). + */ + if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_BUFFER) + { + 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_SMBUS_BUFFER_SIZE, SourceDesc->Buffer.Length)); + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + } + + BufferDesc = AcpiUtCreateBufferObject (ACPI_SMBUS_BUFFER_SIZE); + if (!BufferDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Buffer = BufferDesc->Buffer.Pointer; + 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) + * Note: SMBus protocol type is passed in upper 16-bits of Function. + */ + Status = AcpiExAccessRegion (ObjDesc, 0, + (ACPI_INTEGER *) Buffer, + ACPI_WRITE | (ObjDesc->Field.Attribute << 16)); + AcpiExReleaseGlobalLock (Locked); + + *ResultDesc = BufferDesc; + return_ACPI_STATUS (Status); + } /* * Get a pointer to the data to be written */ switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) { case ACPI_TYPE_INTEGER: Buffer = &SourceDesc->Integer.Value; Length = sizeof (SourceDesc->Integer.Value); break; case ACPI_TYPE_BUFFER: Buffer = SourceDesc->Buffer.Pointer; Length = SourceDesc->Buffer.Length; break; case ACPI_TYPE_STRING: Buffer = SourceDesc->String.Pointer; Length = SourceDesc->String.Length; break; default: return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* * We must have a buffer that is at least as long as the field * we are writing to. This is because individual fields are * indivisible and partial writes are not supported -- as per * the ACPI specification. */ NewBuffer = NULL; RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength); if (Length < RequiredLength) { /* We need to create a new buffer */ NewBuffer = ACPI_MEM_CALLOCATE (RequiredLength); if (!NewBuffer) { return_ACPI_STATUS (AE_NO_MEMORY); } /* * Copy the original data to the new buffer, starting * at Byte zero. All unused (upper) bytes of the * buffer will be 0. */ ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, Length); Buffer = NewBuffer; Length = RequiredLength; } ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Obj=%p Type=%X Buf=%p Len=%X\n", ObjDesc, ACPI_GET_OBJECT_TYPE (ObjDesc), Buffer, Length)); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "FieldRead: BitLen=%X BitOff=%X ByteOff=%X\n", ObjDesc->CommonField.BitLength, ObjDesc->CommonField.StartFieldBitOffset, ObjDesc->CommonField.BaseByteOffset)); + /* Lock entire transaction if requested */ + Locked = AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); - /* - * Write to the field - */ - Status = AcpiExInsertIntoField (ObjDesc, Buffer, Length); + /* Write to the field */ - /* - * Release global lock if we acquired it earlier - */ + Status = AcpiExInsertIntoField (ObjDesc, Buffer, Length); AcpiExReleaseGlobalLock (Locked); /* Free temporary buffer if we used one */ if (NewBuffer) { ACPI_MEM_FREE (NewBuffer); } return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exmisc.c b/sys/contrib/dev/acpica/exmisc.c index 537217b89c2e..7343ac5b596a 100644 --- a/sys/contrib/dev/acpica/exmisc.c +++ b/sys/contrib/dev/acpica/exmisc.c @@ -1,666 +1,620 @@ /****************************************************************************** * * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes - * $Revision: 109 $ + * $Revision: 112 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXMISC_C__ #include "acpi.h" #include "acinterp.h" #include "amlcode.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exmisc") /******************************************************************************* * * FUNCTION: AcpiExGetObjectReference * * PARAMETERS: ObjDesc - Create a reference to this object * ReturnDesc - Where to store the reference * WalkState - Current state * * RETURN: Status * * DESCRIPTION: Obtain and return a "reference" to the target object * Common code for the RefOfOp and the CondRefOfOp. * ******************************************************************************/ ACPI_STATUS AcpiExGetObjectReference ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_OPERAND_OBJECT **ReturnDesc, ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT *ReferenceObj; ACPI_OPERAND_OBJECT *ReferencedObj; ACPI_FUNCTION_TRACE_PTR ("ExGetObjectReference", ObjDesc); *ReturnDesc = NULL; switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) { case ACPI_DESC_TYPE_OPERAND: - if (ACPI_GET_OBJECT_TYPE (ObjDesc) != INTERNAL_TYPE_REFERENCE) + if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_LOCAL_REFERENCE) { return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* * Must be a reference to a Local or Arg */ switch (ObjDesc->Reference.Opcode) { case AML_LOCAL_OP: case AML_ARG_OP: /* The referenced object is the pseudo-node for the local/arg */ ReferencedObj = ObjDesc->Reference.Object; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference subtype %X\n", ObjDesc->Reference.Opcode)); return_ACPI_STATUS (AE_AML_INTERNAL); } break; case ACPI_DESC_TYPE_NAMED: /* * A named reference that has already been resolved to a Node */ ReferencedObj = ObjDesc; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid descriptor type %X in %p\n", ACPI_GET_DESCRIPTOR_TYPE (ObjDesc), ObjDesc)); return_ACPI_STATUS (AE_TYPE); } /* Create a new reference object */ - ReferenceObj = AcpiUtCreateInternalObject (INTERNAL_TYPE_REFERENCE); + ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); if (!ReferenceObj) { return_ACPI_STATUS (AE_NO_MEMORY); } ReferenceObj->Reference.Opcode = AML_REF_OF_OP; ReferenceObj->Reference.Object = ReferencedObj; *ReturnDesc = ReferenceObj; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p Type [%s], returning Reference %p\n", ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc)); return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiExConcatTemplate * * PARAMETERS: *ObjDesc - Object to be converted. Must be an * Integer, Buffer, or String * WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: Concatenate two resource templates * ******************************************************************************/ ACPI_STATUS AcpiExConcatTemplate ( ACPI_OPERAND_OBJECT *ObjDesc1, ACPI_OPERAND_OBJECT *ObjDesc2, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState) { - ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ReturnDesc; - NATIVE_CHAR *NewBuf; + UINT8 *NewBuf; UINT8 *EndTag1; UINT8 *EndTag2; ACPI_SIZE Length1; ACPI_SIZE Length2; ACPI_FUNCTION_TRACE ("ExConcatTemplate"); /* Find the EndTags in each resource template */ EndTag1 = AcpiUtGetResourceEndTag (ObjDesc1); EndTag2 = AcpiUtGetResourceEndTag (ObjDesc2); if (!EndTag1 || !EndTag2) { return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } - /* Create a new buffer object for the result */ - - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); - if (!ReturnDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - /* Allocate a new buffer for the result */ + /* Compute the length of each part */ Length1 = ACPI_PTR_DIFF (EndTag1, ObjDesc1->Buffer.Pointer); Length2 = ACPI_PTR_DIFF (EndTag2, ObjDesc2->Buffer.Pointer) + 2; /* Size of END_TAG */ - NewBuf = ACPI_MEM_ALLOCATE (Length1 + Length2); - if (!NewBuf) + /* Create a new buffer object for the result */ + + ReturnDesc = AcpiUtCreateBufferObject (Length1 + Length2); + if (!ReturnDesc) { - ACPI_REPORT_ERROR - (("ExConcatTemplate: Buffer allocation failure\n")); - Status = AE_NO_MEMORY; - goto Cleanup; + return_ACPI_STATUS (AE_NO_MEMORY); } /* Copy the templates to the new descriptor */ + NewBuf = ReturnDesc->Buffer.Pointer; ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer, Length1); ACPI_MEMCPY (NewBuf + Length1, ObjDesc2->Buffer.Pointer, Length2); - /* Complete the buffer object initialization */ - - ReturnDesc->Common.Flags = AOPOBJ_DATA_VALID; - ReturnDesc->Buffer.Pointer = (UINT8 *) NewBuf; - ReturnDesc->Buffer.Length = (UINT32) (Length1 + Length2); - /* Compute the new checksum */ - NewBuf[ReturnDesc->Buffer.Length - 1] = (NATIVE_CHAR) + NewBuf[ReturnDesc->Buffer.Length - 1] = AcpiUtGenerateChecksum (ReturnDesc->Buffer.Pointer, - (ReturnDesc->Buffer.Length - 1)); + (ReturnDesc->Buffer.Length - 1)); /* Return the completed template descriptor */ *ActualReturnDesc = ReturnDesc; return_ACPI_STATUS (AE_OK); - - -Cleanup: - - AcpiUtRemoveReference (ReturnDesc); - return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExDoConcatenate * * PARAMETERS: ObjDesc1 - First source object * ObjDesc2 - Second source object * ActualReturnDesc - Where to place the return object * WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: Concatenate two objects OF THE SAME TYPE. * ******************************************************************************/ ACPI_STATUS AcpiExDoConcatenate ( ACPI_OPERAND_OBJECT *ObjDesc1, ACPI_OPERAND_OBJECT *ObjDesc2, ACPI_OPERAND_OBJECT **ActualReturnDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; UINT32 i; ACPI_INTEGER ThisInteger; ACPI_OPERAND_OBJECT *ReturnDesc; NATIVE_CHAR *NewBuf; ACPI_FUNCTION_ENTRY (); /* * There are three cases to handle: * * 1) Two Integers concatenated to produce a new Buffer * 2) Two Strings concatenated to produce a new String * 3) Two Buffers concatenated to produce a new Buffer */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc1)) { case ACPI_TYPE_INTEGER: /* Result of two Integers is a Buffer */ + /* Need enough buffer space for two integers */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth * 2); if (!ReturnDesc) { return (AE_NO_MEMORY); } - /* Need enough buffer space for two integers */ - - ReturnDesc->Buffer.Length = AcpiGbl_IntegerByteWidth * 2; - NewBuf = ACPI_MEM_CALLOCATE (ReturnDesc->Buffer.Length); - if (!NewBuf) - { - ACPI_REPORT_ERROR - (("ExDoConcatenate: Buffer allocation failure\n")); - Status = AE_NO_MEMORY; - goto Cleanup; - } + NewBuf = (NATIVE_CHAR *) ReturnDesc->Buffer.Pointer; /* Convert the first integer */ ThisInteger = ObjDesc1->Integer.Value; for (i = 0; i < AcpiGbl_IntegerByteWidth; i++) { NewBuf[i] = (NATIVE_CHAR) ThisInteger; ThisInteger >>= 8; } /* Convert the second integer */ ThisInteger = ObjDesc2->Integer.Value; for (; i < (ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); i++) { NewBuf[i] = (NATIVE_CHAR) ThisInteger; ThisInteger >>= 8; } - /* Complete the buffer object initialization */ - - ReturnDesc->Common.Flags = AOPOBJ_DATA_VALID; - ReturnDesc->Buffer.Pointer = (UINT8 *) NewBuf; break; case ACPI_TYPE_STRING: /* Result of two Strings is a String */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); if (!ReturnDesc) { return (AE_NO_MEMORY); } /* Operand0 is string */ NewBuf = ACPI_MEM_ALLOCATE ((ACPI_SIZE) ObjDesc1->String.Length + (ACPI_SIZE) ObjDesc2->String.Length + 1); if (!NewBuf) { ACPI_REPORT_ERROR (("ExDoConcatenate: String allocation failure\n")); Status = AE_NO_MEMORY; goto Cleanup; } /* Concatenate the strings */ ACPI_STRCPY (NewBuf, ObjDesc1->String.Pointer); ACPI_STRCPY (NewBuf + ObjDesc1->String.Length, ObjDesc2->String.Pointer); /* Complete the String object initialization */ ReturnDesc->String.Pointer = NewBuf; ReturnDesc->String.Length = ObjDesc1->String.Length + ObjDesc2->String.Length; break; case ACPI_TYPE_BUFFER: /* Result of two Buffers is a Buffer */ - ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + ReturnDesc = AcpiUtCreateBufferObject ( + (ACPI_SIZE) ObjDesc1->Buffer.Length + + (ACPI_SIZE) ObjDesc2->Buffer.Length); if (!ReturnDesc) { return (AE_NO_MEMORY); } - NewBuf = ACPI_MEM_ALLOCATE ((ACPI_SIZE) ObjDesc1->Buffer.Length + - (ACPI_SIZE) ObjDesc2->Buffer.Length); - if (!NewBuf) - { - ACPI_REPORT_ERROR - (("ExDoConcatenate: Buffer allocation failure\n")); - Status = AE_NO_MEMORY; - goto Cleanup; - } + NewBuf = (NATIVE_CHAR *) ReturnDesc->Buffer.Pointer; /* Concatenate the buffers */ ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer, ObjDesc1->Buffer.Length); ACPI_MEMCPY (NewBuf + ObjDesc1->Buffer.Length, ObjDesc2->Buffer.Pointer, ObjDesc2->Buffer.Length); - /* Complete the buffer object initialization */ - - ReturnDesc->Common.Flags = AOPOBJ_DATA_VALID; - ReturnDesc->Buffer.Pointer = (UINT8 *) NewBuf; - ReturnDesc->Buffer.Length = ObjDesc1->Buffer.Length + - ObjDesc2->Buffer.Length; break; default: /* Invalid object type, should not happen here */ Status = AE_AML_INTERNAL; ReturnDesc = NULL; } *ActualReturnDesc = ReturnDesc; return (AE_OK); Cleanup: AcpiUtRemoveReference (ReturnDesc); return (Status); } /******************************************************************************* * * FUNCTION: AcpiExDoMathOp * * PARAMETERS: Opcode - AML opcode * Operand0 - Integer operand #0 * Operand1 - Integer operand #1 * * RETURN: Integer result of the operation * * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the * math functions here is to prevent a lot of pointer dereferencing * to obtain the operands. * ******************************************************************************/ ACPI_INTEGER AcpiExDoMathOp ( UINT16 Opcode, ACPI_INTEGER Operand0, ACPI_INTEGER Operand1) { switch (Opcode) { case AML_ADD_OP: /* Add (Operand0, Operand1, Result) */ return (Operand0 + Operand1); case AML_BIT_AND_OP: /* And (Operand0, Operand1, Result) */ return (Operand0 & Operand1); case AML_BIT_NAND_OP: /* NAnd (Operand0, Operand1, Result) */ return (~(Operand0 & Operand1)); case AML_BIT_OR_OP: /* Or (Operand0, Operand1, Result) */ return (Operand0 | Operand1); case AML_BIT_NOR_OP: /* NOr (Operand0, Operand1, Result) */ return (~(Operand0 | Operand1)); case AML_BIT_XOR_OP: /* XOr (Operand0, Operand1, Result) */ return (Operand0 ^ Operand1); case AML_MULTIPLY_OP: /* Multiply (Operand0, Operand1, Result) */ return (Operand0 * Operand1); case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result) */ return (Operand0 << Operand1); case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */ return (Operand0 >> Operand1); case AML_SUBTRACT_OP: /* Subtract (Operand0, Operand1, Result) */ return (Operand0 - Operand1); default: return (0); } } /******************************************************************************* * * FUNCTION: AcpiExDoLogicalOp * * PARAMETERS: Opcode - AML opcode * Operand0 - Integer operand #0 * Operand1 - Integer operand #1 * * RETURN: TRUE/FALSE result of the operation * * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the * functions here is to prevent a lot of pointer dereferencing * to obtain the operands and to simplify the generation of the * logical value. * * Note: cleanest machine code seems to be produced by the code * below, rather than using statements of the form: * Result = (Operand0 == Operand1); * ******************************************************************************/ BOOLEAN AcpiExDoLogicalOp ( UINT16 Opcode, ACPI_INTEGER Operand0, ACPI_INTEGER Operand1) { switch (Opcode) { case AML_LAND_OP: /* LAnd (Operand0, Operand1) */ if (Operand0 && Operand1) { return (TRUE); } break; case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ if (Operand0 == Operand1) { return (TRUE); } break; case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ if (Operand0 > Operand1) { return (TRUE); } break; case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ if (Operand0 < Operand1) { return (TRUE); } break; case AML_LOR_OP: /* LOr (Operand0, Operand1) */ if (Operand0 || Operand1) { return (TRUE); } break; default: break; } return (FALSE); } diff --git a/sys/contrib/dev/acpica/exmutex.c b/sys/contrib/dev/acpica/exmutex.c index 51d6be39e2eb..3f4c8f09d6b5 100644 --- a/sys/contrib/dev/acpica/exmutex.c +++ b/sys/contrib/dev/acpica/exmutex.c @@ -1,413 +1,445 @@ /****************************************************************************** * * Module Name: exmutex - ASL Mutex Acquire/Release functions - * $Revision: 13 $ + * $Revision: 16 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXMUTEX_C__ #include "acpi.h" #include "acinterp.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exmutex") /******************************************************************************* * * FUNCTION: AcpiExUnlinkMutex * * PARAMETERS: *ObjDesc - The mutex to be unlinked * * RETURN: Status * * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list * ******************************************************************************/ void AcpiExUnlinkMutex ( ACPI_OPERAND_OBJECT *ObjDesc) { ACPI_THREAD_STATE *Thread = ObjDesc->Mutex.OwnerThread; if (!Thread) { return; } if (ObjDesc->Mutex.Next) { (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev; } if (ObjDesc->Mutex.Prev) { (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next; } else { Thread->AcquiredMutexList = ObjDesc->Mutex.Next; } } /******************************************************************************* * * FUNCTION: AcpiExLinkMutex * * PARAMETERS: *ObjDesc - The mutex to be linked * *ListHead - head of the "AcquiredMutex" list * * RETURN: Status * * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk * ******************************************************************************/ void AcpiExLinkMutex ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_THREAD_STATE *Thread) { ACPI_OPERAND_OBJECT *ListHead; ListHead = Thread->AcquiredMutexList; /* This object will be the first object in the list */ ObjDesc->Mutex.Prev = NULL; ObjDesc->Mutex.Next = ListHead; /* Update old first object to point back to this object */ if (ListHead) { ListHead->Mutex.Prev = ObjDesc; } /* Update list head */ Thread->AcquiredMutexList = ObjDesc; } /******************************************************************************* * * FUNCTION: AcpiExAcquireMutex * * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor * *ObjDesc - The object descriptor for this op * * RETURN: Status * * DESCRIPTION: Acquire an AML mutex * ******************************************************************************/ ACPI_STATUS AcpiExAcquireMutex ( ACPI_OPERAND_OBJECT *TimeDesc, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE_PTR ("ExAcquireMutex", ObjDesc); + if (!ObjDesc) { return_ACPI_STATUS (AE_BAD_PARAMETER); } + /* Sanity check -- we must have a valid thread ID */ + + if (!WalkState->Thread) + { + ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], null thread info\n", + ObjDesc->Mutex.Node->Name.Ascii)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + /* * Current Sync must be less than or equal to the sync level of the * mutex. This mechanism provides some deadlock prevention */ if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel) { + ACPI_REPORT_ERROR (("Cannot acquire Mutex [%4.4s], incorrect SyncLevel\n", + ObjDesc->Mutex.Node->Name.Ascii)); return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } /* * Support for multiple acquires by the owning thread */ - if (ObjDesc->Mutex.OwnerThread == WalkState->Thread) + + if ((ObjDesc->Mutex.OwnerThread) && + (ObjDesc->Mutex.OwnerThread->ThreadId == WalkState->Thread->ThreadId)) { /* * The mutex is already owned by this thread, * just increment the acquisition depth */ ObjDesc->Mutex.AcquisitionDepth++; return_ACPI_STATUS (AE_OK); } /* Acquire the mutex, wait if necessary */ Status = AcpiExSystemAcquireMutex (TimeDesc, ObjDesc); if (ACPI_FAILURE (Status)) { /* Includes failure from a timeout on TimeDesc */ return_ACPI_STATUS (Status); } /* Have the mutex, update mutex and walk info */ ObjDesc->Mutex.OwnerThread = WalkState->Thread; ObjDesc->Mutex.AcquisitionDepth = 1; WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; /* Link the mutex to the current thread for force-unlock at method exit */ AcpiExLinkMutex (ObjDesc, WalkState->Thread); return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiExReleaseMutex * * PARAMETERS: *ObjDesc - The object descriptor for this op * * RETURN: Status * * DESCRIPTION: Release a previously acquired Mutex. * ******************************************************************************/ ACPI_STATUS AcpiExReleaseMutex ( ACPI_OPERAND_OBJECT *ObjDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("ExReleaseMutex"); if (!ObjDesc) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* The mutex must have been previously acquired in order to release it */ if (!ObjDesc->Mutex.OwnerThread) { + ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], not acquired\n", + ObjDesc->Mutex.Node->Name.Ascii)); return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED); } + /* Sanity check -- we must have a valid thread ID */ + + if (!WalkState->Thread) + { + ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], null thread info\n", + ObjDesc->Mutex.Node->Name.Ascii)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + /* The Mutex is owned, but this thread must be the owner */ - if (ObjDesc->Mutex.OwnerThread != WalkState->Thread) + if (ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId) { + ACPI_REPORT_ERROR (( + "Thread %X cannot release Mutex [%4.4s] acquired by thread %X\n", + WalkState->Thread->ThreadId, + ObjDesc->Mutex.Node->Name.Ascii, + ObjDesc->Mutex.OwnerThread->ThreadId)); return_ACPI_STATUS (AE_AML_NOT_OWNER); } /* * The sync level of the mutex must be less than or * equal to the current sync level */ if (ObjDesc->Mutex.SyncLevel > WalkState->Thread->CurrentSyncLevel) { + ACPI_REPORT_ERROR (("Cannot release Mutex [%4.4s], incorrect SyncLevel\n", + ObjDesc->Mutex.Node->Name.Ascii)); return_ACPI_STATUS (AE_AML_MUTEX_ORDER); } /* * Match multiple Acquires with multiple Releases */ ObjDesc->Mutex.AcquisitionDepth--; if (ObjDesc->Mutex.AcquisitionDepth != 0) { /* Just decrement the depth and return */ return_ACPI_STATUS (AE_OK); } /* Unlink the mutex from the owner's list */ AcpiExUnlinkMutex (ObjDesc); /* Release the mutex */ Status = AcpiExSystemReleaseMutex (ObjDesc); /* Update the mutex and walk state */ ObjDesc->Mutex.OwnerThread = NULL; WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExReleaseAllMutexes * * PARAMETERS: *MutexList - Head of the mutex list * * RETURN: Status * * DESCRIPTION: Release all mutexes in the list * ******************************************************************************/ void AcpiExReleaseAllMutexes ( ACPI_THREAD_STATE *Thread) { ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList; ACPI_OPERAND_OBJECT *This; ACPI_STATUS Status; ACPI_FUNCTION_ENTRY (); /* * Traverse the list of owned mutexes, releasing each one. */ while (Next) { This = Next; Next = This->Mutex.Next; This->Mutex.AcquisitionDepth = 1; This->Mutex.Prev = NULL; This->Mutex.Next = NULL; /* Release the mutex */ Status = AcpiExSystemReleaseMutex (This); if (ACPI_FAILURE (Status)) { continue; } /* Mark mutex unowned */ This->Mutex.OwnerThread = NULL; } } diff --git a/sys/contrib/dev/acpica/exnames.c b/sys/contrib/dev/acpica/exnames.c index 5ac03cc8115a..8069189c465f 100644 --- a/sys/contrib/dev/acpica/exnames.c +++ b/sys/contrib/dev/acpica/exnames.c @@ -1,531 +1,531 @@ /****************************************************************************** * * Module Name: exnames - interpreter/scanner name load/execute - * $Revision: 91 $ + * $Revision: 92 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXNAMES_C__ #include "acpi.h" #include "acinterp.h" #include "amlcode.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exnames") /* 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 /******************************************************************************* * * FUNCTION: AcpiExAllocateNameString * * PARAMETERS: PrefixCount - Count of parent levels. Special cases: * (-1) = root, 0 = none * NumNameSegs - count of 4-character name segments * * RETURN: A pointer to the allocated string segment. This segment must * be deleted by the caller. * * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name * string is long enough, and set up prefix if any. * ******************************************************************************/ NATIVE_CHAR * AcpiExAllocateNameString ( UINT32 PrefixCount, UINT32 NumNameSegs) { NATIVE_CHAR *TempPtr; NATIVE_CHAR *NameString; UINT32 SizeNeeded; ACPI_FUNCTION_TRACE ("ExAllocateNameString"); /* * 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. */ if (PrefixCount == ACPI_UINT32_MAX) { /* Special case for root */ SizeNeeded = 1 + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1; } else { SizeNeeded = PrefixCount + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1; } /* * Allocate a buffer for the name. * This buffer must be deleted by the caller! */ NameString = ACPI_MEM_ALLOCATE (SizeNeeded); if (!NameString) { ACPI_REPORT_ERROR (("ExAllocateNameString: Could not allocate size %d\n", SizeNeeded)); return_PTR (NULL); } TempPtr = NameString; /* Set up Root or Parent prefixes if needed */ if (PrefixCount == ACPI_UINT32_MAX) { *TempPtr++ = AML_ROOT_PREFIX; } else { while (PrefixCount--) { *TempPtr++ = AML_PARENT_PREFIX; } } /* Set up Dual or Multi prefixes if needed */ if (NumNameSegs > 2) { /* Set up multi prefixes */ *TempPtr++ = AML_MULTI_NAME_PREFIX_OP; *TempPtr++ = (char) NumNameSegs; } else if (2 == NumNameSegs) { /* Set up dual prefixes */ *TempPtr++ = AML_DUAL_NAME_PREFIX; } /* * Terminate string following prefixes. AcpiExNameSegment() will * append the segment(s) */ *TempPtr = 0; return_PTR (NameString); } /******************************************************************************* * * FUNCTION: AcpiExNameSegment * * PARAMETERS: InterpreterMode - Current running mode (load1/Load2/Exec) * * RETURN: Status * * DESCRIPTION: Execute a name segment (4 bytes) * ******************************************************************************/ ACPI_STATUS AcpiExNameSegment ( UINT8 **InAmlAddress, NATIVE_CHAR *NameString) { char *AmlAddress = (void *) *InAmlAddress; ACPI_STATUS Status = AE_OK; UINT32 Index; char CharBuf[5]; ACPI_FUNCTION_TRACE ("ExNameSegment"); /* * If first character is a digit, then we know that we aren't looking at a * valid name segment */ CharBuf[0] = *AmlAddress; if ('0' <= CharBuf[0] && CharBuf[0] <= '9') { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "leading digit: %c\n", CharBuf[0])); return_ACPI_STATUS (AE_CTRL_PENDING); } ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n")); for (Index = 0; (Index < ACPI_NAME_SIZE) && (AcpiUtValidAcpiCharacter (*AmlAddress)); Index++) { CharBuf[Index] = *AmlAddress++; ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", CharBuf[Index])); } /* Valid name segment */ if (Index == 4) { /* Found 4 valid characters */ CharBuf[4] = '\0'; if (NameString) { ACPI_STRCAT (NameString, CharBuf); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Appended to - %s \n", NameString)); } else { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "No Name string - %s \n", CharBuf)); } } else if (Index == 0) { /* * First character was not a valid name character, * so we are looking at something other than a name. */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Leading character is not alpha: %02Xh (not a name)\n", CharBuf[0])); Status = AE_CTRL_PENDING; } else { /* Segment started with one or more valid characters, but fewer than 4 */ Status = AE_AML_BAD_NAME; ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad character %02x in name, at %p\n", *AmlAddress, AmlAddress)); } *InAmlAddress = (UINT8 *) AmlAddress; return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExGetNameString * * PARAMETERS: DataType - Data type to be associated with this name * * RETURN: Status * * DESCRIPTION: Get a name, including any prefixes. * ******************************************************************************/ ACPI_STATUS AcpiExGetNameString ( ACPI_OBJECT_TYPE DataType, UINT8 *InAmlAddress, NATIVE_CHAR **OutNameString, UINT32 *OutNameLength) { ACPI_STATUS Status = AE_OK; UINT8 *AmlAddress = InAmlAddress; NATIVE_CHAR *NameString = NULL; UINT32 NumSegments; UINT32 PrefixCount = 0; BOOLEAN HasPrefix = FALSE; ACPI_FUNCTION_TRACE_PTR ("ExGetNameString", AmlAddress); - if (INTERNAL_TYPE_REGION_FIELD == DataType || - INTERNAL_TYPE_BANK_FIELD == DataType || - INTERNAL_TYPE_INDEX_FIELD == DataType) + if (ACPI_TYPE_LOCAL_REGION_FIELD == DataType || + ACPI_TYPE_LOCAL_BANK_FIELD == DataType || + ACPI_TYPE_LOCAL_INDEX_FIELD == DataType) { /* Disallow prefixes for types associated with FieldUnit names */ NameString = AcpiExAllocateNameString (0, 1); if (!NameString) { Status = AE_NO_MEMORY; } else { Status = AcpiExNameSegment (&AmlAddress, NameString); } } else { /* * DataType is not a field name. * Examine first character of name for root or parent prefix operators */ switch (*AmlAddress) { case AML_ROOT_PREFIX: ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n", AmlAddress)); /* * Remember that we have a RootPrefix -- * see comment in AcpiExAllocateNameString() */ AmlAddress++; PrefixCount = ACPI_UINT32_MAX; HasPrefix = TRUE; break; case AML_PARENT_PREFIX: /* Increment past possibly multiple parent prefixes */ do { ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n", AmlAddress)); AmlAddress++; PrefixCount++; } while (*AmlAddress == AML_PARENT_PREFIX); HasPrefix = TRUE; break; default: /* Not a prefix character */ 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)); AmlAddress++; NameString = AcpiExAllocateNameString (PrefixCount, 2); if (!NameString) { Status = AE_NO_MEMORY; break; } /* Indicate that we processed a prefix */ HasPrefix = TRUE; Status = AcpiExNameSegment (&AmlAddress, NameString); if (ACPI_SUCCESS (Status)) { Status = AcpiExNameSegment (&AmlAddress, NameString); } break; case AML_MULTI_NAME_PREFIX_OP: ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n", AmlAddress)); /* Fetch count of segments remaining in name path */ AmlAddress++; NumSegments = *AmlAddress; NameString = AcpiExAllocateNameString (PrefixCount, NumSegments); if (!NameString) { Status = AE_NO_MEMORY; break; } /* Indicate that we processed a prefix */ AmlAddress++; HasPrefix = TRUE; while (NumSegments && (Status = AcpiExNameSegment (&AmlAddress, NameString)) == AE_OK) { NumSegments--; } break; case 0: /* NullName valid as of 8-12-98 ASL/AML Grammar Update */ if (PrefixCount == ACPI_UINT32_MAX) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "NameSeg is \"\\\" followed by NULL\n")); } /* Consume the NULL byte */ AmlAddress++; NameString = AcpiExAllocateNameString (PrefixCount, 0); if (!NameString) { Status = AE_NO_MEMORY; break; } break; default: /* Name segment string */ NameString = AcpiExAllocateNameString (PrefixCount, 1); if (!NameString) { Status = AE_NO_MEMORY; break; } Status = AcpiExNameSegment (&AmlAddress, NameString); break; } } if (AE_CTRL_PENDING == Status && HasPrefix) { /* Ran out of segments after processing a prefix */ ACPI_REPORT_ERROR ( ("ExDoName: Malformed Name at %p\n", NameString)); Status = AE_AML_BAD_NAME; } *OutNameString = NameString; *OutNameLength = (UINT32) (AmlAddress - InAmlAddress); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exoparg1.c b/sys/contrib/dev/acpica/exoparg1.c index 60d65b74ea9d..1600e62e56c0 100644 --- a/sys/contrib/dev/acpica/exoparg1.c +++ b/sys/contrib/dev/acpica/exoparg1.c @@ -1,982 +1,984 @@ /****************************************************************************** * * Module Name: exoparg1 - AML execution - opcodes with 1 argument - * $Revision: 143 $ + * $Revision: 146 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXOPARG1_C__ #include "acpi.h" #include "acparser.h" #include "acdispat.h" #include "acinterp.h" #include "amlcode.h" #include "acnamesp.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exoparg1") /*! * Naming convention for AML interpreter execution routines. * * The routines that begin execution of AML opcodes are named with a common * convention based upon the number of arguments, the number of target operands, * and whether or not a value is returned: * * AcpiExOpcode_xA_yT_zR * * Where: * * xA - ARGUMENTS: The number of arguments (input operands) that are * required for this opcode type (1 through 6 args). * yT - TARGETS: The number of targets (output operands) that are required * for this opcode type (0, 1, or 2 targets). * zR - RETURN VALUE: Indicates whether this opcode type returns a value * as the function return (0 or 1). * * The AcpiExOpcode* functions are called via the Dispatcher component with * fully resolved operands. !*/ /******************************************************************************* * * FUNCTION: AcpiExOpcode_1A_0T_0R * * PARAMETERS: WalkState - Current state (contains AML opcode) * * RETURN: Status * * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on * object stack * ******************************************************************************/ ACPI_STATUS AcpiExOpcode_1A_0T_0R ( ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ switch (WalkState->Opcode) { case AML_RELEASE_OP: /* Release (MutexObject) */ Status = AcpiExReleaseMutex (Operand[0], WalkState); break; case AML_RESET_OP: /* Reset (EventObject) */ Status = AcpiExSystemResetEvent (Operand[0]); break; case AML_SIGNAL_OP: /* Signal (EventObject) */ Status = AcpiExSystemSignalEvent (Operand[0]); break; case AML_SLEEP_OP: /* Sleep (MsecTime) */ Status = AcpiExSystemDoSuspend ((UINT32) Operand[0]->Integer.Value); break; case AML_STALL_OP: /* Stall (UsecTime) */ Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value); break; case AML_UNLOAD_OP: /* Unload (Handle) */ Status = AcpiExUnloadTable (Operand[0]); break; default: /* Unknown opcode */ ACPI_REPORT_ERROR (("AcpiExOpcode_1A_0T_0R: Unknown opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; break; } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExOpcode_1A_1T_0R * * PARAMETERS: WalkState - Current state (contains AML opcode) * * RETURN: Status * * DESCRIPTION: Execute opcode with one argument, one target, and no * return value. * ******************************************************************************/ ACPI_STATUS AcpiExOpcode_1A_1T_0R ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ switch (WalkState->Opcode) { case AML_LOAD_OP: Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState); break; default: /* Unknown opcode */ ACPI_REPORT_ERROR (("AcpiExOpcode_1A_1T_0R: Unknown opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } Cleanup: return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExOpcode_1A_1T_1R * * PARAMETERS: WalkState - Current state (contains AML opcode) * * RETURN: Status * * DESCRIPTION: Execute opcode with one argument, one target, and a * return value. * ******************************************************************************/ ACPI_STATUS AcpiExOpcode_1A_1T_1R ( ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; UINT32 Temp32; UINT32 i; UINT32 j; ACPI_INTEGER Digit; ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ switch (WalkState->Opcode) { case AML_BIT_NOT_OP: case AML_FIND_SET_LEFT_BIT_OP: case AML_FIND_SET_RIGHT_BIT_OP: case AML_FROM_BCD_OP: case AML_TO_BCD_OP: case AML_COND_REF_OF_OP: /* Create a return object of type Integer for these opcodes */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } switch (WalkState->Opcode) { case AML_BIT_NOT_OP: /* Not (Operand, Result) */ ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value; break; case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */ ReturnDesc->Integer.Value = Operand[0]->Integer.Value; /* * Acpi specification describes Integer type as a little * endian unsigned value, so this boundary condition is valid. */ for (Temp32 = 0; ReturnDesc->Integer.Value && Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) { ReturnDesc->Integer.Value >>= 1; } ReturnDesc->Integer.Value = Temp32; break; case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */ ReturnDesc->Integer.Value = Operand[0]->Integer.Value; /* * The Acpi specification describes Integer type as a little * endian unsigned value, so this boundary condition is valid. */ for (Temp32 = 0; ReturnDesc->Integer.Value && Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) { ReturnDesc->Integer.Value <<= 1; } /* Since the bit position is one-based, subtract from 33 (65) */ ReturnDesc->Integer.Value = Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32; break; case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */ /* * The 64-bit ACPI integer can hold 16 4-bit BCD integers */ ReturnDesc->Integer.Value = 0; for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++) { /* Get one BCD digit */ Digit = (ACPI_INTEGER) ((Operand[0]->Integer.Value >> (i * 4)) & 0xF); /* Check the range of the digit */ if (Digit > 9) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD digit too large: %d\n", (UINT32) Digit)); Status = AE_AML_NUMERIC_OVERFLOW; goto Cleanup; } if (Digit > 0) { /* Sum into the result with the appropriate power of 10 */ for (j = 0; j < i; j++) { Digit *= 10; } ReturnDesc->Integer.Value += Digit; } } break; case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */ if (Operand[0]->Integer.Value > ACPI_MAX_BCD_VALUE) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD overflow: %8.8X%8.8X\n", ACPI_HIDWORD(Operand[0]->Integer.Value), ACPI_LODWORD(Operand[0]->Integer.Value))); Status = AE_AML_NUMERIC_OVERFLOW; goto Cleanup; } ReturnDesc->Integer.Value = 0; for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++) { /* Divide by nth factor of 10 */ Temp32 = 0; Digit = Operand[0]->Integer.Value; for (j = 0; j < i; j++) { (void) AcpiUtShortDivide (&Digit, 10, &Digit, &Temp32); } /* Create the BCD digit from the remainder above */ if (Digit > 0) { ReturnDesc->Integer.Value += ((ACPI_INTEGER) Temp32 << (i * 4)); } } break; case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */ /* * This op is a little strange because the internal return value is * different than the return value stored in the result descriptor * (There are really two return values) */ if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode) { /* * This means that the object does not exist in the namespace, * return FALSE */ ReturnDesc->Integer.Value = 0; - - /* - * Must delete the result descriptor since there is no reference - * being returned - */ - AcpiUtRemoveReference (Operand[1]); goto Cleanup; } /* Get the object reference, store it, and remove our reference */ Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc2, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; } Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState); AcpiUtRemoveReference (ReturnDesc2); /* The object exists in the namespace, return TRUE */ ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; goto Cleanup; default: /* No other opcodes get here */ break; } break; case AML_STORE_OP: /* Store (Source, Target) */ /* * A store operand is typically a number, string, buffer or lvalue * Be careful about deleting the source object, * since the object itself may have been stored. */ Status = AcpiExStore (Operand[0], Operand[1], WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - /* - * 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 */ + /* It is possible that the Store already produced a return object */ + + 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. + */ + WalkState->ResultObj = Operand[0]; + WalkState->Operands[0] = NULL; /* Prevent deletion */ + } return_ACPI_STATUS (Status); /* * ACPI 2.0 Opcodes */ case AML_COPY_OP: /* Copy (Source, Target) */ Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc, WalkState); break; case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */ Status = AcpiExConvertToString (Operand[0], &ReturnDesc, 10, ACPI_UINT32_MAX, WalkState); break; case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */ Status = AcpiExConvertToString (Operand[0], &ReturnDesc, 16, ACPI_UINT32_MAX, WalkState); break; case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */ Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc, WalkState); break; case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */ Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, WalkState); break; case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */ case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */ /* * These are two obsolete opcodes */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s is obsolete and not implemented\n", AcpiPsGetOpcodeName (WalkState->Opcode))); Status = AE_SUPPORT; goto Cleanup; default: /* Unknown opcode */ ACPI_REPORT_ERROR (("AcpiExOpcode_1A_1T_1R: Unknown opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } /* * Store the return value computed above into the target object */ Status = AcpiExStore (ReturnDesc, Operand[1], WalkState); Cleanup: - WalkState->ResultObj = ReturnDesc; + if (!WalkState->ResultObj) + { + WalkState->ResultObj = ReturnDesc; + } /* Delete return object on error */ if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ReturnDesc); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExOpcode_1A_0T_1R * * PARAMETERS: WalkState - Current state (contains AML opcode) * * RETURN: Status * * DESCRIPTION: Execute opcode with one argument, no target, and a return value * ******************************************************************************/ ACPI_STATUS AcpiExOpcode_1A_0T_1R ( ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *TempDesc; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; ACPI_STATUS Status = AE_OK; UINT32 Type; ACPI_INTEGER Value; ACPI_FUNCTION_TRACE_STR ("ExOpcode_1A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the AML opcode */ switch (WalkState->Opcode) { case AML_LNOT_OP: /* LNot (Operand) */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } ReturnDesc->Integer.Value = !Operand[0]->Integer.Value; break; case AML_DECREMENT_OP: /* Decrement (Operand) */ case AML_INCREMENT_OP: /* Increment (Operand) */ /* * Since we are expecting a Reference operand, it * can be either a NS Node or an internal object. */ ReturnDesc = Operand[0]; if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_OPERAND) { /* Internal reference object - prevent deletion */ AcpiUtAddReference (ReturnDesc); } /* * Convert the ReturnDesc Reference to a Number * (This removes a reference on the ReturnDesc object) */ Status = AcpiExResolveOperands (AML_LNOT_OP, &ReturnDesc, WalkState); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n", AcpiPsGetOpcodeName (WalkState->Opcode), AcpiFormatException(Status))); goto Cleanup; } /* * ReturnDesc is now guaranteed to be an Integer object * Do the actual increment or decrement */ if (AML_INCREMENT_OP == WalkState->Opcode) { ReturnDesc->Integer.Value++; } else { ReturnDesc->Integer.Value--; } /* Store the result back in the original descriptor */ Status = AcpiExStore (ReturnDesc, Operand[0], WalkState); break; case AML_TYPE_OP: /* ObjectType (SourceObject) */ /* Get the type of the base object */ Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Allocate a descriptor to hold the type. */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } ReturnDesc->Integer.Value = Type; break; case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */ /* Get the base object */ Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* * Type is guaranteed to be a buffer, string, or package at this * point (even if the original operand was an object reference, it * will be resolved and typechecked during operand resolution.) */ switch (Type) { case ACPI_TYPE_BUFFER: Value = TempDesc->Buffer.Length; break; case ACPI_TYPE_STRING: Value = TempDesc->String.Length; break; case ACPI_TYPE_PACKAGE: Value = TempDesc->Package.Count; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "SizeOf, Not Buf/Str/Pkg - found type %s\n", AcpiUtGetTypeName (Type))); Status = AE_AML_OPERAND_TYPE; goto Cleanup; } /* * Now that we have the size of the object, create a result * object to hold the value */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } ReturnDesc->Integer.Value = Value; break; case AML_REF_OF_OP: /* RefOf (SourceObject) */ Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; } break; case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */ /* Check for a method local or argument, or standalone String */ if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED) { switch (ACPI_GET_OBJECT_TYPE (Operand[0])) { - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: /* * This is a DerefOf (LocalX | ArgX) * * Must resolve/dereference the local/arg reference first */ switch (Operand[0]->Reference.Opcode) { case AML_LOCAL_OP: case AML_ARG_OP: /* Set Operand[0] to the value of the local/arg */ Status = AcpiDsMethodDataGetValue (Operand[0]->Reference.Opcode, Operand[0]->Reference.Offset, WalkState, &TempDesc); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* * Delete our reference to the input object and * point to the object just retrieved */ AcpiUtRemoveReference (Operand[0]); Operand[0] = TempDesc; break; case AML_REF_OF_OP: /* Get the object to which the reference refers */ TempDesc = Operand[0]->Reference.Object; AcpiUtRemoveReference (Operand[0]); Operand[0] = TempDesc; break; default: /* Must be an Index op - handled below */ break; } break; case ACPI_TYPE_STRING: /* * 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. */ Status = AcpiNsGetNodeByPath (Operand[0]->String.Pointer, 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); goto Cleanup; default: Status = AE_AML_OPERAND_TYPE; goto Cleanup; } } /* Operand[0] may have changed from the code above */ if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED) { /* * 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. */ ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) Operand[0]); } else { /* * This must be a reference object produced by either the Index() or * RefOf() operator */ switch (Operand[0]->Reference.Opcode) { case AML_INDEX_OP: /* * The target type for the Index operator must be * either a Buffer or a Package */ switch (Operand[0]->Reference.TargetType) { case ACPI_TYPE_BUFFER_FIELD: TempDesc = Operand[0]->Reference.Object; /* * Create a new object that contains one element of the * buffer -- the element pointed to by the index. * * NOTE: index into a buffer is NOT a pointer to a * sub-buffer of the main buffer, it is only a pointer to a * single element (byte) of the buffer! */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } /* * Since we are returning the value of the buffer at the * indexed location, we don't need to add an additional * reference to the buffer itself. */ ReturnDesc->Integer.Value = TempDesc->Buffer.Pointer[Operand[0]->Reference.Offset]; break; case ACPI_TYPE_PACKAGE: /* * Return the referenced element of the package. We must add * another reference to the referenced object, however. */ ReturnDesc = *(Operand[0]->Reference.Where); 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); break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Index TargetType %X in obj %p\n", Operand[0]->Reference.TargetType, Operand[0])); Status = AE_AML_OPERAND_TYPE; goto Cleanup; } break; case AML_REF_OF_OP: ReturnDesc = Operand[0]->Reference.Object; if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == ACPI_DESC_TYPE_NAMED) { ReturnDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ReturnDesc); } /* Add another reference to the object! */ AcpiUtAddReference (ReturnDesc); break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode in ref(%p) - %X\n", Operand[0], Operand[0]->Reference.Opcode)); Status = AE_TYPE; goto Cleanup; } } break; default: ACPI_REPORT_ERROR (("AcpiExOpcode_1A_0T_1R: Unknown opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } Cleanup: /* Delete return object on error */ if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ReturnDesc); } WalkState->ResultObj = ReturnDesc; return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exoparg2.c b/sys/contrib/dev/acpica/exoparg2.c index 465809f6eafd..4d3acbdd16d6 100644 --- a/sys/contrib/dev/acpica/exoparg2.c +++ b/sys/contrib/dev/acpica/exoparg2.c @@ -1,737 +1,716 @@ /****************************************************************************** * * Module Name: exoparg2 - AML execution - opcodes with 2 arguments - * $Revision: 111 $ + * $Revision: 115 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXOPARG2_C__ #include "acpi.h" #include "acparser.h" #include "acinterp.h" #include "acevents.h" #include "amlcode.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exoparg2") /*! * Naming convention for AML interpreter execution routines. * * The routines that begin execution of AML opcodes are named with a common * convention based upon the number of arguments, the number of target operands, * and whether or not a value is returned: * * AcpiExOpcode_xA_yT_zR * * Where: * * xA - ARGUMENTS: The number of arguments (input operands) that are * required for this opcode type (1 through 6 args). * yT - TARGETS: The number of targets (output operands) that are required * for this opcode type (0, 1, or 2 targets). * zR - RETURN VALUE: Indicates whether this opcode type returns a value * as the function return (0 or 1). * * The AcpiExOpcode* functions are called via the Dispatcher component with * fully resolved operands. !*/ /******************************************************************************* * * FUNCTION: AcpiExOpcode_2A_0T_0R * * PARAMETERS: WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: Execute opcode with two arguments, no target, and no return * value. * * ALLOCATION: Deletes both operands * ******************************************************************************/ ACPI_STATUS AcpiExOpcode_2A_0T_0R ( ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); /* Examine the opcode */ switch (WalkState->Opcode) { case AML_NOTIFY_OP: /* Notify (NotifyObject, NotifyValue) */ /* The first operand is a namespace node */ Node = (ACPI_NAMESPACE_NODE *) Operand[0]; /* Notifies allowed on this object? */ if (!AcpiEvIsNotifyObject (Node)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unexpected notify object type [%s]\n", AcpiUtGetTypeName (Node->Type))); Status = AE_AML_OPERAND_TYPE; break; } /* * Dispatch the notify to the appropriate handler * NOTE: the request is queued for execution after this method * completes. The notify handlers are NOT invoked synchronously * from this thread -- because handlers may in turn run other * control methods. */ Status = AcpiEvQueueNotifyRequest (Node, (UINT32) Operand[1]->Integer.Value); break; default: ACPI_REPORT_ERROR (("AcpiExOpcode_2A_0T_0R: Unknown opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExOpcode_2A_2T_1R * * PARAMETERS: WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: Execute a dyadic operator (2 operands) with 2 output targets * and one implicit return value. * ******************************************************************************/ ACPI_STATUS AcpiExOpcode_2A_2T_1R ( ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc1 = NULL; ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; ACPI_STATUS Status; ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_2T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); /* * Execute the opcode */ switch (WalkState->Opcode) { case AML_DIVIDE_OP: /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */ ReturnDesc1 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc1) { Status = AE_NO_MEMORY; goto Cleanup; } ReturnDesc2 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc2) { Status = AE_NO_MEMORY; goto Cleanup; } /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */ Status = AcpiUtDivide (&Operand[0]->Integer.Value, &Operand[1]->Integer.Value, &ReturnDesc1->Integer.Value, &ReturnDesc2->Integer.Value); if (ACPI_FAILURE (Status)) { goto Cleanup; } break; default: ACPI_REPORT_ERROR (("AcpiExOpcode_2A_2T_1R: Unknown opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } /* Store the results to the target reference operands */ Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; } Status = AcpiExStore (ReturnDesc1, Operand[3], WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Return the remainder */ WalkState->ResultObj = ReturnDesc1; Cleanup: /* * Since the remainder is not returned indirectly, remove a reference to * it. Only the quotient is returned indirectly. */ AcpiUtRemoveReference (ReturnDesc2); if (ACPI_FAILURE (Status)) { /* Delete the return object */ AcpiUtRemoveReference (ReturnDesc1); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExOpcode_2A_1T_1R * * PARAMETERS: WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: Execute opcode with two arguments, one target, and a return * value. * ******************************************************************************/ ACPI_STATUS AcpiExOpcode_2A_1T_1R ( ACPI_WALK_STATE *WalkState) { - ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; ACPI_OPERAND_OBJECT *TempDesc = NULL; UINT32 Index; - ACPI_STATUS Status = AE_OK; + ACPI_STATUS Status = AE_OK; ACPI_SIZE Length; ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); /* * Execute the opcode */ if (WalkState->OpInfo->Flags & AML_MATH) { /* All simple math opcodes (add, etc.) */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } ReturnDesc->Integer.Value = AcpiExDoMathOp (WalkState->Opcode, Operand[0]->Integer.Value, Operand[1]->Integer.Value); goto StoreResultToTarget; } switch (WalkState->Opcode) { case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } /* ReturnDesc will contain the remainder */ Status = AcpiUtDivide (&Operand[0]->Integer.Value, &Operand[1]->Integer.Value, NULL, &ReturnDesc->Integer.Value); break; case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ /* * Convert the second operand if necessary. The first operand * determines the type of the second operand, (See the Data Types * section of the ACPI specification.) Both object types are * guaranteed to be either Integer/String/Buffer by the operand * resolution mechanism above. */ switch (ACPI_GET_OBJECT_TYPE (Operand[0])) { case ACPI_TYPE_INTEGER: Status = AcpiExConvertToInteger (Operand[1], &TempDesc, WalkState); break; case ACPI_TYPE_STRING: Status = AcpiExConvertToString (Operand[1], &TempDesc, 16, ACPI_UINT32_MAX, WalkState); break; case ACPI_TYPE_BUFFER: Status = AcpiExConvertToBuffer (Operand[1], &TempDesc, WalkState); break; default: Status = AE_AML_INTERNAL; } if (ACPI_FAILURE (Status)) { goto Cleanup; } /* * Both operands are now known to be the same object type * (Both are Integer, String, or Buffer), and we can now perform the * concatenation. */ Status = AcpiExDoConcatenate (Operand[0], TempDesc, &ReturnDesc, WalkState); if (TempDesc != Operand[1]) { AcpiUtRemoveReference (TempDesc); } break; 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. */ /* Get the length of the new string */ Length = 0; if (Operand[1]->Integer.Value == 0) { /* Handle optional length value */ Operand[1]->Integer.Value = ACPI_INTEGER_MAX; } while ((Length < Operand[0]->Buffer.Length) && (Length < Operand[1]->Integer.Value) && (Operand[0]->Buffer.Pointer[Length])) { Length++; } if (Length > ACPI_MAX_STRING_CONVERSION) { Status = AE_AML_STRING_LIMIT; goto Cleanup; } /* Create the internal return object */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } /* Allocate a new string buffer (Length + 1 for null terminator) */ ReturnDesc->String.Pointer = ACPI_MEM_CALLOCATE (Length + 1); if (!ReturnDesc->String.Pointer) { Status = AE_NO_MEMORY; goto Cleanup; } /* Copy the raw buffer data with no transform */ ACPI_MEMCPY (ReturnDesc->String.Pointer, Operand[0]->Buffer.Pointer, Length); /* Set the string length */ - ReturnDesc->String.Length = Length; + ReturnDesc->String.Length = (UINT32) Length; break; case AML_CONCAT_RES_OP: /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */ Status = AcpiExConcatTemplate (Operand[0], Operand[1], &ReturnDesc, WalkState); break; case AML_INDEX_OP: /* Index (Source Index Result) */ /* Create the internal return object */ - ReturnDesc = AcpiUtCreateInternalObject (INTERNAL_TYPE_REFERENCE); + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } Index = (UINT32) Operand[1]->Integer.Value; /* * At this point, the Source operand is either a Package or a Buffer */ if (ACPI_GET_OBJECT_TYPE (Operand[0]) == ACPI_TYPE_PACKAGE) { /* Object to be indexed is a Package */ 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)); Status = AE_AML_PACKAGE_LIMIT; goto Cleanup; } - if ((ACPI_GET_OBJECT_TYPE (Operand[2]) == ACPI_TYPE_INTEGER) && - (Operand[2]->Common.Flags & AOPOBJ_AML_CONSTANT)) - { - /* - * There is no actual result descriptor (the ZeroOp/Constant Result - * descriptor is a placeholder), so just delete the placeholder and - * return a reference to the package element - */ - AcpiUtRemoveReference (Operand[2]); - } - - else - { - /* - * Each element of the package is an internal object. Get the one - * we are after. - */ - TempDesc = Operand[0]->Package.Elements [Index]; - ReturnDesc->Reference.Opcode = AML_INDEX_OP; - ReturnDesc->Reference.TargetType = ACPI_GET_OBJECT_TYPE (TempDesc); - ReturnDesc->Reference.Object = TempDesc; - - Status = AcpiExStore (ReturnDesc, Operand[2], WalkState); - ReturnDesc->Reference.Object = NULL; - } - - /* - * The local return object must always be a reference to the package element, - * not the element itself. - */ - ReturnDesc->Reference.Opcode = AML_INDEX_OP; ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; + ReturnDesc->Reference.Object = Operand[0]->Package.Elements [Index]; ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index]; } - else { /* Object to be indexed is a Buffer */ 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)); Status = AE_AML_BUFFER_LIMIT; goto Cleanup; } - ReturnDesc->Reference.Opcode = AML_INDEX_OP; - ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; - ReturnDesc->Reference.Object = Operand[0]; - ReturnDesc->Reference.Offset = Index; - - Status = AcpiExStore (ReturnDesc, Operand[2], WalkState); + ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + ReturnDesc->Reference.Object = Operand[0]; } + /* Complete the Index reference object */ + + ReturnDesc->Reference.Opcode = AML_INDEX_OP; + ReturnDesc->Reference.Offset = Index; + + /* Store the reference to the Target */ + + Status = AcpiExStore (ReturnDesc, Operand[2], WalkState); + + /* Return the reference */ + WalkState->ResultObj = ReturnDesc; goto Cleanup; default: ACPI_REPORT_ERROR (("AcpiExOpcode_2A_1T_1R: Unknown opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; break; } StoreResultToTarget: if (ACPI_SUCCESS (Status)) { /* * Store the result of the operation (which is now in ReturnDesc) into * the Target descriptor. */ Status = AcpiExStore (ReturnDesc, Operand[2], WalkState); if (ACPI_FAILURE (Status)) { goto Cleanup; } - WalkState->ResultObj = ReturnDesc; + if (!WalkState->ResultObj) + { + WalkState->ResultObj = ReturnDesc; + } } Cleanup: /* Delete return object on error */ if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ReturnDesc); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExOpcode_2A_0T_1R * * PARAMETERS: WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value * ******************************************************************************/ ACPI_STATUS AcpiExOpcode_2A_0T_1R ( ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; ACPI_STATUS Status = AE_OK; BOOLEAN LogicalResult = FALSE; ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode)); /* Create the internal return object */ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } /* * Execute the Opcode */ if (WalkState->OpInfo->Flags & AML_LOGICAL) /* LogicalOp (Operand0, Operand1) */ { LogicalResult = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0]->Integer.Value, Operand[1]->Integer.Value); goto StoreLogicalResult; } switch (WalkState->Opcode) { case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */ Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState); if (Status == AE_TIME) { LogicalResult = TRUE; /* TRUE = Acquire timed out */ Status = AE_OK; } break; case AML_WAIT_OP: /* Wait (EventObject, Timeout) */ Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]); if (Status == AE_TIME) { LogicalResult = TRUE; /* TRUE, Wait timed out */ Status = AE_OK; } break; default: ACPI_REPORT_ERROR (("AcpiExOpcode_2A_0T_1R: Unknown opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } StoreLogicalResult: /* * Set return value to according to LogicalResult. logical TRUE (all ones) * Default is FALSE (zero) */ if (LogicalResult) { ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; } WalkState->ResultObj = ReturnDesc; Cleanup: /* Delete return object on error */ if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ReturnDesc); } return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exoparg3.c b/sys/contrib/dev/acpica/exoparg3.c index f2aa71479c20..baf9bfe83d39 100644 --- a/sys/contrib/dev/acpica/exoparg3.c +++ b/sys/contrib/dev/acpica/exoparg3.c @@ -1,334 +1,337 @@ /****************************************************************************** * * Module Name: exoparg3 - AML execution - opcodes with 3 arguments - * $Revision: 14 $ + * $Revision: 15 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXOPARG3_C__ #include "acpi.h" #include "acinterp.h" #include "acparser.h" #include "amlcode.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exoparg3") /*! * Naming convention for AML interpreter execution routines. * * The routines that begin execution of AML opcodes are named with a common * convention based upon the number of arguments, the number of target operands, * and whether or not a value is returned: * * AcpiExOpcode_xA_yT_zR * * Where: * * xA - ARGUMENTS: The number of arguments (input operands) that are * required for this opcode type (1 through 6 args). * yT - TARGETS: The number of targets (output operands) that are required * for this opcode type (0, 1, or 2 targets). * zR - RETURN VALUE: Indicates whether this opcode type returns a value * as the function return (0 or 1). * * The AcpiExOpcode* functions are called via the Dispatcher component with * fully resolved operands. !*/ /******************************************************************************* * * FUNCTION: AcpiExOpcode_3A_0T_0R * * PARAMETERS: WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: Execute Triadic operator (3 operands) * ******************************************************************************/ ACPI_STATUS AcpiExOpcode_3A_0T_0R ( ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_SIGNAL_FATAL_INFO *Fatal; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE_STR ("ExOpcode_3A_0T_0R", AcpiPsGetOpcodeName (WalkState->Opcode)); switch (WalkState->Opcode) { case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", (UINT32) Operand[0]->Integer.Value, (UINT32) Operand[1]->Integer.Value, (UINT32) Operand[2]->Integer.Value)); Fatal = ACPI_MEM_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO)); if (Fatal) { Fatal->Type = (UINT32) Operand[0]->Integer.Value; Fatal->Code = (UINT32) Operand[1]->Integer.Value; Fatal->Argument = (UINT32) Operand[2]->Integer.Value; } /* * Always signal the OS! */ Status = AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal); /* Might return while OS is shutting down, just continue */ ACPI_MEM_FREE (Fatal); break; default: ACPI_REPORT_ERROR (("AcpiExOpcode_3A_0T_0R: Unknown opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } Cleanup: return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExOpcode_3A_1T_1R * * PARAMETERS: WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: Execute Triadic operator (3 operands) * ******************************************************************************/ ACPI_STATUS AcpiExOpcode_3A_1T_1R ( ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; ACPI_OPERAND_OBJECT *ReturnDesc = NULL; char *Buffer; ACPI_STATUS Status = AE_OK; NATIVE_UINT Index; ACPI_SIZE Length; 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]) */ /* * 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])); if (!ReturnDesc) { Status = AE_NO_MEMORY; goto Cleanup; } /* Get the Integer values from the objects */ Index = (NATIVE_UINT) 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)) { /* Truncate request if larger than the actual String/Buffer */ if ((Index + Length) > Operand[0]->String.Length) { Length = (ACPI_SIZE) Operand[0]->String.Length - Index; } /* Allocate a new buffer for the String/Buffer */ Buffer = ACPI_MEM_CALLOCATE ((ACPI_SIZE) Length + 1); if (!Buffer) { Status = AE_NO_MEMORY; goto Cleanup; } /* Copy the portion requested */ ACPI_MEMCPY (Buffer, Operand[0]->String.Pointer + Index, Length); /* Set the length of the new String/Buffer */ ReturnDesc->String.Pointer = Buffer; ReturnDesc->String.Length = (UINT32) Length; } break; default: ACPI_REPORT_ERROR (("AcpiExOpcode_3A_0T_0R: Unknown opcode %X\n", WalkState->Opcode)); Status = AE_AML_BAD_OPCODE; goto Cleanup; } /* Store the result in the target */ Status = AcpiExStore (ReturnDesc, Operand[3], WalkState); Cleanup: /* Delete return object on error */ if (ACPI_FAILURE (Status)) { AcpiUtRemoveReference (ReturnDesc); } /* Set the return object and exit */ - WalkState->ResultObj = ReturnDesc; + if (!WalkState->ResultObj) + { + WalkState->ResultObj = ReturnDesc; + } return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exprep.c b/sys/contrib/dev/acpica/exprep.c index 2aeb7eed8c8c..e9ed816135eb 100644 --- a/sys/contrib/dev/acpica/exprep.c +++ b/sys/contrib/dev/acpica/exprep.c @@ -1,542 +1,538 @@ /****************************************************************************** * * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities - * $Revision: 119 $ + * $Revision: 121 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXPREP_C__ #include "acpi.h" #include "acinterp.h" #include "amlcode.h" #include "acnamesp.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exprep") /******************************************************************************* * * FUNCTION: AcpiExDecodeFieldAccess * * PARAMETERS: Access - Encoded field access bits * Length - Field length. * * RETURN: Field granularity (8, 16, 32 or 64) and * ByteAlignment (1, 2, 3, or 4) * * DESCRIPTION: Decode the AccessType bits of a field definition. * ******************************************************************************/ static UINT32 AcpiExDecodeFieldAccess ( ACPI_OPERAND_OBJECT *ObjDesc, UINT8 FieldFlags, UINT32 *ReturnByteAlignment) { UINT32 Access; UINT8 ByteAlignment; UINT8 BitLength; /* UINT32 Length; */ ACPI_FUNCTION_NAME ("ExDecodeFieldAccess"); Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK); switch (Access) { case AML_FIELD_ACCESS_ANY: ByteAlignment = 1; BitLength = 8; #if 0 /* * TBD: optimize * * Any attempt to optimize the access size to the size of the field * must take into consideration the length of the region and take * care that an access to the field will not attempt to access * beyond the end of the region. */ /* Use the length to set the access type */ Length = ObjDesc->CommonField.BitLength; if (Length <= 8) { BitLength = 8; } else if (Length <= 16) { BitLength = 16; } else if (Length <= 32) { BitLength = 32; } else if (Length <= 64) { BitLength = 64; } else { /* Larger than Qword - just use byte-size chunks */ BitLength = 8; } #endif break; case AML_FIELD_ACCESS_BYTE: + case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */ ByteAlignment = 1; - BitLength = 8; + BitLength = 8; break; case AML_FIELD_ACCESS_WORD: ByteAlignment = 2; - BitLength = 16; + BitLength = 16; break; case AML_FIELD_ACCESS_DWORD: ByteAlignment = 4; - BitLength = 32; + BitLength = 32; break; - case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ + case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ ByteAlignment = 8; - BitLength = 64; - break; - - case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 */ - ByteAlignment = 8; - BitLength = 8; + BitLength = 64; break; default: /* Invalid field access type */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown field access type %X\n", Access)); return (0); } if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_BUFFER_FIELD) { /* * BufferField access can be on any byte boundary, so the * ByteAlignment is always 1 byte -- regardless of any ByteAlignment * implied by the field access type. */ ByteAlignment = 1; } *ReturnByteAlignment = ByteAlignment; return (BitLength); } /******************************************************************************* * * FUNCTION: AcpiExPrepCommonFieldObject * * PARAMETERS: ObjDesc - The field object * FieldFlags - Access, LockRule, and UpdateRule. * The format of a FieldFlag is described * in the ACPI specification * FieldBitPosition - Field start position * FieldBitLength - Field length in number of bits * * RETURN: Status * * DESCRIPTION: Initialize the areas of the field object that are common * to the various types of fields. Note: This is very "sensitive" * code because we are solving the general case for field * alignment. * ******************************************************************************/ ACPI_STATUS AcpiExPrepCommonFieldObject ( ACPI_OPERAND_OBJECT *ObjDesc, UINT8 FieldFlags, UINT8 FieldAttribute, UINT32 FieldBitPosition, UINT32 FieldBitLength) { UINT32 AccessBitWidth; UINT32 ByteAlignment; UINT32 NearestByteAddress; ACPI_FUNCTION_TRACE ("ExPrepCommonFieldObject"); /* * Note: the structure being initialized is the * ACPI_COMMON_FIELD_INFO; No structure fields outside of the common * area are initialized by this procedure. */ ObjDesc->CommonField.FieldFlags = FieldFlags; ObjDesc->CommonField.Attribute = FieldAttribute; ObjDesc->CommonField.BitLength = FieldBitLength; /* * Decode the access type so we can compute offsets. The access type gives * two pieces of information - the width of each field access and the * necessary ByteAlignment (address granularity) of the access. * * For AnyAcc, the AccessBitWidth is the largest width that is both * necessary and possible in an attempt to access the whole field in one * I/O operation. However, for AnyAcc, the ByteAlignment is always one * byte. * * For all Buffer Fields, the ByteAlignment is always one byte. * * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is * the same (equivalent) as the ByteAlignment. */ AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags, &ByteAlignment); if (!AccessBitWidth) { return_ACPI_STATUS (AE_AML_OPERAND_VALUE); } /* Setup width (access granularity) fields */ ObjDesc->CommonField.AccessByteWidth = (UINT8) ACPI_DIV_8 (AccessBitWidth); /* 1, 2, 4, 8 */ /* * BaseByteOffset is the address of the start of the field within the * region. It is the byte address of the first *datum* (field-width data * unit) of the field. (i.e., the first datum that contains at least the * first *bit* of the field.) * * Note: ByteAlignment is always either equal to the AccessBitWidth or 8 * (Byte access), and it defines the addressing granularity of the parent * region or buffer. */ NearestByteAddress = ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition); ObjDesc->CommonField.BaseByteOffset = ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment); /* * StartFieldBitOffset is the offset of the first bit of the field within * a field datum. */ ObjDesc->CommonField.StartFieldBitOffset = (UINT8) (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) */ if ((ObjDesc->CommonField.StartFieldBitOffset + FieldBitLength) <= (UINT16) AccessBitWidth) { ObjDesc->Common.Flags |= AOPOBJ_SINGLE_DATUM; } return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * 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 * * RETURN: Status * * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and * connect it to the parent Node. * ******************************************************************************/ ACPI_STATUS AcpiExPrepFieldValue ( ACPI_CREATE_FIELD_INFO *Info) { ACPI_OPERAND_OBJECT *ObjDesc; UINT32 Type; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("ExPrepFieldValue"); /* Parameter validation */ - if (Info->FieldType != INTERNAL_TYPE_INDEX_FIELD) + if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD) { if (!Info->RegionNode) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null RegionNode\n")); return_ACPI_STATUS (AE_AML_NO_OPERAND); } Type = AcpiNsGetType (Info->RegionNode); if (Type != ACPI_TYPE_REGION) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed Region, found type %X %s\n", Type, AcpiUtGetTypeName (Type))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } } /* Allocate a new field object */ ObjDesc = AcpiUtCreateInternalObject (Info->FieldType); if (!ObjDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Initialize areas of the object that are common to all fields */ ObjDesc->CommonField.Node = Info->FieldNode; Status = AcpiExPrepCommonFieldObject (ObjDesc, Info->FieldFlags, Info->Attribute, Info->FieldBitPosition, Info->FieldBitLength); if (ACPI_FAILURE (Status)) { AcpiUtDeleteObjectDesc (ObjDesc); return_ACPI_STATUS (Status); } /* Initialize areas of the object that are specific to the field type */ switch (Info->FieldType) { - case INTERNAL_TYPE_REGION_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); /* An additional reference for the container */ AcpiUtAddReference (ObjDesc->Field.RegionObj); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "RegionField: Bitoff=%X Off=%X Gran=%X Region %p\n", ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset, ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj)); break; - case INTERNAL_TYPE_BANK_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: ObjDesc->BankField.Value = Info->BankValue; ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); ObjDesc->BankField.BankObj = AcpiNsGetAttachedObject (Info->RegisterNode); /* An additional reference for the attached objects */ AcpiUtAddReference (ObjDesc->BankField.RegionObj); AcpiUtAddReference (ObjDesc->BankField.BankObj); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Bank Field: BitOff=%X Off=%X Gran=%X Region %p BankReg %p\n", ObjDesc->BankField.StartFieldBitOffset, ObjDesc->BankField.BaseByteOffset, ObjDesc->Field.AccessByteWidth, ObjDesc->BankField.RegionObj, ObjDesc->BankField.BankObj)); break; - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: ObjDesc->IndexField.IndexObj = AcpiNsGetAttachedObject (Info->RegisterNode); ObjDesc->IndexField.DataObj = AcpiNsGetAttachedObject (Info->DataRegisterNode); ObjDesc->IndexField.Value = (UINT32) (Info->FieldBitPosition / ACPI_MUL_8 (ObjDesc->Field.AccessByteWidth)); if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Index Object\n")); return_ACPI_STATUS (AE_AML_INTERNAL); } /* An additional reference for the attached objects */ AcpiUtAddReference (ObjDesc->IndexField.DataObj); AcpiUtAddReference (ObjDesc->IndexField.IndexObj); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "IndexField: bitoff=%X off=%X gran=%X Index %p Data %p\n", ObjDesc->IndexField.StartFieldBitOffset, ObjDesc->IndexField.BaseByteOffset, ObjDesc->Field.AccessByteWidth, ObjDesc->IndexField.IndexObj, ObjDesc->IndexField.DataObj)); break; default: /* No other types should get here */ break; } /* * Store the constructed descriptor (ObjDesc) into the parent Node, * preserving the current type of that NamedObj. */ Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc, AcpiNsGetType (Info->FieldNode)); ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "set NamedObj %p (%4.4s) val = %p\n", Info->FieldNode, Info->FieldNode->Name.Ascii, ObjDesc)); /* Remove local reference to the object */ AcpiUtRemoveReference (ObjDesc); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exresnte.c b/sys/contrib/dev/acpica/exresnte.c index cb38295527b4..c999b155b208 100644 --- a/sys/contrib/dev/acpica/exresnte.c +++ b/sys/contrib/dev/acpica/exresnte.c @@ -1,356 +1,356 @@ /****************************************************************************** * * Module Name: exresnte - AML Interpreter object resolution - * $Revision: 59 $ + * $Revision: 61 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXRESNTE_C__ #include "acpi.h" #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exresnte") /******************************************************************************* * * FUNCTION: AcpiExResolveNodeToValue * * PARAMETERS: ObjectPtr - Pointer to a location that contains * a pointer to a NS node, and will receive a * pointer to the resolved object. * WalkState - Current state. Valid only if executing AML * code. NULL if simply resolving an object * * RETURN: Status * * DESCRIPTION: Resolve a Namespace node to a valued object * * Note: for some of the data types, the pointer attached to the Node * can be either a pointer to an actual internal object or a pointer into the * AML stream itself. These types are currently: * * ACPI_TYPE_INTEGER * ACPI_TYPE_STRING * ACPI_TYPE_BUFFER * ACPI_TYPE_MUTEX * ACPI_TYPE_PACKAGE * ******************************************************************************/ ACPI_STATUS AcpiExResolveNodeToValue ( ACPI_NAMESPACE_NODE **ObjectPtr, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *SourceDesc; ACPI_OPERAND_OBJECT *ObjDesc = NULL; ACPI_NAMESPACE_NODE *Node; ACPI_OBJECT_TYPE EntryType; ACPI_FUNCTION_TRACE ("ExResolveNodeToValue"); /* * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the * object that is attached to the Node. */ Node = *ObjectPtr; SourceDesc = AcpiNsGetAttachedObject (Node); EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); - ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p Type=%X\n", - Node, SourceDesc, EntryType)); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n", + Node, SourceDesc, AcpiUtGetTypeName (EntryType))); - if (EntryType == INTERNAL_TYPE_ALIAS) + if (EntryType == ACPI_TYPE_LOCAL_ALIAS) { /* There is always exactly one level of indirection */ Node = (ACPI_NAMESPACE_NODE *) Node->Object; SourceDesc = AcpiNsGetAttachedObject (Node); EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); *ObjectPtr = Node; } /* * Several object types require no further processing: * 1) Devices rarely have an attached object, return the Node * 2) Method locals and arguments have a pseudo-Node */ if (EntryType == ACPI_TYPE_DEVICE || (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) { return_ACPI_STATUS (AE_OK); } if (!SourceDesc) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object attached to node %p\n", Node)); return_ACPI_STATUS (AE_AML_NO_OPERAND); } /* * Action is based on the type of the Node, which indicates the type * of the attached object or pointer */ switch (EntryType) { case ACPI_TYPE_PACKAGE: if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_PACKAGE) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Package, type %s\n", AcpiUtGetObjectTypeName (SourceDesc))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } Status = AcpiDsGetPackageArguments (SourceDesc); if (ACPI_SUCCESS (Status)) { /* Return an additional reference to the object */ ObjDesc = SourceDesc; AcpiUtAddReference (ObjDesc); } break; case ACPI_TYPE_BUFFER: if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_BUFFER) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Buffer, type %s\n", AcpiUtGetObjectTypeName (SourceDesc))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } Status = AcpiDsGetBufferArguments (SourceDesc); if (ACPI_SUCCESS (Status)) { /* Return an additional reference to the object */ ObjDesc = SourceDesc; AcpiUtAddReference (ObjDesc); } break; case ACPI_TYPE_STRING: if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_STRING) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a String, type %s\n", AcpiUtGetObjectTypeName (SourceDesc))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* Return an additional reference to the object */ ObjDesc = SourceDesc; AcpiUtAddReference (ObjDesc); break; case ACPI_TYPE_INTEGER: if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_TYPE_INTEGER) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Object not a Integer, type %s\n", AcpiUtGetObjectTypeName (SourceDesc))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* Return an additional reference to the object */ ObjDesc = SourceDesc; AcpiUtAddReference (ObjDesc); break; case ACPI_TYPE_BUFFER_FIELD: - case INTERNAL_TYPE_REGION_FIELD: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + 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", Node, SourceDesc, EntryType)); Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc); break; /* * For these objects, just return the object attached to the Node */ case ACPI_TYPE_MUTEX: case ACPI_TYPE_METHOD: case ACPI_TYPE_POWER: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_THERMAL: case ACPI_TYPE_EVENT: case ACPI_TYPE_REGION: /* Return an additional reference to the object */ ObjDesc = SourceDesc; 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", Node)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: /* No named references are allowed here */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported Reference opcode %X\n", SourceDesc->Reference.Opcode)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Default case is for unknown types */ default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Node %p - Unknown object type %X\n", Node, EntryType)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* switch (EntryType) */ /* Put the object descriptor on the stack */ *ObjectPtr = (void *) ObjDesc; return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exresolv.c b/sys/contrib/dev/acpica/exresolv.c index 9b8b61045489..e5bc4f3357e4 100644 --- a/sys/contrib/dev/acpica/exresolv.c +++ b/sys/contrib/dev/acpica/exresolv.c @@ -1,563 +1,570 @@ /****************************************************************************** * * Module Name: exresolv - AML Interpreter object resolution - * $Revision: 116 $ + * $Revision: 117 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXRESOLV_C__ #include "acpi.h" #include "amlcode.h" #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exresolv") /******************************************************************************* * * FUNCTION: AcpiExResolveToValue * * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can * be either an (ACPI_OPERAND_OBJECT *) * or an ACPI_HANDLE. * WalkState - Current method state * * RETURN: Status * * DESCRIPTION: Convert Reference objects to values * ******************************************************************************/ ACPI_STATUS AcpiExResolveToValue ( ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE_PTR ("ExResolveToValue", StackPtr); if (!StackPtr || !*StackPtr) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null pointer\n")); return_ACPI_STATUS (AE_AML_NO_OPERAND); } /* * The entity pointed to by the StackPtr can be either * 1) A valid ACPI_OPERAND_OBJECT, or * 2) A ACPI_NAMESPACE_NODE (NamedObj) */ if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND) { Status = AcpiExResolveObjectToValue (StackPtr, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } /* * Object on the stack may have changed if AcpiExResolveObjectToValue() * was called (i.e., we can't use an _else_ here.) */ if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED) { Status = AcpiExResolveNodeToValue ( ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr)); return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiExResolveObjectToValue * * PARAMETERS: StackPtr - Pointer to a stack location that contains a * ptr to an internal object. * WalkState - Current method state * * RETURN: Status * * DESCRIPTION: Retrieve the value from an internal object. The Reference type * uses the associated AML opcode to determine the value. * ******************************************************************************/ ACPI_STATUS AcpiExResolveObjectToValue ( ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *StackDesc; void *TempNode; ACPI_OPERAND_OBJECT *ObjDesc; UINT16 Opcode; ACPI_FUNCTION_TRACE ("ExResolveObjectToValue"); StackDesc = *StackPtr; /* This is an ACPI_OPERAND_OBJECT */ switch (ACPI_GET_OBJECT_TYPE (StackDesc)) { - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: Opcode = StackDesc->Reference.Opcode; switch (Opcode) { case AML_NAME_OP: /* * Convert indirect name ptr to a direct name ptr. * Then, AcpiExResolveNodeToValue can be used to get the value */ TempNode = StackDesc->Reference.Object; /* Delete the Reference Object */ AcpiUtRemoveReference (StackDesc); /* Put direct name pointer onto stack and exit */ (*StackPtr) = TempNode; break; case AML_LOCAL_OP: case AML_ARG_OP: /* * Get the local from the method's state info * Note: this increments the local's object reference count */ Status = AcpiDsMethodDataGetValue (Opcode, StackDesc->Reference.Offset, WalkState, &ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Now we can delete the original Reference Object and * replace it with the resolve value */ AcpiUtRemoveReference (StackDesc); *StackPtr = ObjDesc; ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %d] ValueObj is %p\n", StackDesc->Reference.Offset, ObjDesc)); break; case AML_INDEX_OP: switch (StackDesc->Reference.TargetType) { case ACPI_TYPE_BUFFER_FIELD: /* Just return - leave the Reference on the stack */ break; case ACPI_TYPE_PACKAGE: ObjDesc = *StackDesc->Reference.Where; if (ObjDesc) { /* * Valid obj descriptor, copy pointer to return value * (i.e., dereference the package index) * Delete the ref object, increment the returned object */ AcpiUtRemoveReference (StackDesc); AcpiUtAddReference (ObjDesc); *StackPtr = ObjDesc; } else { /* * A NULL object descriptor means an unitialized element of * the package, can't dereference it */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Attempt to deref an Index to NULL pkg element Idx=%p\n", StackDesc)); Status = AE_AML_UNINITIALIZED_ELEMENT; } break; default: /* Invalid reference object */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown TargetType %X in Index/Reference obj %p\n", StackDesc->Reference.TargetType, StackDesc)); Status = AE_AML_INTERNAL; break; } break; case AML_REF_OF_OP: case AML_DEBUG_OP: /* Just leave the object as-is */ break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference opcode %X in %p\n", Opcode, StackDesc)); Status = AE_AML_INTERNAL; break; } break; case ACPI_TYPE_BUFFER: Status = AcpiDsGetBufferArguments (StackDesc); break; case ACPI_TYPE_PACKAGE: Status = AcpiDsGetPackageArguments (StackDesc); break; /* * These cases may never happen here, but just in case.. */ case ACPI_TYPE_BUFFER_FIELD: - case INTERNAL_TYPE_REGION_FIELD: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n", StackDesc, ACPI_GET_OBJECT_TYPE (StackDesc))); Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc); *StackPtr = (void *) ObjDesc; break; default: break; } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExResolveMultiple * * PARAMETERS: WalkState - Current state (contains AML opcode) * Operand - Starting point for resolution * ReturnType - Where the object type is returned * ReturnDesc - Where the resolved object is returned * * RETURN: Status * * DESCRIPTION: Return the base object and type. Traverse a reference list if * necessary to get to the base object. * ******************************************************************************/ ACPI_STATUS AcpiExResolveMultiple ( ACPI_WALK_STATE *WalkState, ACPI_OPERAND_OBJECT *Operand, ACPI_OBJECT_TYPE *ReturnType, ACPI_OPERAND_OBJECT **ReturnDesc) { ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand; ACPI_NAMESPACE_NODE *Node; ACPI_OBJECT_TYPE Type; - ACPI_FUNCTION_TRACE ("ExGetObjectType"); + ACPI_FUNCTION_TRACE ("AcpiExResolveMultiple"); /* * For reference objects created via the RefOf or Index operators, * we need to get to the base object (as per the ACPI specification * of the ObjectType and SizeOf operators). This means traversing * the list of possibly many nested references. */ - while (ACPI_GET_OBJECT_TYPE (ObjDesc) == INTERNAL_TYPE_REFERENCE) + while (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_REFERENCE) { switch (ObjDesc->Reference.Opcode) { case AML_REF_OF_OP: /* Dereference the reference pointer */ Node = ObjDesc->Reference.Object; /* All "References" point to a NS node */ if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { return_ACPI_STATUS (AE_AML_INTERNAL); } /* Get the attached object */ ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { /* No object, use the NS node type */ Type = AcpiNsGetType (Node); goto Exit; } /* Check for circular references */ if (ObjDesc == Operand) { return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); } break; case AML_INDEX_OP: /* Get the type of this reference (index into another object) */ Type = ObjDesc->Reference.TargetType; if (Type != ACPI_TYPE_PACKAGE) { goto Exit; } /* * The main object is a package, we want to get the type * of the individual package element that is referenced by * the index. * * This could of course in turn be another reference object. */ ObjDesc = *(ObjDesc->Reference.Where); break; case AML_INT_NAMEPATH_OP: /* Dereference the reference pointer */ Node = ObjDesc->Reference.Node; /* All "References" point to a NS node */ if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { return_ACPI_STATUS (AE_AML_INTERNAL); } /* Get the attached object */ ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { /* No object, use the NS node type */ Type = AcpiNsGetType (Node); goto Exit; } /* Check for circular references */ if (ObjDesc == Operand) { return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); } break; case AML_DEBUG_OP: /* The Debug Object is of type "DebugObject" */ Type = ACPI_TYPE_DEBUG_OBJECT; goto Exit; default: ACPI_REPORT_ERROR (("AcpiExResolveMultiple: Unknown Reference subtype %X\n", ObjDesc->Reference.Opcode)); return_ACPI_STATUS (AE_AML_INTERNAL); } } /* * Now we are guaranteed to have an object that has not been created * via the RefOf or Index operators. */ Type = ACPI_GET_OBJECT_TYPE (ObjDesc); Exit: /* Convert internal types to external types */ switch (Type) { - case INTERNAL_TYPE_REGION_FIELD: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: Type = ACPI_TYPE_FIELD_UNIT; break; + case ACPI_TYPE_LOCAL_SCOPE: + + /* Per ACPI Specification, Scope is untyped */ + + Type = ACPI_TYPE_ANY; + break; + default: /* No change to Type required */ break; } *ReturnType = Type; if (ReturnDesc) { *ReturnDesc = ObjDesc; } return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/exresop.c b/sys/contrib/dev/acpica/exresop.c index 92592e637dfc..7e46b7b584ae 100644 --- a/sys/contrib/dev/acpica/exresop.c +++ b/sys/contrib/dev/acpica/exresop.c @@ -1,704 +1,670 @@ /****************************************************************************** * * Module Name: exresop - AML Interpreter operand/object resolution - * $Revision: 58 $ + * $Revision: 60 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXRESOP_C__ #include "acpi.h" #include "amlcode.h" #include "acparser.h" #include "acinterp.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exresop") /******************************************************************************* * * FUNCTION: AcpiExCheckObjectType * * PARAMETERS: TypeNeeded Object type needed * ThisType Actual object type * Object Object pointer * * RETURN: Status * * DESCRIPTION: Check required type against actual type * ******************************************************************************/ ACPI_STATUS AcpiExCheckObjectType ( ACPI_OBJECT_TYPE TypeNeeded, ACPI_OBJECT_TYPE ThisType, void *Object) { ACPI_FUNCTION_NAME ("ExCheckObjectType"); if (TypeNeeded == ACPI_TYPE_ANY) { /* All types OK, so we don't perform any typechecks */ return (AE_OK); } - if (TypeNeeded == INTERNAL_TYPE_REFERENCE) + if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE) { /* * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference * objects and thus allow them to be targets. (As per the ACPI * specification, a store to a constant is a noop.) */ if ((ThisType == ACPI_TYPE_INTEGER) && (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT)) { return (AE_OK); } } if (TypeNeeded != ThisType) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed [%s], found [%s] %p\n", AcpiUtGetTypeName (TypeNeeded), AcpiUtGetTypeName (ThisType), Object)); return (AE_AML_OPERAND_TYPE); } return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiExResolveOperands * * PARAMETERS: Opcode - Opcode being interpreted * StackPtr - Pointer to the operand stack to be * resolved * WalkState - Current state * * RETURN: Status * * DESCRIPTION: Convert multiple input operands to the types required by the * target operator. * * Each 5-bit group in ArgTypes represents one required * operand and indicates the required Type. The corresponding operand * will be converted to the required type if possible, otherwise we * abort with an exception. * ******************************************************************************/ ACPI_STATUS AcpiExResolveOperands ( UINT16 Opcode, ACPI_OPERAND_OBJECT **StackPtr, ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_STATUS Status = AE_OK; UINT8 ObjectType; void *TempNode; UINT32 ArgTypes; const ACPI_OPCODE_INFO *OpInfo; UINT32 ThisArgType; ACPI_OBJECT_TYPE TypeNeeded; ACPI_FUNCTION_TRACE_U32 ("ExResolveOperands", Opcode); OpInfo = AcpiPsGetOpcodeInfo (Opcode); if (OpInfo->Class == AML_CLASS_UNKNOWN) { return_ACPI_STATUS (AE_AML_BAD_OPCODE); } ArgTypes = OpInfo->RuntimeArgs; if (ArgTypes == ARGI_INVALID_OPCODE) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - %X is not a valid AML opcode\n", Opcode)); return_ACPI_STATUS (AE_AML_INTERNAL); } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode %X [%s] OperandTypes=%X \n", Opcode, OpInfo->Name, ArgTypes)); /* * Normal exit is with (ArgTypes == 0) at end of argument list. * Function will return an exception from within the loop upon * finding an entry which is not (or cannot be converted * to) the required type; if stack underflows; or upon * finding a NULL stack entry (which should not happen). */ while (GET_CURRENT_ARG_TYPE (ArgTypes)) { if (!StackPtr || !*StackPtr) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - null stack entry at %p\n", StackPtr)); return_ACPI_STATUS (AE_AML_INTERNAL); } /* Extract useful items */ ObjDesc = *StackPtr; /* Decode the descriptor type */ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) { case ACPI_DESC_TYPE_NAMED: /* Node */ ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; break; case ACPI_DESC_TYPE_OPERAND: /* ACPI internal object */ ObjectType = ACPI_GET_OBJECT_TYPE (ObjDesc); /* Check for bad ACPI_OBJECT_TYPE */ - if (!AcpiExValidateObjectType (ObjectType)) + if (!AcpiUtValidObjectType (ObjectType)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad operand object type [%X]\n", ObjectType)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } - if (ObjectType == (UINT8) INTERNAL_TYPE_REFERENCE) + if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE) { /* * Decode the Reference */ OpInfo = AcpiPsGetOpcodeInfo (Opcode); if (OpInfo->Class == AML_CLASS_UNKNOWN) { return_ACPI_STATUS (AE_AML_BAD_OPCODE); } switch (ObjDesc->Reference.Opcode) { case AML_DEBUG_OP: case AML_NAME_OP: case AML_INDEX_OP: case AML_REF_OF_OP: case AML_ARG_OP: case AML_LOCAL_OP: ACPI_DEBUG_ONLY_MEMBERS (ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Reference Opcode: %s\n", OpInfo->Name))); break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference Opcode %X\n", ObjDesc->Reference.Opcode)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } } break; default: /* Invalid descriptor */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Bad descriptor type %X in Obj %p\n", ACPI_GET_DESCRIPTOR_TYPE (ObjDesc), ObjDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* * Get one argument type, point to the next */ ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes); INCREMENT_ARG_LIST (ArgTypes); /* * Handle cases where the object does not need to be * resolved to a value */ switch (ThisArgType) { case ARGI_REF_OR_STRING: /* Can be a String or Reference */ if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) && (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_STRING)) { /* * 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 */ /*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 INTERNAL_TYPE_REFERENCE */ + /* Need an operand of type ACPI_TYPE_LOCAL_REFERENCE */ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) /* Node (name) ptr OK as-is */ { goto NextOperand; } - Status = AcpiExCheckObjectType (INTERNAL_TYPE_REFERENCE, + Status = AcpiExCheckObjectType (ACPI_TYPE_LOCAL_REFERENCE, ObjectType, ObjDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } if (AML_NAME_OP == ObjDesc->Reference.Opcode) { /* * Convert an indirect name ptr to direct name ptr and put * it on the stack */ TempNode = ObjDesc->Reference.Object; AcpiUtRemoveReference (ObjDesc); (*StackPtr) = TempNode; } goto NextOperand; case ARGI_ANYTYPE: /* * We don't want to resolve IndexOp reference objects during * a store because this would be an implicit DeRefOf operation. * Instead, we just want to store the reference object. * -- All others must be resolved below. */ if ((Opcode == AML_STORE_OP) && - (ACPI_GET_OBJECT_TYPE (*StackPtr) == INTERNAL_TYPE_REFERENCE) && + (ACPI_GET_OBJECT_TYPE (*StackPtr) == ACPI_TYPE_LOCAL_REFERENCE) && ((*StackPtr)->Reference.Opcode == AML_INDEX_OP)) { goto NextOperand; } break; default: /* All cases covered above */ break; } /* * Resolve this object to a value */ Status = AcpiExResolveToValue (StackPtr, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Get the resolved object */ ObjDesc = *StackPtr; /* * Check the resulting object (value) type */ switch (ThisArgType) { /* * For the simple cases, only one type of resolved object * is allowed */ case ARGI_MUTEX: /* Need an operand of type ACPI_TYPE_MUTEX */ TypeNeeded = ACPI_TYPE_MUTEX; break; case ARGI_EVENT: /* Need an operand of type ACPI_TYPE_EVENT */ TypeNeeded = ACPI_TYPE_EVENT; break; case ARGI_REGION: /* Need an operand of type ACPI_TYPE_REGION */ TypeNeeded = ACPI_TYPE_REGION; break; - case ARGI_IF: /* If */ - - /* Need an operand of type INTERNAL_TYPE_IF */ - - TypeNeeded = INTERNAL_TYPE_IF; - break; - case ARGI_PACKAGE: /* Package */ /* Need an operand of type ACPI_TYPE_PACKAGE */ TypeNeeded = ACPI_TYPE_PACKAGE; break; case ARGI_ANYTYPE: /* Any operand type will do */ TypeNeeded = ACPI_TYPE_ANY; break; /* * The more complex cases allow multiple resolved object types */ case ARGI_INTEGER: /* Number */ /* * Need an operand of type ACPI_TYPE_INTEGER, * But we can implicitly convert from a STRING or BUFFER * Aka - "Implicit Source Operand Conversion" */ Status = AcpiExConvertToInteger (ObjDesc, StackPtr, WalkState); if (ACPI_FAILURE (Status)) { if (Status == AE_TYPE) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed [Integer/String/Buffer], found [%s] %p\n", AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } return_ACPI_STATUS (Status); } - - if (ObjDesc != *StackPtr) - { - /* - * We just created a new object, remove a reference - * on the original operand object - */ - AcpiUtRemoveReference (ObjDesc); - } goto NextOperand; case ARGI_BUFFER: /* * Need an operand of type ACPI_TYPE_BUFFER, * But we can implicitly convert from a STRING or INTEGER * Aka - "Implicit Source Operand Conversion" */ Status = AcpiExConvertToBuffer (ObjDesc, StackPtr, WalkState); if (ACPI_FAILURE (Status)) { if (Status == AE_TYPE) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed [Integer/String/Buffer], found [%s] %p\n", AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } return_ACPI_STATUS (Status); } - - if (ObjDesc != *StackPtr) - { - /* - * We just created a new object, remove a reference - * on the original operand object - */ - AcpiUtRemoveReference (ObjDesc); - } goto NextOperand; case ARGI_STRING: /* * Need an operand of type ACPI_TYPE_STRING, * But we can implicitly convert from a BUFFER or INTEGER * Aka - "Implicit Source Operand Conversion" */ Status = AcpiExConvertToString (ObjDesc, StackPtr, 16, ACPI_UINT32_MAX, WalkState); if (ACPI_FAILURE (Status)) { if (Status == AE_TYPE) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed [Integer/String/Buffer], found [%s] %p\n", AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } return_ACPI_STATUS (Status); } - - if (ObjDesc != *StackPtr) - { - /* - * We just created a new object, remove a reference - * on the original operand object - */ - AcpiUtRemoveReference (ObjDesc); - } goto NextOperand; case ARGI_COMPUTEDATA: /* Need an operand of type INTEGER, STRING or BUFFER */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_INTEGER: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: /* Valid operand */ break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed [Integer/String/Buffer], found [%s] %p\n", AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } goto NextOperand; case ARGI_DATAOBJECT: /* * ARGI_DATAOBJECT is only used by the SizeOf operator. * Need a buffer, string, package, or RefOf reference. * * The only reference allowed here is a direct reference to * a namespace node. */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_PACKAGE: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: /* Valid operand */ break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed [Buf/Str/Pkg], found [%s] %p\n", AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } goto NextOperand; case ARGI_COMPLEXOBJ: /* Need a buffer or package or (ACPI 2.0) String */ switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) { case ACPI_TYPE_PACKAGE: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: /* Valid operand */ break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed [Buf/Str/Pkg], found [%s] %p\n", AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } goto NextOperand; default: /* Unknown type */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Internal - Unknown ARGI (required operand) type %X\n", ThisArgType)); return_ACPI_STATUS (AE_BAD_PARAMETER); } /* * Make sure that the original object was resolved to the * required object type (Simple cases only). */ Status = AcpiExCheckObjectType (TypeNeeded, ACPI_GET_OBJECT_TYPE (*StackPtr), *StackPtr); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } NextOperand: /* * If more operands needed, decrement StackPtr to point * to next operand on stack */ if (GET_CURRENT_ARG_TYPE (ArgTypes)) { StackPtr--; } } /* while (*Types) */ return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exstore.c b/sys/contrib/dev/acpica/exstore.c index 92caf43a4604..237cceeff6bf 100644 --- a/sys/contrib/dev/acpica/exstore.c +++ b/sys/contrib/dev/acpica/exstore.c @@ -1,600 +1,600 @@ /****************************************************************************** * * Module Name: exstore - AML Interpreter object store support - * $Revision: 172 $ + * $Revision: 174 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXSTORE_C__ #include "acpi.h" #include "acdispat.h" #include "acinterp.h" #include "amlcode.h" #include "acnamesp.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exstore") /******************************************************************************* * * FUNCTION: AcpiExStore * * PARAMETERS: *SourceDesc - Value to be stored * *DestDesc - Where to store it. Must be an NS node * or an ACPI_OPERAND_OBJECT of type * Reference; * WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: Store the value described by SourceDesc into the location * described by DestDesc. Called by various interpreter * functions to store the result of an operation into * the destination operand -- not just simply the actual "Store" * ASL operator. * ******************************************************************************/ ACPI_STATUS AcpiExStore ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *RefDesc = DestDesc; ACPI_FUNCTION_TRACE_PTR ("ExStore", DestDesc); /* Validate parameters */ if (!SourceDesc || !DestDesc) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null parameter\n")); return_ACPI_STATUS (AE_AML_NO_OPERAND); } /* DestDesc can be either a namespace node or an ACPI object */ if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED) { /* * Dest is a namespace node, - * Storing an object into a Name "container" + * Storing an object into a Named node. */ Status = AcpiExStoreObjectToNode (SourceDesc, (ACPI_NAMESPACE_NODE *) DestDesc, WalkState); return_ACPI_STATUS (Status); } /* Destination object must be a Reference or a Constant object */ switch (ACPI_GET_OBJECT_TYPE (DestDesc)) { - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: break; case ACPI_TYPE_INTEGER: /* Allow stores to Constants -- a Noop as per ACPI spec */ if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT) { return_ACPI_STATUS (AE_OK); } /*lint -fallthrough */ default: /* Destination is not an Reference */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Destination is not a Reference or Constant object [%p]\n", DestDesc)); ACPI_DUMP_STACK_ENTRY (SourceDesc); ACPI_DUMP_STACK_ENTRY (DestDesc); ACPI_DUMP_OPERANDS (&DestDesc, ACPI_IMODE_EXECUTE, "ExStore", 2, "Target is not a Reference or Constant object"); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* * Examine the Reference opcode. These cases are handled: * * 1) Store to Name (Change the object associated with a name) * 2) Store to an indexed area of a Buffer or Package * 3) Store to a Method Local or Arg * 4) Store to the debug object */ switch (RefDesc->Reference.Opcode) { case AML_NAME_OP: case AML_REF_OF_OP: /* Storing an object into a Name "container" */ Status = AcpiExStoreObjectToNode (SourceDesc, RefDesc->Reference.Object, WalkState); break; case AML_INDEX_OP: /* Storing to an Index (pointer into a packager or buffer) */ Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState); break; case AML_LOCAL_OP: case AML_ARG_OP: /* Store to a method local/arg */ Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Opcode, RefDesc->Reference.Offset, SourceDesc, WalkState); break; case AML_DEBUG_OP: /* * Storing to the Debug object causes the value stored to be * displayed and otherwise has no effect -- see ACPI Specification */ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Write to Debug Object: ****:\n\n")); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %s: ", AcpiUtGetObjectTypeName (SourceDesc))); switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) { case ACPI_TYPE_INTEGER: ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%8.8X%8.8X\n", ACPI_HIWORD (SourceDesc->Integer.Value), ACPI_LOWORD (SourceDesc->Integer.Value))); break; case ACPI_TYPE_BUFFER: ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Length %.2X\n", (UINT32) SourceDesc->Buffer.Length)); break; case ACPI_TYPE_STRING: ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "%s\n", SourceDesc->String.Pointer)); break; case ACPI_TYPE_PACKAGE: ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Elements Ptr - %p\n", SourceDesc->Package.Elements)); break; default: ACPI_DEBUG_PRINT_RAW ((ACPI_DB_DEBUG_OBJECT, "Type %s %p\n", AcpiUtGetObjectTypeName (SourceDesc), SourceDesc)); break; } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n")); break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Reference opcode %X\n", RefDesc->Reference.Opcode)); ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_ERROR); Status = AE_AML_INTERNAL; break; } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExStoreObjectToIndex * * PARAMETERS: *SourceDesc - Value to be stored * *DestDesc - Named object to receive the value * WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: Store the object to indexed Buffer or Package element * ******************************************************************************/ ACPI_STATUS AcpiExStoreObjectToIndex ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *IndexDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *NewDesc; UINT8 Value = 0; ACPI_FUNCTION_TRACE ("ExStoreObjectToIndex"); /* * Destination must be a reference pointer, and * must point to either a buffer or a package */ switch (IndexDesc->Reference.TargetType) { case ACPI_TYPE_PACKAGE: /* * Storing to a package element is not simple. The source must be * evaluated and converted to the type of the destination and then the * source is copied into the destination - we can't just point to the * source object. */ /* * The object at *(IndexDesc->Reference.Where) is the * element within the package that is to be modified. */ ObjDesc = *(IndexDesc->Reference.Where); /* Do the conversion/store */ Status = AcpiExStoreObjectToObject (SourceDesc, ObjDesc, &NewDesc, WalkState); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not store object to indexed package element\n")); return_ACPI_STATUS (Status); } /* * If a new object was created, we must install it as the new * package element */ if (NewDesc != ObjDesc) { AcpiUtRemoveReference (ObjDesc); *(IndexDesc->Reference.Where) = NewDesc; /* If same as the original source, add a reference */ if (NewDesc == SourceDesc) { AcpiUtAddReference (NewDesc); } } break; case ACPI_TYPE_BUFFER_FIELD: /* * Store into a Buffer (not actually a real BufferField) at a * location defined by an Index. * * The first 8-bit element of the source object is written to the * 8-bit Buffer location defined by the Index destination object, * according to the ACPI 2.0 specification. */ /* * Make sure the target is a Buffer */ ObjDesc = IndexDesc->Reference.Object; if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_BUFFER) { return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* * The assignment of the individual elements will be slightly * different for each source type. */ switch (ACPI_GET_OBJECT_TYPE (SourceDesc)) { case ACPI_TYPE_INTEGER: /* Use the least-significant byte of the integer */ Value = (UINT8) (SourceDesc->Integer.Value); break; case ACPI_TYPE_BUFFER: Value = SourceDesc->Buffer.Pointer[0]; break; case ACPI_TYPE_STRING: Value = (UINT8) SourceDesc->String.Pointer[0]; break; default: /* All other types are invalid */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Source must be Integer/Buffer/String type, not %s\n", AcpiUtGetObjectTypeName (SourceDesc))); return_ACPI_STATUS (AE_AML_OPERAND_TYPE); } /* Store the source value into the target buffer byte */ ObjDesc->Buffer.Pointer[IndexDesc->Reference.Offset] = Value; break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Target is not a Package or BufferField\n")); Status = AE_AML_OPERAND_TYPE; break; } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExStoreObjectToNode * * PARAMETERS: SourceDesc - Value to be stored * Node - Named object to receive the value * WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: Store the object to the named object. * * The Assignment of an object to a named object is handled here * The value passed in will replace the current value (if any) * with the input value. * * When storing into an object the data is converted to the * target object type then stored in the object. This means * that the target object type (for an initialized target) will * not be changed by a store operation. * * Assumes parameters are already validated. * ******************************************************************************/ ACPI_STATUS AcpiExStoreObjectToNode ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_NAMESPACE_NODE *Node, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *TargetDesc; ACPI_OPERAND_OBJECT *NewDesc; ACPI_OBJECT_TYPE TargetType; ACPI_FUNCTION_TRACE_PTR ("ExStoreObjectToNode", SourceDesc); /* * Get current type of the node, and object attached to Node */ TargetType = AcpiNsGetType (Node); TargetDesc = AcpiNsGetAttachedObject (Node); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), Node, AcpiUtGetTypeName (TargetType))); /* * Resolve the source object to an actual value * (If it is a reference object) */ Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Do the actual store operation */ switch (TargetType) { case ACPI_TYPE_BUFFER_FIELD: - case INTERNAL_TYPE_REGION_FIELD: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + 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); + Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, &WalkState->ResultObj); break; case ACPI_TYPE_INTEGER: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: /* * These target types are all of type Integer/String/Buffer, and * therefore support implicit conversion before the store. * * Copy and/or convert the source object to a new target object */ Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, &NewDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } if (NewDesc != TargetDesc) { /* * Store the new NewDesc as the new value of the Name, and set * the Name's type to that of the value being stored in it. * SourceDesc reference count is incremented by AttachObject. * * Note: This may change the type of the node if an explicit store * has been performed such that the node/object type has been * changed. */ Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Store %s into %s via Convert/Attach\n", AcpiUtGetObjectTypeName (SourceDesc), AcpiUtGetObjectTypeName (NewDesc))); } break; default: ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %s (%p) directly into node (%p), 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)); break; } return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exstoren.c b/sys/contrib/dev/acpica/exstoren.c index 712fcdd0ce6b..961d642339b9 100644 --- a/sys/contrib/dev/acpica/exstoren.c +++ b/sys/contrib/dev/acpica/exstoren.c @@ -1,376 +1,376 @@ /****************************************************************************** * * Module Name: exstoren - AML Interpreter object store support, * Store to Node (namespace object) - * $Revision: 51 $ + * $Revision: 52 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXSTOREN_C__ #include "acpi.h" #include "acinterp.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exstoren") /******************************************************************************* * * FUNCTION: AcpiExResolveObject * * PARAMETERS: SourceDescPtr - Pointer to the source object * TargetType - Current type of the target * WalkState - Current walk state * * RETURN: Status, resolved object in SourceDescPtr. * * DESCRIPTION: Resolve an object. If the object is a reference, dereference * it and return the actual object in the SourceDescPtr. * ******************************************************************************/ ACPI_STATUS AcpiExResolveObject ( ACPI_OPERAND_OBJECT **SourceDescPtr, ACPI_OBJECT_TYPE TargetType, ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("ExResolveObject"); /* * Ensure we have a Target that can be stored to */ switch (TargetType) { case ACPI_TYPE_BUFFER_FIELD: - case INTERNAL_TYPE_REGION_FIELD: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: /* * These cases all require only Integers or values that * can be converted to Integers (Strings or Buffers) */ case ACPI_TYPE_INTEGER: case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: /* * Stores into a Field/Region or into a Integer/Buffer/String * are all essentially the same. This case handles the * "interchangeable" types Integer, String, and Buffer. */ - if (ACPI_GET_OBJECT_TYPE (SourceDesc) == INTERNAL_TYPE_REFERENCE) + if (ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_LOCAL_REFERENCE) { /* Resolve a reference object first */ Status = AcpiExResolveToValue (SourceDescPtr, WalkState); if (ACPI_FAILURE (Status)) { break; } } /* * 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)) { /* * 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), AcpiUtGetTypeName (TargetType))); Status = AE_AML_OPERAND_TYPE; } break; - case INTERNAL_TYPE_ALIAS: + case ACPI_TYPE_LOCAL_ALIAS: /* * Aliases are resolved by AcpiExPrepOperands */ ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into Alias - should never happen\n")); Status = AE_AML_INTERNAL; break; case ACPI_TYPE_PACKAGE: default: /* * All other types than Alias and the various Fields come here, * including the untyped case - ACPI_TYPE_ANY. */ break; } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExStoreObjectToObject * * PARAMETERS: SourceDesc - Object to store * DestDesc - Object to receive a copy of the source * NewDesc - New object if DestDesc is obsoleted * WalkState - Current walk state * * RETURN: Status * * DESCRIPTION: "Store" an object to another object. This may include * converting the source type to the target type (implicit * conversion), and a copy of the value of the source to * the target. * * The Assignment of an object to another (not named) object * is handled here. * The Source passed in will replace the current value (if any) * with the input value. * * When storing into an object the data is converted to the * target object type then stored in the object. This means * that the target object type (for an initialized target) will * not be changed by a store operation. * * This module allows destination types of Number, String, * Buffer, and Package. * * Assumes parameters are already validated. NOTE: SourceDesc * resolution (from a reference object) must be performed by * the caller if necessary. * ******************************************************************************/ ACPI_STATUS AcpiExStoreObjectToObject ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc, ACPI_OPERAND_OBJECT **NewDesc, ACPI_WALK_STATE *WalkState) { ACPI_OPERAND_OBJECT *ActualSrcDesc; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE_PTR ("AcpiExStoreObjectToObject", SourceDesc); ActualSrcDesc = SourceDesc; if (!DestDesc) { /* * There is no destination object (An uninitialized node or * package element), so we can simply copy the source object * creating a new destination object */ Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, NewDesc, WalkState); return_ACPI_STATUS (Status); } if (ACPI_GET_OBJECT_TYPE (SourceDesc) != ACPI_GET_OBJECT_TYPE (DestDesc)) { /* * The source type does not match the type of the destination. * Perform the "implicit conversion" of the source to the current type * of the target as per the ACPI specification. * * If no conversion performed, ActualSrcDesc = SourceDesc. * Otherwise, ActualSrcDesc is a temporary object to hold the * converted object. */ Status = AcpiExConvertToTargetType (ACPI_GET_OBJECT_TYPE (DestDesc), SourceDesc, &ActualSrcDesc, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } if (SourceDesc == ActualSrcDesc) { /* * No conversion was performed. Return the SourceDesc as the * new object. */ *NewDesc = SourceDesc; return_ACPI_STATUS (AE_OK); } } /* * We now have two objects of identical types, and we can perform a * copy of the *value* of the source object. */ switch (ACPI_GET_OBJECT_TYPE (DestDesc)) { case ACPI_TYPE_INTEGER: DestDesc->Integer.Value = ActualSrcDesc->Integer.Value; /* Truncate value if we are executing from a 32-bit ACPI table */ AcpiExTruncateFor32bitTable (DestDesc); break; case ACPI_TYPE_STRING: Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc); break; case ACPI_TYPE_BUFFER: Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc); break; case ACPI_TYPE_PACKAGE: Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc, WalkState); break; default: /* * All other types come here. */ ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Store into type %s not implemented\n", AcpiUtGetObjectTypeName (DestDesc))); Status = AE_NOT_IMPLEMENTED; break; } if (ActualSrcDesc != SourceDesc) { /* Delete the intermediate (temporary) source object */ AcpiUtRemoveReference (ActualSrcDesc); } *NewDesc = DestDesc; return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/exstorob.c b/sys/contrib/dev/acpica/exstorob.c index 9a3bee8eef1f..f9be073b5dc3 100644 --- a/sys/contrib/dev/acpica/exstorob.c +++ b/sys/contrib/dev/acpica/exstorob.c @@ -1,277 +1,277 @@ /****************************************************************************** * * Module Name: exstorob - AML Interpreter object store support, store to object - * $Revision: 45 $ + * $Revision: 46 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXSTOROB_C__ #include "acpi.h" #include "acinterp.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exstorob") /******************************************************************************* * * FUNCTION: AcpiExStoreBufferToBuffer * * PARAMETERS: SourceDesc - Source object to copy * TargetDesc - Destination object of the copy * * RETURN: Status * * DESCRIPTION: Copy a buffer object to another buffer object. * ******************************************************************************/ ACPI_STATUS AcpiExStoreBufferToBuffer ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc) { UINT32 Length; UINT8 *Buffer; ACPI_FUNCTION_NAME ("ExStoreBufferToBuffer"); /* * We know that SourceDesc is a buffer by now */ Buffer = (UINT8 *) SourceDesc->Buffer.Pointer; Length = SourceDesc->Buffer.Length; /* * If target is a buffer of length zero, allocate a new * buffer of the proper length */ if (TargetDesc->Buffer.Length == 0) { TargetDesc->Buffer.Pointer = ACPI_MEM_ALLOCATE (Length); if (!TargetDesc->Buffer.Pointer) { return (AE_NO_MEMORY); } TargetDesc->Buffer.Length = Length; } /* * Buffer is a static allocation, * only place what will fit in the 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); } else { /* * 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", Length, TargetDesc->Buffer.Length)); } /* Copy flags */ TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags; return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiExStoreStringToString * * PARAMETERS: SourceDesc - Source object to copy * TargetDesc - Destination object of the copy * * RETURN: Status * * DESCRIPTION: Copy a String object to another String object * ******************************************************************************/ ACPI_STATUS AcpiExStoreStringToString ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *TargetDesc) { UINT32 Length; UINT8 *Buffer; ACPI_FUNCTION_ENTRY (); /* * We know that SourceDesc is a string by now. */ Buffer = (UINT8 *) SourceDesc->String.Pointer; Length = SourceDesc->String.Length; /* * Setting a string value replaces the old string */ if (Length < TargetDesc->String.Length) { /* * String will fit in existing buffer. * Clear old string and copy in the new one */ - ACPI_MEMSET (TargetDesc->String.Pointer, 0, TargetDesc->String.Length + 1); + ACPI_MEMSET (TargetDesc->String.Pointer, 0, (ACPI_SIZE) TargetDesc->String.Length + 1); ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); } else { /* * Free the current buffer, then allocate a new buffer * large enough to hold the value */ if (TargetDesc->String.Pointer && (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) { /* * 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); if (!TargetDesc->String.Pointer) { return (AE_NO_MEMORY); } ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); } /* Set the new target length */ TargetDesc->String.Length = Length; return (AE_OK); } diff --git a/sys/contrib/dev/acpica/exutils.c b/sys/contrib/dev/acpica/exutils.c index 0e75d9df93bf..599f0afb217d 100644 --- a/sys/contrib/dev/acpica/exutils.c +++ b/sys/contrib/dev/acpica/exutils.c @@ -1,489 +1,462 @@ /****************************************************************************** * * Module Name: exutils - interpreter/scanner utilities - * $Revision: 103 $ + * $Revision: 106 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __EXUTILS_C__ /* * DEFINE_AML_GLOBALS is tested in amlcode.h * to determine whether certain global names should be "defined" or only * "declared" in the current compilation. This enhances maintainability * by enabling a single header file to embody all knowledge of the names * in question. * * Exactly one module of any executable should #define DEFINE_GLOBALS * before #including the header files which use this convention. The * names in question will be defined and initialized in that module, * and declared as extern in all other modules which #include those * header files. */ #define DEFINE_AML_GLOBALS #include "acpi.h" #include "acinterp.h" #include "amlcode.h" #include "acevents.h" #define _COMPONENT ACPI_EXECUTER ACPI_MODULE_NAME ("exutils") -/******************************************************************************* - * - * FUNCTION: AcpiExValidateObjectType - * - * PARAMETERS: Type Object type to validate - * - * DESCRIPTION: Determine if a type is a valid ACPI object type - * - ******************************************************************************/ - -BOOLEAN -AcpiExValidateObjectType ( - ACPI_OBJECT_TYPE Type) -{ - - ACPI_FUNCTION_ENTRY (); - - - if ((Type > ACPI_TYPE_MAX && Type < INTERNAL_TYPE_BEGIN) || - (Type > INTERNAL_TYPE_MAX)) - { - return (FALSE); - } - - return (TRUE); -} - #ifndef ACPI_NO_METHOD_EXECUTION /******************************************************************************* * * FUNCTION: AcpiExEnterInterpreter * * PARAMETERS: None * * DESCRIPTION: Enter the interpreter execution region. Failure to enter * the interpreter region is a fatal system error * ******************************************************************************/ ACPI_STATUS AcpiExEnterInterpreter (void) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("ExEnterInterpreter"); Status = AcpiUtAcquireMutex (ACPI_MTX_EXECUTE); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("Could not acquire interpreter mutex\n")); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiExExitInterpreter * * PARAMETERS: None * * DESCRIPTION: Exit the interpreter execution region * * Cases where the interpreter is unlocked: * 1) Completion of the execution of a control method * 2) Method blocked on a Sleep() AML opcode * 3) Method blocked on an Acquire() AML opcode * 4) Method blocked on a Wait() AML opcode * 5) Method blocked to acquire the global lock * 6) Method blocked to execute a serialized control method that is * already executing * 7) About to invoke a user-installed opregion handler * ******************************************************************************/ void AcpiExExitInterpreter (void) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("ExExitInterpreter"); Status = AcpiUtReleaseMutex (ACPI_MTX_EXECUTE); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("Could not release interpreter mutex\n")); } return_VOID; } /******************************************************************************* * * FUNCTION: AcpiExTruncateFor32bitTable * * PARAMETERS: ObjDesc - Object to be truncated * * RETURN: none * * DESCRIPTION: Truncate a number to 32-bits if the currently executing method * belongs to a 32-bit ACPI table. * ******************************************************************************/ void AcpiExTruncateFor32bitTable ( ACPI_OPERAND_OBJECT *ObjDesc) { ACPI_FUNCTION_ENTRY (); /* * Object must be a valid number and we must be executing * a control method */ if ((!ObjDesc) || (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER)) { return; } if (AcpiGbl_IntegerByteWidth == 4) { /* * We are running a method that exists in a 32-bit ACPI table. * Truncate the value to 32 bits by zeroing out the upper 32-bit field */ ObjDesc->Integer.Value &= (ACPI_INTEGER) ACPI_UINT32_MAX; } } /******************************************************************************* * * FUNCTION: AcpiExAcquireGlobalLock * * PARAMETERS: FieldFlags - Flags with Lock rule: * AlwaysLock or NeverLock * * RETURN: TRUE/FALSE indicating whether the lock was actually acquired * * DESCRIPTION: Obtain the global lock and keep track of this fact via two * methods. A global variable keeps the state of the lock, and * the state is returned to the caller. * ******************************************************************************/ BOOLEAN AcpiExAcquireGlobalLock ( UINT32 FieldFlags) { BOOLEAN Locked = FALSE; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("ExAcquireGlobalLock"); /* Only attempt lock if the AlwaysLock bit is set */ if (FieldFlags & AML_FIELD_LOCK_RULE_MASK) { /* We should attempt to get the lock, wait forever */ - Status = AcpiEvAcquireGlobalLock (ACPI_UINT32_MAX); + Status = AcpiEvAcquireGlobalLock (ACPI_WAIT_FOREVER); if (ACPI_SUCCESS (Status)) { Locked = TRUE; } else { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not acquire Global Lock, %s\n", AcpiFormatException (Status))); } } return_VALUE (Locked); } /******************************************************************************* * * FUNCTION: AcpiExReleaseGlobalLock * * PARAMETERS: LockedByMe - Return value from corresponding call to * AcquireGlobalLock. * * RETURN: Status * * DESCRIPTION: Release the global lock if it is locked. * ******************************************************************************/ void AcpiExReleaseGlobalLock ( BOOLEAN LockedByMe) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("ExReleaseGlobalLock"); /* Only attempt unlock if the caller locked it */ if (LockedByMe) { /* OK, now release the lock */ Status = AcpiEvReleaseGlobalLock (); if (ACPI_FAILURE (Status)) { /* Report the error, but there isn't much else we can do */ ACPI_REPORT_ERROR (("Could not release ACPI Global Lock, %s\n", AcpiFormatException (Status))); } } return_VOID; } /******************************************************************************* * * FUNCTION: AcpiExDigitsNeeded * * PARAMETERS: Value - Value to be represented * Base - Base of representation * * RETURN: the number of digits needed to represent Value in Base * ******************************************************************************/ UINT32 AcpiExDigitsNeeded ( ACPI_INTEGER Value, UINT32 Base) { UINT32 NumDigits; ACPI_INTEGER CurrentValue; ACPI_INTEGER Quotient; ACPI_FUNCTION_TRACE ("ExDigitsNeeded"); /* * ACPI_INTEGER is unsigned, so we don't worry about a '-' */ CurrentValue = Value; NumDigits = 0; while (CurrentValue) { (void) AcpiUtShortDivide (&CurrentValue, Base, &Quotient, NULL); NumDigits++; CurrentValue = Quotient; } return_VALUE (NumDigits); } /******************************************************************************* * * FUNCTION: AcpiExEisaIdToString * * PARAMETERS: NumericId - EISA ID to be converted * OutString - Where to put the converted string (8 bytes) * * DESCRIPTION: Convert a numeric EISA ID to string representation * ******************************************************************************/ void AcpiExEisaIdToString ( UINT32 NumericId, NATIVE_CHAR *OutString) { UINT32 EisaId; ACPI_FUNCTION_ENTRY (); /* Swap ID to big-endian to get contiguous bits */ EisaId = AcpiUtDwordByteSwap (NumericId); - OutString[0] = (char) ('@' + ((EisaId >> 26) & 0x1f)); + OutString[0] = (char) ('@' + (((unsigned long) EisaId >> 26) & 0x1f)); OutString[1] = (char) ('@' + ((EisaId >> 21) & 0x1f)); OutString[2] = (char) ('@' + ((EisaId >> 16) & 0x1f)); OutString[3] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 12); OutString[4] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 8); OutString[5] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 4); OutString[6] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) EisaId, 0); OutString[7] = 0; } /******************************************************************************* * * FUNCTION: AcpiExUnsignedIntegerToString * * PARAMETERS: Value - Value to be converted * OutString - Where to put the converted string (8 bytes) * * RETURN: Convert a number to string representation * ******************************************************************************/ void AcpiExUnsignedIntegerToString ( ACPI_INTEGER Value, NATIVE_CHAR *OutString) { UINT32 Count; UINT32 DigitsNeeded; UINT32 Remainder; ACPI_INTEGER Quotient; ACPI_FUNCTION_ENTRY (); DigitsNeeded = AcpiExDigitsNeeded (Value, 10); OutString[DigitsNeeded] = 0; for (Count = DigitsNeeded; Count > 0; Count--) { (void) AcpiUtShortDivide (&Value, 10, &Quotient, &Remainder); OutString[Count-1] = (NATIVE_CHAR) ('0' + Remainder);\ Value = Quotient; } } #endif diff --git a/sys/contrib/dev/acpica/nsaccess.c b/sys/contrib/dev/acpica/nsaccess.c index 92594d02fd4a..51e89ea92cfd 100644 --- a/sys/contrib/dev/acpica/nsaccess.c +++ b/sys/contrib/dev/acpica/nsaccess.c @@ -1,730 +1,710 @@ /******************************************************************************* * * Module Name: nsaccess - Top-level functions for accessing ACPI namespace - * $Revision: 161 $ + * $Revision: 165 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __NSACCESS_C__ #include "acpi.h" #include "amlcode.h" #include "acnamesp.h" #include "acdispat.h" #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsaccess") /******************************************************************************* * * FUNCTION: AcpiNsRootInitialize * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Allocate and initialize the default root named objects * * MUTEX: Locks namespace for entire execution * ******************************************************************************/ ACPI_STATUS AcpiNsRootInitialize (void) { ACPI_STATUS Status; const ACPI_PREDEFINED_NAMES *InitVal = NULL; ACPI_NAMESPACE_NODE *NewNode; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_TRACE ("NsRootInitialize"); Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * The global root ptr is initially NULL, so a non-NULL value indicates * that AcpiNsRootInitialize() has already been called; just return. */ if (AcpiGbl_RootNode) { Status = AE_OK; goto UnlockAndExit; } /* * Tell the rest of the subsystem that the root is initialized * (This is OK because the namespace is locked) */ AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct; /* Enter the pre-defined names in the name table */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Entering predefined entries into namespace\n")); for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++) { Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type, ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, NULL, &NewNode); if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */ { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not create predefined name %s, %s\n", InitVal->Name, AcpiFormatException (Status))); } /* * Name entered successfully. * If entry in PreDefinedNames[] specifies an * initial value, create the initial value. */ if (InitVal->Val) { /* * Entry requests an initial value, allocate a * descriptor for it. */ ObjDesc = AcpiUtCreateInternalObject (InitVal->Type); if (!ObjDesc) { Status = AE_NO_MEMORY; goto UnlockAndExit; } /* * Convert value string from table entry to * internal representation. Only types actually * used for initial values are implemented here. */ switch (InitVal->Type) { case ACPI_TYPE_METHOD: ObjDesc->Method.ParamCount = (UINT8) ACPI_STRTOUL (InitVal->Val, NULL, 10); ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; #if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) /* Compiler cheats by putting parameter count in the OwnerID */ NewNode->OwnerId = ObjDesc->Method.ParamCount; #endif break; case ACPI_TYPE_INTEGER: ObjDesc->Integer.Value = (ACPI_INTEGER) ACPI_STRTOUL (InitVal->Val, NULL, 10); break; case ACPI_TYPE_STRING: /* * Build an object around the static string */ - ObjDesc->String.Length = ACPI_STRLEN (InitVal->Val); + ObjDesc->String.Length = (UINT32) ACPI_STRLEN (InitVal->Val); ObjDesc->String.Pointer = InitVal->Val; ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; break; case ACPI_TYPE_MUTEX: + ObjDesc->Mutex.Node = NewNode; ObjDesc->Mutex.SyncLevel = (UINT16) ACPI_STRTOUL (InitVal->Val, NULL, 10); if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0) { /* * Create a counting semaphore for the * global lock */ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 1, &ObjDesc->Mutex.Semaphore); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } /* * We just created the mutex for the * global lock, save it */ AcpiGbl_GlobalLockSemaphore = ObjDesc->Mutex.Semaphore; } else { /* Create a mutex */ Status = AcpiOsCreateSemaphore (1, 1, &ObjDesc->Mutex.Semaphore); if (ACPI_FAILURE (Status)) { goto UnlockAndExit; } } break; default: ACPI_REPORT_ERROR (("Unsupported initial type value %X\n", InitVal->Type)); AcpiUtRemoveReference (ObjDesc); ObjDesc = NULL; continue; } /* Store pointer to value descriptor in the Node */ Status = AcpiNsAttachObject (NewNode, ObjDesc, ACPI_GET_OBJECT_TYPE (ObjDesc)); /* Remove local reference to the object */ AcpiUtRemoveReference (ObjDesc); } } UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiNsLookup * * PARAMETERS: PrefixNode - Search scope if name is not fully qualified * Pathname - Search pathname, in internal format * (as represented in the AML stream) * Type - Type associated with name * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found * Flags - Flags describing the search restrictions * WalkState - Current state of the walk * ReturnNode - Where the Node is placed (if found * or created successfully) * * RETURN: Status * * DESCRIPTION: Find or enter the passed name in the name space. * Log an error if name not found in Exec mode. * * MUTEX: Assumes namespace is locked. * ******************************************************************************/ ACPI_STATUS AcpiNsLookup ( ACPI_GENERIC_STATE *ScopeInfo, NATIVE_CHAR *Pathname, ACPI_OBJECT_TYPE Type, ACPI_INTERPRETER_MODE InterpreterMode, UINT32 Flags, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE **ReturnNode) { ACPI_STATUS Status; NATIVE_CHAR *Path = Pathname; ACPI_NAMESPACE_NODE *PrefixNode; ACPI_NAMESPACE_NODE *CurrentNode = NULL; ACPI_NAMESPACE_NODE *ThisNode = NULL; UINT32 NumSegments; + UINT32 NumCarats; ACPI_NAME SimpleName; ACPI_OBJECT_TYPE TypeToCheckFor; ACPI_OBJECT_TYPE ThisSearchType; UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT; UINT32 LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT); ACPI_FUNCTION_TRACE ("NsLookup"); if (!ReturnNode) { return_ACPI_STATUS (AE_BAD_PARAMETER); } AcpiGbl_NsLookupCount++; *ReturnNode = ACPI_ENTRY_NOT_FOUND; if (!AcpiGbl_RootNode) { return_ACPI_STATUS (AE_NO_NAMESPACE); } /* * Get the prefix scope. * A null scope means use the root scope */ if ((!ScopeInfo) || (!ScopeInfo->Scope.Node)) { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Null scope prefix, using root node (%p)\n", AcpiGbl_RootNode)); PrefixNode = AcpiGbl_RootNode; } else { PrefixNode = ScopeInfo->Scope.Node; if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "[%p] Not a namespace node\n", PrefixNode)); return_ACPI_STATUS (AE_AML_INTERNAL); } /* * This node might not be a actual "scope" node (such as a * Device/Method, etc.) It could be a Package or other object node. * Backup up the tree to find the containing scope node. */ while (!AcpiNsOpensScope (PrefixNode->Type) && PrefixNode->Type != ACPI_TYPE_ANY) { PrefixNode = AcpiNsGetParentNode (PrefixNode); } } - /* - * This check is explicitly split to relax the TypeToCheckFor - * conditions for BankFieldDefn. Originally, both BankFieldDefn and - * DefFieldDefn caused TypeToCheckFor to be set to ACPI_TYPE_REGION, - * but the BankFieldDefn may also check for a Field definition as well - * as an OperationRegion. - */ - if (INTERNAL_TYPE_FIELD_DEFN == Type) - { - /* DefFieldDefn defines fields in a Region */ + /* Save type TBD: may be no longer necessary */ - TypeToCheckFor = ACPI_TYPE_REGION; - } - else if (INTERNAL_TYPE_BANK_FIELD_DEFN == Type) - { - /* BankFieldDefn defines data fields in a Field Object */ - - TypeToCheckFor = ACPI_TYPE_ANY; - } - else - { - TypeToCheckFor = Type; - } + TypeToCheckFor = Type; /* * Begin examination of the actual pathname */ if (!Pathname) { /* A Null NamePath is allowed and refers to the root */ NumSegments = 0; ThisNode = AcpiGbl_RootNode; Path = ""; ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Null Pathname (Zero segments), Flags=%X\n", Flags)); } else { /* * Name pointer is valid (and must be in internal name format) * * Check for scope prefixes: * * As represented in the AML stream, a namepath consists of an * optional scope prefix followed by a name segment part. * * If present, the scope prefix is either a Root Prefix (in * which case the name is fully qualified), or one or more * Parent Prefixes (in which case the name's scope is relative * to the current scope). */ if (*Path == (UINT8) AML_ROOT_PREFIX) { /* Pathname is fully qualified, start from the root */ ThisNode = AcpiGbl_RootNode; SearchParentFlag = ACPI_NS_NO_UPSEARCH; /* Point to name segment part */ Path++; ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Path is absolute from root [%p]\n", ThisNode)); } else { /* Pathname is relative to current scope, start there */ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Searching relative to prefix scope [%p]\n", - PrefixNode)); + "Searching relative to prefix scope [%4.4s] (%p)\n", + PrefixNode->Name.Ascii, PrefixNode)); /* * Handle multiple Parent Prefixes (carat) by just getting * the parent node for each prefix instance. */ ThisNode = PrefixNode; + NumCarats = 0; while (*Path == (UINT8) AML_PARENT_PREFIX) { /* Name is fully qualified, no search rules apply */ SearchParentFlag = ACPI_NS_NO_UPSEARCH; /* * Point past this prefix to the name segment * part or the next Parent Prefix */ Path++; /* Backup to the parent node */ + NumCarats++; ThisNode = AcpiNsGetParentNode (ThisNode); if (!ThisNode) { /* Current scope has no parent scope */ ACPI_REPORT_ERROR ( ("ACPI path has too many parent prefixes (^) - reached beyond root node\n")); return_ACPI_STATUS (AE_NOT_FOUND); } } if (SearchParentFlag == ACPI_NS_NO_UPSEARCH) { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Path is absolute with one or more carats\n")); + "Search scope is [%4.4s], path has %d carat(s)\n", + ThisNode->Name.Ascii, NumCarats)); } } /* * Determine the number of ACPI name segments in this pathname. * * The segment part consists of either: * - A Null name segment (0) * - A DualNamePrefix followed by two 4-byte name segments * - A MultiNamePrefix followed by a byte indicating the * number of segments and the segments themselves. * - A single 4-byte name segment * * Examine the name prefix opcode, if any, to determine the number of * segments. */ switch (*Path) { case 0: /* * Null name after a root or parent prefixes. We already * have the correct target node and there are no name segments. */ NumSegments = 0; + Type = ThisNode->Type; ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Prefix-only Pathname (Zero name segments), Flags=%X\n", Flags)); break; case AML_DUAL_NAME_PREFIX: /* More than one NameSeg, search rules do not apply */ SearchParentFlag = ACPI_NS_NO_UPSEARCH; /* Two segments, point to first name segment */ NumSegments = 2; Path++; ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Dual Pathname (2 segments, Flags=%X)\n", Flags)); break; case AML_MULTI_NAME_PREFIX_OP: /* More than one NameSeg, search rules do not apply */ SearchParentFlag = ACPI_NS_NO_UPSEARCH; /* Extract segment count, point to first name segment */ Path++; NumSegments = (UINT32) (UINT8) *Path; Path++; ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Multi Pathname (%d Segments, Flags=%X) \n", NumSegments, Flags)); break; default: /* * Not a Null name, no Dual or Multi prefix, hence there is * only one name segment and Pathname is already pointing to it. */ NumSegments = 1; ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Simple Pathname (1 segment, Flags=%X)\n", Flags)); break; } ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path)); } /* * Search namespace for each segment of the name. Loop through and * verify (or add to the namespace) each name segment. * * The object type is significant only at the last name * segment. (We don't care about the types along the path, only * the type of the final target object.) */ ThisSearchType = ACPI_TYPE_ANY; CurrentNode = ThisNode; while (NumSegments && CurrentNode) { NumSegments--; if (!NumSegments) { /* * This is the last segment, enable typechecking */ ThisSearchType = Type; /* * Only allow automatic parent search (search rules) if the caller * requested it AND we have a single, non-fully-qualified NameSeg */ if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) && (Flags & ACPI_NS_SEARCH_PARENT)) { LocalFlags |= ACPI_NS_SEARCH_PARENT; } /* Set error flag according to caller */ if (Flags & ACPI_NS_ERROR_IF_FOUND) { LocalFlags |= ACPI_NS_ERROR_IF_FOUND; } } /* Extract one ACPI name from the front of the pathname */ ACPI_MOVE_UNALIGNED32_TO_32 (&SimpleName, Path); /* Try to find the single (4 character) ACPI name */ Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode, InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); if (ACPI_FAILURE (Status)) { if (Status == AE_NOT_FOUND) { /* Name not found in ACPI namespace */ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Name [%4.4s] not found in scope [%4.4s] %p\n", (char *) &SimpleName, (char *) &CurrentNode->Name, CurrentNode)); } + *ReturnNode = ThisNode; return_ACPI_STATUS (Status); } /* * Sanity typecheck of the target object: * * If 1) This is the last segment (NumSegments == 0) * 2) And we are looking for a specific type * (Not checking for TYPE_ANY) * 3) Which is not an alias - * 4) Which is not a local type (TYPE_DEF_ANY) - * 5) Which is not a local type (TYPE_SCOPE) - * 6) Which is not a local type (TYPE_INDEX_FIELD_DEFN) - * 7) And the type of target object is known (not TYPE_ANY) - * 8) And target object does not match what we are looking for + * 4) Which is not a local type (TYPE_SCOPE) + * 5) And the type of target object is known (not TYPE_ANY) + * 6) And target object does not match what we are looking for * * Then we have a type mismatch. Just warn and ignore it. */ if ((NumSegments == 0) && (TypeToCheckFor != ACPI_TYPE_ANY) && - (TypeToCheckFor != INTERNAL_TYPE_ALIAS) && - (TypeToCheckFor != INTERNAL_TYPE_DEF_ANY) && - (TypeToCheckFor != INTERNAL_TYPE_SCOPE) && - (TypeToCheckFor != INTERNAL_TYPE_INDEX_FIELD_DEFN) && + (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) && + (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) && (ThisNode->Type != ACPI_TYPE_ANY) && (ThisNode->Type != TypeToCheckFor)) { /* Complain about a type mismatch */ ACPI_REPORT_WARNING ( - ("NsLookup: %4.4s, type %X, checking for type %X\n", - (char *) &SimpleName, ThisNode->Type, TypeToCheckFor)); + ("NsLookup: Type mismatch on %4.4s (%s), searching for (%s)\n", + (char *) &SimpleName, AcpiUtGetTypeName (ThisNode->Type), + AcpiUtGetTypeName (TypeToCheckFor))); } /* * If this is the last name segment and we are not looking for a * specific type, but the type of found object is known, use that type * to see if it opens a scope. */ if ((NumSegments == 0) && (Type == ACPI_TYPE_ANY)) { Type = ThisNode->Type; } /* Point to next name segment and make this node current */ Path += ACPI_NAME_SIZE; CurrentNode = ThisNode; } /* * Always check if we need to open a new scope */ if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState)) { /* * If entry is a type which opens a scope, push the new scope on the * scope stack. */ - if (AcpiNsOpensScope (TypeToCheckFor)) + if (AcpiNsOpensScope (Type)) { Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } - - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "Setting current scope to [%4.4s] (%p)\n", - ThisNode->Name.Ascii, ThisNode)); } } *ReturnNode = ThisNode; return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/nsalloc.c b/sys/contrib/dev/acpica/nsalloc.c index cab91bdd76f0..16160aa5ce30 100644 --- a/sys/contrib/dev/acpica/nsalloc.c +++ b/sys/contrib/dev/acpica/nsalloc.c @@ -1,684 +1,762 @@ /******************************************************************************* * * Module Name: nsalloc - Namespace allocation and deletion utilities - * $Revision: 74 $ + * $Revision: 77 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __NSALLOC_C__ #include "acpi.h" #include "acnamesp.h" #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsalloc") /******************************************************************************* * * FUNCTION: AcpiNsCreateNode * * PARAMETERS: AcpiName - Name of the new node * * RETURN: None * * DESCRIPTION: Create a namespace node * ******************************************************************************/ ACPI_NAMESPACE_NODE * AcpiNsCreateNode ( UINT32 Name) { ACPI_NAMESPACE_NODE *Node; ACPI_FUNCTION_TRACE ("NsCreateNode"); Node = ACPI_MEM_CALLOCATE (sizeof (ACPI_NAMESPACE_NODE)); if (!Node) { return_PTR (NULL); } ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].TotalAllocated++); Node->Name.Integer = Name; Node->ReferenceCount = 1; ACPI_SET_DESCRIPTOR_TYPE (Node, ACPI_DESC_TYPE_NAMED); return_PTR (Node); } /******************************************************************************* * * FUNCTION: AcpiNsDeleteNode * * PARAMETERS: Node - Node to be deleted * * RETURN: None * * DESCRIPTION: Delete a namespace node * ******************************************************************************/ void AcpiNsDeleteNode ( ACPI_NAMESPACE_NODE *Node) { ACPI_NAMESPACE_NODE *ParentNode; ACPI_NAMESPACE_NODE *PrevNode; ACPI_NAMESPACE_NODE *NextNode; ACPI_FUNCTION_TRACE_PTR ("NsDeleteNode", Node); ParentNode = AcpiNsGetParentNode (Node); PrevNode = NULL; NextNode = ParentNode->Child; while (NextNode != Node) { PrevNode = NextNode; NextNode = PrevNode->Peer; } if (PrevNode) { PrevNode->Peer = NextNode->Peer; if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) { PrevNode->Flags |= ANOBJ_END_OF_PEER_LIST; } } else { ParentNode->Child = NextNode->Peer; } ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].TotalFreed++); /* * Detach an object if there is one then delete the node */ AcpiNsDetachObject (Node); ACPI_MEM_FREE (Node); return_VOID; } +#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 * * PARAMETERS: WalkState - Current state of the walk * ParentNode - The parent of the new Node * Node - The new Node to install * Type - ACPI object type of the new Node * * RETURN: None * * DESCRIPTION: Initialize a new namespace node and install it amongst * its peers. * - * Note: Current namespace lookup is linear search, so the nodes - * are not linked in any particular order. + * 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. * ******************************************************************************/ void AcpiNsInstallNode ( ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE *ParentNode, /* Parent */ ACPI_NAMESPACE_NODE *Node, /* New Child*/ ACPI_OBJECT_TYPE Type) { UINT16 OwnerId = TABLE_ID_DSDT; ACPI_NAMESPACE_NODE *ChildNode; +#ifdef ACPI_ALPHABETIC_NAMESPACE + + ACPI_NAMESPACE_NODE *PreviousChildNode; +#endif ACPI_FUNCTION_TRACE ("NsInstallNode"); /* * Get the owner ID from the Walk state * The owner ID is used to track table deletion and * deletion of objects created by methods */ if (WalkState) { OwnerId = WalkState->OwnerId; } /* Link the new entry into the parent and existing children */ ChildNode = ParentNode->Child; if (!ChildNode) { ParentNode->Child = Node; + Node->Flags |= ANOBJ_END_OF_PEER_LIST; + Node->Peer = ParentNode; } else { +#ifdef ACPI_ALPHABETIC_NAMESPACE + /* + * Walk the list whilst searching for the the correct + * alphabetic placement. + */ + PreviousChildNode = NULL; + while (AcpiNsCompareNames (ChildNode->Name.Ascii, Node->Name.Ascii) < 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; } ChildNode->Peer = Node; /* Clear end-of-list flag */ ChildNode->Flags &= ~ANOBJ_END_OF_PEER_LIST; + Node->Flags |= ANOBJ_END_OF_PEER_LIST; + Node->Peer = ParentNode; +#endif } /* Init the new entry */ - Node->OwnerId = OwnerId; - Node->Flags |= ANOBJ_END_OF_PEER_LIST; - Node->Peer = ParentNode; - - - /* - * If adding a name with unknown type, or having to - * add the region in order to define fields in it, we - * have a forward reference. - */ - if ((ACPI_TYPE_ANY == Type) || - (INTERNAL_TYPE_FIELD_DEFN == Type) || - (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)) - { - /* - * We don't want to abort here, however! - * We will fill in the actual type when the - * real definition is found later. - */ - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] is a forward reference\n", - Node->Name.Ascii)); - } - - /* - * The DefFieldDefn and BankFieldDefn cases are actually - * looking up the Region in which the field will be defined - */ - if ((INTERNAL_TYPE_FIELD_DEFN == Type) || - (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)) - { - Type = ACPI_TYPE_REGION; - } - - /* - * Scope, DefAny, and IndexFieldDefn are bogus "types" which do - * not actually have anything to do with the type of the name - * being looked up. Save any other value of Type as the type of - * the entry. - */ - if ((Type != INTERNAL_TYPE_SCOPE) && - (Type != INTERNAL_TYPE_DEF_ANY) && - (Type != INTERNAL_TYPE_INDEX_FIELD_DEFN)) - { - Node->Type = (UINT8) Type; - } + Node->OwnerId = OwnerId; + Node->Type = (UINT8) Type; - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s added to %p at %p\n", - Node->Name.Ascii, ParentNode, Node)); + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s (%s) added to %4.4s (%s) %p at %p\n", + Node->Name.Ascii, AcpiUtGetTypeName (Node->Type), + ParentNode->Name.Ascii, AcpiUtGetTypeName (ParentNode->Type), ParentNode, Node)); /* * Increment the reference count(s) of all parents up to * the root! */ while ((Node = AcpiNsGetParentNode (Node)) != NULL) { Node->ReferenceCount++; } return_VOID; } /******************************************************************************* * * FUNCTION: AcpiNsDeleteChildren * * PARAMETERS: ParentNode - Delete this objects children * * RETURN: None. * * DESCRIPTION: Delete all children of the parent object. In other words, * deletes a "scope". * ******************************************************************************/ void AcpiNsDeleteChildren ( ACPI_NAMESPACE_NODE *ParentNode) { ACPI_NAMESPACE_NODE *ChildNode; ACPI_NAMESPACE_NODE *NextNode; UINT8 Flags; ACPI_FUNCTION_TRACE_PTR ("NsDeleteChildren", ParentNode); if (!ParentNode) { return_VOID; } /* If no children, all done! */ ChildNode = ParentNode->Child; if (!ChildNode) { return_VOID; } /* * Deallocate all children at this level */ do { /* Get the things we need */ NextNode = ChildNode->Peer; Flags = ChildNode->Flags; /* Grandchildren should have all been deleted already */ if (ChildNode->Child) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Found a grandchild! P=%p C=%p\n", ParentNode, ChildNode)); } /* Now we can free this child object */ ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].TotalFreed++); ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Object %p, Remaining %X\n", ChildNode, AcpiGbl_CurrentNodeCount)); /* * Detach an object if there is one, then free the child node */ AcpiNsDetachObject (ChildNode); ACPI_MEM_FREE (ChildNode); /* And move on to the next child in the list */ ChildNode = NextNode; } while (!(Flags & ANOBJ_END_OF_PEER_LIST)); /* Clear the parent's child pointer */ ParentNode->Child = NULL; return_VOID; } /******************************************************************************* * * FUNCTION: AcpiNsDeleteNamespaceSubtree * * PARAMETERS: ParentNode - Root of the subtree to be deleted * * RETURN: None. * * DESCRIPTION: Delete a subtree of the namespace. This includes all objects * stored within the subtree. * ******************************************************************************/ void AcpiNsDeleteNamespaceSubtree ( ACPI_NAMESPACE_NODE *ParentNode) { ACPI_NAMESPACE_NODE *ChildNode = NULL; UINT32 Level = 1; ACPI_FUNCTION_TRACE ("NsDeleteNamespaceSubtree"); if (!ParentNode) { return_VOID; } /* * Traverse the tree of objects until we bubble back up * to where we started. */ while (Level > 0) { /* Get the next node in this scope (NULL if none) */ ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode, ChildNode); if (ChildNode) { /* Found a child node - detach any attached object */ AcpiNsDetachObject (ChildNode); /* Check if this node has any children */ if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, 0)) { /* * There is at least one child of this node, * visit the node */ Level++; ParentNode = ChildNode; ChildNode = 0; } } else { /* * No more children of this parent node. * Move up to the grandparent. */ Level--; /* * Now delete all of the children of this parent * all at the same time. */ AcpiNsDeleteChildren (ParentNode); /* New "last child" is this parent node */ ChildNode = ParentNode; /* Move up the tree to the grandparent */ ParentNode = AcpiNsGetParentNode (ParentNode); } } return_VOID; } /******************************************************************************* * * FUNCTION: AcpiNsRemoveReference * * PARAMETERS: Node - Named node whose reference count is to be * decremented * * RETURN: None. * * DESCRIPTION: Remove a Node reference. Decrements the reference count * of all parent Nodes up to the root. Any node along * the way that reaches zero references is freed. * ******************************************************************************/ static void AcpiNsRemoveReference ( ACPI_NAMESPACE_NODE *Node) { ACPI_NAMESPACE_NODE *ParentNode; ACPI_NAMESPACE_NODE *ThisNode; ACPI_FUNCTION_ENTRY (); /* * Decrement the reference count(s) of this node and all * nodes up to the root, Delete anything with zero remaining references. */ ThisNode = Node; while (ThisNode) { /* Prepare to move up to parent */ ParentNode = AcpiNsGetParentNode (ThisNode); /* Decrement the reference count on this node */ ThisNode->ReferenceCount--; /* Delete the node if no more references */ if (!ThisNode->ReferenceCount) { /* Delete all children and delete the node */ AcpiNsDeleteChildren (ThisNode); AcpiNsDeleteNode (ThisNode); } ThisNode = ParentNode; } } /******************************************************************************* * * FUNCTION: AcpiNsDeleteNamespaceByOwner * * PARAMETERS: OwnerId - All nodes with this owner will be deleted * * RETURN: Status * * DESCRIPTION: Delete entries within the namespace that are owned by a * specific ID. Used to delete entire ACPI tables. All * reference counts are updated. * ******************************************************************************/ void AcpiNsDeleteNamespaceByOwner ( UINT16 OwnerId) { ACPI_NAMESPACE_NODE *ChildNode; ACPI_NAMESPACE_NODE *DeletionNode; UINT32 Level; ACPI_NAMESPACE_NODE *ParentNode; ACPI_FUNCTION_TRACE_U32 ("NsDeleteNamespaceByOwner", OwnerId); ParentNode = AcpiGbl_RootNode; ChildNode = NULL; DeletionNode = NULL; Level = 1; /* * Traverse the tree of nodes until we bubble back up * to where we started. */ while (Level > 0) { /* * Get the next child of this parent node. When ChildNode is NULL, * the first child of the parent is returned */ ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode, ChildNode); if (DeletionNode) { AcpiNsRemoveReference (DeletionNode); DeletionNode = NULL; } if (ChildNode) { if (ChildNode->OwnerId == OwnerId) { /* Found a matching child node - detach any attached object */ AcpiNsDetachObject (ChildNode); } /* Check if this node has any children */ if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, NULL)) { /* * There is at least one child of this node, * visit the node */ Level++; ParentNode = ChildNode; ChildNode = NULL; } else if (ChildNode->OwnerId == OwnerId) { DeletionNode = ChildNode; } } else { /* * No more children of this parent node. * Move up to the grandparent. */ Level--; if (Level != 0) { if (ParentNode->OwnerId == OwnerId) { DeletionNode = ParentNode; } } /* New "last child" is this parent node */ ChildNode = ParentNode; /* Move up the tree to the grandparent */ ParentNode = AcpiNsGetParentNode (ParentNode); } } return_VOID; } diff --git a/sys/contrib/dev/acpica/nsdump.c b/sys/contrib/dev/acpica/nsdump.c index 99e52c324f10..88b135c1ec79 100644 --- a/sys/contrib/dev/acpica/nsdump.c +++ b/sys/contrib/dev/acpica/nsdump.c @@ -1,843 +1,786 @@ /****************************************************************************** * * Module Name: nsdump - table dumping routines for debug - * $Revision: 141 $ + * $Revision: 146 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __NSDUMP_C__ #include "acpi.h" #include "acnamesp.h" #include "acparser.h" #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsdump") #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) /******************************************************************************* * * FUNCTION: AcpiNsPrintPathname * * PARAMETERS: NumSegment - Number of ACPI name segments * Pathname - The compressed (internal) path * * DESCRIPTION: Print an object's full namespace pathname * ******************************************************************************/ void AcpiNsPrintPathname ( UINT32 NumSegments, char *Pathname) { ACPI_FUNCTION_NAME ("NsPrintPathname"); if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE)) { return; } /* Print the entire name */ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[")); while (NumSegments) { AcpiOsPrintf ("%4.4s", Pathname); Pathname += ACPI_NAME_SIZE; NumSegments--; if (NumSegments) { AcpiOsPrintf ("."); } } AcpiOsPrintf ("]\n"); } /******************************************************************************* * * FUNCTION: AcpiNsDumpPathname * * PARAMETERS: Handle - Object * Msg - Prefix message * Level - Desired debug level * Component - Caller's component ID * * DESCRIPTION: Print an object's full namespace pathname * Manages allocation/freeing of a pathname buffer * ******************************************************************************/ ACPI_STATUS AcpiNsDumpPathname ( ACPI_HANDLE Handle, NATIVE_CHAR *Msg, UINT32 Level, UINT32 Component) { ACPI_BUFFER Buffer; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("NsDumpPathname"); /* Do this only if the requested debug level and component are enabled */ if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component)) { return_ACPI_STATUS (AE_OK); } /* Convert handle to a full pathname and print it (with supplied message) */ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (Handle, &Buffer); if (ACPI_SUCCESS (Status)) { AcpiOsPrintf ("%s %s (Node %p)\n", Msg, (char *) Buffer.Pointer, Handle); ACPI_MEM_FREE (Buffer.Pointer); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiNsDumpOneObject * * PARAMETERS: Handle - Node to be dumped * Level - Nesting level of the handle * Context - Passed into WalkNamespace * * DESCRIPTION: Dump a single Node * This procedure is a UserFunction called by AcpiNsWalkNamespace. * ******************************************************************************/ ACPI_STATUS AcpiNsDumpOneObject ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue) { ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; ACPI_NAMESPACE_NODE *ThisNode; ACPI_OPERAND_OBJECT *ObjDesc = NULL; ACPI_OBJECT_TYPE ObjType; ACPI_OBJECT_TYPE Type; UINT32 BytesToDump; - UINT32 DownstreamSiblingMask = 0; - UINT32 LevelTmp; - UINT32 WhichBit; - UINT32 i; UINT32 DbgLevel; + UINT32 i; ACPI_FUNCTION_NAME ("NsDumpOneObject"); - ThisNode = AcpiNsMapHandleToNode (ObjHandle); - - LevelTmp = Level; - Type = ThisNode->Type; - WhichBit = 1; - + /* Is output enabled? */ if (!(AcpiDbgLevel & Info->DebugLevel)) { return (AE_OK); } if (!ObjHandle) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n")); return (AE_OK); } + ThisNode = AcpiNsMapHandleToNode (ObjHandle); + Type = ThisNode->Type; + /* Check if the owner matches */ if ((Info->OwnerId != ACPI_UINT32_MAX) && (Info->OwnerId != ThisNode->OwnerId)) { return (AE_OK); } /* Indent the object according to the level */ - while (LevelTmp--) - { - /* Print appropriate characters to form tree structure */ - - if (LevelTmp) - { - if (DownstreamSiblingMask & WhichBit) - { - AcpiOsPrintf ("|"); - } - else - { - AcpiOsPrintf (" "); - } - - WhichBit <<= 1; - } - else - { - if (AcpiNsExistDownstreamSibling (ThisNode + 1)) - { - DownstreamSiblingMask |= ((UINT32) 1 << (Level - 1)); - AcpiOsPrintf ("+"); - } - else - { - DownstreamSiblingMask &= ACPI_UINT32_MAX ^ ((UINT32) 1 << (Level - 1)); - AcpiOsPrintf ("+"); - } - - if (ThisNode->Child == NULL) - { - AcpiOsPrintf ("-"); - } - else if (AcpiNsExistDownstreamSibling (ThisNode->Child)) - { - AcpiOsPrintf ("+"); - } - else - { - AcpiOsPrintf ("-"); - } - } - } + AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " "); - /* Check the integrity of our data */ + /* Check the node type and name */ - if (Type > INTERNAL_TYPE_MAX) + if (Type > ACPI_TYPE_LOCAL_MAX) { - Type = INTERNAL_TYPE_DEF_ANY; /* prints as *ERROR* */ + 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)); } /* * Now we can print out the pertinent information */ - AcpiOsPrintf (" %4.4s %-12s %p", + AcpiOsPrintf ("%4.4s %-12s %p ", ThisNode->Name.Ascii, AcpiUtGetTypeName (Type), ThisNode); DbgLevel = AcpiDbgLevel; AcpiDbgLevel = 0; ObjDesc = AcpiNsGetAttachedObject (ThisNode); AcpiDbgLevel = DbgLevel; switch (Info->DisplayType) { case ACPI_DISPLAY_SUMMARY: if (!ObjDesc) { /* No attached object, we are done */ AcpiOsPrintf ("\n"); return (AE_OK); } switch (Type) { case ACPI_TYPE_PROCESSOR: - AcpiOsPrintf (" ID %X Len %.4X Addr %p\n", + AcpiOsPrintf ("ID %X Len %.4X Addr %p\n", ObjDesc->Processor.ProcId, ObjDesc->Processor.Length, (char *) ObjDesc->Processor.Address); break; case ACPI_TYPE_DEVICE: - AcpiOsPrintf (" Notification object: %p", ObjDesc); + AcpiOsPrintf ("Notify object: %p", ObjDesc); break; case ACPI_TYPE_METHOD: - AcpiOsPrintf (" Args %X Len %.4X Aml %p\n", + AcpiOsPrintf ("Args %X Len %.4X Aml %p\n", (UINT32) ObjDesc->Method.ParamCount, ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart); break; case ACPI_TYPE_INTEGER: - AcpiOsPrintf (" = %8.8X%8.8X\n", + AcpiOsPrintf ("= %8.8X%8.8X\n", ACPI_HIDWORD (ObjDesc->Integer.Value), ACPI_LODWORD (ObjDesc->Integer.Value)); break; case ACPI_TYPE_PACKAGE: if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) { - AcpiOsPrintf (" Elements %.2X\n", + AcpiOsPrintf ("Elements %.2X\n", ObjDesc->Package.Count); } else { - AcpiOsPrintf (" [Length not yet evaluated]\n"); + AcpiOsPrintf ("[Length not yet evaluated]\n"); } break; case ACPI_TYPE_BUFFER: if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) { - AcpiOsPrintf (" Len %.2X", + AcpiOsPrintf ("Len %.2X", ObjDesc->Buffer.Length); /* Dump some of the buffer */ if (ObjDesc->Buffer.Length > 0) { AcpiOsPrintf (" ="); for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++) { AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]); } } AcpiOsPrintf ("\n"); } else { - AcpiOsPrintf (" [Length not yet evaluated]\n"); + AcpiOsPrintf ("[Length not yet evaluated]\n"); } break; case ACPI_TYPE_STRING: - AcpiOsPrintf (" Len %.2X", ObjDesc->String.Length); - - if (ObjDesc->String.Length > 0) - { - AcpiOsPrintf (" = \"%.32s\"", ObjDesc->String.Pointer); - if (ObjDesc->String.Length > 32) - { - AcpiOsPrintf ("..."); - } - } + AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length); + AcpiUtPrintString (ObjDesc->String.Pointer, 32); AcpiOsPrintf ("\n"); break; case ACPI_TYPE_REGION: - AcpiOsPrintf (" [%s]", AcpiUtGetRegionName (ObjDesc->Region.SpaceId)); + AcpiOsPrintf ("[%s]", AcpiUtGetRegionName (ObjDesc->Region.SpaceId)); if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) { AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n", ACPI_HIDWORD (ObjDesc->Region.Address), ACPI_LODWORD (ObjDesc->Region.Address), ObjDesc->Region.Length); } else { AcpiOsPrintf (" [Address/Length not yet evaluated]\n"); } break; - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: - AcpiOsPrintf (" [%s]\n", + AcpiOsPrintf ("[%s]\n", AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode)); break; case ACPI_TYPE_BUFFER_FIELD: if (ObjDesc->BufferField.BufferObj && ObjDesc->BufferField.BufferObj->Buffer.Node) { - AcpiOsPrintf (" Buf [%4.4s]", + AcpiOsPrintf ("Buf [%4.4s]", ObjDesc->BufferField.BufferObj->Buffer.Node->Name.Ascii); } break; - case INTERNAL_TYPE_REGION_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: - AcpiOsPrintf (" Rgn [%4.4s]", + AcpiOsPrintf ("Rgn [%4.4s]", ObjDesc->CommonField.RegionObj->Region.Node->Name.Ascii); break; - case INTERNAL_TYPE_BANK_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: - AcpiOsPrintf (" Rgn [%4.4s] Bnk [%4.4s]", + AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]", ObjDesc->CommonField.RegionObj->Region.Node->Name.Ascii, ObjDesc->BankField.BankObj->CommonField.Node->Name.Ascii); break; - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: - AcpiOsPrintf (" Idx [%4.4s] Dat [%4.4s]", + AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]", ObjDesc->IndexField.IndexObj->CommonField.Node->Name.Ascii, ObjDesc->IndexField.DataObj->CommonField.Node->Name.Ascii); break; - case INTERNAL_TYPE_ALIAS: + case ACPI_TYPE_LOCAL_ALIAS: - AcpiOsPrintf (" Target %4.4s (%p)\n", ((ACPI_NAMESPACE_NODE *) ObjDesc)->Name.Ascii, ObjDesc); + AcpiOsPrintf ("Target %4.4s (%p)\n", ((ACPI_NAMESPACE_NODE *) ObjDesc)->Name.Ascii, ObjDesc); break; default: - AcpiOsPrintf (" Object %p\n", ObjDesc); + AcpiOsPrintf ("Object %p\n", ObjDesc); break; } /* Common field handling */ switch (Type) { case ACPI_TYPE_BUFFER_FIELD: - case INTERNAL_TYPE_REGION_FIELD: - case INTERNAL_TYPE_BANK_FIELD: - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + AcpiOsPrintf (" Off %.2X Len %.2X Acc %.2hd\n", (ObjDesc->CommonField.BaseByteOffset * 8) + ObjDesc->CommonField.StartFieldBitOffset, ObjDesc->CommonField.BitLength, ObjDesc->CommonField.AccessByteWidth); break; default: break; } break; case ACPI_DISPLAY_OBJECTS: - AcpiOsPrintf ("%p O:%p", - ThisNode, ObjDesc); - + AcpiOsPrintf ("O:%p", ObjDesc); if (!ObjDesc) { /* No attached object, we are done */ AcpiOsPrintf ("\n"); return (AE_OK); } AcpiOsPrintf ("(R%d)", ObjDesc->Common.ReferenceCount); switch (Type) { case ACPI_TYPE_METHOD: /* Name is a Method and its AML offset/length are set */ AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength); break; case ACPI_TYPE_INTEGER: AcpiOsPrintf (" N:%X%X\n", ACPI_HIDWORD(ObjDesc->Integer.Value), ACPI_LODWORD(ObjDesc->Integer.Value)); break; case ACPI_TYPE_STRING: AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer, ObjDesc->String.Length); break; case ACPI_TYPE_BUFFER: AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); break; default: AcpiOsPrintf ("\n"); break; } break; default: AcpiOsPrintf ("\n"); break; } /* If debug turned off, done */ if (!(AcpiDbgLevel & ACPI_LV_VALUES)) { return (AE_OK); } /* If there is an attached object, display it */ DbgLevel = AcpiDbgLevel; AcpiDbgLevel = 0; ObjDesc = AcpiNsGetAttachedObject (ThisNode); AcpiDbgLevel = DbgLevel; /* Dump attached objects */ while (ObjDesc) { - ObjType = INTERNAL_TYPE_INVALID; + ObjType = ACPI_TYPE_INVALID; AcpiOsPrintf (" Attached Object %p: ", ObjDesc); /* Decode the type of attached object and dump the contents */ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) { case ACPI_DESC_TYPE_NAMED: AcpiOsPrintf ("(Ptr to Node)\n"); BytesToDump = sizeof (ACPI_NAMESPACE_NODE); break; case ACPI_DESC_TYPE_OPERAND: ObjType = ACPI_GET_OBJECT_TYPE (ObjDesc); - if (ObjType > INTERNAL_TYPE_MAX) + if (ObjType > ACPI_TYPE_LOCAL_MAX) { AcpiOsPrintf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", ObjType); BytesToDump = 32; } else { AcpiOsPrintf ("(Ptr to ACPI Object type %s, %X)\n", AcpiUtGetTypeName (ObjType), ObjType); BytesToDump = sizeof (ACPI_OPERAND_OBJECT); } break; default: AcpiOsPrintf ("(String or Buffer ptr - not an object descriptor)\n"); 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) { goto Cleanup; } /* * Valid object, get the pointer to next level, if any */ switch (ObjType) { case ACPI_TYPE_STRING: ObjDesc = (void *) ObjDesc->String.Pointer; break; case ACPI_TYPE_BUFFER: ObjDesc = (void *) ObjDesc->Buffer.Pointer; break; case ACPI_TYPE_BUFFER_FIELD: ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj; break; case ACPI_TYPE_PACKAGE: ObjDesc = (void *) ObjDesc->Package.Elements; break; case ACPI_TYPE_METHOD: ObjDesc = (void *) ObjDesc->Method.AmlStart; break; - case INTERNAL_TYPE_REGION_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: ObjDesc = (void *) ObjDesc->Field.RegionObj; break; - case INTERNAL_TYPE_BANK_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: ObjDesc = (void *) ObjDesc->BankField.RegionObj; break; - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: ObjDesc = (void *) ObjDesc->IndexField.IndexObj; break; default: goto Cleanup; } - ObjType = INTERNAL_TYPE_INVALID; /* Terminate loop after next pass */ + ObjType = ACPI_TYPE_INVALID; /* Terminate loop after next pass */ } Cleanup: AcpiOsPrintf ("\n"); return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiNsDumpObjects * * PARAMETERS: Type - Object type to be dumped * 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 * * DESCRIPTION: Dump typed objects within the loaded namespace. * Uses AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject. * ******************************************************************************/ void AcpiNsDumpObjects ( ACPI_OBJECT_TYPE Type, UINT8 DisplayType, UINT32 MaxDepth, UINT32 OwnerId, ACPI_HANDLE StartHandle) { ACPI_WALK_INFO Info; ACPI_FUNCTION_ENTRY (); Info.DebugLevel = ACPI_LV_TABLES; Info.OwnerId = OwnerId; Info.DisplayType = DisplayType; (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, ACPI_NS_WALK_NO_UNLOCK, AcpiNsDumpOneObject, (void *) &Info, NULL); } /******************************************************************************* * * FUNCTION: AcpiNsDumpTables * * PARAMETERS: SearchBase - Root of subtree to be dumped, or * NS_ALL to dump the entire namespace * MaxDepth - Maximum depth of dump. Use INT_MAX * for an effectively unlimited depth. * * DESCRIPTION: Dump the name space, or a portion of it. * ******************************************************************************/ void AcpiNsDumpTables ( ACPI_HANDLE SearchBase, UINT32 MaxDepth) { ACPI_HANDLE SearchHandle = SearchBase; ACPI_FUNCTION_TRACE ("NsDumpTables"); if (!AcpiGbl_RootNode) { /* * If the name space has not been initialized, * there is nothing to dump. */ ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n")); return_VOID; } if (ACPI_NS_ALL == SearchBase) { /* entire namespace */ SearchHandle = AcpiGbl_RootNode; ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n")); } AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth, ACPI_UINT32_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 diff --git a/sys/contrib/dev/acpica/nseval.c b/sys/contrib/dev/acpica/nseval.c index 043da2155f1d..be29617932b2 100644 --- a/sys/contrib/dev/acpica/nseval.c +++ b/sys/contrib/dev/acpica/nseval.c @@ -1,614 +1,614 @@ /******************************************************************************* * * Module Name: nseval - Object evaluation interfaces -- includes control * method lookup and execution. - * $Revision: 118 $ + * $Revision: 119 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __NSEVAL_C__ #include "acpi.h" #include "acparser.h" #include "acinterp.h" #include "acnamesp.h" #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nseval") /******************************************************************************* * * FUNCTION: AcpiNsEvaluateRelative * * PARAMETERS: Handle - The relative containing object * Pathname - Name of method to execute, If NULL, the * handle is the object to execute * Params - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. * ReturnObject - Where to put method's return value (if * any). If NULL, no value is returned. * * RETURN: Status * * DESCRIPTION: Find and execute the requested method using the handle as a * scope * * MUTEX: Locks Namespace * ******************************************************************************/ ACPI_STATUS AcpiNsEvaluateRelative ( ACPI_NAMESPACE_NODE *Handle, NATIVE_CHAR *Pathname, ACPI_OPERAND_OBJECT **Params, ACPI_OPERAND_OBJECT **ReturnObject) { ACPI_NAMESPACE_NODE *PrefixNode; ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node = NULL; NATIVE_CHAR *InternalPath = NULL; ACPI_GENERIC_STATE ScopeInfo; ACPI_FUNCTION_TRACE ("NsEvaluateRelative"); /* * Must have a valid object handle */ if (!Handle) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Build an internal name string for the method */ Status = AcpiNsInternalizeName (Pathname, &InternalPath); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Get the prefix handle and Node */ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } PrefixNode = AcpiNsMapHandleToNode (Handle); if (!PrefixNode) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); Status = AE_BAD_PARAMETER; goto Cleanup; } /* Lookup the name in the namespace */ ScopeInfo.Scope.Node = PrefixNode; Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, &Node); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object [%s] not found [%s]\n", Pathname, AcpiFormatException (Status))); goto Cleanup; } /* * Now that we have a handle to the object, we can attempt * to evaluate it. */ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Pathname, Node, AcpiNsGetAttachedObject (Node))); Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", Pathname)); Cleanup: ACPI_MEM_FREE (InternalPath); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiNsEvaluateByName * * PARAMETERS: Pathname - Fully qualified pathname to the object * 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 passing the given * parameters * * MUTEX: Locks Namespace * ******************************************************************************/ ACPI_STATUS AcpiNsEvaluateByName ( NATIVE_CHAR *Pathname, ACPI_OPERAND_OBJECT **Params, ACPI_OPERAND_OBJECT **ReturnObject) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node = NULL; NATIVE_CHAR *InternalPath = NULL; ACPI_FUNCTION_TRACE ("NsEvaluateByName"); /* Build an internal name string for the method */ Status = AcpiNsInternalizeName (Pathname, &InternalPath); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Lookup the name in the namespace */ Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, ACPI_NS_NO_UPSEARCH, NULL, &Node); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Object at [%s] was not found, status=%.4X\n", Pathname, Status)); goto Cleanup; } /* * Now that we have a handle to the object, we can attempt * to evaluate it. */ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Pathname, Node, AcpiNsGetAttachedObject (Node))); Status = AcpiNsEvaluateByHandle (Node, Params, ReturnObject); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "*** Completed eval of object %s ***\n", Pathname)); Cleanup: /* Cleanup */ if (InternalPath) { ACPI_MEM_FREE (InternalPath); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiNsEvaluateByHandle * * PARAMETERS: Handle - Method Node to execute * Params - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. * ReturnObject - Where to put method's return value (if * any). If NULL, no value is returned. * * RETURN: Status * * DESCRIPTION: Execute the requested method passing the given parameters * * MUTEX: Locks Namespace * ******************************************************************************/ ACPI_STATUS AcpiNsEvaluateByHandle ( ACPI_NAMESPACE_NODE *Handle, ACPI_OPERAND_OBJECT **Params, ACPI_OPERAND_OBJECT **ReturnObject) { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; ACPI_OPERAND_OBJECT *LocalReturnObject; ACPI_FUNCTION_TRACE ("NsEvaluateByHandle"); /* Check if namespace has been initialized */ if (!AcpiGbl_RootNode) { return_ACPI_STATUS (AE_NO_NAMESPACE); } /* Parameter Validation */ if (!Handle) { return_ACPI_STATUS (AE_BAD_PARAMETER); } if (ReturnObject) { /* Initialize the return value to an invalid object */ *ReturnObject = NULL; } /* Get the prefix handle and Node */ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Node = AcpiNsMapHandleToNode (Handle); if (!Node) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (AE_BAD_PARAMETER); } /* * Two major cases here: * 1) The object is an actual control method -- execute it. * 2) The object is not a method -- just return it's current * value * * In both cases, the namespace is unlocked by the * AcpiNs* procedure */ if (AcpiNsGetType (Node) == ACPI_TYPE_METHOD) { /* * Case 1) We have an actual control method to execute */ Status = AcpiNsExecuteControlMethod (Node, Params, &LocalReturnObject); } else { /* * Case 2) Object is NOT a method, just return its * current value */ Status = AcpiNsGetObjectValue (Node, &LocalReturnObject); } /* * Check if there is a return value on the stack that must * be dealt with */ if (Status == AE_CTRL_RETURN_VALUE) { /* * If the Method returned a value and the caller * provided a place to store a returned value, Copy * the returned value to the object descriptor provided * by the caller. */ if (ReturnObject) { /* * Valid return object, copy the pointer to * the returned object */ *ReturnObject = LocalReturnObject; } /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ Status = AE_OK; } /* * Namespace was unlocked by the handling AcpiNs* function, * so we just return */ return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiNsExecuteControlMethod * * PARAMETERS: MethodNode - The method to execute * Params - List of parameters to pass to the method, * terminated by NULL. Params itself may be * NULL if no parameters are being passed. * ReturnObjDesc - List of result objects to be returned * from the method. * * RETURN: Status * * DESCRIPTION: Execute the requested method passing the given parameters * * MUTEX: Assumes namespace is locked * ******************************************************************************/ ACPI_STATUS AcpiNsExecuteControlMethod ( ACPI_NAMESPACE_NODE *MethodNode, ACPI_OPERAND_OBJECT **Params, ACPI_OPERAND_OBJECT **ReturnObjDesc) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_TRACE ("NsExecuteControlMethod"); /* Verify that there is a method associated with this object */ ObjDesc = AcpiNsGetAttachedObject (MethodNode); if (!ObjDesc) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No attached method object\n")); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (AE_NULL_OBJECT); } - ACPI_DUMP_PATHNAME (MethodNode, "NsExecuteControlMethod: Executing", + ACPI_DUMP_PATHNAME (MethodNode, "Execute Method:", 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)); /* * Unlock the namespace before execution. This allows namespace access * via the external Acpi* interfaces while a method is being executed. * However, any namespace deletion must acquire both the namespace and * interpreter locks to ensure that no thread is using the portion of the * namespace that is being deleted. */ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Execute the method via the interpreter. The interpreter is locked * here before calling into the AML parser */ Status = AcpiExEnterInterpreter (); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiPsxExecute (MethodNode, Params, ReturnObjDesc); AcpiExExitInterpreter (); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiNsGetObjectValue * * PARAMETERS: Node - The object * ReturnObjDesc - Where the objects value is returned * * RETURN: Status * * DESCRIPTION: Return the current value of the object * * MUTEX: Assumes namespace is locked, leaves namespace unlocked * ******************************************************************************/ ACPI_STATUS AcpiNsGetObjectValue ( ACPI_NAMESPACE_NODE *Node, ACPI_OPERAND_OBJECT **ReturnObjDesc) { ACPI_STATUS Status = AE_OK; ACPI_NAMESPACE_NODE *ResolvedNode = Node; ACPI_FUNCTION_TRACE ("NsGetObjectValue"); /* * Objects require additional resolution steps (e.g., the * Node may be a field that must be read, etc.) -- we can't just grab * the object out of the node. */ /* * Use ResolveNodeToValue() to get the associated value. This call * always deletes ObjDesc (allocated above). * * NOTE: we can get away with passing in NULL for a walk state * because ObjDesc is guaranteed to not be a reference to either * a method local or a method argument (because this interface can only be * called from the AcpiEvaluate external interface, never called from * a running control method.) * * Even though we do not directly invoke the interpreter * for this, we must enter it because we could access an opregion. * The opregion access code assumes that the interpreter * is locked. * * We must release the namespace lock before entering the * intepreter. */ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiExEnterInterpreter (); if (ACPI_SUCCESS (Status)) { Status = AcpiExResolveNodeToValue (&ResolvedNode, NULL); /* * If AcpiExResolveNodeToValue() succeeded, the return value was * placed in ResolvedNode. */ AcpiExExitInterpreter (); if (ACPI_SUCCESS (Status)) { Status = AE_CTRL_RETURN_VALUE; *ReturnObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ResolvedNode); ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", *ReturnObjDesc, AcpiUtGetObjectTypeName (*ReturnObjDesc))); } } /* Namespace is unlocked */ return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/nsinit.c b/sys/contrib/dev/acpica/nsinit.c index d1569ceb0b1b..8babb3d490ef 100644 --- a/sys/contrib/dev/acpica/nsinit.c +++ b/sys/contrib/dev/acpica/nsinit.c @@ -1,510 +1,510 @@ /****************************************************************************** * * Module Name: nsinit - namespace initialization - * $Revision: 49 $ + * $Revision: 50 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __NSXFINIT_C__ #include "acpi.h" #include "acnamesp.h" #include "acdispat.h" #include "acinterp.h" #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsinit") /******************************************************************************* * * FUNCTION: AcpiNsInitializeObjects * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Walk the entire namespace and perform any necessary * initialization on the objects found therein * ******************************************************************************/ ACPI_STATUS AcpiNsInitializeObjects ( void) { ACPI_STATUS Status; ACPI_INIT_WALK_INFO Info; ACPI_FUNCTION_TRACE ("NsInitializeObjects"); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "**** Starting initialization of namespace objects ****\n")); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "Completing Region/Field/Buffer/Package initialization:")); /* Set all init info to zero */ ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); /* Walk entire namespace from the supplied root */ Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, AcpiNsInitOneObject, &Info, NULL); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "WalkNamespace failed! %s\n", AcpiFormatException (Status))); } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd Buffers %hd/%hd Packages (%hd nodes)\n", Info.OpRegionInit, Info.OpRegionCount, Info.FieldInit, Info.FieldCount, Info.BufferInit, Info.BufferCount, Info.PackageInit, Info.PackageCount, Info.ObjectCount)); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "%hd Control Methods found\n", Info.MethodCount)); ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "%hd Op Regions found\n", Info.OpRegionCount)); return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiNsInitializeDevices * * PARAMETERS: None * * RETURN: ACPI_STATUS * * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices. * This means running _INI on all present devices. * * Note: We install PCI config space handler on region access, * not here. * ******************************************************************************/ ACPI_STATUS AcpiNsInitializeDevices ( void) { ACPI_STATUS Status; ACPI_DEVICE_WALK_INFO Info; ACPI_FUNCTION_TRACE ("NsInitializeDevices"); /* Init counters */ Info.DeviceCount = 0; Info.Num_STA = 0; Info.Num_INI = 0; ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "Executing all Device _STA and_INI methods:")); /* Walk namespace for all objects of type Device */ Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, &Info, NULL); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "WalkNamespace failed! %s\n", AcpiFormatException (Status))); } ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, "\n%hd Devices found containing: %hd _STA, %hd _INI methods\n", Info.DeviceCount, Info.Num_STA, Info.Num_INI)); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiNsInitOneObject * * PARAMETERS: ObjHandle - Node * Level - Current nesting level * Context - Points to a init info struct * ReturnValue - Not used * * RETURN: Status * * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object * within the namespace. * * Currently, the only objects that require initialization are: * 1) Methods * 2) Op Regions * ******************************************************************************/ ACPI_STATUS AcpiNsInitOneObject ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue) { ACPI_OBJECT_TYPE Type; ACPI_STATUS Status; ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_NAME ("NsInitOneObject"); Info->ObjectCount++; /* And even then, we are only interested in a few object types */ Type = AcpiNsGetType (ObjHandle); ObjDesc = AcpiNsGetAttachedObject (Node); if (!ObjDesc) { return (AE_OK); } /* Increment counters for object types we are looking for */ switch (Type) { case ACPI_TYPE_REGION: Info->OpRegionCount++; break; case ACPI_TYPE_BUFFER_FIELD: Info->FieldCount++; break; case ACPI_TYPE_BUFFER: Info->BufferCount++; break; case ACPI_TYPE_PACKAGE: Info->PackageCount++; break; default: /* No init required, just exit now */ return (AE_OK); } /* * If the object is already initialized, nothing else to do */ if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) { return (AE_OK); } /* * Must lock the interpreter before executing AML code */ Status = AcpiExEnterInterpreter (); if (ACPI_FAILURE (Status)) { return (Status); } /* * Each of these types can contain executable AML code within * the declaration. */ switch (Type) { case ACPI_TYPE_REGION: Info->OpRegionInit++; Status = AcpiDsGetRegionArguments (ObjDesc); break; case ACPI_TYPE_BUFFER_FIELD: Info->FieldInit++; Status = AcpiDsGetBufferFieldArguments (ObjDesc); break; case ACPI_TYPE_BUFFER: Info->BufferInit++; Status = AcpiDsGetBufferArguments (ObjDesc); break; case ACPI_TYPE_PACKAGE: Info->PackageInit++; Status = AcpiDsGetPackageArguments (ObjDesc); break; default: /* No other types can get here */ break; } if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, "\n")); ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not execute arguments for [%4.4s] (%s), %s\n", Node->Name.Ascii, AcpiUtGetTypeName (Type), AcpiFormatException (Status))); } if (!(AcpiDbgLevel & ACPI_LV_INIT)) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, ".")); } /* * We ignore errors from above, and always return OK, since * we don't want to abort the walk on any single error. */ AcpiExExitInterpreter (); return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiNsInitOneDevice * * PARAMETERS: ACPI_WALK_CALLBACK * * RETURN: ACPI_STATUS * * DESCRIPTION: This is called once per device soon after ACPI is enabled * to initialize each device. It determines if the device is * present, and if so, calls _INI. * ******************************************************************************/ ACPI_STATUS AcpiNsInitOneDevice ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; UINT32 Flags; ACPI_DEVICE_WALK_INFO *Info = (ACPI_DEVICE_WALK_INFO *) Context; ACPI_FUNCTION_TRACE ("NsInitOneDevice"); - if (!(AcpiDbgLevel & ACPI_LV_INIT)) + if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) && (!(AcpiDbgLevel & ACPI_LV_INFO))) { ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OK, ".")); } Info->DeviceCount++; Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Node = AcpiNsMapHandleToNode (ObjHandle); if (!Node) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Run _STA to determine if we can run _INI on the device. */ ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (Node, "_STA [Method]")); Status = AcpiUtExecute_STA (Node, &Flags); if (ACPI_FAILURE (Status)) { /* Ignore error and move on to next device */ return_ACPI_STATUS (AE_OK); } Info->Num_STA++; if (!(Flags & 0x01)) { /* don't look at children of a not present device */ return_ACPI_STATUS(AE_CTRL_DEPTH); } /* * The device is present. Run _INI. */ ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ObjHandle, "_INI [Method]")); Status = AcpiNsEvaluateRelative (ObjHandle, "_INI", NULL, NULL); if (ACPI_FAILURE (Status)) { /* No _INI (AE_NOT_FOUND) means device requires no initialization */ if (Status != AE_NOT_FOUND) { /* Ignore error and move on to next device */ #ifdef ACPI_DEBUG_OUTPUT NATIVE_CHAR *ScopeName = AcpiNsGetExternalPathname (ObjHandle); ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "%s._INI failed: %s\n", ScopeName, AcpiFormatException (Status))); ACPI_MEM_FREE (ScopeName); #endif } Status = AE_OK; } else { /* Count of successful INIs */ Info->Num_INI++; } if (AcpiGbl_InitHandler) { /* External initialization handler is present, call it */ Status = AcpiGbl_InitHandler (ObjHandle, ACPI_INIT_DEVICE_INI); } return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/nsobject.c b/sys/contrib/dev/acpica/nsobject.c index acc5aba5d85b..ec308807db8c 100644 --- a/sys/contrib/dev/acpica/nsobject.c +++ b/sys/contrib/dev/acpica/nsobject.c @@ -1,559 +1,562 @@ /******************************************************************************* * * Module Name: nsobject - Utilities for objects attached to namespace * table entries - * $Revision: 83 $ + * $Revision: 85 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __NSOBJECT_C__ #include "acpi.h" #include "acnamesp.h" #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsobject") /******************************************************************************* * * FUNCTION: AcpiNsAttachObject * * PARAMETERS: Node - Parent Node * Object - Object to be attached * Type - Type of object, or ACPI_TYPE_ANY if not * known * * 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. * Note: Future may require that the Node->Flags field be passed * as a parameter. * * MUTEX: Assumes namespace is locked * ******************************************************************************/ ACPI_STATUS AcpiNsAttachObject ( ACPI_NAMESPACE_NODE *Node, ACPI_OPERAND_OBJECT *Object, ACPI_OBJECT_TYPE Type) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *LastObjDesc; ACPI_OBJECT_TYPE ObjectType = ACPI_TYPE_ANY; ACPI_FUNCTION_TRACE ("NsAttachObject"); /* * Parameter validation */ if (!Node) { /* Invalid handle */ ACPI_REPORT_ERROR (("NsAttachObject: Null NamedObj handle\n")); return_ACPI_STATUS (AE_BAD_PARAMETER); } if (!Object && (ACPI_TYPE_ANY != Type)) { /* Null object */ ACPI_REPORT_ERROR (("NsAttachObject: Null object, but type not ACPI_TYPE_ANY\n")); return_ACPI_STATUS (AE_BAD_PARAMETER); } if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) { /* Not a name handle */ ACPI_REPORT_ERROR (("NsAttachObject: Invalid handle\n")); return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Check if this object is already attached */ if (Node->Object == Object) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj %p already installed in NameObj %p\n", Object, Node)); return_ACPI_STATUS (AE_OK); } /* If null object, we will just install it */ if (!Object) { ObjDesc = NULL; ObjectType = ACPI_TYPE_ANY; } /* * If the source object is a namespace Node with an attached object, * we will use that (attached) object */ else if ((ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) && ((ACPI_NAMESPACE_NODE *) Object)->Object) { /* * Value passed is a name handle and that name has a * non-null value. Use that name's value and type. */ ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object; ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type; } /* * Otherwise, we will use the parameter object, but we must type * it first */ else { ObjDesc = (ACPI_OPERAND_OBJECT *) Object; - /* If a valid type (non-ANY) was given, just use it */ + /* Use the given type */ - if (ACPI_TYPE_ANY != Type) - { - ObjectType = Type; - } - else - { - ObjectType = INTERNAL_TYPE_DEF_ANY; - } + ObjectType = Type; } ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", ObjDesc, Node, Node->Name.Ascii)); /* Detach an existing attached object if present */ if (Node->Object) { AcpiNsDetachObject (Node); } if (ObjDesc) { /* * Must increment the new value's reference count * (if it is an internal object) */ AcpiUtAddReference (ObjDesc); /* * Handle objects with multiple descriptors - walk * to the end of the descriptor list */ LastObjDesc = ObjDesc; while (LastObjDesc->Common.NextObject) { LastObjDesc = LastObjDesc->Common.NextObject; } /* Install the object at the front of the object list */ LastObjDesc->Common.NextObject = Node->Object; } Node->Type = (UINT8) ObjectType; Node->Object = ObjDesc; return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiNsDetachObject * - * PARAMETERS: Node - An object whose Value will be deleted + * PARAMETERS: Node - An node whose object will be detached * * RETURN: None. * - * DESCRIPTION: Delete the Value associated with a namespace object. If the - * Value is an allocated object, it is freed. Otherwise, the - * field is simply cleared. + * DESCRIPTION: Detach/delete an object associated with a namespace node. + * if the object is an allocated object, it is freed. + * Otherwise, the field is simply cleared. * ******************************************************************************/ void AcpiNsDetachObject ( ACPI_NAMESPACE_NODE *Node) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_FUNCTION_TRACE ("NsDetachObject"); ObjDesc = Node->Object; if (!ObjDesc || - (ACPI_GET_OBJECT_TYPE (ObjDesc) == INTERNAL_TYPE_DATA)) + (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA)) { return_VOID; } /* Clear the entry in all cases */ Node->Object = NULL; if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) { Node->Object = ObjDesc->Common.NextObject; if (Node->Object && - (ACPI_GET_OBJECT_TYPE (Node->Object) != INTERNAL_TYPE_DATA)) + (ACPI_GET_OBJECT_TYPE (Node->Object) != ACPI_TYPE_LOCAL_DATA)) { Node->Object = Node->Object->Common.NextObject; } } /* Reset the node type to untyped */ Node->Type = ACPI_TYPE_ANY; ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n", Node, Node->Name.Ascii, ObjDesc)); /* Remove one reference on the object (and all subobjects) */ AcpiUtRemoveReference (ObjDesc); return_VOID; } /******************************************************************************* * * FUNCTION: AcpiNsGetAttachedObject * * PARAMETERS: Node - Parent Node to be examined * * RETURN: Current value of the object field from the Node whose * handle is passed * + * DESCRIPTION: Obtain the object attached to a namespace node. + * ******************************************************************************/ ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject ( ACPI_NAMESPACE_NODE *Node) { ACPI_FUNCTION_TRACE_PTR ("NsGetAttachedObject", Node); if (!Node) { ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "Null Node ptr\n")); return_PTR (NULL); } if (!Node->Object || ((ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_OPERAND) && (ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_NAMED)) || - (ACPI_GET_OBJECT_TYPE (Node->Object) == INTERNAL_TYPE_DATA)) + (ACPI_GET_OBJECT_TYPE (Node->Object) == ACPI_TYPE_LOCAL_DATA)) { return_PTR (NULL); } return_PTR (Node->Object); } /******************************************************************************* * * FUNCTION: AcpiNsGetSecondaryObject * * PARAMETERS: Node - Parent Node to be examined * * RETURN: Current value of the object field from the Node whose - * handle is passed + * handle is passed. + * + * DESCRIPTION: Obtain a secondary object associated with a namespace node. * ******************************************************************************/ ACPI_OPERAND_OBJECT * AcpiNsGetSecondaryObject ( ACPI_OPERAND_OBJECT *ObjDesc) { ACPI_FUNCTION_TRACE_PTR ("NsGetSecondaryObject", ObjDesc); - if ((!ObjDesc) || - (ACPI_GET_OBJECT_TYPE (ObjDesc) == INTERNAL_TYPE_DATA) || - (!ObjDesc->Common.NextObject) || - (ACPI_GET_OBJECT_TYPE (ObjDesc->Common.NextObject) == INTERNAL_TYPE_DATA)) + if ((!ObjDesc) || + (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA) || + (!ObjDesc->Common.NextObject) || + (ACPI_GET_OBJECT_TYPE (ObjDesc->Common.NextObject) == ACPI_TYPE_LOCAL_DATA)) { return_PTR (NULL); } return_PTR (ObjDesc->Common.NextObject); } /******************************************************************************* * * FUNCTION: AcpiNsAttachData * - * PARAMETERS: + * PARAMETERS: Node - Namespace node + * Handler - Handler to be associated with the data + * Data - Data to be attached * * RETURN: Status * - * DESCRIPTION: + * DESCRIPTION: Low-level attach data. Create and attach a Data object. * ******************************************************************************/ ACPI_STATUS AcpiNsAttachData ( ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_HANDLER Handler, void *Data) { ACPI_OPERAND_OBJECT *PrevObjDesc; ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *DataDesc; - /* */ + /* We only allow one attachment per handler */ + PrevObjDesc = NULL; ObjDesc = Node->Object; while (ObjDesc) { - if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == INTERNAL_TYPE_DATA) && + if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA) && (ObjDesc->Data.Handler == Handler)) { return (AE_ALREADY_EXISTS); } PrevObjDesc = ObjDesc; ObjDesc = ObjDesc->Common.NextObject; } - /* Create an internal object for the data */ - DataDesc = AcpiUtCreateInternalObject (INTERNAL_TYPE_DATA); + DataDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_DATA); if (!DataDesc) { return (AE_NO_MEMORY); } DataDesc->Data.Handler = Handler; DataDesc->Data.Pointer = Data; - /* Install the data object */ if (PrevObjDesc) { PrevObjDesc->Common.NextObject = DataDesc; } else { Node->Object = DataDesc; } return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiNsDetachData * - * PARAMETERS: + * PARAMETERS: Node - Namespace node + * Handler - Handler associated with the data * * RETURN: Status * - * DESCRIPTION: + * DESCRIPTION: Low-level detach data. Delete the data node, but the caller + * is responsible for the actual data. * ******************************************************************************/ ACPI_STATUS AcpiNsDetachData ( ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_HANDLER Handler) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *PrevObjDesc; PrevObjDesc = NULL; ObjDesc = Node->Object; while (ObjDesc) { - if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == INTERNAL_TYPE_DATA) && + if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA) && (ObjDesc->Data.Handler == Handler)) { if (PrevObjDesc) { PrevObjDesc->Common.NextObject = ObjDesc->Common.NextObject; } else { Node->Object = ObjDesc->Common.NextObject; } AcpiUtRemoveReference (ObjDesc); return (AE_OK); } PrevObjDesc = ObjDesc; ObjDesc = ObjDesc->Common.NextObject; } return (AE_NOT_FOUND); } /******************************************************************************* * * FUNCTION: AcpiNsGetAttachedData * - * PARAMETERS: + * PARAMETERS: Node - Namespace node + * Handler - Handler associated with the data + * Data - Where the data is returned * * RETURN: Status * - * DESCRIPTION: + * DESCRIPTION: Low level interface to obtain data previously associated with + * a namespace node. * ******************************************************************************/ ACPI_STATUS AcpiNsGetAttachedData ( ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_HANDLER Handler, void **Data) { ACPI_OPERAND_OBJECT *ObjDesc; ObjDesc = Node->Object; while (ObjDesc) { - if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == INTERNAL_TYPE_DATA) && + if ((ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_LOCAL_DATA) && (ObjDesc->Data.Handler == Handler)) { *Data = ObjDesc->Data.Pointer; return (AE_OK); } ObjDesc = ObjDesc->Common.NextObject; } return (AE_NOT_FOUND); } diff --git a/sys/contrib/dev/acpica/nssearch.c b/sys/contrib/dev/acpica/nssearch.c index b0add89a27ed..4b7819d0b432 100644 --- a/sys/contrib/dev/acpica/nssearch.c +++ b/sys/contrib/dev/acpica/nssearch.c @@ -1,489 +1,460 @@ /******************************************************************************* * * Module Name: nssearch - Namespace search - * $Revision: 89 $ + * $Revision: 92 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __NSSEARCH_C__ #include "acpi.h" #include "acnamesp.h" #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nssearch") /******************************************************************************* * * FUNCTION: AcpiNsSearchNode * * PARAMETERS: *TargetName - Ascii ACPI name to search for - * *Node - Starting table where search will begin + * *Node - Starting node where search will begin * Type - Object type to match * **ReturnNode - Where the matched Named obj is returned * * RETURN: Status * - * DESCRIPTION: Search a single namespace table. Performs a simple search, - * does not add entries or search parents. + * DESCRIPTION: Search a single level of the namespace. Performs a + * simple search of the specified level, and does not add + * entries or search parents. * * * Named object lists are built (and subsequently dumped) in the * order in which the names are encountered during the namespace load; * * All namespace searching is linear in this implementation, but * could be easily modified to support any improved search * algorithm. However, the linear search was chosen for simplicity * and because the trees are small and the other interpreter * execution overhead is relatively high. * ******************************************************************************/ ACPI_STATUS AcpiNsSearchNode ( UINT32 TargetName, ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, ACPI_NAMESPACE_NODE **ReturnNode) { ACPI_NAMESPACE_NODE *NextNode; ACPI_FUNCTION_TRACE ("NsSearchNode"); #ifdef ACPI_DEBUG_OUTPUT if (ACPI_LV_NAMES & AcpiDbgLevel) { NATIVE_CHAR *ScopeName; ScopeName = AcpiNsGetExternalPathname (Node); if (ScopeName) { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching %s [%p] For %4.4s (type %s)\n", + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching %s [%p] For %4.4s (%s)\n", ScopeName, Node, (char *) &TargetName, AcpiUtGetTypeName (Type))); ACPI_MEM_FREE (ScopeName); } } #endif /* - * Search for name in this table, which is to say that we must search - * for the name among the children of this object + * Search for name at this namespace level, which is to say that we + * must search for the name among the children of this object */ NextNode = Node->Child; while (NextNode) { /* Check for match against the name */ if (NextNode->Name.Integer == TargetName) { /* - * Found matching entry. Capture the type if appropriate, before - * returning the entry. - * - * The DefFieldDefn and BankFieldDefn cases are actually looking up - * the Region in which the field will be defined + * Found matching entry. */ - if ((INTERNAL_TYPE_FIELD_DEFN == Type) || - (INTERNAL_TYPE_BANK_FIELD_DEFN == Type)) - { - Type = ACPI_TYPE_REGION; - } - - /* - * Scope, DefAny, and IndexFieldDefn are bogus "types" which do not - * actually have anything to do with the type of the name being - * looked up. For any other value of Type, if the type stored in - * the entry is Any (i.e. unknown), save the actual type. - */ - if (Type != INTERNAL_TYPE_SCOPE && - Type != INTERNAL_TYPE_DEF_ANY && - Type != INTERNAL_TYPE_INDEX_FIELD_DEFN && - NextNode->Type == ACPI_TYPE_ANY) - { - NextNode->Type = (UINT8) Type; - } - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Name %4.4s Type [%s] found at %p\n", (char *) &TargetName, AcpiUtGetTypeName (NextNode->Type), NextNode)); *ReturnNode = NextNode; return_ACPI_STATUS (AE_OK); } /* * The last entry in the list points back to the parent, * so a flag is used to indicate the end-of-list */ if (NextNode->Flags & ANOBJ_END_OF_PEER_LIST) { /* Searched entire list, we are done */ break; } /* Didn't match name, move on to the next peer object */ NextNode = NextNode->Peer; } - /* Searched entire table, not found */ + /* Searched entire namespace level, not found */ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Name %4.4s Type [%s] not found at %p\n", (char *) &TargetName, AcpiUtGetTypeName (Type), NextNode)); return_ACPI_STATUS (AE_NOT_FOUND); } /******************************************************************************* * * FUNCTION: AcpiNsSearchParentTree * * PARAMETERS: *TargetName - Ascii ACPI name to search for - * *Node - Starting table where search will begin + * *Node - Starting node where search will begin * Type - Object type to match * **ReturnNode - Where the matched Named Obj is returned * * RETURN: Status * * DESCRIPTION: Called when a name has not been found in the current namespace - * table. Before adding it or giving up, ACPI scope rules require + * level. Before adding it or giving up, ACPI scope rules require * searching enclosing scopes in cases identified by AcpiNsLocal(). * * "A name is located by finding the matching name in the current * name space, and then in the parent name space. If the parent * name space does not contain the name, the search continues * recursively until either the name is found or the name space * does not have a parent (the root of the name space). This * indicates that the name is not found" (From ACPI Specification, * section 5.3) * ******************************************************************************/ static ACPI_STATUS AcpiNsSearchParentTree ( UINT32 TargetName, ACPI_NAMESPACE_NODE *Node, ACPI_OBJECT_TYPE Type, ACPI_NAMESPACE_NODE **ReturnNode) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *ParentNode; ACPI_FUNCTION_TRACE ("NsSearchParentTree"); ParentNode = AcpiNsGetParentNode (Node); /* - * If there is no parent (at the root) or type is "local", we won't be - * searching the parent tree. + * If there is no parent (i.e., we are at the root) or + * type is "local", we won't be searching the parent tree. */ - if ((AcpiNsLocal (Type)) || - (!ParentNode)) + if (!ParentNode) { - if (!ParentNode) - { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n", - (char *) &TargetName)); - } - - if (AcpiNsLocal (Type)) - { - ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, - "[%4.4s] type [%s] must be local to this scope (no parent search)\n", - (char *) &TargetName, AcpiUtGetTypeName (Type))); - } + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n", + (char *) &TargetName)); + return_ACPI_STATUS (AE_NOT_FOUND); + } + if (AcpiNsLocal (Type)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "[%4.4s] type [%s] must be local to this scope (no parent search)\n", + (char *) &TargetName, AcpiUtGetTypeName (Type))); return_ACPI_STATUS (AE_NOT_FOUND); } /* Search the parent tree */ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching parent for %4.4s\n", (char *) &TargetName)); /* * Search parents until found the target or we have backed up to * the root */ while (ParentNode) { /* * Search parent scope. Use TYPE_ANY because we don't care about the * object type at this point, we only care about the existence of * the actual name we are searching for. Typechecking comes later. */ Status = AcpiNsSearchNode (TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode); if (ACPI_SUCCESS (Status)) { return_ACPI_STATUS (Status); } /* * Not found here, go up another level * (until we reach the root) */ ParentNode = AcpiNsGetParentNode (ParentNode); } /* Not found in parent tree */ return_ACPI_STATUS (AE_NOT_FOUND); } /******************************************************************************* * * FUNCTION: AcpiNsSearchAndEnter * * PARAMETERS: TargetName - Ascii ACPI name to search for (4 chars) * WalkState - Current state of the walk - * *Node - Starting table where search will begin - * InterpreterMode - Add names only in MODE_LoadPassX. + * *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 * * RETURN: Status * - * DESCRIPTION: Search for a name segment in a single name table, + * DESCRIPTION: Search for a name segment in a single namespace level, * optionally adding it if it is not found. If the passed * Type is not Any and the type previously stored in the * entry was Any (i.e. unknown), update the stored type. * - * In IMODE_EXECUTE, search only. + * In ACPI_IMODE_EXECUTE, search only. * In other modes, search and add if not found. * ******************************************************************************/ ACPI_STATUS AcpiNsSearchAndEnter ( UINT32 TargetName, ACPI_WALK_STATE *WalkState, ACPI_NAMESPACE_NODE *Node, ACPI_INTERPRETER_MODE InterpreterMode, ACPI_OBJECT_TYPE Type, UINT32 Flags, ACPI_NAMESPACE_NODE **ReturnNode) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *NewNode; ACPI_FUNCTION_TRACE ("NsSearchAndEnter"); /* Parameter validation */ if (!Node || !TargetName || !ReturnNode) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null param: Node %p Name %X ReturnNode %p\n", Node, TargetName, ReturnNode)); ACPI_REPORT_ERROR (("NsSearchAndEnter: Null parameter\n")); return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Name must consist of printable characters */ if (!AcpiUtValidAcpiName (TargetName)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "*** Bad character in name: %08x *** \n", + ACPI_REPORT_ERROR (("NsSearchAndEnter: Bad character in ACPI Name: %X\n", TargetName)); - - ACPI_REPORT_ERROR (("NsSearchAndEnter: Bad character in ACPI Name\n")); return_ACPI_STATUS (AE_BAD_CHARACTER); } - /* Try to find the name in the table specified by the caller */ + /* Try to find the name in the namespace level specified by the caller */ *ReturnNode = ACPI_ENTRY_NOT_FOUND; Status = AcpiNsSearchNode (TargetName, Node, Type, ReturnNode); if (Status != AE_NOT_FOUND) { /* * If we found it AND the request specifies that a find is an error, * return the error */ if ((Status == AE_OK) && (Flags & ACPI_NS_ERROR_IF_FOUND)) { Status = AE_ALREADY_EXISTS; } /* * Either found it or there was an error * -- finished either way */ return_ACPI_STATUS (Status); } /* * The name was not found. If we are NOT performing the * first pass (name entry) of loading the namespace, search * the parent tree (all the way to the root if necessary.) * We don't want to perform the parent search when the * namespace is actually being loaded. We want to perform * the search when namespace references are being resolved * (load pass 2) and during the execution phase. */ if ((InterpreterMode != ACPI_IMODE_LOAD_PASS1) && (Flags & ACPI_NS_SEARCH_PARENT)) { /* - * Not found in table - search parent tree according + * Not found at this level - search parent tree according * to ACPI specification */ Status = AcpiNsSearchParentTree (TargetName, Node, Type, ReturnNode); if (ACPI_SUCCESS (Status)) { return_ACPI_STATUS (Status); } } /* * In execute mode, just search, never add names. Exit now. */ if (InterpreterMode == ACPI_IMODE_EXECUTE) { ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%4.4s Not found in %p [Not adding]\n", (char *) &TargetName, Node)); return_ACPI_STATUS (AE_NOT_FOUND); } /* Create the new named object */ NewNode = AcpiNsCreateNode (TargetName); if (!NewNode) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Install the new object into the parent's list of children */ AcpiNsInstallNode (WalkState, Node, NewNode, Type); *ReturnNode = NewNode; return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/nsutils.c b/sys/contrib/dev/acpica/nsutils.c index 6e87abad3d52..69ed423ae7e8 100644 --- a/sys/contrib/dev/acpica/nsutils.c +++ b/sys/contrib/dev/acpica/nsutils.c @@ -1,1151 +1,1116 @@ /****************************************************************************** * * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing * parents and siblings and Scope manipulation - * $Revision: 113 $ + * $Revision: 116 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __NSUTILS_C__ #include "acpi.h" #include "acnamesp.h" #include "amlcode.h" #include "actables.h" #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsutils") /******************************************************************************* * * FUNCTION: AcpiNsReportError * * 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 * - * DESCRIPTION: Print warning message + * DESCRIPTION: Print warning message with full pathname * ******************************************************************************/ void AcpiNsReportError ( NATIVE_CHAR *ModuleName, UINT32 LineNumber, UINT32 ComponentId, char *InternalName, ACPI_STATUS LookupStatus) { ACPI_STATUS Status; char *Name; + /* Convert path to external format */ + Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, InternalName, NULL, &Name); AcpiOsPrintf ("%8s-%04d: *** Error: Looking up ", ModuleName, LineNumber); - if (Name) + /* Print target name */ + + if (ACPI_SUCCESS (Status)) { AcpiOsPrintf ("[%s]", Name); } else { AcpiOsPrintf ("[COULD NOT EXTERNALIZE NAME]"); } AcpiOsPrintf (" in namespace, %s\n", AcpiFormatException (LookupStatus)); if (Name) { ACPI_MEM_FREE (Name); } } /******************************************************************************* * * FUNCTION: AcpiNsValidRootPrefix * * PARAMETERS: Prefix - Character to be checked * * RETURN: TRUE if a valid prefix * * DESCRIPTION: Check if a character is a valid ACPI Root prefix * ******************************************************************************/ BOOLEAN AcpiNsValidRootPrefix ( NATIVE_CHAR Prefix) { return ((BOOLEAN) (Prefix == '\\')); } /******************************************************************************* * * FUNCTION: AcpiNsValidPathSeparator * * PARAMETERS: Sep - Character to be checked * * RETURN: TRUE if a valid path separator * * DESCRIPTION: Check if a character is a valid ACPI path separator * ******************************************************************************/ BOOLEAN AcpiNsValidPathSeparator ( NATIVE_CHAR Sep) { return ((BOOLEAN) (Sep == '.')); } /******************************************************************************* * * FUNCTION: AcpiNsGetType * * PARAMETERS: Handle - Parent Node to be examined * * RETURN: Type field from Node whose handle is passed * ******************************************************************************/ ACPI_OBJECT_TYPE AcpiNsGetType ( ACPI_NAMESPACE_NODE *Node) { ACPI_FUNCTION_TRACE ("NsGetType"); if (!Node) { ACPI_REPORT_WARNING (("NsGetType: Null Node ptr")); return_VALUE (ACPI_TYPE_ANY); } return_VALUE ((ACPI_OBJECT_TYPE) Node->Type); } /******************************************************************************* * * FUNCTION: AcpiNsLocal * * 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 * ******************************************************************************/ UINT32 AcpiNsLocal ( ACPI_OBJECT_TYPE Type) { ACPI_FUNCTION_TRACE ("NsLocal"); if (!AcpiUtValidObjectType (Type)) { /* Type code out of range */ ACPI_REPORT_WARNING (("NsLocal: Invalid Object Type\n")); return_VALUE (ACPI_NS_NORMAL); } return_VALUE ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL); } /******************************************************************************* * * FUNCTION: AcpiNsGetInternalNameLength * * PARAMETERS: Info - Info struct initialized with the * external name pointer. * * RETURN: Status * * DESCRIPTION: Calculate the length of the internal (AML) namestring * corresponding to the external (ASL) namestring. * ******************************************************************************/ void AcpiNsGetInternalNameLength ( ACPI_NAMESTRING_INFO *Info) { NATIVE_CHAR *NextExternalChar; UINT32 i; ACPI_FUNCTION_ENTRY (); NextExternalChar = Info->ExternalName; Info->NumCarats = 0; Info->NumSegments = 0; Info->FullyQualified = FALSE; /* * For the internal name, the required length is 4 bytes * per segment, plus 1 each for RootPrefix, MultiNamePrefixOp, * segment count, trailing null (which is not really needed, * but no there's harm in putting it there) * * strlen() + 1 covers the first NameSeg, which has no * path separator */ if (AcpiNsValidRootPrefix (NextExternalChar[0])) { Info->FullyQualified = TRUE; NextExternalChar++; } else { /* * Handle Carat prefixes */ while (*NextExternalChar == '^') { Info->NumCarats++; NextExternalChar++; } } /* * Determine the number of ACPI name "segments" by counting * the number of path separators within the string. Start * with one segment since the segment count is (# separators) * + 1, and zero separators is ok. */ if (*NextExternalChar) { Info->NumSegments = 1; for (i = 0; NextExternalChar[i]; i++) { if (AcpiNsValidPathSeparator (NextExternalChar[i])) { Info->NumSegments++; } } } Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) + 4 + Info->NumCarats; Info->NextExternalChar = NextExternalChar; } /******************************************************************************* * * FUNCTION: AcpiNsBuildInternalName * * PARAMETERS: Info - Info struct fully initialized * * RETURN: Status * * DESCRIPTION: Construct the internal (AML) namestring * corresponding to the external (ASL) namestring. * ******************************************************************************/ ACPI_STATUS AcpiNsBuildInternalName ( ACPI_NAMESTRING_INFO *Info) { UINT32 NumSegments = Info->NumSegments; NATIVE_CHAR *InternalName = Info->InternalName; NATIVE_CHAR *ExternalName = Info->NextExternalChar; NATIVE_CHAR *Result = NULL; NATIVE_UINT i; ACPI_FUNCTION_TRACE ("NsBuildInternalName"); /* Setup the correct prefixes, counts, and pointers */ if (Info->FullyQualified) { InternalName[0] = '\\'; if (NumSegments <= 1) { Result = &InternalName[1]; } else if (NumSegments == 2) { InternalName[1] = AML_DUAL_NAME_PREFIX; Result = &InternalName[2]; } else { InternalName[1] = AML_MULTI_NAME_PREFIX_OP; InternalName[2] = (char) NumSegments; Result = &InternalName[3]; } } else { /* * Not fully qualified. * Handle Carats first, then append the name segments */ i = 0; if (Info->NumCarats) { for (i = 0; i < Info->NumCarats; i++) { InternalName[i] = '^'; } } if (NumSegments <= 1) { Result = &InternalName[i]; } else if (NumSegments == 2) { InternalName[i] = AML_DUAL_NAME_PREFIX; Result = &InternalName[i+1]; } else { InternalName[i] = AML_MULTI_NAME_PREFIX_OP; InternalName[i+1] = (char) NumSegments; Result = &InternalName[i+2]; } } /* Build the name (minus path separators) */ for (; NumSegments; NumSegments--) { for (i = 0; i < ACPI_NAME_SIZE; i++) { if (AcpiNsValidPathSeparator (*ExternalName) || (*ExternalName == 0)) { /* Pad the segment with underscore(s) if segment is short */ Result[i] = '_'; } else { /* Convert the character to uppercase and save it */ Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName); ExternalName++; } } /* Now we must have a path separator, or the pathname is bad */ if (!AcpiNsValidPathSeparator (*ExternalName) && (*ExternalName != 0)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Move on the next segment */ ExternalName++; Result += ACPI_NAME_SIZE; } /* Terminate the string */ *Result = 0; if (Info->FullyQualified) { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "returning [%p] (abs) \"\\%s\"\n", InternalName, InternalName)); } else { ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "returning [%p] (rel) \"%s\"\n", InternalName, InternalName)); } return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiNsInternalizeName * * PARAMETERS: *ExternalName - External representation of name * **Converted Name - Where to return the resulting * internal represention of the name * * RETURN: Status * * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0") * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) * *******************************************************************************/ ACPI_STATUS AcpiNsInternalizeName ( NATIVE_CHAR *ExternalName, NATIVE_CHAR **ConvertedName) { NATIVE_CHAR *InternalName; ACPI_NAMESTRING_INFO Info; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("NsInternalizeName"); if ((!ExternalName) || (*ExternalName == 0) || (!ConvertedName)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Get the length of the new internal name */ Info.ExternalName = ExternalName; AcpiNsGetInternalNameLength (&Info); /* We need a segment to store the internal name */ InternalName = ACPI_MEM_CALLOCATE (Info.Length); if (!InternalName) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Build the name */ Info.InternalName = InternalName; Status = AcpiNsBuildInternalName (&Info); if (ACPI_FAILURE (Status)) { ACPI_MEM_FREE (InternalName); return_ACPI_STATUS (Status); } *ConvertedName = InternalName; return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiNsExternalizeName * * PARAMETERS: *InternalName - Internal representation of name * **ConvertedName - Where to return the resulting * external representation of name * * 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") * ******************************************************************************/ ACPI_STATUS AcpiNsExternalizeName ( UINT32 InternalNameLength, char *InternalName, UINT32 *ConvertedNameLength, char **ConvertedName) { NATIVE_UINT_MIN32 PrefixLength = 0; NATIVE_UINT_MIN32 NamesIndex = 0; NATIVE_UINT_MIN32 NumSegments = 0; NATIVE_UINT_MIN32 i = 0; NATIVE_UINT_MIN32 j = 0; NATIVE_UINT_MIN32 RequiredLength; ACPI_FUNCTION_TRACE ("NsExternalizeName"); if (!InternalNameLength || !InternalName || !ConvertedName) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* * Check for a prefix (one '\' | one or more '^'). */ switch (InternalName[0]) { case '\\': PrefixLength = 1; break; case '^': for (i = 0; i < InternalNameLength; i++) { if (InternalName[i] == '^') { PrefixLength = i + 1; } else { break; } } if (i == InternalNameLength) { PrefixLength = i; } break; default: break; } /* * Check for object names. Note that there could be 0-255 of these * 4-byte elements. */ if (PrefixLength < InternalNameLength) { switch (InternalName[PrefixLength]) { case AML_MULTI_NAME_PREFIX_OP: /* 4-byte names */ NamesIndex = PrefixLength + 2; NumSegments = (UINT32) (UINT8) InternalName[PrefixLength + 1]; break; case AML_DUAL_NAME_PREFIX: /* Two 4-byte names */ NamesIndex = PrefixLength + 1; NumSegments = 2; break; case 0: /* NullName */ NamesIndex = 0; NumSegments = 0; break; default: /* one 4-byte name */ NamesIndex = PrefixLength; NumSegments = 1; break; } } /* * Calculate the length of ConvertedName, which equals the length * of the prefix, length of all object names, length of any required * punctuation ('.') between object names, plus the NULL terminator. */ RequiredLength = PrefixLength + (4 * NumSegments) + ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1; /* * Check to see if we're still in bounds. If not, there's a problem * with InternalName (invalid format). */ if (RequiredLength > InternalNameLength) { ACPI_REPORT_ERROR (("NsExternalizeName: Invalid internal name\n")); return_ACPI_STATUS (AE_BAD_PATHNAME); } /* * Build ConvertedName... */ *ConvertedName = ACPI_MEM_CALLOCATE (RequiredLength); if (!(*ConvertedName)) { return_ACPI_STATUS (AE_NO_MEMORY); } j = 0; for (i = 0; i < PrefixLength; i++) { (*ConvertedName)[j++] = InternalName[i]; } if (NumSegments > 0) { for (i = 0; i < NumSegments; i++) { if (i > 0) { (*ConvertedName)[j++] = '.'; } (*ConvertedName)[j++] = InternalName[NamesIndex++]; (*ConvertedName)[j++] = InternalName[NamesIndex++]; (*ConvertedName)[j++] = InternalName[NamesIndex++]; (*ConvertedName)[j++] = InternalName[NamesIndex++]; } } if (ConvertedNameLength) { *ConvertedNameLength = (UINT32) RequiredLength; } return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiNsMapHandleToNode * * PARAMETERS: Handle - Handle to be converted to an Node * * RETURN: A Name table entry pointer * * DESCRIPTION: Convert a namespace handle to a real Node * * Note: Real integer handles allow for more verification * and keep all pointers within this subsystem. * ******************************************************************************/ ACPI_NAMESPACE_NODE * AcpiNsMapHandleToNode ( ACPI_HANDLE Handle) { ACPI_FUNCTION_ENTRY (); /* * Simple implementation. */ if (!Handle) { return (NULL); } if (Handle == ACPI_ROOT_OBJECT) { return (AcpiGbl_RootNode); } /* We can at least attempt to verify the handle */ if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED) { return (NULL); } return ((ACPI_NAMESPACE_NODE *) Handle); } /******************************************************************************* * * FUNCTION: AcpiNsConvertEntryToHandle * * PARAMETERS: Node - Node to be converted to a Handle * * RETURN: An USER ACPI_HANDLE * * DESCRIPTION: Convert a real Node to a namespace handle * ******************************************************************************/ ACPI_HANDLE AcpiNsConvertEntryToHandle ( ACPI_NAMESPACE_NODE *Node) { /* * Simple implementation for now; */ return ((ACPI_HANDLE) Node); /* --------------------------------------------------- if (!Node) { return (NULL); } if (Node == AcpiGbl_RootNode) { return (ACPI_ROOT_OBJECT); } return ((ACPI_HANDLE) Node); ------------------------------------------------------*/ } /******************************************************************************* * * FUNCTION: AcpiNsTerminate * * PARAMETERS: none * * RETURN: none * * DESCRIPTION: free memory allocated for table storage. * ******************************************************************************/ void AcpiNsTerminate (void) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_NAMESPACE_NODE *ThisNode; ACPI_FUNCTION_TRACE ("NsTerminate"); ThisNode = AcpiGbl_RootNode; /* * 1) Free the entire namespace -- all objects, tables, and stacks * * Delete all objects linked to the root * (additional table descriptors) */ AcpiNsDeleteNamespaceSubtree (ThisNode); /* Detach any object(s) attached to the root */ ObjDesc = AcpiNsGetAttachedObject (ThisNode); if (ObjDesc) { AcpiNsDetachObject (ThisNode); AcpiUtRemoveReference (ObjDesc); } AcpiNsDeleteChildren (ThisNode); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n")); /* * 2) Now we can delete the ACPI tables */ AcpiTbDeleteAcpiTables (); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); return_VOID; } /******************************************************************************* * * FUNCTION: AcpiNsOpensScope * * PARAMETERS: Type - A valid namespace type * * RETURN: NEWSCOPE if the passed type "opens a name scope" according * to the ACPI specification, else 0 * ******************************************************************************/ UINT32 AcpiNsOpensScope ( ACPI_OBJECT_TYPE Type) { - ACPI_FUNCTION_TRACE_U32 ("NsOpensScope", Type); + ACPI_FUNCTION_TRACE_STR ("NsOpensScope", AcpiUtGetTypeName (Type)); if (!AcpiUtValidObjectType (Type)) { /* type code out of range */ ACPI_REPORT_WARNING (("NsOpensScope: Invalid Object Type %X\n", Type)); return_VALUE (ACPI_NS_NORMAL); } return_VALUE (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE); } /******************************************************************************* * * FUNCTION: AcpiNsGetNodeByPath * * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The * \ (backslash) and ^ (carat) prefixes, and the * . (period) to separate segments are supported. * StartNode - Root of subtree to be searched, or NS_ALL for the * root of the name space. If Name is fully * qualified (first INT8 is '\'), the passed value * of Scope will not be accessed. * Flags - Used to indicate whether to perform upsearch or * not. * ReturnNode - Where the Node is returned * * DESCRIPTION: Look up a name relative to a given scope and return the * corresponding Node. NOTE: Scope can be null. * * MUTEX: Locks namespace * ******************************************************************************/ ACPI_STATUS AcpiNsGetNodeByPath ( NATIVE_CHAR *Pathname, ACPI_NAMESPACE_NODE *StartNode, UINT32 Flags, ACPI_NAMESPACE_NODE **ReturnNode) { ACPI_GENERIC_STATE ScopeInfo; ACPI_STATUS Status; NATIVE_CHAR *InternalPath = NULL; ACPI_FUNCTION_TRACE_PTR ("NsGetNodeByPath", Pathname); if (!Pathname) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Convert path to internal representation */ Status = AcpiNsInternalizeName (Pathname, &InternalPath); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Must lock namespace during lookup */ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Setup lookup scope (search starting point) */ ScopeInfo.Scope.Node = StartNode; /* Lookup the name in the namespace */ Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE), NULL, ReturnNode); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s, %s\n", InternalPath, AcpiFormatException (Status))); } /* Cleanup */ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); ACPI_MEM_FREE (InternalPath); return_ACPI_STATUS (Status); } /******************************************************************************* * * 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, ChildNode->Name.Ascii, ParentNode, ParentNode->Name.Ascii)); 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, ChildNode->Name.Ascii)); } return_VALUE (ACPI_UNKNOWN_NAME); } -#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) - -/******************************************************************************* - * - * FUNCTION: AcpiNsExistDownstreamSibling - * - * PARAMETERS: *Node - pointer to first Node to examine - * - * RETURN: TRUE if sibling is found, FALSE otherwise - * - * DESCRIPTION: Searches remainder of scope being processed to determine - * whether there is a downstream sibling to the current - * object. This function is used to determine what type of - * line drawing character to use when displaying namespace - * trees. - * - ******************************************************************************/ - -BOOLEAN -AcpiNsExistDownstreamSibling ( - ACPI_NAMESPACE_NODE *Node) -{ - - if (!Node) - { - return (FALSE); - } - - if (Node->Name.Integer) - { - return (TRUE); - } - - return (FALSE); -} - -#endif /* ACPI_DEBUG_OUTPUT */ - - /******************************************************************************* * * FUNCTION: AcpiNsGetParentNode * * PARAMETERS: Node - Current table entry * * RETURN: Parent entry of the given entry * * DESCRIPTION: Obtain the parent entry for a given entry in the namespace. * ******************************************************************************/ ACPI_NAMESPACE_NODE * AcpiNsGetParentNode ( ACPI_NAMESPACE_NODE *Node) { ACPI_FUNCTION_ENTRY (); if (!Node) { return (NULL); } /* * Walk to the end of this peer list. * The last entry is marked with a flag and the peer * pointer is really a pointer back to the parent. * This saves putting a parent back pointer in each and * every named object! */ while (!(Node->Flags & ANOBJ_END_OF_PEER_LIST)) { Node = Node->Peer; } return (Node->Peer); } /******************************************************************************* * * FUNCTION: AcpiNsGetNextValidNode * * PARAMETERS: Node - Current table entry * * RETURN: Next valid Node in the linked node list. NULL if no more valid * nodess * * DESCRIPTION: Find the next valid node within a name table. * Useful for implementing NULL-end-of-list loops. * ******************************************************************************/ ACPI_NAMESPACE_NODE * AcpiNsGetNextValidNode ( ACPI_NAMESPACE_NODE *Node) { /* If we are at the end of this peer list, return NULL */ if (Node->Flags & ANOBJ_END_OF_PEER_LIST) { return NULL; } /* Otherwise just return the next peer */ return (Node->Peer); } diff --git a/sys/contrib/dev/acpica/nsxfeval.c b/sys/contrib/dev/acpica/nsxfeval.c index 1349eda1f00b..19260112e950 100644 --- a/sys/contrib/dev/acpica/nsxfeval.c +++ b/sys/contrib/dev/acpica/nsxfeval.c @@ -1,865 +1,870 @@ /******************************************************************************* * * Module Name: nsxfeval - Public interfaces to the ACPI subsystem * ACPI Object evaluation interfaces - * $Revision: 2 $ + * $Revision: 4 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __NSXFEVAL_C__ #include "acpi.h" #include "acnamesp.h" #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsxfeval") /******************************************************************************* * * FUNCTION: AcpiEvaluateObjectTyped * * PARAMETERS: Handle - Object handle (optional) * *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 * any). If NULL, no value is returned. * ReturnType - Expected type of return object * * RETURN: Status * * DESCRIPTION: Find and evaluate the given object, passing the given * parameters if necessary. One of "Handle" or "Pathname" must * be valid (non-null) * ******************************************************************************/ ACPI_STATUS AcpiEvaluateObjectTyped ( ACPI_HANDLE Handle, ACPI_STRING Pathname, ACPI_OBJECT_LIST *ExternalParams, ACPI_BUFFER *ReturnBuffer, ACPI_OBJECT_TYPE ReturnType) { ACPI_STATUS Status; BOOLEAN MustFree = FALSE; ACPI_FUNCTION_TRACE ("AcpiEvaluateObjectTyped"); /* Return buffer must be valid */ if (!ReturnBuffer) { return_ACPI_STATUS (AE_BAD_PARAMETER); } if (ReturnBuffer->Length == ACPI_ALLOCATE_BUFFER) { MustFree = TRUE; } /* Evaluate the object */ Status = AcpiEvaluateObject (Handle, Pathname, ExternalParams, ReturnBuffer); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Type ANY means "don't care" */ if (ReturnType == ACPI_TYPE_ANY) { return_ACPI_STATUS (AE_OK); } if (ReturnBuffer->Length == 0) { /* Error because caller specifically asked for a return value */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No return value\n")); return_ACPI_STATUS (AE_NULL_OBJECT); } /* Examine the object type returned from EvaluateObject */ if (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type == ReturnType) { return_ACPI_STATUS (AE_OK); } /* Return object type does not match requested type */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Incorrect return type [%s] requested [%s]\n", AcpiUtGetTypeName (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type), AcpiUtGetTypeName (ReturnType))); if (MustFree) { /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ AcpiOsFree (ReturnBuffer->Pointer); ReturnBuffer->Pointer = NULL; } ReturnBuffer->Length = 0; return_ACPI_STATUS (AE_TYPE); } /******************************************************************************* * * FUNCTION: AcpiEvaluateObject * * PARAMETERS: Handle - Object handle (optional) * *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 * any). If NULL, no value is returned. * * RETURN: Status * * DESCRIPTION: Find and evaluate the given object, passing the given * parameters if necessary. One of "Handle" or "Pathname" must * be valid (non-null) * ******************************************************************************/ ACPI_STATUS AcpiEvaluateObject ( ACPI_HANDLE Handle, ACPI_STRING Pathname, ACPI_OBJECT_LIST *ExternalParams, ACPI_BUFFER *ReturnBuffer) { ACPI_STATUS Status; ACPI_OPERAND_OBJECT **InternalParams = NULL; ACPI_OPERAND_OBJECT *InternalReturnObj = NULL; ACPI_SIZE BufferSpaceNeeded; UINT32 i; ACPI_FUNCTION_TRACE ("AcpiEvaluateObject"); /* * If there are parameters to be passed to the object * (which must be a control method), the external objects * must be converted to internal objects */ if (ExternalParams && ExternalParams->Count) { /* * Allocate a new parameter block for the internal objects * Add 1 to count to allow for null terminated internal list */ InternalParams = ACPI_MEM_CALLOCATE (((ACPI_SIZE) ExternalParams->Count + 1) * sizeof (void *)); if (!InternalParams) { return_ACPI_STATUS (AE_NO_MEMORY); } /* * Convert each external object in the list to an * internal object */ for (i = 0; i < ExternalParams->Count; i++) { Status = AcpiUtCopyEobjectToIobject (&ExternalParams->Pointer[i], &InternalParams[i]); if (ACPI_FAILURE (Status)) { AcpiUtDeleteInternalObjectList (InternalParams); return_ACPI_STATUS (Status); } } InternalParams[ExternalParams->Count] = NULL; } /* * Three major cases: * 1) Fully qualified pathname * 2) No handle, not fully qualified pathname (error) * 3) Valid handle */ if ((Pathname) && (AcpiNsValidRootPrefix (Pathname[0]))) { /* * The path is fully qualified, just evaluate by name */ Status = AcpiNsEvaluateByName (Pathname, InternalParams, &InternalReturnObj); } else if (!Handle) { /* * A handle is optional iff a fully qualified pathname * is specified. Since we've already handled fully * qualified names above, this is an error */ if (!Pathname) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Both Handle and Pathname are NULL\n")); } else { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Handle is NULL and Pathname is relative\n")); } Status = AE_BAD_PARAMETER; } else { /* * We get here if we have a handle -- and if we have a * pathname it is relative. The handle will be validated * in the lower procedures */ if (!Pathname) { /* * The null pathname case means the handle is for * the actual object to be evaluated */ Status = AcpiNsEvaluateByHandle (Handle, InternalParams, &InternalReturnObj); } else { /* * Both a Handle and a relative Pathname */ Status = AcpiNsEvaluateRelative (Handle, Pathname, InternalParams, &InternalReturnObj); } } /* * If we are expecting a return value, and all went well above, * copy the return value to an external object. */ if (ReturnBuffer) { if (!InternalReturnObj) { ReturnBuffer->Length = 0; } else { if (ACPI_GET_DESCRIPTOR_TYPE (InternalReturnObj) == ACPI_DESC_TYPE_NAMED) { /* * If we received a NS Node as a return object, this means that * the object we are evaluating has nothing interesting to * return (such as a mutex, etc.) We return an error because * these types are essentially unsupported by this interface. * We don't check up front because this makes it easier to add * support for various types at a later date if necessary. */ Status = AE_TYPE; InternalReturnObj = NULL; /* No need to delete a NS Node */ ReturnBuffer->Length = 0; } if (ACPI_SUCCESS (Status)) { /* * Find out how large a buffer is needed * to contain the returned object */ Status = AcpiUtGetObjectSize (InternalReturnObj, &BufferSpaceNeeded); if (ACPI_SUCCESS (Status)) { /* Validate/Allocate/Clear caller buffer */ Status = AcpiUtInitializeBuffer (ReturnBuffer, BufferSpaceNeeded); if (ACPI_FAILURE (Status)) { /* * Caller's buffer is too small or a new one can't be allocated */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Needed buffer size %X, %s\n", (UINT32) BufferSpaceNeeded, AcpiFormatException (Status))); } else { /* * We have enough space for the object, build it */ Status = AcpiUtCopyIobjectToEobject (InternalReturnObj, ReturnBuffer); } } } } } /* Delete the return and parameter objects */ if (InternalReturnObj) { /* * Delete the internal return object. (Or at least * decrement the reference count by one) */ AcpiUtRemoveReference (InternalReturnObj); } /* * Free the input parameter list (if we created one), */ if (InternalParams) { /* Free the allocated parameter block */ AcpiUtDeleteInternalObjectList (InternalParams); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiWalkNamespace * * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for * StartObject - Handle in namespace where search begins * MaxDepth - Depth to which search is to reach * UserFunction - Called when an object of "Type" is found * Context - Passed to user function * ReturnValue - Location where return value of * UserFunction is put if terminated early * * RETURNS Return value from the UserFunction if terminated early. * Otherwise, returns NULL. * * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, * starting (and ending) at the object specified by StartHandle. * The UserFunction is called whenever an object that matches * the type parameter is found. If the user function returns * a non-zero value, the search is terminated immediately and this * value is returned to the caller. * * The point of this procedure is to provide a generic namespace * walk routine that can be called from multiple places to * provide multiple services; the User Function can be tailored * to each task, whether it is a print function, a compare * function, etc. * ******************************************************************************/ ACPI_STATUS AcpiWalkNamespace ( ACPI_OBJECT_TYPE Type, ACPI_HANDLE StartObject, UINT32 MaxDepth, ACPI_WALK_CALLBACK UserFunction, void *Context, void **ReturnValue) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("AcpiWalkNamespace"); /* Parameter validation */ - if ((Type > ACPI_TYPE_MAX) || - (!MaxDepth) || + if ((Type > ACPI_TYPE_EXTERNAL_MAX) || + (!MaxDepth) || (!UserFunction)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* * Lock the namespace around the walk. * The namespace will be unlocked/locked around each call * to the user function - since this function * must be allowed to make Acpi calls itself. */ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, ACPI_NS_WALK_UNLOCK, UserFunction, Context, ReturnValue); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiNsGetDeviceCallback * * PARAMETERS: Callback from AcpiGetDevice * * RETURN: Status * * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non- * present devices, or if they specified a HID, it filters based * on that. * ******************************************************************************/ static ACPI_STATUS AcpiNsGetDeviceCallback ( ACPI_HANDLE ObjHandle, UINT32 NestingLevel, void *Context, void **ReturnValue) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; UINT32 Flags; ACPI_DEVICE_ID Hid; ACPI_DEVICE_ID Cid; ACPI_GET_DEVICES_INFO *Info; Info = Context; Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return (Status); } Node = AcpiNsMapHandleToNode (ObjHandle); Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return (Status); } if (!Node) { return (AE_BAD_PARAMETER); } /* * Run _STA to determine if device is present */ Status = AcpiUtExecute_STA (Node, &Flags); if (ACPI_FAILURE (Status)) { return (AE_CTRL_DEPTH); } if (!(Flags & 0x01)) { /* Don't return at the device or children of the device if not there */ return (AE_CTRL_DEPTH); } /* * Filter based on device HID & CID */ if (Info->Hid != NULL) { Status = AcpiUtExecute_HID (Node, &Hid); if (Status == AE_NOT_FOUND) { return (AE_OK); } else if (ACPI_FAILURE (Status)) { return (AE_CTRL_DEPTH); } if (ACPI_STRNCMP (Hid.Buffer, Info->Hid, sizeof (Hid.Buffer)) != 0) { Status = AcpiUtExecute_CID (Node, &Cid); if (Status == AE_NOT_FOUND) { return (AE_OK); } else if (ACPI_FAILURE (Status)) { return (AE_CTRL_DEPTH); } /* TBD: Handle CID packages */ if (ACPI_STRNCMP (Cid.Buffer, Info->Hid, sizeof (Cid.Buffer)) != 0) { return (AE_OK); } } } Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context, ReturnValue); return (Status); } /******************************************************************************* * * FUNCTION: AcpiGetDevices * * PARAMETERS: HID - HID to search for. Can be NULL. * UserFunction - Called when a matching object is found * Context - Passed to user function * ReturnValue - Location where return value of * UserFunction is put if terminated early * * RETURNS Return value from the UserFunction if terminated early. * Otherwise, returns NULL. * * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, * starting (and ending) at the object specified by StartHandle. * The UserFunction is called whenever an object that matches * the type parameter is found. If the user function returns * a non-zero value, the search is terminated immediately and this * value is returned to the caller. * * This is a wrapper for WalkNamespace, but the callback performs * additional filtering. Please see AcpiGetDeviceCallback. * ******************************************************************************/ ACPI_STATUS AcpiGetDevices ( NATIVE_CHAR *HID, ACPI_WALK_CALLBACK UserFunction, void *Context, void **ReturnValue) { ACPI_STATUS Status; ACPI_GET_DEVICES_INFO Info; ACPI_FUNCTION_TRACE ("AcpiGetDevices"); /* Parameter validation */ if (!UserFunction) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* * We're going to call their callback from OUR callback, so we need * to know what it is, and their context parameter. */ Info.Context = Context; Info.UserFunction = UserFunction; Info.Hid = HID; /* * Lock the namespace around the walk. * The namespace will be unlocked/locked around each call * to the user function - since this function * must be allowed to make Acpi calls itself. */ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, AcpiNsGetDeviceCallback, &Info, ReturnValue); (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiAttachData * - * PARAMETERS: + * PARAMETERS: ObjHandle - Namespace node + * Handler - Handler for this attachment + * Data - Pointer to data to be attached * * RETURN: Status * - * DESCRIPTION: + * DESCRIPTION: Attach arbitrary data and handler to a namespace node. * ******************************************************************************/ ACPI_STATUS AcpiAttachData ( ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler, void *Data) { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; /* Parameter validation */ if (!ObjHandle || !Handler || !Data) { return (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return (Status); } /* Convert and validate the handle */ Node = AcpiNsMapHandleToNode (ObjHandle); if (!Node) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } Status = AcpiNsAttachData (Node, Handler, Data); UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); } /******************************************************************************* * * FUNCTION: AcpiDetachData * - * PARAMETERS: + * PARAMETERS: ObjHandle - Namespace node handle + * Handler - Handler used in call to AcpiAttachData * * RETURN: Status * - * DESCRIPTION: + * DESCRIPTION: Remove data that was previously attached to a node. * ******************************************************************************/ ACPI_STATUS AcpiDetachData ( ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler) { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; /* Parameter validation */ if (!ObjHandle || !Handler) { return (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return (Status); } /* Convert and validate the handle */ Node = AcpiNsMapHandleToNode (ObjHandle); if (!Node) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } Status = AcpiNsDetachData (Node, Handler); UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); } /******************************************************************************* * * FUNCTION: AcpiGetData * - * PARAMETERS: + * PARAMETERS: ObjHandle - Namespace node + * Handler - Handler used in call to AttachData + * Data - Where the data is returned * * RETURN: Status * - * DESCRIPTION: + * DESCRIPTION: Retrieve data that was previously attached to a namespace node. * ******************************************************************************/ ACPI_STATUS AcpiGetData ( ACPI_HANDLE ObjHandle, ACPI_OBJECT_HANDLER Handler, void **Data) { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; /* Parameter validation */ if (!ObjHandle || !Handler || !Data) { return (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return (Status); } /* Convert and validate the handle */ Node = AcpiNsMapHandleToNode (ObjHandle); if (!Node) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } Status = AcpiNsGetAttachedData (Node, Handler, Data); UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); } diff --git a/sys/contrib/dev/acpica/nsxfobj.c b/sys/contrib/dev/acpica/nsxfobj.c index baa72a9615a8..b6fe80730d90 100644 --- a/sys/contrib/dev/acpica/nsxfobj.c +++ b/sys/contrib/dev/acpica/nsxfobj.c @@ -1,351 +1,351 @@ /******************************************************************************* * * Module Name: nsxfobj - Public interfaces to the ACPI subsystem * ACPI Object oriented interfaces - * $Revision: 113 $ + * $Revision: 114 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __NSXFOBJ_C__ #include "acpi.h" #include "acnamesp.h" #define _COMPONENT ACPI_NAMESPACE ACPI_MODULE_NAME ("nsxfobj") /******************************************************************************* * * FUNCTION: AcpiGetType * * PARAMETERS: Handle - Handle of object whose type is desired * *RetType - Where the type will be placed * * RETURN: Status * * DESCRIPTION: This routine returns the type associatd with a particular handle * ******************************************************************************/ ACPI_STATUS AcpiGetType ( ACPI_HANDLE Handle, ACPI_OBJECT_TYPE *RetType) { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; /* Parameter Validation */ if (!RetType) { return (AE_BAD_PARAMETER); } /* * Special case for the predefined Root Node * (return type ANY) */ if (Handle == ACPI_ROOT_OBJECT) { *RetType = ACPI_TYPE_ANY; return (AE_OK); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return (Status); } /* Convert and validate the handle */ Node = AcpiNsMapHandleToNode (Handle); if (!Node) { (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (AE_BAD_PARAMETER); } *RetType = Node->Type; Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); } /******************************************************************************* * * FUNCTION: AcpiGetParent * * PARAMETERS: Handle - Handle of object whose parent is desired * RetHandle - Where the parent handle will be placed * * RETURN: Status * * DESCRIPTION: Returns a handle to the parent of the object represented by * Handle. * ******************************************************************************/ ACPI_STATUS AcpiGetParent ( ACPI_HANDLE Handle, ACPI_HANDLE *RetHandle) { ACPI_NAMESPACE_NODE *Node; ACPI_STATUS Status; if (!RetHandle) { return (AE_BAD_PARAMETER); } /* Special case for the predefined Root Node (no parent) */ if (Handle == ACPI_ROOT_OBJECT) { return (AE_NULL_ENTRY); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return (Status); } /* Convert and validate the handle */ Node = AcpiNsMapHandleToNode (Handle); if (!Node) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } /* Get the parent entry */ *RetHandle = AcpiNsConvertEntryToHandle (AcpiNsGetParentNode (Node)); /* Return exeption if parent is null */ if (!AcpiNsGetParentNode (Node)) { Status = AE_NULL_ENTRY; } UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); } /******************************************************************************* * * FUNCTION: AcpiGetNextObject * * PARAMETERS: Type - Type of object to be searched for * Parent - Parent object whose children we are getting * LastChild - Previous child that was found. * The NEXT child will be returned * RetHandle - Where handle to the next object is placed * * RETURN: Status * * DESCRIPTION: Return the next peer object within the namespace. If Handle is * valid, Scope is ignored. Otherwise, the first object within * Scope is returned. * ******************************************************************************/ ACPI_STATUS AcpiGetNextObject ( ACPI_OBJECT_TYPE Type, ACPI_HANDLE Parent, ACPI_HANDLE Child, ACPI_HANDLE *RetHandle) { ACPI_STATUS Status; ACPI_NAMESPACE_NODE *Node; ACPI_NAMESPACE_NODE *ParentNode = NULL; ACPI_NAMESPACE_NODE *ChildNode = NULL; /* Parameter validation */ - if (Type > ACPI_TYPE_MAX) + if (Type > ACPI_TYPE_EXTERNAL_MAX) { return (AE_BAD_PARAMETER); } Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); if (ACPI_FAILURE (Status)) { return (Status); } /* If null handle, use the parent */ if (!Child) { /* Start search at the beginning of the specified scope */ ParentNode = AcpiNsMapHandleToNode (Parent); if (!ParentNode) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } } else { /* Non-null handle, ignore the parent */ /* Convert and validate the handle */ ChildNode = AcpiNsMapHandleToNode (Child); if (!ChildNode) { Status = AE_BAD_PARAMETER; goto UnlockAndExit; } } /* Internal function does the real work */ Node = AcpiNsGetNextNode (Type, ParentNode, ChildNode); if (!Node) { Status = AE_NOT_FOUND; goto UnlockAndExit; } if (RetHandle) { *RetHandle = AcpiNsConvertEntryToHandle (Node); } UnlockAndExit: (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); return (Status); } diff --git a/sys/contrib/dev/acpica/psargs.c b/sys/contrib/dev/acpica/psargs.c index e1e5346a8dde..1b9e1a43676a 100644 --- a/sys/contrib/dev/acpica/psargs.c +++ b/sys/contrib/dev/acpica/psargs.c @@ -1,808 +1,846 @@ /****************************************************************************** * * Module Name: psargs - Parse AML opcode arguments - * $Revision: 64 $ + * $Revision: 65 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __PSARGS_C__ #include "acpi.h" #include "acparser.h" #include "amlcode.h" #include "acnamesp.h" #define _COMPONENT ACPI_PARSER ACPI_MODULE_NAME ("psargs") /******************************************************************************* * * FUNCTION: AcpiPsGetNextPackageLength * * PARAMETERS: ParserState - Current parser state object * * RETURN: Decoded package length. On completion, the AML pointer points * past the length byte or bytes. * * DESCRIPTION: Decode and return a package length field * ******************************************************************************/ UINT32 AcpiPsGetNextPackageLength ( ACPI_PARSE_STATE *ParserState) { UINT32 EncodedLength; UINT32 Length = 0; ACPI_FUNCTION_TRACE ("PsGetNextPackageLength"); 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) */ Length = (EncodedLength & 0x3F); break; case 1: /* 2-byte encoding (next byte + bits 0-3) */ Length = ((ACPI_GET8 (ParserState->Aml) << 04) | (EncodedLength & 0x0F)); ParserState->Aml++; break; case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */ Length = ((ACPI_GET8 (ParserState->Aml + 1) << 12) | (ACPI_GET8 (ParserState->Aml) << 04) | (EncodedLength & 0x0F)); ParserState->Aml += 2; break; case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */ Length = ((ACPI_GET8 (ParserState->Aml + 2) << 20) | (ACPI_GET8 (ParserState->Aml + 1) << 12) | (ACPI_GET8 (ParserState->Aml) << 04) | (EncodedLength & 0x0F)); ParserState->Aml += 3; break; default: + /* Can't get here, only 2 bits / 4 cases */ break; } return_VALUE (Length); } /******************************************************************************* * * FUNCTION: AcpiPsGetNextPackageEnd * * PARAMETERS: ParserState - Current parser state object * * RETURN: Pointer to end-of-package +1 * * DESCRIPTION: Get next package length and return a pointer past the end of * the package. Consumes the package length field * ******************************************************************************/ UINT8 * AcpiPsGetNextPackageEnd ( ACPI_PARSE_STATE *ParserState) { UINT8 *Start = ParserState->Aml; NATIVE_UINT Length; ACPI_FUNCTION_TRACE ("PsGetNextPackageEnd"); + /* Function below changes ParserState->Aml */ + Length = (NATIVE_UINT) AcpiPsGetNextPackageLength (ParserState); return_PTR (Start + Length); /* end of package */ } /******************************************************************************* * * FUNCTION: AcpiPsGetNextNamestring * * PARAMETERS: ParserState - Current parser state object * * RETURN: Pointer to the start of the name string (pointer points into * the AML. * * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name * prefix characters. Set parser state to point past the string. * (Name is consumed from the AML.) * ******************************************************************************/ NATIVE_CHAR * AcpiPsGetNextNamestring ( ACPI_PARSE_STATE *ParserState) { UINT8 *Start = ParserState->Aml; UINT8 *End = ParserState->Aml; ACPI_FUNCTION_TRACE ("PsGetNextNamestring"); /* Handle multiple prefix characters */ while (AcpiPsIsPrefixChar (ACPI_GET8 (End))) { /* Include prefix '\\' or '^' */ End++; } /* Decode the path */ switch (ACPI_GET8 (End)) { case 0: /* NullName */ if (End == Start) { Start = NULL; } End++; break; case AML_DUAL_NAME_PREFIX: /* Two name segments */ - End += 9; + End += 1 + (2 * ACPI_NAME_SIZE); break; case AML_MULTI_NAME_PREFIX_OP: /* Multiple name segments, 4 chars each */ - End += 2 + ((ACPI_SIZE) ACPI_GET8 (End + 1) * 4); + End += 2 + ((ACPI_SIZE) ACPI_GET8 (End + 1) * ACPI_NAME_SIZE); break; default: /* Single name segment */ - End += 4; + End += ACPI_NAME_SIZE; break; } ParserState->Aml = (UINT8*) End; return_PTR ((NATIVE_CHAR *) Start); } /******************************************************************************* * * FUNCTION: AcpiPsGetNextNamepath * * PARAMETERS: ParserState - Current parser state object * Arg - Where the namepath will be stored * ArgCount - If the namepath points to a control method * the method's argument is returned here. - * MethodCall - Whether the namepath can be the start - * of a method call + * MethodCall - Whether the namepath can possibly be the + * start of a method call * * RETURN: Status * * DESCRIPTION: Get next name (if method call, return # of required args). * Names are looked up in the internal namespace to determine * if the name represents a control method. If a method * is found, the number of arguments to the method is returned. * This information is critical for parsing to continue correctly. * ******************************************************************************/ ACPI_STATUS AcpiPsGetNextNamepath ( + ACPI_WALK_STATE *WalkState, ACPI_PARSE_STATE *ParserState, ACPI_PARSE_OBJECT *Arg, - UINT32 *ArgCount, BOOLEAN MethodCall) { NATIVE_CHAR *Path; ACPI_PARSE_OBJECT *NameOp; ACPI_STATUS Status = AE_OK; ACPI_OPERAND_OBJECT *MethodDesc; ACPI_NAMESPACE_NODE *Node; ACPI_GENERIC_STATE ScopeInfo; ACPI_FUNCTION_TRACE ("PsGetNextNamepath"); Path = AcpiPsGetNextNamestring (ParserState); /* Null path case is allowed */ if (Path) { /* * Lookup the name in the internal namespace */ ScopeInfo.Scope.Node = NULL; Node = ParserState->StartNode; if (Node) { ScopeInfo.Scope.Node = Node; } /* * Lookup object. We don't want to add anything new to the namespace * here, however. So we use MODE_EXECUTE. Allow searching of the * 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); + 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 + */ MethodDesc = AcpiNsGetAttachedObject (Node); - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Control Method - %p Desc %p Path=%p\n", + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path)); NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); if (!NameOp) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Change arg into a METHOD CALL and attach name to it */ AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); - NameOp->Common.Value.Name = Path; /* Point METHODCALL/NAME to the METHOD Node */ NameOp->Common.Node = Node; AcpiPsAppendArg (Arg, NameOp); if (!MethodDesc) { - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Control Method - %p has no attached object\n", + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Control Method - %p has no attached object\n", Node)); return_ACPI_STATUS (AE_AML_INTERNAL); } - ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Control Method - %p Args %X\n", + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Control Method - %p Args %X\n", Node, MethodDesc->Method.ParamCount)); - *ArgCount = MethodDesc->Method.ParamCount; + /* Get the number of arguments to expect */ + + WalkState->ArgCount = MethodDesc->Method.ParamCount; return_ACPI_STATUS (AE_OK); } /* * Else this is normal named object reference. * Just init the NAMEPATH object with the pathname. * (See code below) */ } + + if (ACPI_FAILURE (Status)) + { + /* + * 1) Any error other than NOT_FOUND is always severe + * 2) NOT_FOUND is only important if we are executing a method. + * 3) If executing a CondRefOf opcode, NOT_FOUND is ok. + */ + if ((((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) && + (Status == AE_NOT_FOUND) && + (WalkState->Op->Common.AmlOpcode != AML_COND_REF_OF_OP)) || + + (Status != AE_NOT_FOUND)) + { + ACPI_REPORT_NSERROR (Path, Status); + } + else + { + /* + * We got a NOT_FOUND during table load or we encountered + * a CondRefOf(x) where the target does not exist. + * -- either case is ok + */ + Status = AE_OK; + } + } } /* * Regardless of success/failure above, * Just initialize the Op with the pathname. */ AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); Arg->Common.Value.Name = Path; return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiPsGetNextSimpleArg * * PARAMETERS: ParserState - Current parser state object * ArgType - The argument type (AML_*_ARG) * Arg - Where the argument is returned * * RETURN: None * * DESCRIPTION: Get the next simple argument (constant, string, or namestring) * ******************************************************************************/ void AcpiPsGetNextSimpleArg ( ACPI_PARSE_STATE *ParserState, UINT32 ArgType, ACPI_PARSE_OBJECT *Arg) { ACPI_FUNCTION_TRACE_U32 ("PsGetNextSimpleArg", ArgType); switch (ArgType) { case ARGP_BYTEDATA: AcpiPsInitOp (Arg, AML_BYTE_OP); Arg->Common.Value.Integer = (UINT32) ACPI_GET8 (ParserState->Aml); ParserState->Aml++; break; case ARGP_WORDDATA: AcpiPsInitOp (Arg, AML_WORD_OP); /* Get 2 bytes from the AML stream */ ACPI_MOVE_UNALIGNED16_TO_32 (&Arg->Common.Value.Integer, ParserState->Aml); ParserState->Aml += 2; break; case ARGP_DWORDDATA: AcpiPsInitOp (Arg, AML_DWORD_OP); /* Get 4 bytes from the AML stream */ ACPI_MOVE_UNALIGNED32_TO_32 (&Arg->Common.Value.Integer, ParserState->Aml); ParserState->Aml += 4; break; case ARGP_QWORDDATA: AcpiPsInitOp (Arg, AML_QWORD_OP); /* Get 8 bytes from the AML stream */ ACPI_MOVE_UNALIGNED64_TO_64 (&Arg->Common.Value.Integer, ParserState->Aml); ParserState->Aml += 8; break; case ARGP_CHARLIST: AcpiPsInitOp (Arg, AML_STRING_OP); Arg->Common.Value.String = (char *) ParserState->Aml; while (ACPI_GET8 (ParserState->Aml) != '\0') { ParserState->Aml++; } ParserState->Aml++; break; case ARGP_NAME: case ARGP_NAMESTRING: AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState); break; default: + ACPI_REPORT_ERROR (("Invalid ArgType %X\n", ArgType)); break; } return_VOID; } /******************************************************************************* * * FUNCTION: AcpiPsGetNextField * * PARAMETERS: ParserState - Current parser state object * * RETURN: A newly allocated FIELD op * * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField) * ******************************************************************************/ ACPI_PARSE_OBJECT * AcpiPsGetNextField ( ACPI_PARSE_STATE *ParserState) { UINT32 AmlOffset = ACPI_PTR_DIFF (ParserState->Aml, - ParserState->AmlStart); + ParserState->AmlStart); ACPI_PARSE_OBJECT *Field; UINT16 Opcode; UINT32 Name; ACPI_FUNCTION_TRACE ("PsGetNextField"); /* determine field type */ switch (ACPI_GET8 (ParserState->Aml)) { default: Opcode = AML_INT_NAMEDFIELD_OP; break; case 0x00: Opcode = AML_INT_RESERVEDFIELD_OP; ParserState->Aml++; break; case 0x01: Opcode = AML_INT_ACCESSFIELD_OP; ParserState->Aml++; break; } /* Allocate a new field op */ Field = AcpiPsAllocOp (Opcode); if (!Field) { return_PTR (NULL); } Field->Common.AmlOffset = AmlOffset; /* Decode the field type */ switch (Opcode) { case AML_INT_NAMEDFIELD_OP: /* Get the 4-character name */ ACPI_MOVE_UNALIGNED32_TO_32 (&Name, ParserState->Aml); AcpiPsSetName (Field, Name); - ParserState->Aml += 4; + ParserState->Aml += ACPI_NAME_SIZE; /* Get the length which is encoded as a package length */ Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); break; case AML_INT_RESERVEDFIELD_OP: /* Get the length which is encoded as a package length */ Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); break; case AML_INT_ACCESSFIELD_OP: /* * Get AccessType and AccessAttrib and merge into the field Op * AccessType is first operand, AccessAttribute is second */ Field->Common.Value.Integer32 = (ACPI_GET8 (ParserState->Aml) << 8); ParserState->Aml++; Field->Common.Value.Integer32 |= ACPI_GET8 (ParserState->Aml); ParserState->Aml++; break; default: + /* Opcode was set in previous switch */ break; } return_PTR (Field); } /******************************************************************************* * * FUNCTION: AcpiPsGetNextArg * * PARAMETERS: 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. * * RETURN: Status, and an op object containing the next argument. * * DESCRIPTION: Get next argument (including complex list arguments that require * pushing the parser stack) * ******************************************************************************/ ACPI_STATUS AcpiPsGetNextArg ( + ACPI_WALK_STATE *WalkState, ACPI_PARSE_STATE *ParserState, UINT32 ArgType, - UINT32 *ArgCount, ACPI_PARSE_OBJECT **ReturnArg) { ACPI_PARSE_OBJECT *Arg = NULL; ACPI_PARSE_OBJECT *Prev = NULL; ACPI_PARSE_OBJECT *Field; UINT32 Subop; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE_PTR ("PsGetNextArg", ParserState); switch (ArgType) { case ARGP_BYTEDATA: case ARGP_WORDDATA: case ARGP_DWORDDATA: case ARGP_CHARLIST: case ARGP_NAME: case ARGP_NAMESTRING: /* constants, strings, and namestrings are all the same size */ Arg = AcpiPsAllocOp (AML_BYTE_OP); if (!Arg) { return_ACPI_STATUS (AE_NO_MEMORY); } AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg); break; case ARGP_PKGLENGTH: /* Package length, nothing returned */ ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState); break; case ARGP_FIELDLIST: if (ParserState->Aml < ParserState->PkgEnd) { /* Non-empty list */ while (ParserState->Aml < ParserState->PkgEnd) { Field = AcpiPsGetNextField (ParserState); if (!Field) { return_ACPI_STATUS (AE_NO_MEMORY); } if (Prev) { Prev->Common.Next = Field; } else { Arg = Field; } Prev = Field; } /* Skip to End of byte data */ ParserState->Aml = ParserState->PkgEnd; } break; case ARGP_BYTELIST: if (ParserState->Aml < ParserState->PkgEnd) { /* Non-empty list */ Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP); if (!Arg) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Fill in bytelist data */ - Arg->Common.Value.Size = ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml); + Arg->Common.Value.Size = ACPI_PTR_DIFF (ParserState->PkgEnd, + ParserState->Aml); Arg->Named.Data = ParserState->Aml; /* Skip to End of byte data */ ParserState->Aml = ParserState->PkgEnd; } break; case ARGP_TARGET: case ARGP_SUPERNAME: case ARGP_SIMPLENAME: Subop = AcpiPsPeekOpcode (ParserState); if (Subop == 0 || AcpiPsIsLeadingChar (Subop) || AcpiPsIsPrefixChar (Subop)) { /* NullName or NameString */ Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); if (!Arg) { return_ACPI_STATUS (AE_NO_MEMORY); } - Status = AcpiPsGetNextNamepath (ParserState, Arg, ArgCount, 0); + Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0); } else { /* single complex argument, nothing returned */ - *ArgCount = 1; + WalkState->ArgCount = 1; } break; case ARGP_DATAOBJ: case ARGP_TERMARG: /* single complex argument, nothing returned */ - *ArgCount = 1; + WalkState->ArgCount = 1; break; case ARGP_DATAOBJLIST: case ARGP_TERMLIST: case ARGP_OBJLIST: if (ParserState->Aml < ParserState->PkgEnd) { /* non-empty list of variable arguments, nothing returned */ - *ArgCount = ACPI_VAR_ARGS; + WalkState->ArgCount = ACPI_VAR_ARGS; } break; default: ACPI_REPORT_ERROR (("Invalid ArgType: %X\n", ArgType)); Status = AE_AML_OPERAND_TYPE; break; } *ReturnArg = Arg; return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/psopcode.c b/sys/contrib/dev/acpica/psopcode.c index 270c743990d7..ab2f137c8278 100644 --- a/sys/contrib/dev/acpica/psopcode.c +++ b/sys/contrib/dev/acpica/psopcode.c @@ -1,846 +1,846 @@ /****************************************************************************** * * Module Name: psopcode - Parser/Interpreter opcode information table - * $Revision: 72 $ + * $Revision: 73 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. * All rights reserved. * * 2. License * * 2.1. This is your license from Intel Corp. under its intellectual property * rights. You may have additional license terms from the party that provided * you this software, covering your right to use that party's intellectual * property rights. * * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a * copy of the source code appearing in this file ("Covered Code") an * irrevocable, perpetual, worldwide license under Intel's copyrights in the * base code distributed originally by Intel ("Original Intel Code") to copy, * make derivatives, distribute, use and display any portion of the Covered * Code in any form, with the right to sublicense such rights; and * * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent * license (with the right to sublicense), under only those claims of Intel * patents that are infringed by the Original Intel Code, to make, use, sell, * offer to sell, and import the Covered Code and derivative works thereof * solely to the minimum extent necessary to exercise the above copyright * license, and in no event shall the patent license extend to any additions * to or modifications of the Original Intel Code. No other license or right * is granted directly or by implication, estoppel or otherwise; * * The above copyright and patent license is granted only if the following * conditions are met: * * 3. Conditions * * 3.1. Redistribution of Source with Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification with rights to further distribute source must include * the above Copyright Notice, the above License, this list of Conditions, * and the following Disclaimer and Export Compliance provision. In addition, * Licensee must cause all Covered Code to which Licensee contributes to * contain a file documenting the changes Licensee made to create that Covered * Code and the date of any change. Licensee must include in that file the * documentation of any changes made by any predecessor Licensee. Licensee * must include a prominent statement that the modification is derived, * directly or indirectly, from Original Intel Code. * * 3.2. Redistribution of Source with no Rights to Further Distribute Source. * Redistribution of source code of any substantial portion of the Covered * Code or modification without rights to further distribute source must * include the following Disclaimer and Export Compliance provision in the * documentation and/or other materials provided with distribution. In * addition, Licensee may not authorize further sublicense of source of any * portion of the Covered Code, and must include terms to the effect that the * license from Licensee to its licensee is limited to the intellectual * property embodied in the software Licensee provides to its licensee, and * not to intellectual property embodied in modifications its licensee may * make. * * 3.3. Redistribution of Executable. Redistribution in executable form of any * substantial portion of the Covered Code or modification must reproduce the * above Copyright Notice, and the following Disclaimer and Export Compliance * provision in the documentation and/or other materials provided with the * distribution. * * 3.4. Intel retains all right, title, and interest in and to the Original * Intel Code. * * 3.5. Neither the name Intel nor any other trademark owned or controlled by * Intel shall be used in advertising or otherwise to promote the sale, use or * other dealings in products derived from or relating to the Covered Code * without prior written authorization from Intel. * * 4. Disclaimer and Export Compliance * * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A * PARTICULAR PURPOSE. * * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY * LIMITED REMEDY. * * 4.3. Licensee shall not export, either directly or indirectly, any of this * software or system incorporating such software without first obtaining any * required license or other approval from the U. S. Department of Commerce or * any other agency or department of the United States Government. In the * event Licensee exports any such software from the United States or * re-exports any such software from a foreign destination, Licensee shall * ensure that the distribution and export/re-export of the software is in * compliance with all laws, regulations, orders, or other restrictions of the * U.S. Export Administration Regulations. Licensee agrees that neither it nor * any of its subsidiaries will export/re-export any technical data, process, * software, or service, directly or indirectly, to any country for which the * United States government or any agency thereof requires an export license, * other governmental approval, or letter of assurance, without first obtaining * such license, approval or letter. * *****************************************************************************/ #include "acpi.h" #include "acparser.h" #include "amlcode.h" #define _COMPONENT ACPI_PARSER 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 * * DESCRIPTION: Opcode table. Each entry contains * The name is a simple ascii string, the operand specifier is an * ascii string with one letter per operand. The letter specifies * the operand type. * ******************************************************************************/ /* * 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_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_INTEGER, ARGI_INTEGER) #define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) #define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE #define ARGI_LLESS_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) #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, 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_BUFFERSTRING,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_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_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 /* * Summary of opcode types/flags */ /****************************************************************************** Opcodes that have associated namespace objects (AML_NSOBJECT flag) AML_SCOPE_OP AML_DEVICE_OP AML_THERMAL_ZONE_OP AML_METHOD_OP AML_POWER_RES_OP AML_PROCESSOR_OP AML_FIELD_OP AML_INDEX_FIELD_OP AML_BANK_FIELD_OP AML_NAME_OP AML_ALIAS_OP AML_MUTEX_OP AML_EVENT_OP AML_REGION_OP AML_CREATE_FIELD_OP AML_CREATE_BIT_FIELD_OP AML_CREATE_BYTE_FIELD_OP AML_CREATE_WORD_FIELD_OP AML_CREATE_DWORD_FIELD_OP AML_CREATE_QWORD_FIELD_OP AML_INT_NAMEDFIELD_OP AML_INT_METHODCALL_OP AML_INT_NAMEPATH_OP Opcodes that are "namespace" opcodes (AML_NSOPCODE flag) AML_SCOPE_OP AML_DEVICE_OP AML_THERMAL_ZONE_OP AML_METHOD_OP AML_POWER_RES_OP AML_PROCESSOR_OP AML_FIELD_OP AML_INDEX_FIELD_OP AML_BANK_FIELD_OP AML_NAME_OP AML_ALIAS_OP AML_MUTEX_OP AML_EVENT_OP AML_REGION_OP AML_INT_NAMEDFIELD_OP Opcodes that have an associated namespace node (AML_NSNODE flag) AML_SCOPE_OP AML_DEVICE_OP AML_THERMAL_ZONE_OP AML_METHOD_OP AML_POWER_RES_OP AML_PROCESSOR_OP AML_NAME_OP AML_ALIAS_OP AML_MUTEX_OP AML_EVENT_OP AML_REGION_OP AML_CREATE_FIELD_OP AML_CREATE_BIT_FIELD_OP AML_CREATE_BYTE_FIELD_OP AML_CREATE_WORD_FIELD_OP AML_CREATE_DWORD_FIELD_OP AML_CREATE_QWORD_FIELD_OP AML_INT_NAMEDFIELD_OP AML_INT_METHODCALL_OP AML_INT_NAMEPATH_OP Opcodes that define named ACPI objects (AML_NAMED flag) AML_SCOPE_OP AML_DEVICE_OP AML_THERMAL_ZONE_OP AML_METHOD_OP AML_POWER_RES_OP AML_PROCESSOR_OP AML_NAME_OP AML_ALIAS_OP AML_MUTEX_OP AML_EVENT_OP AML_REGION_OP AML_INT_NAMEDFIELD_OP Opcodes that contain executable AML as part of the definition that must be deferred until needed AML_METHOD_OP AML_VAR_PACKAGE_OP AML_CREATE_FIELD_OP AML_CREATE_BIT_FIELD_OP AML_CREATE_BYTE_FIELD_OP AML_CREATE_WORD_FIELD_OP AML_CREATE_DWORD_FIELD_OP AML_CREATE_QWORD_FIELD_OP AML_REGION_OP AML_BUFFER_OP Field opcodes AML_CREATE_FIELD_OP AML_FIELD_OP AML_INDEX_FIELD_OP AML_BANK_FIELD_OP Field "Create" opcodes AML_CREATE_FIELD_OP AML_CREATE_BIT_FIELD_OP AML_CREATE_BYTE_FIELD_OP AML_CREATE_WORD_FIELD_OP 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. */ const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = { /*! [Begin] no source code translation */ -/* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */ - -/* 00 */ ACPI_OP ("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), -/* 01 */ ACPI_OP ("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), -/* 02 */ ACPI_OP ("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, INTERNAL_TYPE_ALIAS, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 03 */ ACPI_OP ("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 04 */ ACPI_OP ("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), -/* 05 */ ACPI_OP ("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), -/* 06 */ ACPI_OP ("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), -/* 07 */ ACPI_OP ("String", ARGP_STRING_OP, ARGI_STRING_OP, ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), -/* 08 */ ACPI_OP ("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, INTERNAL_TYPE_SCOPE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 09 */ ACPI_OP ("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, ACPI_TYPE_BUFFER, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), -/* 0A */ ACPI_OP ("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), -/* 0B */ ACPI_OP ("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), -/* 0C */ ACPI_OP ("Local0", ARGP_LOCAL0, ARGI_LOCAL0, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 0D */ ACPI_OP ("Local1", ARGP_LOCAL1, ARGI_LOCAL1, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 0E */ ACPI_OP ("Local2", ARGP_LOCAL2, ARGI_LOCAL2, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 0F */ ACPI_OP ("Local3", ARGP_LOCAL3, ARGI_LOCAL3, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 10 */ ACPI_OP ("Local4", ARGP_LOCAL4, ARGI_LOCAL4, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 11 */ ACPI_OP ("Local5", ARGP_LOCAL5, ARGI_LOCAL5, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 12 */ ACPI_OP ("Local6", ARGP_LOCAL6, ARGI_LOCAL6, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 13 */ ACPI_OP ("Local7", ARGP_LOCAL7, ARGI_LOCAL7, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), -/* 14 */ ACPI_OP ("Arg0", ARGP_ARG0, ARGI_ARG0, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 15 */ ACPI_OP ("Arg1", ARGP_ARG1, ARGI_ARG1, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 16 */ ACPI_OP ("Arg2", ARGP_ARG2, ARGI_ARG2, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 17 */ ACPI_OP ("Arg3", ARGP_ARG3, ARGI_ARG3, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 18 */ ACPI_OP ("Arg4", ARGP_ARG4, ARGI_ARG4, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 19 */ ACPI_OP ("Arg5", ARGP_ARG5, ARGI_ARG5, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 1A */ ACPI_OP ("Arg6", ARGP_ARG6, ARGI_ARG6, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), -/* 1B */ ACPI_OP ("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), -/* 1C */ ACPI_OP ("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), -/* 1D */ ACPI_OP ("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 1E */ ACPI_OP ("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), -/* 1F */ ACPI_OP ("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 20 */ ACPI_OP ("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), -/* 21 */ ACPI_OP ("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), -/* 22 */ ACPI_OP ("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 23 */ ACPI_OP ("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_2T_1R, AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT), -/* 24 */ ACPI_OP ("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 25 */ ACPI_OP ("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 26 */ ACPI_OP ("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 27 */ ACPI_OP ("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 28 */ ACPI_OP ("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 29 */ ACPI_OP ("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 2A */ ACPI_OP ("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), -/* 2B */ ACPI_OP ("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 2C */ ACPI_OP ("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 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), -/* 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), -/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), -/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), -/* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), -/* 3B */ ACPI_OP ("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), -/* 3C */ ACPI_OP ("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), -/* 3D */ ACPI_OP ("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), -/* 3E */ ACPI_OP ("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), -/* 3F */ ACPI_OP ("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), -/* 40 */ ACPI_OP ("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), -/* 41 */ ACPI_OP ("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), -/* 42 */ ACPI_OP ("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), -/* 43 */ ACPI_OP ("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), -/* 44 */ ACPI_OP ("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), -/* 45 */ ACPI_OP ("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), +/* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */ + +/* 00 */ ACPI_OP ("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), +/* 01 */ ACPI_OP ("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), +/* 02 */ ACPI_OP ("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 03 */ ACPI_OP ("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 04 */ ACPI_OP ("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 05 */ ACPI_OP ("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 06 */ ACPI_OP ("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 07 */ ACPI_OP ("String", ARGP_STRING_OP, ARGI_STRING_OP, ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 08 */ ACPI_OP ("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 09 */ ACPI_OP ("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, ACPI_TYPE_BUFFER, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), +/* 0A */ ACPI_OP ("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), +/* 0B */ ACPI_OP ("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), +/* 0C */ ACPI_OP ("Local0", ARGP_LOCAL0, ARGI_LOCAL0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 0D */ ACPI_OP ("Local1", ARGP_LOCAL1, ARGI_LOCAL1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 0E */ ACPI_OP ("Local2", ARGP_LOCAL2, ARGI_LOCAL2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 0F */ ACPI_OP ("Local3", ARGP_LOCAL3, ARGI_LOCAL3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 10 */ ACPI_OP ("Local4", ARGP_LOCAL4, ARGI_LOCAL4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 11 */ ACPI_OP ("Local5", ARGP_LOCAL5, ARGI_LOCAL5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 12 */ ACPI_OP ("Local6", ARGP_LOCAL6, ARGI_LOCAL6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 13 */ ACPI_OP ("Local7", ARGP_LOCAL7, ARGI_LOCAL7, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 14 */ ACPI_OP ("Arg0", ARGP_ARG0, ARGI_ARG0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 15 */ ACPI_OP ("Arg1", ARGP_ARG1, ARGI_ARG1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 16 */ ACPI_OP ("Arg2", ARGP_ARG2, ARGI_ARG2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 17 */ ACPI_OP ("Arg3", ARGP_ARG3, ARGI_ARG3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 18 */ ACPI_OP ("Arg4", ARGP_ARG4, ARGI_ARG4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 19 */ ACPI_OP ("Arg5", ARGP_ARG5, ARGI_ARG5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 1A */ ACPI_OP ("Arg6", ARGP_ARG6, ARGI_ARG6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 1B */ ACPI_OP ("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 1C */ ACPI_OP ("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), +/* 1D */ ACPI_OP ("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 1E */ ACPI_OP ("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 1F */ ACPI_OP ("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 20 */ ACPI_OP ("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 21 */ ACPI_OP ("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 22 */ ACPI_OP ("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 23 */ ACPI_OP ("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_2T_1R, AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT), +/* 24 */ ACPI_OP ("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 25 */ ACPI_OP ("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 26 */ ACPI_OP ("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 27 */ ACPI_OP ("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 28 */ ACPI_OP ("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 29 */ ACPI_OP ("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 2A */ ACPI_OP ("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 2B */ ACPI_OP ("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 2C */ ACPI_OP ("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 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), +/* 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), +/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 3B */ ACPI_OP ("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3C */ ACPI_OP ("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3D */ ACPI_OP ("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3E */ ACPI_OP ("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 3F */ ACPI_OP ("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 40 */ ACPI_OP ("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 41 */ ACPI_OP ("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 42 */ ACPI_OP ("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 43 */ ACPI_OP ("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 44 */ ACPI_OP ("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 45 */ ACPI_OP ("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), /* Prefixed opcodes (Two-byte opcodes with a prefix op) */ -/* 46 */ ACPI_OP ("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 47 */ ACPI_OP ("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), -/* 48 */ ACPI_OP ("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), -/* 49 */ ACPI_OP ("CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE), -/* 4A */ ACPI_OP ("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, AML_FLAGS_EXEC_1A_1T_0R), -/* 4B */ ACPI_OP ("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), -/* 4C */ ACPI_OP ("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), -/* 4D */ ACPI_OP ("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), -/* 4E */ ACPI_OP ("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), -/* 4F */ ACPI_OP ("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), -/* 50 */ ACPI_OP ("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), -/* 51 */ ACPI_OP ("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), -/* 52 */ ACPI_OP ("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 53 */ ACPI_OP ("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 54 */ ACPI_OP ("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), -/* 55 */ ACPI_OP ("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), -/* 56 */ ACPI_OP ("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), -/* 57 */ ACPI_OP ("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, AML_FLAGS_EXEC_3A_0T_0R), -/* 58 */ ACPI_OP ("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), -/* 59 */ ACPI_OP ("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, INTERNAL_TYPE_FIELD_DEFN,AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), -/* 5A */ ACPI_OP ("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 5B */ ACPI_OP ("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 5C */ ACPI_OP ("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 5D */ ACPI_OP ("ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 5E */ ACPI_OP ("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, INTERNAL_TYPE_INDEX_FIELD_DEFN,AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), -/* 5F */ ACPI_OP ("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, INTERNAL_TYPE_BANK_FIELD_DEFN,AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), +/* 46 */ ACPI_OP ("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 47 */ ACPI_OP ("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), +/* 48 */ ACPI_OP ("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 49 */ ACPI_OP ("CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE), +/* 4A */ ACPI_OP ("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, AML_FLAGS_EXEC_1A_1T_0R), +/* 4B */ ACPI_OP ("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 4C */ ACPI_OP ("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 4D */ ACPI_OP ("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), +/* 4E */ ACPI_OP ("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 4F */ ACPI_OP ("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), +/* 50 */ ACPI_OP ("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 51 */ ACPI_OP ("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 52 */ ACPI_OP ("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 53 */ ACPI_OP ("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 54 */ ACPI_OP ("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 55 */ ACPI_OP ("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), +/* 56 */ ACPI_OP ("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), +/* 57 */ ACPI_OP ("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, AML_FLAGS_EXEC_3A_0T_0R), +/* 58 */ ACPI_OP ("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), +/* 59 */ ACPI_OP ("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), +/* 5A */ ACPI_OP ("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5B */ ACPI_OP ("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5C */ ACPI_OP ("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5D */ ACPI_OP ("ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5E */ ACPI_OP ("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), +/* 5F */ ACPI_OP ("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), /* Internal opcodes that map to invalid AML opcodes */ -/* 60 */ ACPI_OP ("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), -/* 61 */ ACPI_OP ("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), -/* 62 */ ACPI_OP ("LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), -/* 63 */ ACPI_OP ("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, INTERNAL_TYPE_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE ), -/* 64 */ ACPI_OP ("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, AML_TYPE_METHOD_CALL, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE), -/* 65 */ ACPI_OP ("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, 0), -/* 66 */ ACPI_OP ("-ReservedField-", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), -/* 67 */ ACPI_OP ("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), -/* 68 */ ACPI_OP ("-AccessField-", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), -/* 69 */ ACPI_OP ("-StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), -/* 6A */ ACPI_OP ("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, AML_HAS_ARGS | AML_HAS_RETVAL), -/* 6B */ ACPI_OP ("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, INTERNAL_TYPE_INVALID, AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS), -/* 6C */ ACPI_OP ("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS), -/* 6D */ ACPI_OP ("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS), +/* 60 */ ACPI_OP ("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 61 */ ACPI_OP ("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 62 */ ACPI_OP ("LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 63 */ ACPI_OP ("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE ), +/* 64 */ ACPI_OP ("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, AML_TYPE_METHOD_CALL, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE), +/* 65 */ ACPI_OP ("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, 0), +/* 66 */ ACPI_OP ("-ReservedField-", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 67 */ ACPI_OP ("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), +/* 68 */ ACPI_OP ("-AccessField-", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 69 */ ACPI_OP ("-StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 6A */ ACPI_OP ("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, AML_HAS_ARGS | AML_HAS_RETVAL), +/* 6B */ ACPI_OP ("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS), +/* 6C */ ACPI_OP ("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS), +/* 6D */ ACPI_OP ("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS), /* ACPI 2.0 opcodes */ -/* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), -/* 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), -/* 73 */ ACPI_OP ("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 74 */ ACPI_OP ("ToDecimalString", ARGP_TO_DEC_STR_OP, ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 75 */ ACPI_OP ("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 76 */ ACPI_OP ("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), -/* 77 */ ACPI_OP ("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), -/* 78 */ ACPI_OP ("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), -/* 79 */ ACPI_OP ("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT), -/* 7A */ ACPI_OP ("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), -/* 7B */ ACPI_OP ("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R), -/* 7C */ ACPI_OP ("DataTableRegion", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), -/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, INTERNAL_TYPE_SCOPE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE) +/* 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), +/* 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), +/* 73 */ ACPI_OP ("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 74 */ ACPI_OP ("ToDecimalString", ARGP_TO_DEC_STR_OP, ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 75 */ ACPI_OP ("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 76 */ ACPI_OP ("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 77 */ ACPI_OP ("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 78 */ ACPI_OP ("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 79 */ ACPI_OP ("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT), +/* 7A */ ACPI_OP ("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 7B */ ACPI_OP ("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R), +/* 7C */ ACPI_OP ("DataTableRegion", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE) /*! [End] no source code translation !*/ }; /* * This table is directly indexed by the opcodes, and returns an * index into the table above */ static const UINT8 AcpiGbl_ShortOpIndex[256] = { /* 0 1 2 3 4 5 6 7 */ /* 8 9 A B C D E F */ /* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, /* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK, /* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK, /* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, /* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D, /* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, /* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, /* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, /* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, /* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, /* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, /* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, /* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, /* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30, /* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72, /* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74, /* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A, /* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, /* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK, /* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, }; static const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] = { /* 0 1 2 3 4 5 6 7 */ /* 8 9 A B C D E F */ /* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, /* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, /* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, /* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x30 */ 0x55, 0x56, 0x57, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, /* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 0x88 */ 0x7C, }; /******************************************************************************* * * FUNCTION: AcpiPsGetOpcodeInfo * * PARAMETERS: Opcode - The AML opcode * * RETURN: A pointer to the info about the opcode. NULL if the opcode was * not found in the table. * * DESCRIPTION: Find AML opcode description based on the opcode. * NOTE: This procedure must ALWAYS return a valid pointer! * ******************************************************************************/ const ACPI_OPCODE_INFO * AcpiPsGetOpcodeInfo ( UINT16 Opcode) { ACPI_FUNCTION_NAME ("PsGetOpcodeInfo"); /* * Detect normal 8-bit opcode or extended 16-bit opcode */ switch ((UINT8) (Opcode >> 8)) { 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: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown extended opcode [%X]\n", Opcode)); break; } /* Default is "unknown opcode" */ return (&AcpiGbl_AmlOpInfo [_UNK]); } /******************************************************************************* * * FUNCTION: AcpiPsGetOpcodeName * * PARAMETERS: Opcode - The AML opcode * * RETURN: A pointer to the name of the opcode (ASCII String) * Note: Never returns NULL. * * DESCRIPTION: Translate an opcode into a human-readable string * ******************************************************************************/ NATIVE_CHAR * AcpiPsGetOpcodeName ( UINT16 Opcode) { #ifdef ACPI_DISASSEMBLER const ACPI_OPCODE_INFO *Op; Op = AcpiPsGetOpcodeInfo (Opcode); /* Always guaranteed to return a valid pointer */ return (Op->Name); #else return ("AE_NOT_CONFIGURED"); #endif } diff --git a/sys/contrib/dev/acpica/rscalc.c b/sys/contrib/dev/acpica/rscalc.c index b5b2563243a1..b125ee587a0e 100644 --- a/sys/contrib/dev/acpica/rscalc.c +++ b/sys/contrib/dev/acpica/rscalc.c @@ -1,953 +1,953 @@ /******************************************************************************* * * Module Name: rscalc - Calculate stream and list lengths - * $Revision: 43 $ + * $Revision: 44 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __RSCALC_C__ #include "acpi.h" #include "acresrc.h" #include "amlcode.h" #include "acnamesp.h" #define _COMPONENT ACPI_RESOURCES ACPI_MODULE_NAME ("rscalc") /******************************************************************************* * * FUNCTION: AcpiRsGetByteStreamLength * * PARAMETERS: LinkedList - Pointer to the resource linked list * SizeNeeded - UINT32 pointer of the size buffer needed * to properly return the parsed data * * 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. * ******************************************************************************/ ACPI_STATUS AcpiRsGetByteStreamLength ( ACPI_RESOURCE *LinkedList, ACPI_SIZE *SizeNeeded) { ACPI_SIZE ByteStreamSizeNeeded = 0; ACPI_SIZE SegmentSize; ACPI_RESOURCE_EXT_IRQ *ExIrq = NULL; BOOLEAN Done = FALSE; ACPI_FUNCTION_TRACE ("RsGetByteStreamLength"); while (!Done) { /* * Init the variable that will hold the size to add to the total. */ SegmentSize = 0; 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; 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; 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; case ACPI_RSTYPE_MEM32: /* * 32-Bit Memory Range Resource * For this resource the size is static */ SegmentSize = 20; break; 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 (LinkedList->Data.Address16.ResourceSource.StringPtr) { SegmentSize += LinkedList->Data.Address16.ResourceSource.StringLength; SegmentSize++; } break; 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 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 = 46; if (LinkedList->Data.Address64.ResourceSource.StringPtr) { SegmentSize += LinkedList->Data.Address64.ResourceSource.StringLength; SegmentSize++; } break; 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 (ExIrq && ExIrq->ResourceSource.StringPtr) { SegmentSize += LinkedList->Data.ExtendedIrq.ResourceSource.StringLength; SegmentSize++; } break; default: /* * If we get here, everything is out of sync, * so exit with an error */ return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); } /* switch (LinkedList->Id) */ /* * Update the total */ ByteStreamSizeNeeded += SegmentSize; /* * Point to the next object */ LinkedList = ACPI_PTR_ADD (ACPI_RESOURCE, LinkedList, LinkedList->Length); } /* * This is the data the caller needs */ *SizeNeeded = ByteStreamSizeNeeded; return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiRsGetListLength * * 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 * * 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. * ******************************************************************************/ ACPI_STATUS AcpiRsGetListLength ( UINT8 *ByteStreamBuffer, UINT32 ByteStreamBufferLength, 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_FUNCTION_TRACE ("RsGetListLength"); while (BytesParsed < ByteStreamBufferLength) { /* * The next byte in the stream is the resource type */ ResourceType = AcpiRsGetResourceType (*ByteStreamBuffer); switch (ResourceType) { case ACPI_RDESC_TYPE_MEMORY_24: /* * 24-Bit Memory Resource */ BytesConsumed = 12; StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_MEM24); break; case ACPI_RDESC_TYPE_LARGE_VENDOR: /* * Vendor Defined Resource */ Buffer = ByteStreamBuffer; ++Buffer; ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); BytesConsumed = Temp16 + 3; /* * Ensure a 32-bit boundary for the structure */ Temp16 = (UINT16) ACPI_ROUND_UP_TO_32BITS (Temp16); StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_VENDOR) + (Temp16 * sizeof (UINT8)); break; case ACPI_RDESC_TYPE_MEMORY_32: /* * 32-Bit Memory Range Resource */ BytesConsumed = 20; StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_MEM32); break; case ACPI_RDESC_TYPE_FIXED_MEMORY_32: /* * 32-Bit Fixed Memory Resource */ BytesConsumed = 12; StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_FIXED_MEM32); break; case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE: /* * 64-Bit Address Resource */ Buffer = ByteStreamBuffer; ++Buffer; ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); BytesConsumed = Temp16 + 3; /* * Resource Source Index and Resource Source are * optional elements. Check the length of the * Bytestream. If it is greater than 43, that * means that an Index exists and is followed by * a null termininated string. Therefore, set * the temp variable to the length minus the minimum * byte stream length plus the byte for the Index to * determine the size of the NULL terminiated string. */ if (43 < Temp16) { Temp8 = (UINT8) (Temp16 - 44); } else { Temp8 = 0; } /* * Ensure a 64-bit boundary for the structure */ Temp8 = (UINT8) ACPI_ROUND_UP_TO_64BITS (Temp8); StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS64) + (Temp8 * sizeof (UINT8)); break; case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE: /* * 32-Bit Address Resource */ Buffer = ByteStreamBuffer; ++Buffer; ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); BytesConsumed = Temp16 + 3; /* * Resource Source Index and Resource Source are * optional elements. Check the length of the * Bytestream. If it is greater than 23, that * means that an Index exists and is followed by * a null termininated string. Therefore, set * the temp variable to the length minus the minimum * byte stream length plus the byte for the Index to * determine the size of the NULL terminiated string. */ if (23 < Temp16) { Temp8 = (UINT8) (Temp16 - 24); } else { Temp8 = 0; } /* * 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)); break; case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE: /* * 16-Bit Address Resource */ Buffer = ByteStreamBuffer; ++Buffer; ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); BytesConsumed = Temp16 + 3; /* * Resource Source Index and Resource Source are * optional elements. Check the length of the * Bytestream. If it is greater than 13, that * means that an Index exists and is followed by * a null termininated string. Therefore, set * the temp variable to the length minus the minimum * byte stream length plus the byte for the Index to * determine the size of the NULL terminiated string. */ if (13 < Temp16) { Temp8 = (UINT8) (Temp16 - 14); } else { Temp8 = 0; } /* * Ensure a 32-bit boundary for the structure */ Temp8 = (UINT8) ACPI_ROUND_UP_TO_32BITS (Temp8); StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS16) + (Temp8 * sizeof (UINT8)); break; case ACPI_RDESC_TYPE_EXTENDED_XRUPT: /* * Extended IRQ */ Buffer = ByteStreamBuffer; ++Buffer; ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); 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; /* * 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 termininated string. Therefore, set * the temp variable to the length minus the minimum * byte stream length plus the byte for the Index to * determine the size of the NULL terminiated string. */ if (9 + AdditionalBytes < Temp16) { Temp8 = (UINT8) (Temp16 - (9 + AdditionalBytes)); } else { Temp8 = 0; } /* * Ensure a 32-bit boundary for the structure */ Temp8 = (UINT8) ACPI_ROUND_UP_TO_32BITS (Temp8); StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_EXT_IRQ) + (AdditionalBytes * sizeof (UINT8)) + (Temp8 * sizeof (UINT8)); break; case ACPI_RDESC_TYPE_IRQ_FORMAT: /* * IRQ Resource. * Determine if it there are two or three trailing bytes */ Buffer = ByteStreamBuffer; Temp8 = *Buffer; if(Temp8 & 0x01) { BytesConsumed = 4; } else { BytesConsumed = 3; } /* * Point past the descriptor */ ++Buffer; /* * Look at the number of bits set */ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer); for (Index = 0; Index < 16; Index++) { if (Temp16 & 0x1) { ++NumberOfInterrupts; } Temp16 >>= 1; } StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_IO) + (NumberOfInterrupts * sizeof (UINT32)); break; case ACPI_RDESC_TYPE_DMA_FORMAT: /* * DMA Resource */ Buffer = ByteStreamBuffer; BytesConsumed = 3; /* * Point past the descriptor */ ++Buffer; /* * Look at the number of bits set */ Temp8 = *Buffer; for(Index = 0; Index < 8; Index++) { if(Temp8 & 0x1) { ++NumberOfChannels; } Temp8 >>= 1; } StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_DMA) + (NumberOfChannels * sizeof (UINT32)); break; case ACPI_RDESC_TYPE_START_DEPENDENT: /* * Start Dependent Functions Resource * Determine if it there are two or three trailing bytes */ Buffer = ByteStreamBuffer; Temp8 = *Buffer; if(Temp8 & 0x01) { BytesConsumed = 2; } else { 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_RDESC_TYPE_IO_PORT: /* * IO Port Resource */ BytesConsumed = 8; StructureSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_IO); 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_RDESC_TYPE_SMALL_VENDOR: /* * Vendor Specific Resource */ Buffer = ByteStreamBuffer; Temp8 = *Buffer; Temp8 = (UINT8) (Temp8 & 0x7); BytesConsumed = Temp8 + 1; /* * 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; case ACPI_RDESC_TYPE_END_TAG: /* * End Tag */ BytesConsumed = 2; StructureSize = ACPI_RESOURCE_LENGTH; ByteStreamBufferLength = BytesParsed; break; default: /* * If we get here, everything is out of sync, * so exit with an error */ return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); } /* * Update the return value and counter */ BufferSize += ACPI_ALIGN_RESOURCE_SIZE(StructureSize); BytesParsed += BytesConsumed; /* * Set the byte stream to point to the next resource */ ByteStreamBuffer += BytesConsumed; } /* * This is the data the caller needs */ *SizeNeeded = BufferSize; return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiRsGetPciRoutingTableLength * * PARAMETERS: PackageObject - Pointer to the package object * BufferSizeNeeded - UINT32 pointer of the size buffer * needed to properly return the * parsed data * * RETURN: Status * * DESCRIPTION: Given a package representing a PCI routing table, this * calculates the size of the corresponding linked list of * descriptions. * ******************************************************************************/ ACPI_STATUS AcpiRsGetPciRoutingTableLength ( ACPI_OPERAND_OBJECT *PackageObject, ACPI_SIZE *BufferSizeNeeded) { UINT32 NumberOfElements; ACPI_SIZE TempSizeNeeded = 0; ACPI_OPERAND_OBJECT **TopObjectList; UINT32 Index; ACPI_OPERAND_OBJECT *PackageElement; ACPI_OPERAND_OBJECT **SubObjectList; BOOLEAN NameFound; UINT32 TableIndex; ACPI_FUNCTION_TRACE ("RsGetPciRoutingTableLength"); NumberOfElements = PackageObject->Package.Count; /* * Calculate the size of the return buffer. * The base size is the number of elements * the sizes of the * structures. Additional space for the strings is added below. * The minus one is to subtract the size of the UINT8 Source[1] * member because it is added below. * * But each PRT_ENTRY structure has a pointer to a string and * the size of that string must be found. */ TopObjectList = PackageObject->Package.Elements; for (Index = 0; Index < NumberOfElements; Index++) { /* * Dereference the sub-package */ PackageElement = *TopObjectList; /* * The SubObjectList will now point to an array of the * four IRQ elements: Address, Pin, Source and SourceIndex */ SubObjectList = PackageElement->Package.Elements; /* * 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)) || - ((INTERNAL_TYPE_REFERENCE == 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 */ SubObjectList++; } } TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); /* * Was a String type found? */ if (NameFound) { if (ACPI_GET_OBJECT_TYPE (*SubObjectList) == ACPI_TYPE_STRING) { /* * The length String.Length field includes the * terminating NULL */ TempSizeNeeded += (*SubObjectList)->String.Length; } else { TempSizeNeeded += AcpiNsGetPathnameLength ( (*SubObjectList)->Reference.Node); } } else { /* * If no name was found, then this is a NULL, which is * translated as a UINT32 zero. */ TempSizeNeeded += sizeof (UINT32); } /* Round up the size since each element must be aligned */ TempSizeNeeded = ACPI_ROUND_UP_TO_64BITS (TempSizeNeeded); /* * Point to the next ACPI_OPERAND_OBJECT */ TopObjectList++; } /* * 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/tbconvrt.c b/sys/contrib/dev/acpica/tbconvrt.c index 14d33e46f097..0490767f7990 100644 --- a/sys/contrib/dev/acpica/tbconvrt.c +++ b/sys/contrib/dev/acpica/tbconvrt.c @@ -1,575 +1,573 @@ /****************************************************************************** * * Module Name: tbconvrt - ACPI Table conversion utilities - * $Revision: 43 $ + * $Revision: 45 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __TBCONVRT_C__ #include "acpi.h" #include "actables.h" #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbconvrt") /******************************************************************************* * * FUNCTION: AcpiTbGetTableCount * - * PARAMETERS: + * PARAMETERS: RSDP - Pointer to the RSDP + * RSDT - Pointer to the RSDT/XSDT * - * RETURN: + * RETURN: The number of tables pointed to by the RSDT or XSDT. * - * DESCRIPTION: Calculate the number of tables + * DESCRIPTION: Calculate the number of tables. Automatically handles either + * an RSDT or XSDT. * ******************************************************************************/ UINT32 AcpiTbGetTableCount ( RSDP_DESCRIPTOR *RSDP, ACPI_TABLE_HEADER *RSDT) { UINT32 PointerSize; ACPI_FUNCTION_ENTRY (); #if ACPI_MACHINE_WIDTH != 64 if (RSDP->Revision < 2) { PointerSize = sizeof (UINT32); } else #endif { PointerSize = sizeof (UINT64); } /* * Determine the number of tables pointed to by the RSDT/XSDT. * This is defined by the ACPI Specification to be the number of * pointers contained within the RSDT/XSDT. The size of the pointers * is architecture-dependent. */ return ((RSDT->Length - sizeof (ACPI_TABLE_HEADER)) / PointerSize); } /******************************************************************************* * * FUNCTION: AcpiTbConvertToXsdt * - * PARAMETERS: + * PARAMETERS: TableInfo - Info about the RSDT * - * RETURN: + * RETURN: Status * * DESCRIPTION: Convert an RSDT to an XSDT (internal common format) * ******************************************************************************/ ACPI_STATUS AcpiTbConvertToXsdt ( ACPI_TABLE_DESC *TableInfo) { ACPI_SIZE TableSize; UINT32 i; XSDT_DESCRIPTOR *NewTable; ACPI_FUNCTION_ENTRY (); /* Compute size of the converted XSDT */ TableSize = ((ACPI_SIZE) AcpiGbl_RsdtTableCount * sizeof (UINT64)) + sizeof (ACPI_TABLE_HEADER); /* Allocate an XSDT */ NewTable = ACPI_MEM_CALLOCATE (TableSize); if (!NewTable) { return (AE_NO_MEMORY); } /* Copy the header and set the length */ ACPI_MEMCPY (NewTable, TableInfo->Pointer, sizeof (ACPI_TABLE_HEADER)); NewTable->Header.Length = (UINT32) TableSize; /* Copy the table pointers */ for (i = 0; i < AcpiGbl_RsdtTableCount; i++) { if (AcpiGbl_RSDP->Revision < 2) { ACPI_STORE_ADDRESS (NewTable->TableOffsetEntry[i], ((RSDT_DESCRIPTOR_REV1 *) TableInfo->Pointer)->TableOffsetEntry[i]); } else { NewTable->TableOffsetEntry[i] = ((XSDT_DESCRIPTOR *) TableInfo->Pointer)->TableOffsetEntry[i]; } } /* Delete the original table (either mapped or in a buffer) */ AcpiTbDeleteSingleTable (TableInfo); /* Point the table descriptor to the new table */ TableInfo->Pointer = (ACPI_TABLE_HEADER *) NewTable; - TableInfo->BasePointer = (ACPI_TABLE_HEADER *) NewTable; TableInfo->Length = TableSize; TableInfo->Allocation = ACPI_MEM_ALLOCATED; return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiTbConvertFadt1 * * PARAMETERS: LocalFadt - Pointer to new FADT * OriginalFadt - Pointer to old FADT * * RETURN: Populates LocalFadt * * DESCRIPTION: Convert an ACPI 1.0 FADT to common internal format * ******************************************************************************/ static void AcpiTbConvertFadt1 ( FADT_DESCRIPTOR_REV2 *LocalFadt, FADT_DESCRIPTOR_REV1 *OriginalFadt) { /* ACPI 1.0 FACS */ /* The BIOS stored FADT should agree with Revision 1.0 */ /* * Copy the table header and the common part of the tables. * * The 2.0 table is an extension of the 1.0 table, so the entire 1.0 * table can be copied first, then expand some fields to 64 bits. */ ACPI_MEMCPY (LocalFadt, OriginalFadt, sizeof (FADT_DESCRIPTOR_REV1)); /* Convert table pointers to 64-bit fields */ ACPI_STORE_ADDRESS (LocalFadt->XFirmwareCtrl, LocalFadt->V1_FirmwareCtrl); ACPI_STORE_ADDRESS (LocalFadt->XDsdt, LocalFadt->V1_Dsdt); /* * System Interrupt Model isn't used in ACPI 2.0 (LocalFadt->Reserved1 = 0;) */ /* * This field is set by the OEM to convey the preferred power management * profile to OSPM. It doesn't have any 1.0 equivalence. Since we don't * know what kind of 32-bit system this is, we will use "unspecified". */ LocalFadt->Prefer_PM_Profile = PM_UNSPECIFIED; /* * Processor Performance State Control. This is the value OSPM writes to * the SMI_CMD register to assume processor performance state control * responsibility. There isn't any equivalence in 1.0, leave it zeroed. */ LocalFadt->PstateCnt = 0; /* * Support for the _CST object and C States change notification. * This data item hasn't any 1.0 equivalence so leave it zero. */ LocalFadt->CstCnt = 0; /* * Since there isn't any equivalence in 1.0 and since it highly likely * that a 1.0 system has legacy support. */ LocalFadt->IapcBootArch = BAF_LEGACY_DEVICES; /* * Convert the V1.0 block addresses to V2.0 GAS structures */ ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XPm1aEvtBlk, LocalFadt->Pm1EvtLen, LocalFadt->V1_Pm1aEvtBlk); ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XPm1bEvtBlk, LocalFadt->Pm1EvtLen, LocalFadt->V1_Pm1bEvtBlk); ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XPm1aCntBlk, LocalFadt->Pm1CntLen, LocalFadt->V1_Pm1aCntBlk); ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XPm1bCntBlk, LocalFadt->Pm1CntLen, LocalFadt->V1_Pm1bCntBlk); ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XPm2CntBlk, LocalFadt->Pm2CntLen, LocalFadt->V1_Pm2CntBlk); ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XPmTmrBlk, LocalFadt->PmTmLen, LocalFadt->V1_PmTmrBlk); ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XGpe0Blk, LocalFadt->Gpe0BlkLen, LocalFadt->V1_Gpe0Blk); ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XGpe1Blk, LocalFadt->Gpe1BlkLen, LocalFadt->V1_Gpe1Blk); } /******************************************************************************* * * FUNCTION: AcpiTbConvertFadt2 * * PARAMETERS: LocalFadt - Pointer to new FADT * OriginalFadt - Pointer to old FADT * * RETURN: Populates LocalFadt * * DESCRIPTION: Convert an ACPI 2.0 FADT to common internal format. * Handles optional "X" fields. * ******************************************************************************/ static void AcpiTbConvertFadt2 ( FADT_DESCRIPTOR_REV2 *LocalFadt, FADT_DESCRIPTOR_REV2 *OriginalFadt) { /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */ ACPI_MEMCPY (LocalFadt, OriginalFadt, sizeof (FADT_DESCRIPTOR_REV2)); /* * "X" fields are optional extensions to the original V1.0 fields, so * we must selectively expand V1.0 fields if the corresponding X field * is zero. */ if (!(ACPI_GET_ADDRESS (LocalFadt->XFirmwareCtrl))) { ACPI_STORE_ADDRESS (LocalFadt->XFirmwareCtrl, LocalFadt->V1_FirmwareCtrl); } if (!(ACPI_GET_ADDRESS (LocalFadt->XDsdt))) { ACPI_STORE_ADDRESS (LocalFadt->XDsdt, LocalFadt->V1_Dsdt); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1aEvtBlk.Address))) { ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XPm1aEvtBlk, LocalFadt->Pm1EvtLen, LocalFadt->V1_Pm1aEvtBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1bEvtBlk.Address))) { ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XPm1bEvtBlk, LocalFadt->Pm1EvtLen, LocalFadt->V1_Pm1bEvtBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1aCntBlk.Address))) { ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XPm1aCntBlk, LocalFadt->Pm1CntLen, LocalFadt->V1_Pm1aCntBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPm1bCntBlk.Address))) { ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XPm1bCntBlk, LocalFadt->Pm1CntLen, LocalFadt->V1_Pm1bCntBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPm2CntBlk.Address))) { ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XPm2CntBlk, LocalFadt->Pm2CntLen, LocalFadt->V1_Pm2CntBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XPmTmrBlk.Address))) { ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XPmTmrBlk, LocalFadt->PmTmLen, LocalFadt->V1_PmTmrBlk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XGpe0Blk.Address))) { ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XGpe0Blk, LocalFadt->Gpe0BlkLen, LocalFadt->V1_Gpe0Blk); } if (!(ACPI_GET_ADDRESS (LocalFadt->XGpe1Blk.Address))) { ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XGpe1Blk, LocalFadt->Gpe1BlkLen, LocalFadt->V1_Gpe1Blk); } } /******************************************************************************* * * FUNCTION: AcpiTbConvertTableFadt * * PARAMETERS: None * * RETURN: Status * - * DESCRIPTION: - * Converts a BIOS supplied ACPI 1.0 FADT to an intermediate - * ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply - * copied to the intermediate FADT. The ACPI CA software uses this - * intermediate FADT. Thus a significant amount of special #ifdef - * type codeing is saved. This intermediate FADT will need to be - * freed at some point. + * DESCRIPTION: Converts a BIOS supplied ACPI 1.0 FADT to a local + * ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply + * copied to the local FADT. The ACPI CA software uses this + * local FADT. Thus a significant amount of special #ifdef + * type codeing is saved. * ******************************************************************************/ ACPI_STATUS AcpiTbConvertTableFadt (void) { FADT_DESCRIPTOR_REV2 *LocalFadt; ACPI_TABLE_DESC *TableDesc; ACPI_FUNCTION_TRACE ("TbConvertTableFadt"); /* * AcpiGbl_FADT is valid * Allocate and zero the 2.0 FADT buffer */ LocalFadt = ACPI_MEM_CALLOCATE (sizeof (FADT_DESCRIPTOR_REV2)); if (LocalFadt == NULL) { return_ACPI_STATUS (AE_NO_MEMORY); } /* * FADT length and version validation. The table must be at least as * long as the version 1.0 FADT */ if (AcpiGbl_FADT->Header.Length < sizeof (FADT_DESCRIPTOR_REV1)) { ACPI_REPORT_ERROR (("Invalid FADT table length: 0x%X\n", AcpiGbl_FADT->Header.Length)); return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); } if (AcpiGbl_FADT->Header.Revision >= FADT2_REVISION_ID) { if (AcpiGbl_FADT->Header.Length < sizeof (FADT_DESCRIPTOR_REV2)) { /* 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->Header.Length, AcpiGbl_FADT->Header.Revision)); AcpiTbConvertFadt1 (LocalFadt, (void *) AcpiGbl_FADT); } else { /* Valid V2.0 table */ AcpiTbConvertFadt2 (LocalFadt, AcpiGbl_FADT); } } else { /* Valid V1.0 table */ AcpiTbConvertFadt1 (LocalFadt, (void *) AcpiGbl_FADT); } /* * Global FADT pointer will point to the new common V2.0 FADT */ AcpiGbl_FADT = LocalFadt; AcpiGbl_FADT->Header.Length = sizeof (FADT_DESCRIPTOR); /* Free the original table */ TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_FADT]; AcpiTbDeleteSingleTable (TableDesc); /* Install the new table */ TableDesc->Pointer = (ACPI_TABLE_HEADER *) AcpiGbl_FADT; - TableDesc->BasePointer = AcpiGbl_FADT; TableDesc->Allocation = ACPI_MEM_ALLOCATED; TableDesc->Length = sizeof (FADT_DESCRIPTOR_REV2); /* Dump the entire FADT */ ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Hex dump of common internal FADT, size %d (%X)\n", AcpiGbl_FADT->Header.Length, AcpiGbl_FADT->Header.Length)); ACPI_DUMP_BUFFER ((UINT8 *) (AcpiGbl_FADT), AcpiGbl_FADT->Header.Length); return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiTbConvertTableFacs * * PARAMETERS: TableInfo - Info for currently installad FACS * * RETURN: Status * * DESCRIPTION: Convert ACPI 1.0 and ACPI 2.0 FACS to a common internal * table format. * ******************************************************************************/ ACPI_STATUS AcpiTbBuildCommonFacs ( ACPI_TABLE_DESC *TableInfo) { ACPI_FUNCTION_TRACE ("TbBuildCommonFacs"); /* Absolute minimum length is 24, but the ACPI spec says 64 */ if (AcpiGbl_FACS->Length < 24) { 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", AcpiGbl_FACS->Length)); } /* Copy fields to the new FACS */ AcpiGbl_CommonFACS.GlobalLock = &(AcpiGbl_FACS->GlobalLock); if ((AcpiGbl_RSDP->Revision < 2) || (AcpiGbl_FACS->Length < 32) || (!(ACPI_GET_ADDRESS (AcpiGbl_FACS->XFirmwareWakingVector)))) { /* 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.VectorWidth = 32; } else { /* ACPI 2.0 FACS with valid X_ field */ AcpiGbl_CommonFACS.FirmwareWakingVector = &AcpiGbl_FACS->XFirmwareWakingVector; AcpiGbl_CommonFACS.VectorWidth = 64; } return_ACPI_STATUS (AE_OK); } diff --git a/sys/contrib/dev/acpica/tbgetall.c b/sys/contrib/dev/acpica/tbgetall.c index 690a999d5dd6..fd7184d29fe4 100644 --- a/sys/contrib/dev/acpica/tbgetall.c +++ b/sys/contrib/dev/acpica/tbgetall.c @@ -1,396 +1,403 @@ /****************************************************************************** * * Module Name: tbgetall - Get all required ACPI tables - * $Revision: 2 $ + * $Revision: 3 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __TBGETALL_C__ #include "acpi.h" #include "actables.h" #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbgetall") /******************************************************************************* * * FUNCTION: AcpiTbGetPrimaryTable * * PARAMETERS: Address - Physical address of table to retrieve * *TableInfo - Where the table info is returned * * RETURN: Status * * DESCRIPTION: Maps the physical address of table into a logical address * ******************************************************************************/ ACPI_STATUS AcpiTbGetPrimaryTable ( ACPI_POINTER *Address, ACPI_TABLE_DESC *TableInfo) { ACPI_STATUS Status; ACPI_TABLE_HEADER Header; ACPI_FUNCTION_TRACE ("TbGetPrimaryTable"); /* Ignore a NULL address in the RSDT */ if (!Address->Pointer.Value) { return_ACPI_STATUS (AE_OK); } /* * Get the header in order to get signature and table size */ Status = AcpiTbGetTableHeader (Address, &Header); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Clear the TableInfo */ ACPI_MEMSET (TableInfo, 0, sizeof (ACPI_TABLE_DESC)); /* * Check the table signature and make sure it is recognized. * Also checks the header checksum */ TableInfo->Pointer = &Header; Status = AcpiTbRecognizeTable (TableInfo, ACPI_TABLE_PRIMARY); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Get the entire table */ Status = AcpiTbGetTableBody (Address, &Header, TableInfo); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Install the table */ Status = AcpiTbInstallTable (TableInfo); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiTbGetSecondaryTable * * PARAMETERS: Address - Physical address of table to retrieve * *TableInfo - Where the table info is returned * * RETURN: Status * * DESCRIPTION: Maps the physical address of table into a logical address * ******************************************************************************/ ACPI_STATUS AcpiTbGetSecondaryTable ( ACPI_POINTER *Address, ACPI_STRING Signature, ACPI_TABLE_DESC *TableInfo) { ACPI_STATUS Status; ACPI_TABLE_HEADER Header; ACPI_FUNCTION_TRACE_STR ("TbGetSecondaryTable", Signature); /* Get the header in order to match the signature */ Status = AcpiTbGetTableHeader (Address, &Header); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Signature must match request */ if (ACPI_STRNCMP (Header.Signature, Signature, ACPI_NAME_SIZE)) { ACPI_REPORT_ERROR (("Incorrect table signature - wanted [%s] found [%4.4s]\n", Signature, Header.Signature)); return_ACPI_STATUS (AE_BAD_SIGNATURE); } /* * Check the table signature and make sure it is recognized. * Also checks the header checksum */ TableInfo->Pointer = &Header; Status = AcpiTbRecognizeTable (TableInfo, ACPI_TABLE_SECONDARY); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Get the entire table */ Status = AcpiTbGetTableBody (Address, &Header, TableInfo); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Install the table */ Status = AcpiTbInstallTable (TableInfo); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiTbGetRequiredTables * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Load and validate tables other than the RSDT. The RSDT must * already be loaded and validated. * * Get the minimum set of ACPI tables, namely: * * 1) FADT (via RSDT in loop below) * 2) FACS (via FADT) * 3) DSDT (via FADT) * ******************************************************************************/ ACPI_STATUS AcpiTbGetRequiredTables ( void) { ACPI_STATUS Status = AE_OK; UINT32 i; ACPI_TABLE_DESC TableInfo; ACPI_POINTER Address; ACPI_FUNCTION_TRACE ("TbGetRequiredTables"); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%d ACPI tables in RSDT\n", AcpiGbl_RsdtTableCount)); Address.PointerType = AcpiGbl_TableFlags | ACPI_LOGICAL_ADDRESSING; /* * Loop through all table pointers found in RSDT. * This will NOT include the FACS and DSDT - we must get * them after the loop. * * The only tables we are interested in getting here is the FADT and * any SSDTs. */ for (i = 0; i < AcpiGbl_RsdtTableCount; i++) { /* Get the table addresss from the common internal XSDT */ Address.Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_XSDT->TableOffsetEntry[i]); /* * Get the tables needed by this subsystem (FADT and any SSDTs). * NOTE: All other tables are completely ignored at this time. */ - AcpiTbGetPrimaryTable (&Address, &TableInfo); + Status = AcpiTbGetPrimaryTable (&Address, &TableInfo); + if ((Status != AE_OK) && (Status != AE_TABLE_NOT_SUPPORTED)) + { + ACPI_REPORT_WARNING (("%s, while getting table at %8.8X%8.8X\n", + AcpiFormatException (Status), + ACPI_HIDWORD (Address.Pointer.Value), + ACPI_LODWORD (Address.Pointer.Value))); + } } /* We must have a FADT to continue */ if (!AcpiGbl_FADT) { ACPI_REPORT_ERROR (("No FADT present in RSDT/XSDT\n")); return_ACPI_STATUS (AE_NO_ACPI_TABLES); } /* * 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")); return_ACPI_STATUS (Status); } /* * Get the FACS (Pointed to by the FADT) */ Address.Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_FADT->XFirmwareCtrl); Status = AcpiTbGetSecondaryTable (&Address, FACS_SIG, &TableInfo); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("Could not get/install the FACS, %s\n", AcpiFormatException (Status))); return_ACPI_STATUS (Status); } /* * Create the common FACS pointer table * (Contains pointers to the original table) */ Status = AcpiTbBuildCommonFacs (&TableInfo); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Get/install the DSDT (Pointed to by the FADT) */ Address.Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_FADT->XDsdt); Status = AcpiTbGetSecondaryTable (&Address, DSDT_SIG, &TableInfo); if (ACPI_FAILURE (Status)) { ACPI_REPORT_ERROR (("Could not get/install the DSDT\n")); return_ACPI_STATUS (Status); } /* Set Integer Width (32/64) based upon DSDT revision */ AcpiUtSetIntegerWidth (AcpiGbl_DSDT->Revision); /* Dump the entire DSDT */ ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n", AcpiGbl_DSDT->Length, AcpiGbl_DSDT->Length, AcpiGbl_IntegerBitWidth)); ACPI_DUMP_BUFFER ((UINT8 *) AcpiGbl_DSDT, AcpiGbl_DSDT->Length); /* Always delete the RSDP mapping, we are done with it */ AcpiTbDeleteAcpiTable (ACPI_TABLE_RSDP); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/tbinstal.c b/sys/contrib/dev/acpica/tbinstal.c index 6f7a213a5ab1..d4a28d1ea15c 100644 --- a/sys/contrib/dev/acpica/tbinstal.c +++ b/sys/contrib/dev/acpica/tbinstal.c @@ -1,683 +1,682 @@ /****************************************************************************** * * Module Name: tbinstal - ACPI table installation and removal - * $Revision: 63 $ + * $Revision: 64 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __TBINSTAL_C__ #include "acpi.h" #include "actables.h" #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbinstal") /******************************************************************************* * * FUNCTION: AcpiTbMatchSignature * * PARAMETERS: Signature - Table signature to match * TableInfo - Return data * * RETURN: Status * * DESCRIPTION: Compare signature against the list of "ACPI-subsystem-owned" * tables (DSDT/FADT/SSDT, etc.) Returns the TableTypeID on match. * ******************************************************************************/ ACPI_STATUS AcpiTbMatchSignature ( NATIVE_CHAR *Signature, ACPI_TABLE_DESC *TableInfo, UINT8 SearchType) { NATIVE_UINT i; ACPI_FUNCTION_TRACE ("TbMatchSignature"); /* * Search for a signature match among the known table types */ for (i = 0; i < NUM_ACPI_TABLES; i++) { if ((AcpiGbl_AcpiTableData[i].Flags & ACPI_TABLE_TYPE_MASK) != SearchType) { continue; } if (!ACPI_STRNCMP (Signature, AcpiGbl_AcpiTableData[i].Signature, AcpiGbl_AcpiTableData[i].SigLength)) { /* Found a signature match, return index if requested */ if (TableInfo) { TableInfo->Type = (UINT8) i; } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Table [%4.4s] matched and is a required ACPI table\n", (char *) AcpiGbl_AcpiTableData[i].Signature)); return_ACPI_STATUS (AE_OK); } } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Table [%4.4s] is not a required ACPI table - ignored\n", (char *) Signature)); return_ACPI_STATUS (AE_TABLE_NOT_SUPPORTED); } /******************************************************************************* * * FUNCTION: AcpiTbInstallTable * * PARAMETERS: TableInfo - Return value from AcpiTbGetTableBody * * 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. * ******************************************************************************/ ACPI_STATUS AcpiTbInstallTable ( ACPI_TABLE_DESC *TableInfo) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("TbInstallTable"); /* Lock tables while installing */ 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))); return_ACPI_STATUS (Status); } /* 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 [%s], %s\n", TableInfo->Pointer->Signature, AcpiFormatException (Status))); } ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "%s located at %p\n", AcpiGbl_AcpiTableData[TableInfo->Type].Name, TableInfo->Pointer)); (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiTbRecognizeTable * * PARAMETERS: TableInfo - Return value from AcpiTbGetTableBody * * RETURN: Status * * DESCRIPTION: Check a table signature for a match against known table types * * NOTE: All table pointers are validated as follows: * 1) Table pointer must point to valid physical memory * 2) Signature must be 4 ASCII chars, even if we don't recognize the * name * 3) Table must be readable for length specified in the header * 4) Table checksum must be valid (with the exception of the FACS * which has no checksum for some odd reason) * ******************************************************************************/ ACPI_STATUS AcpiTbRecognizeTable ( ACPI_TABLE_DESC *TableInfo, UINT8 SearchType) { ACPI_TABLE_HEADER *TableHeader; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("TbRecognizeTable"); /* Ensure that we have a valid table pointer */ TableHeader = (ACPI_TABLE_HEADER *) TableInfo->Pointer; if (!TableHeader) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* * We only "recognize" a limited number of ACPI tables -- namely, the * ones that are used by the subsystem (DSDT, FADT, etc.) * * An AE_TABLE_NOT_SUPPORTED means that the table was not recognized. * 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); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiTbValidateTableHeader (TableHeader); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Return the table type and length via the info struct */ TableInfo->Length = (ACPI_SIZE) TableHeader->Length; return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiTbInitTableDescriptor * * PARAMETERS: TableType - The type of the table * TableInfo - A table info struct * * RETURN: None. * * DESCRIPTION: Install a table into the global data structs. * ******************************************************************************/ ACPI_STATUS AcpiTbInitTableDescriptor ( ACPI_TABLE_TYPE TableType, ACPI_TABLE_DESC *TableInfo) { ACPI_TABLE_DESC *ListHead; ACPI_TABLE_DESC *TableDesc; ACPI_FUNCTION_TRACE_U32 ("TbInitTableDescriptor", TableType); /* * Install the table into the global data structure */ ListHead = &AcpiGbl_AcpiTables[TableType]; TableDesc = ListHead; /* * Two major types of tables: 1) Only one instance is allowed. This * includes most ACPI tables such as the DSDT. 2) Multiple instances of * the table are allowed. This includes SSDT and PSDTs. */ if (ACPI_IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags)) { /* * Only one table allowed, and a table has alread been installed * at this location, so return an error. */ if (ListHead->Pointer) { return_ACPI_STATUS (AE_ALREADY_EXISTS); } TableDesc->Count = 1; TableDesc->Prev = NULL; TableDesc->Next = NULL; } else { /* * Multiple tables allowed for this table type, we must link * the new table in to the list of tables of this type. */ if (ListHead->Pointer) { TableDesc = ACPI_MEM_CALLOCATE (sizeof (ACPI_TABLE_DESC)); if (!TableDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } ListHead->Count++; /* Update the original previous */ ListHead->Prev->Next = TableDesc; /* Update new entry */ TableDesc->Prev = ListHead->Prev; TableDesc->Next = ListHead; /* Update list head */ ListHead->Prev = TableDesc; } else { TableDesc->Count = 1; } } /* Common initialization of the table descriptor */ TableDesc->Type = TableInfo->Type; TableDesc->Pointer = TableInfo->Pointer; - TableDesc->BasePointer = TableInfo->BasePointer; TableDesc->Length = TableInfo->Length; TableDesc->Allocation = TableInfo->Allocation; 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; /* * Set the appropriate global pointer (if there is one) to point to the * newly installed table */ if (AcpiGbl_AcpiTableData[TableType].GlobalPtr) { *(AcpiGbl_AcpiTableData[TableType].GlobalPtr) = TableInfo->Pointer; } /* Return Data */ TableInfo->TableId = TableDesc->TableId; TableInfo->InstalledDesc = TableDesc; return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiTbDeleteAcpiTables * * PARAMETERS: None. * * RETURN: None. * * DESCRIPTION: Delete all internal ACPI tables * ******************************************************************************/ void AcpiTbDeleteAcpiTables (void) { ACPI_TABLE_TYPE Type; /* * Free memory allocated for ACPI tables * Memory can either be mapped or allocated */ for (Type = 0; Type < NUM_ACPI_TABLES; Type++) { AcpiTbDeleteAcpiTable (Type); } } /******************************************************************************* * * FUNCTION: AcpiTbDeleteAcpiTable * * PARAMETERS: Type - The table type to be deleted * * RETURN: None. * * DESCRIPTION: Delete an internal ACPI table * Locks the ACPI table mutex * ******************************************************************************/ void AcpiTbDeleteAcpiTable ( ACPI_TABLE_TYPE Type) { ACPI_FUNCTION_TRACE_U32 ("TbDeleteAcpiTable", Type); if (Type > ACPI_TABLE_MAX) { return_VOID; } if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_TABLES))) { return; } /* Clear the appropriate "typed" global table pointer */ switch (Type) { case ACPI_TABLE_RSDP: AcpiGbl_RSDP = NULL; break; case ACPI_TABLE_DSDT: AcpiGbl_DSDT = NULL; break; case ACPI_TABLE_FADT: AcpiGbl_FADT = NULL; break; case ACPI_TABLE_FACS: AcpiGbl_FACS = NULL; break; case ACPI_TABLE_XSDT: AcpiGbl_XSDT = NULL; break; case ACPI_TABLE_SSDT: case ACPI_TABLE_PSDT: default: break; } /* Free the table */ AcpiTbFreeAcpiTablesOfType (&AcpiGbl_AcpiTables[Type]); (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); return_VOID; } /******************************************************************************* * * FUNCTION: AcpiTbFreeAcpiTablesOfType * * PARAMETERS: TableInfo - A table info struct * * RETURN: None. * * DESCRIPTION: Free the memory associated with an internal ACPI table * Table mutex should be locked. * ******************************************************************************/ void AcpiTbFreeAcpiTablesOfType ( ACPI_TABLE_DESC *ListHead) { ACPI_TABLE_DESC *TableDesc; UINT32 Count; UINT32 i; ACPI_FUNCTION_TRACE_PTR ("TbFreeAcpiTablesOfType", ListHead); /* Get the head of the list */ TableDesc = ListHead; Count = ListHead->Count; /* * Walk the entire list, deleting both the allocated tables * and the table descriptors */ for (i = 0; i < Count; i++) { TableDesc = AcpiTbUninstallTable (TableDesc); } return_VOID; } /******************************************************************************* * * FUNCTION: AcpiTbDeleteSingleTable * * PARAMETERS: TableInfo - A table info struct * * RETURN: None. * * DESCRIPTION: Low-level free for a single ACPI table. Handles cases where * the table was allocated a buffer or was mapped. * ******************************************************************************/ void AcpiTbDeleteSingleTable ( ACPI_TABLE_DESC *TableDesc) { if (!TableDesc) { return; } if (TableDesc->Pointer) { /* Valid table, determine type of memory allocation */ switch (TableDesc->Allocation) { case ACPI_MEM_NOT_ALLOCATED: break; case ACPI_MEM_ALLOCATED: - ACPI_MEM_FREE (TableDesc->BasePointer); + ACPI_MEM_FREE (TableDesc->Pointer); break; case ACPI_MEM_MAPPED: - AcpiOsUnmapMemory (TableDesc->BasePointer, TableDesc->Length); + AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length); break; default: break; } } } /******************************************************************************* * * FUNCTION: AcpiTbUninstallTable * * PARAMETERS: TableInfo - A table info struct * * RETURN: Pointer to the next table in the list (of same type) * * DESCRIPTION: Free the memory associated with an internal ACPI table that * is either installed or has never been installed. * Table mutex should be locked. * ******************************************************************************/ ACPI_TABLE_DESC * AcpiTbUninstallTable ( ACPI_TABLE_DESC *TableDesc) { ACPI_TABLE_DESC *NextDesc; ACPI_FUNCTION_TRACE_PTR ("AcpiTbUninstallTable", TableDesc); if (!TableDesc) { return_PTR (NULL); } /* Unlink the descriptor */ if (TableDesc->Prev) { TableDesc->Prev->Next = TableDesc->Next; } if (TableDesc->Next) { TableDesc->Next->Prev = TableDesc->Prev; } /* Free the memory allocated for the table itself */ AcpiTbDeleteSingleTable (TableDesc); /* Free the table descriptor (Don't delete the list head, tho) */ if ((TableDesc->Prev) == (TableDesc->Next)) { NextDesc = NULL; /* Clear the list head */ TableDesc->Pointer = NULL; TableDesc->Length = 0; TableDesc->Count = 0; } else { /* Free the table descriptor */ NextDesc = TableDesc->Next; ACPI_MEM_FREE (TableDesc); } return_PTR (NextDesc); } diff --git a/sys/contrib/dev/acpica/tbrsdt.c b/sys/contrib/dev/acpica/tbrsdt.c index 66c14cbe67f3..9876f6131b69 100644 --- a/sys/contrib/dev/acpica/tbrsdt.c +++ b/sys/contrib/dev/acpica/tbrsdt.c @@ -1,407 +1,406 @@ /****************************************************************************** * * Module Name: tbrsdt - ACPI RSDT table utilities - * $Revision: 3 $ + * $Revision: 4 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __TBRSDT_C__ #include "acpi.h" #include "actables.h" #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbrsdt") /******************************************************************************* * * FUNCTION: AcpiTbVerifyRsdp * * PARAMETERS: Address - RSDP (Pointer to RSDT) * * RETURN: Status * * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) * ******************************************************************************/ ACPI_STATUS AcpiTbVerifyRsdp ( ACPI_POINTER *Address) { ACPI_TABLE_DESC TableInfo; ACPI_STATUS Status; RSDP_DESCRIPTOR *Rsdp; ACPI_FUNCTION_TRACE ("TbVerifyRsdp"); switch (Address->PointerType) { case ACPI_LOGICAL_POINTER: Rsdp = Address->Pointer.Logical; break; case ACPI_PHYSICAL_POINTER: /* * Obtain access to the RSDP structure */ Status = AcpiOsMapMemory (Address->Pointer.Physical, sizeof (RSDP_DESCRIPTOR), (void **) &Rsdp); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } break; default: return_ACPI_STATUS (AE_BAD_PARAMETER); } /* * The signature and checksum must both be correct */ if (ACPI_STRNCMP ((NATIVE_CHAR *) Rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { /* Nope, BAD Signature */ Status = AE_BAD_SIGNATURE; goto Cleanup; } /* Check the standard checksum */ if (AcpiTbChecksum (Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { 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); TableInfo.Length = sizeof (RSDP_DESCRIPTOR); TableInfo.Allocation = ACPI_MEM_MAPPED; - TableInfo.BasePointer = Rsdp; /* Save the table pointers and allocation info */ Status = AcpiTbInitTableDescriptor (ACPI_TABLE_RSDP, &TableInfo); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Save the RSDP in a global for easy access */ AcpiGbl_RSDP = ACPI_CAST_PTR (RSDP_DESCRIPTOR, TableInfo.Pointer); return_ACPI_STATUS (Status); /* Error exit */ Cleanup: if (AcpiGbl_TableFlags & ACPI_PHYSICAL_POINTER) { AcpiOsUnmapMemory (Rsdp, sizeof (RSDP_DESCRIPTOR)); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiTbGetRsdtAddress * * PARAMETERS: None * * RETURN: RSDT physical address * * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the * version of the RSDP * ******************************************************************************/ void AcpiTbGetRsdtAddress ( ACPI_POINTER *OutAddress) { ACPI_FUNCTION_ENTRY (); 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) { OutAddress->Pointer.Value = AcpiGbl_RSDP->RsdtPhysicalAddress; } else { OutAddress->Pointer.Value = ACPI_GET_ADDRESS (AcpiGbl_RSDP->XsdtPhysicalAddress); } } /******************************************************************************* * * FUNCTION: AcpiTbValidateRsdt * * PARAMETERS: TablePtr - Addressable pointer to the RSDT. * * RETURN: Status * * DESCRIPTION: Validate signature for the RSDT or XSDT * ******************************************************************************/ ACPI_STATUS AcpiTbValidateRsdt ( ACPI_TABLE_HEADER *TablePtr) { int NoMatch; ACPI_FUNCTION_NAME ("TbValidateRsdt"); /* * 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) { NoMatch = ACPI_STRNCMP ((char *) TablePtr, RSDT_SIG, sizeof (RSDT_SIG) -1); } else { NoMatch = ACPI_STRNCMP ((char *) TablePtr, XSDT_SIG, sizeof (XSDT_SIG) -1); } if (NoMatch) { /* Invalid RSDT or XSDT signature */ ACPI_REPORT_ERROR (("Invalid signature where RSDP indicates RSDT/XSDT should be located\n")); ACPI_DUMP_BUFFER (AcpiGbl_RSDP, 20); ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, "RSDT/XSDT signature at %X (%p) is invalid\n", AcpiGbl_RSDP->RsdtPhysicalAddress, (void *) (NATIVE_UINT) AcpiGbl_RSDP->RsdtPhysicalAddress)); return (AE_BAD_SIGNATURE); } return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiTbGetTableRsdt * * PARAMETERS: None * * RETURN: Status * * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) * ******************************************************************************/ ACPI_STATUS AcpiTbGetTableRsdt ( void) { ACPI_TABLE_DESC TableInfo; ACPI_STATUS Status; ACPI_POINTER Address; ACPI_FUNCTION_TRACE ("TbGetTableRsdt"); /* Get the RSDT/XSDT via the RSDP */ AcpiTbGetRsdtAddress (&Address); Status = AcpiTbGetTable (&Address, &TableInfo); if (ACPI_FAILURE (Status)) { 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", AcpiGbl_RSDP, ACPI_HIDWORD (Address.Pointer.Value), ACPI_LODWORD (Address.Pointer.Value))); /* Check the RSDT or XSDT signature */ Status = AcpiTbValidateRsdt (TableInfo.Pointer); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Get the number of tables defined in the RSDT or XSDT */ AcpiGbl_RsdtTableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, TableInfo.Pointer); /* Convert and/or copy to an XSDT structure */ Status = AcpiTbConvertToXsdt (&TableInfo); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Save the table pointers and allocation info */ Status = AcpiTbInitTableDescriptor (ACPI_TABLE_XSDT, &TableInfo); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } AcpiGbl_XSDT = (XSDT_DESCRIPTOR *) TableInfo.Pointer; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "XSDT located at %p\n", AcpiGbl_XSDT)); return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/tbutils.c b/sys/contrib/dev/acpica/tbutils.c index a1334b6021c6..773bd19c28e5 100644 --- a/sys/contrib/dev/acpica/tbutils.c +++ b/sys/contrib/dev/acpica/tbutils.c @@ -1,323 +1,323 @@ /****************************************************************************** * * Module Name: tbutils - Table manipulation utilities - * $Revision: 56 $ + * $Revision: 57 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __TBUTILS_C__ #include "acpi.h" #include "actables.h" #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbutils") /******************************************************************************* * * 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 **TableDesc) { UINT32 i; ACPI_TABLE_DESC *ListHead; ACPI_FUNCTION_NAME ("TbHandleToObject"); for (i = 0; i < ACPI_TABLE_MAX; i++) { ListHead = &AcpiGbl_AcpiTables[i]; do { if (ListHead->TableId == TableId) { *TableDesc = ListHead; return (AE_OK); } ListHead = ListHead->Next; } while (ListHead != &AcpiGbl_AcpiTables[i]); } ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "TableId=%X does not exist\n", TableId)); return (AE_BAD_PARAMETER); } /******************************************************************************* * * FUNCTION: AcpiTbValidateTableHeader * * PARAMETERS: TableHeader - Logical pointer to the table * * RETURN: Status * * DESCRIPTION: Check an ACPI table header for validity * * NOTE: Table pointers are validated as follows: * 1) Table pointer must point to valid physical memory * 2) Signature must be 4 ASCII chars, even if we don't recognize the * name * 3) Table must be readable for length specified in the header * 4) Table checksum must be valid (with the exception of the FACS * which has no checksum because it contains variable fields) * ******************************************************************************/ ACPI_STATUS AcpiTbValidateTableHeader ( ACPI_TABLE_HEADER *TableHeader) { ACPI_NAME Signature; ACPI_FUNCTION_NAME ("TbValidateTableHeader"); /* Verify that this is a valid address */ if (!AcpiOsReadable (TableHeader, sizeof (ACPI_TABLE_HEADER))) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Cannot read table header at %p\n", TableHeader)); return (AE_BAD_ADDRESS); } /* Ensure that the signature is 4 ASCII characters */ ACPI_MOVE_UNALIGNED32_TO_32 (&Signature, TableHeader->Signature); if (!AcpiUtValidAcpiName (Signature)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Table signature at %p [%p] has invalid characters\n", TableHeader, &Signature)); ACPI_REPORT_WARNING (("Invalid table signature found: [%4.4s]\n", (char *) &Signature)); ACPI_DUMP_BUFFER (TableHeader, sizeof (ACPI_TABLE_HEADER)); return (AE_BAD_SIGNATURE); } /* Validate the table length */ if (TableHeader->Length < sizeof (ACPI_TABLE_HEADER)) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid length in table header %p name %4.4s\n", TableHeader, (char *) &Signature)); 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); } return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiTbVerifyTableChecksum * * PARAMETERS: *TableHeader - ACPI table to verify * * RETURN: 8 bit checksum of table * * DESCRIPTION: Does an 8 bit checksum of table and returns status. A correct * table should have a checksum of 0. * ******************************************************************************/ ACPI_STATUS AcpiTbVerifyTableChecksum ( ACPI_TABLE_HEADER *TableHeader) { UINT8 Checksum; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("TbVerifyTableChecksum"); /* Compute the checksum on the table */ Checksum = AcpiTbChecksum (TableHeader, TableHeader->Length); /* Return the appropriate exception */ if (Checksum) { - ACPI_REPORT_WARNING (("Invalid checksum (%X) in table %4.4s\n", - (UINT32) Checksum, TableHeader->Signature)); + 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; } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiTbChecksum * * PARAMETERS: Buffer - Buffer to checksum * Length - Size of the buffer * * RETURNS 8 bit checksum of buffer * * DESCRIPTION: Computes an 8 bit checksum of the buffer(length) and returns it. * ******************************************************************************/ UINT8 AcpiTbChecksum ( void *Buffer, UINT32 Length) { const UINT8 *limit; const UINT8 *rover; UINT8 sum = 0; if (Buffer && Length) { /* Buffer and Length are valid */ limit = (UINT8 *) Buffer + Length; for (rover = Buffer; rover < limit; rover++) { sum = (UINT8) (sum + *rover); } } return (sum); } diff --git a/sys/contrib/dev/acpica/tbxfroot.c b/sys/contrib/dev/acpica/tbxfroot.c index aac15037bfeb..f6ba0eaceabb 100644 --- a/sys/contrib/dev/acpica/tbxfroot.c +++ b/sys/contrib/dev/acpica/tbxfroot.c @@ -1,606 +1,611 @@ /****************************************************************************** * * Module Name: tbxfroot - Find the root ACPI table (RSDT) - * $Revision: 64 $ + * $Revision: 65 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __TBXFROOT_C__ #include "acpi.h" #include "actables.h" #define _COMPONENT ACPI_TABLES ACPI_MODULE_NAME ("tbxfroot") /******************************************************************************* * * FUNCTION: AcpiTbFindTable * * PARAMETERS: Signature - String with ACPI table signature * OemId - String with the table OEM ID * OemTableId - String with the OEM Table ID. * * RETURN: Status * * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the * Signature, OEM ID and OEM Table ID. * ******************************************************************************/ ACPI_STATUS AcpiTbFindTable ( NATIVE_CHAR *Signature, NATIVE_CHAR *OemId, NATIVE_CHAR *OemTableId, ACPI_TABLE_HEADER **TablePtr) { ACPI_STATUS Status; ACPI_TABLE_HEADER *Table; ACPI_FUNCTION_TRACE ("TbFindTable"); /* Validate string lengths */ if ((ACPI_STRLEN (Signature) > ACPI_NAME_SIZE) || (ACPI_STRLEN (OemId) > sizeof (Table->OemId)) || (ACPI_STRLEN (OemTableId) > sizeof (Table->OemTableId))) { return_ACPI_STATUS (AE_AML_STRING_LIMIT); } /* Find the table */ Status = AcpiGetFirmwareTable (Signature, 1, ACPI_LOGICAL_ADDRESSING, &Table); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Check OemId and OemTableId */ if ((OemId[0] && ACPI_STRCMP (OemId, Table->OemId)) || (OemTableId[0] && ACPI_STRCMP (OemTableId, Table->OemTableId))) { return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND); } *TablePtr = Table; return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiGetFirmwareTable * * PARAMETERS: Signature - Any ACPI table signature * Instance - the non zero instance of the table, allows * support for multiple tables of the same type * Flags - Physical/Virtual support * RetBuffer - pointer to a structure containing a buffer to * receive the table * * RETURN: Status * * DESCRIPTION: This function is called to get an ACPI table. The caller * supplies an OutBuffer large enough to contain the entire ACPI * table. Upon completion * the OutBuffer->Length field will indicate the number of bytes * copied into the OutBuffer->BufPtr buffer. This table will be * a complete table including the header. * ******************************************************************************/ ACPI_STATUS AcpiGetFirmwareTable ( ACPI_STRING Signature, UINT32 Instance, UINT32 Flags, ACPI_TABLE_HEADER **TablePointer) { ACPI_POINTER RsdpAddress; ACPI_POINTER Address; ACPI_STATUS Status; ACPI_TABLE_HEADER Header; ACPI_TABLE_DESC TableInfo; ACPI_TABLE_DESC RsdtInfo; UINT32 TableCount; UINT32 i; UINT32 j; ACPI_FUNCTION_TRACE ("AcpiGetFirmwareTable"); /* * Ensure that at least the table manager is initialized. We don't * require that the entire ACPI subsystem is up for this interface */ /* * If we have a buffer, we must have a length too */ if ((Instance == 0) || (!Signature) || (!TablePointer)) { return_ACPI_STATUS (AE_BAD_PARAMETER); } RsdtInfo.Pointer = NULL; if (!AcpiGbl_RSDP) { /* Get the RSDP */ Status = AcpiOsGetRootPointer (Flags, &RsdpAddress); if (ACPI_FAILURE (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP not found\n")); return_ACPI_STATUS (AE_NO_ACPI_TABLES); } /* Map and validate the RSDP */ if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { Status = AcpiOsMapMemory (RsdpAddress.Pointer.Physical, sizeof (RSDP_DESCRIPTOR), (void **) &AcpiGbl_RSDP); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } else { AcpiGbl_RSDP = RsdpAddress.Pointer.Logical; } /* * The signature and checksum must both be correct */ if (ACPI_STRNCMP ((NATIVE_CHAR *) AcpiGbl_RSDP, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { /* Nope, BAD Signature */ return_ACPI_STATUS (AE_BAD_SIGNATURE); } if (AcpiTbChecksum (AcpiGbl_RSDP, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { /* Nope, BAD Checksum */ return_ACPI_STATUS (AE_BAD_CHECKSUM); } } /* Get the RSDT and validate it */ AcpiTbGetRsdtAddress (&Address); ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP located at %p, RSDT physical=%8.8X%8.8X \n", AcpiGbl_RSDP, ACPI_HIDWORD (Address.Pointer.Value), ACPI_LODWORD (Address.Pointer.Value))); /* Insert ProcessorMode flags */ Address.PointerType |= Flags; Status = AcpiTbGetTable (&Address, &RsdtInfo); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } Status = AcpiTbValidateRsdt (RsdtInfo.Pointer); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Get the number of table pointers within the RSDT */ TableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, RsdtInfo.Pointer); Address.PointerType = AcpiGbl_TableFlags | Flags; /* * Search the RSDT/XSDT for the correct instance of the * requested table */ for (i = 0, j = 0; i < TableCount; i++) { /* Get the next table pointer, handle RSDT vs. XSDT */ if (AcpiGbl_RSDP->Revision < 2) { Address.Pointer.Value = ((RSDT_DESCRIPTOR *) RsdtInfo.Pointer)->TableOffsetEntry[i]; } else { Address.Pointer.Value = ACPI_GET_ADDRESS ( ((XSDT_DESCRIPTOR *) RsdtInfo.Pointer)->TableOffsetEntry[i]); } /* Get the table header */ Status = AcpiTbGetTableHeader (&Address, &Header); if (ACPI_FAILURE (Status)) { goto Cleanup; } /* Compare table signatures and table instance */ if (!ACPI_STRNCMP (Header.Signature, Signature, ACPI_NAME_SIZE)) { /* An instance of the table was found */ j++; if (j >= Instance) { /* Found the correct instance, get the entire table */ Status = AcpiTbGetTableBody (&Address, &Header, &TableInfo); if (ACPI_FAILURE (Status)) { goto Cleanup; } *TablePointer = TableInfo.Pointer; goto Cleanup; } } } /* Did not find the table */ Status = AE_NOT_EXIST; Cleanup: AcpiOsUnmapMemory (RsdtInfo.Pointer, (ACPI_SIZE) RsdtInfo.Pointer->Length); return_ACPI_STATUS (Status); } /* TBD: Move to a new file */ #if ACPI_MACHINE_WIDTH != 16 /******************************************************************************* * * FUNCTION: AcpiFindRootPointer * * PARAMETERS: **RsdpAddress - Where to place the RSDP address * Flags - Logical/Physical addressing * * RETURN: Status, Physical address of the RSDP * * DESCRIPTION: Find the RSDP * ******************************************************************************/ ACPI_STATUS AcpiFindRootPointer ( UINT32 Flags, ACPI_POINTER *RsdpAddress) { ACPI_TABLE_DESC TableInfo; ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("AcpiFindRootPointer"); /* Get the RSDP */ Status = AcpiTbFindRsdp (&TableInfo, Flags); if (ACPI_FAILURE (Status)) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "RSDP structure not found\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); } RsdpAddress->PointerType = ACPI_PHYSICAL_POINTER; RsdpAddress->Pointer.Physical = TableInfo.PhysicalAddress; return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiTbScanMemoryForRsdp * * PARAMETERS: StartAddress - Starting pointer for search * Length - Maximum length to search * * RETURN: Pointer to the RSDP if found, otherwise NULL. * * DESCRIPTION: Search a block of memory for the RSDP signature * ******************************************************************************/ UINT8 * AcpiTbScanMemoryForRsdp ( UINT8 *StartAddress, UINT32 Length) { UINT32 Offset; UINT8 *MemRover; ACPI_FUNCTION_TRACE ("TbScanMemoryForRsdp"); /* Search from given start addr for the requested length */ for (Offset = 0, MemRover = StartAddress; Offset < Length; Offset += RSDP_SCAN_STEP, MemRover += RSDP_SCAN_STEP) { /* The signature and checksum must both be correct */ if (ACPI_STRNCMP ((NATIVE_CHAR *) MemRover, RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 && AcpiTbChecksum (MemRover, ACPI_RSDP_CHECKSUM_LENGTH) == 0) { /* If so, we have found the RSDP */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP located at physical address %p\n",MemRover)); return_PTR (MemRover); } } /* Searched entire block, no RSDP was found */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,"Searched entire block, no RSDP was found.\n")); return_PTR (NULL); } /******************************************************************************* * * FUNCTION: AcpiTbFindRsdp * * PARAMETERS: *TableInfo - Where the table info is returned * Flags - Current memory mode (logical vs. * physical addressing) * * RETURN: Status * * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor * pointer structure. If it is found, set *RSDP to point to it. * * NOTE: The RSDP must be either in the first 1K of the Extended * BIOS Data Area or between E0000 and FFFFF (ACPI 1.0 section * 5.2.2; assertion #421). * ******************************************************************************/ ACPI_STATUS AcpiTbFindRsdp ( ACPI_TABLE_DESC *TableInfo, UINT32 Flags) { UINT8 *TablePtr; UINT8 *MemRover; UINT64 PhysAddr; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("TbFindRsdp"); /* * Scan supports either 1) Logical addressing or 2) Physical addressing */ if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING) { /* * 1) Search EBDA (low memory) paragraphs */ Status = AcpiOsMapMemory ((UINT64) LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE, (void **) &TablePtr); if (ACPI_FAILURE (Status)) { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %X for length %X\n", + LO_RSDP_WINDOW_BASE, LO_RSDP_WINDOW_SIZE)); return_ACPI_STATUS (Status); } MemRover = AcpiTbScanMemoryForRsdp (TablePtr, LO_RSDP_WINDOW_SIZE); AcpiOsUnmapMemory (TablePtr, LO_RSDP_WINDOW_SIZE); if (MemRover) { /* Found it, return the physical address */ PhysAddr = LO_RSDP_WINDOW_BASE; PhysAddr += ACPI_PTR_DIFF (MemRover,TablePtr); TableInfo->PhysicalAddress = PhysAddr; return_ACPI_STATUS (AE_OK); } /* * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h */ Status = AcpiOsMapMemory ((UINT64) HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE, (void **) &TablePtr); if (ACPI_FAILURE (Status)) { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %X for length %X\n", + HI_RSDP_WINDOW_BASE, HI_RSDP_WINDOW_SIZE)); return_ACPI_STATUS (Status); } MemRover = AcpiTbScanMemoryForRsdp (TablePtr, HI_RSDP_WINDOW_SIZE); AcpiOsUnmapMemory (TablePtr, HI_RSDP_WINDOW_SIZE); if (MemRover) { /* Found it, return the physical address */ PhysAddr = HI_RSDP_WINDOW_BASE; PhysAddr += ACPI_PTR_DIFF (MemRover, TablePtr); TableInfo->PhysicalAddress = PhysAddr; return_ACPI_STATUS (AE_OK); } } /* * Physical addressing */ else { /* * 1) Search EBDA (low memory) paragraphs */ MemRover = AcpiTbScanMemoryForRsdp (ACPI_PHYSADDR_TO_PTR (LO_RSDP_WINDOW_BASE), LO_RSDP_WINDOW_SIZE); if (MemRover) { /* Found it, return the physical address */ TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover); return_ACPI_STATUS (AE_OK); } /* * 2) Search upper memory: 16-byte boundaries in E0000h-F0000h */ MemRover = AcpiTbScanMemoryForRsdp (ACPI_PHYSADDR_TO_PTR (HI_RSDP_WINDOW_BASE), HI_RSDP_WINDOW_SIZE); if (MemRover) { /* Found it, return the physical address */ TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover); return_ACPI_STATUS (AE_OK); } } /* RSDP signature was not found */ return_ACPI_STATUS (AE_NOT_FOUND); } #endif diff --git a/sys/contrib/dev/acpica/utcopy.c b/sys/contrib/dev/acpica/utcopy.c index aa8cf3501b51..c1bb6d5984c0 100644 --- a/sys/contrib/dev/acpica/utcopy.c +++ b/sys/contrib/dev/acpica/utcopy.c @@ -1,965 +1,965 @@ /****************************************************************************** * * Module Name: utcopy - Internal to external object translation utilities - * $Revision: 104 $ + * $Revision: 105 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __UTCOPY_C__ #include "acpi.h" #include "amlcode.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utcopy") /******************************************************************************* * * FUNCTION: AcpiUtCopyIsimpleToEsimple * * PARAMETERS: *InternalObject - Pointer to the object we are examining * *Buffer - Where the object is returned * *SpaceUsed - Where the data length is returned * * RETURN: Status * * DESCRIPTION: This function is called to place a simple object in a user * buffer. * * The buffer is assumed to have sufficient space for the object. * ******************************************************************************/ static ACPI_STATUS AcpiUtCopyIsimpleToEsimple ( ACPI_OPERAND_OBJECT *InternalObject, ACPI_OBJECT *ExternalObject, UINT8 *DataSpace, ACPI_SIZE *BufferSpaceUsed) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("UtCopyIsimpleToEsimple"); *BufferSpaceUsed = 0; /* * Check for NULL object case (could be an uninitialized * package element) */ if (!InternalObject) { return_ACPI_STATUS (AE_OK); } /* Always clear the external object */ ACPI_MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT)); /* * In general, the external object will be the same type as * the internal object */ ExternalObject->Type = ACPI_GET_OBJECT_TYPE (InternalObject); /* However, only a limited number of external types are supported */ switch (ACPI_GET_OBJECT_TYPE (InternalObject)) { case ACPI_TYPE_STRING: ExternalObject->String.Pointer = (NATIVE_CHAR *) DataSpace; ExternalObject->String.Length = InternalObject->String.Length; *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); break; case ACPI_TYPE_BUFFER: ExternalObject->Buffer.Pointer = DataSpace; ExternalObject->Buffer.Length = InternalObject->Buffer.Length; *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD (InternalObject->String.Length); ACPI_MEMCPY ((void *) DataSpace, (void *) InternalObject->Buffer.Pointer, InternalObject->Buffer.Length); break; case ACPI_TYPE_INTEGER: ExternalObject->Integer.Value = InternalObject->Integer.Value; break; - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: /* * This is an object reference. Attempt to dereference it. */ switch (InternalObject->Reference.Opcode) { case AML_INT_NAMEPATH_OP: /* For namepath, return the object handle ("reference") */ default: /* * Use the object type of "Any" to indicate a reference * to object containing a handle to an ACPI named object. */ ExternalObject->Type = ACPI_TYPE_ANY; ExternalObject->Reference.Handle = InternalObject->Reference.Node; break; } break; case ACPI_TYPE_PROCESSOR: ExternalObject->Processor.ProcId = InternalObject->Processor.ProcId; ExternalObject->Processor.PblkAddress = InternalObject->Processor.Address; ExternalObject->Processor.PblkLength = InternalObject->Processor.Length; break; case ACPI_TYPE_POWER: ExternalObject->PowerResource.SystemLevel = InternalObject->PowerResource.SystemLevel; ExternalObject->PowerResource.ResourceOrder = InternalObject->PowerResource.ResourceOrder; break; default: /* * There is no corresponding external object type */ return_ACPI_STATUS (AE_SUPPORT); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiUtCopyIelementToEelement * * PARAMETERS: ACPI_PKG_CALLBACK * * RETURN: Status * * DESCRIPTION: Copy one package element to another package element * ******************************************************************************/ ACPI_STATUS AcpiUtCopyIelementToEelement ( UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, ACPI_GENERIC_STATE *State, void *Context) { ACPI_STATUS Status = AE_OK; ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; ACPI_SIZE ObjectSpace; UINT32 ThisIndex; ACPI_OBJECT *TargetObject; ACPI_FUNCTION_ENTRY (); ThisIndex = State->Pkg.Index; TargetObject = (ACPI_OBJECT *) &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; switch (ObjectType) { case ACPI_COPY_TYPE_SIMPLE: /* * This is a simple or null object */ Status = AcpiUtCopyIsimpleToEsimple (SourceObject, TargetObject, Info->FreeSpace, &ObjectSpace); if (ACPI_FAILURE (Status)) { return (Status); } break; case ACPI_COPY_TYPE_PACKAGE: /* * Build the package object */ TargetObject->Type = ACPI_TYPE_PACKAGE; TargetObject->Package.Count = SourceObject->Package.Count; TargetObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace); /* * Pass the new package object back to the package walk routine */ State->Pkg.ThisTargetObj = TargetObject; /* * Save space for the array of objects (Package elements) * update the buffer length counter */ ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD ( (ACPI_SIZE) TargetObject->Package.Count * sizeof (ACPI_OBJECT)); break; default: return (AE_BAD_PARAMETER); } Info->FreeSpace += ObjectSpace; Info->Length += ObjectSpace; return (Status); } /******************************************************************************* * * FUNCTION: AcpiUtCopyIpackageToEpackage * * PARAMETERS: *InternalObject - Pointer to the object we are returning * *Buffer - Where the object is returned * *SpaceUsed - Where the object length is returned * * RETURN: Status * * DESCRIPTION: This function is called to place a package object in a user * buffer. A package object by definition contains other objects. * * The buffer is assumed to have sufficient space for the object. * The caller must have verified the buffer length needed using the * AcpiUtGetObjectSize function before calling this function. * ******************************************************************************/ static ACPI_STATUS AcpiUtCopyIpackageToEpackage ( ACPI_OPERAND_OBJECT *InternalObject, UINT8 *Buffer, ACPI_SIZE *SpaceUsed) { ACPI_OBJECT *ExternalObject; ACPI_STATUS Status; ACPI_PKG_INFO Info; ACPI_FUNCTION_TRACE ("UtCopyIpackageToEpackage"); /* * First package at head of the buffer */ ExternalObject = ACPI_CAST_PTR (ACPI_OBJECT, Buffer); /* * 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.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); /* * Leave room for an array of ACPI_OBJECTS in the buffer * and move the free space past it */ Info.Length += (ACPI_SIZE) ExternalObject->Package.Count * ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); Info.FreeSpace += ExternalObject->Package.Count * ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject, AcpiUtCopyIelementToEelement, &Info); *SpaceUsed = Info.Length; return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiUtCopyIobjectToEobject * * PARAMETERS: *InternalObject - The internal object to be converted * *BufferPtr - Where the object is returned * * RETURN: Status * * DESCRIPTION: This function is called to build an API object to be returned to * the caller. * ******************************************************************************/ ACPI_STATUS AcpiUtCopyIobjectToEobject ( ACPI_OPERAND_OBJECT *InternalObject, ACPI_BUFFER *RetBuffer) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("UtCopyIobjectToEobject"); if (ACPI_GET_OBJECT_TYPE (InternalObject) == ACPI_TYPE_PACKAGE) { /* * Package object: Copy all subobjects (including * nested packages) */ Status = AcpiUtCopyIpackageToEpackage (InternalObject, RetBuffer->Pointer, &RetBuffer->Length); } else { /* * 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); /* * build simple does not include the object size in the length * so we add it in here */ RetBuffer->Length += sizeof (ACPI_OBJECT); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiUtCopyEsimpleToIsimple * * PARAMETERS: *ExternalObject - The external object to be converted * *InternalObject - Where the internal object is returned * * RETURN: Status * * DESCRIPTION: This function copies an external object to an internal one. * NOTE: Pointers can be copied, we don't need to copy data. * (The pointers have to be valid in our address space no matter * what we do with them!) * ******************************************************************************/ ACPI_STATUS AcpiUtCopyEsimpleToIsimple ( ACPI_OBJECT *ExternalObject, ACPI_OPERAND_OBJECT **RetInternalObject) { ACPI_OPERAND_OBJECT *InternalObject; ACPI_FUNCTION_TRACE ("UtCopyEsimpleToIsimple"); /* * Simple types supported are: String, Buffer, Integer */ switch (ExternalObject->Type) { case ACPI_TYPE_STRING: case ACPI_TYPE_BUFFER: case ACPI_TYPE_INTEGER: InternalObject = AcpiUtCreateInternalObject ((UINT8) ExternalObject->Type); if (!InternalObject) { return_ACPI_STATUS (AE_NO_MEMORY); } break; default: /* * Whatever other type -- it is not supported */ return_ACPI_STATUS (AE_SUPPORT); } switch (ExternalObject->Type) { /* Must COPY string and buffer contents */ case ACPI_TYPE_STRING: InternalObject->String.Pointer = ACPI_MEM_CALLOCATE ((ACPI_SIZE) ExternalObject->String.Length + 1); if (!InternalObject->String.Pointer) { return_ACPI_STATUS (AE_NO_MEMORY); } ACPI_MEMCPY (InternalObject->String.Pointer, ExternalObject->String.Pointer, ExternalObject->String.Length); InternalObject->String.Length = ExternalObject->String.Length; break; case ACPI_TYPE_BUFFER: InternalObject->Buffer.Pointer = ACPI_MEM_CALLOCATE (ExternalObject->Buffer.Length); if (!InternalObject->Buffer.Pointer) { return_ACPI_STATUS (AE_NO_MEMORY); } ACPI_MEMCPY (InternalObject->Buffer.Pointer, ExternalObject->Buffer.Pointer, ExternalObject->Buffer.Length); InternalObject->Buffer.Length = ExternalObject->Buffer.Length; break; case ACPI_TYPE_INTEGER: InternalObject->Integer.Value = ExternalObject->Integer.Value; break; default: /* Other types can't get here */ break; } *RetInternalObject = InternalObject; return_ACPI_STATUS (AE_OK); } #ifdef ACPI_FUTURE_IMPLEMENTATION /* Code to convert packages that are parameters to control methods */ /******************************************************************************* * * FUNCTION: AcpiUtCopyEpackageToIpackage * * PARAMETERS: *InternalObject - Pointer to the object we are returning * *Buffer - Where the object is returned * *SpaceUsed - Where the length of the object is returned * * RETURN: Status - the status of the call * * DESCRIPTION: This function is called to place a package object in a user * buffer. A package object by definition contains other objects. * * The buffer is assumed to have sufficient space for the object. * The caller must have verified the buffer length needed using the * AcpiUtGetObjectSize function before calling this function. * ******************************************************************************/ static ACPI_STATUS AcpiUtCopyEpackageToIpackage ( ACPI_OPERAND_OBJECT *InternalObject, UINT8 *Buffer, UINT32 *SpaceUsed) { UINT8 *FreeSpace; ACPI_OBJECT *ExternalObject; UINT32 Length = 0; UINT32 ThisIndex; UINT32 ObjectSpace = 0; ACPI_OPERAND_OBJECT *ThisInternalObj; ACPI_OBJECT *ThisExternalObj; ACPI_FUNCTION_TRACE ("UtCopyEpackageToIpackage"); /* * First package at head of the buffer */ ExternalObject = (ACPI_OBJECT *)Buffer; /* * Free space begins right after the first package */ FreeSpace = Buffer + sizeof(ACPI_OBJECT); ExternalObject->Type = ACPI_GET_OBJECT_TYPE (InternalObject); ExternalObject->Package.Count = InternalObject->Package.Count; ExternalObject->Package.Elements = (ACPI_OBJECT *)FreeSpace; /* * Build an array of ACPI_OBJECTS in the buffer * and move the free space past it */ FreeSpace += ExternalObject->Package.Count * sizeof(ACPI_OBJECT); /* Call WalkPackage */ } #endif /* Future implementation */ /******************************************************************************* * * FUNCTION: AcpiUtCopyEobjectToIobject * * PARAMETERS: *InternalObject - The external object to be converted * *BufferPtr - Where the internal object is returned * * RETURN: Status - the status of the call * * DESCRIPTION: Converts an external object to an internal object. * ******************************************************************************/ ACPI_STATUS AcpiUtCopyEobjectToIobject ( ACPI_OBJECT *ExternalObject, ACPI_OPERAND_OBJECT **InternalObject) { ACPI_STATUS Status; ACPI_FUNCTION_TRACE ("UtCopyEobjectToIobject"); if (ExternalObject->Type == ACPI_TYPE_PACKAGE) { /* * Packages as external input to control methods are not supported, */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Packages as parameters not implemented!\n")); return_ACPI_STATUS (AE_NOT_IMPLEMENTED); } else { /* * Build a simple object (no nested objects) */ Status = AcpiUtCopyEsimpleToIsimple (ExternalObject, InternalObject); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiUtCopySimpleObject * * PARAMETERS: SourceDesc - The internal object to be copied * DestDesc - New target object * * RETURN: Status * * DESCRIPTION: Simple copy of one internal object to another. Reference count * of the destination object is preserved. * ******************************************************************************/ ACPI_STATUS AcpiUtCopySimpleObject ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT *DestDesc) { UINT16 ReferenceCount; ACPI_OPERAND_OBJECT *NextObject; /* Save fields from destination that we don't want to overwrite */ ReferenceCount = DestDesc->Common.ReferenceCount; NextObject = DestDesc->Common.NextObject; /* Copy the entire source object over the destination object*/ ACPI_MEMCPY ((char *) DestDesc, (char *) SourceDesc, sizeof (ACPI_OPERAND_OBJECT)); /* Restore the saved fields */ DestDesc->Common.ReferenceCount = ReferenceCount; DestDesc->Common.NextObject = NextObject; /* 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; /* Fall through to common string/buffer case */ /*lint -fallthrough */ case ACPI_TYPE_STRING: /* * Allocate and copy the actual string if and only if: * 1) There is a valid string (length > 0) * 2) The string is not static (not in an ACPI table) (in this case, * the actual pointer was already copied above) */ if ((SourceDesc->String.Length) && (!(SourceDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) { DestDesc->String.Pointer = ACPI_MEM_ALLOCATE (SourceDesc->String.Length); if (!DestDesc->String.Pointer) { return (AE_NO_MEMORY); } ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer, SourceDesc->String.Length); } break; default: /* Nothing to do for other simple objects */ break; } return (AE_OK); } /******************************************************************************* * * FUNCTION: AcpiUtCopyIelementToIelement * * PARAMETERS: ACPI_PKG_CALLBACK * * RETURN: Status * * DESCRIPTION: Copy one package element to another package element * ******************************************************************************/ ACPI_STATUS AcpiUtCopyIelementToIelement ( UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, ACPI_GENERIC_STATE *State, void *Context) { ACPI_STATUS Status = AE_OK; UINT32 ThisIndex; ACPI_OPERAND_OBJECT **ThisTargetPtr; ACPI_OPERAND_OBJECT *TargetObject; ACPI_FUNCTION_ENTRY (); ThisIndex = State->Pkg.Index; ThisTargetPtr = (ACPI_OPERAND_OBJECT **) &State->Pkg.DestObject->Package.Elements[ThisIndex]; switch (ObjectType) { case 0: /* * This is a simple object, just copy it */ TargetObject = AcpiUtCreateInternalObject (ACPI_GET_OBJECT_TYPE (SourceObject)); if (!TargetObject) { return (AE_NO_MEMORY); } Status = AcpiUtCopySimpleObject (SourceObject, TargetObject); if (ACPI_FAILURE (Status)) { return (Status); } *ThisTargetPtr = TargetObject; break; case 1: /* * This object is a package - go down another nesting level * Create and build the package object */ TargetObject = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); if (!TargetObject) { return (AE_NO_MEMORY); } TargetObject->Package.Count = SourceObject->Package.Count; TargetObject->Common.Flags = SourceObject->Common.Flags; /* * Pass the new package object back to the package walk routine */ State->Pkg.ThisTargetObj = TargetObject; /* * Store the object pointer in the parent package object */ *ThisTargetPtr = TargetObject; break; default: return (AE_BAD_PARAMETER); } return (Status); } /******************************************************************************* * * FUNCTION: AcpiUtCopyIpackageToIpackage * * PARAMETERS: *SourceObj - Pointer to the source package object * *DestObj - Where the internal object is returned * * RETURN: Status - the status of the call * * DESCRIPTION: This function is called to copy an internal package object * into another internal package object. * ******************************************************************************/ ACPI_STATUS AcpiUtCopyIpackageToIpackage ( ACPI_OPERAND_OBJECT *SourceObj, ACPI_OPERAND_OBJECT *DestObj, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("UtCopyIpackageToIpackage"); DestObj->Common.Type = ACPI_GET_OBJECT_TYPE (SourceObj); DestObj->Common.Flags = SourceObj->Common.Flags; DestObj->Package.Count = SourceObj->Package.Count; /* * Create the object array and walk the source package tree */ DestObj->Package.Elements = ACPI_MEM_CALLOCATE ( ((ACPI_SIZE) SourceObj->Package.Count + 1) * sizeof (void *)); if (!DestObj->Package.Elements) { ACPI_REPORT_ERROR ( ("AmlBuildCopyInternalPackageObject: Package allocation failure\n")); return_ACPI_STATUS (AE_NO_MEMORY); } /* * Copy the package element-by-element by walking the package "tree". * This handles nested packages of arbitrary depth. */ Status = AcpiUtWalkPackageTree (SourceObj, DestObj, AcpiUtCopyIelementToIelement, WalkState); if (ACPI_FAILURE (Status)) { /* On failure, delete the destination package object */ AcpiUtRemoveReference (DestObj); } return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiUtCopyIobjectToIobject * * PARAMETERS: WalkState - Current walk state * SourceDesc - The internal object to be copied * DestDesc - Where the copied object is returned * * RETURN: Status * * DESCRIPTION: Copy an internal object to a new internal object * ******************************************************************************/ ACPI_STATUS AcpiUtCopyIobjectToIobject ( ACPI_OPERAND_OBJECT *SourceDesc, ACPI_OPERAND_OBJECT **DestDesc, ACPI_WALK_STATE *WalkState) { ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE ("UtCopyIobjectToIobject"); /* Create the top level object */ *DestDesc = AcpiUtCreateInternalObject (ACPI_GET_OBJECT_TYPE (SourceDesc)); if (!*DestDesc) { return_ACPI_STATUS (AE_NO_MEMORY); } /* Copy the object and possible subobjects */ if (ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_PACKAGE) { Status = AcpiUtCopyIpackageToIpackage (SourceDesc, *DestDesc, WalkState); } else { Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc); } return_ACPI_STATUS (Status); } diff --git a/sys/contrib/dev/acpica/utdelete.c b/sys/contrib/dev/acpica/utdelete.c index 08c5ff16bc43..40d58baf2c79 100644 --- a/sys/contrib/dev/acpica/utdelete.c +++ b/sys/contrib/dev/acpica/utdelete.c @@ -1,749 +1,749 @@ /******************************************************************************* * * Module Name: utdelete - object deletion and reference count utilities - * $Revision: 91 $ + * $Revision: 92 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __UTDELETE_C__ #include "acpi.h" #include "acinterp.h" #include "acnamesp.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utdelete") /******************************************************************************* * * FUNCTION: AcpiUtDeleteInternalObj * * PARAMETERS: *Object - Pointer to the list to be deleted * * RETURN: None * * DESCRIPTION: Low level object deletion, after reference counts have been * updated (All reference counts, including sub-objects!) * ******************************************************************************/ void AcpiUtDeleteInternalObj ( ACPI_OPERAND_OBJECT *Object) { void *ObjPointer = NULL; ACPI_OPERAND_OBJECT *HandlerDesc; ACPI_OPERAND_OBJECT *SecondDesc; ACPI_FUNCTION_TRACE_PTR ("UtDeleteInternalObj", Object); if (!Object) { return_VOID; } /* * Must delete or free any pointers within the object that are not * actual ACPI objects (for example, a raw buffer pointer). */ switch (ACPI_GET_OBJECT_TYPE (Object)) { case ACPI_TYPE_STRING: ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n", Object, Object->String.Pointer)); /* Free the actual string buffer */ if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER)) { ObjPointer = Object->String.Pointer; } break; case ACPI_TYPE_BUFFER: ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n", Object, Object->Buffer.Pointer)); /* Free the actual buffer */ ObjPointer = Object->Buffer.Pointer; break; case ACPI_TYPE_PACKAGE: ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n", Object->Package.Count)); /* * Elements of the package are not handled here, they are deleted * separately */ /* Free the (variable length) element pointer array */ ObjPointer = Object->Package.Elements; break; case ACPI_TYPE_MUTEX: ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Mutex %p, Semaphore %p\n", Object, Object->Mutex.Semaphore)); AcpiExUnlinkMutex (Object); (void) AcpiOsDeleteSemaphore (Object->Mutex.Semaphore); break; case ACPI_TYPE_EVENT: ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Event %p, Semaphore %p\n", Object, Object->Event.Semaphore)); (void) AcpiOsDeleteSemaphore (Object->Event.Semaphore); Object->Event.Semaphore = NULL; break; case ACPI_TYPE_METHOD: ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Method %p\n", Object)); /* Delete the method semaphore if it exists */ if (Object->Method.Semaphore) { (void) AcpiOsDeleteSemaphore (Object->Method.Semaphore); Object->Method.Semaphore = NULL; } break; case ACPI_TYPE_REGION: ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Region %p\n", Object)); SecondDesc = AcpiNsGetSecondaryObject (Object); if (SecondDesc) { /* * Free the RegionContext if and only if the handler is one of the * default handlers -- and therefore, we created the context object * locally, it was not created by an external caller. */ HandlerDesc = Object->Region.AddrHandler; if ((HandlerDesc) && (HandlerDesc->AddrHandler.Hflags == ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { ObjPointer = SecondDesc->Extra.RegionContext; } /* Now we can free the Extra object */ AcpiUtDeleteObjectDesc (SecondDesc); } break; case ACPI_TYPE_BUFFER_FIELD: ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "***** Buffer Field %p\n", Object)); SecondDesc = AcpiNsGetSecondaryObject (Object); if (SecondDesc) { AcpiUtDeleteObjectDesc (SecondDesc); } break; default: break; } /* Free any allocated memory (pointer within the object) found above */ if (ObjPointer) { ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n", ObjPointer)); ACPI_MEM_FREE (ObjPointer); } /* Now the object can be safely deleted */ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n", Object, AcpiUtGetObjectTypeName (Object))); AcpiUtDeleteObjectDesc (Object); return_VOID; } /******************************************************************************* * * FUNCTION: AcpiUtDeleteInternalObjectList * * PARAMETERS: *ObjList - Pointer to the list to be deleted * * RETURN: None * * DESCRIPTION: This function deletes an internal object list, including both * simple objects and package objects * ******************************************************************************/ void AcpiUtDeleteInternalObjectList ( ACPI_OPERAND_OBJECT **ObjList) { ACPI_OPERAND_OBJECT **InternalObj; ACPI_FUNCTION_TRACE ("UtDeleteInternalObjectList"); /* Walk the null-terminated internal list */ for (InternalObj = ObjList; *InternalObj; InternalObj++) { AcpiUtRemoveReference (*InternalObj); } /* Free the combined parameter pointer list and object array */ ACPI_MEM_FREE (ObjList); return_VOID; } /******************************************************************************* * * FUNCTION: AcpiUtUpdateRefCount * * PARAMETERS: *Object - Object whose ref count is to be updated * Action - What to do * * RETURN: New ref count * * DESCRIPTION: Modify the ref count and return it. * ******************************************************************************/ static void AcpiUtUpdateRefCount ( ACPI_OPERAND_OBJECT *Object, UINT32 Action) { UINT16 Count; UINT16 NewCount; ACPI_FUNCTION_NAME ("UtUpdateRefCount"); if (!Object) { return; } Count = Object->Common.ReferenceCount; NewCount = Count; /* * Reference count action (increment, decrement, or force delete) */ switch (Action) { case REF_INCREMENT: NewCount++; Object->Common.ReferenceCount = NewCount; ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, [Incremented]\n", Object, NewCount)); break; case REF_DECREMENT: if (Count < 1) { ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, can't decrement! (Set to 0)\n", Object, NewCount)); NewCount = 0; } else { NewCount--; 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", Object, NewCount)); } Object->Common.ReferenceCount = NewCount; if (NewCount == 0) { AcpiUtDeleteInternalObj (Object); } break; case REF_FORCE_DELETE: ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X, Force delete! (Set to 0)\n", Object, Count)); NewCount = 0; Object->Common.ReferenceCount = NewCount; AcpiUtDeleteInternalObj (Object); break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown action (%X)\n", Action)); break; } /* * Sanity check the reference count, for debug purposes only. * (A deleted object will have a huge reference count) */ if (Count > MAX_REFERENCE_COUNT) { ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "**** Warning **** Large Reference Count (%X) in object %p\n\n", Count, Object)); } return; } /******************************************************************************* * * FUNCTION: AcpiUtUpdateObjectReference * * PARAMETERS: *Object - Increment ref count for this object * and all sub-objects * Action - Either REF_INCREMENT or REF_DECREMENT or * REF_FORCE_DELETE * * RETURN: Status * * DESCRIPTION: Increment the object reference count * * Object references are incremented when: * 1) An object is attached to a Node (namespace object) * 2) An object is copied (all subobjects must be incremented) * * Object references are decremented when: * 1) An object is detached from an Node * ******************************************************************************/ ACPI_STATUS AcpiUtUpdateObjectReference ( ACPI_OPERAND_OBJECT *Object, UINT16 Action) { ACPI_STATUS Status; UINT32 i; ACPI_OPERAND_OBJECT *Next; ACPI_OPERAND_OBJECT *New; ACPI_GENERIC_STATE *StateList = NULL; ACPI_GENERIC_STATE *State; ACPI_FUNCTION_TRACE_PTR ("UtUpdateObjectReference", Object); /* Ignore a null object ptr */ if (!Object) { return_ACPI_STATUS (AE_OK); } /* * 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); /* * All sub-objects must have their reference count incremented also. * Different object types have different subobjects. */ switch (ACPI_GET_OBJECT_TYPE (Object)) { case ACPI_TYPE_DEVICE: Status = AcpiUtCreateUpdateStateAndPush (Object->Device.AddrHandler, Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; } AcpiUtUpdateRefCount (Object->Device.SysHandler, Action); AcpiUtUpdateRefCount (Object->Device.DrvHandler, Action); break; - case INTERNAL_TYPE_ADDRESS_HANDLER: + case ACPI_TYPE_LOCAL_ADDRESS_HANDLER: /* Must walk list of address handlers */ Next = Object->AddrHandler.Next; while (Next) { New = Next->AddrHandler.Next; AcpiUtUpdateRefCount (Next, Action); Next = New; } 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. */ for (i = 0; i < Object->Package.Count; i++) { /* * Push each element onto the stack for later processing. * Note: There can be null elements within the package, * these are simply ignored */ Status = AcpiUtCreateUpdateStateAndPush ( Object->Package.Elements[i], Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; } } break; case ACPI_TYPE_BUFFER_FIELD: Status = AcpiUtCreateUpdateStateAndPush ( Object->BufferField.BufferObj, Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; } break; - case INTERNAL_TYPE_REGION_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: Status = AcpiUtCreateUpdateStateAndPush ( Object->Field.RegionObj, Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; } break; - case INTERNAL_TYPE_BANK_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: Status = AcpiUtCreateUpdateStateAndPush ( Object->BankField.BankObj, Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; } Status = AcpiUtCreateUpdateStateAndPush ( Object->BankField.RegionObj, Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; } break; - case INTERNAL_TYPE_INDEX_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: Status = AcpiUtCreateUpdateStateAndPush ( Object->IndexField.IndexObj, Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; } Status = AcpiUtCreateUpdateStateAndPush ( Object->IndexField.DataObj, Action, &StateList); if (ACPI_FAILURE (Status)) { goto ErrorExit; } break; case ACPI_TYPE_REGION: - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: default: /* No subobjects */ break; } /* * Now we can update the count in the main object. This can only * happen after we update the sub-objects in case this causes the * main object to be deleted. */ AcpiUtUpdateRefCount (Object, Action); /* Move on to the next object to be updated */ State = AcpiUtPopGenericState (&StateList); } return_ACPI_STATUS (AE_OK); ErrorExit: ACPI_REPORT_ERROR (("Could not update object reference count, %s\n", AcpiFormatException (Status))); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiUtAddReference * * PARAMETERS: *Object - Object whose reference count is to be * incremented * * RETURN: None * * DESCRIPTION: Add one reference to an ACPI object * ******************************************************************************/ void AcpiUtAddReference ( ACPI_OPERAND_OBJECT *Object) { ACPI_FUNCTION_TRACE_PTR ("UtAddReference", Object); /* * Ensure that we have a valid object */ if (!AcpiUtValidInternalObject (Object)) { return_VOID; } /* * We have a valid ACPI internal object, now increment the reference count */ (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT); return_VOID; } /******************************************************************************* * * FUNCTION: AcpiUtRemoveReference * * PARAMETERS: *Object - Object whose ref count will be decremented * * RETURN: None * * DESCRIPTION: Decrement the reference count of an ACPI internal object * ******************************************************************************/ void AcpiUtRemoveReference ( ACPI_OPERAND_OBJECT *Object) { ACPI_FUNCTION_TRACE_PTR ("UtRemoveReference", Object); /* * Allow a NULL pointer to be passed in, just ignore it. This saves * each caller from having to check. Also, ignore NS nodes. * */ if (!Object || (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)) { return_VOID; } /* * Ensure that we have a valid object */ if (!AcpiUtValidInternalObject (Object)) { return_VOID; } ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Obj %p Refs=%X\n", Object, Object->Common.ReferenceCount)); /* * Decrement the reference count, and only actually delete the object * if the reference count becomes 0. (Must also decrement the ref count * of all subobjects!) */ (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT); return_VOID; } diff --git a/sys/contrib/dev/acpica/utmisc.c b/sys/contrib/dev/acpica/utmisc.c index c132f279fcb4..4862b7df6344 100644 --- a/sys/contrib/dev/acpica/utmisc.c +++ b/sys/contrib/dev/acpica/utmisc.c @@ -1,1537 +1,1633 @@ /******************************************************************************* * * Module Name: utmisc - common utility procedures - * $Revision: 84 $ + * $Revision: 86 $ * ******************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __UTMISC_C__ #include "acpi.h" #include "acnamesp.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utmisc") +/******************************************************************************* + * + * FUNCTION: AcpiUtPrintString + * + * PARAMETERS: String - Null terminated ASCII string + * + * RETURN: None + * + * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape + * sequences. + * + ******************************************************************************/ + +void +AcpiUtPrintString ( + char *String, + UINT8 MaxLength) +{ + UINT32 i; + + + if (!String) + { + AcpiOsPrintf ("<\"NULL STRING PTR\">"); + return; + } + + AcpiOsPrintf ("\""); + for (i = 0; String[i] && (i < MaxLength); i++) + { + /* Escape sequences */ + + switch (String[i]) + { + case 0x07: + AcpiOsPrintf ("\\a"); /* BELL */ + break; + + case 0x08: + AcpiOsPrintf ("\\b"); /* BACKSPACE */ + break; + + case 0x0C: + AcpiOsPrintf ("\\f"); /* FORMFEED */ + break; + + case 0x0A: + AcpiOsPrintf ("\\n"); /* LINEFEED */ + break; + + case 0x0D: + AcpiOsPrintf ("\\r"); /* CARRIAGE RETURN*/ + break; + + case 0x09: + AcpiOsPrintf ("\\t"); /* HORIZONTAL TAB */ + break; + + case 0x0B: + AcpiOsPrintf ("\\v"); /* VERTICAL TAB */ + break; + + case '\'': /* Single Quote */ + case '\"': /* Double Quote */ + case '\\': /* Backslash */ + AcpiOsPrintf ("\\%c", (int) String[i]); + break; + + default: + + /* Check for printable character or hex escape */ + + if (ACPI_IS_PRINT (String[i])) + { + /* This is a normal character */ + + AcpiOsPrintf ("%c", (int) String[i]); + } + else + { + /* All others will be Hex escapes */ + + AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]); + } + break; + } + } + AcpiOsPrintf ("\""); + + if (i == MaxLength && String[i]) + { + AcpiOsPrintf ("..."); + } +} + + /******************************************************************************* * * FUNCTION: AcpiUtDwordByteSwap * * PARAMETERS: Value - Value to be converted * * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) * ******************************************************************************/ UINT32 AcpiUtDwordByteSwap ( UINT32 Value) { union { UINT32 Value; UINT8 Bytes[4]; } Out; union { UINT32 Value; UINT8 Bytes[4]; } In; ACPI_FUNCTION_ENTRY (); In.Value = Value; Out.Bytes[0] = In.Bytes[3]; Out.Bytes[1] = In.Bytes[2]; Out.Bytes[2] = In.Bytes[1]; Out.Bytes[3] = In.Bytes[0]; return (Out.Value); } /******************************************************************************* * * FUNCTION: AcpiUtSetIntegerWidth * * PARAMETERS: Revision From DSDT header * * RETURN: None * * DESCRIPTION: Set the global integer bit width based upon the revision * of the DSDT. For Revision 1 and 0, Integers are 32 bits. * For Revision 2 and above, Integers are 64 bits. Yes, this * makes a difference. * ******************************************************************************/ void AcpiUtSetIntegerWidth ( UINT8 Revision) { if (Revision <= 1) { AcpiGbl_IntegerBitWidth = 32; AcpiGbl_IntegerByteWidth = 4; } else { AcpiGbl_IntegerBitWidth = 64; AcpiGbl_IntegerByteWidth = 8; } } #ifdef ACPI_DEBUG_OUTPUT /******************************************************************************* * * FUNCTION: AcpiUtDisplayInitPathname * * PARAMETERS: ObjHandle - Handle whose pathname will be displayed * Path - Additional path string to be appended * * RETURN: ACPI_STATUS * * DESCRIPTION: Display full pathnbame of an object, DEBUG ONLY * ******************************************************************************/ void AcpiUtDisplayInitPathname ( ACPI_HANDLE ObjHandle, char *Path) { ACPI_STATUS Status; ACPI_BUFFER Buffer; ACPI_FUNCTION_NAME ("UtDisplayInitPathname"); Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); if (ACPI_SUCCESS (Status)) { if (Path) { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "%s.%s\n", (char *) Buffer.Pointer, Path)); } else { ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "%s\n", (char *) Buffer.Pointer)); } ACPI_MEM_FREE (Buffer.Pointer); } } #endif /******************************************************************************* * * FUNCTION: AcpiUtValidAcpiName * * PARAMETERS: Character - The character to be examined * * RETURN: 1 if Character may appear in a name, else 0 * * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: * 1) Upper case alpha * 2) numeric * 3) underscore * ******************************************************************************/ BOOLEAN AcpiUtValidAcpiName ( UINT32 Name) { NATIVE_CHAR *NamePtr = (NATIVE_CHAR *) &Name; UINT32 i; ACPI_FUNCTION_ENTRY (); for (i = 0; i < ACPI_NAME_SIZE; i++) { if (!((NamePtr[i] == '_') || (NamePtr[i] >= 'A' && NamePtr[i] <= 'Z') || (NamePtr[i] >= '0' && NamePtr[i] <= '9'))) { return (FALSE); } } return (TRUE); } /******************************************************************************* * * FUNCTION: AcpiUtValidAcpiCharacter * * PARAMETERS: Character - The character to be examined * * RETURN: 1 if Character may appear in a name, else 0 * * DESCRIPTION: Check for a printable character * ******************************************************************************/ BOOLEAN AcpiUtValidAcpiCharacter ( NATIVE_CHAR Character) { ACPI_FUNCTION_ENTRY (); return ((BOOLEAN) ((Character == '_') || (Character >= 'A' && Character <= 'Z') || (Character >= '0' && Character <= '9'))); } /******************************************************************************* * * FUNCTION: AcpiUtStrtoul64 * * PARAMETERS: String - Null terminated string * 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. * ******************************************************************************/ #define NEGATIVE 1 #define POSITIVE 0 ACPI_STATUS AcpiUtStrtoul64 ( NATIVE_CHAR *String, UINT32 Base, ACPI_INTEGER *RetInteger) { UINT32 Index; ACPI_INTEGER ReturnValue = 0; ACPI_STATUS Status = AE_OK; ACPI_INTEGER Dividend; ACPI_INTEGER Quotient; *RetInteger = 0; switch (Base) { case 0: case 8: case 10: case 16: break; default: /* * The specified Base parameter is not in the domain of * this function: */ return (AE_BAD_PARAMETER); } /* * skip over any white space in the buffer: */ while (ACPI_IS_SPACE (*String) || *String == '\t') { ++String; } /* * If the input parameter Base is zero, then we need to * determine if it is octal, decimal, or hexadecimal: */ if (Base == 0) { if (*String == '0') { if (ACPI_TOLOWER (*(++String)) == 'x') { Base = 16; ++String; } else { Base = 8; } } else { Base = 10; } } /* * For octal and hexadecimal bases, skip over the leading * 0 or 0x, if they are present. */ if (Base == 8 && *String == '0') { String++; } if (Base == 16 && *String == '0' && ACPI_TOLOWER (*(++String)) == 'x') { String++; } /* Main loop: convert the string to an unsigned long */ while (*String) { if (ACPI_IS_DIGIT (*String)) { Index = ((UINT8) *String) - '0'; } else { Index = (UINT8) ACPI_TOUPPER (*String); if (ACPI_IS_UPPER ((char) Index)) { Index = Index - 'A' + 10; } else { goto ErrorExit; } } if (Index >= Base) { goto ErrorExit; } /* Check to see if value is out of range: */ Dividend = ACPI_INTEGER_MAX - (ACPI_INTEGER) Index; (void) AcpiUtShortDivide (&Dividend, Base, &Quotient, NULL); if (ReturnValue > Quotient) { goto ErrorExit; } ReturnValue *= Base; ReturnValue += Index; ++String; } *RetInteger = ReturnValue; return (Status); ErrorExit: switch (Base) { case 8: Status = AE_BAD_OCTAL_CONSTANT; break; case 10: Status = AE_BAD_DECIMAL_CONSTANT; break; case 16: Status = AE_BAD_HEX_CONSTANT; break; default: /* Base validated above */ break; } return (Status); } /******************************************************************************* * * FUNCTION: AcpiUtStrupr * * PARAMETERS: SrcString - The source string to convert to * * RETURN: SrcString * * DESCRIPTION: Convert string to uppercase * ******************************************************************************/ NATIVE_CHAR * AcpiUtStrupr ( NATIVE_CHAR *SrcString) { NATIVE_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_MTX; i++) { Status = AcpiUtCreateMutex (i); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } } return_ACPI_STATUS (AE_OK); } /******************************************************************************* * * 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_MTX; i++) { (void) AcpiUtDeleteMutex (i); } 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_MTX) { return_ACPI_STATUS (AE_BAD_PARAMETER); } if (!AcpiGbl_AcpiMutexInfo[MutexId].Mutex) { Status = AcpiOsCreateSemaphore (1, 1, &AcpiGbl_AcpiMutexInfo[MutexId].Mutex); AcpiGbl_AcpiMutexInfo[MutexId].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; AcpiGbl_AcpiMutexInfo[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_MTX) { return_ACPI_STATUS (AE_BAD_PARAMETER); } Status = AcpiOsDeleteSemaphore (AcpiGbl_AcpiMutexInfo[MutexId].Mutex); AcpiGbl_AcpiMutexInfo[MutexId].Mutex = NULL; AcpiGbl_AcpiMutexInfo[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_MTX) { 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_MTX; i++) { if (AcpiGbl_AcpiMutexInfo[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_AcpiMutexInfo[MutexId].Mutex, - 1, WAIT_FOREVER); + 1, ACPI_WAIT_FOREVER); if (ACPI_SUCCESS (Status)) { ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %X acquired Mutex [%s]\n", ThisThreadId, AcpiUtGetMutexName (MutexId))); AcpiGbl_AcpiMutexInfo[MutexId].UseCount++; AcpiGbl_AcpiMutexInfo[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_MTX) { return (AE_BAD_PARAMETER); } /* * Mutex must be acquired in order to release it! */ if (AcpiGbl_AcpiMutexInfo[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_MTX; i++) { if (AcpiGbl_AcpiMutexInfo[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_AcpiMutexInfo[MutexId].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; Status = AcpiOsSignalSemaphore (AcpiGbl_AcpiMutexInfo[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 * Action - Increment/Decrement * StateList - List the state will be added to * * RETURN: None * * DESCRIPTION: Create a new state and push it * ******************************************************************************/ ACPI_STATUS AcpiUtCreateUpdateStateAndPush ( ACPI_OPERAND_OBJECT *Object, UINT16 Action, ACPI_GENERIC_STATE **StateList) { ACPI_GENERIC_STATE *State; ACPI_FUNCTION_ENTRY (); /* Ignore null objects; these are expected */ if (!Object) { return (AE_OK); } State = AcpiUtCreateUpdateState (Object, Action); if (!State) { return (AE_NO_MEMORY); } AcpiUtPushGenericState (StateList, State); return (AE_OK); } /******************************************************************************* * * 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 * * RETURN: Status * * DESCRIPTION: Walk through a package * ******************************************************************************/ ACPI_STATUS AcpiUtWalkPackageTree ( ACPI_OPERAND_OBJECT *SourceObject, void *TargetObject, ACPI_PKG_CALLBACK WalkCallback, void *Context) { ACPI_STATUS Status = AE_OK; ACPI_GENERIC_STATE *StateList = NULL; ACPI_GENERIC_STATE *State; UINT32 ThisIndex; ACPI_OPERAND_OBJECT *ThisSourceObj; ACPI_FUNCTION_TRACE ("UtWalkPackageTree"); State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0); if (!State) { return_ACPI_STATUS (AE_NO_MEMORY); } while (State) { ThisIndex = State->Pkg.Index; ThisSourceObj = (ACPI_OPERAND_OBJECT *) State->Pkg.SourceObject->Package.Elements[ThisIndex]; /* * Check for: * 1) An uninitialized package element. It is completely * legal to declare a package and leave it uninitialized * 2) Not an internal object - can be a namespace node instead * 3) Any type other than a package. Packages are handled in else * case below. */ if ((!ThisSourceObj) || (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) || (ACPI_GET_OBJECT_TYPE (ThisSourceObj) != ACPI_TYPE_PACKAGE)) { Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj, State, Context); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } State->Pkg.Index++; while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count) { /* * We've handled all of the objects at this level, This means * that we have just completed a package. That package may * have contained one or more packages itself. * * Delete this state and pop the previous state (package). */ AcpiUtDeleteGenericState (State); State = AcpiUtPopGenericState (&StateList); /* Finished when there are no more states */ if (!State) { /* * We have handled all of the objects in the top level * package just add the length of the package objects * and exit */ return_ACPI_STATUS (AE_OK); } /* * Go back up a level and move the index past the just * completed package object. */ State->Pkg.Index++; } } else { /* This is a subobject of type package */ Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj, State, Context); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Push the current state and create a new one * The callback above returned a new target package object. */ AcpiUtPushGenericState (&StateList, State); State = AcpiUtCreatePkgState (ThisSourceObj, State->Pkg.ThisTargetObj, 0); if (!State) { return_ACPI_STATUS (AE_NO_MEMORY); } } } /* We should never get here */ return_ACPI_STATUS (AE_AML_INTERNAL); } /******************************************************************************* * * FUNCTION: AcpiUtGenerateChecksum * * PARAMETERS: Buffer - Buffer to be scanned * Length - number of bytes to examine * * RETURN: checksum * * DESCRIPTION: Generate a checksum on a raw buffer * ******************************************************************************/ UINT8 AcpiUtGenerateChecksum ( UINT8 *Buffer, UINT32 Length) { UINT32 i; signed char Sum = 0; for (i = 0; i < Length; i++) { Sum = (signed char) (Sum + Buffer[i]); } return ((UINT8) (0 - Sum)); } /******************************************************************************* * * 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 * ******************************************************************************/ UINT8 * AcpiUtGetResourceEndTag ( ACPI_OPERAND_OBJECT *ObjDesc) { UINT8 BufferByte; UINT8 *Buffer; UINT8 *EndBuffer; Buffer = ObjDesc->Buffer.Pointer; EndBuffer = Buffer + ObjDesc->Buffer.Length; while (Buffer < EndBuffer) { BufferByte = *Buffer; if (BufferByte & ACPI_RDESC_TYPE_MASK) { /* Large Descriptor - Length is next 2 bytes */ Buffer += ((*(Buffer+1) | (*(Buffer+2) << 8)) + 3); } 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 */ Buffer += ((BufferByte & 0x07) + 1); } } /* End tag not found */ return (NULL); } /******************************************************************************* * * FUNCTION: 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 * * DESCRIPTION: Print error message * ******************************************************************************/ void AcpiUtReportError ( NATIVE_CHAR *ModuleName, UINT32 LineNumber, UINT32 ComponentId) { AcpiOsPrintf ("%8s-%04d: *** Error: ", ModuleName, LineNumber); } /******************************************************************************* * * FUNCTION: 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 * * DESCRIPTION: Print warning message * ******************************************************************************/ void AcpiUtReportWarning ( NATIVE_CHAR *ModuleName, UINT32 LineNumber, UINT32 ComponentId) { AcpiOsPrintf ("%8s-%04d: *** Warning: ", ModuleName, LineNumber); } /******************************************************************************* * * FUNCTION: AcpiUtReportInfo * * 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 * * DESCRIPTION: Print information message * ******************************************************************************/ void AcpiUtReportInfo ( NATIVE_CHAR *ModuleName, UINT32 LineNumber, UINT32 ComponentId) { AcpiOsPrintf ("%8s-%04d: *** Info: ", ModuleName, LineNumber); } diff --git a/sys/contrib/dev/acpica/utobject.c b/sys/contrib/dev/acpica/utobject.c index e7513959502c..67283a0c84bc 100644 --- a/sys/contrib/dev/acpica/utobject.c +++ b/sys/contrib/dev/acpica/utobject.c @@ -1,660 +1,721 @@ /****************************************************************************** * * Module Name: utobject - ACPI object create/delete/size/cache routines - * $Revision: 76 $ + * $Revision: 79 $ * *****************************************************************************/ /****************************************************************************** * * 1. Copyright Notice * * Some or all of this work - Copyright (c) 1999 - 2002, 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 __UTOBJECT_C__ #include "acpi.h" #include "acnamesp.h" #include "amlcode.h" #define _COMPONENT ACPI_UTILITIES ACPI_MODULE_NAME ("utobject") /******************************************************************************* * * FUNCTION: AcpiUtCreateInternalObjectDbg * * PARAMETERS: ModuleName - Source file name of caller * LineNumber - Line number of caller * ComponentId - Component type of caller * Type - ACPI Type of the new object * * RETURN: Object - The new object. Null on failure * * DESCRIPTION: Create and initialize a new internal object. * * NOTE: We always allocate the worst-case object descriptor because * these objects are cached, and we want them to be * one-size-satisifies-any-request. This in itself may not be * the most memory efficient, but the efficiency of the object * cache should more than make up for this! * ******************************************************************************/ ACPI_OPERAND_OBJECT * AcpiUtCreateInternalObjectDbg ( NATIVE_CHAR *ModuleName, UINT32 LineNumber, UINT32 ComponentId, ACPI_OBJECT_TYPE Type) { ACPI_OPERAND_OBJECT *Object; ACPI_OPERAND_OBJECT *SecondObject; ACPI_FUNCTION_TRACE_STR ("UtCreateInternalObjectDbg", AcpiUtGetTypeName (Type)); /* Allocate the raw object descriptor */ Object = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId); if (!Object) { return_PTR (NULL); } switch (Type) { case ACPI_TYPE_REGION: case ACPI_TYPE_BUFFER_FIELD: /* These types require a secondary object */ SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId); if (!SecondObject) { AcpiUtDeleteObjectDesc (Object); return_PTR (NULL); } - SecondObject->Common.Type = INTERNAL_TYPE_EXTRA; + SecondObject->Common.Type = ACPI_TYPE_LOCAL_EXTRA; SecondObject->Common.ReferenceCount = 1; /* Link the second object to the first */ Object->Common.NextObject = SecondObject; break; default: /* All others have no secondary object */ break; } /* Save the object type in the object descriptor */ Object->Common.Type = (UINT8) Type; /* Init the reference count */ Object->Common.ReferenceCount = 1; /* Any per-type initialization should go here */ return_PTR (Object); } +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateBufferObject + * + * PARAMETERS: BufferSize - Size of buffer to be created + * + * RETURN: Pointer to a new Buffer object + * + * DESCRIPTION: Create a fully initialized buffer object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateBufferObject ( + ACPI_SIZE BufferSize) +{ + ACPI_OPERAND_OBJECT *BufferDesc; + UINT8 *Buffer; + + + ACPI_FUNCTION_TRACE_U32 ("UtCreateBufferObject", BufferSize); + + + /* + * Create a new Buffer object + */ + BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + if (!BufferDesc) + { + return_PTR (NULL); + } + + /* Allocate the actual buffer */ + + Buffer = ACPI_MEM_CALLOCATE (BufferSize); + if (!Buffer) + { + ACPI_REPORT_ERROR (("CreateBuffer: could not allocate size %X\n", + (UINT32) BufferSize)); + AcpiUtRemoveReference (BufferDesc); + return_PTR (NULL); + } + + /* Complete buffer object initialization */ + + BufferDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; + BufferDesc->Buffer.Pointer = Buffer; + BufferDesc->Buffer.Length = (UINT32) BufferSize; + + /* Return the new buffer descriptor */ + + return_PTR (BufferDesc); +} + + /******************************************************************************* * * FUNCTION: AcpiUtValidInternalObject * * PARAMETERS: Object - Object to be validated * * RETURN: Validate a pointer to be an ACPI_OPERAND_OBJECT * ******************************************************************************/ BOOLEAN AcpiUtValidInternalObject ( void *Object) { ACPI_FUNCTION_NAME ("UtValidInternalObject"); /* Check for a null pointer */ if (!Object) { - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "**** Null Object Ptr\n")); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Null Object Ptr\n")); return (FALSE); } /* Check the descriptor type field */ switch (ACPI_GET_DESCRIPTOR_TYPE (Object)) { case ACPI_DESC_TYPE_OPERAND: /* The object appears to be a valid ACPI_OPERAND_OBJECT */ return (TRUE); case ACPI_DESC_TYPE_NAMED: ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Obj %p is a named obj, not ACPI obj\n", Object)); break; case ACPI_DESC_TYPE_PARSER: ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Obj %p is a parser obj, not ACPI obj\n", Object)); break; + case ACPI_DESC_TYPE_CACHED: + + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "**** Obj %p has already been released to internal cache\n", Object)); + break; + default: - ACPI_DEBUG_PRINT ((ACPI_DB_INFO, - "**** Obj %p is of unknown type\n", Object)); + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "**** Obj %p has unknown descriptor type %X\n", Object, + ACPI_GET_DESCRIPTOR_TYPE (Object))); break; } return (FALSE); } /******************************************************************************* * * FUNCTION: AcpiUtAllocateObjectDescDbg * * 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) * * RETURN: Pointer to newly allocated object descriptor. Null on error * * DESCRIPTION: Allocate a new object descriptor. Gracefully handle * error conditions. * ******************************************************************************/ void * AcpiUtAllocateObjectDescDbg ( NATIVE_CHAR *ModuleName, UINT32 LineNumber, UINT32 ComponentId) { ACPI_OPERAND_OBJECT *Object; ACPI_FUNCTION_TRACE ("UtAllocateObjectDescDbg"); Object = AcpiUtAcquireFromCache (ACPI_MEM_LIST_OPERAND); if (!Object) { _ACPI_REPORT_ERROR (ModuleName, LineNumber, ComponentId, ("Could not allocate an object descriptor\n")); return_PTR (NULL); } /* Mark the descriptor type */ ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_OPERAND); ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", Object, (UINT32) sizeof (ACPI_OPERAND_OBJECT))); return_PTR (Object); } /******************************************************************************* * * FUNCTION: AcpiUtDeleteObjectDesc * * PARAMETERS: Object - An Acpi internal object to be deleted * * RETURN: None. * * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache * ******************************************************************************/ void AcpiUtDeleteObjectDesc ( ACPI_OPERAND_OBJECT *Object) { ACPI_FUNCTION_TRACE_PTR ("UtDeleteObjectDesc", Object); /* Object must be an ACPI_OPERAND_OBJECT */ if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) { ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Obj %p is not an ACPI object\n", Object)); 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); return_VOID; } /******************************************************************************* * * FUNCTION: AcpiUtGetSimpleObjectSize * * PARAMETERS: *InternalObject - Pointer to the object we are examining * *ObjLength - Where the length is returned * * RETURN: Status * * DESCRIPTION: This function is called to determine the space required to * contain a simple object for return to an external user. * * The length includes the object structure plus any additional * needed space. * ******************************************************************************/ ACPI_STATUS AcpiUtGetSimpleObjectSize ( ACPI_OPERAND_OBJECT *InternalObject, ACPI_SIZE *ObjLength) { ACPI_SIZE Length; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE_PTR ("UtGetSimpleObjectSize", InternalObject); /* Handle a null object (Could be a uninitialized package element -- which is legal) */ if (!InternalObject) { *ObjLength = 0; return_ACPI_STATUS (AE_OK); } /* Start with the length of the Acpi object */ Length = sizeof (ACPI_OBJECT); if (ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_NAMED) { /* Object is a named object (reference), just return the length */ *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length); return_ACPI_STATUS (Status); } /* * The final length depends on the object type * Strings and Buffers are packed right up against the parent object and * must be accessed bytewise or there may be alignment problems on * certain processors */ switch (ACPI_GET_OBJECT_TYPE (InternalObject)) { case ACPI_TYPE_STRING: Length += (ACPI_SIZE) InternalObject->String.Length + 1; break; case ACPI_TYPE_BUFFER: Length += (ACPI_SIZE) InternalObject->Buffer.Length; break; case ACPI_TYPE_INTEGER: case ACPI_TYPE_PROCESSOR: case ACPI_TYPE_POWER: /* * No extra data for these types */ break; - case INTERNAL_TYPE_REFERENCE: + case ACPI_TYPE_LOCAL_REFERENCE: switch (InternalObject->Reference.Opcode) { case AML_INT_NAMEPATH_OP: /* * 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)); break; default: /* * No other reference opcodes are supported. * Notably, Locals and Args are not supported, but this may be * required eventually. */ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported Reference opcode=%X in object %p\n", InternalObject->Reference.Opcode, InternalObject)); Status = AE_TYPE; break; } break; default: ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported type=%X in object %p\n", ACPI_GET_OBJECT_TYPE (InternalObject), InternalObject)); Status = AE_TYPE; break; } /* * Account for the space required by the object rounded up to the next * multiple of the machine word size. This keeps each object aligned * on a machine word boundary. (preventing alignment faults on some * machines.) */ *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length); return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiUtGetElementLength * * PARAMETERS: ACPI_PKG_CALLBACK * * RETURN: Status * * DESCRIPTION: Get the length of one package element. * ******************************************************************************/ ACPI_STATUS AcpiUtGetElementLength ( UINT8 ObjectType, ACPI_OPERAND_OBJECT *SourceObject, ACPI_GENERIC_STATE *State, void *Context) { ACPI_STATUS Status = AE_OK; ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; ACPI_SIZE ObjectSpace; switch (ObjectType) { case ACPI_COPY_TYPE_SIMPLE: /* * Simple object - just get the size (Null object/entry is handled * here also) and sum it into the running package length */ Status = AcpiUtGetSimpleObjectSize (SourceObject, &ObjectSpace); if (ACPI_FAILURE (Status)) { return (Status); } Info->Length += ObjectSpace; break; case ACPI_COPY_TYPE_PACKAGE: /* Package object - nothing much to do here, let the walk handle it */ Info->NumPackages++; State->Pkg.ThisTargetObj = NULL; break; default: /* No other types allowed */ return (AE_BAD_PARAMETER); } return (Status); } /******************************************************************************* * * FUNCTION: AcpiUtGetPackageObjectSize * * PARAMETERS: *InternalObject - Pointer to the object we are examining * *ObjLength - Where the length is returned * * RETURN: Status * * DESCRIPTION: This function is called to determine the space required to * contain a package object for return to an external user. * * This is moderately complex since a package contains other * objects including packages. * ******************************************************************************/ ACPI_STATUS AcpiUtGetPackageObjectSize ( ACPI_OPERAND_OBJECT *InternalObject, ACPI_SIZE *ObjLength) { ACPI_STATUS Status; ACPI_PKG_INFO Info; ACPI_FUNCTION_TRACE_PTR ("UtGetPackageObjectSize", InternalObject); Info.Length = 0; Info.ObjectSpace = 0; Info.NumPackages = 1; Status = AcpiUtWalkPackageTree (InternalObject, NULL, AcpiUtGetElementLength, &Info); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * We have handled all of the objects in all levels of the package. * just add the length of the package objects themselves. * Round up to the next machine word. */ Info.Length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) * (ACPI_SIZE) Info.NumPackages; /* Return the total package length */ *ObjLength = Info.Length; return_ACPI_STATUS (Status); } /******************************************************************************* * * FUNCTION: AcpiUtGetObjectSize * * PARAMETERS: *InternalObject - Pointer to the object we are examining * *ObjLength - Where the length will be returned * * RETURN: Status * * DESCRIPTION: This function is called to determine the space required to * contain an object for return to an API user. * ******************************************************************************/ ACPI_STATUS AcpiUtGetObjectSize( ACPI_OPERAND_OBJECT *InternalObject, ACPI_SIZE *ObjLength) { ACPI_STATUS Status; ACPI_FUNCTION_ENTRY (); if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) && (ACPI_GET_OBJECT_TYPE (InternalObject) == ACPI_TYPE_PACKAGE)) { Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength); } else { Status = AcpiUtGetSimpleObjectSize (InternalObject, ObjLength); } return (Status); }