summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica')
-rw-r--r--sys/contrib/dev/acpica/CHANGES.txt3533
-rw-r--r--sys/contrib/dev/acpica/acapps.h192
-rw-r--r--sys/contrib/dev/acpica/acconfig.h280
-rw-r--r--sys/contrib/dev/acpica/acdebug.h553
-rw-r--r--sys/contrib/dev/acpica/acdisasm.h452
-rw-r--r--sys/contrib/dev/acpica/acdispat.h586
-rw-r--r--sys/contrib/dev/acpica/acdos16.h152
-rw-r--r--sys/contrib/dev/acpica/acefi.h150
-rw-r--r--sys/contrib/dev/acpica/acenv.h438
-rw-r--r--sys/contrib/dev/acpica/acevents.h309
-rw-r--r--sys/contrib/dev/acpica/acexcep.h375
-rw-r--r--sys/contrib/dev/acpica/acfreebsd.h213
-rw-r--r--sys/contrib/dev/acpica/acgcc.h132
-rw-r--r--sys/contrib/dev/acpica/acglobal.h375
-rw-r--r--sys/contrib/dev/acpica/achware.h242
-rw-r--r--sys/contrib/dev/acpica/acinterp.h809
-rw-r--r--sys/contrib/dev/acpica/aclocal.h1084
-rw-r--r--sys/contrib/dev/acpica/acmacros.h670
-rw-r--r--sys/contrib/dev/acpica/acnamesp.h581
-rw-r--r--sys/contrib/dev/acpica/acobject.h591
-rw-r--r--sys/contrib/dev/acpica/acoutput.h258
-rw-r--r--sys/contrib/dev/acpica/acparser.h420
-rw-r--r--sys/contrib/dev/acpica/acpi.h142
-rwxr-xr-xsys/contrib/dev/acpica/acpica_prep.sh69
-rw-r--r--sys/contrib/dev/acpica/acpiosxf.h442
-rw-r--r--sys/contrib/dev/acpica/acpixf.h499
-rw-r--r--sys/contrib/dev/acpica/acresrc.h465
-rw-r--r--sys/contrib/dev/acpica/acstruct.h281
-rw-r--r--sys/contrib/dev/acpica/actables.h310
-rw-r--r--sys/contrib/dev/acpica/actbl.h308
-rw-r--r--sys/contrib/dev/acpica/actbl1.h211
-rw-r--r--sys/contrib/dev/acpica/actbl2.h277
-rw-r--r--sys/contrib/dev/acpica/actbl71.h238
-rw-r--r--sys/contrib/dev/acpica/actypes.h1320
-rw-r--r--sys/contrib/dev/acpica/acutils.h910
-rw-r--r--sys/contrib/dev/acpica/amlcode.h579
-rw-r--r--sys/contrib/dev/acpica/amlresrc.h423
-rw-r--r--sys/contrib/dev/acpica/dbcmds.c1309
-rw-r--r--sys/contrib/dev/acpica/dbdisply.c1056
-rw-r--r--sys/contrib/dev/acpica/dbexec.c582
-rw-r--r--sys/contrib/dev/acpica/dbfileio.c489
-rw-r--r--sys/contrib/dev/acpica/dbhistry.c291
-rw-r--r--sys/contrib/dev/acpica/dbinput.c995
-rw-r--r--sys/contrib/dev/acpica/dbstats.c558
-rw-r--r--sys/contrib/dev/acpica/dbutils.c538
-rw-r--r--sys/contrib/dev/acpica/dbxface.c588
-rw-r--r--sys/contrib/dev/acpica/dmbuffer.c537
-rw-r--r--sys/contrib/dev/acpica/dmnames.c499
-rw-r--r--sys/contrib/dev/acpica/dmopcode.c602
-rw-r--r--sys/contrib/dev/acpica/dmresrc.c528
-rw-r--r--sys/contrib/dev/acpica/dmresrcl.c619
-rw-r--r--sys/contrib/dev/acpica/dmresrcs.c352
-rw-r--r--sys/contrib/dev/acpica/dmutils.c464
-rw-r--r--sys/contrib/dev/acpica/dmwalk.c920
-rw-r--r--sys/contrib/dev/acpica/dsfield.c698
-rw-r--r--sys/contrib/dev/acpica/dsinit.c316
-rw-r--r--sys/contrib/dev/acpica/dsmethod.c649
-rw-r--r--sys/contrib/dev/acpica/dsmthdat.c787
-rw-r--r--sys/contrib/dev/acpica/dsobject.c720
-rw-r--r--sys/contrib/dev/acpica/dsopcode.c1263
-rw-r--r--sys/contrib/dev/acpica/dsutils.c720
-rw-r--r--sys/contrib/dev/acpica/dswexec.c780
-rw-r--r--sys/contrib/dev/acpica/dswload.c1063
-rw-r--r--sys/contrib/dev/acpica/dswscope.c315
-rw-r--r--sys/contrib/dev/acpica/dswstate.c1200
-rw-r--r--sys/contrib/dev/acpica/evevent.c381
-rw-r--r--sys/contrib/dev/acpica/evgpe.c479
-rw-r--r--sys/contrib/dev/acpica/evgpeblk.c645
-rw-r--r--sys/contrib/dev/acpica/evmisc.c712
-rw-r--r--sys/contrib/dev/acpica/evregion.c829
-rw-r--r--sys/contrib/dev/acpica/evrgnini.c650
-rw-r--r--sys/contrib/dev/acpica/evsci.c235
-rw-r--r--sys/contrib/dev/acpica/evxface.c817
-rw-r--r--sys/contrib/dev/acpica/evxfevnt.c581
-rw-r--r--sys/contrib/dev/acpica/evxfregn.c520
-rw-r--r--sys/contrib/dev/acpica/exconfig.c562
-rw-r--r--sys/contrib/dev/acpica/exconvrt.c813
-rw-r--r--sys/contrib/dev/acpica/excreate.c728
-rw-r--r--sys/contrib/dev/acpica/exdump.c901
-rw-r--r--sys/contrib/dev/acpica/exdyadic.c939
-rw-r--r--sys/contrib/dev/acpica/exfield.c463
-rw-r--r--sys/contrib/dev/acpica/exfldio.c1185
-rw-r--r--sys/contrib/dev/acpica/exmisc.c620
-rw-r--r--sys/contrib/dev/acpica/exmonad.c1083
-rw-r--r--sys/contrib/dev/acpica/exmutex.c445
-rw-r--r--sys/contrib/dev/acpica/exnames.c531
-rw-r--r--sys/contrib/dev/acpica/exoparg1.c984
-rw-r--r--sys/contrib/dev/acpica/exoparg2.c716
-rw-r--r--sys/contrib/dev/acpica/exoparg3.c337
-rw-r--r--sys/contrib/dev/acpica/exoparg6.c377
-rw-r--r--sys/contrib/dev/acpica/exprep.c538
-rw-r--r--sys/contrib/dev/acpica/exregion.c615
-rw-r--r--sys/contrib/dev/acpica/exresnte.c356
-rw-r--r--sys/contrib/dev/acpica/exresolv.c570
-rw-r--r--sys/contrib/dev/acpica/exresop.c720
-rw-r--r--sys/contrib/dev/acpica/exstore.c600
-rw-r--r--sys/contrib/dev/acpica/exstoren.c376
-rw-r--r--sys/contrib/dev/acpica/exstorob.c282
-rw-r--r--sys/contrib/dev/acpica/exsystem.c461
-rw-r--r--sys/contrib/dev/acpica/exutils.c462
-rw-r--r--sys/contrib/dev/acpica/hwacpi.c307
-rw-r--r--sys/contrib/dev/acpica/hwgpe.c553
-rw-r--r--sys/contrib/dev/acpica/hwregs.c982
-rw-r--r--sys/contrib/dev/acpica/hwsleep.c553
-rw-r--r--sys/contrib/dev/acpica/hwtimer.c290
-rw-r--r--sys/contrib/dev/acpica/nsaccess.c724
-rw-r--r--sys/contrib/dev/acpica/nsalloc.c762
-rw-r--r--sys/contrib/dev/acpica/nsdump.c776
-rw-r--r--sys/contrib/dev/acpica/nsdumpdv.c220
-rw-r--r--sys/contrib/dev/acpica/nseval.c614
-rw-r--r--sys/contrib/dev/acpica/nsinit.c513
-rw-r--r--sys/contrib/dev/acpica/nsload.c555
-rw-r--r--sys/contrib/dev/acpica/nsnames.c341
-rw-r--r--sys/contrib/dev/acpica/nsobject.c562
-rw-r--r--sys/contrib/dev/acpica/nsparse.c250
-rw-r--r--sys/contrib/dev/acpica/nssearch.c460
-rw-r--r--sys/contrib/dev/acpica/nsutils.c1197
-rw-r--r--sys/contrib/dev/acpica/nswalk.c382
-rw-r--r--sys/contrib/dev/acpica/nsxfeval.c870
-rw-r--r--sys/contrib/dev/acpica/nsxfname.c420
-rw-r--r--sys/contrib/dev/acpica/nsxfobj.c351
-rw-r--r--sys/contrib/dev/acpica/psargs.c846
-rw-r--r--sys/contrib/dev/acpica/psfind.c485
-rw-r--r--sys/contrib/dev/acpica/psopcode.c846
-rw-r--r--sys/contrib/dev/acpica/psparse.c1396
-rw-r--r--sys/contrib/dev/acpica/psscope.c376
-rw-r--r--sys/contrib/dev/acpica/pstree.c418
-rw-r--r--sys/contrib/dev/acpica/psutils.c396
-rw-r--r--sys/contrib/dev/acpica/pswalk.c393
-rw-r--r--sys/contrib/dev/acpica/psxface.c312
-rw-r--r--sys/contrib/dev/acpica/rsaddr.c1318
-rw-r--r--sys/contrib/dev/acpica/rscalc.c953
-rw-r--r--sys/contrib/dev/acpica/rscreate.c522
-rw-r--r--sys/contrib/dev/acpica/rsdump.c1255
-rw-r--r--sys/contrib/dev/acpica/rsio.c624
-rw-r--r--sys/contrib/dev/acpica/rsirq.c671
-rw-r--r--sys/contrib/dev/acpica/rslist.c599
-rw-r--r--sys/contrib/dev/acpica/rsmemory.c644
-rw-r--r--sys/contrib/dev/acpica/rsmisc.c683
-rw-r--r--sys/contrib/dev/acpica/rsutils.c423
-rw-r--r--sys/contrib/dev/acpica/rsxface.c494
-rw-r--r--sys/contrib/dev/acpica/tbconvrt.c573
-rw-r--r--sys/contrib/dev/acpica/tbget.c585
-rw-r--r--sys/contrib/dev/acpica/tbgetall.c403
-rw-r--r--sys/contrib/dev/acpica/tbinstal.c682
-rw-r--r--sys/contrib/dev/acpica/tbrsdt.c406
-rw-r--r--sys/contrib/dev/acpica/tbutils.c323
-rw-r--r--sys/contrib/dev/acpica/tbxface.c541
-rw-r--r--sys/contrib/dev/acpica/tbxfroot.c611
-rw-r--r--sys/contrib/dev/acpica/utalloc.c1119
-rw-r--r--sys/contrib/dev/acpica/utclib.c892
-rw-r--r--sys/contrib/dev/acpica/utcopy.c1009
-rw-r--r--sys/contrib/dev/acpica/utdebug.c714
-rw-r--r--sys/contrib/dev/acpica/utdelete.c756
-rw-r--r--sys/contrib/dev/acpica/uteval.c532
-rw-r--r--sys/contrib/dev/acpica/utglobal.c876
-rw-r--r--sys/contrib/dev/acpica/utinit.c329
-rw-r--r--sys/contrib/dev/acpica/utmath.c428
-rw-r--r--sys/contrib/dev/acpica/utmisc.c1651
-rw-r--r--sys/contrib/dev/acpica/utobject.c721
-rw-r--r--sys/contrib/dev/acpica/utxface.c602
161 files changed, 98909 insertions, 0 deletions
diff --git a/sys/contrib/dev/acpica/CHANGES.txt b/sys/contrib/dev/acpica/CHANGES.txt
new file mode 100644
index 0000000..999f103
--- /dev/null
+++ b/sys/contrib/dev/acpica/CHANGES.txt
@@ -0,0 +1,3533 @@
+28 February 2003. Summary of changes for version 20030228.
+
+
+1) ACPI CA Core Subsystem:
+
+The GPE handling and dispatch code has been completely overhauled
+in preparation for support of GPE Block Devices (ID ACPI0006).
+This affects internal data structures and code only; there should
+be no differences visible externally. One new file has been
+added, evgpeblk.c
+
+The FADT fields GPE0_BLK_LEN and GPE1_BLK_LEN are now the only
+fields that are used to determine the GPE block lengths. The
+REGISTER_BIT_WIDTH field of the X_GPEx_BLK extended address
+structures are ignored. This is per the ACPI specification but
+it isn't very clear. The full 256 Block 0/1 GPEs are now
+supported (the use of REGISTER_BIT_WIDTH limited the number of
+GPEs to 128).
+
+In the SCI interrupt handler, removed the read of the PM1_CONTROL
+register to look at the SCI_EN bit. On some machines, this read
+causes an SMI event and greatly slows down SCI events. (This may
+in fact be the cause of slow battery status response on some
+systems.)
+
+Fixed a problem where a store of a NULL string to a package
+object could cause the premature deletion of the object. This
+was seen during execution of the battery _BIF method on some
+systems, resulting in no battery data being returned.
+
+Added AcpiWalkResources interface to simplify parsing of resource
+lists.
+
+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: 72.0K Code, 9.5K Data, 81.5K Total
+ Debug Version: 153.0K Code, 62.9K Data, 215.9K Total
+ Current Release:
+ Non-Debug Version: 72.3K Code, 9.5K Data, 81.8K Total
+ Debug Version: 154.0K Code, 63.4K Data, 217.4K Total
+
+
+2) Linux
+
+S3 fixes (Ole Rohne)
+
+Update ACPI PHP driver with to use new acpi_walk_resource API
+(Bjorn Helgaas)
+
+Add S4BIOS support (Pavel Machek)
+
+Map in entire table before performing checksum (John Stultz)
+
+Expand the mem= cmdline to allow the specification of reserved
+and ACPI DATA blocks (Pavel Machek)
+
+Never use ACPI on VISWS
+
+Fix derive_pci_id (Ducrot Bruno, Alvaro Lopez)
+
+Revert a change that allowed P_BLK lengths to be 4 or 5. This is
+causing us to think that some systems support C2 when they really
+don't.
+
+Do not count processor objects for non-present CPUs (Thanks to
+Dominik Brodowski)
+
+
+3) iASL Compiler:
+
+Fixed a problem where ASL include files could not be found and
+opened.
+
+Added support for the _PDC reserved name.
+
+
+22 January 2003. Summary of changes for version 20030122.
+
+
+1) ACPI CA Core Subsystem:
+
+Added a check for constructs of the form: Store (Local0, Local0)
+where Local0 is not initialized. Apparently, some BIOS
+programmers believe that this is a NOOP. Since this store
+doesn't do anything anyway, the new prototype behavior will
+ignore this error. This is a case where we can relax the strict
+checking in the interpreter in the name of compatibility.
+
+
+2) Linux
+
+The AcpiSrc Source Conversion Utility has been released with the
+Linux package for the first time. This is the utility that is
+used to convert the ACPI CA base source code to the Linux
+version.
+
+(Both) Handle P_BLK lengths shorter than 6 more gracefully
+
+(Both) Move more headers to include/acpi, and delete an unused
+header.
+
+(Both) Move drivers/acpi/include directory to include/acpi
+
+(Both) Boot functions don't use cmdline, so don't pass it around
+
+(Both) Remove include of unused header (Adrian Bunk)
+
+(Both) acpiphp.h includes both linux/acpi.h and acpi_bus.h. Since
+the
+former now also includes the latter, acpiphp.h only needs the
+one, now.
+
+(2.5) Make it possible to select method of bios restoring after
+S3
+resume. [=> no more ugly ifdefs] (Pavel Machek)
+
+(2.5) Make proc write interfaces work (Pavel Machek)
+
+(2.5) Properly init/clean up in cpufreq/acpi (Dominik Brodowski)
+
+(2.5) Break out ACPI Perf code into its own module, under cpufreq
+(Dominik Brodowski)
+
+(2.4) S4BIOS support (Ducrot Bruno)
+
+(2.4) Fix acpiphp_glue.c for latest ACPI struct changes (Sergio
+Visinoni)
+
+
+3) iASL Compiler:
+
+Added support to disassemble SSDT and PSDTs.
+
+Implemented support to obtain SSDTs from the Windows registry if
+available.
+
+
+----------------------------------------
+09 January 2003. Summary of changes for version 20030109.
+
+1) ACPI CA Core Subsystem:
+
+Changed the behavior of the internal Buffer-to-String conversion
+function. The current ACPI specification states that the
+contents of the buffer are "converted to a string of two-
+character hexadecimal numbers, each separated by a space".
+Unfortunately, this definition is not backwards compatible with
+existing ACPI 1.0 implementations (although the behavior was not
+defined in the ACPI 1.0 specification). The new behavior simply
+copies data from the buffer to the string until a null character
+is found or the end of the buffer is reached. The new String
+object is always null terminated. This problem was seen during
+the generation of _BIF battery data where incorrect strings were
+returned for battery type, etc. This will also require an errata
+to the ACPI specification.
+
+Renamed all instances of NATIVE_UINT and NATIVE_INT to
+ACPI_NATIVE_UINT and ACPI_NATIVE_INT, respectively.
+
+Copyright in all module headers (both Linux and non-Linux) has be
+updated to 2003.
+
+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: 72.0K Code, 9.5K Data, 81.5K Total
+ Debug Version: 153.0K Code, 62.9K Data, 215.9K Total
+ Current Release:
+ Non-Debug Version: 72.0K Code, 9.5K Data, 81.5K Total
+ Debug Version: 153.0K Code, 62.9K Data, 215.9K Total
+
+
+2) Linux
+
+Fixed an oops on module insertion/removal (Matthew Tippett)
+
+(2.4) Fix to handle dynamic size of mp_irqs (Joerg Prante)
+
+(2.5) Replace pr_debug (Randy Dunlap)
+
+(2.5) Remove usage of CPUFREQ_ALL_CPUS (Dominik Brodowski)
+
+(Both) Eliminate spawning of thread from timer callback, in favor
+of schedule_work()
+
+(Both) Show Lid status in /proc (Zdenek OGAR Skalak)
+
+(Both) Added define for Fixed Function HW region (Matthew Wilcox)
+
+(Both) Add missing statics to button.c (Pavel Machek)
+
+Several changes have been made to the source code translation
+utility that generates the Linux Code in order to make the code
+more "Linux-like":
+
+All typedefs on structs and unions have been removed in keeping
+with the Linux coding style.
+
+Removed the non-Linux SourceSafe module revision number from each
+module header.
+
+Completed major overhaul of symbols to be lowercased for linux.
+Doubled the number of symbols that are lowercased.
+
+Fixed a problem where identifiers within procedure headers and
+within quotes were not fully lower cased (they were left with a
+starting capital.)
+
+Some C macros whose only purpose is to allow the generation of 16-
+bit code are now completely removed in the Linux code, increasing
+readability and maintainability.
+
+----------------------------------------
+
+12 December 2002. Summary of changes for version 20021212.
+
+
+1) ACPI CA Core Subsystem:
+
+Fixed a problem where the creation of a zero-length AML Buffer
+would cause a fault.
+
+Fixed a problem where a Buffer object that pointed to a static
+AML buffer (in an ACPI table) could inadvertently be deleted,
+causing memory corruption.
+
+Fixed a problem where a user buffer (passed in to the external
+ACPI CA interfaces) could be overwritten if the buffer was too
+small to complete the operation, causing memory corruption.
+
+Fixed a problem in the Buffer-to-String conversion code where a
+string of length one was always returned, regardless of the size
+of the input Buffer object.
+
+Removed the NATIVE_CHAR data type across the entire source due to
+lack of need and lack of consistent use.
+
+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: 72.1K Code, 9.5K Data, 81.6K Total
+ Debug Version: 152.7K Code, 62.7K Data, 215.4K Total
+ Current Release:
+ Non-Debug Version: 72.0K Code, 9.5K Data, 81.5K Total
+ Debug Version: 153.0K Code, 62.9K Data, 215.9K Total
+
+
+----------------------------------------
+05 December 2002. Summary of changes for version 20021205.
+
+1) ACPI CA Core Subsystem:
+
+Fixed a problem where a store to a String or Buffer object could
+cause corruption of the DSDT if the object type being stored was
+the same as the target object type and the length of the object
+being stored was equal to or smaller than the original (existing)
+target object. This was seen to cause corruption of battery _BIF
+buffers if the _BIF method modified the buffer on the fly.
+
+Fixed a problem where an internal error was generated if a
+control method invocation was used in an OperationRegion, Buffer,
+or Package declaration. This was caused by the deferred parsing
+of the control method and thus the deferred creation of the
+internal method object. The solution to this problem was to
+create the internal method object at the moment the method is
+encountered in the first pass - so that subsequent references to
+the method will able to obtain the required parameter count and
+thus properly parse the method invocation. This problem
+presented itself as an AE_AML_INTERNAL during the pass 1 parse
+phase during table load.
+
+Fixed a problem where the internal String object copy routine did
+not always allocate sufficient memory for the target String
+object and caused memory corruption. This problem was seen to
+cause "Allocation already present in list!" errors as memory
+allocation became corrupted.
+
+Implemented a new function for the evaluation of namespace
+objects that allows the specification of the allowable return
+object types. This simplifies a lot of code that checks for a
+return object of one or more specific objects returned from the
+evaluation (such as _STA, etc.) This may become and external
+function if it would be useful to ACPI-related drivers.
+
+Completed another round of prefixing #defines with "ACPI_" for
+clarity.
+
+Completed additional code restructuring to allow more modular
+linking for iASL compiler and AcpiExec. Several files were split
+creating new files. New files: nsparse.c dsinit.c evgpe.c
+
+Implemented an abort mechanism to terminate an executing control
+method via the AML debugger. This feature is useful for
+debugging control methods that depend (wait) for specific
+hardware responses.
+
+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.9K Code, 63.3K Data, 216.2K Total
+ Current Release:
+ Non-Debug Version: 72.1K Code, 9.5K Data, 81.6K Total
+ Debug Version: 152.7K Code, 62.7K Data, 215.4K Total
+
+
+2) iASL Compiler/Disassembler
+
+Fixed a compiler code generation problem for "Interrupt" Resource
+Descriptors. If specified in the ASL, the optional "Resource
+Source Index" and "Resource Source" fields were not inserted into
+the correct location within the AML resource descriptor, creating
+an invalid descriptor.
+
+Fixed a disassembler problem for "Interrupt" resource
+descriptors. The optional "Resource Source Index" and "Resource
+Source" fields were ignored.
+
+
+----------------------------------------
+22 November 2002. Summary of changes for version 20021122.
+
+
+1) ACPI CA Core Subsystem:
+
+Fixed a reported problem where an object stored to a Method Local
+or Arg was not copied to a new object during the store - the
+object pointer was simply copied to the Local/Arg. This caused
+all subsequent operations on the Local/Arg to also affect the
+original source of the store operation.
+
+Fixed a problem where a store operation to a Method Local or Arg
+was not completed properly if the Local/Arg contained a reference
+(from RefOf) to a named field. The general-purpose store-to-
+namespace-node code is now used so that this case is handled
+automatically.
+
+Fixed a problem where the internal object copy routine would
+cause a protection fault if the object being copied was a Package
+and contained either 1) a NULL package element or 2) a nested sub-
+package.
+
+Fixed a problem with the GPE initialization that resulted from an
+ambiguity in the ACPI specification. One section of the
+specification states that both the address and length of the GPE
+block must be zero if the block is not supported. Another
+section implies that only the address need be zero if the block
+is not supported. The code has been changed so that both the
+address and the length must be non-zero to indicate a valid GPE
+block (i.e., if either the address or the length is zero, the GPE
+block is invalid.)
+
+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.3K Code, 9.0K Data, 80.3K Total
+ Debug Version: 152.7K Code, 63.2K Data, 215.5K Total
+ Current Release:
+ Non-Debug Version: 71.4K Code, 9.0K Data, 80.4K Total
+ Debug Version: 152.9K Code, 63.3K Data, 216.2K Total
+
+
+2) Linux
+
+Cleaned up EC driver. Exported an external EC read/write
+interface. By going through this, other drivers (most notably
+sonypi) will be able to serialize access to the EC.
+
+
+3) iASL Compiler/Disassembler
+
+Implemented support to optionally generate include files for both
+ASM and C (the -i switch). This simplifies BIOS development by
+automatically creating include files that contain external
+declarations for the symbols that are created within the
+(optionally generated) ASM and C AML source files.
+
+
+----------------------------------------
+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 <NULL>
+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 <NULL> 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
new file mode 100644
index 0000000..154593f
--- /dev/null
+++ b/sys/contrib/dev/acpica/acapps.h
@@ -0,0 +1,192 @@
+/******************************************************************************
+ *
+ * Module Name: acapps - common include for ACPI applications/tools
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 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 *Prefix,
+ char **OutFilename,
+ BOOLEAN GetAllTables);
+
+void
+AdPrintStatistics (void);
+
+ACPI_STATUS
+AdFindDsdt(
+ UINT8 **DsdtPtr,
+ UINT32 *DsdtLength);
+
+void
+AdDumpTables (void);
+
+ACPI_STATUS
+AdGetLocalTables (
+ char *Filename,
+ BOOLEAN GetAllTables);
+
+ACPI_STATUS
+AdParseTable (
+ ACPI_TABLE_HEADER *Table);
+
+ACPI_STATUS
+AdDisplayTables (
+ char *Filename,
+ ACPI_TABLE_HEADER *Table);
+
+ACPI_STATUS
+AdDisplayStatistics (void);
+
+
+#endif /* _ACAPPS */
+
diff --git a/sys/contrib/dev/acpica/acconfig.h b/sys/contrib/dev/acpica/acconfig.h
new file mode 100644
index 0000000..25d30f7
--- /dev/null
+++ b/sys/contrib/dev/acpica/acconfig.h
@@ -0,0 +1,280 @@
+/******************************************************************************
+ *
+ * Name: acconfig.h - Global configuration constants
+ * $Revision: 129 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 _ACCONFIG_H
+#define _ACCONFIG_H
+
+
+/******************************************************************************
+ *
+ * Compile-time options
+ *
+ *****************************************************************************/
+
+/*
+ * ACPI_DEBUG_OUTPUT - This switch enables all the debug facilities of the
+ * ACPI subsystem. This includes the DEBUG_PRINT output
+ * statements. When disabled, all DEBUG_PRINT
+ * statements are compiled out.
+ *
+ * ACPI_APPLICATION - Use this switch if the subsystem is going to be run
+ * at the application level.
+ *
+ */
+
+
+/******************************************************************************
+ *
+ * Subsystem Constants
+ *
+ *****************************************************************************/
+
+
+/* Version string */
+
+#define ACPI_CA_VERSION 0x20030228
+
+/* Version of ACPI supported */
+
+#define ACPI_CA_SUPPORT_LEVEL 2
+
+/* Maximum objects in the various object caches */
+
+#define ACPI_MAX_STATE_CACHE_DEPTH 64 /* State objects for stacks */
+#define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */
+#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 64 /* Parse tree objects */
+#define ACPI_MAX_OBJECT_CACHE_DEPTH 64 /* Interpreter operand objects */
+#define ACPI_MAX_WALK_CACHE_DEPTH 4 /* Objects for parse tree walks */
+
+/* String size constants */
+
+#define ACPI_MAX_STRING_LENGTH 512
+#define ACPI_PATHNAME_MAX 256 /* A full namespace pathname */
+
+/* Maximum count for a semaphore object */
+
+#define ACPI_MAX_SEMAPHORE_COUNT 256
+
+/* Max reference count (for debug only) */
+
+#define ACPI_MAX_REFERENCE_COUNT 0x400
+
+/* Size of cached memory mapping for system memory operation region */
+
+#define ACPI_SYSMEM_REGION_WINDOW_SIZE 4096
+
+
+/******************************************************************************
+ *
+ * Configuration of subsystem behavior
+ *
+ *****************************************************************************/
+
+
+/*
+ * Should the subystem abort the loading of an ACPI table if the
+ * table checksum is incorrect?
+ */
+#define ACPI_CHECKSUM_ABORT FALSE
+
+
+/******************************************************************************
+ *
+ * ACPI Specification constants (Do not change unless the specification changes)
+ *
+ *****************************************************************************/
+
+/* Number of distinct GPE register blocks and register width */
+
+#define ACPI_MAX_GPE_BLOCKS 2
+#define ACPI_GPE_REGISTER_WIDTH 8
+
+/*
+ * Method info (in WALK_STATE), containing local variables and argumetns
+ */
+#define ACPI_METHOD_NUM_LOCALS 8
+#define ACPI_METHOD_MAX_LOCAL 7
+
+#define ACPI_METHOD_NUM_ARGS 7
+#define ACPI_METHOD_MAX_ARG 6
+
+/* Maximum length of resulting string when converting from a buffer */
+
+#define ACPI_MAX_STRING_CONVERSION 200
+
+/*
+ * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG
+ */
+#define ACPI_OBJ_NUM_OPERANDS 8
+#define ACPI_OBJ_MAX_OPERAND 7
+
+/* Names within the namespace are 4 bytes long */
+
+#define ACPI_NAME_SIZE 4
+#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */
+#define ACPI_PATH_SEPARATOR '.'
+
+/* Constants used in searching for the RSDP in low memory */
+
+#define ACPI_LO_RSDP_WINDOW_BASE 0 /* Physical Address */
+#define ACPI_HI_RSDP_WINDOW_BASE 0xE0000 /* Physical Address */
+#define ACPI_LO_RSDP_WINDOW_SIZE 0x400
+#define ACPI_HI_RSDP_WINDOW_SIZE 0x20000
+#define ACPI_RSDP_SCAN_STEP 16
+
+/* Operation regions */
+
+#define ACPI_NUM_PREDEFINED_REGIONS 8
+#define ACPI_USER_REGION_BEGIN 0x80
+
+/* Maximum SpaceIds for Operation Regions */
+
+#define ACPI_MAX_ADDRESS_SPACE 255
+
+/* Array sizes. Used for range checking also */
+
+#define ACPI_NUM_ACCESS_TYPES 6
+#define ACPI_NUM_UPDATE_RULES 3
+#define ACPI_NUM_LOCK_RULES 2
+#define ACPI_NUM_MATCH_OPS 6
+#define ACPI_NUM_OPCODES 256
+#define ACPI_NUM_FIELD_NAMES 2
+
+/* RSDP checksums */
+
+#define ACPI_RSDP_CHECKSUM_LENGTH 20
+#define ACPI_RSDP_XCHECKSUM_LENGTH 36
+
+/* SMBus bidirectional buffer size */
+
+#define ACPI_SMBUS_BUFFER_SIZE 34
+
+
+/******************************************************************************
+ *
+ * ACPI AML Debugger
+ *
+ *****************************************************************************/
+
+
+#define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */
+
+#define ACPI_DEBUGGER_COMMAND_PROMPT '-'
+#define ACPI_DEBUGGER_EXECUTE_PROMPT '%'
+
+
+#endif /* _ACCONFIG_H */
+
diff --git a/sys/contrib/dev/acpica/acdebug.h b/sys/contrib/dev/acpica/acdebug.h
new file mode 100644
index 0000000..4ca325b
--- /dev/null
+++ b/sys/contrib/dev/acpica/acdebug.h
@@ -0,0 +1,553 @@
+/******************************************************************************
+ *
+ * Name: acdebug.h - ACPI/AML debugger
+ * $Revision: 70 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACDEBUG_H__
+#define __ACDEBUG_H__
+
+
+#define ACPI_DEBUG_BUFFER_SIZE 4196
+
+typedef struct CommandInfo
+{
+ char *Name; /* Command Name */
+ UINT8 MinArgs; /* Minimum arguments required */
+
+} COMMAND_INFO;
+
+
+typedef struct ArgumentInfo
+{
+ char *Name; /* Argument Name */
+
+} ARGUMENT_INFO;
+
+
+#define PARAM_LIST(pl) pl
+
+#define DBTEST_OUTPUT_LEVEL(lvl) if (AcpiGbl_DbOpt_verbose)
+
+#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\
+ AcpiOsPrintf PARAM_LIST(fp);}
+
+#define EX_NO_SINGLE_STEP 1
+#define EX_SINGLE_STEP 2
+
+
+/* Prototypes */
+
+
+/*
+ * dbxface - external debugger interfaces
+ */
+
+ACPI_STATUS
+AcpiDbInitialize (
+ void);
+
+void
+AcpiDbTerminate (
+ void);
+
+ACPI_STATUS
+AcpiDbSingleStep (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 OpType);
+
+ACPI_STATUS
+AcpiDbStartCommand (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op);
+
+void
+AcpiDbMethodEnd (
+ ACPI_WALK_STATE *WalkState);
+
+
+/*
+ * dbcmds - debug commands and output routines
+ */
+
+void
+AcpiDbDisplayTableInfo (
+ char *TableArg);
+
+void
+AcpiDbUnloadAcpiTable (
+ char *TableArg,
+ char *InstanceArg);
+
+void
+AcpiDbSetMethodBreakpoint (
+ char *Location,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op);
+
+void
+AcpiDbSetMethodCallBreakpoint (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+AcpiDbDisassembleAml (
+ char *Statements,
+ ACPI_PARSE_OBJECT *Op);
+
+void
+AcpiDbDumpNamespace (
+ char *StartArg,
+ char *DepthArg);
+
+void
+AcpiDbDumpNamespaceByOwner (
+ char *OwnerArg,
+ char *DepthArg);
+
+void
+AcpiDbSendNotify (
+ char *Name,
+ UINT32 Value);
+
+void
+AcpiDbSetMethodData (
+ char *TypeArg,
+ char *IndexArg,
+ char *ValueArg);
+
+ACPI_STATUS
+AcpiDbDisplayObjects (
+ char *ObjTypeArg,
+ char *DisplayCountArg);
+
+ACPI_STATUS
+AcpiDbFindNameInNamespace (
+ char *NameArg);
+
+void
+AcpiDbSetScope (
+ char *Name);
+
+void
+AcpiDbFindReferences (
+ char *ObjectArg);
+
+void
+AcpiDbDisplayLocks (void);
+
+
+void
+AcpiDbDisplayResources (
+ char *ObjectArg);
+
+void
+AcpiDbDisplayGpes (void);
+
+void
+AcpiDbCheckIntegrity (
+ void);
+
+ACPI_STATUS
+AcpiDbIntegrityWalk (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue);
+
+ACPI_STATUS
+AcpiDbWalkAndMatchName (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue);
+
+ACPI_STATUS
+AcpiDbWalkForReferences (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue);
+
+ACPI_STATUS
+AcpiDbWalkForSpecificObjects (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue);
+
+void
+AcpiDbGenerateGpe (
+ char *GpeArg,
+ char *BlockArg);
+
+/*
+ * dbdisply - debug display commands
+ */
+
+void
+AcpiDbDisplayMethodInfo (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+AcpiDbDecodeAndDisplayObject (
+ char *Target,
+ char *OutputType);
+
+void
+AcpiDbDecodeNode (
+ ACPI_NAMESPACE_NODE *Node);
+
+void
+AcpiDbDisplayResultObject (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_WALK_STATE *WalkState);
+
+ACPI_STATUS
+AcpiDbDisplayAllMethods (
+ char *DisplayCountArg);
+
+void
+AcpiDbDisplayInternalObject (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_WALK_STATE *WalkState);
+
+void
+AcpiDbDisplayArguments (
+ void);
+
+void
+AcpiDbDisplayLocals (
+ void);
+
+void
+AcpiDbDisplayResults (
+ void);
+
+void
+AcpiDbDisplayCallingTree (
+ void);
+
+void
+AcpiDbDisplayArgumentObject (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_WALK_STATE *WalkState);
+
+void
+AcpiDbDumpParserDescriptor (
+ ACPI_PARSE_OBJECT *Op);
+
+void *
+AcpiDbGetPointer (
+ void *Target);
+
+void
+AcpiDbDecodeInternalObject (
+ ACPI_OPERAND_OBJECT *ObjDesc);
+
+
+/*
+ * dbexec - debugger control method execution
+ */
+
+void
+AcpiDbExecute (
+ char *Name,
+ char **Args,
+ UINT32 Flags);
+
+void
+AcpiDbCreateExecutionThreads (
+ char *NumThreadsArg,
+ char *NumLoopsArg,
+ char *MethodNameArg);
+
+ACPI_STATUS
+AcpiDbExecuteMethod (
+ ACPI_DB_METHOD_INFO *Info,
+ ACPI_BUFFER *ReturnObj);
+
+void
+AcpiDbExecuteSetup (
+ ACPI_DB_METHOD_INFO *Info);
+
+UINT32
+AcpiDbGetOutstandingAllocations (
+ void);
+
+void ACPI_SYSTEM_XFACE
+AcpiDbMethodThread (
+ void *Context);
+
+ACPI_STATUS
+AcpiDbExecutionWalk (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue);
+
+
+/*
+ * dbfileio - Debugger file I/O commands
+ */
+
+ACPI_OBJECT_TYPE
+AcpiDbMatchArgument (
+ char *UserArgument,
+ ARGUMENT_INFO *Arguments);
+
+ACPI_STATUS
+AeLocalLoadTable (
+ ACPI_TABLE_HEADER *TablePtr);
+
+void
+AcpiDbCloseDebugFile (
+ void);
+
+void
+AcpiDbOpenDebugFile (
+ char *Name);
+
+ACPI_STATUS
+AcpiDbLoadAcpiTable (
+ char *Filename);
+
+ACPI_STATUS
+AcpiDbGetTableFromFile (
+ char *Filename,
+ ACPI_TABLE_HEADER **Table);
+
+ACPI_STATUS
+AcpiDbReadTableFromFile (
+ char *Filename,
+ ACPI_TABLE_HEADER **Table);
+
+/*
+ * dbhistry - debugger HISTORY command
+ */
+
+void
+AcpiDbAddToHistory (
+ char *CommandLine);
+
+void
+AcpiDbDisplayHistory (void);
+
+char *
+AcpiDbGetFromHistory (
+ char *CommandNumArg);
+
+
+/*
+ * dbinput - user front-end to the AML debugger
+ */
+
+ACPI_STATUS
+AcpiDbCommandDispatch (
+ char *InputBuffer,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op);
+
+void ACPI_SYSTEM_XFACE
+AcpiDbExecuteThread (
+ void *Context);
+
+ACPI_STATUS
+AcpiDbUserCommands (
+ char Prompt,
+ ACPI_PARSE_OBJECT *Op);
+
+void
+AcpiDbDisplayHelp (
+ char *HelpType);
+
+char *
+AcpiDbGetNextToken (
+ char *String,
+ char **Next);
+
+UINT32
+AcpiDbGetLine (
+ char *InputBuffer);
+
+UINT32
+AcpiDbMatchCommand (
+ char *UserCommand);
+
+void
+AcpiDbSingleThread (
+ void);
+
+
+/*
+ * dbstats - Generation and display of ACPI table statistics
+ */
+
+void
+AcpiDbGenerateStatistics (
+ ACPI_PARSE_OBJECT *Root,
+ BOOLEAN IsMethod);
+
+
+ACPI_STATUS
+AcpiDbDisplayStatistics (
+ char *TypeArg);
+
+ACPI_STATUS
+AcpiDbClassifyOneObject (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue);
+
+void
+AcpiDbCountNamespaceObjects (
+ void);
+
+void
+AcpiDbEnumerateObject (
+ ACPI_OPERAND_OBJECT *ObjDesc);
+
+
+/*
+ * dbutils - AML debugger utilities
+ */
+
+void
+AcpiDbSetOutputDestination (
+ UINT32 Where);
+
+void
+AcpiDbDumpBuffer (
+ UINT32 Address);
+
+void
+AcpiDbDumpObject (
+ ACPI_OBJECT *ObjDesc,
+ UINT32 Level);
+
+void
+AcpiDbPrepNamestring (
+ char *Name);
+
+
+ACPI_STATUS
+AcpiDbSecondPassParse (
+ ACPI_PARSE_OBJECT *Root);
+
+ACPI_NAMESPACE_NODE *
+AcpiDbLocalNsLookup (
+ char *Name);
+
+
+#endif /* __ACDEBUG_H__ */
diff --git a/sys/contrib/dev/acpica/acdisasm.h b/sys/contrib/dev/acpica/acdisasm.h
new file mode 100644
index 0000000..021d189
--- /dev/null
+++ b/sys/contrib/dev/acpica/acdisasm.h
@@ -0,0 +1,452 @@
+/******************************************************************************
+ *
+ * Name: acdisasm.h - AML disassembler
+ * $Revision: 8 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 char *AcpiGbl_LockRule[ACPI_NUM_LOCK_RULES];
+extern const char *AcpiGbl_AccessTypes[ACPI_NUM_ACCESS_TYPES];
+extern const char *AcpiGbl_UpdateRules[ACPI_NUM_UPDATE_RULES];
+extern const char *AcpiGbl_MatchOps[ACPI_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
+AcpiDmUnicode (
+ ACPI_PARSE_OBJECT *Op);
+
+void
+AcpiDmDisassemble (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Origin,
+ UINT32 NumOpcodes);
+
+void
+AcpiDmNamestring (
+ char *Name);
+
+void
+AcpiDmDisplayPath (
+ ACPI_PARSE_OBJECT *Op);
+
+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
new file mode 100644
index 0000000..bd14a6a
--- /dev/null
+++ b/sys/contrib/dev/acpica/acdispat.h
@@ -0,0 +1,586 @@
+/******************************************************************************
+ *
+ * Name: acdispat.h - dispatcher (parser to interpreter interface)
+ * $Revision: 56 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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/acdos16.h b/sys/contrib/dev/acpica/acdos16.h
new file mode 100644
index 0000000..435f293
--- /dev/null
+++ b/sys/contrib/dev/acpica/acdos16.h
@@ -0,0 +1,152 @@
+/******************************************************************************
+ *
+ * Name: acdos16.h - DOS specific defines, etc.
+ * $Revision: 2 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 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 __ACDOS16_H__
+#define __ACDOS16_H__
+
+#define ACPI_USE_STANDARD_HEADERS
+#define ACPI_OS_NAME "MSDOS"
+
+/*
+ * Calling conventions:
+ *
+ * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
+ * ACPI_EXTERNAL_XFACE - External ACPI interfaces
+ * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
+ * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
+ */
+#define ACPI_SYSTEM_XFACE __cdecl
+#define ACPI_EXTERNAL_XFACE
+#define ACPI_INTERNAL_XFACE
+#define ACPI_INTERNAL_VAR_XFACE __cdecl
+
+#define ACPI_ASM_MACROS
+#define BREAKPOINT3
+#define ACPI_DISABLE_IRQS()
+#define ACPI_ENABLE_IRQS()
+#define halt()
+#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq)
+#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq)
+
+
+
+/* This macro is used to tag functions as "printf-like" because
+ * some compilers can catch printf format string problems. MSVC
+ * doesn't, so this is proprocessed away.
+ */
+#define ACPI_PRINTF_LIKE_FUNC
+
+#endif /* __ACDOS16_H__ */
diff --git a/sys/contrib/dev/acpica/acefi.h b/sys/contrib/dev/acpica/acefi.h
new file mode 100644
index 0000000..a7d7bb0
--- /dev/null
+++ b/sys/contrib/dev/acpica/acefi.h
@@ -0,0 +1,150 @@
+/******************************************************************************
+ *
+ * Name: acefi.h - OS specific defines, etc.
+ * $Revision: 13 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACEFI_H__
+#define __ACEFI_H__
+
+#define ACPI_OS_NAME "AED EFI"
+
+#include <efi.h>
+#include <efistdarg.h>
+#include <efilib.h>
+
+
+/* _int64 works for both IA32 and IA64 */
+
+#define COMPILER_DEPENDENT_INT64 __int64
+#define COMPILER_DEPENDENT_UINT64 unsigned __int64
+
+/*
+ * Calling conventions:
+ *
+ * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
+ * ACPI_EXTERNAL_XFACE - External ACPI interfaces
+ * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
+ * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
+ */
+#define ACPI_SYSTEM_XFACE
+#define ACPI_EXTERNAL_XFACE
+#define ACPI_INTERNAL_XFACE
+#define ACPI_INTERNAL_VAR_XFACE
+
+/* warn C4142: redefinition of type */
+
+#pragma warning(disable:4142)
+
+
+#endif /* __ACEFI_H__ */
diff --git a/sys/contrib/dev/acpica/acenv.h b/sys/contrib/dev/acpica/acenv.h
new file mode 100644
index 0000000..5cc9376
--- /dev/null
+++ b/sys/contrib/dev/acpica/acenv.h
@@ -0,0 +1,438 @@
+/******************************************************************************
+ *
+ * Name: acenv.h - Generation environment specific items
+ * $Revision: 104 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACENV_H__
+#define __ACENV_H__
+
+
+/*
+ * Configuration for ACPI tools and utilities
+ */
+
+#ifdef _ACPI_DUMP_APP
+#ifndef MSDOS
+#define ACPI_DEBUG_OUTPUT
+#endif
+#define ACPI_APPLICATION
+#define ACPI_DISASSEMBLER
+#define ACPI_NO_METHOD_EXECUTION
+#define ACPI_USE_SYSTEM_CLIBRARY
+#endif
+
+#ifdef _ACPI_EXEC_APP
+#undef DEBUGGER_THREADING
+#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
+#define ACPI_DEBUG_OUTPUT
+#define ACPI_APPLICATION
+#define ACPI_DEBUGGER
+#define ACPI_DISASSEMBLER
+#define ACPI_USE_SYSTEM_CLIBRARY
+#endif
+
+#ifdef _ACPI_ASL_COMPILER
+#define ACPI_DEBUG_OUTPUT
+#define ACPI_APPLICATION
+#define ACPI_DISASSEMBLER
+#define ACPI_CONSTANT_EVAL_ONLY
+#define ACPI_USE_SYSTEM_CLIBRARY
+#endif
+
+/*
+ * Environment configuration. The purpose of this file is to interface to the
+ * local generation environment.
+ *
+ * 1) ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library.
+ * Otherwise, local versions of string/memory functions will be used.
+ * 2) ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and
+ * the standard header files may be used.
+ *
+ * The ACPI subsystem only uses low level C library functions that do not call
+ * operating system services and may therefore be inlined in the code.
+ *
+ * It may be necessary to tailor these include files to the target
+ * generation environment.
+ *
+ *
+ * Functions and constants used from each header:
+ *
+ * string.h: memcpy
+ * memset
+ * strcat
+ * strcmp
+ * strcpy
+ * strlen
+ * strncmp
+ * strncat
+ * strncpy
+ *
+ * stdlib.h: strtoul
+ *
+ * stdarg.h: va_list
+ * va_arg
+ * va_start
+ * va_end
+ *
+ */
+
+/*! [Begin] no source code translation */
+
+#if defined(__linux__)
+#include "aclinux.h"
+
+#elif defined(_AED_EFI)
+#include "acefi.h"
+
+#elif defined(WIN32)
+#include "acwin.h"
+
+#elif defined(WIN64)
+#include "acwin64.h"
+
+#elif defined(MSDOS) /* Must appear after WIN32 and WIN64 check */
+#include "acdos16.h"
+
+#elif defined(__FreeBSD__)
+#include "acfreebsd.h"
+
+#elif defined(MODESTO)
+#include "acmodesto.h"
+
+#elif defined(NETWARE)
+#include "acnetware.h"
+
+#else
+
+/* All other environments */
+
+#define ACPI_USE_STANDARD_HEADERS
+
+#define COMPILER_DEPENDENT_INT64 long long
+#define COMPILER_DEPENDENT_UINT64 unsigned long long
+
+
+/* Name of host operating system (returned by the _OS_ namespace object) */
+
+#define ACPI_OS_NAME "Intel ACPI/CA Core Subsystem"
+
+/* This macro is used to tag functions as "printf-like" because
+ * some compilers can catch printf format string problems. MSVC
+ * doesn't, so this is proprocessed away.
+ */
+#define ACPI_PRINTF_LIKE_FUNC
+
+#endif
+
+/*
+ * Memory allocation tracking. Used only if
+ * 1) This is the debug version
+ * 2) This is NOT a 16-bit version of the code (not enough real-mode memory)
+ */
+#ifdef ACPI_DEBUG_OUTPUT
+#if ACPI_MACHINE_WIDTH != 16
+#define ACPI_DBG_TRACK_ALLOCATIONS
+#endif
+#endif
+
+/*! [End] no source code translation !*/
+
+
+/*
+ * Debugger threading model
+ * Use single threaded if the entire subsystem is contained in an application
+ * Use multiple threaded when the subsystem is running in the kernel.
+ *
+ * By default the model is single threaded if ACPI_APPLICATION is set,
+ * multi-threaded if ACPI_APPLICATION is not set.
+ */
+#define DEBUGGER_SINGLE_THREADED 0
+#define DEBUGGER_MULTI_THREADED 1
+
+#ifndef DEBUGGER_THREADING
+#ifdef ACPI_APPLICATION
+#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED
+
+#else
+#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED
+#endif
+#endif
+
+
+/******************************************************************************
+ *
+ * C library configuration
+ *
+ *****************************************************************************/
+
+#ifdef ACPI_USE_SYSTEM_CLIBRARY
+/*
+ * Use the standard C library headers.
+ * We want to keep these to a minimum.
+ */
+
+#ifdef ACPI_USE_STANDARD_HEADERS
+/*
+ * Use the standard headers from the standard locations
+ */
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#endif /* ACPI_USE_STANDARD_HEADERS */
+
+/*
+ * We will be linking to the standard Clib functions
+ */
+
+#define ACPI_STRSTR(s1,s2) strstr((s1), (s2))
+#define ACPI_STRUPR(s) (void) AcpiUtStrupr ((s))
+#define ACPI_STRLEN(s) (ACPI_SIZE) strlen((s))
+#define ACPI_STRCPY(d,s) (void) strcpy((d), (s))
+#define ACPI_STRNCPY(d,s,n) (void) strncpy((d), (s), (ACPI_SIZE)(n))
+#define ACPI_STRNCMP(d,s,n) strncmp((d), (s), (ACPI_SIZE)(n))
+#define ACPI_STRCMP(d,s) strcmp((d), (s))
+#define ACPI_STRCAT(d,s) (void) strcat((d), (s))
+#define ACPI_STRNCAT(d,s,n) strncat((d), (s), (ACPI_SIZE)(n))
+#define ACPI_STRTOUL(d,s,n) strtoul((d), (s), (ACPI_SIZE)(n))
+#define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (ACPI_SIZE)(n))
+#define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (ACPI_SIZE)(n))
+
+#define ACPI_TOUPPER toupper
+#define ACPI_TOLOWER tolower
+#define ACPI_IS_XDIGIT isxdigit
+#define ACPI_IS_DIGIT isdigit
+#define ACPI_IS_SPACE isspace
+#define ACPI_IS_UPPER isupper
+#define ACPI_IS_PRINT isprint
+#define ACPI_IS_ALPHA isalpha
+#define ACPI_IS_ASCII isascii
+
+/******************************************************************************
+ *
+ * Not using native C library, use local implementations
+ *
+ *****************************************************************************/
+#else
+
+/*
+ * Use local definitions of C library macros and functions
+ * NOTE: The function implementations may not be as efficient
+ * as an inline or assembly code implementation provided by a
+ * native C library.
+ */
+
+#ifndef va_arg
+
+#ifndef _VALIST
+#define _VALIST
+typedef char *va_list;
+#endif /* _VALIST */
+
+/*
+ * Storage alignment properties
+ */
+
+#define _AUPBND (sizeof (ACPI_NATIVE_INT) - 1)
+#define _ADNBND (sizeof (ACPI_NATIVE_INT) - 1)
+
+/*
+ * Variable argument list macro definitions
+ */
+
+#define _Bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))
+#define va_arg(ap, T) (*(T *)(((ap) += (_Bnd (T, _AUPBND))) - (_Bnd (T,_ADNBND))))
+#define va_end(ap) (void) 0
+#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_Bnd (A,_AUPBND))))
+
+#endif /* va_arg */
+
+
+#define ACPI_STRSTR(s1,s2) AcpiUtStrstr ((s1), (s2))
+#define ACPI_STRUPR(s) (void) AcpiUtStrupr ((s))
+#define ACPI_STRLEN(s) (ACPI_SIZE) AcpiUtStrlen ((s))
+#define ACPI_STRCPY(d,s) (void) AcpiUtStrcpy ((d), (s))
+#define ACPI_STRNCPY(d,s,n) (void) AcpiUtStrncpy ((d), (s), (ACPI_SIZE)(n))
+#define ACPI_STRNCMP(d,s,n) AcpiUtStrncmp ((d), (s), (ACPI_SIZE)(n))
+#define ACPI_STRCMP(d,s) AcpiUtStrcmp ((d), (s))
+#define ACPI_STRCAT(d,s) (void) AcpiUtStrcat ((d), (s))
+#define ACPI_STRNCAT(d,s,n) AcpiUtStrncat ((d), (s), (ACPI_SIZE)(n))
+#define ACPI_STRTOUL(d,s,n) AcpiUtStrtoul ((d), (s), (ACPI_SIZE)(n))
+#define ACPI_MEMCPY(d,s,n) (void) AcpiUtMemcpy ((d), (s), (ACPI_SIZE)(n))
+#define ACPI_MEMSET(d,v,n) (void) AcpiUtMemset ((d), (v), (ACPI_SIZE)(n))
+#define ACPI_TOUPPER AcpiUtToUpper
+#define ACPI_TOLOWER AcpiUtToLower
+
+#endif /* ACPI_USE_SYSTEM_CLIBRARY */
+
+
+/******************************************************************************
+ *
+ * Assembly code macros
+ *
+ *****************************************************************************/
+
+/*
+ * Handle platform- and compiler-specific assembly language differences.
+ * These should already have been defined by the platform includes above.
+ *
+ * Notes:
+ * 1) Interrupt 3 is used to break into a debugger
+ * 2) Interrupts are turned off during ACPI register setup
+ */
+
+/* Unrecognized compiler, use defaults */
+
+#ifndef ACPI_ASM_MACROS
+
+/*
+ * Calling conventions:
+ *
+ * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
+ * ACPI_EXTERNAL_XFACE - External ACPI interfaces
+ * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
+ * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
+ */
+#define ACPI_SYSTEM_XFACE
+#define ACPI_EXTERNAL_XFACE
+#define ACPI_INTERNAL_XFACE
+#define ACPI_INTERNAL_VAR_XFACE
+
+#define ACPI_ASM_MACROS
+#define BREAKPOINT3
+#define ACPI_DISABLE_IRQS()
+#define ACPI_ENABLE_IRQS()
+#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq)
+#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq)
+
+#endif /* ACPI_ASM_MACROS */
+
+
+#ifdef ACPI_APPLICATION
+
+/* Don't want software interrupts within a ring3 application */
+
+#undef BREAKPOINT3
+#define BREAKPOINT3
+#endif
+
+
+/******************************************************************************
+ *
+ * Compiler-specific information is contained in the compiler-specific
+ * headers.
+ *
+ *****************************************************************************/
+#endif /* __ACENV_H__ */
diff --git a/sys/contrib/dev/acpica/acevents.h b/sys/contrib/dev/acpica/acevents.h
new file mode 100644
index 0000000..a18b999
--- /dev/null
+++ b/sys/contrib/dev/acpica/acevents.h
@@ -0,0 +1,309 @@
+/******************************************************************************
+ *
+ * Name: acevents.h - Event subcomponent prototypes and defines
+ * $Revision: 83 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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(
+ UINT16 Timeout);
+
+ACPI_STATUS
+AcpiEvReleaseGlobalLock(
+ void);
+
+ACPI_STATUS
+AcpiEvInitGlobalLockHandler (
+ void);
+
+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_GPE_EVENT_INFO *
+AcpiEvGetGpeEventInfo (
+ UINT32 GpeNumber);
+
+ACPI_STATUS
+AcpiEvGpeInitialize (
+ void);
+
+UINT32
+AcpiEvGpeDispatch (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo);
+
+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/acexcep.h b/sys/contrib/dev/acpica/acexcep.h
new file mode 100644
index 0000000..9034a4a
--- /dev/null
+++ b/sys/contrib/dev/acpica/acexcep.h
@@ -0,0 +1,375 @@
+/******************************************************************************
+ *
+ * Name: acexcep.h - Exception codes returned by the ACPI subsystem
+ * $Revision: 67 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACEXCEP_H__
+#define __ACEXCEP_H__
+
+
+/*
+ * Exceptions returned by external ACPI interfaces
+ */
+
+#define AE_CODE_ENVIRONMENTAL 0x0000
+#define AE_CODE_PROGRAMMER 0x1000
+#define AE_CODE_ACPI_TABLES 0x2000
+#define AE_CODE_AML 0x3000
+#define AE_CODE_CONTROL 0x4000
+#define AE_CODE_MASK 0xF000
+
+
+#define ACPI_SUCCESS(a) (!(a))
+#define ACPI_FAILURE(a) (a)
+
+
+#define AE_OK (ACPI_STATUS) 0x0000
+
+/*
+ * Environmental exceptions
+ */
+#define AE_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_ENVIRONMENTAL)
+#define AE_NO_ACPI_TABLES (ACPI_STATUS) (0x0002 | AE_CODE_ENVIRONMENTAL)
+#define AE_NO_NAMESPACE (ACPI_STATUS) (0x0003 | AE_CODE_ENVIRONMENTAL)
+#define AE_NO_MEMORY (ACPI_STATUS) (0x0004 | AE_CODE_ENVIRONMENTAL)
+#define AE_NOT_FOUND (ACPI_STATUS) (0x0005 | AE_CODE_ENVIRONMENTAL)
+#define AE_NOT_EXIST (ACPI_STATUS) (0x0006 | AE_CODE_ENVIRONMENTAL)
+#define AE_ALREADY_EXISTS (ACPI_STATUS) (0x0007 | AE_CODE_ENVIRONMENTAL)
+#define AE_TYPE (ACPI_STATUS) (0x0008 | AE_CODE_ENVIRONMENTAL)
+#define AE_NULL_OBJECT (ACPI_STATUS) (0x0009 | AE_CODE_ENVIRONMENTAL)
+#define AE_NULL_ENTRY (ACPI_STATUS) (0x000A | AE_CODE_ENVIRONMENTAL)
+#define AE_BUFFER_OVERFLOW (ACPI_STATUS) (0x000B | AE_CODE_ENVIRONMENTAL)
+#define AE_STACK_OVERFLOW (ACPI_STATUS) (0x000C | AE_CODE_ENVIRONMENTAL)
+#define AE_STACK_UNDERFLOW (ACPI_STATUS) (0x000D | AE_CODE_ENVIRONMENTAL)
+#define AE_NOT_IMPLEMENTED (ACPI_STATUS) (0x000E | AE_CODE_ENVIRONMENTAL)
+#define AE_VERSION_MISMATCH (ACPI_STATUS) (0x000F | AE_CODE_ENVIRONMENTAL)
+#define AE_SUPPORT (ACPI_STATUS) (0x0010 | AE_CODE_ENVIRONMENTAL)
+#define AE_SHARE (ACPI_STATUS) (0x0011 | AE_CODE_ENVIRONMENTAL)
+#define AE_LIMIT (ACPI_STATUS) (0x0012 | AE_CODE_ENVIRONMENTAL)
+#define AE_TIME (ACPI_STATUS) (0x0013 | AE_CODE_ENVIRONMENTAL)
+#define AE_UNKNOWN_STATUS (ACPI_STATUS) (0x0014 | AE_CODE_ENVIRONMENTAL)
+#define AE_ACQUIRE_DEADLOCK (ACPI_STATUS) (0x0015 | AE_CODE_ENVIRONMENTAL)
+#define AE_RELEASE_DEADLOCK (ACPI_STATUS) (0x0016 | AE_CODE_ENVIRONMENTAL)
+#define AE_NOT_ACQUIRED (ACPI_STATUS) (0x0017 | AE_CODE_ENVIRONMENTAL)
+#define AE_ALREADY_ACQUIRED (ACPI_STATUS) (0x0018 | AE_CODE_ENVIRONMENTAL)
+#define AE_NO_HARDWARE_RESPONSE (ACPI_STATUS) (0x0019 | AE_CODE_ENVIRONMENTAL)
+#define AE_NO_GLOBAL_LOCK (ACPI_STATUS) (0x001A | AE_CODE_ENVIRONMENTAL)
+#define AE_LOGICAL_ADDRESS (ACPI_STATUS) (0x001B | AE_CODE_ENVIRONMENTAL)
+#define AE_ABORT_METHOD (ACPI_STATUS) (0x001C | AE_CODE_ENVIRONMENTAL)
+
+#define AE_CODE_ENV_MAX 0x001C
+
+/*
+ * Programmer exceptions
+ */
+#define AE_BAD_PARAMETER (ACPI_STATUS) (0x0001 | AE_CODE_PROGRAMMER)
+#define AE_BAD_CHARACTER (ACPI_STATUS) (0x0002 | AE_CODE_PROGRAMMER)
+#define AE_BAD_PATHNAME (ACPI_STATUS) (0x0003 | AE_CODE_PROGRAMMER)
+#define AE_BAD_DATA (ACPI_STATUS) (0x0004 | AE_CODE_PROGRAMMER)
+#define AE_BAD_ADDRESS (ACPI_STATUS) (0x0005 | AE_CODE_PROGRAMMER)
+#define AE_ALIGNMENT (ACPI_STATUS) (0x0006 | AE_CODE_PROGRAMMER)
+#define AE_BAD_HEX_CONSTANT (ACPI_STATUS) (0x0007 | AE_CODE_PROGRAMMER)
+#define AE_BAD_OCTAL_CONSTANT (ACPI_STATUS) (0x0008 | AE_CODE_PROGRAMMER)
+#define AE_BAD_DECIMAL_CONSTANT (ACPI_STATUS) (0x0009 | AE_CODE_PROGRAMMER)
+
+#define AE_CODE_PGM_MAX 0x0009
+
+
+/*
+ * Acpi table exceptions
+ */
+#define AE_BAD_SIGNATURE (ACPI_STATUS) (0x0001 | AE_CODE_ACPI_TABLES)
+#define AE_BAD_HEADER (ACPI_STATUS) (0x0002 | AE_CODE_ACPI_TABLES)
+#define AE_BAD_CHECKSUM (ACPI_STATUS) (0x0003 | AE_CODE_ACPI_TABLES)
+#define AE_BAD_VALUE (ACPI_STATUS) (0x0004 | AE_CODE_ACPI_TABLES)
+#define AE_TABLE_NOT_SUPPORTED (ACPI_STATUS) (0x0005 | AE_CODE_ACPI_TABLES)
+#define AE_INVALID_TABLE_LENGTH (ACPI_STATUS) (0x0006 | AE_CODE_ACPI_TABLES)
+
+#define AE_CODE_TBL_MAX 0x0006
+
+
+/*
+ * AML exceptions. These are caused by problems with
+ * the actual AML byte stream
+ */
+#define AE_AML_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_AML)
+#define AE_AML_PARSE (ACPI_STATUS) (0x0002 | AE_CODE_AML)
+#define AE_AML_BAD_OPCODE (ACPI_STATUS) (0x0003 | AE_CODE_AML)
+#define AE_AML_NO_OPERAND (ACPI_STATUS) (0x0004 | AE_CODE_AML)
+#define AE_AML_OPERAND_TYPE (ACPI_STATUS) (0x0005 | AE_CODE_AML)
+#define AE_AML_OPERAND_VALUE (ACPI_STATUS) (0x0006 | AE_CODE_AML)
+#define AE_AML_UNINITIALIZED_LOCAL (ACPI_STATUS) (0x0007 | AE_CODE_AML)
+#define AE_AML_UNINITIALIZED_ARG (ACPI_STATUS) (0x0008 | AE_CODE_AML)
+#define AE_AML_UNINITIALIZED_ELEMENT (ACPI_STATUS) (0x0009 | AE_CODE_AML)
+#define AE_AML_NUMERIC_OVERFLOW (ACPI_STATUS) (0x000A | AE_CODE_AML)
+#define AE_AML_REGION_LIMIT (ACPI_STATUS) (0x000B | AE_CODE_AML)
+#define AE_AML_BUFFER_LIMIT (ACPI_STATUS) (0x000C | AE_CODE_AML)
+#define AE_AML_PACKAGE_LIMIT (ACPI_STATUS) (0x000D | AE_CODE_AML)
+#define AE_AML_DIVIDE_BY_ZERO (ACPI_STATUS) (0x000E | AE_CODE_AML)
+#define AE_AML_BAD_NAME (ACPI_STATUS) (0x000F | AE_CODE_AML)
+#define AE_AML_NAME_NOT_FOUND (ACPI_STATUS) (0x0010 | AE_CODE_AML)
+#define AE_AML_INTERNAL (ACPI_STATUS) (0x0011 | AE_CODE_AML)
+#define AE_AML_INVALID_SPACE_ID (ACPI_STATUS) (0x0012 | AE_CODE_AML)
+#define AE_AML_STRING_LIMIT (ACPI_STATUS) (0x0013 | AE_CODE_AML)
+#define AE_AML_NO_RETURN_VALUE (ACPI_STATUS) (0x0014 | AE_CODE_AML)
+#define AE_AML_METHOD_LIMIT (ACPI_STATUS) (0x0015 | AE_CODE_AML)
+#define AE_AML_NOT_OWNER (ACPI_STATUS) (0x0016 | AE_CODE_AML)
+#define AE_AML_MUTEX_ORDER (ACPI_STATUS) (0x0017 | AE_CODE_AML)
+#define AE_AML_MUTEX_NOT_ACQUIRED (ACPI_STATUS) (0x0018 | AE_CODE_AML)
+#define AE_AML_INVALID_RESOURCE_TYPE (ACPI_STATUS) (0x0019 | AE_CODE_AML)
+#define AE_AML_INVALID_INDEX (ACPI_STATUS) (0x001A | AE_CODE_AML)
+#define AE_AML_REGISTER_LIMIT (ACPI_STATUS) (0x001B | AE_CODE_AML)
+#define AE_AML_NO_WHILE (ACPI_STATUS) (0x001C | AE_CODE_AML)
+#define AE_AML_ALIGNMENT (ACPI_STATUS) (0x001D | AE_CODE_AML)
+#define AE_AML_NO_RESOURCE_END_TAG (ACPI_STATUS) (0x001E | AE_CODE_AML)
+#define AE_AML_BAD_RESOURCE_VALUE (ACPI_STATUS) (0x001F | AE_CODE_AML)
+#define AE_AML_CIRCULAR_REFERENCE (ACPI_STATUS) (0x0020 | AE_CODE_AML)
+
+#define AE_CODE_AML_MAX 0x0020
+
+/*
+ * Internal exceptions used for control
+ */
+#define AE_CTRL_RETURN_VALUE (ACPI_STATUS) (0x0001 | AE_CODE_CONTROL)
+#define AE_CTRL_PENDING (ACPI_STATUS) (0x0002 | AE_CODE_CONTROL)
+#define AE_CTRL_TERMINATE (ACPI_STATUS) (0x0003 | AE_CODE_CONTROL)
+#define AE_CTRL_TRUE (ACPI_STATUS) (0x0004 | AE_CODE_CONTROL)
+#define AE_CTRL_FALSE (ACPI_STATUS) (0x0005 | AE_CODE_CONTROL)
+#define AE_CTRL_DEPTH (ACPI_STATUS) (0x0006 | AE_CODE_CONTROL)
+#define AE_CTRL_END (ACPI_STATUS) (0x0007 | AE_CODE_CONTROL)
+#define AE_CTRL_TRANSFER (ACPI_STATUS) (0x0008 | AE_CODE_CONTROL)
+#define AE_CTRL_BREAK (ACPI_STATUS) (0x0009 | AE_CODE_CONTROL)
+#define AE_CTRL_CONTINUE (ACPI_STATUS) (0x000A | AE_CODE_CONTROL)
+#define AE_CTRL_SKIP (ACPI_STATUS) (0x000B | AE_CODE_CONTROL)
+
+#define AE_CODE_CTRL_MAX 0x000B
+
+
+#ifdef DEFINE_ACPI_GLOBALS
+
+/*
+ * String versions of the exception codes above
+ * These strings must match the corresponding defines exactly
+ */
+char const *AcpiGbl_ExceptionNames_Env[] =
+{
+ "AE_OK",
+ "AE_ERROR",
+ "AE_NO_ACPI_TABLES",
+ "AE_NO_NAMESPACE",
+ "AE_NO_MEMORY",
+ "AE_NOT_FOUND",
+ "AE_NOT_EXIST",
+ "AE_ALREADY_EXISTS",
+ "AE_TYPE",
+ "AE_NULL_OBJECT",
+ "AE_NULL_ENTRY",
+ "AE_BUFFER_OVERFLOW",
+ "AE_STACK_OVERFLOW",
+ "AE_STACK_UNDERFLOW",
+ "AE_NOT_IMPLEMENTED",
+ "AE_VERSION_MISMATCH",
+ "AE_SUPPORT",
+ "AE_SHARE",
+ "AE_LIMIT",
+ "AE_TIME",
+ "AE_UNKNOWN_STATUS",
+ "AE_ACQUIRE_DEADLOCK",
+ "AE_RELEASE_DEADLOCK",
+ "AE_NOT_ACQUIRED",
+ "AE_ALREADY_ACQUIRED",
+ "AE_NO_HARDWARE_RESPONSE",
+ "AE_NO_GLOBAL_LOCK",
+ "AE_LOGICAL_ADDRESS",
+ "AE_ABORT_METHOD"
+};
+
+char const *AcpiGbl_ExceptionNames_Pgm[] =
+{
+ "AE_BAD_PARAMETER",
+ "AE_BAD_CHARACTER",
+ "AE_BAD_PATHNAME",
+ "AE_BAD_DATA",
+ "AE_BAD_ADDRESS",
+ "AE_ALIGNMENT",
+ "AE_BAD_HEX_CONSTANT",
+ "AE_BAD_OCTAL_CONSTANT",
+ "AE_BAD_DECIMAL_CONSTANT"
+};
+
+char const *AcpiGbl_ExceptionNames_Tbl[] =
+{
+ "AE_BAD_SIGNATURE",
+ "AE_BAD_HEADER",
+ "AE_BAD_CHECKSUM",
+ "AE_BAD_VALUE",
+ "AE_TABLE_NOT_SUPPORTED",
+ "AE_INVALID_TABLE_LENGTH"
+};
+
+char const *AcpiGbl_ExceptionNames_Aml[] =
+{
+ "AE_AML_ERROR",
+ "AE_AML_PARSE",
+ "AE_AML_BAD_OPCODE",
+ "AE_AML_NO_OPERAND",
+ "AE_AML_OPERAND_TYPE",
+ "AE_AML_OPERAND_VALUE",
+ "AE_AML_UNINITIALIZED_LOCAL",
+ "AE_AML_UNINITIALIZED_ARG",
+ "AE_AML_UNINITIALIZED_ELEMENT",
+ "AE_AML_NUMERIC_OVERFLOW",
+ "AE_AML_REGION_LIMIT",
+ "AE_AML_BUFFER_LIMIT",
+ "AE_AML_PACKAGE_LIMIT",
+ "AE_AML_DIVIDE_BY_ZERO",
+ "AE_AML_BAD_NAME",
+ "AE_AML_NAME_NOT_FOUND",
+ "AE_AML_INTERNAL",
+ "AE_AML_INVALID_SPACE_ID",
+ "AE_AML_STRING_LIMIT",
+ "AE_AML_NO_RETURN_VALUE",
+ "AE_AML_METHOD_LIMIT",
+ "AE_AML_NOT_OWNER",
+ "AE_AML_MUTEX_ORDER",
+ "AE_AML_MUTEX_NOT_ACQUIRED",
+ "AE_AML_INVALID_RESOURCE_TYPE",
+ "AE_AML_INVALID_INDEX",
+ "AE_AML_REGISTER_LIMIT",
+ "AE_AML_NO_WHILE",
+ "AE_AML_ALIGNMENT",
+ "AE_AML_NO_RESOURCE_END_TAG",
+ "AE_AML_BAD_RESOURCE_VALUE",
+ "AE_AML_CIRCULAR_REFERENCE"
+};
+
+char const *AcpiGbl_ExceptionNames_Ctrl[] =
+{
+ "AE_CTRL_RETURN_VALUE",
+ "AE_CTRL_PENDING",
+ "AE_CTRL_TERMINATE",
+ "AE_CTRL_TRUE",
+ "AE_CTRL_FALSE",
+ "AE_CTRL_DEPTH",
+ "AE_CTRL_END",
+ "AE_CTRL_TRANSFER",
+ "AE_CTRL_BREAK",
+ "AE_CTRL_CONTINUE",
+ "AE_CTRL_SKIP"
+};
+
+#endif /* ACPI GLOBALS */
+
+
+#endif /* __ACEXCEP_H__ */
diff --git a/sys/contrib/dev/acpica/acfreebsd.h b/sys/contrib/dev/acpica/acfreebsd.h
new file mode 100644
index 0000000..2adec41
--- /dev/null
+++ b/sys/contrib/dev/acpica/acfreebsd.h
@@ -0,0 +1,213 @@
+/******************************************************************************
+ *
+ * Name: acfreebsd.h - OS specific defines, etc.
+ * $Revision: 11 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACFREEBSD_H__
+#define __ACFREEBSD_H__
+
+/*
+ * XXX this is technically correct, but will cause problems with some ASL
+ * which only works if the string names a Microsoft operating system.
+ */
+#define ACPI_OS_NAME "FreeBSD"
+
+/* FreeBSD uses GCC */
+
+#include "acgcc.h"
+#include <machine/acpica_machdep.h>
+
+#ifdef _KERNEL
+#include "opt_acpi.h"
+#endif
+
+#ifdef ACPI_DEBUG
+#define ACPI_DEBUG_OUTPUT /* for backward compatibility */
+#endif
+
+#ifdef _KERNEL
+#include "opt_acpi.h"
+#endif
+
+#ifdef ACPI_DEBUG
+#define ACPI_DEBUG_OUTPUT /* for backward compatibility */
+#endif
+
+#ifdef _KERNEL
+#include <sys/ctype.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/libkern.h>
+#include <machine/stdarg.h>
+
+#ifdef DEBUGGER_THREADING
+#undef DEBUGGER_THREADING
+#endif /* DEBUGGER_THREADING */
+#define DEBUGGER_THREADING 0 /* integrated with DDB */
+#ifdef ACPI_DEBUG_OUTPUT
+#include "opt_ddb.h"
+#ifdef DDB
+#define ACPI_DEBUGGER
+#endif /* DDB */
+#endif /* ACPI_DEBUG_OUTPUT */
+
+#else /* _KERNEL */
+
+/* Not building kernel code, so use libc */
+#define ACPI_USE_STANDARD_HEADERS
+
+#define __cli()
+#define __sti()
+#define ACPI_FLUSH_CPU_CACHE()
+
+#endif /* _KERNEL */
+
+/* Always use FreeBSD code over our local versions */
+#define ACPI_USE_SYSTEM_CLIBRARY
+
+/* FreeBSD doesn't have strupr, should be fixed. (move to libkern) */
+static __inline char *
+strupr(char *str)
+{
+ char *c = str;
+ while(*c) {
+ *c = toupper(*c);
+ c++;
+ }
+ return(str);
+}
+
+#ifdef _KERNEL
+/* Or strstr (used in debugging mode, also move to libkern) */
+static __inline char *
+strstr(char *s, char *find)
+{
+ char c, sc;
+ size_t len;
+
+ if ((c = *find++) != 0) {
+ len = strlen(find);
+ do {
+ do {
+ if ((sc = *s++) == 0)
+ return (NULL);
+ } while (sc != c);
+ } while (strncmp(s, find, len) != 0);
+ s--;
+ }
+ return ((char *)s);
+}
+#endif /* _KERNEL */
+
+#endif /* __ACFREEBSD_H__ */
diff --git a/sys/contrib/dev/acpica/acgcc.h b/sys/contrib/dev/acpica/acgcc.h
new file mode 100644
index 0000000..af60e3a
--- /dev/null
+++ b/sys/contrib/dev/acpica/acgcc.h
@@ -0,0 +1,132 @@
+/******************************************************************************
+ *
+ * Name: acgcc.h - GCC specific defines, etc.
+ * $Revision: 25 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACGCC_H__
+#define __ACGCC_H__
+
+/* This macro is used to tag functions as "printf-like" because
+ * some compilers (like GCC) can catch printf format string problems.
+ */
+#define ACPI_PRINTF_LIKE_FUNC __attribute__ ((__format__ (__printf__, 4, 5)))
+
+/* Some compilers complain about unused variables. Sometimes we don't want to
+ * use all the variables (most specifically for _THIS_MODULE). This allow us
+ * to to tell the compiler warning in a per-variable manner that a variable
+ * is unused.
+ */
+#define ACPI_UNUSED_VAR __attribute__ ((unused))
+
+#endif /* __ACGCC_H__ */
diff --git a/sys/contrib/dev/acpica/acglobal.h b/sys/contrib/dev/acpica/acglobal.h
new file mode 100644
index 0000000..92541f7
--- /dev/null
+++ b/sys/contrib/dev/acpica/acglobal.h
@@ -0,0 +1,375 @@
+/******************************************************************************
+ *
+ * Name: acglobal.h - Declarations for global variables
+ * $Revision: 137 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 char *AcpiGbl_DbSleepStates[ACPI_S_STATE_COUNT];
+extern const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES];
+extern const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS];
+
+
+/*****************************************************************************
+ *
+ * Namespace globals
+ *
+ ****************************************************************************/
+
+#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_GPE_BLOCK_INFO *AcpiGbl_GpeBlockListHead;
+
+
+/*****************************************************************************
+ *
+ * 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_AbortMethod;
+extern BOOLEAN AcpiGbl_DbTerminateThreads;
+
+ACPI_EXTERN int optind;
+ACPI_EXTERN char *optarg;
+
+ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_tables;
+ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_stats;
+ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_ini_methods;
+
+
+ACPI_EXTERN char *AcpiGbl_DbArgs[ACPI_DEBUGGER_MAX_ARGS];
+ACPI_EXTERN char AcpiGbl_DbLineBuf[80];
+ACPI_EXTERN char AcpiGbl_DbParsedBuf[80];
+ACPI_EXTERN char AcpiGbl_DbScopeBuf[40];
+ACPI_EXTERN char AcpiGbl_DbDebugFilename[40];
+ACPI_EXTERN BOOLEAN AcpiGbl_DbOutputToFile;
+ACPI_EXTERN char *AcpiGbl_DbBuffer;
+ACPI_EXTERN 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[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/achware.h b/sys/contrib/dev/acpica/achware.h
new file mode 100644
index 0000000..addc164
--- /dev/null
+++ b/sys/contrib/dev/acpica/achware.h
@@ -0,0 +1,242 @@
+/******************************************************************************
+ *
+ * Name: achware.h -- hardware specific interfaces
+ * $Revision: 62 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACHWARE_H__
+#define __ACHWARE_H__
+
+
+/* PM Timer ticks per second (HZ) */
+#define PM_TIMER_FREQUENCY 3579545
+
+
+/* Prototypes */
+
+
+ACPI_STATUS
+AcpiHwInitialize (
+ void);
+
+ACPI_STATUS
+AcpiHwShutdown (
+ void);
+
+ACPI_STATUS
+AcpiHwInitializeSystemInfo (
+ void);
+
+ACPI_STATUS
+AcpiHwSetMode (
+ UINT32 Mode);
+
+UINT32
+AcpiHwGetMode (
+ void);
+
+UINT32
+AcpiHwGetModeCapabilities (
+ void);
+
+/* Register I/O Prototypes */
+
+ACPI_BIT_REGISTER_INFO *
+AcpiHwGetBitRegisterInfo (
+ UINT32 RegisterId);
+
+ACPI_STATUS
+AcpiHwRegisterRead (
+ BOOLEAN UseLock,
+ UINT32 RegisterId,
+ UINT32 *ReturnValue);
+
+ACPI_STATUS
+AcpiHwRegisterWrite (
+ BOOLEAN UseLock,
+ UINT32 RegisterId,
+ UINT32 Value);
+
+ACPI_STATUS
+AcpiHwLowLevelRead (
+ UINT32 Width,
+ UINT32 *Value,
+ ACPI_GENERIC_ADDRESS *Reg,
+ UINT32 Offset);
+
+ACPI_STATUS
+AcpiHwLowLevelWrite (
+ UINT32 Width,
+ UINT32 Value,
+ ACPI_GENERIC_ADDRESS *Reg,
+ UINT32 Offset);
+
+ACPI_STATUS
+AcpiHwClearAcpiStatus (
+ void);
+
+
+/* GPE support */
+
+ACPI_STATUS
+AcpiHwEnableGpe (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo);
+
+void
+AcpiHwEnableGpeForWakeup (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo);
+
+ACPI_STATUS
+AcpiHwDisableGpe (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo);
+
+void
+AcpiHwDisableGpeForWakeup (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo);
+
+ACPI_STATUS
+AcpiHwClearGpe (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo);
+
+ACPI_STATUS
+AcpiHwGetGpeStatus (
+ UINT32 GpeNumber,
+ ACPI_EVENT_STATUS *EventStatus);
+
+ACPI_STATUS
+AcpiHwDisableNonWakeupGpes (
+ void);
+
+ACPI_STATUS
+AcpiHwEnableNonWakeupGpes (
+ void);
+
+
+/* ACPI Timer prototypes */
+
+ACPI_STATUS
+AcpiGetTimerResolution (
+ UINT32 *Resolution);
+
+ACPI_STATUS
+AcpiGetTimer (
+ UINT32 *Ticks);
+
+ACPI_STATUS
+AcpiGetTimerDuration (
+ UINT32 StartTicks,
+ UINT32 EndTicks,
+ UINT32 *TimeElapsed);
+
+
+#endif /* __ACHWARE_H__ */
diff --git a/sys/contrib/dev/acpica/acinterp.h b/sys/contrib/dev/acpica/acinterp.h
new file mode 100644
index 0000000..240981f
--- /dev/null
+++ b/sys/contrib/dev/acpica/acinterp.h
@@ -0,0 +1,809 @@
+/******************************************************************************
+ *
+ * Name: acinterp.h - Interpreter subcomponent prototypes and defines
+ * $Revision: 145 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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,
+ UINT8 MaxLength);
+
+/*
+ * 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 **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,
+ 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,
+ char *Ident,
+ UINT32 NumLevels,
+ char *Note,
+ 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
+ */
+
+char *
+AcpiExAllocateNameString (
+ UINT32 PrefixCount,
+ UINT32 NumNameSegs);
+
+UINT32
+AcpiExGoodChar (
+ UINT32 Character);
+
+ACPI_STATUS
+AcpiExNameSegment (
+ UINT8 **InAmlAddress,
+ char *NameString);
+
+ACPI_STATUS
+AcpiExGetNameString (
+ ACPI_OBJECT_TYPE DataType,
+ UINT8 *InAmlAddress,
+ 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
+AcpiExAcquireGlobalLock (
+ UINT32 Rule);
+
+void
+AcpiExReleaseGlobalLock (
+ BOOLEAN Locked);
+
+UINT32
+AcpiExDigitsNeeded (
+ ACPI_INTEGER Value,
+ UINT32 Base);
+
+void
+AcpiExEisaIdToString (
+ UINT32 NumericId,
+ char *OutString);
+
+void
+AcpiExUnsignedIntegerToString (
+ ACPI_INTEGER Value,
+ 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
new file mode 100644
index 0000000..4144788
--- /dev/null
+++ b/sys/contrib/dev/acpica/aclocal.h
@@ -0,0 +1,1084 @@
+/******************************************************************************
+ *
+ * Name: aclocal.h - Internal data types used across the ACPI subsystem
+ * $Revision: 189 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 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 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 acpi_mutex_info
+{
+ 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_namespace_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_object *Object; /* Pointer to attached ACPI object (optional) */
+ struct acpi_namespace_node *Child; /* first child */
+ struct acpi_namespace_node *Peer; /* Next peer*/
+ UINT16 ReferenceCount; /* Current count of references and children */
+ UINT8 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 acpi_table_desc
+{
+ struct acpi_table_desc *Prev;
+ struct acpi_table_desc *Next;
+ struct acpi_table_desc *InstalledDesc;
+ ACPI_TABLE_HEADER *Pointer;
+ 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 acpi_find_context
+{
+ char *SearchFor;
+ ACPI_HANDLE *List;
+ UINT32 *Count;
+
+} ACPI_FIND_CONTEXT;
+
+
+typedef struct acpi_ns_search_data
+{
+ ACPI_NAMESPACE_NODE *Node;
+
+} ACPI_NS_SEARCH_DATA;
+
+
+/*
+ * Predefined Namespace items
+ */
+typedef struct acpi_predefined_names
+{
+ char *Name;
+ UINT8 Type;
+ 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
+{
+ char *ExternalName;
+ char *NextExternalChar;
+ char *InternalName;
+ UINT32 Length;
+ UINT32 NumSegments;
+ UINT32 NumCarats;
+ BOOLEAN FullyQualified;
+
+} ACPI_NAMESTRING_INFO;
+
+
+/* Field creation info */
+
+typedef struct acpi_create_field_info
+{
+ 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 particular GPE level */
+
+typedef struct acpi_gpe_event_info
+{
+ ACPI_NAMESPACE_NODE *MethodNode; /* Method node for this GPE level */
+ ACPI_GPE_HANDLER Handler; /* Address of handler, if any */
+ void *Context; /* Context to be passed to handler */
+ struct acpi_gpe_register_info *RegisterInfo;
+ UINT8 Type; /* Level or Edge */
+ UINT8 BitMask;
+
+} ACPI_GPE_EVENT_INFO;
+
+/* Information about a particular GPE register pair */
+
+typedef struct acpi_gpe_register_info
+{
+ 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 GPE register block */
+
+typedef struct acpi_gpe_block_info
+{
+ struct acpi_gpe_block_info *Previous;
+ struct acpi_gpe_block_info *Next;
+ struct acpi_gpe_block_info *NextOnInterrupt;
+ ACPI_GPE_REGISTER_INFO *RegisterInfo;
+ ACPI_GPE_EVENT_INFO *EventInfo;
+ ACPI_GENERIC_ADDRESS BlockAddress;
+ UINT32 RegisterCount;
+ UINT8 BlockBaseNumber;
+
+} ACPI_GPE_BLOCK_INFO;
+
+
+/* Information about each particular fixed event */
+
+typedef struct acpi_fixed_event_handler
+{
+ ACPI_EVENT_HANDLER Handler; /* Address of handler. */
+ void *Context; /* Context to be passed to handler */
+
+} ACPI_FIXED_EVENT_HANDLER;
+
+
+typedef struct acpi_fixed_event_info
+{
+ UINT8 StatusRegisterId;
+ UINT8 EnableRegisterId;
+ UINT16 StatusBitMask;
+ UINT16 EnableBitMask;
+
+} ACPI_FIXED_EVENT_INFO;
+
+/* Information used during field processing */
+
+typedef struct acpi_field_info
+{
+ 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_object;
+
+
+#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_object *Object;
+
+} ACPI_UPDATE_STATE;
+
+
+/*
+ * Pkg state - used to traverse nested package structures
+ */
+typedef struct acpi_pkg_state
+{
+ ACPI_STATE_COMMON
+ union acpi_operand_object *SourceObject;
+ union acpi_operand_object *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_object *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_object *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_object *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_object *ObjDesc [ACPI_OBJ_NUM_OPERANDS];
+ UINT8 NumResults;
+ UINT8 LastInsert;
+
+} ACPI_RESULT_VALUES;
+
+
+typedef
+ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) (
+ struct acpi_walk_state *WalkState,
+ union acpi_parse_object **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_object *HandlerObj;
+
+} ACPI_NOTIFY_INFO;
+
+
+/* Generic state is union of structs above */
+
+typedef union acpi_generic_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)
+ 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_value
+{
+ 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 */
+ char *String; /* NULL terminated string */
+ UINT8 *Buffer; /* buffer or string */
+ char *Name; /* NULL terminated string */
+ union acpi_parse_object *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_object *Parent; /* parent op */\
+ union acpi_parse_object *Next; /* next op */\
+ ACPI_DISASM_ONLY_MEMBERS (\
+ UINT8 DisasmFlags; /* Used during AML disassembly */\
+ UINT8 DisasmOpcode; /* Subtype used for disassembly */\
+ 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_parse_obj_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_parse_obj_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_parse_obj_asl
+{
+ ACPI_PARSE_COMMON
+ union acpi_parse_object *Child;
+ union acpi_parse_object *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_object
+{
+ 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_object *StartOp; /* root of parse tree */
+ struct acpi_namespace_node *StartNode;
+ union acpi_generic_state *Scope; /* current scope */
+ union acpi_parse_object *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 acpi_bit_register_info
+{
+ 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 acpi_device_id
+{
+ char Buffer[ACPI_DEVICE_ID_LENGTH];
+
+} ACPI_DEVICE_ID;
+
+
+/*****************************************************************************
+ *
+ * Miscellaneous
+ *
+ ****************************************************************************/
+
+#define ACPI_ASCII_ZERO 0x30
+
+
+/*****************************************************************************
+ *
+ * Debugger
+ *
+ ****************************************************************************/
+
+typedef struct acpi_db_method_info
+{
+ ACPI_HANDLE ThreadGate;
+ char *Name;
+ char **Args;
+ UINT32 Flags;
+ UINT32 NumLoops;
+ char Pathname[128];
+
+} ACPI_DB_METHOD_INFO;
+
+typedef struct acpi_integrity_info
+{
+ UINT32 Nodes;
+ UINT32 Objects;
+
+} ACPI_INTEGRITY_INFO;
+
+
+#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01
+#define ACPI_DB_CONSOLE_OUTPUT 0x02
+#define ACPI_DB_DUPLICATE_OUTPUT 0x03
+
+
+/*****************************************************************************
+ *
+ * Debug
+ *
+ ****************************************************************************/
+
+typedef struct acpi_debug_print_info
+{
+ UINT32 ComponentId;
+ char *ProcName;
+ char *ModuleName;
+
+} ACPI_DEBUG_PRINT_INFO;
+
+
+/* Entry for a memory allocation (debug only) */
+
+#define ACPI_MEM_MALLOC 0
+#define ACPI_MEM_CALLOC 1
+#define ACPI_MAX_MODULE_NAME 16
+
+#define ACPI_COMMON_DEBUG_MEM_HEADER \
+ struct acpi_debug_mem_block *Previous; \
+ struct acpi_debug_mem_block *Next; \
+ UINT32 Size; \
+ UINT32 Component; \
+ UINT32 Line; \
+ char Module[ACPI_MAX_MODULE_NAME]; \
+ UINT8 AllocType;
+
+typedef struct acpi_debug_mem_header
+{
+ ACPI_COMMON_DEBUG_MEM_HEADER
+
+} ACPI_DEBUG_MEM_HEADER;
+
+typedef struct acpi_debug_mem_block
+{
+ 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 acpi_memory_list
+{
+ 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/acmacros.h b/sys/contrib/dev/acpica/acmacros.h
new file mode 100644
index 0000000..998cab4
--- /dev/null
+++ b/sys/contrib/dev/acpica/acmacros.h
@@ -0,0 +1,670 @@
+/******************************************************************************
+ *
+ * Name: acmacros.h - C macros for the entire subsystem.
+ * $Revision: 137 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACMACROS_H__
+#define __ACMACROS_H__
+
+
+/*
+ * Data manipulation macros
+ */
+
+#define ACPI_LOWORD(l) ((UINT16)(UINT32)(l))
+#define ACPI_HIWORD(l) ((UINT16)((((UINT32)(l)) >> 16) & 0xFFFF))
+#define ACPI_LOBYTE(l) ((UINT8)(UINT16)(l))
+#define ACPI_HIBYTE(l) ((UINT8)((((UINT16)(l)) >> 8) & 0xFF))
+
+
+#if ACPI_MACHINE_WIDTH == 16
+
+/*
+ * For 16-bit addresses, we have to assume that the upper 32 bits
+ * are zero.
+ */
+#define ACPI_LODWORD(l) ((UINT32)(l))
+#define ACPI_HIDWORD(l) ((UINT32)(0))
+
+#define ACPI_GET_ADDRESS(a) ((a).Lo)
+#define ACPI_STORE_ADDRESS(a,b) {(a).Hi=0;(a).Lo=(UINT32)(b);}
+#define ACPI_VALID_ADDRESS(a) ((a).Hi | (a).Lo)
+
+#else
+#ifdef ACPI_NO_INTEGER64_SUPPORT
+/*
+ * ACPI_INTEGER is 32-bits, no 64-bit support on this platform
+ */
+#define ACPI_LODWORD(l) ((UINT32)(l))
+#define ACPI_HIDWORD(l) ((UINT32)(0))
+
+#define ACPI_GET_ADDRESS(a) (a)
+#define ACPI_STORE_ADDRESS(a,b) ((a)=(b))
+#define ACPI_VALID_ADDRESS(a) (a)
+
+#else
+
+/*
+ * Full 64-bit address/integer on both 32-bit and 64-bit platforms
+ */
+#define ACPI_LODWORD(l) ((UINT32)(UINT64)(l))
+#define ACPI_HIDWORD(l) ((UINT32)(((*(UINT64_STRUCT *)(void *)(&l))).Hi))
+
+#define ACPI_GET_ADDRESS(a) (a)
+#define ACPI_STORE_ADDRESS(a,b) ((a)=(ACPI_PHYSICAL_ADDRESS)(b))
+#define ACPI_VALID_ADDRESS(a) (a)
+#endif
+#endif
+
+ /*
+ * Extract a byte of data using a pointer. Any more than a byte and we
+ * get into potential aligment issues -- see the STORE macros below
+ */
+#define ACPI_GET8(addr) (*(UINT8*)(addr))
+
+/* Pointer arithmetic */
+
+#define ACPI_PTR_ADD(t,a,b) (t *) (void *)((char *)(a) + (ACPI_NATIVE_UINT)(b))
+#define ACPI_PTR_DIFF(a,b) (ACPI_NATIVE_UINT) ((char *)(a) - (char *)(b))
+
+/* Pointer/Integer type conversions */
+
+#define ACPI_TO_POINTER(i) ACPI_PTR_ADD (void, (void *) NULL,(ACPI_NATIVE_UINT)i)
+#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL)
+#define ACPI_OFFSET(d,f) (ACPI_SIZE) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL)
+#define ACPI_FADT_OFFSET(f) ACPI_OFFSET (FADT_DESCRIPTOR, f)
+
+#define ACPI_CAST_PTR(t, p) ((t *)(void *)(p))
+#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **)(void *)(p))
+
+#if ACPI_MACHINE_WIDTH == 16
+#define ACPI_STORE_POINTER(d,s) ACPI_MOVE_UNALIGNED32_TO_32(d,s)
+#define ACPI_PHYSADDR_TO_PTR(i) (void *)(i)
+#define ACPI_PTR_TO_PHYSADDR(i) (UINT32) (char *)(i)
+#else
+#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i)
+#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i)
+#endif
+
+/*
+ * Macros for moving data around to/from buffers that are possibly unaligned.
+ * If the hardware supports the transfer of unaligned data, just do the store.
+ * Otherwise, we have to move one byte at a time.
+ */
+
+#ifdef _HW_ALIGNMENT_SUPPORT
+
+/* The hardware supports unaligned transfers, just do the move */
+
+#define ACPI_MOVE_UNALIGNED16_TO_16(d,s) *(UINT16 *)(void *)(d) = *(UINT16 *)(void *)(s)
+#define ACPI_MOVE_UNALIGNED32_TO_32(d,s) *(UINT32 *)(void *)(d) = *(UINT32 *)(void *)(s)
+#define ACPI_MOVE_UNALIGNED16_TO_32(d,s) *(UINT32 *)(void *)(d) = *(UINT16 *)(void *)(s)
+#define ACPI_MOVE_UNALIGNED64_TO_64(d,s) *(UINT64 *)(void *)(d) = *(UINT64 *)(void *)(s)
+
+#else
+/*
+ * The hardware does not support unaligned transfers. We must move the
+ * data one byte at a time. These macros work whether the source or
+ * the destination (or both) is/are unaligned.
+ */
+
+#define ACPI_MOVE_UNALIGNED16_TO_16(d,s) {((UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\
+ ((UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];}
+
+#define ACPI_MOVE_UNALIGNED32_TO_32(d,s) {((UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\
+ ((UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];\
+ ((UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[2];\
+ ((UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[3];}
+
+#define ACPI_MOVE_UNALIGNED16_TO_32(d,s) {(*(UINT32*)(void *)(d)) = 0; ACPI_MOVE_UNALIGNED16_TO_16(d,s);}
+
+#define ACPI_MOVE_UNALIGNED64_TO_64(d,s) {((UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\
+ ((UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];\
+ ((UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[2];\
+ ((UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[3];\
+ ((UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[4];\
+ ((UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[5];\
+ ((UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[6];\
+ ((UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[7];}
+
+#endif
+
+
+/*
+ * Fast power-of-two math macros for non-optimized compilers
+ */
+
+#define _ACPI_DIV(value,PowerOf2) ((UINT32) ((value) >> (PowerOf2)))
+#define _ACPI_MUL(value,PowerOf2) ((UINT32) ((value) << (PowerOf2)))
+#define _ACPI_MOD(value,Divisor) ((UINT32) ((value) & ((Divisor) -1)))
+
+#define ACPI_DIV_2(a) _ACPI_DIV(a,1)
+#define ACPI_MUL_2(a) _ACPI_MUL(a,1)
+#define ACPI_MOD_2(a) _ACPI_MOD(a,2)
+
+#define ACPI_DIV_4(a) _ACPI_DIV(a,2)
+#define ACPI_MUL_4(a) _ACPI_MUL(a,2)
+#define ACPI_MOD_4(a) _ACPI_MOD(a,4)
+
+#define ACPI_DIV_8(a) _ACPI_DIV(a,3)
+#define ACPI_MUL_8(a) _ACPI_MUL(a,3)
+#define ACPI_MOD_8(a) _ACPI_MOD(a,8)
+
+#define ACPI_DIV_16(a) _ACPI_DIV(a,4)
+#define ACPI_MUL_16(a) _ACPI_MUL(a,4)
+#define ACPI_MOD_16(a) _ACPI_MOD(a,16)
+
+
+/*
+ * Rounding macros (Power of two boundaries only)
+ */
+#define ACPI_ROUND_DOWN(value,boundary) (((ACPI_NATIVE_UINT)(value)) & (~(((ACPI_NATIVE_UINT) boundary)-1)))
+#define ACPI_ROUND_UP(value,boundary) ((((ACPI_NATIVE_UINT)(value)) + (((ACPI_NATIVE_UINT) boundary)-1)) & (~(((ACPI_NATIVE_UINT) boundary)-1)))
+
+#define ACPI_ROUND_DOWN_TO_32_BITS(a) ACPI_ROUND_DOWN(a,4)
+#define ACPI_ROUND_DOWN_TO_64_BITS(a) ACPI_ROUND_DOWN(a,8)
+#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a) ACPI_ROUND_DOWN(a,ALIGNED_ADDRESS_BOUNDARY)
+
+#define ACPI_ROUND_UP_TO_32BITS(a) ACPI_ROUND_UP(a,4)
+#define ACPI_ROUND_UP_TO_64BITS(a) ACPI_ROUND_UP(a,8)
+#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a,ALIGNED_ADDRESS_BOUNDARY)
+
+
+#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7)
+#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a))
+
+#define ACPI_ROUND_UP_TO_1K(a) (((a) + 1023) >> 10)
+
+/* Generic (non-power-of-two) rounding */
+
+#define ACPI_ROUND_UP_TO(value,boundary) (((value) + ((boundary)-1)) / (boundary))
+
+/*
+ * Bitmask creation
+ * Bit positions start at zero.
+ * MASK_BITS_ABOVE creates a mask starting AT the position and above
+ * MASK_BITS_BELOW creates a mask starting one bit BELOW the position
+ */
+#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((UINT32) (position))))
+#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((UINT32) (position)))
+
+#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7'))
+
+/* Macros for GAS addressing */
+
+#if ACPI_MACHINE_WIDTH != 16
+
+#define ACPI_PCI_DEVICE_MASK (UINT64) 0x0000FFFF00000000
+#define ACPI_PCI_FUNCTION_MASK (UINT64) 0x00000000FFFF0000
+#define ACPI_PCI_REGISTER_MASK (UINT64) 0x000000000000FFFF
+
+/*
+ * Obsolete
+ */
+
+/*
+#define ACPI_PCI_FUNCTION(a) (UINT16) ((((UINT64)((UINT64)(a) & ACPI_PCI_FUNCTION_MASK)) >> 16))
+#define ACPI_PCI_DEVICE(a) (UINT16) ((((UINT64)((UINT64)(a) & ACPI_PCI_DEVICE_MASK)) >> 32))
+#define ACPI_PCI_REGISTER(a) (UINT16) (((UINT64)((UINT64)(a) & ACPI_PCI_REGISTER_MASK)))
+*/
+
+
+#define ACPI_PCI_DEVICE(a) (UINT16) ((ACPI_HIDWORD ((a))) & 0x0000FFFF)
+#define ACPI_PCI_FUNCTION(a) (UINT16) ((ACPI_LODWORD ((a))) >> 16)
+#define ACPI_PCI_REGISTER(a) (UINT16) ((ACPI_LODWORD ((a))) & 0x0000FFFF)
+
+#else
+
+/* No support for GAS and PCI IDs in 16-bit mode */
+
+#define ACPI_PCI_FUNCTION(a) (UINT16) ((a) & 0xFFFF0000)
+#define ACPI_PCI_DEVICE(a) (UINT16) ((a) & 0x0000FFFF)
+#define ACPI_PCI_REGISTER(a) (UINT16) ((a) & 0x0000FFFF)
+
+#endif
+
+
+/* Bitfields within ACPI registers */
+
+#define ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) ((Val << Pos) & Mask)
+#define ACPI_REGISTER_INSERT_VALUE(Reg, Pos, Mask, Val) Reg = (Reg & (~(Mask))) | ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask)
+
+/*
+ * An ACPI_NAMESPACE_NODE * can appear in some contexts,
+ * where a pointer to an ACPI_OPERAND_OBJECT can also
+ * appear. This macro is used to distinguish them.
+ *
+ * The "Descriptor" field is the first field in both structures.
+ */
+#define ACPI_GET_DESCRIPTOR_TYPE(d) (((ACPI_DESCRIPTOR *)(void *)(d))->DescriptorId)
+#define ACPI_SET_DESCRIPTOR_TYPE(d,t) (((ACPI_DESCRIPTOR *)(void *)(d))->DescriptorId = t)
+
+
+/* Macro to test the object type */
+
+#define ACPI_GET_OBJECT_TYPE(d) (((ACPI_OPERAND_OBJECT *)(void *)(d))->Common.Type)
+
+/* Macro to check the table flags for SINGLE or MULTIPLE tables are allowed */
+
+#define ACPI_IS_SINGLE_TABLE(x) (((x) & 0x01) == ACPI_TABLE_SINGLE ? 1 : 0)
+
+/*
+ * Macros for the master AML opcode table
+ */
+#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
+#define ACPI_OP(Name,PArgs,IArgs,ObjType,Class,Type,Flags) {Name,(UINT32)(PArgs),(UINT32)(IArgs),(UINT32)(Flags),ObjType,Class,Type}
+#else
+#define ACPI_OP(Name,PArgs,IArgs,ObjType,Class,Type,Flags) {(UINT32)(PArgs),(UINT32)(IArgs),(UINT32)(Flags),ObjType,Class,Type}
+#endif
+
+#ifdef ACPI_DISASSEMBLER
+#define ACPI_DISASM_ONLY_MEMBERS(a) a;
+#else
+#define ACPI_DISASM_ONLY_MEMBERS(a)
+#endif
+
+#define ARG_TYPE_WIDTH 5
+#define ARG_1(x) ((UINT32)(x))
+#define ARG_2(x) ((UINT32)(x) << (1 * ARG_TYPE_WIDTH))
+#define ARG_3(x) ((UINT32)(x) << (2 * ARG_TYPE_WIDTH))
+#define ARG_4(x) ((UINT32)(x) << (3 * ARG_TYPE_WIDTH))
+#define ARG_5(x) ((UINT32)(x) << (4 * ARG_TYPE_WIDTH))
+#define ARG_6(x) ((UINT32)(x) << (5 * ARG_TYPE_WIDTH))
+
+#define ARGI_LIST1(a) (ARG_1(a))
+#define ARGI_LIST2(a,b) (ARG_1(b)|ARG_2(a))
+#define ARGI_LIST3(a,b,c) (ARG_1(c)|ARG_2(b)|ARG_3(a))
+#define ARGI_LIST4(a,b,c,d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a))
+#define ARGI_LIST5(a,b,c,d,e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a))
+#define ARGI_LIST6(a,b,c,d,e,f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a))
+
+#define ARGP_LIST1(a) (ARG_1(a))
+#define ARGP_LIST2(a,b) (ARG_1(a)|ARG_2(b))
+#define ARGP_LIST3(a,b,c) (ARG_1(a)|ARG_2(b)|ARG_3(c))
+#define ARGP_LIST4(a,b,c,d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d))
+#define ARGP_LIST5(a,b,c,d,e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e))
+#define ARGP_LIST6(a,b,c,d,e,f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f))
+
+#define GET_CURRENT_ARG_TYPE(List) (List & ((UINT32) 0x1F))
+#define INCREMENT_ARG_LIST(List) (List >>= ((UINT32) ARG_TYPE_WIDTH))
+
+
+/*
+ * Build a GAS structure from earlier ACPI table entries (V1.0 and 0.71 extensions)
+ *
+ * 1) Address space
+ * 2) Length in bytes -- convert to length in bits
+ * 3) Bit offset is zero
+ * 4) Reserved field is zero
+ * 5) Expand address to 64 bits
+ */
+#define ASL_BUILD_GAS_FROM_ENTRY(a,b,c,d) do {a.AddressSpaceId = (UINT8) d;\
+ a.RegisterBitWidth = (UINT8) ACPI_MUL_8 (b);\
+ a.RegisterBitOffset = 0;\
+ a.Reserved = 0;\
+ ACPI_STORE_ADDRESS (a.Address,(ACPI_PHYSICAL_ADDRESS) c);} while (0)
+
+/* ACPI V1.0 entries -- address space is always I/O */
+
+#define ASL_BUILD_GAS_FROM_V1_ENTRY(a,b,c) ASL_BUILD_GAS_FROM_ENTRY(a,b,c,ACPI_ADR_SPACE_SYSTEM_IO)
+
+
+/*
+ * Reporting macros that are never compiled out
+ */
+
+#define ACPI_PARAM_LIST(pl) pl
+
+/*
+ * Error reporting. These versions add callers module and line#. Since
+ * _THIS_MODULE gets compiled out when ACPI_DEBUG_OUTPUT isn't defined, only
+ * use it in debug mode.
+ */
+
+#ifdef ACPI_DEBUG_OUTPUT
+
+#define ACPI_REPORT_INFO(fp) {AcpiUtReportInfo(_THIS_MODULE,__LINE__,_COMPONENT); \
+ AcpiOsPrintf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_ERROR(fp) {AcpiUtReportError(_THIS_MODULE,__LINE__,_COMPONENT); \
+ AcpiOsPrintf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_WARNING(fp) {AcpiUtReportWarning(_THIS_MODULE,__LINE__,_COMPONENT); \
+ AcpiOsPrintf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_NSERROR(s,e) AcpiNsReportError(_THIS_MODULE,__LINE__,_COMPONENT, s, e);
+
+#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) AcpiNsReportMethodError(_THIS_MODULE,__LINE__,_COMPONENT, s, n, p, e);
+
+#else
+
+#define ACPI_REPORT_INFO(fp) {AcpiUtReportInfo("ACPI",__LINE__,_COMPONENT); \
+ AcpiOsPrintf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_ERROR(fp) {AcpiUtReportError("ACPI",__LINE__,_COMPONENT); \
+ AcpiOsPrintf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_WARNING(fp) {AcpiUtReportWarning("ACPI",__LINE__,_COMPONENT); \
+ AcpiOsPrintf ACPI_PARAM_LIST(fp);}
+#define ACPI_REPORT_NSERROR(s,e) AcpiNsReportError("ACPI",__LINE__,_COMPONENT, s, e);
+
+#define ACPI_REPORT_METHOD_ERROR(s,n,p,e) AcpiNsReportMethodError("ACPI",__LINE__,_COMPONENT, s, n, p, e);
+
+#endif
+
+/* Error reporting. These versions pass thru the module and line# */
+
+#define _ACPI_REPORT_INFO(a,b,c,fp) {AcpiUtReportInfo(a,b,c); \
+ AcpiOsPrintf ACPI_PARAM_LIST(fp);}
+#define _ACPI_REPORT_ERROR(a,b,c,fp) {AcpiUtReportError(a,b,c); \
+ AcpiOsPrintf ACPI_PARAM_LIST(fp);}
+#define _ACPI_REPORT_WARNING(a,b,c,fp) {AcpiUtReportWarning(a,b,c); \
+ AcpiOsPrintf ACPI_PARAM_LIST(fp);}
+
+/*
+ * Debug macros that are conditionally compiled
+ */
+
+#ifdef ACPI_DEBUG_OUTPUT
+
+#define ACPI_MODULE_NAME(name) static char ACPI_UNUSED_VAR *_THIS_MODULE = name;
+
+/*
+ * Function entry tracing.
+ * The first parameter should be the procedure name as a quoted string. This is declared
+ * as a local string ("_ProcName) so that it can be also used by the function exit macros below.
+ */
+
+#define ACPI_FUNCTION_NAME(a) ACPI_DEBUG_PRINT_INFO _Dbg; \
+ _Dbg.ComponentId = _COMPONENT; \
+ _Dbg.ProcName = a; \
+ _Dbg.ModuleName = _THIS_MODULE;
+
+#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a)\
+ AcpiUtTrace(__LINE__,&_Dbg)
+#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a)\
+ AcpiUtTracePtr(__LINE__,&_Dbg,(void *)b)
+#define ACPI_FUNCTION_TRACE_U32(a,b) ACPI_FUNCTION_NAME(a)\
+ AcpiUtTraceU32(__LINE__,&_Dbg,(UINT32)b)
+#define ACPI_FUNCTION_TRACE_STR(a,b) ACPI_FUNCTION_NAME(a)\
+ AcpiUtTraceStr(__LINE__,&_Dbg,(char *)b)
+
+#define ACPI_FUNCTION_ENTRY() AcpiUtTrackStackPtr()
+
+/*
+ * Function exit tracing.
+ * WARNING: These macros include a return statement. This is usually considered
+ * bad form, but having a separate exit macro is very ugly and difficult to maintain.
+ * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros
+ * so that "_ProcName" is defined.
+ */
+#ifdef ACPI_USE_DO_WHILE_0
+#define ACPI_DO_WHILE0(a) do a while(0)
+#else
+#define ACPI_DO_WHILE0(a) a
+#endif
+
+#define return_VOID ACPI_DO_WHILE0 ({AcpiUtExit(__LINE__,&_Dbg);return;})
+#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({AcpiUtStatusExit(__LINE__,&_Dbg,(s));return((s));})
+#define return_VALUE(s) ACPI_DO_WHILE0 ({AcpiUtValueExit(__LINE__,&_Dbg,(ACPI_INTEGER)(s));return((s));})
+#define return_PTR(s) ACPI_DO_WHILE0 ({AcpiUtPtrExit(__LINE__,&_Dbg,(UINT8 *)(s));return((s));})
+
+/* Conditional execution */
+
+#define ACPI_DEBUG_EXEC(a) a
+#define ACPI_NORMAL_EXEC(a)
+
+#define ACPI_DEBUG_DEFINE(a) a;
+#define ACPI_DEBUG_ONLY_MEMBERS(a) a;
+#define _VERBOSE_STRUCTURES
+
+
+/* Stack and buffer dumping */
+
+#define ACPI_DUMP_STACK_ENTRY(a) AcpiExDumpOperand(a)
+#define ACPI_DUMP_OPERANDS(a,b,c,d,e) AcpiExDumpOperands(a,b,c,d,e,_THIS_MODULE,__LINE__)
+
+
+#define ACPI_DUMP_ENTRY(a,b) AcpiNsDumpEntry (a,b)
+#define ACPI_DUMP_TABLES(a,b) AcpiNsDumpTables(a,b)
+#define ACPI_DUMP_PATHNAME(a,b,c,d) AcpiNsDumpPathname(a,b,c,d)
+#define ACPI_DUMP_RESOURCE_LIST(a) AcpiRsDumpResourceList(a)
+#define ACPI_DUMP_BUFFER(a,b) AcpiUtDumpBuffer((UINT8 *)a,b,DB_BYTE_DISPLAY,_COMPONENT)
+#define ACPI_BREAK_MSG(a) AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT,(a))
+
+
+/*
+ * Generate INT3 on ACPI_ERROR (Debug only!)
+ */
+
+#define ACPI_ERROR_BREAK
+#ifdef ACPI_ERROR_BREAK
+#define ACPI_BREAK_ON_ERROR(lvl) if ((lvl)&ACPI_ERROR) \
+ AcpiOsSignal(ACPI_SIGNAL_BREAKPOINT,"Fatal error encountered\n")
+#else
+#define ACPI_BREAK_ON_ERROR(lvl)
+#endif
+
+/*
+ * Master debug print macros
+ * Print iff:
+ * 1) Debug print for the current component is enabled
+ * 2) Debug error level or trace level for the print statement is enabled
+ */
+
+#define ACPI_DEBUG_PRINT(pl) AcpiUtDebugPrint ACPI_PARAM_LIST(pl)
+#define ACPI_DEBUG_PRINT_RAW(pl) AcpiUtDebugPrintRaw ACPI_PARAM_LIST(pl)
+
+
+#else
+/*
+ * This is the non-debug case -- make everything go away,
+ * leaving no executable debug code!
+ */
+
+#define ACPI_MODULE_NAME(name)
+#define _THIS_MODULE ""
+
+#define ACPI_DEBUG_EXEC(a)
+#define ACPI_NORMAL_EXEC(a) a;
+
+#define ACPI_DEBUG_DEFINE(a)
+#define ACPI_DEBUG_ONLY_MEMBERS(a)
+#define ACPI_FUNCTION_NAME(a)
+#define ACPI_FUNCTION_TRACE(a)
+#define ACPI_FUNCTION_TRACE_PTR(a,b)
+#define ACPI_FUNCTION_TRACE_U32(a,b)
+#define ACPI_FUNCTION_TRACE_STR(a,b)
+#define ACPI_FUNCTION_EXIT
+#define ACPI_FUNCTION_STATUS_EXIT(s)
+#define ACPI_FUNCTION_VALUE_EXIT(s)
+#define ACPI_FUNCTION_ENTRY()
+#define ACPI_DUMP_STACK_ENTRY(a)
+#define ACPI_DUMP_OPERANDS(a,b,c,d,e)
+#define ACPI_DUMP_ENTRY(a,b)
+#define ACPI_DUMP_TABLES(a,b)
+#define ACPI_DUMP_PATHNAME(a,b,c,d)
+#define ACPI_DUMP_RESOURCE_LIST(a)
+#define ACPI_DUMP_BUFFER(a,b)
+#define ACPI_DEBUG_PRINT(pl)
+#define ACPI_DEBUG_PRINT_RAW(pl)
+#define ACPI_BREAK_MSG(a)
+
+#define return_VOID return
+#define return_ACPI_STATUS(s) return(s)
+#define return_VALUE(s) return(s)
+#define return_PTR(s) return(s)
+
+#endif
+
+/*
+ * Some code only gets executed when the debugger is built in.
+ * Note that this is entirely independent of whether the
+ * DEBUG_PRINT stuff (set by ACPI_DEBUG_OUTPUT) is on, or not.
+ */
+#ifdef ACPI_DEBUGGER
+#define ACPI_DEBUGGER_EXEC(a) a
+#else
+#define ACPI_DEBUGGER_EXEC(a)
+#endif
+
+
+/*
+ * For 16-bit code, we want to shrink some things even though
+ * we are using ACPI_DEBUG_OUTPUT to get the debug output
+ */
+#if ACPI_MACHINE_WIDTH == 16
+#undef ACPI_DEBUG_ONLY_MEMBERS
+#undef _VERBOSE_STRUCTURES
+#define ACPI_DEBUG_ONLY_MEMBERS(a)
+#endif
+
+
+#ifdef ACPI_DEBUG_OUTPUT
+/*
+ * 1) Set name to blanks
+ * 2) Copy the object name
+ */
+#define ACPI_ADD_OBJECT_NAME(a,b) ACPI_MEMSET (a->Common.Name, ' ', sizeof (a->Common.Name));\
+ ACPI_STRNCPY (a->Common.Name, AcpiGbl_NsTypeNames[b], sizeof (a->Common.Name))
+#else
+
+#define ACPI_ADD_OBJECT_NAME(a,b)
+#endif
+
+
+/*
+ * Memory allocation tracking (DEBUG ONLY)
+ */
+
+#ifndef ACPI_DBG_TRACK_ALLOCATIONS
+
+/* Memory allocation */
+
+#define ACPI_MEM_ALLOCATE(a) AcpiUtAllocate((ACPI_SIZE)(a),_COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_CALLOCATE(a) AcpiUtCallocate((ACPI_SIZE)(a), _COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_FREE(a) AcpiOsFree(a)
+#define ACPI_MEM_TRACKING(a)
+
+
+#else
+
+/* Memory allocation */
+
+#define ACPI_MEM_ALLOCATE(a) AcpiUtAllocateAndTrack((ACPI_SIZE)(a),_COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_CALLOCATE(a) AcpiUtCallocateAndTrack((ACPI_SIZE)(a), _COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_FREE(a) AcpiUtFreeAndTrack(a,_COMPONENT,_THIS_MODULE,__LINE__)
+#define ACPI_MEM_TRACKING(a) a
+
+#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
+
+
+#define ACPI_GET_STACK_POINTER _asm {mov eax, ebx}
+
+#endif /* ACMACROS_H */
diff --git a/sys/contrib/dev/acpica/acnamesp.h b/sys/contrib/dev/acpica/acnamesp.h
new file mode 100644
index 0000000..54c1c25
--- /dev/null
+++ b/sys/contrib/dev/acpica/acnamesp.h
@@ -0,0 +1,581 @@
+/******************************************************************************
+ *
+ * Name: acnamesp.h - Namespace subcomponent prototypes and defines
+ * $Revision: 133 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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,
+ 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);
+
+void
+AcpiNsDumpPathname (
+ ACPI_HANDLE Handle,
+ 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 (
+ char *Pathname,
+ ACPI_OPERAND_OBJECT **Params,
+ ACPI_OPERAND_OBJECT **ReturnObject);
+
+ACPI_STATUS
+AcpiNsEvaluateRelative (
+ ACPI_NAMESPACE_NODE *PrefixNode,
+ 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
+ */
+
+ACPI_NAME
+AcpiNsFindParentName (
+ ACPI_NAMESPACE_NODE *NodeToSearch);
+
+
+/*
+ * Name and Scope manipulation - nsnames
+ */
+
+UINT32
+AcpiNsOpensScope (
+ ACPI_OBJECT_TYPE Type);
+
+void
+AcpiNsBuildExternalPath (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_SIZE Size,
+ char *NameBuffer);
+
+char *
+AcpiNsGetExternalPathname (
+ ACPI_NAMESPACE_NODE *Node);
+
+char *
+AcpiNsNameOfCurrentScope (
+ ACPI_WALK_STATE *WalkState);
+
+ACPI_STATUS
+AcpiNsHandleToPathname (
+ ACPI_HANDLE TargetHandle,
+ ACPI_BUFFER *Buffer);
+
+BOOLEAN
+AcpiNsPatternMatch (
+ ACPI_NAMESPACE_NODE *ObjNode,
+ char *SearchFor);
+
+ACPI_STATUS
+AcpiNsGetNodeByPath (
+ 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,
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_OBJECT_TYPE Type);
+
+
+/*
+ * Utility functions - nsutils
+ */
+
+BOOLEAN
+AcpiNsValidRootPrefix (
+ char Prefix);
+
+BOOLEAN
+AcpiNsValidPathSeparator (
+ char Sep);
+
+ACPI_OBJECT_TYPE
+AcpiNsGetType (
+ ACPI_NAMESPACE_NODE *Node);
+
+UINT32
+AcpiNsLocal (
+ ACPI_OBJECT_TYPE Type);
+
+void
+AcpiNsReportError (
+ char *ModuleName,
+ UINT32 LineNumber,
+ UINT32 ComponentId,
+ char *InternalName,
+ ACPI_STATUS LookupStatus);
+
+void
+AcpiNsReportMethodError (
+ char *ModuleName,
+ UINT32 LineNumber,
+ UINT32 ComponentId,
+ char *Message,
+ ACPI_NAMESPACE_NODE *Node,
+ char *Path,
+ ACPI_STATUS LookupStatus);
+
+void
+AcpiNsPrintNodePathname (
+ ACPI_NAMESPACE_NODE *Node,
+ char *Msg);
+
+ACPI_STATUS
+AcpiNsBuildInternalName (
+ ACPI_NAMESTRING_INFO *Info);
+
+void
+AcpiNsGetInternalNameLength (
+ ACPI_NAMESTRING_INFO *Info);
+
+ACPI_STATUS
+AcpiNsInternalizeName (
+ char *DottedName,
+ char **ConvertedName);
+
+ACPI_STATUS
+AcpiNsExternalizeName (
+ UINT32 InternalNameLength,
+ char *InternalName,
+ UINT32 *ConvertedNameLength,
+ 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
new file mode 100644
index 0000000..2f92f05
--- /dev/null
+++ b/sys/contrib/dev/acpica/acobject.h
@@ -0,0 +1,591 @@
+
+/******************************************************************************
+ *
+ * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only)
+ * $Revision: 118 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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_object *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_object *SysHandler; /* Handler for system notifies */\
+ union acpi_operand_object *DrvHandler; /* Handler for driver notifies */\
+ union acpi_operand_object *AddrHandler; /* Handler for Address space */
+
+
+/******************************************************************************
+ *
+ * Basic data types
+ *
+ *****************************************************************************/
+
+typedef struct acpi_object_common
+{
+ ACPI_OBJECT_COMMON_HEADER
+
+} ACPI_OBJECT_COMMON;
+
+
+typedef struct acpi_object_integer
+{
+ ACPI_OBJECT_COMMON_HEADER
+ ACPI_INTEGER Value;
+
+} ACPI_OBJECT_INTEGER;
+
+
+typedef struct acpi_object_string /* Null terminated, ASCII characters only */
+{
+ ACPI_OBJECT_COMMON_HEADER
+ ACPI_COMMON_BUFFER_INFO
+ char *Pointer; /* String in AML stream or allocated string */
+
+} ACPI_OBJECT_STRING;
+
+
+typedef struct acpi_object_buffer
+{
+ 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 acpi_object_package
+{
+ 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_object **Elements; /* Array of pointers to AcpiObjects */
+
+} ACPI_OBJECT_PACKAGE;
+
+
+/******************************************************************************
+ *
+ * Complex data types
+ *
+ *****************************************************************************/
+
+typedef struct acpi_object_event
+{
+ ACPI_OBJECT_COMMON_HEADER
+ void *Semaphore;
+
+} ACPI_OBJECT_EVENT;
+
+
+#define INFINITE_CONCURRENCY 0xFF
+
+typedef struct acpi_object_method
+{
+ 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 acpi_object_mutex
+{
+ ACPI_OBJECT_COMMON_HEADER
+ UINT16 SyncLevel;
+ UINT16 AcquisitionDepth;
+ struct acpi_thread_state *OwnerThread;
+ void *Semaphore;
+ union acpi_operand_object *Prev; /* Link for list of acquired mutexes */
+ union acpi_operand_object *Next; /* Link for list of acquired mutexes */
+ ACPI_NAMESPACE_NODE *Node; /* containing object */
+
+} ACPI_OBJECT_MUTEX;
+
+
+typedef struct acpi_object_region
+{
+ ACPI_OBJECT_COMMON_HEADER
+
+ UINT8 SpaceId;
+ union acpi_operand_object *AddrHandler; /* Handler for system notifies */
+ ACPI_NAMESPACE_NODE *Node; /* containing object */
+ union acpi_operand_object *Next;
+ UINT32 Length;
+ ACPI_PHYSICAL_ADDRESS Address;
+
+} ACPI_OBJECT_REGION;
+
+
+/******************************************************************************
+ *
+ * Objects that can be notified. All share a common NotifyInfo area.
+ *
+ *****************************************************************************/
+
+typedef struct acpi_object_notify_common /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */
+{
+ ACPI_OBJECT_COMMON_HEADER
+ ACPI_COMMON_NOTIFY_INFO
+
+} ACPI_OBJECT_NOTIFY_COMMON;
+
+
+typedef struct acpi_object_device
+{
+ ACPI_OBJECT_COMMON_HEADER
+ ACPI_COMMON_NOTIFY_INFO
+
+} ACPI_OBJECT_DEVICE;
+
+
+typedef struct acpi_object_power_resource
+{
+ ACPI_OBJECT_COMMON_HEADER
+ ACPI_COMMON_NOTIFY_INFO
+ UINT32 SystemLevel;
+ UINT32 ResourceOrder;
+
+} ACPI_OBJECT_POWER_RESOURCE;
+
+
+typedef struct acpi_object_processor
+{
+ ACPI_OBJECT_COMMON_HEADER
+ ACPI_COMMON_NOTIFY_INFO
+ UINT32 ProcId;
+ UINT32 Length;
+ ACPI_IO_ADDRESS Address;
+
+} ACPI_OBJECT_PROCESSOR;
+
+
+typedef struct acpi_object_thermal_zone
+{
+ ACPI_OBJECT_COMMON_HEADER
+ ACPI_COMMON_NOTIFY_INFO
+
+} ACPI_OBJECT_THERMAL_ZONE;
+
+
+/******************************************************************************
+ *
+ * Fields. All share a common header/info field.
+ *
+ *****************************************************************************/
+
+typedef struct acpi_object_field_common /* COMMON FIELD (for BUFFER, REGION, BANK, and INDEX fields) */
+{
+ ACPI_OBJECT_COMMON_HEADER
+ ACPI_COMMON_FIELD_INFO
+ union acpi_operand_object *RegionObj; /* Containing Operation Region object */
+ /* (REGION/BANK fields only) */
+} ACPI_OBJECT_FIELD_COMMON;
+
+
+typedef struct acpi_object_region_field
+{
+ ACPI_OBJECT_COMMON_HEADER
+ ACPI_COMMON_FIELD_INFO
+ union acpi_operand_object *RegionObj; /* Containing OpRegion object */
+
+} ACPI_OBJECT_REGION_FIELD;
+
+
+typedef struct acpi_object_bank_field
+{
+ ACPI_OBJECT_COMMON_HEADER
+ ACPI_COMMON_FIELD_INFO
+ union acpi_operand_object *RegionObj; /* Containing OpRegion object */
+ union acpi_operand_object *BankObj; /* BankSelect Register object */
+
+} ACPI_OBJECT_BANK_FIELD;
+
+
+typedef struct acpi_object_index_field
+{
+ 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_object *IndexObj; /* Index register */
+ union acpi_operand_object *DataObj; /* Data register */
+
+} ACPI_OBJECT_INDEX_FIELD;
+
+
+/* The BufferField is different in that it is part of a Buffer, not an OpRegion */
+
+typedef struct acpi_object_buffer_field
+{
+ ACPI_OBJECT_COMMON_HEADER
+ ACPI_COMMON_FIELD_INFO
+ union acpi_operand_object *BufferObj; /* Containing Buffer object */
+
+} ACPI_OBJECT_BUFFER_FIELD;
+
+
+/******************************************************************************
+ *
+ * Objects for handlers
+ *
+ *****************************************************************************/
+
+typedef struct acpi_object_notify_handler
+{
+ 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 acpi_object_addr_handler
+{
+ 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_object *RegionList; /* regions using this handler */
+ union acpi_operand_object *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 acpi_object_reference
+{
+ 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_object **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 acpi_object_extra
+{
+ 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 acpi_object_data
+{
+ ACPI_OBJECT_COMMON_HEADER
+ ACPI_OBJECT_HANDLER Handler;
+ void *Pointer;
+
+} ACPI_OBJECT_DATA;
+
+
+/* Structure used when objects are cached for reuse */
+
+typedef struct acpi_object_cache_list
+{
+ ACPI_OBJECT_COMMON_HEADER
+ union acpi_operand_object *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_object
+{
+ 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_descriptor
+{
+ 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/acoutput.h b/sys/contrib/dev/acpica/acoutput.h
new file mode 100644
index 0000000..74f7aeb
--- /dev/null
+++ b/sys/contrib/dev/acpica/acoutput.h
@@ -0,0 +1,258 @@
+/******************************************************************************
+ *
+ * Name: acoutput.h -- debug output
+ * $Revision: 93 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACOUTPUT_H__
+#define __ACOUTPUT_H__
+
+/*
+ * Debug levels and component IDs. These are used to control the
+ * granularity of the output of the DEBUG_PRINT macro -- on a per-
+ * component basis and a per-exception-type basis.
+ */
+
+/* Component IDs are used in the global "DebugLayer" */
+
+#define ACPI_UTILITIES 0x00000001
+#define ACPI_HARDWARE 0x00000002
+#define ACPI_EVENTS 0x00000004
+#define ACPI_TABLES 0x00000008
+#define ACPI_NAMESPACE 0x00000010
+#define ACPI_PARSER 0x00000020
+#define ACPI_DISPATCHER 0x00000040
+#define ACPI_EXECUTER 0x00000080
+#define ACPI_RESOURCES 0x00000100
+#define ACPI_CA_DEBUGGER 0x00000200
+#define ACPI_OS_SERVICES 0x00000400
+#define ACPI_CA_DISASSEMBLER 0x00000800
+
+/* Component IDs for ACPI tools and utilities */
+
+#define ACPI_COMPILER 0x00001000
+#define ACPI_TOOLS 0x00002000
+
+#define ACPI_ALL_COMPONENTS 0x00003FFF
+#define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS)
+
+
+/* Component IDs reserved for ACPI drivers */
+
+#define ACPI_ALL_DRIVERS 0xFFFF0000
+
+
+/*
+ * Raw debug output levels, do not use these in the DEBUG_PRINT macros
+ */
+#define ACPI_LV_ERROR 0x00000001
+#define ACPI_LV_WARN 0x00000002
+#define ACPI_LV_INIT 0x00000004
+#define ACPI_LV_DEBUG_OBJECT 0x00000008
+#define ACPI_LV_INFO 0x00000010
+#define ACPI_LV_ALL_EXCEPTIONS 0x0000001F
+
+/* Trace verbosity level 1 [Standard Trace Level] */
+
+#define ACPI_LV_INIT_NAMES 0x00000020
+#define ACPI_LV_PARSE 0x00000040
+#define ACPI_LV_LOAD 0x00000080
+#define ACPI_LV_DISPATCH 0x00000100
+#define ACPI_LV_EXEC 0x00000200
+#define ACPI_LV_NAMES 0x00000400
+#define ACPI_LV_OPREGION 0x00000800
+#define ACPI_LV_BFIELD 0x00001000
+#define ACPI_LV_TABLES 0x00002000
+#define ACPI_LV_VALUES 0x00004000
+#define ACPI_LV_OBJECTS 0x00008000
+#define ACPI_LV_RESOURCES 0x00010000
+#define ACPI_LV_USER_REQUESTS 0x00020000
+#define ACPI_LV_PACKAGE 0x00040000
+#define ACPI_LV_VERBOSITY1 0x0007FF40 | ACPI_LV_ALL_EXCEPTIONS
+
+/* Trace verbosity level 2 [Function tracing and memory allocation] */
+
+#define ACPI_LV_ALLOCATIONS 0x00100000
+#define ACPI_LV_FUNCTIONS 0x00200000
+#define ACPI_LV_OPTIMIZATIONS 0x00400000
+#define ACPI_LV_VERBOSITY2 0x00700000 | ACPI_LV_VERBOSITY1
+#define ACPI_LV_ALL ACPI_LV_VERBOSITY2
+
+/* Trace verbosity level 3 [Threading, I/O, and Interrupts] */
+
+#define ACPI_LV_MUTEX 0x01000000
+#define ACPI_LV_THREADS 0x02000000
+#define ACPI_LV_IO 0x04000000
+#define ACPI_LV_INTERRUPTS 0x08000000
+#define ACPI_LV_VERBOSITY3 0x0F000000 | ACPI_LV_VERBOSITY2
+
+/* Exceptionally verbose output -- also used in the global "DebugLevel" */
+
+#define ACPI_LV_AML_DISASSEMBLE 0x10000000
+#define ACPI_LV_VERBOSE_INFO 0x20000000
+#define ACPI_LV_FULL_TABLES 0x40000000
+#define ACPI_LV_EVENTS 0x80000000
+
+#define ACPI_LV_VERBOSE 0xF0000000
+
+
+/*
+ * Debug level macros that are used in the DEBUG_PRINT macros
+ */
+#define ACPI_DEBUG_LEVEL(dl) (UINT32) dl,__LINE__,&_Dbg
+
+/* Exception level -- used in the global "DebugLevel" */
+
+#define ACPI_DB_ERROR ACPI_DEBUG_LEVEL (ACPI_LV_ERROR)
+#define ACPI_DB_WARN ACPI_DEBUG_LEVEL (ACPI_LV_WARN)
+#define ACPI_DB_INIT ACPI_DEBUG_LEVEL (ACPI_LV_INIT)
+#define ACPI_DB_DEBUG_OBJECT ACPI_DEBUG_LEVEL (ACPI_LV_DEBUG_OBJECT)
+#define ACPI_DB_INFO ACPI_DEBUG_LEVEL (ACPI_LV_INFO)
+#define ACPI_DB_ALL_EXCEPTIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALL_EXCEPTIONS)
+
+
+/* Trace level -- also used in the global "DebugLevel" */
+
+#define ACPI_DB_INIT_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES)
+#define ACPI_DB_THREADS ACPI_DEBUG_LEVEL (ACPI_LV_THREADS)
+#define ACPI_DB_PARSE ACPI_DEBUG_LEVEL (ACPI_LV_PARSE)
+#define ACPI_DB_DISPATCH ACPI_DEBUG_LEVEL (ACPI_LV_DISPATCH)
+#define ACPI_DB_LOAD ACPI_DEBUG_LEVEL (ACPI_LV_LOAD)
+#define ACPI_DB_EXEC ACPI_DEBUG_LEVEL (ACPI_LV_EXEC)
+#define ACPI_DB_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_NAMES)
+#define ACPI_DB_OPREGION ACPI_DEBUG_LEVEL (ACPI_LV_OPREGION)
+#define ACPI_DB_BFIELD ACPI_DEBUG_LEVEL (ACPI_LV_BFIELD)
+#define ACPI_DB_TABLES ACPI_DEBUG_LEVEL (ACPI_LV_TABLES)
+#define ACPI_DB_FUNCTIONS ACPI_DEBUG_LEVEL (ACPI_LV_FUNCTIONS)
+#define ACPI_DB_OPTIMIZATIONS ACPI_DEBUG_LEVEL (ACPI_LV_OPTIMIZATIONS)
+#define ACPI_DB_VALUES ACPI_DEBUG_LEVEL (ACPI_LV_VALUES)
+#define ACPI_DB_OBJECTS ACPI_DEBUG_LEVEL (ACPI_LV_OBJECTS)
+#define ACPI_DB_ALLOCATIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALLOCATIONS)
+#define ACPI_DB_RESOURCES ACPI_DEBUG_LEVEL (ACPI_LV_RESOURCES)
+#define ACPI_DB_IO ACPI_DEBUG_LEVEL (ACPI_LV_IO)
+#define ACPI_DB_INTERRUPTS ACPI_DEBUG_LEVEL (ACPI_LV_INTERRUPTS)
+#define ACPI_DB_USER_REQUESTS ACPI_DEBUG_LEVEL (ACPI_LV_USER_REQUESTS)
+#define ACPI_DB_PACKAGE ACPI_DEBUG_LEVEL (ACPI_LV_PACKAGE)
+#define ACPI_DB_MUTEX ACPI_DEBUG_LEVEL (ACPI_LV_MUTEX)
+
+#define ACPI_DB_ALL ACPI_DEBUG_LEVEL (ACPI_LV_ALL)
+
+
+/* Defaults for DebugLevel, debug and normal */
+
+#define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT)
+#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT)
+#define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL)
+
+
+#endif /* __ACOUTPUT_H__ */
diff --git a/sys/contrib/dev/acpica/acparser.h b/sys/contrib/dev/acpica/acparser.h
new file mode 100644
index 0000000..d3f6727
--- /dev/null
+++ b/sys/contrib/dev/acpica/acparser.h
@@ -0,0 +1,420 @@
+/******************************************************************************
+ *
+ * Module Name: acparser.h - AML Parser subcomponent prototypes and defines
+ * $Revision: 65 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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);
+
+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,
+ BOOLEAN MethodCall);
+
+ACPI_PARSE_OBJECT *
+AcpiPsGetNextField (
+ ACPI_PARSE_STATE *ParserState);
+
+ACPI_STATUS
+AcpiPsGetNextArg (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_STATE *ParserState,
+ UINT32 ArgType,
+ 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);
+
+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,
+ 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 (
+ char *BufferStart,
+ UINT32 BufferSize,
+ ACPI_PARSE_OBJECT *Op);
+
+UINT32
+AcpiPsSprintOp (
+ char *BufferStart,
+ UINT32 BufferSize,
+ ACPI_PARSE_OBJECT *Op);
+
+void
+AcpiPsShow (
+ ACPI_PARSE_OBJECT *op);
+
+
+#endif /* __ACPARSER_H__ */
diff --git a/sys/contrib/dev/acpica/acpi.h b/sys/contrib/dev/acpica/acpi.h
new file mode 100644
index 0000000..0ae41b2
--- /dev/null
+++ b/sys/contrib/dev/acpica/acpi.h
@@ -0,0 +1,142 @@
+/******************************************************************************
+ *
+ * Name: acpi.h - Master include file, Publics and external data.
+ * $Revision: 56 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACPI_H__
+#define __ACPI_H__
+
+/*
+ * Common includes for all ACPI driver files
+ * We put them here because we don't want to duplicate them
+ * in the rest of the source code again and again.
+ */
+#include "acconfig.h" /* Configuration constants */
+#include "acenv.h" /* Target environment specific items */
+#include "actypes.h" /* Fundamental common data types */
+#include "acexcep.h" /* ACPI exception codes */
+#include "acmacros.h" /* C macros */
+#include "actbl.h" /* ACPI table definitions */
+#include "aclocal.h" /* Internal data types */
+#include "acoutput.h" /* Error output and Debug macros */
+#include "acpiosxf.h" /* Interfaces to the ACPI-to-OS layer*/
+#include "acpixf.h" /* ACPI core subsystem external interfaces */
+#include "acobject.h" /* ACPI internal object */
+#include "acstruct.h" /* Common structures */
+#include "acglobal.h" /* All global variables */
+#include "achware.h" /* Hardware defines and interfaces */
+#include "acutils.h" /* Utility interfaces */
+
+
+#endif /* __ACPI_H__ */
diff --git a/sys/contrib/dev/acpica/acpica_prep.sh b/sys/contrib/dev/acpica/acpica_prep.sh
new file mode 100755
index 0000000..a128538
--- /dev/null
+++ b/sys/contrib/dev/acpica/acpica_prep.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+# $FreeBSD$
+#
+# Unpack an ACPI CA drop and restructure it to fit the FreeBSD layout
+#
+
+if [ ! $# -eq 1 ]; then
+ echo "usage: $0 acpica_archive"
+ exit
+fi
+
+src=$1
+wrk=./_acpi_ca_unpack
+dst=./acpi_ca_destination
+
+# files to remove
+stripdirs="common compiler generate acpisrc"
+stripfiles="osunixxf.c Makefile README adisasm.h acdos16.h \
+ acintel.h aclinux.h acmsvc.h acwin.h acwin64.h"
+# files to update paths in
+src_update_files="acpi.h acpiosxf.h"
+
+# pre-clean
+echo pre-clean
+rm -rf ${wrk}
+rm -rf ${dst}
+mkdir -p ${wrk}
+mkdir -p ${dst}
+
+# fetch document
+echo fetch document
+fetch http://developer.intel.com/technology/iapc/acpi/downloads/CHANGES.txt
+tr -d '\r' < CHANGES.txt > CHANGES.txt.tmp
+mv CHANGES.txt.tmp CHANGES.txt
+
+# unpack
+echo unpack
+tar -x -z -f ${src} -C ${wrk}
+
+# strip files
+echo strip
+for i in ${stripdirs}; do
+ find ${wrk} -name ${i} -type d | xargs rm -r
+done
+for i in ${stripfiles}; do
+ find ${wrk} -name ${i} -type f -delete
+done
+
+# move files to destination
+echo copy
+find ${wrk} -type f | xargs -J % mv % ${dst}
+mv CHANGES.txt ${dst}
+
+# update src/headers for appropriate paths
+echo updating paths
+for i in ${src_update_files}; do
+ i=${dst}/$i
+ sed -e 's/platform\///' $i > $i.new && mv $i.new $i
+done
+
+# post-clean
+echo post-clean
+rm -rf ${wrk}
+
+# assist the developer in generating a diff
+echo "Directories you may want to 'cvs diff':"
+echo " src/sys/dev/acpica src/sys/i386/acpica src/sys/ia64/acpica \\"
+echo " src/sys/modules/acpi src/sys/boot src/sys/i386/include \\"
+echo " src/usr.sbin/acpi src/sys/contrib/dev/acpica"
diff --git a/sys/contrib/dev/acpica/acpiosxf.h b/sys/contrib/dev/acpica/acpiosxf.h
new file mode 100644
index 0000000..acbd985
--- /dev/null
+++ b/sys/contrib/dev/acpica/acpiosxf.h
@@ -0,0 +1,442 @@
+
+/******************************************************************************
+ *
+ * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL). These
+ * interfaces must be implemented by OSL to interface the
+ * ACPI components to the host operating system.
+ *
+ *****************************************************************************/
+
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 exer
+ se 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 __ACPIOSXF_H__
+#define __ACPIOSXF_H__
+
+#include "acenv.h"
+#include "actypes.h"
+
+
+/* Priorities for AcpiOsQueueForExecution */
+
+#define OSD_PRIORITY_GPE 1
+#define OSD_PRIORITY_HIGH 2
+#define OSD_PRIORITY_MED 3
+#define OSD_PRIORITY_LO 4
+
+#define ACPI_NO_UNIT_LIMIT ((UINT32) -1)
+#define ACPI_MUTEX_SEM 1
+
+
+/* Functions for AcpiOsSignal */
+
+#define ACPI_SIGNAL_FATAL 0
+#define ACPI_SIGNAL_BREAKPOINT 1
+
+typedef struct acpi_signal_fatal_info
+{
+ UINT32 Type;
+ UINT32 Code;
+ UINT32 Argument;
+
+} ACPI_SIGNAL_FATAL_INFO;
+
+
+/*
+ * Types specific to the OS service interfaces
+ */
+
+typedef UINT32
+(ACPI_SYSTEM_XFACE *OSD_HANDLER) (
+ void *Context);
+
+typedef void
+(ACPI_SYSTEM_XFACE *OSD_EXECUTION_CALLBACK) (
+ void *Context);
+
+
+/*
+ * OSL Initialization and shutdown primitives
+ */
+
+ACPI_STATUS
+AcpiOsInitialize (
+ void);
+
+ACPI_STATUS
+AcpiOsTerminate (
+ void);
+
+
+/*
+ * ACPI Table interfaces
+ */
+
+ACPI_STATUS
+AcpiOsGetRootPointer (
+ UINT32 Flags,
+ ACPI_POINTER *Address);
+
+ACPI_STATUS
+AcpiOsPredefinedOverride (
+ const ACPI_PREDEFINED_NAMES *InitVal,
+ ACPI_STRING *NewVal);
+
+ACPI_STATUS
+AcpiOsTableOverride (
+ ACPI_TABLE_HEADER *ExistingTable,
+ ACPI_TABLE_HEADER **NewTable);
+
+
+/*
+ * Synchronization primitives
+ */
+
+ACPI_STATUS
+AcpiOsCreateSemaphore (
+ UINT32 MaxUnits,
+ UINT32 InitialUnits,
+ ACPI_HANDLE *OutHandle);
+
+ACPI_STATUS
+AcpiOsDeleteSemaphore (
+ ACPI_HANDLE Handle);
+
+ACPI_STATUS
+AcpiOsWaitSemaphore (
+ ACPI_HANDLE Handle,
+ UINT32 Units,
+ UINT16 Timeout);
+
+ACPI_STATUS
+AcpiOsSignalSemaphore (
+ ACPI_HANDLE Handle,
+ UINT32 Units);
+
+
+/*
+ * Memory allocation and mapping
+ */
+
+void *
+AcpiOsAllocate (
+ ACPI_SIZE Size);
+
+void
+AcpiOsFree (
+ void * Memory);
+
+ACPI_STATUS
+AcpiOsMapMemory (
+ ACPI_PHYSICAL_ADDRESS PhysicalAddress,
+ ACPI_SIZE Size,
+ void **LogicalAddress);
+
+void
+AcpiOsUnmapMemory (
+ void *LogicalAddress,
+ ACPI_SIZE Size);
+
+ACPI_STATUS
+AcpiOsGetPhysicalAddress (
+ void *LogicalAddress,
+ ACPI_PHYSICAL_ADDRESS *PhysicalAddress);
+
+
+/*
+ * Interrupt handlers
+ */
+
+ACPI_STATUS
+AcpiOsInstallInterruptHandler (
+ UINT32 InterruptNumber,
+ OSD_HANDLER ServiceRoutine,
+ void *Context);
+
+ACPI_STATUS
+AcpiOsRemoveInterruptHandler (
+ UINT32 InterruptNumber,
+ OSD_HANDLER ServiceRoutine);
+
+
+/*
+ * Threads and Scheduling
+ */
+
+UINT32
+AcpiOsGetThreadId (
+ void);
+
+ACPI_STATUS
+AcpiOsQueueForExecution (
+ UINT32 Priority,
+ OSD_EXECUTION_CALLBACK Function,
+ void *Context);
+
+void
+AcpiOsSleep (
+ UINT32 Seconds,
+ UINT32 Milliseconds);
+
+void
+AcpiOsStall (
+ UINT32 Microseconds);
+
+
+/*
+ * Platform and hardware-independent I/O interfaces
+ */
+
+ACPI_STATUS
+AcpiOsReadPort (
+ ACPI_IO_ADDRESS Address,
+ void *Value,
+ UINT32 Width);
+
+ACPI_STATUS
+AcpiOsWritePort (
+ ACPI_IO_ADDRESS Address,
+ ACPI_INTEGER Value,
+ UINT32 Width);
+
+
+/*
+ * Platform and hardware-independent physical memory interfaces
+ */
+
+ACPI_STATUS
+AcpiOsReadMemory (
+ ACPI_PHYSICAL_ADDRESS Address,
+ void *Value,
+ UINT32 Width);
+
+ACPI_STATUS
+AcpiOsWriteMemory (
+ ACPI_PHYSICAL_ADDRESS Address,
+ ACPI_INTEGER Value,
+ UINT32 Width);
+
+
+/*
+ * Platform and hardware-independent PCI configuration space access
+ */
+
+ACPI_STATUS
+AcpiOsReadPciConfiguration (
+ ACPI_PCI_ID *PciId,
+ UINT32 Register,
+ void *Value,
+ UINT32 Width);
+
+ACPI_STATUS
+AcpiOsWritePciConfiguration (
+ ACPI_PCI_ID *PciId,
+ UINT32 Register,
+ ACPI_INTEGER Value,
+ UINT32 Width);
+
+/*
+ * Interim function needed for PCI IRQ routing
+ */
+void
+AcpiOsDerivePciId(
+ ACPI_HANDLE rhandle,
+ ACPI_HANDLE chandle,
+ ACPI_PCI_ID **PciId);
+
+/*
+ * Miscellaneous
+ */
+
+BOOLEAN
+AcpiOsReadable (
+ void *Pointer,
+ UINT32 Length);
+
+BOOLEAN
+AcpiOsWritable (
+ void *Pointer,
+ UINT32 Length);
+
+UINT32
+AcpiOsGetTimer (
+ void);
+
+ACPI_STATUS
+AcpiOsSignal (
+ UINT32 Function,
+ void *Info);
+
+/*
+ * Debug print routines
+ */
+
+void ACPI_INTERNAL_VAR_XFACE
+AcpiOsPrintf (
+ const char *Format,
+ ...);
+
+void
+AcpiOsVprintf (
+ const char *Format,
+ va_list Args);
+
+void
+AcpiOsRedirectOutput (
+ void *Destination);
+
+
+/*
+ * Debug input
+ */
+
+UINT32
+AcpiOsGetLine (
+ char *Buffer);
+
+
+/*
+ * Directory manipulation
+ */
+
+void *
+AcpiOsOpenDirectory (
+ char *Pathname,
+ char *WildcardSpec,
+ char RequestedFileType);
+
+/* RequesteFileType values */
+
+#define REQUEST_FILE_ONLY 0
+#define REQUEST_DIR_ONLY 1
+
+
+char *
+AcpiOsGetNextFilename (
+ void *DirHandle);
+
+void
+AcpiOsCloseDirectory (
+ void *DirHandle);
+
+/*
+ * Debug
+ */
+
+void
+AcpiOsDbgAssert(
+ void *FailedAssertion,
+ void *FileName,
+ UINT32 LineNumber,
+ char *Message);
+
+
+#endif /* __ACPIOSXF_H__ */
diff --git a/sys/contrib/dev/acpica/acpixf.h b/sys/contrib/dev/acpica/acpixf.h
new file mode 100644
index 0000000..ea13888
--- /dev/null
+++ b/sys/contrib/dev/acpica/acpixf.h
@@ -0,0 +1,499 @@
+
+/******************************************************************************
+ *
+ * Name: acpixf.h - External interfaces to the ACPI subsystem
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACXFACE_H__
+#define __ACXFACE_H__
+
+#include "actypes.h"
+#include "actbl.h"
+
+
+ /*
+ * Global interfaces
+ */
+
+ACPI_STATUS
+AcpiInitializeSubsystem (
+ void);
+
+ACPI_STATUS
+AcpiEnableSubsystem (
+ UINT32 Flags);
+
+ACPI_STATUS
+AcpiInitializeObjects (
+ UINT32 Flags);
+
+ACPI_STATUS
+AcpiTerminate (
+ void);
+
+ACPI_STATUS
+AcpiSubsystemStatus (
+ void);
+
+ACPI_STATUS
+AcpiEnable (
+ void);
+
+ACPI_STATUS
+AcpiDisable (
+ void);
+
+ACPI_STATUS
+AcpiGetSystemInfo (
+ ACPI_BUFFER *RetBuffer);
+
+const char *
+AcpiFormatException (
+ ACPI_STATUS Exception);
+
+ACPI_STATUS
+AcpiPurgeCachedObjects (
+ void);
+
+ACPI_STATUS
+AcpiInstallInitializationHandler (
+ ACPI_INIT_HANDLER Handler,
+ UINT32 Function);
+
+/*
+ * ACPI Memory manager
+ */
+
+void *
+AcpiAllocate (
+ UINT32 Size);
+
+void *
+AcpiCallocate (
+ UINT32 Size);
+
+void
+AcpiFree (
+ void *Address);
+
+
+/*
+ * ACPI table manipulation interfaces
+ */
+
+ACPI_STATUS
+AcpiFindRootPointer (
+ UINT32 Flags,
+ ACPI_POINTER *RsdpAddress);
+
+ACPI_STATUS
+AcpiLoadTables (
+ void);
+
+ACPI_STATUS
+AcpiLoadTable (
+ ACPI_TABLE_HEADER *TablePtr);
+
+ACPI_STATUS
+AcpiUnloadTable (
+ ACPI_TABLE_TYPE TableType);
+
+ACPI_STATUS
+AcpiGetTableHeader (
+ ACPI_TABLE_TYPE TableType,
+ UINT32 Instance,
+ ACPI_TABLE_HEADER *OutTableHeader);
+
+ACPI_STATUS
+AcpiGetTable (
+ ACPI_TABLE_TYPE TableType,
+ UINT32 Instance,
+ ACPI_BUFFER *RetBuffer);
+
+ACPI_STATUS
+AcpiGetFirmwareTable (
+ ACPI_STRING Signature,
+ UINT32 Instance,
+ UINT32 Flags,
+ ACPI_TABLE_HEADER **TablePointer);
+
+
+/*
+ * Namespace and name interfaces
+ */
+
+ACPI_STATUS
+AcpiWalkNamespace (
+ ACPI_OBJECT_TYPE Type,
+ ACPI_HANDLE StartObject,
+ UINT32 MaxDepth,
+ ACPI_WALK_CALLBACK UserFunction,
+ void *Context,
+ void **ReturnValue);
+
+ACPI_STATUS
+AcpiGetDevices (
+ char *HID,
+ ACPI_WALK_CALLBACK UserFunction,
+ void *Context,
+ void **ReturnValue);
+
+ACPI_STATUS
+AcpiGetName (
+ ACPI_HANDLE Handle,
+ UINT32 NameType,
+ ACPI_BUFFER *RetPathPtr);
+
+ACPI_STATUS
+AcpiGetHandle (
+ ACPI_HANDLE Parent,
+ ACPI_STRING Pathname,
+ ACPI_HANDLE *RetHandle);
+
+ACPI_STATUS
+AcpiAttachData (
+ ACPI_HANDLE ObjHandle,
+ ACPI_OBJECT_HANDLER Handler,
+ void *Data);
+
+ACPI_STATUS
+AcpiDetachData (
+ ACPI_HANDLE ObjHandle,
+ ACPI_OBJECT_HANDLER Handler);
+
+ACPI_STATUS
+AcpiGetData (
+ ACPI_HANDLE ObjHandle,
+ ACPI_OBJECT_HANDLER Handler,
+ void **Data);
+
+
+/*
+ * Object manipulation and enumeration
+ */
+
+ACPI_STATUS
+AcpiEvaluateObject (
+ ACPI_HANDLE Object,
+ ACPI_STRING Pathname,
+ ACPI_OBJECT_LIST *ParameterObjects,
+ ACPI_BUFFER *ReturnObjectBuffer);
+
+ACPI_STATUS
+AcpiEvaluateObjectTyped (
+ ACPI_HANDLE Object,
+ ACPI_STRING Pathname,
+ ACPI_OBJECT_LIST *ExternalParams,
+ ACPI_BUFFER *ReturnBuffer,
+ ACPI_OBJECT_TYPE ReturnType);
+
+ACPI_STATUS
+AcpiGetObjectInfo (
+ ACPI_HANDLE Device,
+ ACPI_DEVICE_INFO *Info);
+
+ACPI_STATUS
+AcpiGetNextObject (
+ ACPI_OBJECT_TYPE Type,
+ ACPI_HANDLE Parent,
+ ACPI_HANDLE Child,
+ ACPI_HANDLE *OutHandle);
+
+ACPI_STATUS
+AcpiGetType (
+ ACPI_HANDLE Object,
+ ACPI_OBJECT_TYPE *OutType);
+
+ACPI_STATUS
+AcpiGetParent (
+ ACPI_HANDLE Object,
+ ACPI_HANDLE *OutHandle);
+
+
+/*
+ * Event handler interfaces
+ */
+
+ACPI_STATUS
+AcpiInstallFixedEventHandler (
+ UINT32 AcpiEvent,
+ ACPI_EVENT_HANDLER Handler,
+ void *Context);
+
+ACPI_STATUS
+AcpiRemoveFixedEventHandler (
+ UINT32 AcpiEvent,
+ ACPI_EVENT_HANDLER Handler);
+
+ACPI_STATUS
+AcpiInstallNotifyHandler (
+ ACPI_HANDLE Device,
+ UINT32 HandlerType,
+ ACPI_NOTIFY_HANDLER Handler,
+ void *Context);
+
+ACPI_STATUS
+AcpiRemoveNotifyHandler (
+ ACPI_HANDLE Device,
+ UINT32 HandlerType,
+ ACPI_NOTIFY_HANDLER Handler);
+
+ACPI_STATUS
+AcpiInstallAddressSpaceHandler (
+ ACPI_HANDLE Device,
+ ACPI_ADR_SPACE_TYPE SpaceId,
+ ACPI_ADR_SPACE_HANDLER Handler,
+ ACPI_ADR_SPACE_SETUP Setup,
+ void *Context);
+
+ACPI_STATUS
+AcpiRemoveAddressSpaceHandler (
+ ACPI_HANDLE Device,
+ ACPI_ADR_SPACE_TYPE SpaceId,
+ ACPI_ADR_SPACE_HANDLER Handler);
+
+ACPI_STATUS
+AcpiInstallGpeHandler (
+ UINT32 GpeNumber,
+ UINT32 Type,
+ ACPI_GPE_HANDLER Handler,
+ void *Context);
+
+ACPI_STATUS
+AcpiAcquireGlobalLock (
+ UINT16 Timeout,
+ UINT32 *Handle);
+
+ACPI_STATUS
+AcpiReleaseGlobalLock (
+ UINT32 Handle);
+
+ACPI_STATUS
+AcpiRemoveGpeHandler (
+ UINT32 GpeNumber,
+ ACPI_GPE_HANDLER Handler);
+
+ACPI_STATUS
+AcpiEnableEvent (
+ UINT32 AcpiEvent,
+ UINT32 Type,
+ UINT32 Flags);
+
+ACPI_STATUS
+AcpiDisableEvent (
+ UINT32 AcpiEvent,
+ UINT32 Type,
+ UINT32 Flags);
+
+ACPI_STATUS
+AcpiClearEvent (
+ UINT32 AcpiEvent,
+ UINT32 Type);
+
+ACPI_STATUS
+AcpiGetEventStatus (
+ UINT32 AcpiEvent,
+ UINT32 Type,
+ ACPI_EVENT_STATUS *EventStatus);
+
+/*
+ * Resource interfaces
+ */
+
+typedef
+ACPI_STATUS (*ACPI_WALK_RESOURCE_CALLBACK) (
+ ACPI_RESOURCE *Resource,
+ void *Context);
+
+
+ACPI_STATUS
+AcpiGetCurrentResources(
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *RetBuffer);
+
+ACPI_STATUS
+AcpiGetPossibleResources(
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *RetBuffer);
+
+ACPI_STATUS
+AcpiWalkResources (
+ ACPI_HANDLE DeviceHandle,
+ char *Path,
+ ACPI_WALK_RESOURCE_CALLBACK UserFunction,
+ void *Context);
+
+ACPI_STATUS
+AcpiSetCurrentResources (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *InBuffer);
+
+ACPI_STATUS
+AcpiGetIrqRoutingTable (
+ ACPI_HANDLE BusDeviceHandle,
+ ACPI_BUFFER *RetBuffer);
+
+ACPI_STATUS
+AcpiResourceToAddress64 (
+ ACPI_RESOURCE *Resource,
+ ACPI_RESOURCE_ADDRESS64 *Out);
+
+/*
+ * Hardware (ACPI device) interfaces
+ */
+
+ACPI_STATUS
+AcpiGetRegister (
+ UINT32 RegisterId,
+ UINT32 *ReturnValue,
+ UINT32 Flags);
+
+ACPI_STATUS
+AcpiSetRegister (
+ UINT32 RegisterId,
+ UINT32 Value,
+ UINT32 Flags);
+
+ACPI_STATUS
+AcpiSetFirmwareWakingVector (
+ ACPI_PHYSICAL_ADDRESS PhysicalAddress);
+
+ACPI_STATUS
+AcpiGetFirmwareWakingVector (
+ ACPI_PHYSICAL_ADDRESS *PhysicalAddress);
+
+ACPI_STATUS
+AcpiGetSleepTypeData (
+ UINT8 SleepState,
+ UINT8 *Slp_TypA,
+ UINT8 *Slp_TypB);
+
+ACPI_STATUS
+AcpiEnterSleepStatePrep (
+ UINT8 SleepState);
+
+ACPI_STATUS
+AcpiEnterSleepState (
+ UINT8 SleepState);
+
+ACPI_STATUS
+AcpiEnterSleepStateS4bios (
+ void);
+
+ACPI_STATUS
+AcpiLeaveSleepState (
+ UINT8 SleepState);
+
+
+#endif /* __ACXFACE_H__ */
diff --git a/sys/contrib/dev/acpica/acresrc.h b/sys/contrib/dev/acpica/acresrc.h
new file mode 100644
index 0000000..f1b1729
--- /dev/null
+++ b/sys/contrib/dev/acpica/acresrc.h
@@ -0,0 +1,465 @@
+/******************************************************************************
+ *
+ * Name: acresrc.h - Resource Manager function prototypes
+ * $Revision: 37 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACRESRC_H__
+#define __ACRESRC_H__
+
+
+/*
+ * Function prototypes called from Acpi* APIs
+ */
+
+ACPI_STATUS
+AcpiRsGetPrtMethodData (
+ ACPI_HANDLE Handle,
+ ACPI_BUFFER *RetBuffer);
+
+
+ACPI_STATUS
+AcpiRsGetCrsMethodData (
+ ACPI_HANDLE Handle,
+ ACPI_BUFFER *RetBuffer);
+
+ACPI_STATUS
+AcpiRsGetPrsMethodData (
+ ACPI_HANDLE Handle,
+ ACPI_BUFFER *RetBuffer);
+
+ACPI_STATUS
+AcpiRsGetMethodData (
+ ACPI_HANDLE Handle,
+ char *Path,
+ ACPI_BUFFER *RetBuffer);
+
+ACPI_STATUS
+AcpiRsSetSrsMethodData (
+ ACPI_HANDLE Handle,
+ ACPI_BUFFER *RetBuffer);
+
+ACPI_STATUS
+AcpiRsCreateResourceList (
+ ACPI_OPERAND_OBJECT *ByteStreamBuffer,
+ ACPI_BUFFER *OutputBuffer);
+
+ACPI_STATUS
+AcpiRsCreateByteStream (
+ ACPI_RESOURCE *LinkedListBuffer,
+ ACPI_BUFFER *OutputBuffer);
+
+ACPI_STATUS
+AcpiRsCreatePciRoutingTable (
+ ACPI_OPERAND_OBJECT *PackageObject,
+ ACPI_BUFFER *OutputBuffer);
+
+
+/*
+ * Function prototypes called from AcpiRsCreate*
+ */
+void
+AcpiRsDumpIrq (
+ ACPI_RESOURCE_DATA *Data);
+
+void
+AcpiRsDumpAddress16 (
+ ACPI_RESOURCE_DATA *Data);
+
+void
+AcpiRsDumpAddress32 (
+ ACPI_RESOURCE_DATA *Data);
+
+void
+AcpiRsDumpAddress64 (
+ ACPI_RESOURCE_DATA *Data);
+
+void
+AcpiRsDumpDma (
+ ACPI_RESOURCE_DATA *Data);
+
+void
+AcpiRsDumpIo (
+ ACPI_RESOURCE_DATA *Data);
+
+void
+AcpiRsDumpExtendedIrq (
+ ACPI_RESOURCE_DATA *Data);
+
+void
+AcpiRsDumpFixedIo (
+ ACPI_RESOURCE_DATA *Data);
+
+void
+AcpiRsDumpFixedMemory32 (
+ ACPI_RESOURCE_DATA *Data);
+
+void
+AcpiRsDumpMemory24 (
+ ACPI_RESOURCE_DATA *Data);
+
+void
+AcpiRsDumpMemory32 (
+ ACPI_RESOURCE_DATA *Data);
+
+void
+AcpiRsDumpStartDependFns (
+ ACPI_RESOURCE_DATA *Data);
+
+void
+AcpiRsDumpVendorSpecific (
+ ACPI_RESOURCE_DATA *Data);
+
+void
+AcpiRsDumpResourceList (
+ ACPI_RESOURCE *Resource);
+
+void
+AcpiRsDumpIrqList (
+ UINT8 *RouteTable);
+
+ACPI_STATUS
+AcpiRsGetByteStreamStart (
+ UINT8 *ByteStreamBuffer,
+ UINT8 **ByteStreamStart,
+ UINT32 *Size);
+
+ACPI_STATUS
+AcpiRsGetListLength (
+ UINT8 *ByteStreamBuffer,
+ UINT32 ByteStreamBufferLength,
+ ACPI_SIZE *SizeNeeded);
+
+ACPI_STATUS
+AcpiRsGetByteStreamLength (
+ ACPI_RESOURCE *LinkedListBuffer,
+ ACPI_SIZE *SizeNeeded);
+
+ACPI_STATUS
+AcpiRsGetPciRoutingTableLength (
+ ACPI_OPERAND_OBJECT *PackageObject,
+ ACPI_SIZE *BufferSizeNeeded);
+
+ACPI_STATUS
+AcpiRsByteStreamToList (
+ UINT8 *ByteStreamBuffer,
+ UINT32 ByteStreamBufferLength,
+ UINT8 *OutputBuffer);
+
+ACPI_STATUS
+AcpiRsListToByteStream (
+ ACPI_RESOURCE *LinkedList,
+ ACPI_SIZE ByteStreamSizeNeeded,
+ UINT8 *OutputBuffer);
+
+ACPI_STATUS
+AcpiRsIoResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsFixedIoResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsIoStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsFixedIoStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsIrqResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsIrqStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsDmaResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsDmaStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsAddress16Resource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsAddress16Stream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsAddress32Resource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsAddress32Stream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsAddress64Resource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsAddress64Stream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsStartDependFnsResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsEndDependFnsResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsStartDependFnsStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsEndDependFnsStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsMemory24Resource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsMemory24Stream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsMemory32RangeResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsFixedMemory32Resource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsMemory32RangeStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsFixedMemory32Stream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsExtendedIrqResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsExtendedIrqStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsEndTagResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsEndTagStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+ACPI_STATUS
+AcpiRsVendorResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize);
+
+ACPI_STATUS
+AcpiRsVendorStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed);
+
+UINT8
+AcpiRsGetResourceType (
+ UINT8 ResourceStartByte);
+
+#endif /* __ACRESRC_H__ */
diff --git a/sys/contrib/dev/acpica/acstruct.h b/sys/contrib/dev/acpica/acstruct.h
new file mode 100644
index 0000000..9ce641e
--- /dev/null
+++ b/sys/contrib/dev/acpica/acstruct.h
@@ -0,0 +1,281 @@
+/******************************************************************************
+ *
+ * Name: acstruct.h - Internal structs
+ * $Revision: 25 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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_namespace_node Arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */
+ union acpi_operand_object **CallerReturnDesc;
+ ACPI_GENERIC_STATE *ControlState; /* List of control states (nested IFs) */
+ struct acpi_namespace_node LocalVariables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */
+ struct acpi_namespace_node *MethodCallNode; /* Called method Node*/
+ ACPI_PARSE_OBJECT *MethodCallOp; /* MethodCall Op if running a method */
+ union acpi_operand_object *MethodDesc; /* Method descriptor if running a method */
+ struct acpi_namespace_node *MethodNode; /* Method Node if running a method */
+ ACPI_PARSE_OBJECT *Op; /* Current parser op */
+ union acpi_operand_object *Operands[ACPI_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_object **Params;
+ ACPI_PARSE_STATE ParserState; /* Current state of parser */
+ union acpi_operand_object *ResultObj;
+ ACPI_GENERIC_STATE *Results; /* Stack of accumulated results */
+ union acpi_operand_object *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;
+ 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/actables.h b/sys/contrib/dev/acpica/actables.h
new file mode 100644
index 0000000..ecf733f
--- /dev/null
+++ b/sys/contrib/dev/acpica/actables.h
@@ -0,0 +1,310 @@
+/******************************************************************************
+ *
+ * Name: actables.h - ACPI table management
+ * $Revision: 44 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACTABLES_H__
+#define __ACTABLES_H__
+
+
+/* Used in AcpiTbMapAcpiTable for size parameter if table header is to be used */
+
+#define SIZE_IN_HEADER 0
+
+
+ACPI_STATUS
+AcpiTbHandleToObject (
+ UINT16 TableId,
+ ACPI_TABLE_DESC **TableDesc);
+
+/*
+ * tbconvrt - Table conversion routines
+ */
+
+ACPI_STATUS
+AcpiTbConvertToXsdt (
+ ACPI_TABLE_DESC *TableInfo);
+
+ACPI_STATUS
+AcpiTbConvertTableFadt (
+ void);
+
+ACPI_STATUS
+AcpiTbBuildCommonFacs (
+ ACPI_TABLE_DESC *TableInfo);
+
+UINT32
+AcpiTbGetTableCount (
+ RSDP_DESCRIPTOR *RSDP,
+ ACPI_TABLE_HEADER *RSDT);
+
+/*
+ * tbget - Table "get" routines
+ */
+
+ACPI_STATUS
+AcpiTbGetTable (
+ ACPI_POINTER *Address,
+ ACPI_TABLE_DESC *TableInfo);
+
+ACPI_STATUS
+AcpiTbGetTableHeader (
+ ACPI_POINTER *Address,
+ ACPI_TABLE_HEADER *ReturnHeader);
+
+ACPI_STATUS
+AcpiTbGetTableBody (
+ ACPI_POINTER *Address,
+ ACPI_TABLE_HEADER *Header,
+ ACPI_TABLE_DESC *TableInfo);
+
+ACPI_STATUS
+AcpiTbGetThisTable (
+ ACPI_POINTER *Address,
+ ACPI_TABLE_HEADER *Header,
+ ACPI_TABLE_DESC *TableInfo);
+
+ACPI_STATUS
+AcpiTbTableOverride (
+ ACPI_TABLE_HEADER *Header,
+ ACPI_TABLE_DESC *TableInfo);
+
+ACPI_STATUS
+AcpiTbGetTablePtr (
+ ACPI_TABLE_TYPE TableType,
+ UINT32 Instance,
+ ACPI_TABLE_HEADER **TablePtrLoc);
+
+ACPI_STATUS
+AcpiTbVerifyRsdp (
+ ACPI_POINTER *Address);
+
+void
+AcpiTbGetRsdtAddress (
+ ACPI_POINTER *OutAddress);
+
+ACPI_STATUS
+AcpiTbValidateRsdt (
+ ACPI_TABLE_HEADER *TablePtr);
+
+ACPI_STATUS
+AcpiTbGetRequiredTables (
+ void);
+
+ACPI_STATUS
+AcpiTbGetPrimaryTable (
+ ACPI_POINTER *Address,
+ ACPI_TABLE_DESC *TableInfo);
+
+ACPI_STATUS
+AcpiTbGetSecondaryTable (
+ ACPI_POINTER *Address,
+ ACPI_STRING Signature,
+ ACPI_TABLE_DESC *TableInfo);
+
+/*
+ * tbinstall - Table installation
+ */
+
+ACPI_STATUS
+AcpiTbInstallTable (
+ ACPI_TABLE_DESC *TableInfo);
+
+ACPI_STATUS
+AcpiTbMatchSignature (
+ char *Signature,
+ ACPI_TABLE_DESC *TableInfo,
+ UINT8 SearchType);
+
+ACPI_STATUS
+AcpiTbRecognizeTable (
+ ACPI_TABLE_DESC *TableInfo,
+ UINT8 SearchType);
+
+ACPI_STATUS
+AcpiTbInitTableDescriptor (
+ ACPI_TABLE_TYPE TableType,
+ ACPI_TABLE_DESC *TableInfo);
+
+
+/*
+ * tbremove - Table removal and deletion
+ */
+
+void
+AcpiTbDeleteAcpiTables (
+ void);
+
+void
+AcpiTbDeleteAcpiTable (
+ ACPI_TABLE_TYPE Type);
+
+void
+AcpiTbDeleteSingleTable (
+ ACPI_TABLE_DESC *TableDesc);
+
+ACPI_TABLE_DESC *
+AcpiTbUninstallTable (
+ ACPI_TABLE_DESC *TableDesc);
+
+void
+AcpiTbFreeAcpiTablesOfType (
+ ACPI_TABLE_DESC *TableInfo);
+
+
+/*
+ * tbrsd - RSDP, RSDT utilities
+ */
+
+ACPI_STATUS
+AcpiTbGetTableRsdt (
+ void);
+
+UINT8 *
+AcpiTbScanMemoryForRsdp (
+ UINT8 *StartAddress,
+ UINT32 Length);
+
+ACPI_STATUS
+AcpiTbFindRsdp (
+ ACPI_TABLE_DESC *TableInfo,
+ UINT32 Flags);
+
+
+/*
+ * tbutils - common table utilities
+ */
+
+ACPI_STATUS
+AcpiTbFindTable (
+ char *Signature,
+ char *OemId,
+ char *OemTableId,
+ ACPI_TABLE_HEADER **TablePtr);
+
+ACPI_STATUS
+AcpiTbVerifyTableChecksum (
+ ACPI_TABLE_HEADER *TableHeader);
+
+UINT8
+AcpiTbChecksum (
+ void *Buffer,
+ UINT32 Length);
+
+ACPI_STATUS
+AcpiTbValidateTableHeader (
+ ACPI_TABLE_HEADER *TableHeader);
+
+
+#endif /* __ACTABLES_H__ */
diff --git a/sys/contrib/dev/acpica/actbl.h b/sys/contrib/dev/acpica/actbl.h
new file mode 100644
index 0000000..82f3d28
--- /dev/null
+++ b/sys/contrib/dev/acpica/actbl.h
@@ -0,0 +1,308 @@
+/******************************************************************************
+ *
+ * Name: actbl.h - Table data structures defined in ACPI specification
+ * $Revision: 58 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACTBL_H__
+#define __ACTBL_H__
+
+
+/*
+ * Values for description table header signatures
+ */
+#define RSDP_NAME "RSDP"
+#define RSDP_SIG "RSD PTR " /* RSDT Pointer signature */
+#define APIC_SIG "APIC" /* Multiple APIC Description Table */
+#define DSDT_SIG "DSDT" /* Differentiated System Description Table */
+#define FADT_SIG "FACP" /* Fixed ACPI Description Table */
+#define FACS_SIG "FACS" /* Firmware ACPI Control Structure */
+#define PSDT_SIG "PSDT" /* Persistent System Description Table */
+#define RSDT_SIG "RSDT" /* Root System Description Table */
+#define XSDT_SIG "XSDT" /* Extended System Description Table */
+#define SSDT_SIG "SSDT" /* Secondary System Description Table */
+#define SBST_SIG "SBST" /* Smart Battery Specification Table */
+#define SPIC_SIG "SPIC" /* IOSAPIC table */
+#define BOOT_SIG "BOOT" /* Boot table */
+
+
+#define GL_OWNED 0x02 /* Ownership of global lock is bit 1 */
+
+/* values of Mapic.Model */
+
+#define DUAL_PIC 0
+#define MULTIPLE_APIC 1
+
+/* values of Type in APIC_HEADER */
+
+#define APIC_PROC 0
+#define APIC_IO 1
+
+
+/*
+ * Common table types. The base code can remain
+ * constant if the underlying tables are changed
+ */
+#define RSDT_DESCRIPTOR RSDT_DESCRIPTOR_REV2
+#define XSDT_DESCRIPTOR XSDT_DESCRIPTOR_REV2
+#define FACS_DESCRIPTOR FACS_DESCRIPTOR_REV2
+#define FADT_DESCRIPTOR FADT_DESCRIPTOR_REV2
+
+
+#pragma pack(1)
+
+/*
+ * Architecture-independent tables
+ * The architecture dependent tables are in separate files
+ */
+typedef struct rsdp_descriptor /* Root System Descriptor Pointer */
+{
+ char Signature [8]; /* ACPI signature, contains "RSD PTR " */
+ UINT8 Checksum; /* To make sum of struct == 0 */
+ char OemId [6]; /* OEM identification */
+ UINT8 Revision; /* Must be 0 for 1.0, 2 for 2.0 */
+ UINT32 RsdtPhysicalAddress; /* 32-bit physical address of RSDT */
+ UINT32 Length; /* XSDT Length in bytes including hdr */
+ UINT64 XsdtPhysicalAddress; /* 64-bit physical address of XSDT */
+ UINT8 ExtendedChecksum; /* Checksum of entire table */
+ char Reserved [3]; /* Reserved field must be 0 */
+
+} RSDP_DESCRIPTOR;
+
+
+typedef struct acpi_table_header /* ACPI common table header */
+{
+ char Signature [4]; /* ACPI signature (4 ASCII characters) */
+ UINT32 Length; /* Length of table, in bytes, including header */
+ UINT8 Revision; /* ACPI Specification minor version # */
+ UINT8 Checksum; /* To make sum of entire table == 0 */
+ char OemId [6]; /* OEM identification */
+ char OemTableId [8]; /* OEM table identification */
+ UINT32 OemRevision; /* OEM revision number */
+ char AslCompilerId [4]; /* ASL compiler vendor ID */
+ UINT32 AslCompilerRevision; /* ASL compiler revision number */
+
+} ACPI_TABLE_HEADER;
+
+
+typedef struct acpi_common_facs /* Common FACS for internal use */
+{
+ UINT32 *GlobalLock;
+ UINT64 *FirmwareWakingVector;
+ UINT8 VectorWidth;
+
+} ACPI_COMMON_FACS;
+
+
+typedef struct apic_table
+{
+ ACPI_TABLE_HEADER Header; /* ACPI table header */
+ UINT32 LocalApicAddress; /* Physical address for accessing local APICs */
+ UINT32_BIT PCATCompat : 1; /* a one indicates system also has dual 8259s */
+ UINT32_BIT Reserved1 : 31;
+
+} APIC_TABLE;
+
+
+typedef struct apic_header
+{
+ UINT8 Type; /* APIC type. Either APIC_PROC or APIC_IO */
+ UINT8 Length; /* Length of APIC structure */
+
+} APIC_HEADER;
+
+
+typedef struct processor_apic
+{
+ APIC_HEADER Header;
+ UINT8 ProcessorApicId; /* ACPI processor id */
+ UINT8 LocalApicId; /* Processor's local APIC id */
+ UINT32_BIT ProcessorEnabled: 1; /* Processor is usable if set */
+ UINT32_BIT Reserved1 : 31;
+
+} PROCESSOR_APIC;
+
+
+typedef struct io_apic
+{
+ APIC_HEADER Header;
+ UINT8 IoApicId; /* I/O APIC ID */
+ UINT8 Reserved; /* Reserved - must be zero */
+ UINT32 IoApicAddress; /* APIC's physical address */
+ UINT32 Vector; /* Interrupt vector index where INTI
+ * lines start */
+} IO_APIC;
+
+
+/*
+ * IA64 TBD: Add SAPIC Tables
+ */
+
+/*
+ * IA64 TBD: Modify Smart Battery Description to comply with ACPI IA64
+ * extensions.
+ */
+typedef struct smart_battery_description_table
+{
+ ACPI_TABLE_HEADER Header;
+ UINT32 WarningLevel;
+ UINT32 LowLevel;
+ UINT32 CriticalLevel;
+
+} SMART_BATTERY_DESCRIPTION_TABLE;
+
+
+#pragma pack()
+
+
+/*
+ * ACPI Table information. We save the table address, length,
+ * and type of memory allocation (mapped or allocated) for each
+ * table for 1) when we exit, and 2) if a new table is installed
+ */
+#define ACPI_MEM_NOT_ALLOCATED 0
+#define ACPI_MEM_ALLOCATED 1
+#define ACPI_MEM_MAPPED 2
+
+/* Definitions for the Flags bitfield member of ACPI_TABLE_SUPPORT */
+
+#define ACPI_TABLE_SINGLE 0x00
+#define ACPI_TABLE_MULTIPLE 0x01
+#define ACPI_TABLE_EXECUTABLE 0x02
+
+#define ACPI_TABLE_ROOT 0x00
+#define ACPI_TABLE_PRIMARY 0x10
+#define ACPI_TABLE_SECONDARY 0x20
+#define ACPI_TABLE_ALL 0x30
+#define ACPI_TABLE_TYPE_MASK 0x30
+
+/* Data about each known table type */
+
+typedef struct acpi_table_support
+{
+ char *Name;
+ char *Signature;
+ void **GlobalPtr;
+ UINT8 SigLength;
+ UINT8 Flags;
+
+} ACPI_TABLE_SUPPORT;
+
+
+/*
+ * Get the architecture-specific tables
+ */
+#include "actbl1.h" /* Acpi 1.0 table definitions */
+#include "actbl2.h" /* Acpi 2.0 table definitions */
+
+#endif /* __ACTBL_H__ */
diff --git a/sys/contrib/dev/acpica/actbl1.h b/sys/contrib/dev/acpica/actbl1.h
new file mode 100644
index 0000000..5b931a3
--- /dev/null
+++ b/sys/contrib/dev/acpica/actbl1.h
@@ -0,0 +1,211 @@
+/******************************************************************************
+ *
+ * Name: actbl1.h - ACPI 1.0 tables
+ * $Revision: 26 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACTBL1_H__
+#define __ACTBL1_H__
+
+#pragma pack(1)
+
+/*
+ * ACPI 1.0 Root System Description Table (RSDT)
+ */
+typedef struct rsdt_descriptor_rev1
+{
+ ACPI_TABLE_HEADER Header; /* ACPI Table header */
+ UINT32 TableOffsetEntry [1]; /* Array of pointers to other */
+ /* ACPI tables */
+} RSDT_DESCRIPTOR_REV1;
+
+
+/*
+ * ACPI 1.0 Firmware ACPI Control Structure (FACS)
+ */
+typedef struct facs_descriptor_rev1
+{
+ char Signature[4]; /* ACPI Signature */
+ UINT32 Length; /* Length of structure, in bytes */
+ UINT32 HardwareSignature; /* Hardware configuration signature */
+ UINT32 FirmwareWakingVector; /* ACPI OS waking vector */
+ UINT32 GlobalLock; /* Global Lock */
+ UINT32_BIT S4Bios_f : 1; /* Indicates if S4BIOS support is present */
+ UINT32_BIT Reserved1 : 31; /* Must be 0 */
+ UINT8 Resverved3 [40]; /* Reserved - must be zero */
+
+} FACS_DESCRIPTOR_REV1;
+
+
+/*
+ * ACPI 1.0 Fixed ACPI Description Table (FADT)
+ */
+typedef struct fadt_descriptor_rev1
+{
+ ACPI_TABLE_HEADER Header; /* ACPI Table header */
+ UINT32 FirmwareCtrl; /* Physical address of FACS */
+ UINT32 Dsdt; /* Physical address of DSDT */
+ UINT8 Model; /* System Interrupt Model */
+ UINT8 Reserved1; /* Reserved */
+ UINT16 SciInt; /* System vector of SCI interrupt */
+ UINT32 SmiCmd; /* Port address of SMI command port */
+ UINT8 AcpiEnable; /* Value to write to smi_cmd to enable ACPI */
+ UINT8 AcpiDisable; /* Value to write to smi_cmd to disable ACPI */
+ UINT8 S4BiosReq; /* Value to write to SMI CMD to enter S4BIOS state */
+ UINT8 Reserved2; /* Reserved - must be zero */
+ UINT32 Pm1aEvtBlk; /* Port address of Power Mgt 1a AcpiEvent Reg Blk */
+ UINT32 Pm1bEvtBlk; /* Port address of Power Mgt 1b AcpiEvent Reg Blk */
+ UINT32 Pm1aCntBlk; /* Port address of Power Mgt 1a Control Reg Blk */
+ UINT32 Pm1bCntBlk; /* Port address of Power Mgt 1b Control Reg Blk */
+ UINT32 Pm2CntBlk; /* Port address of Power Mgt 2 Control Reg Blk */
+ UINT32 PmTmrBlk; /* Port address of Power Mgt Timer Ctrl Reg Blk */
+ UINT32 Gpe0Blk; /* Port addr of General Purpose AcpiEvent 0 Reg Blk */
+ UINT32 Gpe1Blk; /* Port addr of General Purpose AcpiEvent 1 Reg Blk */
+ UINT8 Pm1EvtLen; /* Byte Length of ports at pm1X_evt_blk */
+ UINT8 Pm1CntLen; /* Byte Length of ports at pm1X_cnt_blk */
+ UINT8 Pm2CntLen; /* Byte Length of ports at pm2_cnt_blk */
+ UINT8 PmTmLen; /* Byte Length of ports at pm_tm_blk */
+ UINT8 Gpe0BlkLen; /* Byte Length of ports at gpe0_blk */
+ UINT8 Gpe1BlkLen; /* Byte Length of ports at gpe1_blk */
+ UINT8 Gpe1Base; /* Offset in gpe model where gpe1 events start */
+ UINT8 Reserved3; /* Reserved */
+ UINT16 Plvl2Lat; /* Worst case HW latency to enter/exit C2 state */
+ UINT16 Plvl3Lat; /* Worst case HW latency to enter/exit C3 state */
+ UINT16 FlushSize; /* Size of area read to flush caches */
+ UINT16 FlushStride; /* Stride used in flushing caches */
+ UINT8 DutyOffset; /* Bit location of duty cycle field in p_cnt reg */
+ UINT8 DutyWidth; /* Bit width of duty cycle field in p_cnt reg */
+ UINT8 DayAlrm; /* Index to day-of-month alarm in RTC CMOS RAM */
+ UINT8 MonAlrm; /* Index to month-of-year alarm in RTC CMOS RAM */
+ UINT8 Century; /* Index to century in RTC CMOS RAM */
+ UINT8 Reserved4; /* Reserved */
+ UINT8 Reserved4a; /* Reserved */
+ UINT8 Reserved4b; /* Reserved */
+ UINT32_BIT WbInvd : 1; /* The wbinvd instruction works properly */
+ UINT32_BIT WbInvdFlush : 1; /* The wbinvd flushes but does not invalidate */
+ UINT32_BIT ProcC1 : 1; /* All processors support C1 state */
+ UINT32_BIT Plvl2Up : 1; /* C2 state works on MP system */
+ UINT32_BIT PwrButton : 1; /* Power button is handled as a generic feature */
+ UINT32_BIT SleepButton : 1; /* Sleep button is handled as a generic feature, or not present */
+ UINT32_BIT FixedRTC : 1; /* RTC wakeup stat not in fixed register space */
+ UINT32_BIT Rtcs4 : 1; /* RTC wakeup stat not possible from S4 */
+ UINT32_BIT TmrValExt : 1; /* The tmr_val width is 32 bits (0 = 24 bits) */
+ UINT32_BIT Reserved5 : 23; /* Reserved - must be zero */
+
+} FADT_DESCRIPTOR_REV1;
+
+#pragma pack()
+
+#endif /* __ACTBL1_H__ */
+
+
diff --git a/sys/contrib/dev/acpica/actbl2.h b/sys/contrib/dev/acpica/actbl2.h
new file mode 100644
index 0000000..a683645
--- /dev/null
+++ b/sys/contrib/dev/acpica/actbl2.h
@@ -0,0 +1,277 @@
+/******************************************************************************
+ *
+ * Name: actbl2.h - ACPI Specification Revision 2.0 Tables
+ * $Revision: 32 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __ACTBL2_H__
+#define __ACTBL2_H__
+
+/*
+ * Prefered Power Management Profiles
+ */
+#define PM_UNSPECIFIED 0
+#define PM_DESKTOP 1
+#define PM_MOBILE 2
+#define PM_WORKSTATION 3
+#define PM_ENTERPRISE_SERVER 4
+#define PM_SOHO_SERVER 5
+#define PM_APPLIANCE_PC 6
+
+/*
+ * ACPI Boot Arch Flags
+ */
+#define BAF_LEGACY_DEVICES 0x0001
+#define BAF_8042_KEYBOARD_CONTROLLER 0x0002
+
+#define FADT2_REVISION_ID 3
+
+
+#pragma pack(1)
+
+/*
+ * ACPI 2.0 Root System Description Table (RSDT)
+ */
+typedef struct rsdt_descriptor_rev2
+{
+ ACPI_TABLE_HEADER Header; /* ACPI table header */
+ UINT32 TableOffsetEntry [1]; /* Array of pointers to */
+ /* ACPI table headers */
+} RSDT_DESCRIPTOR_REV2;
+
+
+/*
+ * ACPI 2.0 Extended System Description Table (XSDT)
+ */
+typedef struct xsdt_descriptor_rev2
+{
+ ACPI_TABLE_HEADER Header; /* ACPI table header */
+ UINT64 TableOffsetEntry [1]; /* Array of pointers to */
+ /* ACPI table headers */
+} XSDT_DESCRIPTOR_REV2;
+
+
+/*
+ * ACPI 2.0 Firmware ACPI Control Structure (FACS)
+ */
+typedef struct facs_descriptor_rev2
+{
+ char Signature[4]; /* ACPI signature */
+ UINT32 Length; /* Length of structure, in bytes */
+ UINT32 HardwareSignature; /* Hardware configuration signature */
+ UINT32 FirmwareWakingVector; /* 32bit physical address of the Firmware Waking Vector. */
+ UINT32 GlobalLock; /* Global Lock used to synchronize access to shared hardware resources */
+ UINT32 S4Bios_f : 1; /* S4Bios_f - Indicates if S4BIOS support is present */
+ UINT32_BIT Reserved1 : 31; /* Must be 0 */
+ UINT64 XFirmwareWakingVector; /* 64bit physical address of the Firmware Waking Vector. */
+ UINT8 Version; /* Version of this table */
+ UINT8 Reserved3 [31]; /* Reserved - must be zero */
+
+} FACS_DESCRIPTOR_REV2;
+
+
+/*
+ * ACPI 2.0 Generic Address Structure (GAS)
+ */
+typedef struct acpi_generic_address
+{
+ UINT8 AddressSpaceId; /* Address space where struct or register exists. */
+ UINT8 RegisterBitWidth; /* Size in bits of given register */
+ UINT8 RegisterBitOffset; /* Bit offset within the register */
+ UINT8 Reserved; /* Must be 0 */
+ UINT64 Address; /* 64-bit address of struct or register */
+
+} ACPI_GENERIC_ADDRESS;
+
+
+/*
+ * ACPI 2.0 Fixed ACPI Description Table (FADT)
+ */
+typedef struct fadt_descriptor_rev2
+{
+ ACPI_TABLE_HEADER Header; /* ACPI table header */
+ UINT32 V1_FirmwareCtrl; /* 32-bit physical address of FACS */
+ UINT32 V1_Dsdt; /* 32-bit physical address of DSDT */
+ UINT8 Reserved1; /* System Interrupt Model isn't used in ACPI 2.0*/
+ UINT8 Prefer_PM_Profile; /* Conveys preferred power management profile to OSPM. */
+ UINT16 SciInt; /* System vector of SCI interrupt */
+ UINT32 SmiCmd; /* Port address of SMI command port */
+ UINT8 AcpiEnable; /* Value to write to smi_cmd to enable ACPI */
+ UINT8 AcpiDisable; /* Value to write to smi_cmd to disable ACPI */
+ UINT8 S4BiosReq; /* Value to write to SMI CMD to enter S4BIOS state */
+ UINT8 PstateCnt; /* Processor performance state control*/
+ UINT32 V1_Pm1aEvtBlk; /* Port address of Power Mgt 1a AcpiEvent Reg Blk */
+ UINT32 V1_Pm1bEvtBlk; /* Port address of Power Mgt 1b AcpiEvent Reg Blk */
+ UINT32 V1_Pm1aCntBlk; /* Port address of Power Mgt 1a Control Reg Blk */
+ UINT32 V1_Pm1bCntBlk; /* Port address of Power Mgt 1b Control Reg Blk */
+ UINT32 V1_Pm2CntBlk; /* Port address of Power Mgt 2 Control Reg Blk */
+ UINT32 V1_PmTmrBlk; /* Port address of Power Mgt Timer Ctrl Reg Blk */
+ UINT32 V1_Gpe0Blk; /* Port addr of General Purpose AcpiEvent 0 Reg Blk */
+ UINT32 V1_Gpe1Blk; /* Port addr of General Purpose AcpiEvent 1 Reg Blk */
+ UINT8 Pm1EvtLen; /* Byte Length of ports at pm1X_evt_blk */
+ UINT8 Pm1CntLen; /* Byte Length of ports at pm1X_cnt_blk */
+ UINT8 Pm2CntLen; /* Byte Length of ports at pm2_cnt_blk */
+ UINT8 PmTmLen; /* Byte Length of ports at pm_tm_blk */
+ UINT8 Gpe0BlkLen; /* Byte Length of ports at gpe0_blk */
+ UINT8 Gpe1BlkLen; /* Byte Length of ports at gpe1_blk */
+ UINT8 Gpe1Base; /* Offset in gpe model where gpe1 events start */
+ UINT8 CstCnt; /* Support for the _CST object and C States change notification.*/
+ UINT16 Plvl2Lat; /* Worst case HW latency to enter/exit C2 state */
+ UINT16 Plvl3Lat; /* Worst case HW latency to enter/exit C3 state */
+ UINT16 FlushSize; /* Number of flush strides that need to be read */
+ UINT16 FlushStride; /* Processor's memory cache line width, in bytes */
+ UINT8 DutyOffset; /* Processor's duty cycle index in processor's P_CNT reg*/
+ UINT8 DutyWidth; /* Processor's duty cycle value bit width in P_CNT register.*/
+ UINT8 DayAlrm; /* Index to day-of-month alarm in RTC CMOS RAM */
+ UINT8 MonAlrm; /* Index to month-of-year alarm in RTC CMOS RAM */
+ UINT8 Century; /* Index to century in RTC CMOS RAM */
+ UINT16 IapcBootArch; /* IA-PC Boot Architecture Flags. See Table 5-10 for description*/
+ UINT8 Reserved2; /* Reserved */
+ UINT32_BIT WbInvd : 1; /* The wbinvd instruction works properly */
+ UINT32_BIT WbInvdFlush : 1; /* The wbinvd flushes but does not invalidate */
+ UINT32_BIT ProcC1 : 1; /* All processors support C1 state */
+ UINT32_BIT Plvl2Up : 1; /* C2 state works on MP system */
+ UINT32_BIT PwrButton : 1; /* Power button is handled as a generic feature */
+ UINT32_BIT SleepButton : 1; /* Sleep button is handled as a generic feature, or not present */
+ UINT32_BIT FixedRTC : 1; /* RTC wakeup stat not in fixed register space */
+ UINT32_BIT Rtcs4 : 1; /* RTC wakeup stat not possible from S4 */
+ UINT32_BIT TmrValExt : 1; /* Indicates tmr_val is 32 bits 0=24-bits*/
+ UINT32_BIT DockCap : 1; /* Supports Docking */
+ UINT32_BIT ResetRegSup : 1; /* Indicates system supports system reset via the FADT RESET_REG*/
+ UINT32_BIT SealedCase : 1; /* Indicates system has no internal expansion capabilities and case is sealed. */
+ UINT32_BIT Headless : 1; /* Indicates system does not have local video capabilities or local input devices.*/
+ UINT32_BIT CpuSwSleep : 1; /* Indicates to OSPM that a processor native instruction */
+ /* Must be executed after writing the SLP_TYPx register. */
+ UINT32_BIT Reserved6 : 18; /* Reserved - must be zero */
+
+ ACPI_GENERIC_ADDRESS ResetRegister; /* Reset register address in GAS format */
+ UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system. */
+ UINT8 Reserved7[3]; /* These three bytes must be zero */
+ UINT64 XFirmwareCtrl; /* 64-bit physical address of FACS */
+ UINT64 XDsdt; /* 64-bit physical address of DSDT */
+ ACPI_GENERIC_ADDRESS XPm1aEvtBlk; /* Extended Power Mgt 1a AcpiEvent Reg Blk address */
+ ACPI_GENERIC_ADDRESS XPm1bEvtBlk; /* Extended Power Mgt 1b AcpiEvent Reg Blk address */
+ ACPI_GENERIC_ADDRESS XPm1aCntBlk; /* Extended Power Mgt 1a Control Reg Blk address */
+ ACPI_GENERIC_ADDRESS XPm1bCntBlk; /* Extended Power Mgt 1b Control Reg Blk address */
+ ACPI_GENERIC_ADDRESS XPm2CntBlk; /* Extended Power Mgt 2 Control Reg Blk address */
+ ACPI_GENERIC_ADDRESS XPmTmrBlk; /* Extended Power Mgt Timer Ctrl Reg Blk address */
+ ACPI_GENERIC_ADDRESS XGpe0Blk; /* Extended General Purpose AcpiEvent 0 Reg Blk address */
+ ACPI_GENERIC_ADDRESS XGpe1Blk; /* Extended General Purpose AcpiEvent 1 Reg Blk address */
+
+} FADT_DESCRIPTOR_REV2;
+
+
+#pragma pack()
+
+#endif /* __ACTBL2_H__ */
+
diff --git a/sys/contrib/dev/acpica/actbl71.h b/sys/contrib/dev/acpica/actbl71.h
new file mode 100644
index 0000000..6a84009
--- /dev/null
+++ b/sys/contrib/dev/acpica/actbl71.h
@@ -0,0 +1,238 @@
+/******************************************************************************
+ *
+ * Name: actbl71.h - IA-64 Extensions to the ACPI Spec Rev. 0.71
+ * This file includes tables specific to this
+ * specification revision.
+ * $Revision: 12 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 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 __ACTBL71_H__
+#define __ACTBL71_H__
+
+
+/* 0.71 FADT AddressSpace data item bitmasks defines */
+/* If the associated bit is zero then it is in memory space else in io space */
+
+#define SMI_CMD_ADDRESS_SPACE 0x01
+#define PM1_BLK_ADDRESS_SPACE 0x02
+#define PM2_CNT_BLK_ADDRESS_SPACE 0x04
+#define PM_TMR_BLK_ADDRESS_SPACE 0x08
+#define GPE0_BLK_ADDRESS_SPACE 0x10
+#define GPE1_BLK_ADDRESS_SPACE 0x20
+
+/* Only for clarity in declarations */
+
+typedef UINT64 IO_ADDRESS;
+
+
+#pragma pack(1)
+typedef struct /* Root System Descriptor Pointer */
+{
+ NATIVE_CHAR Signature [8]; /* contains "RSD PTR " */
+ UINT8 Checksum; /* to make sum of struct == 0 */
+ NATIVE_CHAR OemId [6]; /* OEM identification */
+ UINT8 Reserved; /* Must be 0 for 1.0, 2 for 2.0 */
+ UINT64 RsdtPhysicalAddress; /* 64-bit physical address of RSDT */
+} RSDP_DESCRIPTOR_REV071;
+
+
+/*****************************************/
+/* IA64 Extensions to ACPI Spec Rev 0.71 */
+/* for the Root System Description Table */
+/*****************************************/
+typedef struct
+{
+ ACPI_TABLE_HEADER header; /* Table header */
+ UINT32 ReservedPad; /* IA64 alignment, must be 0 */
+ UINT64 TableOffsetEntry [1]; /* Array of pointers to other */
+ /* tables' headers */
+} RSDT_DESCRIPTOR_REV071;
+
+
+/*******************************************/
+/* IA64 Extensions to ACPI Spec Rev 0.71 */
+/* for the Firmware ACPI Control Structure */
+/*******************************************/
+typedef struct
+{
+ NATIVE_CHAR Signature[4]; /* signature "FACS" */
+ UINT32 Length; /* length of structure, in bytes */
+ UINT32 HardwareSignature; /* hardware configuration signature */
+ UINT32 Reserved4; /* must be 0 */
+ UINT64 FirmwareWakingVector; /* ACPI OS waking vector */
+ UINT64 GlobalLock; /* Global Lock */
+ UINT32_BIT S4Bios_f : 1; /* Indicates if S4BIOS support is present */
+ UINT32_BIT Reserved1 : 31; /* must be 0 */
+ UINT8 Reserved3 [28]; /* reserved - must be zero */
+
+} FACS_DESCRIPTOR_REV071;
+
+
+/******************************************/
+/* IA64 Extensions to ACPI Spec Rev 0.71 */
+/* for the Fixed ACPI Description Table */
+/******************************************/
+typedef struct
+{
+ ACPI_TABLE_HEADER header; /* table header */
+ UINT32 ReservedPad; /* IA64 alignment, must be 0 */
+ UINT64 FirmwareCtrl; /* 64-bit Physical address of FACS */
+ UINT64 Dsdt; /* 64-bit Physical address of DSDT */
+ UINT8 Model; /* System Interrupt Model */
+ UINT8 AddressSpace; /* Address Space Bitmask */
+ UINT16 SciInt; /* System vector of SCI interrupt */
+ UINT8 AcpiEnable; /* value to write to smi_cmd to enable ACPI */
+ UINT8 AcpiDisable; /* value to write to smi_cmd to disable ACPI */
+ UINT8 S4BiosReq; /* Value to write to SMI CMD to enter S4BIOS state */
+ UINT8 Reserved2; /* reserved - must be zero */
+ UINT64 SmiCmd; /* Port address of SMI command port */
+ UINT64 Pm1aEvtBlk; /* Port address of Power Mgt 1a AcpiEvent Reg Blk */
+ UINT64 Pm1bEvtBlk; /* Port address of Power Mgt 1b AcpiEvent Reg Blk */
+ UINT64 Pm1aCntBlk; /* Port address of Power Mgt 1a Control Reg Blk */
+ UINT64 Pm1bCntBlk; /* Port address of Power Mgt 1b Control Reg Blk */
+ UINT64 Pm2CntBlk; /* Port address of Power Mgt 2 Control Reg Blk */
+ UINT64 PmTmrBlk; /* Port address of Power Mgt Timer Ctrl Reg Blk */
+ UINT64 Gpe0Blk; /* Port addr of General Purpose AcpiEvent 0 Reg Blk */
+ UINT64 Gpe1Blk; /* Port addr of General Purpose AcpiEvent 1 Reg Blk */
+ UINT8 Pm1EvtLen; /* Byte Length of ports at pm1X_evt_blk */
+ UINT8 Pm1CntLen; /* Byte Length of ports at pm1X_cnt_blk */
+ UINT8 Pm2CntLen; /* Byte Length of ports at pm2_cnt_blk */
+ UINT8 PmTmLen; /* Byte Length of ports at pm_tm_blk */
+ UINT8 Gpe0BlkLen; /* Byte Length of ports at gpe0_blk */
+ UINT8 Gpe1BlkLen; /* Byte Length of ports at gpe1_blk */
+ UINT8 Gpe1Base; /* offset in gpe model where gpe1 events start */
+ UINT8 Reserved3; /* reserved */
+ UINT16 Plvl2Lat; /* worst case HW latency to enter/exit C2 state */
+ UINT16 Plvl3Lat; /* worst case HW latency to enter/exit C3 state */
+ UINT8 DayAlrm; /* index to day-of-month alarm in RTC CMOS RAM */
+ UINT8 MonAlrm; /* index to month-of-year alarm in RTC CMOS RAM */
+ UINT8 Century; /* index to century in RTC CMOS RAM */
+ UINT8 Reserved4; /* reserved */
+ UINT32_BIT FlushCash : 1; /* PAL_FLUSH_CACHE is correctly supported */
+ UINT32_BIT Reserved5 : 1; /* reserved - must be zero */
+ UINT32_BIT ProcC1 : 1; /* all processors support C1 state */
+ UINT32_BIT Plvl2Up : 1; /* C2 state works on MP system */
+ UINT32_BIT PwrButton : 1; /* Power button is handled as a generic feature */
+ UINT32_BIT SleepButton : 1; /* Sleep button is handled as a generic feature, or not present */
+ UINT32_BIT FixedRTC : 1; /* RTC wakeup stat not in fixed register space */
+ UINT32_BIT Rtcs4 : 1; /* RTC wakeup stat not possible from S4 */
+ UINT32_BIT TmrValExt : 1; /* tmr_val is 32 bits */
+ UINT32_BIT DockCap : 1; /* Supports Docking */
+ UINT32_BIT Reserved6 : 22; /* reserved - must be zero */
+
+} FADT_DESCRIPTOR_REV071;
+
+#pragma pack()
+
+#endif /* __ACTBL71_H__ */
+
diff --git a/sys/contrib/dev/acpica/actypes.h b/sys/contrib/dev/acpica/actypes.h
new file mode 100644
index 0000000..0b19399
--- /dev/null
+++ b/sys/contrib/dev/acpica/actypes.h
@@ -0,0 +1,1320 @@
+/******************************************************************************
+ *
+ * Name: actypes.h - Common data types for the entire ACPI subsystem
+ * $Revision: 253 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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
+
+
+#ifdef DEFINE_ALTERNATE_TYPES
+/*
+ * Types used only in translated source, defined here to enable
+ * cross-platform compilation only.
+ */
+typedef int s32;
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned int u32;
+typedef COMPILER_DEPENDENT_UINT64 u64;
+
+#endif
+
+
+/*
+ * 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
+ * ACPI_NATIVE_INT 32-bit on IA-32, 64-bit on IA-64 signed value
+ * ACPI_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
+
+/*! [Begin] no source code translation (keep the typedefs) */
+
+/*
+ * 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;
+
+/*! [End] no source code translation !*/
+
+typedef INT64 ACPI_NATIVE_INT;
+typedef UINT64 ACPI_NATIVE_UINT;
+
+typedef UINT64 ACPI_TABLE_PTR;
+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
+
+/*! [Begin] no source code translation (keep the typedefs) */
+
+/*
+ * 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;
+
+/*! [End] no source code translation !*/
+
+typedef UINT16 ACPI_NATIVE_UINT;
+typedef INT16 ACPI_NATIVE_INT;
+
+typedef UINT32 ACPI_TABLE_PTR;
+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
+
+/*! [Begin] no source code translation (keep the typedefs) */
+
+/*
+ * 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;
+
+/*! [End] no source code translation !*/
+
+typedef INT32 ACPI_NATIVE_INT;
+typedef UINT32 ACPI_NATIVE_UINT;
+
+typedef UINT64 ACPI_TABLE_PTR;
+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 ACPI_NATIVE_UINT ACPI_PTRDIFF;
+
+/*
+ * Pointer overlays to avoid lots of typecasting for
+ * code that accepts both physical and logical pointers.
+ */
+typedef union acpi_pointers
+{
+ ACPI_PHYSICAL_ADDRESS Physical;
+ void *Logical;
+ ACPI_TABLE_PTR Value;
+
+} ACPI_POINTERS;
+
+typedef struct acpi_pointer
+{
+ UINT32 PointerType;
+ union acpi_pointers 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 uint64_struct
+{
+ UINT32 Lo;
+ UINT32 Hi;
+
+} UINT64_STRUCT;
+
+typedef union uint64_overlay
+{
+ UINT64 Full;
+ UINT64_STRUCT Part;
+
+} UINT64_OVERLAY;
+
+typedef struct uint32_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 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 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_EXTERNAL_MAX 0x10
+
+/*
+ * 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 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 */
+
+/*
+ * 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 ACPI_TYPE_LOCAL_MAX 0x1C
+
+/* All types above here are invalid */
+
+#define ACPI_TYPE_INVALID 0x1D
+#define ACPI_TYPE_NOT_FOUND 0xFF
+
+
+/*
+ * 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?
+ * +----------- <Reserved>
+ */
+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
+
+
+/* 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
+#define ACPI_ADR_SPACE_FIXED_HARDWARE (ACPI_ADR_SPACE_TYPE) 127
+
+
+/*
+ * 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 acpi_object
+{
+ 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 */
+ 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 acpi_object *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 acpi_object_list
+{
+ 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_buffer
+{
+ 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 acpi_table_info
+{
+ UINT32 Count;
+
+} ACPI_TABLE_INFO;
+
+
+/*
+ * System info returned by AcpiGetSystemInfo()
+ */
+typedef struct acpi_system_info
+{
+ 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_obj_info_header
+{
+ ACPI_COMMON_OBJ_INFO;
+
+} ACPI_OBJ_INFO_HEADER;
+
+
+typedef struct acpi_device_info
+{
+ ACPI_COMMON_OBJ_INFO;
+
+ UINT32 Valid; /* Are the next bits legit? */
+ char HardwareId[9]; /* _HID value if any */
+ 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 acpi_pci_id
+{
+ UINT16 Segment;
+ UINT16 Bus;
+ UINT16 Device;
+ UINT16 Function;
+
+} ACPI_PCI_ID;
+
+
+typedef struct acpi_mem_space_context
+{
+ UINT32 Length;
+ ACPI_PHYSICAL_ADDRESS Address;
+ ACPI_PHYSICAL_ADDRESS MappedPhysicalAddress;
+ UINT8 *MappedLogicalAddress;
+ ACPI_SIZE MappedLength;
+
+} ACPI_MEM_SPACE_CONTEXT;
+
+
+/*
+ * 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)
+
+#define ACPI_SPARSE_TRANSLATION (UINT8) 0x03
+
+/*
+ * 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 acpi_resource_irq
+{
+ UINT32 EdgeLevel;
+ UINT32 ActiveHighLow;
+ UINT32 SharedExclusive;
+ UINT32 NumberOfInterrupts;
+ UINT32 Interrupts[1];
+
+} ACPI_RESOURCE_IRQ;
+
+typedef struct ACPI_RESOURCE_DMA
+{
+ UINT32 Type;
+ UINT32 BusMaster;
+ UINT32 Transfer;
+ UINT32 NumberOfChannels;
+ UINT32 Channels[1];
+
+} ACPI_RESOURCE_DMA;
+
+typedef struct acpi_resource_start_dpf
+{
+ UINT32 CompatibilityPriority;
+ UINT32 PerformanceRobustness;
+
+} ACPI_RESOURCE_START_DPF;
+
+/*
+ * END_DEPENDENT_FUNCTIONS_RESOURCE struct is not
+ * needed because it has no fields
+ */
+
+typedef struct acpi_resource_io
+{
+ UINT32 IoDecode;
+ UINT32 MinBaseAddress;
+ UINT32 MaxBaseAddress;
+ UINT32 Alignment;
+ UINT32 RangeLength;
+
+} ACPI_RESOURCE_IO;
+
+typedef struct acpi_resource_fixed_io
+{
+ UINT32 BaseAddress;
+ UINT32 RangeLength;
+
+} ACPI_RESOURCE_FIXED_IO;
+
+typedef struct acpi_resource_vendor
+{
+ UINT32 Length;
+ UINT8 Reserved[1];
+
+} ACPI_RESOURCE_VENDOR;
+
+typedef struct acpi_resource_end_tag
+{
+ UINT8 Checksum;
+
+} ACPI_RESOURCE_END_TAG;
+
+typedef struct acpi_resource_mem24
+{
+ UINT32 ReadWriteAttribute;
+ UINT32 MinBaseAddress;
+ UINT32 MaxBaseAddress;
+ UINT32 Alignment;
+ UINT32 RangeLength;
+
+} ACPI_RESOURCE_MEM24;
+
+typedef struct acpi_resource_mem32
+{
+ UINT32 ReadWriteAttribute;
+ UINT32 MinBaseAddress;
+ UINT32 MaxBaseAddress;
+ UINT32 Alignment;
+ UINT32 RangeLength;
+
+} ACPI_RESOURCE_MEM32;
+
+typedef struct acpi_resource_fixed_mem32
+{
+ UINT32 ReadWriteAttribute;
+ UINT32 RangeBaseAddress;
+ UINT32 RangeLength;
+
+} ACPI_RESOURCE_FIXED_MEM32;
+
+typedef struct acpi_memory_attribute
+{
+ UINT16 CacheAttribute;
+ UINT16 ReadWriteAttribute;
+
+} ACPI_MEMORY_ATTRIBUTE;
+
+typedef struct acpi_io_attribute
+{
+ UINT16 RangeAttribute;
+ UINT16 TranslationAttribute;
+
+} ACPI_IO_ATTRIBUTE;
+
+typedef struct acpi_bus_attribute
+{
+ UINT16 Reserved1;
+ UINT16 Reserved2;
+
+} ACPI_BUS_ATTRIBUTE;
+
+typedef union acpi_resource_attribute
+{
+ ACPI_MEMORY_ATTRIBUTE Memory;
+ ACPI_IO_ATTRIBUTE Io;
+ ACPI_BUS_ATTRIBUTE Bus;
+
+} ACPI_RESOURCE_ATTRIBUTE;
+
+typedef struct acpi_resource_source
+{
+ UINT32 Index;
+ UINT32 StringLength;
+ char *StringPtr;
+
+} ACPI_RESOURCE_SOURCE;
+
+typedef struct acpi_resource_address16
+{
+ UINT32 ResourceType;
+ UINT32 ProducerConsumer;
+ UINT32 Decode;
+ UINT32 MinAddressFixed;
+ UINT32 MaxAddressFixed;
+ ACPI_RESOURCE_ATTRIBUTE Attribute;
+ UINT32 Granularity;
+ UINT32 MinAddressRange;
+ UINT32 MaxAddressRange;
+ UINT32 AddressTranslationOffset;
+ UINT32 AddressLength;
+ ACPI_RESOURCE_SOURCE ResourceSource;
+
+} ACPI_RESOURCE_ADDRESS16;
+
+typedef struct acpi_resource_address32
+{
+ 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 acpi_resource_address64
+{
+ 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 acpi_resource_ext_irq
+{
+ 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_data
+{
+ ACPI_RESOURCE_IRQ Irq;
+ ACPI_RESOURCE_DMA Dma;
+ ACPI_RESOURCE_START_DPF StartDpf;
+ ACPI_RESOURCE_IO Io;
+ ACPI_RESOURCE_FIXED_IO FixedIo;
+ ACPI_RESOURCE_VENDOR VendorSpecific;
+ ACPI_RESOURCE_END_TAG EndTag;
+ ACPI_RESOURCE_MEM24 Memory24;
+ ACPI_RESOURCE_MEM32 Memory32;
+ ACPI_RESOURCE_FIXED_MEM32 FixedMemory32;
+ ACPI_RESOURCE_ADDRESS16 Address16;
+ ACPI_RESOURCE_ADDRESS32 Address32;
+ ACPI_RESOURCE_ADDRESS64 Address64;
+ ACPI_RESOURCE_EXT_IRQ ExtendedIrq;
+
+} ACPI_RESOURCE_DATA;
+
+typedef struct acpi_resource
+{
+ 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;
+ 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/acutils.h b/sys/contrib/dev/acpica/acutils.h
new file mode 100644
index 0000000..31826e2
--- /dev/null
+++ b/sys/contrib/dev/acpica/acutils.h
@@ -0,0 +1,910 @@
+/******************************************************************************
+ *
+ * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures
+ * $Revision: 154 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 _ACUTILS_H
+#define _ACUTILS_H
+
+
+typedef
+ACPI_STATUS (*ACPI_PKG_CALLBACK) (
+ UINT8 ObjectType,
+ ACPI_OPERAND_OBJECT *SourceObject,
+ ACPI_GENERIC_STATE *State,
+ void *Context);
+
+
+ACPI_STATUS
+AcpiUtWalkPackageTree (
+ ACPI_OPERAND_OBJECT *SourceObject,
+ void *TargetObject,
+ ACPI_PKG_CALLBACK WalkCallback,
+ void *Context);
+
+
+typedef struct acpi_pkg_info
+{
+ UINT8 *FreeSpace;
+ ACPI_SIZE Length;
+ UINT32 ObjectSpace;
+ UINT32 NumPackages;
+
+} ACPI_PKG_INFO;
+
+#define REF_INCREMENT (UINT16) 0
+#define REF_DECREMENT (UINT16) 1
+#define REF_FORCE_DELETE (UINT16) 2
+
+/* AcpiUtDumpBuffer */
+
+#define DB_BYTE_DISPLAY 1
+#define DB_WORD_DISPLAY 2
+#define DB_DWORD_DISPLAY 4
+#define DB_QWORD_DISPLAY 8
+
+
+/* Global initialization interfaces */
+
+void
+AcpiUtInitGlobals (
+ void);
+
+void
+AcpiUtTerminate (
+ void);
+
+
+/*
+ * UtInit - miscellaneous initialization and shutdown
+ */
+
+ACPI_STATUS
+AcpiUtHardwareInitialize (
+ void);
+
+void
+AcpiUtSubsystemShutdown (
+ void);
+
+ACPI_STATUS
+AcpiUtValidateFadt (
+ void);
+
+/*
+ * UtGlobal - Global data structures and procedures
+ */
+
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+
+char *
+AcpiUtGetMutexName (
+ UINT32 MutexId);
+
+#endif
+
+char *
+AcpiUtGetTypeName (
+ ACPI_OBJECT_TYPE Type);
+
+char *
+AcpiUtGetObjectTypeName (
+ ACPI_OPERAND_OBJECT *ObjDesc);
+
+char *
+AcpiUtGetRegionName (
+ UINT8 SpaceId);
+
+char *
+AcpiUtGetEventName (
+ UINT32 EventId);
+
+char
+AcpiUtHexToAsciiChar (
+ ACPI_INTEGER Integer,
+ UINT32 Position);
+
+BOOLEAN
+AcpiUtValidObjectType (
+ ACPI_OBJECT_TYPE Type);
+
+ACPI_OWNER_ID
+AcpiUtAllocateOwnerId (
+ UINT32 IdType);
+
+
+/*
+ * UtClib - Local implementations of C library functions
+ */
+
+#ifndef ACPI_USE_SYSTEM_CLIBRARY
+
+ACPI_SIZE
+AcpiUtStrlen (
+ const char *String);
+
+char *
+AcpiUtStrcpy (
+ char *DstString,
+ const char *SrcString);
+
+char *
+AcpiUtStrncpy (
+ char *DstString,
+ const char *SrcString,
+ ACPI_SIZE Count);
+
+int
+AcpiUtStrncmp (
+ const char *String1,
+ const char *String2,
+ ACPI_SIZE Count);
+
+int
+AcpiUtStrcmp (
+ const char *String1,
+ const char *String2);
+
+char *
+AcpiUtStrcat (
+ char *DstString,
+ const char *SrcString);
+
+char *
+AcpiUtStrncat (
+ char *DstString,
+ const char *SrcString,
+ ACPI_SIZE Count);
+
+UINT32
+AcpiUtStrtoul (
+ const char *String,
+ char **Terminator,
+ UINT32 Base);
+
+char *
+AcpiUtStrstr (
+ char *String1,
+ char *String2);
+
+void *
+AcpiUtMemcpy (
+ void *Dest,
+ const void *Src,
+ ACPI_SIZE Count);
+
+void *
+AcpiUtMemset (
+ void *Dest,
+ ACPI_NATIVE_UINT Value,
+ ACPI_SIZE Count);
+
+int
+AcpiUtToUpper (
+ int c);
+
+int
+AcpiUtToLower (
+ int c);
+
+extern const UINT8 _acpi_ctype[];
+
+#define _ACPI_XA 0x00 /* extra alphabetic - not supported */
+#define _ACPI_XS 0x40 /* extra space */
+#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */
+#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */
+#define _ACPI_DI 0x04 /* '0'-'9' */
+#define _ACPI_LO 0x02 /* 'a'-'z' */
+#define _ACPI_PU 0x10 /* punctuation */
+#define _ACPI_SP 0x08 /* space */
+#define _ACPI_UP 0x01 /* 'A'-'Z' */
+#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
+
+#define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI))
+#define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP))
+#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
+#define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
+#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
+#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU))
+#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
+#define ACPI_IS_ASCII(c) ((c) < 0x80)
+
+#endif /* ACPI_USE_SYSTEM_CLIBRARY */
+
+/*
+ * UtCopy - Object construction and conversion interfaces
+ */
+
+ACPI_STATUS
+AcpiUtBuildSimpleObject(
+ ACPI_OPERAND_OBJECT *Obj,
+ ACPI_OBJECT *UserObj,
+ UINT8 *DataSpace,
+ UINT32 *BufferSpaceUsed);
+
+ACPI_STATUS
+AcpiUtBuildPackageObject (
+ ACPI_OPERAND_OBJECT *Obj,
+ UINT8 *Buffer,
+ UINT32 *SpaceUsed);
+
+ACPI_STATUS
+AcpiUtCopyIelementToEelement (
+ UINT8 ObjectType,
+ ACPI_OPERAND_OBJECT *SourceObject,
+ ACPI_GENERIC_STATE *State,
+ void *Context);
+
+ACPI_STATUS
+AcpiUtCopyIelementToIelement (
+ UINT8 ObjectType,
+ ACPI_OPERAND_OBJECT *SourceObject,
+ ACPI_GENERIC_STATE *State,
+ void *Context);
+
+ACPI_STATUS
+AcpiUtCopyIobjectToEobject (
+ ACPI_OPERAND_OBJECT *Obj,
+ ACPI_BUFFER *RetBuffer);
+
+ACPI_STATUS
+AcpiUtCopyEsimpleToIsimple(
+ ACPI_OBJECT *UserObj,
+ ACPI_OPERAND_OBJECT **ReturnObj);
+
+ACPI_STATUS
+AcpiUtCopyEobjectToIobject (
+ ACPI_OBJECT *Obj,
+ ACPI_OPERAND_OBJECT **InternalObj);
+
+ACPI_STATUS
+AcpiUtCopyISimpleToIsimple (
+ ACPI_OPERAND_OBJECT *SourceObj,
+ ACPI_OPERAND_OBJECT *DestObj);
+
+ACPI_STATUS
+AcpiUtCopyIpackageToIpackage (
+ ACPI_OPERAND_OBJECT *SourceObj,
+ ACPI_OPERAND_OBJECT *DestObj,
+ ACPI_WALK_STATE *WalkState);
+
+ACPI_STATUS
+AcpiUtCopySimpleObject (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT *DestDesc);
+
+ACPI_STATUS
+AcpiUtCopyIobjectToIobject (
+ ACPI_OPERAND_OBJECT *SourceDesc,
+ ACPI_OPERAND_OBJECT **DestDesc,
+ ACPI_WALK_STATE *WalkState);
+
+
+/*
+ * UtCreate - Object creation
+ */
+
+ACPI_STATUS
+AcpiUtUpdateObjectReference (
+ ACPI_OPERAND_OBJECT *Object,
+ UINT16 Action);
+
+
+/*
+ * UtDebug - Debug interfaces
+ */
+
+void
+AcpiUtInitStackPtrTrace (
+ void);
+
+void
+AcpiUtTrackStackPtr (
+ void);
+
+void
+AcpiUtTrace (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo);
+
+void
+AcpiUtTracePtr (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ void *Pointer);
+
+void
+AcpiUtTraceU32 (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ UINT32 Integer);
+
+void
+AcpiUtTraceStr (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ char *String);
+
+void
+AcpiUtExit (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo);
+
+void
+AcpiUtStatusExit (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ ACPI_STATUS Status);
+
+void
+AcpiUtValueExit (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ ACPI_INTEGER Value);
+
+void
+AcpiUtPtrExit (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ UINT8 *Ptr);
+
+void
+AcpiUtReportInfo (
+ char *ModuleName,
+ UINT32 LineNumber,
+ UINT32 ComponentId);
+
+void
+AcpiUtReportError (
+ char *ModuleName,
+ UINT32 LineNumber,
+ UINT32 ComponentId);
+
+void
+AcpiUtReportWarning (
+ char *ModuleName,
+ UINT32 LineNumber,
+ UINT32 ComponentId);
+
+void
+AcpiUtDumpBuffer (
+ UINT8 *Buffer,
+ UINT32 Count,
+ UINT32 Display,
+ UINT32 componentId);
+
+void ACPI_INTERNAL_VAR_XFACE
+AcpiUtDebugPrint (
+ UINT32 RequestedDebugLevel,
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ char *Format,
+ ...) ACPI_PRINTF_LIKE_FUNC;
+
+void ACPI_INTERNAL_VAR_XFACE
+AcpiUtDebugPrintRaw (
+ UINT32 RequestedDebugLevel,
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ char *Format,
+ ...) ACPI_PRINTF_LIKE_FUNC;
+
+
+/*
+ * UtDelete - Object deletion
+ */
+
+void
+AcpiUtDeleteInternalObj (
+ ACPI_OPERAND_OBJECT *Object);
+
+void
+AcpiUtDeleteInternalPackageObject (
+ ACPI_OPERAND_OBJECT *Object);
+
+void
+AcpiUtDeleteInternalSimpleObject (
+ ACPI_OPERAND_OBJECT *Object);
+
+void
+AcpiUtDeleteInternalObjectList (
+ ACPI_OPERAND_OBJECT **ObjList);
+
+
+/*
+ * UtEval - object evaluation
+ */
+
+/* Method name strings */
+
+#define METHOD_NAME__HID "_HID"
+#define METHOD_NAME__CID "_CID"
+#define METHOD_NAME__UID "_UID"
+#define METHOD_NAME__ADR "_ADR"
+#define METHOD_NAME__STA "_STA"
+#define METHOD_NAME__REG "_REG"
+#define METHOD_NAME__SEG "_SEG"
+#define METHOD_NAME__BBN "_BBN"
+#define METHOD_NAME__PRT "_PRT"
+#define METHOD_NAME__CRS "_CRS"
+#define METHOD_NAME__PRS "_PRS"
+
+
+ACPI_STATUS
+AcpiUtEvaluateObject (
+ ACPI_NAMESPACE_NODE *PrefixNode,
+ char *Path,
+ UINT32 ExpectedReturnBtypes,
+ ACPI_OPERAND_OBJECT **ReturnDesc);
+
+ACPI_STATUS
+AcpiUtEvaluateNumericObject (
+ char *ObjectName,
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ ACPI_INTEGER *Address);
+
+ACPI_STATUS
+AcpiUtExecute_HID (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ ACPI_DEVICE_ID *Hid);
+
+ACPI_STATUS
+AcpiUtExecute_CID (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ ACPI_DEVICE_ID *Cid);
+
+ACPI_STATUS
+AcpiUtExecute_STA (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ UINT32 *StatusFlags);
+
+ACPI_STATUS
+AcpiUtExecute_UID (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ ACPI_DEVICE_ID *Uid);
+
+
+/*
+ * UtMutex - mutual exclusion interfaces
+ */
+
+ACPI_STATUS
+AcpiUtMutexInitialize (
+ void);
+
+void
+AcpiUtMutexTerminate (
+ void);
+
+ACPI_STATUS
+AcpiUtCreateMutex (
+ ACPI_MUTEX_HANDLE MutexId);
+
+ACPI_STATUS
+AcpiUtDeleteMutex (
+ ACPI_MUTEX_HANDLE MutexId);
+
+ACPI_STATUS
+AcpiUtAcquireMutex (
+ ACPI_MUTEX_HANDLE MutexId);
+
+ACPI_STATUS
+AcpiUtReleaseMutex (
+ ACPI_MUTEX_HANDLE MutexId);
+
+
+/*
+ * UtObject - internal object create/delete/cache routines
+ */
+
+ACPI_OPERAND_OBJECT *
+AcpiUtCreateInternalObjectDbg (
+ char *ModuleName,
+ UINT32 LineNumber,
+ UINT32 ComponentId,
+ ACPI_OBJECT_TYPE Type);
+
+void *
+AcpiUtAllocateObjectDescDbg (
+ char *ModuleName,
+ UINT32 LineNumber,
+ UINT32 ComponentId);
+
+#define AcpiUtCreateInternalObject(t) AcpiUtCreateInternalObjectDbg (_THIS_MODULE,__LINE__,_COMPONENT,t)
+#define AcpiUtAllocateObjectDesc() AcpiUtAllocateObjectDescDbg (_THIS_MODULE,__LINE__,_COMPONENT)
+
+void
+AcpiUtDeleteObjectDesc (
+ ACPI_OPERAND_OBJECT *Object);
+
+BOOLEAN
+AcpiUtValidInternalObject (
+ void *Object);
+
+ACPI_OPERAND_OBJECT *
+AcpiUtCreateBufferObject (
+ ACPI_SIZE BufferSize);
+
+
+/*
+ * UtRefCnt - Object reference count management
+ */
+
+void
+AcpiUtAddReference (
+ ACPI_OPERAND_OBJECT *Object);
+
+void
+AcpiUtRemoveReference (
+ ACPI_OPERAND_OBJECT *Object);
+
+/*
+ * UtSize - Object size routines
+ */
+
+ACPI_STATUS
+AcpiUtGetSimpleObjectSize (
+ ACPI_OPERAND_OBJECT *Obj,
+ ACPI_SIZE *ObjLength);
+
+ACPI_STATUS
+AcpiUtGetPackageObjectSize (
+ ACPI_OPERAND_OBJECT *Obj,
+ ACPI_SIZE *ObjLength);
+
+ACPI_STATUS
+AcpiUtGetObjectSize(
+ ACPI_OPERAND_OBJECT *Obj,
+ ACPI_SIZE *ObjLength);
+
+ACPI_STATUS
+AcpiUtGetElementLength (
+ UINT8 ObjectType,
+ ACPI_OPERAND_OBJECT *SourceObject,
+ ACPI_GENERIC_STATE *State,
+ void *Context);
+
+
+/*
+ * UtState - Generic state creation/cache routines
+ */
+
+void
+AcpiUtPushGenericState (
+ ACPI_GENERIC_STATE **ListHead,
+ ACPI_GENERIC_STATE *State);
+
+ACPI_GENERIC_STATE *
+AcpiUtPopGenericState (
+ ACPI_GENERIC_STATE **ListHead);
+
+
+ACPI_GENERIC_STATE *
+AcpiUtCreateGenericState (
+ void);
+
+ACPI_THREAD_STATE *
+AcpiUtCreateThreadState (
+ void);
+
+ACPI_GENERIC_STATE *
+AcpiUtCreateUpdateState (
+ ACPI_OPERAND_OBJECT *Object,
+ UINT16 Action);
+
+ACPI_GENERIC_STATE *
+AcpiUtCreatePkgState (
+ void *InternalObject,
+ void *ExternalObject,
+ UINT16 Index);
+
+ACPI_STATUS
+AcpiUtCreateUpdateStateAndPush (
+ ACPI_OPERAND_OBJECT *Object,
+ UINT16 Action,
+ ACPI_GENERIC_STATE **StateList);
+
+ACPI_STATUS
+AcpiUtCreatePkgStateAndPush (
+ void *InternalObject,
+ void *ExternalObject,
+ UINT16 Index,
+ ACPI_GENERIC_STATE **StateList);
+
+ACPI_GENERIC_STATE *
+AcpiUtCreateControlState (
+ void);
+
+void
+AcpiUtDeleteGenericState (
+ ACPI_GENERIC_STATE *State);
+
+void
+AcpiUtDeleteGenericStateCache (
+ void);
+
+void
+AcpiUtDeleteObjectCache (
+ void);
+
+/*
+ * utmisc
+ */
+
+void
+AcpiUtPrintString (
+ char *String,
+ UINT8 MaxLength);
+
+ACPI_STATUS
+AcpiUtDivide (
+ ACPI_INTEGER *InDividend,
+ ACPI_INTEGER *InDivisor,
+ ACPI_INTEGER *OutQuotient,
+ ACPI_INTEGER *OutRemainder);
+
+ACPI_STATUS
+AcpiUtShortDivide (
+ ACPI_INTEGER *InDividend,
+ UINT32 Divisor,
+ ACPI_INTEGER *OutQuotient,
+ UINT32 *OutRemainder);
+
+BOOLEAN
+AcpiUtValidAcpiName (
+ UINT32 Name);
+
+BOOLEAN
+AcpiUtValidAcpiCharacter (
+ char Character);
+
+ACPI_STATUS
+AcpiUtStrtoul64 (
+ char *String,
+ UINT32 Base,
+ ACPI_INTEGER *RetInteger);
+
+char *
+AcpiUtStrupr (
+ char *SrcString);
+
+UINT8 *
+AcpiUtGetResourceEndTag (
+ ACPI_OPERAND_OBJECT *ObjDesc);
+
+UINT8
+AcpiUtGenerateChecksum (
+ UINT8 *Buffer,
+ UINT32 Length);
+
+UINT32
+AcpiUtDwordByteSwap (
+ UINT32 Value);
+
+void
+AcpiUtSetIntegerWidth (
+ UINT8 Revision);
+
+#ifdef ACPI_DEBUG_OUTPUT
+void
+AcpiUtDisplayInitPathname (
+ UINT8 Type,
+ ACPI_NAMESPACE_NODE *ObjHandle,
+ char *Path);
+
+#endif
+
+
+/*
+ * Utalloc - memory allocation and object caching
+ */
+
+void *
+AcpiUtAcquireFromCache (
+ UINT32 ListId);
+
+void
+AcpiUtReleaseToCache (
+ UINT32 ListId,
+ void *Object);
+
+void
+AcpiUtDeleteGenericCache (
+ UINT32 ListId);
+
+ACPI_STATUS
+AcpiUtValidateBuffer (
+ ACPI_BUFFER *Buffer);
+
+ACPI_STATUS
+AcpiUtInitializeBuffer (
+ ACPI_BUFFER *Buffer,
+ ACPI_SIZE RequiredLength);
+
+
+/* Memory allocation functions */
+
+void *
+AcpiUtAllocate (
+ ACPI_SIZE Size,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line);
+
+void *
+AcpiUtCallocate (
+ ACPI_SIZE Size,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line);
+
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+
+void *
+AcpiUtAllocateAndTrack (
+ ACPI_SIZE Size,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line);
+
+void *
+AcpiUtCallocateAndTrack (
+ ACPI_SIZE Size,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line);
+
+void
+AcpiUtFreeAndTrack (
+ void *Address,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line);
+
+ACPI_DEBUG_MEM_BLOCK *
+AcpiUtFindAllocation (
+ UINT32 ListId,
+ void *Allocation);
+
+ACPI_STATUS
+AcpiUtTrackAllocation (
+ UINT32 ListId,
+ ACPI_DEBUG_MEM_BLOCK *Address,
+ ACPI_SIZE Size,
+ UINT8 AllocType,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line);
+
+ACPI_STATUS
+AcpiUtRemoveAllocation (
+ UINT32 ListId,
+ ACPI_DEBUG_MEM_BLOCK *Address,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line);
+
+void
+AcpiUtDumpAllocationInfo (
+ void);
+
+void
+AcpiUtDumpAllocations (
+ UINT32 Component,
+ char *Module);
+#endif
+
+
+#endif /* _ACUTILS_H */
diff --git a/sys/contrib/dev/acpica/amlcode.h b/sys/contrib/dev/acpica/amlcode.h
new file mode 100644
index 0000000..fba83b2
--- /dev/null
+++ b/sys/contrib/dev/acpica/amlcode.h
@@ -0,0 +1,579 @@
+/******************************************************************************
+ *
+ * Name: amlcode.h - Definitions for AML, as included in "definition blocks"
+ * Declarations and definitions contained herein are derived
+ * directly from the ACPI specification.
+ * $Revision: 73 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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
+ * Zero is reserved as end-of-list indicator
+ */
+
+#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)
+ *
+ * Note1: These values are completely independent from the ACPI_TYPEs
+ * i.e., ARGI_INTEGER != ACPI_TYPE_INTEGER
+ *
+ * Note2: 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.
+ */
+
+/* Single, simple types */
+
+#define ARGI_ANYTYPE 0x01 /* Don't care */
+#define ARGI_PACKAGE 0x02
+#define ARGI_EVENT 0x03
+#define ARGI_MUTEX 0x04
+#define ARGI_DDBHANDLE 0x05
+
+/* Interchangeable types (via implicit conversion) */
+
+#define ARGI_INTEGER 0x06
+#define ARGI_STRING 0x07
+#define ARGI_BUFFER 0x08
+#define ARGI_BUFFER_OR_STRING 0x09 /* Used by MID op only */
+#define ARGI_COMPUTEDATA 0x0A /* Buffer, String, or Integer */
+
+/* Reference objects */
+
+#define ARGI_INTEGER_REF 0x0B
+#define ARGI_OBJECT_REF 0x0C
+#define ARGI_DEVICE_REF 0x0D
+#define ARGI_REFERENCE 0x0E
+#define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */
+#define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */
+#define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */
+
+/* Multiple/complex types */
+
+#define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a Node - Used only by SizeOf operator*/
+#define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */
+#define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */
+#define ARGI_REGION_OR_FIELD 0x15 /* Used by LOAD op only */
+
+/* Note: types above can expand to 0x1F maximum */
+
+#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_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/amlresrc.h b/sys/contrib/dev/acpica/amlresrc.h
new file mode 100644
index 0000000..6ca7978
--- /dev/null
+++ b/sys/contrib/dev/acpica/amlresrc.h
@@ -0,0 +1,423 @@
+
+/******************************************************************************
+ *
+ * Module Name: amlresrc.h - AML resource descriptors
+ * $Revision: 23 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __AMLRESRC_H
+#define __AMLRESRC_H
+
+
+#define ASL_RESNAME_ADDRESS "_ADR"
+#define ASL_RESNAME_ALIGNMENT "_ALN"
+#define ASL_RESNAME_ADDRESSSPACE "_ASI"
+#define ASL_RESNAME_BASEADDRESS "_BAS"
+#define ASL_RESNAME_BUSMASTER "_BM_" /* Master(1), Slave(0) */
+#define ASL_RESNAME_DECODE "_DEC"
+#define ASL_RESNAME_DMA "_DMA"
+#define ASL_RESNAME_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */
+#define ASL_RESNAME_GRANULARITY "_GRA"
+#define ASL_RESNAME_INTERRUPT "_INT"
+#define ASL_RESNAME_INTERRUPTLEVEL "_LL_" /* ActiveLo(1), ActiveHi(0) */
+#define ASL_RESNAME_INTERRUPTSHARE "_SHR" /* Shareable(1), NoShare(0) */
+#define ASL_RESNAME_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */
+#define ASL_RESNAME_LENGTH "_LEN"
+#define ASL_RESNAME_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */
+#define ASL_RESNAME_MEMTYPE "_MEM" /* NonCache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */
+#define ASL_RESNAME_MAXADDR "_MAX"
+#define ASL_RESNAME_MINADDR "_MIN"
+#define ASL_RESNAME_MAXTYPE "_MAF"
+#define ASL_RESNAME_MINTYPE "_MIF"
+#define ASL_RESNAME_REGISTERBITOFFSET "_RBO"
+#define ASL_RESNAME_REGISTERBITWIDTH "_RBW"
+#define ASL_RESNAME_RANGETYPE "_RNG"
+#define ASL_RESNAME_READWRITETYPE "_RW_" /* ReadOnly(0), Writeable (1) */
+#define ASL_RESNAME_TRANSLATION "_TRA"
+#define ASL_RESNAME_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */
+#define ASL_RESNAME_TYPE "_TTP" /* Translation(1), Static (0) */
+#define ASL_RESNAME_XFERTYPE "_SIZ" /* 8(0), 8And16(1), 16(2) */
+
+
+/* Default sizes for "small" resource descriptors */
+
+#define ASL_RDESC_IRQ_SIZE 0x02
+#define ASL_RDESC_DMA_SIZE 0x02
+#define ASL_RDESC_ST_DEPEND_SIZE 0x00
+#define ASL_RDESC_END_DEPEND_SIZE 0x00
+#define ASL_RDESC_IO_SIZE 0x07
+#define ASL_RDESC_FIXED_IO_SIZE 0x03
+#define ASL_RDESC_END_TAG_SIZE 0x01
+
+
+typedef struct asl_resource_node
+{
+ UINT32 BufferLength;
+ void *Buffer;
+ struct asl_resource_node *Next;
+
+} ASL_RESOURCE_NODE;
+
+
+/*
+ * Resource descriptors defined in the ACPI specification.
+ *
+ * Alignment must be BYTE because these descriptors
+ * are used to overlay the AML byte stream.
+ */
+#pragma pack(1)
+
+typedef struct asl_irq_format_desc
+{
+ UINT8 DescriptorType;
+ UINT16 IrqMask;
+ UINT8 Flags;
+
+} ASL_IRQ_FORMAT_DESC;
+
+
+typedef struct asl_irq_noflags_desc
+{
+ UINT8 DescriptorType;
+ UINT16 IrqMask;
+
+} ASL_IRQ_NOFLAGS_DESC;
+
+
+typedef struct asl_dma_format_desc
+{
+ UINT8 DescriptorType;
+ UINT8 DmaChannelMask;
+ UINT8 Flags;
+
+} ASL_DMA_FORMAT_DESC;
+
+
+typedef struct asl_start_dependent_desc
+{
+ UINT8 DescriptorType;
+ UINT8 Flags;
+
+} ASL_START_DEPENDENT_DESC;
+
+
+typedef struct asl_start_dependent_noprio_desc
+{
+ UINT8 DescriptorType;
+
+} ASL_START_DEPENDENT_NOPRIO_DESC;
+
+
+typedef struct asl_end_dependent_desc
+{
+ UINT8 DescriptorType;
+
+} ASL_END_DEPENDENT_DESC;
+
+
+typedef struct asl_io_port_desc
+{
+ UINT8 DescriptorType;
+ UINT8 Information;
+ UINT16 AddressMin;
+ UINT16 AddressMax;
+ UINT8 Alignment;
+ UINT8 Length;
+
+} ASL_IO_PORT_DESC;
+
+
+typedef struct asl_fixed_io_port_desc
+{
+ UINT8 DescriptorType;
+ UINT16 BaseAddress;
+ UINT8 Length;
+
+} ASL_FIXED_IO_PORT_DESC;
+
+
+typedef struct asl_small_vendor_desc
+{
+ UINT8 DescriptorType;
+ UINT8 VendorDefined[7];
+
+} ASL_SMALL_VENDOR_DESC;
+
+
+typedef struct asl_end_tag_desc
+{
+ UINT8 DescriptorType;
+ UINT8 Checksum;
+
+} ASL_END_TAG_DESC;
+
+
+/* LARGE descriptors */
+
+typedef struct asl_memory_24_desc
+{
+ UINT8 DescriptorType;
+ UINT16 Length;
+ UINT8 Information;
+ UINT16 AddressMin;
+ UINT16 AddressMax;
+ UINT16 Alignment;
+ UINT16 RangeLength;
+
+} ASL_MEMORY_24_DESC;
+
+
+typedef struct asl_large_vendor_desc
+{
+ UINT8 DescriptorType;
+ UINT16 Length;
+ UINT8 VendorDefined[1];
+
+} ASL_LARGE_VENDOR_DESC;
+
+
+typedef struct asl_memory_32_desc
+{
+ UINT8 DescriptorType;
+ UINT16 Length;
+ UINT8 Information;
+ UINT32 AddressMin;
+ UINT32 AddressMax;
+ UINT32 Alignment;
+ UINT32 RangeLength;
+
+} ASL_MEMORY_32_DESC;
+
+
+typedef struct asl_fixed_memory_32_desc
+{
+ UINT8 DescriptorType;
+ UINT16 Length;
+ UINT8 Information;
+ UINT32 BaseAddress;
+ UINT32 RangeLength;
+
+} ASL_FIXED_MEMORY_32_DESC;
+
+
+typedef struct asl_qword_address_desc
+{
+ UINT8 DescriptorType;
+ UINT16 Length;
+ UINT8 ResourceType;
+ UINT8 Flags;
+ UINT8 SpecificFlags;
+ UINT64 Granularity;
+ UINT64 AddressMin;
+ UINT64 AddressMax;
+ UINT64 TranslationOffset;
+ UINT64 AddressLength;
+ UINT8 OptionalFields[2];
+
+} ASL_QWORD_ADDRESS_DESC;
+
+
+typedef struct asl_dword_address_desc
+{
+ UINT8 DescriptorType;
+ UINT16 Length;
+ UINT8 ResourceType;
+ UINT8 Flags;
+ UINT8 SpecificFlags;
+ UINT32 Granularity;
+ UINT32 AddressMin;
+ UINT32 AddressMax;
+ UINT32 TranslationOffset;
+ UINT32 AddressLength;
+ UINT8 OptionalFields[2];
+
+} ASL_DWORD_ADDRESS_DESC;
+
+
+typedef struct asl_word_address_desc
+{
+ UINT8 DescriptorType;
+ UINT16 Length;
+ UINT8 ResourceType;
+ UINT8 Flags;
+ UINT8 SpecificFlags;
+ UINT16 Granularity;
+ UINT16 AddressMin;
+ UINT16 AddressMax;
+ UINT16 TranslationOffset;
+ UINT16 AddressLength;
+ UINT8 OptionalFields[2];
+
+} ASL_WORD_ADDRESS_DESC;
+
+
+typedef struct asl_extended_xrupt_desc
+{
+ UINT8 DescriptorType;
+ UINT16 Length;
+ UINT8 Flags;
+ UINT8 TableLength;
+ UINT32 InterruptNumber[1];
+ /* ResSourceIndex, ResSource optional fields follow */
+
+} ASL_EXTENDED_XRUPT_DESC;
+
+
+typedef struct asl_general_register_desc
+{
+ UINT8 DescriptorType;
+ UINT16 Length;
+ UINT8 AddressSpaceId;
+ UINT8 BitWidth;
+ UINT8 BitOffset;
+ UINT8 Reserved;
+ UINT64 Address;
+
+} ASL_GENERAL_REGISTER_DESC;
+
+/* restore default alignment */
+
+#pragma pack()
+
+/* Union of all resource descriptors, sow we can allocate the worst case */
+
+typedef union asl_resource_desc
+{
+ ASL_IRQ_FORMAT_DESC Irq;
+ ASL_DMA_FORMAT_DESC Dma;
+ ASL_START_DEPENDENT_DESC Std;
+ ASL_END_DEPENDENT_DESC End;
+ ASL_IO_PORT_DESC Iop;
+ ASL_FIXED_IO_PORT_DESC Fio;
+ ASL_SMALL_VENDOR_DESC Smv;
+ ASL_END_TAG_DESC Et;
+
+ ASL_MEMORY_24_DESC M24;
+ ASL_LARGE_VENDOR_DESC Lgv;
+ ASL_MEMORY_32_DESC M32;
+ ASL_FIXED_MEMORY_32_DESC F32;
+ ASL_QWORD_ADDRESS_DESC Qas;
+ ASL_DWORD_ADDRESS_DESC Das;
+ ASL_WORD_ADDRESS_DESC Was;
+ ASL_EXTENDED_XRUPT_DESC Exx;
+ ASL_GENERAL_REGISTER_DESC Grg;
+ UINT32 U32Item;
+ UINT16 U16Item;
+ UINT8 U8Item;
+
+} ASL_RESOURCE_DESC;
+
+
+#endif
+
diff --git a/sys/contrib/dev/acpica/dbcmds.c b/sys/contrib/dev/acpica/dbcmds.c
new file mode 100644
index 0000000..20694d5
--- /dev/null
+++ b/sys/contrib/dev/acpica/dbcmds.c
@@ -0,0 +1,1309 @@
+/*******************************************************************************
+ *
+ * Module Name: dbcmds - debug commands and output routines
+ * $Revision: 97 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "acdispat.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "acevents.h"
+#include "acdebug.h"
+#include "acresrc.h"
+#include "acdisasm.h"
+
+#ifdef ACPI_DEBUGGER
+
+#define _COMPONENT ACPI_CA_DEBUGGER
+ ACPI_MODULE_NAME ("dbcmds")
+
+
+/*
+ * Arguments for the Objects command
+ * These object types map directly to the ACPI_TYPES
+ */
+
+static ARGUMENT_INFO AcpiDbObjectTypes [] =
+{
+ {"ANY"},
+ {"NUMBERS"},
+ {"STRINGS"},
+ {"BUFFERS"},
+ {"PACKAGES"},
+ {"FIELDS"},
+ {"DEVICES"},
+ {"EVENTS"},
+ {"METHODS"},
+ {"MUTEXES"},
+ {"REGIONS"},
+ {"POWERRESOURCES"},
+ {"PROCESSORS"},
+ {"THERMALZONES"},
+ {"BUFFERFIELDS"},
+ {"DDBHANDLES"},
+ {NULL} /* Must be null terminated */
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbWalkForReferences
+ *
+ * PARAMETERS: Callback from WalkNamespace
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Check if this namespace object refers to the target object
+ * that is passed in as the context value.
+ *
+ * Note: Currently doesn't check subobjects within the Node's object
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbWalkForReferences (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context;
+ ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
+
+
+ /* Check for match against the namespace node itself */
+
+ if (Node == (void *) ObjDesc)
+ {
+ AcpiOsPrintf ("Object is a Node [%4.4s]\n", Node->Name.Ascii);
+ }
+
+ /* Check for match against the object attached to the node */
+
+ if (AcpiNsGetAttachedObject (Node) == ObjDesc)
+ {
+ AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", Node, Node->Name.Ascii);
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbFindReferences
+ *
+ * PARAMETERS: ObjectArg - String with hex value of the object
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Search namespace for all references to the input object
+ *
+ ******************************************************************************/
+
+void
+AcpiDbFindReferences (
+ char *ObjectArg)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ /* Convert string to object pointer */
+
+ ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
+
+ /* Search all nodes in namespace */
+
+ (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+ AcpiDbWalkForReferences, (void *) ObjDesc, NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbDisplayLocks
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Display information about internal mutexes.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayLocks (void)
+{
+ UINT32 i;
+
+
+ for (i = 0; i < MAX_MTX; i++)
+ {
+ AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
+ AcpiGbl_AcpiMutexInfo[i].OwnerId == ACPI_MUTEX_NOT_ACQUIRED
+ ? "Locked" : "Unlocked");
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbDisplayTableInfo
+ *
+ * PARAMETERS: TableArg - String with name of table to be displayed
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Display information about loaded tables. Current
+ * implementation displays all loaded tables.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayTableInfo (
+ char *TableArg)
+{
+ UINT32 i;
+
+
+ for (i = 0; i < NUM_ACPI_TABLES; i++)
+ {
+ if (AcpiGbl_AcpiTables[i].Pointer)
+ {
+ AcpiOsPrintf ("%s at %p length %X\n", AcpiGbl_AcpiTableData[i].Name,
+ AcpiGbl_AcpiTables[i].Pointer,
+ (UINT32) AcpiGbl_AcpiTables[i].Length);
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbUnloadAcpiTable
+ *
+ * PARAMETERS: TableArg - Name of the table to be unloaded
+ * InstanceArg - Which instance of the table to unload (if
+ * there are multiple tables of the same type)
+ *
+ * RETURN: Nonde
+ *
+ * DESCRIPTION: Unload an ACPI table.
+ * Instance is not implemented
+ *
+ ******************************************************************************/
+
+void
+AcpiDbUnloadAcpiTable (
+ char *TableArg,
+ char *InstanceArg)
+{
+ UINT32 i;
+ ACPI_STATUS Status;
+
+
+ /* Search all tables for the target type */
+
+ for (i = 0; i < NUM_ACPI_TABLES; i++)
+ {
+ if (!ACPI_STRNCMP (TableArg, AcpiGbl_AcpiTableData[i].Signature,
+ AcpiGbl_AcpiTableData[i].SigLength))
+ {
+ /* Found the table, unload it */
+
+ Status = AcpiUnloadTable (i);
+ if (ACPI_SUCCESS (Status))
+ {
+ AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
+ }
+ else
+ {
+ AcpiOsPrintf ("%s, while unloading [%s]\n",
+ AcpiFormatException (Status), TableArg);
+ }
+
+ return;
+ }
+ }
+
+ AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbSetMethodBreakpoint
+ *
+ * PARAMETERS: Location - AML offset of breakpoint
+ * WalkState - Current walk info
+ * Op - Current Op (from parse walk)
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Set a breakpoint in a control method at the specified
+ * AML offset
+ *
+ ******************************************************************************/
+
+void
+AcpiDbSetMethodBreakpoint (
+ char *Location,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op)
+{
+ UINT32 Address;
+
+
+ if (!Op)
+ {
+ AcpiOsPrintf ("There is no method currently executing\n");
+ return;
+ }
+
+ /* Get and verify the breakpoint address */
+
+ Address = ACPI_STRTOUL (Location, NULL, 16);
+ if (Address <= Op->Common.AmlOffset)
+ {
+ AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", Address, Op->Common.AmlOffset);
+ }
+
+ /* Save breakpoint in current walk */
+
+ WalkState->UserBreakpoint = Address;
+ AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbSetMethodCallBreakpoint
+ *
+ * PARAMETERS: Op - Current Op (from parse walk)
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Set a breakpoint in a control method at the specified
+ * AML offset
+ *
+ ******************************************************************************/
+
+void
+AcpiDbSetMethodCallBreakpoint (
+ ACPI_PARSE_OBJECT *Op)
+{
+
+
+ if (!Op)
+ {
+ AcpiOsPrintf ("There is no method currently executing\n");
+ return;
+ }
+
+ AcpiGbl_StepToNextCall = TRUE;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbDisassembleAml
+ *
+ * PARAMETERS: Statements - Number of statements to disassemble
+ * Op - Current Op (from parse walk)
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
+ * of statements specified.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisassembleAml (
+ char *Statements,
+ ACPI_PARSE_OBJECT *Op)
+{
+ UINT32 NumStatements = 8;
+
+
+ if (!Op)
+ {
+ AcpiOsPrintf ("There is no method currently executing\n");
+ return;
+ }
+
+ if (Statements)
+ {
+ NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
+ }
+
+#ifdef ACPI_DISASSEMBLER
+ AcpiDmDisassemble (NULL, Op, NumStatements);
+#endif
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbDumpNamespace
+ *
+ * PARAMETERS: StartArg - Node to begin namespace dump
+ * DepthArg - Maximum tree depth to be dumped
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
+ * with type and other information.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDumpNamespace (
+ char *StartArg,
+ char *DepthArg)
+{
+ ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
+ UINT32 MaxDepth = ACPI_UINT32_MAX;
+
+
+ /* No argument given, just start at the root and dump entire namespace */
+
+ if (StartArg)
+ {
+ /* Check if numeric argument, must be a Node */
+
+ if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39))
+ {
+ SubtreeEntry = ACPI_TO_POINTER (ACPI_STRTOUL (StartArg, NULL, 16));
+ if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE)))
+ {
+ AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry);
+ return;
+ }
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (SubtreeEntry) != ACPI_DESC_TYPE_NAMED)
+ {
+ AcpiOsPrintf ("Address %p is not a valid Named object\n", SubtreeEntry);
+ return;
+ }
+ }
+
+ /* Alpha argument */
+
+ else
+ {
+ /* The parameter is a name string that must be resolved to a Named obj*/
+
+ SubtreeEntry = AcpiDbLocalNsLookup (StartArg);
+ if (!SubtreeEntry)
+ {
+ SubtreeEntry = AcpiGbl_RootNode;
+ }
+ }
+
+ /* Now we can check for the depth argument */
+
+ if (DepthArg)
+ {
+ MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
+ }
+ }
+
+ AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
+ AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry);
+
+ /* Display the subtree */
+
+ AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
+ AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry);
+ AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbDumpNamespaceByOwner
+ *
+ * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed
+ * DepthArg - Maximum tree depth to be dumped
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDumpNamespaceByOwner (
+ char *OwnerArg,
+ char *DepthArg)
+{
+ ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
+ UINT32 MaxDepth = ACPI_UINT32_MAX;
+ UINT16 OwnerId;
+
+
+ OwnerId = (UINT16) ACPI_STRTOUL (OwnerArg, NULL, 0);
+
+ /* Now we can check for the depth argument */
+
+ if (DepthArg)
+ {
+ MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
+ }
+
+ AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
+ AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
+
+ /* Display the subtree */
+
+ AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
+ AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, SubtreeEntry);
+ AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbSendNotify
+ *
+ * PARAMETERS: Name - Name of ACPI object to send the notify to
+ * Value - Value of the notify to send.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
+ * named object as an ACPI notify.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbSendNotify (
+ char *Name,
+ UINT32 Value)
+{
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
+
+
+ /* Translate name to an Named object */
+
+ Node = AcpiDbLocalNsLookup (Name);
+ if (!Node)
+ {
+ return;
+ }
+
+ /* Decode Named object type */
+
+ switch (Node->Type)
+ {
+ case ACPI_TYPE_DEVICE:
+ case ACPI_TYPE_THERMAL:
+
+ /* Send the notify */
+
+ Status = AcpiEvQueueNotifyRequest (Node, Value);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could not queue notify\n");
+ }
+ break;
+
+ default:
+ AcpiOsPrintf ("Named object is not a device or a thermal object\n");
+ break;
+ }
+
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbSetMethodData
+ *
+ * PARAMETERS: TypeArg - L for local, A for argument
+ * IndexArg - which one
+ * ValueArg - Value to set.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Set a local or argument for the running control method.
+ * NOTE: only object supported is Number.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbSetMethodData (
+ char *TypeArg,
+ char *IndexArg,
+ char *ValueArg)
+{
+ char Type;
+ UINT32 Index;
+ UINT32 Value;
+ ACPI_WALK_STATE *WalkState;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ /* Validate TypeArg */
+
+ ACPI_STRUPR (TypeArg);
+ Type = TypeArg[0];
+ if ((Type != 'L') &&
+ (Type != 'A'))
+ {
+ AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
+ return;
+ }
+
+ /* Get the index and value */
+
+ Index = ACPI_STRTOUL (IndexArg, NULL, 16);
+ Value = ACPI_STRTOUL (ValueArg, NULL, 16);
+
+ WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
+ if (!WalkState)
+ {
+ AcpiOsPrintf ("There is no method currently executing\n");
+ return;
+ }
+
+
+ /* Create and initialize the new object */
+
+ ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ObjDesc)
+ {
+ AcpiOsPrintf ("Could not create an internal object\n");
+ return;
+ }
+
+ ObjDesc->Integer.Value = Value;
+
+
+ /* Store the new object into the target */
+
+ switch (Type)
+ {
+ case 'A':
+
+ /* Set a method argument */
+
+ if (Index > ACPI_METHOD_MAX_ARG)
+ {
+ AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
+ return;
+ }
+
+ Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ ObjDesc = WalkState->Arguments[Index].Object;
+
+ AcpiOsPrintf ("Arg%d: ", Index);
+ AcpiDbDisplayInternalObject (ObjDesc, WalkState);
+ break;
+
+ case 'L':
+
+ /* Set a method local */
+
+ if (Index > ACPI_METHOD_MAX_LOCAL)
+ {
+ AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
+ return;
+ }
+
+ Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ ObjDesc = WalkState->LocalVariables[Index].Object;
+
+ AcpiOsPrintf ("Local%d: ", Index);
+ AcpiDbDisplayInternalObject (ObjDesc, WalkState);
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbWalkForSpecificObjects
+ *
+ * PARAMETERS: Callback from WalkNamespace
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Display short info about objects in the namespace
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbWalkForSpecificObjects (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+ ACPI_BUFFER Buffer;
+
+
+ ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjHandle);
+
+ /* Get and display the full pathname to this object */
+
+ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
+ return (AE_OK);
+ }
+
+ AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
+ ACPI_MEM_FREE (Buffer.Pointer);
+
+
+ /* Display short information about the object */
+
+ if (ObjDesc)
+ {
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
+ {
+ case ACPI_TYPE_METHOD:
+ AcpiOsPrintf (" #Args %d Concurrency %X",
+ ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency);
+ break;
+
+ case ACPI_TYPE_INTEGER:
+ AcpiOsPrintf (" Value %8.8X%8.8X",
+ ACPI_HIDWORD (ObjDesc->Integer.Value),
+ ACPI_LODWORD (ObjDesc->Integer.Value));
+ break;
+
+ case ACPI_TYPE_STRING:
+ AcpiOsPrintf (" \"%s\"", ObjDesc->String.Pointer);
+ break;
+
+ case ACPI_TYPE_REGION:
+ AcpiOsPrintf (" SpaceId %X Length %X Address %8.8X%8.8X",
+ ObjDesc->Region.SpaceId,
+ ObjDesc->Region.Length,
+ ACPI_HIDWORD (ObjDesc->Region.Address),
+ ACPI_LODWORD (ObjDesc->Region.Address));
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+ AcpiOsPrintf (" #Elements %X", ObjDesc->Package.Count);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ AcpiOsPrintf (" Length %X", ObjDesc->Buffer.Length);
+ break;
+
+ default:
+ /* Ignore other object types */
+ break;
+ }
+ }
+
+ AcpiOsPrintf ("\n");
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbDisplayObjects
+ *
+ * PARAMETERS: ObjTypeArg - Type of object to display
+ * DisplayCountArg - Max depth to display
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Display objects in the namespace of the requested type
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbDisplayObjects (
+ char *ObjTypeArg,
+ char *DisplayCountArg)
+{
+ ACPI_OBJECT_TYPE Type;
+
+
+ /* Get the object type */
+
+ Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
+ if (Type == ACPI_TYPE_NOT_FOUND)
+ {
+ AcpiOsPrintf ("Invalid or unsupported argument\n");
+ return (AE_OK);
+ }
+
+ AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
+ AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n",
+ AcpiUtGetTypeName (Type));
+
+ AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
+
+ /* Walk the namespace from the root */
+
+ (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+ AcpiDbWalkForSpecificObjects, (void *) &Type, NULL);
+
+ AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbWalkAndMatchName
+ *
+ * PARAMETERS: Callback from WalkNamespace
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
+ * are supported -- '?' matches any character.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbWalkAndMatchName (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_STATUS Status;
+ char *RequestedName = (char *) Context;
+ UINT32 i;
+ ACPI_BUFFER Buffer;
+
+
+ /* Check for a name match */
+
+ for (i = 0; i < 4; i++)
+ {
+ /* Wildcard support */
+
+ if ((RequestedName[i] != '?') &&
+ (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
+ {
+ /* No match, just exit */
+
+ return (AE_OK);
+ }
+ }
+
+
+ /* Get the full pathname to this object */
+
+ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
+ }
+ else
+ {
+ AcpiOsPrintf ("%32s (%p) - %s\n", (char *) Buffer.Pointer, ObjHandle,
+ AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type));
+ ACPI_MEM_FREE (Buffer.Pointer);
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbFindNameInNamespace
+ *
+ * PARAMETERS: NameArg - The 4-character ACPI name to find.
+ * wildcards are supported.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Search the namespace for a given name (with wildcards)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbFindNameInNamespace (
+ char *NameArg)
+{
+
+ if (ACPI_STRLEN (NameArg) > 4)
+ {
+ AcpiOsPrintf ("Name must be no longer than 4 characters\n");
+ return (AE_OK);
+ }
+
+ /* Walk the namespace from the root */
+
+ (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+ AcpiDbWalkAndMatchName, NameArg, NULL);
+
+ AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbSetScope
+ *
+ * PARAMETERS: Name - New scope path
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Set the "current scope" as maintained by this utility.
+ * The scope is used as a prefix to ACPI paths.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbSetScope (
+ char *Name)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ if (!Name || Name[0] == 0)
+ {
+ AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
+ return;
+ }
+
+ AcpiDbPrepNamestring (Name);
+
+
+ if (Name[0] == '\\')
+ {
+ /* Validate new scope from the root */
+
+ Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode, ACPI_NS_NO_UPSEARCH, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+
+ ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
+ ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
+ }
+ else
+ {
+ /* Validate new scope relative to old scope */
+
+ Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode, ACPI_NS_NO_UPSEARCH, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+
+ ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
+ ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
+ }
+
+ AcpiGbl_DbScopeNode = Node;
+ AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
+ return;
+
+
+ErrorExit:
+
+ AcpiOsPrintf ("Could not attach scope: %s, %s\n", Name, AcpiFormatException (Status));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbDisplayResources
+ *
+ * PARAMETERS: ObjectArg - String with hex value of the object
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Display the resource objects associated with a device.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayResources (
+ char *ObjectArg)
+{
+#if ACPI_MACHINE_WIDTH != 16
+
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+ ACPI_BUFFER ReturnObj;
+
+
+ AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
+ AcpiDbgLevel |= ACPI_LV_RESOURCES;
+
+ /* Convert string to object pointer */
+
+ ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
+
+ /* Prepare for a return object of arbitrary size */
+
+ ReturnObj.Pointer = AcpiGbl_DbBuffer;
+ ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
+
+ /* _PRT */
+
+ AcpiOsPrintf ("Evaluating _PRT\n");
+
+ Status = AcpiEvaluateObject (ObjDesc, "_PRT", NULL, &ReturnObj);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiFormatException (Status));
+ goto GetCrs;
+ }
+
+ ReturnObj.Pointer = AcpiGbl_DbBuffer;
+ ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
+
+ Status = AcpiGetIrqRoutingTable (ObjDesc, &ReturnObj);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiFormatException (Status));
+ }
+
+ else
+ {
+ AcpiRsDumpIrqList ((UINT8 *) AcpiGbl_DbBuffer);
+ }
+
+
+ /* _CRS */
+
+GetCrs:
+ AcpiOsPrintf ("Evaluating _CRS\n");
+
+ ReturnObj.Pointer = AcpiGbl_DbBuffer;
+ ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
+
+ Status = AcpiEvaluateObject (ObjDesc, "_CRS", NULL, &ReturnObj);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could not obtain _CRS: %s\n", AcpiFormatException (Status));
+ goto GetPrs;
+ }
+
+ ReturnObj.Pointer = AcpiGbl_DbBuffer;
+ ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
+
+ Status = AcpiGetCurrentResources (ObjDesc, &ReturnObj);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", AcpiFormatException (Status));
+ goto GetPrs;
+ }
+
+ else
+ {
+ AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
+ }
+
+ Status = AcpiSetCurrentResources (ObjDesc, &ReturnObj);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", AcpiFormatException (Status));
+ goto GetPrs;
+ }
+
+
+ /* _PRS */
+
+GetPrs:
+ AcpiOsPrintf ("Evaluating _PRS\n");
+
+ ReturnObj.Pointer = AcpiGbl_DbBuffer;
+ ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
+
+ Status = AcpiEvaluateObject (ObjDesc, "_PRS", NULL, &ReturnObj);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could not obtain _PRS: %s\n", AcpiFormatException (Status));
+ goto Cleanup;
+ }
+
+ ReturnObj.Pointer = AcpiGbl_DbBuffer;
+ ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
+
+ Status = AcpiGetPossibleResources (ObjDesc, &ReturnObj);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", AcpiFormatException (Status));
+ }
+
+ else
+ {
+ AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
+ }
+
+
+Cleanup:
+
+ AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+ return;
+#endif
+
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbIntegrityWalk
+ *
+ * PARAMETERS: Callback from WalkNamespace
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Examine one NS node for valid values.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbIntegrityWalk (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context;
+ ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
+ ACPI_OPERAND_OBJECT *Object;
+
+
+ Info->Nodes++;
+ if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
+ {
+ AcpiOsPrintf ("Invalid Descriptor Type for Node %p, Type = %X\n",
+ Node, ACPI_GET_DESCRIPTOR_TYPE (Node));
+ }
+
+ if (Node->Type > ACPI_TYPE_LOCAL_MAX)
+ {
+ AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
+ Node, Node->Type);
+ }
+
+ if (!AcpiUtValidAcpiName (Node->Name.Integer))
+ {
+ AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
+ }
+
+ Object = AcpiNsGetAttachedObject (Node);
+ if (Object)
+ {
+ Info->Objects++;
+ if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
+ {
+ AcpiOsPrintf ("Invalid Descriptor Type for Object %p, Type = %X\n",
+ Object, ACPI_GET_DESCRIPTOR_TYPE (Object));
+ }
+ }
+
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbCheckIntegrity
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Check entire namespace for data structure integrity
+ *
+ ******************************************************************************/
+
+void
+AcpiDbCheckIntegrity (void)
+{
+ ACPI_INTEGRITY_INFO Info = {0,0};
+
+ /* Search all nodes in namespace */
+
+ (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+ AcpiDbIntegrityWalk, (void *) &Info, NULL);
+
+ AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", Info.Nodes, Info.Objects);
+
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbGenerateGpe
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Generate a GPE
+ *
+ ******************************************************************************/
+
+void
+AcpiDbGenerateGpe (
+ char *GpeArg,
+ char *BlockArg)
+{
+ UINT32 BlockNumber;
+ UINT32 GpeNumber;
+ ACPI_GPE_EVENT_INFO *GpeEventInfo;
+
+
+ GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 10);
+ BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 10);
+
+
+ GpeEventInfo = AcpiEvGetGpeEventInfo (GpeNumber);
+ if (!GpeEventInfo)
+ {
+ AcpiOsPrintf ("Invalid GPE\n");
+ return;
+ }
+
+ AcpiEvGpeDispatch (GpeEventInfo);
+
+}
+
+#endif /* ACPI_DEBUGGER */
diff --git a/sys/contrib/dev/acpica/dbdisply.c b/sys/contrib/dev/acpica/dbdisply.c
new file mode 100644
index 0000000..2f74d1f
--- /dev/null
+++ b/sys/contrib/dev/acpica/dbdisply.c
@@ -0,0 +1,1056 @@
+/*******************************************************************************
+ *
+ * Module Name: dbdisply - debug display commands
+ * $Revision: 89 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 <stdio.h>
+
+ /* 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 (
+ char *Target,
+ char *OutputType)
+{
+ void *ObjPtr;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ UINT32 Display = DB_BYTE_DISPLAY;
+ 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);
+ 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);
+ 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 ("<Node> 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 ("<NullObj>\n");
+ return;
+ }
+
+ /* Decode the object type */
+
+ switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
+ {
+ case ACPI_DESC_TYPE_PARSER:
+
+ AcpiOsPrintf ("<Parser> ");
+ 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 > ACPI_TYPE_LOCAL_MAX)
+ {
+ AcpiOsPrintf (" Type %X [Invalid Type]", (UINT32) Type);
+ return;
+ }
+
+ /* Decode the ACPI object type */
+
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
+ {
+ 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 ("<Obj> ");
+ AcpiOsPrintf (" ");
+ AcpiDbDecodeInternalObject (ObjDesc);
+ break;
+ }
+ break;
+
+
+ default:
+
+ AcpiOsPrintf ("<Not a valid ACPI Object Descriptor> ");
+ 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;
+ if (!Node)
+ {
+ AcpiOsPrintf ("No method node (Executing subtree for buffer or opregion)\n");
+ return;
+ }
+
+ AcpiOsPrintf ("Local Variables for method [%4.4s]:\n", Node->Name.Ascii);
+
+ for (i = 0; i < ACPI_METHOD_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;
+ if (!Node)
+ {
+ AcpiOsPrintf ("No method node (Executing subtree for buffer or opregion)\n");
+ return;
+ }
+
+ 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 < ACPI_METHOD_NUM_ARGS; 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);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbDisplayGpes
+ *
+ * PARAMETERS:
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Display the GPE structures
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayGpes (void)
+{
+ ACPI_GPE_BLOCK_INFO *GpeBlock;
+ UINT32 i = 0;
+
+
+ GpeBlock = AcpiGbl_GpeBlockListHead;
+ while (GpeBlock)
+ {
+ AcpiOsPrintf ("Block %d - %p\n", i, GpeBlock);
+ AcpiOsPrintf (" Registers: %d\n", GpeBlock->RegisterCount);
+ AcpiOsPrintf (" GPE range: %d to %d\n", GpeBlock->BlockBaseNumber,
+ GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8) -1);
+ AcpiOsPrintf (" RegisterInfo: %p\n", GpeBlock->RegisterInfo);
+ AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo);
+ i++;
+
+ GpeBlock = GpeBlock->Next;
+ }
+}
+
+
+#endif /* ACPI_DEBUGGER */
+
diff --git a/sys/contrib/dev/acpica/dbexec.c b/sys/contrib/dev/acpica/dbexec.c
new file mode 100644
index 0000000..505496e
--- /dev/null
+++ b/sys/contrib/dev/acpica/dbexec.c
@@ -0,0 +1,582 @@
+/*******************************************************************************
+ *
+ * Module Name: dbexec - debugger control method execution
+ * $Revision: 53 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 ("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[ACPI_METHOD_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 < ACPI_METHOD_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 */
+
+ AcpiGbl_MethodExecuting = TRUE;
+ 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: AcpiDbExecutionWalk
+ *
+ * PARAMETERS: WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute a control method. Name is relative to the current
+ * scope.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbExecutionWalk (
+ ACPI_HANDLE ObjHandle,
+ UINT32 NestingLevel,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
+ ACPI_BUFFER ReturnObj;
+ ACPI_STATUS Status;
+
+
+ ObjDesc = AcpiNsGetAttachedObject (Node);
+ if (ObjDesc->Method.ParamCount)
+ {
+ return (AE_OK);
+ }
+
+ ReturnObj.Pointer = NULL;
+ ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
+
+ AcpiNsPrintNodePathname (Node, "Execute");
+
+ /* Do the actual method execution */
+
+ AcpiOsPrintf ("\n");
+ AcpiGbl_MethodExecuting = TRUE;
+
+ Status = AcpiEvaluateObject (Node, NULL, NULL, &ReturnObj);
+
+ AcpiOsPrintf ("[%4.4s] returned %s\n", Node->Name.Ascii,
+ AcpiFormatException (Status));
+ AcpiGbl_MethodExecuting = FALSE;
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * 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 (
+ char *Name,
+ char **Args,
+ UINT32 Flags)
+{
+ ACPI_STATUS Status;
+ ACPI_BUFFER ReturnObj;
+
+
+#ifdef ACPI_DEBUG_OUTPUT
+ UINT32 PreviousAllocations;
+ UINT32 Allocations;
+
+
+ /* Memory allocation tracking */
+
+ PreviousAllocations = AcpiDbGetOutstandingAllocations ();
+#endif
+
+ if (*Name == '*')
+ {
+ (void) AcpiWalkNamespace (ACPI_TYPE_METHOD, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+ AcpiDbExecutionWalk, NULL, NULL);
+ return;
+ }
+ else
+ {
+ 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 (
+ char *NumThreadsArg,
+ char *NumLoopsArg,
+ 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, 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/dbfileio.c b/sys/contrib/dev/acpica/dbfileio.c
new file mode 100644
index 0000000..11c0206
--- /dev/null
+++ b/sys/contrib/dev/acpica/dbfileio.c
@@ -0,0 +1,489 @@
+/*******************************************************************************
+ *
+ * Module Name: dbfileio - Debugger file I/O commands. These can't usually
+ * be used when running the debugger in Ring 0 (Kernel mode)
+ * $Revision: 72 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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"
+#include "actables.h"
+
+#if (defined ACPI_DEBUGGER || defined ACPI_DISASSEMBLER)
+
+#define _COMPONENT ACPI_CA_DEBUGGER
+ ACPI_MODULE_NAME ("dbfileio")
+
+
+/*
+ * NOTE: this is here for lack of a better place. It is used in all
+ * flavors of the debugger, need LCD file
+ */
+#ifdef ACPI_APPLICATION
+#include <stdio.h>
+FILE *AcpiGbl_DebugFile = NULL;
+#endif
+
+
+#ifdef ACPI_DEBUGGER
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbCloseDebugFile
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: If open, close the current debug output file
+ *
+ ******************************************************************************/
+
+void
+AcpiDbCloseDebugFile (
+ void)
+{
+
+#ifdef ACPI_APPLICATION
+
+ if (AcpiGbl_DebugFile)
+ {
+ fclose (AcpiGbl_DebugFile);
+ AcpiGbl_DebugFile = NULL;
+ AcpiGbl_DbOutputToFile = FALSE;
+ AcpiOsPrintf ("Debug output file %s closed\n", AcpiGbl_DbDebugFilename);
+ }
+#endif
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbOpenDebugFile
+ *
+ * PARAMETERS: Name - Filename to open
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Open a file where debug output will be directed.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbOpenDebugFile (
+ char *Name)
+{
+
+#ifdef ACPI_APPLICATION
+
+ AcpiDbCloseDebugFile ();
+ AcpiGbl_DebugFile = fopen (Name, "w+");
+ if (AcpiGbl_DebugFile)
+ {
+ AcpiOsPrintf ("Debug output file %s opened\n", Name);
+ ACPI_STRCPY (AcpiGbl_DbDebugFilename, Name);
+ AcpiGbl_DbOutputToFile = TRUE;
+ }
+ else
+ {
+ AcpiOsPrintf ("Could not open debug file %s\n", Name);
+ }
+
+#endif
+}
+#endif
+
+
+#ifdef ACPI_APPLICATION
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbReadTable
+ *
+ * PARAMETERS: fp - File that contains table
+ * Table - Return value, buffer with table
+ * TableLength - Return value, length of table
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Load the DSDT from the file pointer
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbReadTable (
+ FILE *fp,
+ ACPI_TABLE_HEADER **Table,
+ UINT32 *TableLength)
+{
+ ACPI_TABLE_HEADER TableHeader;
+ UINT8 *AmlStart;
+ UINT32 AmlLength;
+ UINT32 Actual;
+ ACPI_STATUS Status;
+
+
+ /* Read the table header */
+
+ if (fread (&TableHeader, 1, sizeof (TableHeader), fp) != sizeof (ACPI_TABLE_HEADER))
+ {
+ AcpiOsPrintf ("Couldn't read the table header\n");
+ return (AE_BAD_SIGNATURE);
+ }
+
+ /* Validate the table header/length */
+
+ Status = AcpiTbValidateTableHeader (&TableHeader);
+ if ((ACPI_FAILURE (Status)) ||
+ (TableHeader.Length > 0x800000)) /* 8 Mbyte should be enough */
+ {
+ AcpiOsPrintf ("Table header is invalid!\n");
+ return (AE_ERROR);
+ }
+
+ /* We only support a limited number of table types */
+
+ if (ACPI_STRNCMP ((char *) TableHeader.Signature, DSDT_SIG, 4) &&
+ ACPI_STRNCMP ((char *) TableHeader.Signature, PSDT_SIG, 4) &&
+ ACPI_STRNCMP ((char *) TableHeader.Signature, SSDT_SIG, 4))
+ {
+ AcpiOsPrintf ("Table signature is invalid\n");
+ ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER));
+ return (AE_ERROR);
+ }
+
+ /* Allocate a buffer for the table */
+
+ *TableLength = TableHeader.Length;
+ *Table = AcpiOsAllocate ((size_t) *TableLength);
+ if (!*Table)
+ {
+ AcpiOsPrintf ("Could not allocate memory for ACPI table %4.4s (size=%X)\n",
+ TableHeader.Signature, TableHeader.Length);
+ return (AE_NO_MEMORY);
+ }
+
+ AmlStart = (UINT8 *) *Table + sizeof (TableHeader);
+ AmlLength = *TableLength - sizeof (TableHeader);
+
+ /* Copy the header to the buffer */
+
+ ACPI_MEMCPY (*Table, &TableHeader, sizeof (TableHeader));
+
+ /* Get the rest of the table */
+
+ Actual = fread (AmlStart, 1, (size_t) AmlLength, fp);
+ if (Actual == AmlLength)
+ {
+ /* Now validate the checksum */
+
+ Status = AcpiTbVerifyTableChecksum (*Table);
+ return (AE_OK);
+ }
+
+ if (Actual > 0)
+ {
+ AcpiOsPrintf ("Warning - reading table, asked for %X got %X\n", AmlLength, Actual);
+ return (AE_OK);
+ }
+
+ AcpiOsPrintf ("Error - could not read the table file\n");
+ AcpiOsFree (*Table);
+ *Table = NULL;
+ *TableLength = 0;
+
+ return (AE_ERROR);
+}
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AeLocalLoadTable
+ *
+ * PARAMETERS: Table - pointer to a buffer containing the entire
+ * table to be loaded
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to load a table from the caller's
+ * buffer. The buffer must contain an entire ACPI Table including
+ * a valid header. The header fields will be verified, and if it
+ * is determined that the table is invalid, the call will fail.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AeLocalLoadTable (
+ ACPI_TABLE_HEADER *Table)
+{
+ ACPI_STATUS Status;
+ ACPI_TABLE_DESC TableInfo;
+
+
+ ACPI_FUNCTION_TRACE ("AeLocalLoadTable");
+
+
+ if (!Table)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ TableInfo.Pointer = Table;
+ Status = AcpiTbRecognizeTable (&TableInfo, ACPI_TABLE_ALL);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Install the new table into the local data structures */
+
+ Status = AcpiTbInstallTable (&TableInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Free table allocated by AcpiTbGetTable */
+
+ AcpiTbDeleteSingleTable (&TableInfo);
+ return_ACPI_STATUS (Status);
+ }
+
+#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
+
+ Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Uninstall table and free the buffer */
+
+ AcpiTbDeleteAcpiTable (ACPI_TABLE_DSDT);
+ return_ACPI_STATUS (Status);
+ }
+#endif
+
+ return_ACPI_STATUS (Status);
+}
+
+
+#ifdef ACPI_APPLICATION
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbReadTableFromFile
+ *
+ * PARAMETERS: Filename - File where table is located
+ * Table - Where a pointer to the table is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Get an ACPI table from a file
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbReadTableFromFile (
+ char *Filename,
+ ACPI_TABLE_HEADER **Table)
+{
+ FILE *fp;
+ UINT32 TableLength;
+ ACPI_STATUS Status;
+
+
+ /* Open the file */
+
+ fp = fopen (Filename, "rb");
+ if (!fp)
+ {
+ AcpiOsPrintf ("Could not open input file %s\n", Filename);
+ return (AE_ERROR);
+ }
+
+ /* Get the entire file */
+
+ fprintf (stderr, "Loading Acpi table from file %s\n", Filename);
+ Status = AcpiDbReadTable (fp, Table, &TableLength);
+ fclose(fp);
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Couldn't get table from the file\n");
+ return (Status);
+ }
+
+ return (AE_OK);
+ }
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbGetTableFromFile
+ *
+ * PARAMETERS: Filename - File where table is located
+ * Table - Where a pointer to the table is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Load an ACPI table from a file
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbGetTableFromFile (
+ char *Filename,
+ ACPI_TABLE_HEADER **ReturnTable)
+{
+#ifdef ACPI_APPLICATION
+ ACPI_STATUS Status;
+ ACPI_TABLE_HEADER *Table;
+
+
+ Status = AcpiDbReadTableFromFile (Filename, &Table);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Attempt to recognize and install the table */
+
+ Status = AeLocalLoadTable (Table);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_ALREADY_EXISTS)
+ {
+ AcpiOsPrintf ("Table %4.4s is already installed\n",
+ Table->Signature);
+ }
+ else
+ {
+ AcpiOsPrintf ("Could not install table, %s\n",
+ AcpiFormatException (Status));
+ }
+
+ return (Status);
+ }
+
+ fprintf (stderr, "Acpi table [%4.4s] successfully installed and loaded\n",
+ Table->Signature);
+
+ AcpiGbl_AcpiHardwarePresent = FALSE;
+ if (ReturnTable)
+ {
+ *ReturnTable = Table;
+ }
+
+
+#endif /* ACPI_APPLICATION */
+ return (AE_OK);
+}
+
+#endif /* ACPI_DEBUGGER */
+
diff --git a/sys/contrib/dev/acpica/dbhistry.c b/sys/contrib/dev/acpica/dbhistry.c
new file mode 100644
index 0000000..bbdaa25
--- /dev/null
+++ b/sys/contrib/dev/acpica/dbhistry.c
@@ -0,0 +1,291 @@
+/******************************************************************************
+ *
+ * Module Name: dbhistry - debugger HISTORY command
+ * $Revision: 28 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 ("dbhistry")
+
+
+#define HI_NO_HISTORY 0
+#define HI_RECORD_HISTORY 1
+#define HISTORY_SIZE 20
+
+
+typedef struct HistoryInfo
+{
+ char Command[80];
+ UINT32 CmdNum;
+
+} HISTORY_INFO;
+
+
+static HISTORY_INFO AcpiGbl_HistoryBuffer[HISTORY_SIZE];
+static UINT16 AcpiGbl_LoHistory = 0;
+static UINT16 AcpiGbl_NumHistory = 0;
+static UINT16 AcpiGbl_NextHistoryIndex = 0;
+static UINT32 AcpiGbl_NextCmdNum = 1;
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbAddToHistory
+ *
+ * PARAMETERS: CommandLine - Command to add
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Add a command line to the history buffer.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbAddToHistory (
+ char *CommandLine)
+{
+
+ /* Put command into the next available slot */
+
+ ACPI_STRCPY (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command, CommandLine);
+
+ AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].CmdNum = AcpiGbl_NextCmdNum;
+
+ /* Adjust indexes */
+
+ if ((AcpiGbl_NumHistory == HISTORY_SIZE) &&
+ (AcpiGbl_NextHistoryIndex == AcpiGbl_LoHistory))
+ {
+ AcpiGbl_LoHistory++;
+ if (AcpiGbl_LoHistory >= HISTORY_SIZE)
+ {
+ AcpiGbl_LoHistory = 0;
+ }
+ }
+
+ AcpiGbl_NextHistoryIndex++;
+ if (AcpiGbl_NextHistoryIndex >= HISTORY_SIZE)
+ {
+ AcpiGbl_NextHistoryIndex = 0;
+ }
+
+ AcpiGbl_NextCmdNum++;
+ if (AcpiGbl_NumHistory < HISTORY_SIZE)
+ {
+ AcpiGbl_NumHistory++;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbDisplayHistory
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Display the contents of the history buffer
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayHistory (void)
+{
+ ACPI_NATIVE_UINT i;
+ UINT16 HistoryIndex;
+
+
+ HistoryIndex = AcpiGbl_LoHistory;
+
+ /* Dump entire history buffer */
+
+ for (i = 0; i < AcpiGbl_NumHistory; i++)
+ {
+ AcpiOsPrintf ("%ld %s\n", AcpiGbl_HistoryBuffer[HistoryIndex].CmdNum,
+ AcpiGbl_HistoryBuffer[HistoryIndex].Command);
+
+ HistoryIndex++;
+ if (HistoryIndex >= HISTORY_SIZE)
+ {
+ HistoryIndex = 0;
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbGetFromHistory
+ *
+ * PARAMETERS: CommandNumArg - String containing the number of the
+ * command to be retrieved
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Get a command from the history buffer
+ *
+ ******************************************************************************/
+
+char *
+AcpiDbGetFromHistory (
+ char *CommandNumArg)
+{
+ ACPI_NATIVE_UINT i;
+ UINT16 HistoryIndex;
+ UINT32 CmdNum;
+
+
+ if (CommandNumArg == NULL)
+ {
+ CmdNum = AcpiGbl_NextCmdNum - 1;
+ }
+
+ else
+ {
+ CmdNum = ACPI_STRTOUL (CommandNumArg, NULL, 0);
+ }
+
+ /* Search history buffer */
+
+ HistoryIndex = AcpiGbl_LoHistory;
+ for (i = 0; i < AcpiGbl_NumHistory; i++)
+ {
+ if (AcpiGbl_HistoryBuffer[HistoryIndex].CmdNum == CmdNum)
+ {
+ /* Found the commnad, return it */
+
+ return (AcpiGbl_HistoryBuffer[HistoryIndex].Command);
+ }
+
+
+ HistoryIndex++;
+ if (HistoryIndex >= HISTORY_SIZE)
+ {
+ HistoryIndex = 0;
+ }
+ }
+
+ AcpiOsPrintf ("Invalid history number: %d\n", HistoryIndex);
+ return (NULL);
+}
+
+
+#endif /* ACPI_DEBUGGER */
+
diff --git a/sys/contrib/dev/acpica/dbinput.c b/sys/contrib/dev/acpica/dbinput.c
new file mode 100644
index 0000000..546a09f
--- /dev/null
+++ b/sys/contrib/dev/acpica/dbinput.c
@@ -0,0 +1,995 @@
+/*******************************************************************************
+ *
+ * Module Name: dbinput - user front-end to the AML debugger
+ * $Revision: 96 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 ("dbinput")
+
+
+/*
+ * Top-level debugger commands.
+ *
+ * This list of commands must match the string table below it
+ */
+enum AcpiExDebuggerCommands
+{
+ CMD_NOT_FOUND = 0,
+ CMD_NULL,
+ CMD_ALLOCATIONS,
+ CMD_ARGS,
+ CMD_ARGUMENTS,
+ CMD_BREAKPOINT,
+ CMD_CALL,
+ CMD_CLOSE,
+ CMD_DEBUG,
+ CMD_DUMP,
+ CMD_ENABLEACPI,
+ CMD_EVENT,
+ CMD_EXECUTE,
+ CMD_EXIT,
+ CMD_FIND,
+ CMD_GO,
+ CMD_GPE,
+ CMD_GPES,
+ CMD_HELP,
+ CMD_HELP2,
+ CMD_HISTORY,
+ CMD_HISTORY_EXE,
+ CMD_HISTORY_LAST,
+ CMD_INFORMATION,
+ CMD_INTEGRITY,
+ CMD_INTO,
+ CMD_LEVEL,
+ CMD_LIST,
+ CMD_LOAD,
+ CMD_LOCALS,
+ CMD_LOCKS,
+ CMD_METHODS,
+ CMD_NAMESPACE,
+ CMD_NOTIFY,
+ CMD_OBJECT,
+ CMD_OPEN,
+ CMD_OWNER,
+ CMD_PREFIX,
+ CMD_QUIT,
+ CMD_REFERENCES,
+ CMD_RESOURCES,
+ CMD_RESULTS,
+ CMD_SET,
+ CMD_STATS,
+ CMD_STOP,
+ CMD_TABLES,
+ CMD_TERMINATE,
+ CMD_THREADS,
+ CMD_TREE,
+ CMD_UNLOAD
+};
+
+#define CMD_FIRST_VALID 2
+
+
+static const COMMAND_INFO AcpiGbl_DbCommands[] =
+{
+ {"<NOT FOUND>", 0},
+ {"<NULL>", 0},
+ {"ALLOCATIONS", 0},
+ {"ARGS", 0},
+ {"ARGUMENTS", 0},
+ {"BREAKPOINT", 1},
+ {"CALL", 0},
+ {"CLOSE", 0},
+ {"DEBUG", 1},
+ {"DUMP", 1},
+ {"ENABLEACPI", 0},
+ {"EVENT", 1},
+ {"EXECUTE", 1},
+ {"EXIT", 0},
+ {"FIND", 1},
+ {"GO", 0},
+ {"GPE", 2},
+ {"GPES", 0},
+ {"HELP", 0},
+ {"?", 0},
+ {"HISTORY", 0},
+ {"!", 1},
+ {"!!", 0},
+ {"INFORMATION", 0},
+ {"INTEGRITY", 0},
+ {"INTO", 0},
+ {"LEVEL", 0},
+ {"LIST", 0},
+ {"LOAD", 1},
+ {"LOCALS", 0},
+ {"LOCKS", 0},
+ {"METHODS", 0},
+ {"NAMESPACE", 0},
+ {"NOTIFY", 2},
+ {"OBJECT", 1},
+ {"OPEN", 1},
+ {"OWNER", 1},
+ {"PREFIX", 0},
+ {"QUIT", 0},
+ {"REFERENCES", 1},
+ {"RESOURCES", 1},
+ {"RESULTS", 0},
+ {"SET", 3},
+ {"STATS", 0},
+ {"STOP", 0},
+ {"TABLES", 0},
+ {"TERMINATE", 0},
+ {"THREADS", 3},
+ {"TREE", 0},
+ {"UNLOAD", 1},
+ {NULL, 0}
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbDisplayHelp
+ *
+ * PARAMETERS: HelpType - Subcommand (optional)
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print a usage message.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayHelp (
+ char *HelpType)
+{
+
+
+ /* No parameter, just give the overview */
+
+ if (!HelpType)
+ {
+ AcpiOsPrintf ("ACPI CA Debugger Commands\n\n");
+ AcpiOsPrintf ("The following classes of commands are available. Help is available for\n");
+ AcpiOsPrintf ("each class by entering \"Help <ClassName>\"\n\n");
+ AcpiOsPrintf (" [GENERAL] General-Purpose Commands\n");
+ AcpiOsPrintf (" [NAMESPACE] Namespace Access Commands\n");
+ AcpiOsPrintf (" [METHOD] Control Method Execution Commands\n");
+ AcpiOsPrintf (" [FILE] File I/O Commands\n");
+ return;
+ }
+
+ /*
+ * Parameter is the command class
+ *
+ * The idea here is to keep each class of commands smaller than a screenful
+ */
+ switch (HelpType[0])
+ {
+ case 'G':
+ AcpiOsPrintf ("\nGeneral-Purpose Commands\n\n");
+ AcpiOsPrintf ("Allocations Display list of current memory allocations\n");
+ AcpiOsPrintf ("Dump <Address>|<Namepath>\n");
+ AcpiOsPrintf (" [Byte|Word|Dword|Qword] Display ACPI objects or memory\n");
+ AcpiOsPrintf ("EnableAcpi Enable ACPI (hardware) mode\n");
+ AcpiOsPrintf ("Help This help screen\n");
+ AcpiOsPrintf ("History Display command history buffer\n");
+ AcpiOsPrintf ("Level [<DebugLevel>] [console] Get/Set debug level for file or console\n");
+ AcpiOsPrintf ("Locks Current status of internal mutexes\n");
+ AcpiOsPrintf ("Quit or Exit Exit this command\n");
+ AcpiOsPrintf ("Stats [Allocations|Memory|Misc\n");
+ AcpiOsPrintf (" |Objects|Tables] Display namespace and memory statistics\n");
+ AcpiOsPrintf ("Tables Display info about loaded ACPI tables\n");
+ AcpiOsPrintf ("Unload <TableSig> [Instance] Unload an ACPI table\n");
+ AcpiOsPrintf ("! <CommandNumber> Execute command from history buffer\n");
+ AcpiOsPrintf ("!! Execute last command again\n");
+ return;
+
+ case 'N':
+ AcpiOsPrintf ("\nNamespace Access Commands\n\n");
+ AcpiOsPrintf ("Event <F|G> <Value> Generate AcpiEvent (Fixed/GPE)\n");
+ AcpiOsPrintf ("Find <Name> (? is wildcard) Find ACPI name(s) with wildcards\n");
+ AcpiOsPrintf ("Method Display list of loaded control methods\n");
+ AcpiOsPrintf ("Namespace [<Addr>|<Path>] [Depth] Display loaded namespace tree/subtree\n");
+ AcpiOsPrintf ("Notify <NamePath> <Value> Send a notification\n");
+ AcpiOsPrintf ("Objects <ObjectType> Display all objects of the given type\n");
+ AcpiOsPrintf ("Owner <OwnerId> [Depth] Display loaded namespace by object owner\n");
+ AcpiOsPrintf ("Prefix [<NamePath>] Set or Get current execution prefix\n");
+ AcpiOsPrintf ("References <Addr> Find all references to object at addr\n");
+ AcpiOsPrintf ("Resources xxx Get and display resources\n");
+ AcpiOsPrintf ("Terminate Delete namespace and all internal objects\n");
+ AcpiOsPrintf ("Thread <Threads><Loops><NamePath> Spawn threads to execute method(s)\n");
+ return;
+
+ case 'M':
+ AcpiOsPrintf ("\nControl Method Execution Commands\n\n");
+ AcpiOsPrintf ("Arguments (or Args) Display method arguments\n");
+ AcpiOsPrintf ("Breakpoint <AmlOffset> Set an AML execution breakpoint\n");
+ AcpiOsPrintf ("Call Run to next control method invocation\n");
+ AcpiOsPrintf ("Debug <Namepath> [Arguments] Single Step a control method\n");
+ AcpiOsPrintf ("Execute <Namepath> [Arguments] Execute control method\n");
+ AcpiOsPrintf ("Go Allow method to run to completion\n");
+ AcpiOsPrintf ("Information Display info about the current method\n");
+ AcpiOsPrintf ("Into Step into (not over) a method call\n");
+ AcpiOsPrintf ("List [# of Aml Opcodes] Display method ASL statements\n");
+ AcpiOsPrintf ("Locals Display method local variables\n");
+ AcpiOsPrintf ("Results Display method result stack\n");
+ AcpiOsPrintf ("Set <A|L> <#> <Value> Set method data (Arguments/Locals)\n");
+ AcpiOsPrintf ("Stop Terminate control method\n");
+ AcpiOsPrintf ("Tree Display control method calling tree\n");
+ AcpiOsPrintf ("<Enter> Single step next AML opcode (over calls)\n");
+ return;
+
+ case 'F':
+ AcpiOsPrintf ("\nFile I/O Commands\n\n");
+ AcpiOsPrintf ("Close Close debug output file\n");
+ AcpiOsPrintf ("Open <Output Filename> Open a file for debug output\n");
+ AcpiOsPrintf ("Load <Input Filename> Load ACPI table from a file\n");
+ return;
+
+ default:
+ AcpiOsPrintf ("Unrecognized Command Class: %s\n", HelpType);
+ return;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbGetNextToken
+ *
+ * PARAMETERS: String - Command buffer
+ * Next - Return value, end of next token
+ *
+ * RETURN: Pointer to the start of the next token.
+ *
+ * DESCRIPTION: Command line parsing. Get the next token on the command line
+ *
+ ******************************************************************************/
+
+char *
+AcpiDbGetNextToken (
+ char *String,
+ char **Next)
+{
+ char *Start;
+
+
+ /* At end of buffer? */
+
+ if (!String || !(*String))
+ {
+ return (NULL);
+ }
+
+ /* Get rid of any spaces at the beginning */
+
+ if (*String == ' ')
+ {
+ while (*String && (*String == ' '))
+ {
+ String++;
+ }
+
+ if (!(*String))
+ {
+ return (NULL);
+ }
+ }
+
+ Start = String;
+
+ /* Find end of token */
+
+ while (*String && (*String != ' '))
+ {
+ String++;
+ }
+
+ if (!(*String))
+ {
+ *Next = NULL;
+ }
+ else
+ {
+ *String = 0;
+ *Next = String + 1;
+ }
+
+ return (Start);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbGetLine
+ *
+ * PARAMETERS: InputBuffer - Command line buffer
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Get the next command line from the user. Gets entire line
+ * up to the next newline
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiDbGetLine (
+ char *InputBuffer)
+{
+ UINT32 i;
+ UINT32 Count;
+ char *Next;
+ char *This;
+
+
+ ACPI_STRCPY (AcpiGbl_DbParsedBuf, InputBuffer);
+ ACPI_STRUPR (AcpiGbl_DbParsedBuf);
+
+ This = AcpiGbl_DbParsedBuf;
+ for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++)
+ {
+ AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next);
+ if (!AcpiGbl_DbArgs[i])
+ {
+ break;
+ }
+
+ This = Next;
+ }
+
+ /* Uppercase the actual command */
+
+ if (AcpiGbl_DbArgs[0])
+ {
+ ACPI_STRUPR (AcpiGbl_DbArgs[0]);
+ }
+
+ Count = i;
+ if (Count)
+ {
+ Count--; /* Number of args only */
+ }
+
+ return (Count);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbMatchCommand
+ *
+ * PARAMETERS: UserCommand - User command line
+ *
+ * RETURN: Index into command array, -1 if not found
+ *
+ * DESCRIPTION: Search command array for a command match
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiDbMatchCommand (
+ char *UserCommand)
+{
+ UINT32 i;
+
+
+ if (!UserCommand || UserCommand[0] == 0)
+ {
+ return (CMD_NULL);
+ }
+
+ for (i = CMD_FIRST_VALID; AcpiGbl_DbCommands[i].Name; i++)
+ {
+ if (ACPI_STRSTR (AcpiGbl_DbCommands[i].Name, UserCommand) ==
+ AcpiGbl_DbCommands[i].Name)
+ {
+ return (i);
+ }
+ }
+
+ /* Command not recognized */
+
+ return (CMD_NOT_FOUND);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbCommandDispatch
+ *
+ * PARAMETERS: InputBuffer - Command line buffer
+ * WalkState - Current walk
+ * Op - Current (executing) parse op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Command dispatcher. Called from two places:
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbCommandDispatch (
+ char *InputBuffer,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op)
+{
+ UINT32 Temp;
+ UINT32 CommandIndex;
+ UINT32 ParamCount;
+ char *CommandLine;
+ ACPI_STATUS Status = AE_CTRL_TRUE;
+
+
+ /* If AcpiTerminate has been called, terminate this thread */
+
+ if (AcpiGbl_DbTerminateThreads)
+ {
+ return (AE_CTRL_TERMINATE);
+ }
+
+ ParamCount = AcpiDbGetLine (InputBuffer);
+ CommandIndex = AcpiDbMatchCommand (AcpiGbl_DbArgs[0]);
+ Temp = 0;
+
+ /* Verify that we have the minimum number of params */
+
+ if (ParamCount < AcpiGbl_DbCommands[CommandIndex].MinArgs)
+ {
+ AcpiOsPrintf ("%d parameters entered, [%s] requires %d parameters\n",
+ ParamCount, AcpiGbl_DbCommands[CommandIndex].Name, AcpiGbl_DbCommands[CommandIndex].MinArgs);
+ return (AE_CTRL_TRUE);
+ }
+
+ /* Decode and dispatch the command */
+
+ switch (CommandIndex)
+ {
+ case CMD_NULL:
+ if (Op)
+ {
+ return (AE_OK);
+ }
+ break;
+
+ case CMD_ALLOCATIONS:
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+ AcpiUtDumpAllocations ((UINT32) -1, NULL);
+#endif
+ break;
+
+ case CMD_ARGS:
+ case CMD_ARGUMENTS:
+ AcpiDbDisplayArguments ();
+ break;
+
+ case CMD_BREAKPOINT:
+ AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op);
+ break;
+
+ case CMD_CALL:
+ AcpiDbSetMethodCallBreakpoint (Op);
+ Status = AE_OK;
+ break;
+
+ case CMD_CLOSE:
+ AcpiDbCloseDebugFile ();
+ break;
+
+ case CMD_DEBUG:
+ AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_SINGLE_STEP);
+ break;
+
+ case CMD_DUMP:
+ AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
+ break;
+
+ case CMD_ENABLEACPI:
+ Status = AcpiEnable();
+ if (ACPI_FAILURE(Status))
+ {
+ AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
+ return (Status);
+ }
+ break;
+
+ case CMD_EVENT:
+ AcpiOsPrintf ("Event command not implemented\n");
+ break;
+
+ case CMD_EXECUTE:
+ AcpiDbExecute (AcpiGbl_DbArgs[1], &AcpiGbl_DbArgs[2], EX_NO_SINGLE_STEP);
+ break;
+
+ case CMD_FIND:
+ AcpiDbFindNameInNamespace (AcpiGbl_DbArgs[1]);
+ break;
+
+ case CMD_GO:
+ AcpiGbl_CmSingleStep = FALSE;
+ return (AE_OK);
+
+ case CMD_GPE:
+ AcpiDbGenerateGpe (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
+ break;
+
+ case CMD_GPES:
+ AcpiDbDisplayGpes ();
+ break;
+
+ case CMD_HELP:
+ case CMD_HELP2:
+ AcpiDbDisplayHelp (AcpiGbl_DbArgs[1]);
+ break;
+
+ case CMD_HISTORY:
+ AcpiDbDisplayHistory ();
+ break;
+
+ case CMD_HISTORY_EXE:
+ CommandLine = AcpiDbGetFromHistory (AcpiGbl_DbArgs[1]);
+ if (!CommandLine)
+ {
+ return (AE_CTRL_TRUE);
+ }
+
+ Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
+ if (ACPI_SUCCESS (Status))
+ {
+ Status = AE_CTRL_TRUE;
+ }
+ return (Status);
+
+ case CMD_HISTORY_LAST:
+ CommandLine = AcpiDbGetFromHistory (NULL);
+ if (!CommandLine)
+ {
+ return (AE_CTRL_TRUE);
+ }
+
+ Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
+ if (ACPI_SUCCESS (Status))
+ {
+ Status = AE_CTRL_TRUE;
+ }
+ return (Status);
+
+ case CMD_INFORMATION:
+ AcpiDbDisplayMethodInfo (Op);
+ break;
+
+ case CMD_INTEGRITY:
+ AcpiDbCheckIntegrity ();
+ break;
+
+ case CMD_INTO:
+ if (Op)
+ {
+ AcpiGbl_CmSingleStep = TRUE;
+ return (AE_OK);
+ }
+ break;
+
+ case CMD_LEVEL:
+ if (ParamCount == 0)
+ {
+ AcpiOsPrintf ("Current debug level for file output is: %8.8lX\n", AcpiGbl_DbDebugLevel);
+ AcpiOsPrintf ("Current debug level for console output is: %8.8lX\n", AcpiGbl_DbConsoleDebugLevel);
+ }
+ else if (ParamCount == 2)
+ {
+ Temp = AcpiGbl_DbConsoleDebugLevel;
+ AcpiGbl_DbConsoleDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16);
+ AcpiOsPrintf ("Debug Level for console output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbConsoleDebugLevel);
+ }
+ else
+ {
+ Temp = AcpiGbl_DbDebugLevel;
+ AcpiGbl_DbDebugLevel = ACPI_STRTOUL (AcpiGbl_DbArgs[1], NULL, 16);
+ AcpiOsPrintf ("Debug Level for file output was %8.8lX, now %8.8lX\n", Temp, AcpiGbl_DbDebugLevel);
+ }
+ break;
+
+ case CMD_LIST:
+ AcpiDbDisassembleAml (AcpiGbl_DbArgs[1], Op);
+ break;
+
+ case CMD_LOAD:
+ Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ break;
+
+ case CMD_LOCKS:
+ AcpiDbDisplayLocks ();
+ break;
+
+ case CMD_LOCALS:
+ AcpiDbDisplayLocals ();
+ break;
+
+ case CMD_METHODS:
+ AcpiDbDisplayObjects ("METHOD", AcpiGbl_DbArgs[1]);
+ break;
+
+ case CMD_NAMESPACE:
+ AcpiDbDumpNamespace (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
+ break;
+
+ case CMD_NOTIFY:
+ Temp = ACPI_STRTOUL (AcpiGbl_DbArgs[2], NULL, 0);
+ AcpiDbSendNotify (AcpiGbl_DbArgs[1], Temp);
+ break;
+
+ case CMD_OBJECT:
+ ACPI_STRUPR (AcpiGbl_DbArgs[1]);
+ AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
+ break;
+
+ case CMD_OPEN:
+ AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]);
+ break;
+
+ case CMD_OWNER:
+ AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
+ break;
+
+ case CMD_PREFIX:
+ AcpiDbSetScope (AcpiGbl_DbArgs[1]);
+ break;
+
+ case CMD_REFERENCES:
+ AcpiDbFindReferences (AcpiGbl_DbArgs[1]);
+ break;
+
+ case CMD_RESOURCES:
+ AcpiDbDisplayResources (AcpiGbl_DbArgs[1]);
+ break;
+
+ case CMD_RESULTS:
+ AcpiDbDisplayResults ();
+ break;
+
+ case CMD_SET:
+ AcpiDbSetMethodData (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]);
+ break;
+
+ case CMD_STATS:
+ AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
+ break;
+
+ case CMD_STOP:
+ return (AE_NOT_IMPLEMENTED);
+
+ case CMD_TABLES:
+ AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]);
+ break;
+
+ case CMD_TERMINATE:
+ AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
+ AcpiUtSubsystemShutdown ();
+
+ /* TBD: [Restructure] Need some way to re-initialize without re-creating the semaphores! */
+
+ /* AcpiInitialize (NULL); */
+ break;
+
+ case CMD_THREADS:
+ AcpiDbCreateExecutionThreads (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2], AcpiGbl_DbArgs[3]);
+ break;
+
+ case CMD_TREE:
+ AcpiDbDisplayCallingTree ();
+ break;
+
+ case CMD_UNLOAD:
+ AcpiDbUnloadAcpiTable (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
+ break;
+
+ case CMD_EXIT:
+ case CMD_QUIT:
+ if (Op)
+ {
+ AcpiOsPrintf ("Method execution terminated\n");
+ return (AE_CTRL_TERMINATE);
+ }
+
+ if (!AcpiGbl_DbOutputToFile)
+ {
+ AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
+ }
+
+ /* Shutdown */
+
+ /* AcpiUtSubsystemShutdown (); */
+ AcpiDbCloseDebugFile ();
+
+ AcpiGbl_DbTerminateThreads = TRUE;
+
+ return (AE_CTRL_TERMINATE);
+
+ case CMD_NOT_FOUND:
+ default:
+ AcpiOsPrintf ("Unknown Command\n");
+ return (AE_CTRL_TRUE);
+ }
+
+
+ /* Add all commands that come here to the history buffer */
+
+ AcpiDbAddToHistory (InputBuffer);
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbExecuteThread
+ *
+ * PARAMETERS: Context - Not used
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Debugger execute thread. Waits for a command line, then
+ * simply dispatches it.
+ *
+ ******************************************************************************/
+
+void ACPI_SYSTEM_XFACE
+AcpiDbExecuteThread (
+ void *Context)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_STATUS MStatus;
+
+
+ while (Status != AE_CTRL_TERMINATE)
+ {
+ AcpiGbl_MethodExecuting = FALSE;
+ AcpiGbl_StepToNextCall = FALSE;
+
+ MStatus = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
+ if (ACPI_FAILURE (MStatus))
+ {
+ return;
+ }
+
+ Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
+
+ MStatus = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
+ if (ACPI_FAILURE (MStatus))
+ {
+ return;
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbSingleThread
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Debugger execute thread. Waits for a command line, then
+ * simply dispatches it.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbSingleThread (
+ void)
+{
+
+ AcpiGbl_MethodExecuting = FALSE;
+ AcpiGbl_StepToNextCall = FALSE;
+
+ (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbUserCommands
+ *
+ * PARAMETERS: Prompt - User prompt (depends on mode)
+ * Op - Current executing parse op
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Command line execution for the AML debugger. Commands are
+ * matched and dispatched here.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbUserCommands (
+ char Prompt,
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ /* TBD: [Restructure] Need a separate command line buffer for step mode */
+
+ while (!AcpiGbl_DbTerminateThreads)
+ {
+ /* Force output to console until a command is entered */
+
+ AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+
+ /* Different prompt if method is executing */
+
+ if (!AcpiGbl_MethodExecuting)
+ {
+ AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
+ }
+ else
+ {
+ AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
+ }
+
+ /* Get the user input line */
+
+ (void) AcpiOsGetLine (AcpiGbl_DbLineBuf);
+
+ /* Check for single or multithreaded debug */
+
+ if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
+ {
+ /*
+ * Signal the debug thread that we have a command to execute,
+ * and wait for the command to complete.
+ */
+ Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_READY);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+ else
+ {
+ /* Just call to the command line interpreter */
+
+ AcpiDbSingleThread ();
+ }
+ }
+
+ /*
+ * Only this thread (the original thread) should actually terminate the subsystem,
+ * because all the semaphores are deleted during termination
+ */
+ Status = AcpiTerminate ();
+ return (Status);
+}
+
+
+#endif /* ACPI_DEBUGGER */
+
diff --git a/sys/contrib/dev/acpica/dbstats.c b/sys/contrib/dev/acpica/dbstats.c
new file mode 100644
index 0000000..cf6c531
--- /dev/null
+++ b/sys/contrib/dev/acpica/dbstats.c
@@ -0,0 +1,558 @@
+/*******************************************************************************
+ *
+ * Module Name: dbstats - Generation and display of ACPI table statistics
+ * $Revision: 66 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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) > 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 [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 > 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 < (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 (
+ 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 < 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
new file mode 100644
index 0000000..3fa3eb0
--- /dev/null
+++ b/sys/contrib/dev/acpica/dbutils.c
@@ -0,0 +1,538 @@
+/*******************************************************************************
+ *
+ * Module Name: dbutils - AML debugger utilities
+ * $Revision: 61 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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: AcpiDbMatchArgument
+ *
+ * PARAMETERS: UserArgument - User command line
+ * Arguments - Array of commands to match against
+ *
+ * RETURN: Index into command array or ACPI_TYPE_NOT_FOUND if not found
+ *
+ * DESCRIPTION: Search command array for a command match
+ *
+ ******************************************************************************/
+
+ACPI_OBJECT_TYPE
+AcpiDbMatchArgument (
+ char *UserArgument,
+ ARGUMENT_INFO *Arguments)
+{
+ UINT32 i;
+
+
+ if (!UserArgument || UserArgument[0] == 0)
+ {
+ return (ACPI_TYPE_NOT_FOUND);
+ }
+
+ for (i = 0; Arguments[i].Name; i++)
+ {
+ if (ACPI_STRSTR (Arguments[i].Name, UserArgument) == Arguments[i].Name)
+ {
+ return (i);
+ }
+ }
+
+ /* Argument not recognized */
+
+ return (ACPI_TYPE_NOT_FOUND);
+}
+
+
+/*******************************************************************************
+ *
+ * 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);
+ if (ObjDesc->Buffer.Length)
+ {
+ AcpiUtDumpBuffer ((UINT8 *) ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT);
+ }
+ else
+ {
+ AcpiOsPrintf ("\n");
+ }
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ AcpiOsPrintf ("[Package] Contains %d Elements: \n", ObjDesc->Package.Count);
+
+ for (i = 0; i < ObjDesc->Package.Count; i++)
+ {
+ AcpiDbDumpObject (&ObjDesc->Package.Elements[i], Level+1);
+ }
+ break;
+
+
+ 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 (
+ 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 (
+ char *Name)
+{
+ char *InternalPath;
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node = NULL;
+
+
+ AcpiDbPrepNamestring (Name);
+
+ /* Build an internal namestring */
+
+ Status = AcpiNsInternalizeName (Name, &InternalPath);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Invalid namestring: %s\n", Name);
+ return (NULL);
+ }
+
+ /*
+ * Lookup the name.
+ * (Uses root node as the search starting point)
+ */
+ Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+ ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could not locate name: %s %s\n", Name, AcpiFormatException (Status));
+ }
+
+ ACPI_MEM_FREE (InternalPath);
+ return (Node);
+}
+
+
+#endif /* ACPI_DEBUGGER */
+
+
diff --git a/sys/contrib/dev/acpica/dbxface.c b/sys/contrib/dev/acpica/dbxface.c
new file mode 100644
index 0000000..6eeb117
--- /dev/null
+++ b/sys/contrib/dev/acpica/dbxface.c
@@ -0,0 +1,588 @@
+/*******************************************************************************
+ *
+ * Module Name: dbxface - AML Debugger external interfaces
+ * $Revision: 70 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "acdebug.h"
+#include "acdisasm.h"
+
+
+#ifdef ACPI_DEBUGGER
+
+#define _COMPONENT ACPI_CA_DEBUGGER
+ ACPI_MODULE_NAME ("dbxface")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbStartCommand
+ *
+ * PARAMETERS: WalkState - Current walk
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enter debugger command loop
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbStartCommand (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_STATUS Status;
+
+
+ /* TBD: [Investigate] what are the namespace locking issues here */
+
+ /* AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); */
+
+ /* Go into the command loop and await next user command */
+
+
+ AcpiGbl_MethodExecuting = TRUE;
+ Status = AE_CTRL_TRUE;
+ while (Status == AE_CTRL_TRUE)
+ {
+ if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED)
+ {
+ /* Handshake with the front-end that gets user command lines */
+
+ Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+ else
+ {
+ /* Single threaded, we must get a command line ourselves */
+
+ /* Force output to console until a command is entered */
+
+ AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+
+ /* Different prompt if method is executing */
+
+ if (!AcpiGbl_MethodExecuting)
+ {
+ AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
+ }
+ else
+ {
+ AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
+ }
+
+ /* Get the user input line */
+
+ (void) AcpiOsGetLine (AcpiGbl_DbLineBuf);
+ }
+
+ Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op);
+ }
+
+ /* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */
+
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbMethodEnd
+ *
+ * PARAMETERS: WalkState - Current walk
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION:
+ *
+ ******************************************************************************/
+
+void
+AcpiDbMethodEnd (
+ ACPI_WALK_STATE *WalkState)
+{
+
+ if (!AcpiGbl_CmSingleStep)
+ {
+ return;
+ }
+
+ AcpiOsPrintf ("<Method Terminating>\n");
+
+ AcpiDbStartCommand (WalkState, NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbSingleStep
+ *
+ * PARAMETERS: WalkState - Current walk
+ * Op - Current executing op
+ * OpcodeClass - Class of the current AML Opcode
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Called just before execution of an AML opcode.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbSingleStep (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 OpcodeClass)
+{
+ ACPI_PARSE_OBJECT *Next;
+ ACPI_STATUS Status = AE_OK;
+ UINT32 OriginalDebugLevel;
+ ACPI_PARSE_OBJECT *DisplayOp;
+ ACPI_PARSE_OBJECT *ParentOp;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Check the abort flag */
+
+ if (AcpiGbl_AbortMethod)
+ {
+ AcpiGbl_AbortMethod = FALSE;
+ return (AE_ABORT_METHOD);
+ }
+
+ /* Check for single-step breakpoint */
+
+ if (WalkState->MethodBreakpoint &&
+ (WalkState->MethodBreakpoint <= Op->Common.AmlOffset))
+ {
+ /* Check if the breakpoint has been reached or passed */
+ /* Hit the breakpoint, resume single step, reset breakpoint */
+
+ AcpiOsPrintf ("***Break*** at AML offset %X\n", Op->Common.AmlOffset);
+ AcpiGbl_CmSingleStep = TRUE;
+ AcpiGbl_StepToNextCall = FALSE;
+ WalkState->MethodBreakpoint = 0;
+ }
+
+ /* Check for user breakpoint (Must be on exact Aml offset) */
+
+ else if (WalkState->UserBreakpoint &&
+ (WalkState->UserBreakpoint == Op->Common.AmlOffset))
+ {
+ AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n", Op->Common.AmlOffset);
+ AcpiGbl_CmSingleStep = TRUE;
+ AcpiGbl_StepToNextCall = FALSE;
+ WalkState->MethodBreakpoint = 0;
+ }
+
+ /*
+ * Check if this is an opcode that we are interested in --
+ * namely, opcodes that have arguments
+ */
+ if (Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
+ {
+ return (AE_OK);
+ }
+
+ switch (OpcodeClass)
+ {
+ case AML_CLASS_UNKNOWN:
+ case AML_CLASS_ARGUMENT: /* constants, literals, etc. do nothing */
+ return (AE_OK);
+
+ default:
+ /* All other opcodes -- continue */
+ break;
+ }
+
+ /*
+ * Under certain debug conditions, display this opcode and its operands
+ */
+ if ((AcpiGbl_DbOutputToFile) ||
+ (AcpiGbl_CmSingleStep) ||
+ (AcpiDbgLevel & ACPI_LV_PARSE))
+ {
+ if ((AcpiGbl_DbOutputToFile) ||
+ (AcpiDbgLevel & ACPI_LV_PARSE))
+ {
+ AcpiOsPrintf ("\n[AmlDebug] Next AML Opcode to execute:\n");
+ }
+
+ /*
+ * Display this op (and only this op - zero out the NEXT field temporarily,
+ * and disable parser trace output for the duration of the display because
+ * we don't want the extraneous debug output)
+ */
+ OriginalDebugLevel = AcpiDbgLevel;
+ AcpiDbgLevel &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS);
+ Next = Op->Common.Next;
+ Op->Common.Next = NULL;
+
+
+ DisplayOp = Op;
+ ParentOp = Op->Common.Parent;
+ if (ParentOp)
+ {
+ if ((WalkState->ControlState) &&
+ (WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING))
+ {
+ /*
+ * We are executing the predicate of an IF or WHILE statement
+ * Search upwards for the containing IF or WHILE so that the
+ * entire predicate can be displayed.
+ */
+ while (ParentOp)
+ {
+ if ((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
+ (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
+ {
+ DisplayOp = ParentOp;
+ break;
+ }
+ ParentOp = ParentOp->Common.Parent;
+ }
+ }
+ else
+ {
+ while (ParentOp)
+ {
+ if ((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
+ (ParentOp->Common.AmlOpcode == AML_ELSE_OP) ||
+ (ParentOp->Common.AmlOpcode == AML_SCOPE_OP) ||
+ (ParentOp->Common.AmlOpcode == AML_METHOD_OP) ||
+ (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
+ {
+ break;
+ }
+ DisplayOp = ParentOp;
+ ParentOp = ParentOp->Common.Parent;
+ }
+ }
+ }
+
+ /* Now we can display it */
+
+#ifdef ACPI_DISASSEMBLER
+ AcpiDmDisassemble (WalkState, DisplayOp, ACPI_UINT32_MAX);
+#endif
+
+ if ((Op->Common.AmlOpcode == AML_IF_OP) ||
+ (Op->Common.AmlOpcode == AML_WHILE_OP))
+ {
+ if (WalkState->ControlState->Common.Value)
+ {
+ AcpiOsPrintf ("Predicate = [True], IF block was executed\n");
+ }
+ else
+ {
+ AcpiOsPrintf ("Predicate = [False], Skipping IF block\n");
+ }
+ }
+ else if (Op->Common.AmlOpcode == AML_ELSE_OP)
+ {
+ AcpiOsPrintf ("Predicate = [False], ELSE block was executed\n");
+ }
+
+ /* Restore everything */
+
+ Op->Common.Next = Next;
+ AcpiOsPrintf ("\n");
+ if ((AcpiGbl_DbOutputToFile) ||
+ (AcpiDbgLevel & ACPI_LV_PARSE))
+ {
+ AcpiOsPrintf ("\n");
+ }
+ AcpiDbgLevel = OriginalDebugLevel;
+ }
+
+ /* If we are not single stepping, just continue executing the method */
+
+ if (!AcpiGbl_CmSingleStep)
+ {
+ return (AE_OK);
+ }
+
+ /*
+ * If we are executing a step-to-call command,
+ * Check if this is a method call.
+ */
+ if (AcpiGbl_StepToNextCall)
+ {
+ if (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)
+ {
+ /* Not a method call, just keep executing */
+
+ return (AE_OK);
+ }
+
+ /* Found a method call, stop executing */
+
+ AcpiGbl_StepToNextCall = FALSE;
+ }
+
+ /*
+ * If the next opcode is a method call, we will "step over" it
+ * by default.
+ */
+ if (Op->Common.AmlOpcode == AML_INT_METHODCALL_OP)
+ {
+ AcpiGbl_CmSingleStep = FALSE; /* No more single step while executing called method */
+
+ /* Set the breakpoint on/before the call, it will stop execution as soon as we return */
+
+ WalkState->MethodBreakpoint = 1; /* Must be non-zero! */
+ }
+
+
+ Status = AcpiDbStartCommand (WalkState, Op);
+
+ /* User commands complete, continue execution of the interrupted method */
+
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbInitialize
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Init and start debugger
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbInitialize (void)
+{
+ ACPI_STATUS Status;
+
+
+ /* Init globals */
+
+ AcpiGbl_DbBuffer = NULL;
+ AcpiGbl_DbFilename = NULL;
+ AcpiGbl_DbOutputToFile = FALSE;
+
+ AcpiGbl_DbDebugLevel = ACPI_LV_VERBOSITY2;
+ AcpiGbl_DbConsoleDebugLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES;
+ AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT;
+
+ AcpiGbl_DbOpt_tables = FALSE;
+ AcpiGbl_DbOpt_stats = FALSE;
+#ifdef ACPI_DISASSEMBLER
+ AcpiGbl_DbOpt_disasm = FALSE;
+ AcpiGbl_DbOpt_verbose = TRUE;
+#endif
+ AcpiGbl_DbOpt_ini_methods = TRUE;
+
+ AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE);
+ if (!AcpiGbl_DbBuffer)
+ {
+ return (AE_NO_MEMORY);
+ }
+ ACPI_MEMSET (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE);
+
+ /* Initial scope is the root */
+
+ AcpiGbl_DbScopeBuf [0] = '\\';
+ AcpiGbl_DbScopeBuf [1] = 0;
+ AcpiGbl_DbScopeNode = AcpiGbl_RootNode;
+
+ /*
+ * If configured for multi-thread support, the debug executor runs in
+ * a separate thread so that the front end can be in another address
+ * space, environment, or even another machine.
+ */
+ if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
+ {
+ /* These were created with one unit, grab it */
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could not get debugger mutex\n");
+ return (Status);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could not get debugger mutex\n");
+ return (Status);
+ }
+
+ /* Create the debug execution thread to execute commands */
+
+ Status = AcpiOsQueueForExecution (0, AcpiDbExecuteThread, NULL);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("Could not start debugger thread\n");
+ return (Status);
+ }
+ }
+
+#ifdef ACPI_DISASSEMBLER
+ if (!AcpiGbl_DbOpt_verbose)
+ {
+ AcpiGbl_DbOpt_disasm = TRUE;
+ AcpiGbl_DbOpt_stats = FALSE;
+ }
+#endif
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDbTerminate
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Stop debugger
+ *
+ ******************************************************************************/
+
+void
+AcpiDbTerminate (void)
+{
+
+ if (AcpiGbl_DbTablePtr)
+ {
+ AcpiOsFree (AcpiGbl_DbTablePtr);
+ }
+ if (AcpiGbl_DbBuffer)
+ {
+ AcpiOsFree (AcpiGbl_DbBuffer);
+ }
+}
+
+
+#endif /* ACPI_DEBUGGER */
diff --git a/sys/contrib/dev/acpica/dmbuffer.c b/sys/contrib/dev/acpica/dmbuffer.c
new file mode 100644
index 0000000..5d734c4
--- /dev/null
+++ b/sys/contrib/dev/acpica/dmbuffer.c
@@ -0,0 +1,537 @@
+/*******************************************************************************
+ *
+ * Module Name: dmbuffer - AML disassembler, buffer and string support
+ * $Revision: 10 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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);
+ 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;
+ ACPI_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: 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;
+ ACPI_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/dmnames.c b/sys/contrib/dev/acpica/dmnames.c
new file mode 100644
index 0000000..c9a0069
--- /dev/null
+++ b/sys/contrib/dev/acpica/dmnames.c
@@ -0,0 +1,499 @@
+/*******************************************************************************
+ *
+ * Module Name: dmnames - AML disassembler, names, namestrings, pathnames
+ * $Revision: 6 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "acdisasm.h"
+
+
+#ifdef ACPI_DISASSEMBLER
+
+#define _COMPONENT ACPI_CA_DEBUGGER
+ ACPI_MODULE_NAME ("dmnames")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmValidateName
+ *
+ * PARAMETERS: Name - 4 character ACPI name
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Lookup the name
+ *
+ ******************************************************************************/
+
+void
+AcpiDmValidateName (
+ char *Name,
+ ACPI_PARSE_OBJECT *Op)
+{
+
+#if 0
+ if ((!Name) ||
+ (!Op->Common.Parent))
+ {
+ return;
+ }
+
+ if (!Op->Common.Node)
+ {
+ AcpiOsPrintf (" /**** Name not found or not accessible from this scope ****/ ");
+ }
+
+ ACPI_PARSE_OBJECT *TargetOp;
+
+
+ if ((!Name) ||
+ (!Op->Common.Parent))
+ {
+ return;
+ }
+
+ TargetOp = AcpiPsFind (Op, Name, 0, 0);
+ if (!TargetOp)
+ {
+ /*
+ * Didn't find the name in the parse tree. This may be
+ * a problem, or it may simply be one of the predefined names
+ * (such as _OS_). Rather than worry about looking up all
+ * the predefined names, just display the name as given
+ */
+ AcpiOsPrintf (" /**** Name not found or not accessible from this scope ****/ ");
+ }
+#endif
+
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmDumpName
+ *
+ * PARAMETERS: Name - 4 character ACPI name
+ *
+ * RETURN: Final length of name
+ *
+ * DESCRIPTION: Dump an ACPI name, minus any trailing underscores.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiDmDumpName (
+ char *Name)
+{
+ UINT32 i;
+ UINT32 Length;
+ char *End = Name + ACPI_NAME_SIZE;
+
+
+ for (i = 0; i < ACPI_NAME_SIZE; i++)
+ {
+ if (Name[i] != '_')
+ {
+ End = &Name[i];
+ }
+ }
+
+ Length = (UINT32)(End - Name) + 1;
+ for (i = 0; i < Length; i++)
+ {
+ AcpiOsPrintf ("%c", Name[i]);
+ }
+
+ return (Length);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsDisplayObjectPathname
+ *
+ * PARAMETERS: WalkState - Current walk state
+ * Op - Object whose pathname is to be obtained
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Diplay the pathname associated with a named object. Two
+ * versions. One searches the parse tree (for parser-only
+ * applications suchas AcpiDump), and the other searches the
+ * ACPI namespace (the parse tree is probably deleted)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsDisplayObjectPathname (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_BUFFER Buffer;
+ UINT32 DebugLevel;
+
+
+ /* Save current debug level so we don't get extraneous debug output */
+
+ DebugLevel = AcpiDbgLevel;
+ AcpiDbgLevel = 0;
+
+ /* Just get the Node out of the Op object */
+
+ Node = Op->Common.Node;
+ if (!Node)
+ {
+ /* Node not defined in this scope, look it up */
+
+ Status = AcpiNsLookup (WalkState->ScopeInfo, Op->Common.Value.String, ACPI_TYPE_ANY,
+ ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, WalkState, &(Node));
+
+ if (ACPI_FAILURE (Status))
+ {
+ /*
+ * We can't get the pathname since the object
+ * is not in the namespace. This can happen during single
+ * stepping where a dynamic named object is *about* to be created.
+ */
+ AcpiOsPrintf (" [Path not found]");
+ goto Exit;
+ }
+
+ /* Save it for next time. */
+
+ Op->Common.Node = Node;
+ }
+
+ /* Convert NamedDesc/handle to a full pathname */
+
+ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ Status = AcpiNsHandleToPathname (Node, &Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("****Could not get pathname****)");
+ goto Exit;
+ }
+
+ AcpiOsPrintf (" (Path %s)", (char *) Buffer.Pointer);
+ ACPI_MEM_FREE (Buffer.Pointer);
+
+
+Exit:
+ /* Restore the debug level */
+
+ AcpiDbgLevel = DebugLevel;
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmNamestring
+ *
+ * PARAMETERS: Name - ACPI Name string to store
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode an ACPI namestring. Handles prefix characters
+ *
+ ******************************************************************************/
+
+void
+AcpiDmNamestring (
+ char *Name)
+{
+ UINT32 SegCount;
+
+
+ if (!Name)
+ {
+ return;
+ }
+
+ /* Handle all Scope Prefix operators */
+
+ while (AcpiPsIsPrefixChar (ACPI_GET8 (Name)))
+ {
+ /* Append prefix character */
+
+ AcpiOsPrintf ("%1c", ACPI_GET8 (Name));
+ Name++;
+ }
+
+ switch (ACPI_GET8 (Name))
+ {
+ case 0:
+ SegCount = 0;
+ break;
+
+ case AML_DUAL_NAME_PREFIX:
+ SegCount = 2;
+ Name++;
+ break;
+
+ case AML_MULTI_NAME_PREFIX_OP:
+ SegCount = (UINT32) ACPI_GET8 (Name + 1);
+ Name += 2;
+ break;
+
+ default:
+ SegCount = 1;
+ break;
+ }
+
+ while (SegCount)
+ {
+ /* Append Name segment */
+
+ AcpiDmDumpName ((char *) Name);
+
+ SegCount--;
+ if (SegCount)
+ {
+ /* Not last name, append dot separator */
+
+ AcpiOsPrintf (".");
+ }
+ Name += ACPI_NAME_SIZE;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmDisplayPath
+ *
+ * PARAMETERS: Op - Named Op whose path is to be constructed
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Walk backwards from current scope and display the name
+ * of each previous level of scope up to the root scope
+ * (like "pwd" does with file systems)
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDisplayPath (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Prev;
+ ACPI_PARSE_OBJECT *Search;
+ UINT32 Name;
+ BOOLEAN DoDot = FALSE;
+ ACPI_PARSE_OBJECT *NamePath;
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ /* We are only interested in named objects */
+
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ if (!(OpInfo->Flags & AML_NSNODE))
+ {
+ return;
+ }
+
+ if (OpInfo->Flags & AML_CREATE)
+ {
+ /* Field creation - check for a fully qualified namepath */
+
+ if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
+ {
+ NamePath = AcpiPsGetArg (Op, 3);
+ }
+ else
+ {
+ NamePath = AcpiPsGetArg (Op, 2);
+ }
+
+ if ((NamePath) &&
+ (NamePath->Common.Value.String) &&
+ (NamePath->Common.Value.String[0] == '\\'))
+ {
+ AcpiDmNamestring (NamePath->Common.Value.String);
+ return;
+ }
+ }
+
+ Prev = NULL; /* Start with Root Node */
+
+ while (Prev != Op)
+ {
+ /* Search upwards in the tree to find scope with "prev" as its parent */
+
+ Search = Op;
+ for (; ;)
+ {
+ if (Search->Common.Parent == Prev)
+ {
+ break;
+ }
+
+ /* Go up one level */
+
+ Search = Search->Common.Parent;
+ }
+
+ if (Prev)
+ {
+ OpInfo = AcpiPsGetOpcodeInfo (Search->Common.AmlOpcode);
+ if (!(OpInfo->Flags & AML_FIELD))
+ {
+ /* Below root scope, append scope name */
+
+ if (DoDot)
+ {
+ /* Append dot */
+
+ AcpiOsPrintf (".");
+ }
+
+ if (OpInfo->Flags & AML_CREATE)
+ {
+ if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
+ {
+ NamePath = AcpiPsGetArg (Op, 3);
+ }
+ else
+ {
+ NamePath = AcpiPsGetArg (Op, 2);
+ }
+
+ if ((NamePath) &&
+ (NamePath->Common.Value.String))
+ {
+ AcpiDmDumpName (NamePath->Common.Value.String);
+ }
+ }
+ else
+ {
+ Name = AcpiPsGetName (Search);
+ AcpiDmDumpName ((char *) &Name);
+ }
+
+ DoDot = TRUE;
+ }
+ }
+ Prev = Search;
+ }
+}
+
+#endif
+
+
diff --git a/sys/contrib/dev/acpica/dmopcode.c b/sys/contrib/dev/acpica/dmopcode.c
new file mode 100644
index 0000000..4059848
--- /dev/null
+++ b/sys/contrib/dev/acpica/dmopcode.c
@@ -0,0 +1,602 @@
+/*******************************************************************************
+ *
+ * Module Name: dmopcode - AML disassembler, specific AML opcodes
+ * $Revision: 81 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 >= ACPI_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 ("<NULL OP PTR>");
+ 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:
+
+ 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 ("\"<NULL STATIC STRING PTR>\"");
+ }
+ 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, ",
+ 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/dmresrc.c b/sys/contrib/dev/acpica/dmresrc.c
new file mode 100644
index 0000000..5c8c52f
--- /dev/null
+++ b/sys/contrib/dev/acpica/dmresrc.c
@@ -0,0 +1,528 @@
+/*******************************************************************************
+ *
+ * Module Name: dmresrc.c - Resource Descriptor disassembly
+ * $Revision: 7 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 ("dbresrc")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmBitList
+ *
+ * PARAMETERS: Mask - 16-bit value corresponding to 16 interrupt
+ * or DMA values
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump a bit mask as a list of individual interrupt/dma levels.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmBitList (
+ UINT16 Mask)
+{
+ UINT32 i;
+ BOOLEAN Previous = FALSE;
+
+
+ /* Open the initializer list */
+
+ AcpiOsPrintf (") {");
+
+ /* Examine each bit */
+
+ for (i = 0; i < 16; i++)
+ {
+ /* Only interested in bits that are set to 1 */
+
+ if (Mask & 1)
+ {
+ if (Previous)
+ {
+ AcpiOsPrintf (",");
+ }
+ Previous = TRUE;
+ AcpiOsPrintf ("%d", i);
+ }
+
+ Mask >>= 1;
+ }
+
+ /* Close list */
+
+ AcpiOsPrintf ("}\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmResourceDescriptor
+ *
+ * PARAMETERS: Info - Curent parse tree walk info
+ * ByteData - Pointer to the byte list data
+ * ByteCount - Length of the byte list
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dump the contents of one ResourceTemplate descriptor.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmResourceDescriptor (
+ ACPI_OP_WALK_INFO *Info,
+ UINT8 *ByteData,
+ UINT32 ByteCount)
+{
+ ACPI_NATIVE_UINT CurrentByteOffset;
+ UINT8 CurrentByte;
+ UINT8 DescriptorId;
+ UINT32 Length;
+ void *DescriptorBody;
+ UINT32 Level;
+ BOOLEAN DependentFns = FALSE;
+
+
+ Level = Info->Level;
+
+ for (CurrentByteOffset = 0; CurrentByteOffset < ByteCount; )
+ {
+ CurrentByte = ByteData[CurrentByteOffset];
+ DescriptorBody = &ByteData[CurrentByteOffset];
+
+ if (CurrentByte & ACPI_RDESC_TYPE_LARGE)
+ {
+ DescriptorId = CurrentByte;
+ Length = (* (ACPI_CAST_PTR (UINT16, &ByteData[CurrentByteOffset + 1])));
+ CurrentByteOffset += 3;
+ }
+ else
+ {
+ DescriptorId = (UINT8) (CurrentByte & 0xF8);
+ Length = (ByteData[CurrentByteOffset] & 0x7);
+ CurrentByteOffset += 1;
+ }
+
+ CurrentByteOffset += (ACPI_NATIVE_UINT) Length;
+
+ /* Determine type of resource */
+
+ switch (DescriptorId)
+ {
+ /*
+ * "Small" type descriptors
+ */
+ case ACPI_RDESC_TYPE_IRQ_FORMAT:
+
+ AcpiDmIrqDescriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_DMA_FORMAT:
+
+ AcpiDmDmaDescriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_START_DEPENDENT:
+
+ /* Finish a previous StartDependentFns */
+
+ if (DependentFns)
+ {
+ Level--;
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("}\n");
+ }
+
+ AcpiDmStartDependentDescriptor (DescriptorBody, Length, Level);
+ DependentFns = TRUE;
+ Level++;
+ break;
+
+
+ case ACPI_RDESC_TYPE_END_DEPENDENT:
+
+ Level--;
+ DependentFns = FALSE;
+ AcpiDmEndDependentDescriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_IO_PORT:
+
+ AcpiDmIoDescriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_FIXED_IO_PORT:
+
+ AcpiDmFixedIoDescriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_SMALL_VENDOR:
+
+ AcpiDmVendorSmallDescriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_END_TAG:
+
+ if (DependentFns)
+ {
+ /*
+ * Close an open StartDependentDescriptor. This indicates a missing
+ * EndDependentDescriptor.
+ */
+ Level--;
+ DependentFns = FALSE;
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("}\n");
+ AcpiDmIndent (Level);
+
+ AcpiOsPrintf ("/*** Missing EndDependentFunctions descriptor */");
+
+ /*
+ * We could fix the problem, but then the ASL would not match the AML
+ * So, we don't do this:
+ * AcpiDmEndDependentDescriptor (DescriptorBody, Length, Level);
+ */
+ }
+ return;
+
+
+ /*
+ * "Large" type descriptors
+ */
+ case ACPI_RDESC_TYPE_MEMORY_24:
+
+ AcpiDmMemory24Descriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_GENERAL_REGISTER:
+
+ AcpiDmGenericRegisterDescriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_LARGE_VENDOR:
+
+ AcpiDmVendorLargeDescriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_MEMORY_32:
+
+ AcpiDmMemory32Descriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
+
+ AcpiDmFixedMem32Descriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
+
+ AcpiDmDwordDescriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
+
+ AcpiDmWordDescriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
+
+ AcpiDmInterruptDescriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
+
+ AcpiDmQwordDescriptor (DescriptorBody, Length, Level);
+ break;
+
+
+ default:
+ /*
+ * Anything else is unrecognized.
+ *
+ * Since the entire resource buffer has been already walked and
+ * validated, this is a very serious error indicating that someone
+ * overwrote the buffer.
+ */
+ AcpiOsPrintf ("/* Unknown Resource type (%X) */\n", DescriptorId);
+ return;
+ }
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmIsResourceDescriptor
+ *
+ * PARAMETERS: Op - Buffer Op to be examined
+ *
+ * RETURN: TRUE if this Buffer Op contains a valid resource
+ * descriptor.
+ *
+ * DESCRIPTION: Walk a byte list to determine if it consists of a valid set
+ * of resource descriptors. Nothing is output.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiDmIsResourceDescriptor (
+ ACPI_PARSE_OBJECT *Op)
+{
+ UINT8 *ByteData;
+ UINT32 ByteCount;
+ ACPI_PARSE_OBJECT *NextOp;
+ ACPI_NATIVE_UINT CurrentByteOffset;
+ UINT8 CurrentByte;
+ UINT8 DescriptorId;
+ UINT32 Length;
+
+
+ /* This op must be a buffer */
+
+ if (Op->Common.AmlOpcode != AML_BUFFER_OP)
+ {
+ return FALSE;
+ }
+
+ /* Get to the ByteData list */
+
+ NextOp = Op->Common.Value.Arg;
+ NextOp = NextOp->Common.Next;
+ if (!NextOp)
+ {
+ return (FALSE);
+ }
+
+ /* Extract the data pointer and data length */
+
+ ByteCount = NextOp->Common.Value.Integer32;
+ ByteData = NextOp->Named.Data;
+
+ /* The list must have a valid END_TAG */
+
+ if (ByteData[ByteCount-2] != (ACPI_RDESC_TYPE_END_TAG | 1))
+ {
+ return FALSE;
+ }
+
+ /*
+ * Walk the byte list. Abort on any invalid descriptor ID or
+ * or length
+ */
+ for (CurrentByteOffset = 0; CurrentByteOffset < ByteCount; )
+ {
+ CurrentByte = ByteData[CurrentByteOffset];
+
+ /* Large or small resource? */
+
+ if (CurrentByte & ACPI_RDESC_TYPE_LARGE)
+ {
+ DescriptorId = CurrentByte;
+ Length = (* (ACPI_CAST_PTR (UINT16, (&ByteData[CurrentByteOffset + 1]))));
+ CurrentByteOffset += 3;
+ }
+ else
+ {
+ DescriptorId = (UINT8) (CurrentByte & 0xF8);
+ Length = (ByteData[CurrentByteOffset] & 0x7);
+ CurrentByteOffset += 1;
+ }
+
+ CurrentByteOffset += (ACPI_NATIVE_UINT) Length;
+
+ /* Determine type of resource */
+
+ switch (DescriptorId)
+ {
+ /*
+ * "Small" type descriptors
+ */
+ case ACPI_RDESC_TYPE_IRQ_FORMAT:
+ case ACPI_RDESC_TYPE_DMA_FORMAT:
+ case ACPI_RDESC_TYPE_START_DEPENDENT:
+ case ACPI_RDESC_TYPE_END_DEPENDENT:
+ case ACPI_RDESC_TYPE_IO_PORT:
+ case ACPI_RDESC_TYPE_FIXED_IO_PORT:
+ case ACPI_RDESC_TYPE_SMALL_VENDOR:
+ /*
+ * "Large" type descriptors
+ */
+ case ACPI_RDESC_TYPE_MEMORY_24:
+ case ACPI_RDESC_TYPE_GENERAL_REGISTER:
+ case ACPI_RDESC_TYPE_LARGE_VENDOR:
+ case ACPI_RDESC_TYPE_MEMORY_32:
+ case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
+ case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
+ case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
+ case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
+ case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
+
+ /* Valid descriptor ID, keep going */
+
+ break;
+
+
+ case ACPI_RDESC_TYPE_END_TAG:
+
+ /* We must be at the end of the ByteList */
+
+ if (CurrentByteOffset != ByteCount)
+ {
+ return (FALSE);
+ }
+
+ /* All descriptors/lengths valid, this is a valid descriptor */
+
+ return (TRUE);
+
+
+ default:
+
+ /* Bad descriptor, abort */
+
+ return (FALSE);
+ }
+ }
+
+ /* Did not find an END_TAG, something seriously wrong */
+
+ return (FALSE);
+}
+
+
+#endif
diff --git a/sys/contrib/dev/acpica/dmresrcl.c b/sys/contrib/dev/acpica/dmresrcl.c
new file mode 100644
index 0000000..34993ed
--- /dev/null
+++ b/sys/contrib/dev/acpica/dmresrcl.c
@@ -0,0 +1,619 @@
+/*******************************************************************************
+ *
+ * Module Name: dmresrcl.c - "Large" Resource Descriptor disassembly
+ * $Revision: 10 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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"
+
+
+#ifdef ACPI_DISASSEMBLER
+
+#define _COMPONENT ACPI_CA_DEBUGGER
+ ACPI_MODULE_NAME ("dbresrcl")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmIoFlags
+ *
+ * PARAMETERS: Flags - Flag byte to be decoded
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode the flags specific to IO Address space descriptors
+ *
+ ******************************************************************************/
+
+void
+AcpiDmIoFlags (
+ UINT8 Flags)
+{
+ AcpiOsPrintf ("%s, %s, %s, %s,",
+ AcpiGbl_ConsumeDecode [(Flags & 1)],
+ AcpiGbl_MinDecode [(Flags & 0x4) >> 2],
+ AcpiGbl_MaxDecode [(Flags & 0x8) >> 3],
+ AcpiGbl_DECDecode [(Flags & 0x2) >> 1]);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmMemoryFlags
+ *
+ * PARAMETERS: Flags - Flag byte to be decoded
+ * SpecificFlags - "Specific" flag byte to be decoded
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode flags specific to Memory Address Space descriptors
+ *
+ ******************************************************************************/
+
+void
+AcpiDmMemoryFlags (
+ UINT8 Flags,
+ UINT8 SpecificFlags)
+{
+ AcpiOsPrintf ("%s, %s, %s, %s, %s, %s,",
+ AcpiGbl_ConsumeDecode [(Flags & 1)],
+ AcpiGbl_DECDecode [(Flags & 0x2) >> 1],
+ AcpiGbl_MinDecode [(Flags & 0x4) >> 2],
+ AcpiGbl_MaxDecode [(Flags & 0x8) >> 3],
+ AcpiGbl_MEMDecode [(SpecificFlags & 0x6) >> 1],
+ AcpiGbl_RWDecode [(SpecificFlags & 0x1)]);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmWordDescriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a Word Address Space descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmWordDescriptor (
+ ASL_WORD_ADDRESS_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("%s (",
+ AcpiGbl_WordDecode [(Resource->ResourceType & 3)]);
+
+ AcpiDmIoFlags (Resource->Flags);
+
+ if ((Resource->ResourceType & 0x3) == 1)
+ {
+ AcpiOsPrintf (" %s,",
+ AcpiGbl_RNGDecode [(Resource->SpecificFlags & 0x3)]);
+ }
+
+ /* The WORD values */
+
+ AcpiOsPrintf ("\n");
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%4.4X,\n",
+ (UINT32) Resource->Granularity);
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%4.4X,\n",
+ (UINT32) Resource->AddressMin);
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%4.4X,\n",
+ (UINT32) Resource->AddressMax);
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%4.4X,\n",
+ (UINT32) Resource->TranslationOffset);
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%4.4X",
+ (UINT32) Resource->AddressLength);
+
+ /* Optional fields */
+
+ if (Length > 13)
+ {
+ AcpiOsPrintf (", 0x%2.2X",
+ (UINT32) Resource->OptionalFields[0]);
+ }
+
+ if (Length > 14)
+ {
+ AcpiOsPrintf (", %s",
+ &Resource->OptionalFields[1]);
+ }
+ AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmDwordDescriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a DWord Address Space descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDwordDescriptor (
+ ASL_DWORD_ADDRESS_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("D%s (",
+ AcpiGbl_WordDecode [(Resource->ResourceType & 3)]);
+
+ if ((Resource->ResourceType & 0x3) == 1)
+ {
+ AcpiDmIoFlags (Resource->Flags);
+ AcpiOsPrintf (" %s,",
+ AcpiGbl_RNGDecode [(Resource->SpecificFlags & 0x3)]);
+ }
+ else
+ {
+ AcpiDmMemoryFlags (Resource->Flags, Resource->SpecificFlags);
+ }
+
+ /* The DWORD values */
+
+ AcpiOsPrintf ("\n");
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%8.8X,\n",
+ Resource->Granularity);
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%8.8X,\n",
+ Resource->AddressMin);
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%8.8X,\n",
+ Resource->AddressMax);
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%8.8X,\n",
+ Resource->TranslationOffset);
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%8.8X",
+ Resource->AddressLength);
+
+ /* Optional fields */
+
+ if (Length > 23)
+ {
+ AcpiOsPrintf (", 0x%2.2X",
+ Resource->OptionalFields[0]);
+ }
+ if (Length > 24)
+ {
+ AcpiOsPrintf (", %s",
+ &Resource->OptionalFields[1]);
+ }
+ AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmQwordDescriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a QWord Address Space descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmQwordDescriptor (
+ ASL_QWORD_ADDRESS_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("Q%s (",
+ AcpiGbl_WordDecode [(Resource->ResourceType & 3)]);
+
+ if ((Resource->ResourceType & 0x3) == 1)
+ {
+ AcpiDmIoFlags (Resource->Flags);
+ AcpiOsPrintf (" %s,",
+ AcpiGbl_RNGDecode [(Resource->SpecificFlags & 0x3)]);
+ }
+ else
+ {
+ AcpiDmMemoryFlags (Resource->Flags, Resource->SpecificFlags);
+ }
+
+ /* The QWORD values */
+
+ AcpiOsPrintf ("\n");
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%8.8X%8.8X,\n",
+ ACPI_HIDWORD (ACPI_GET_ADDRESS (Resource->Granularity)),
+ ACPI_LODWORD (ACPI_GET_ADDRESS (Resource->Granularity)));
+
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%8.8X%8.8X,\n",
+ ACPI_HIDWORD (ACPI_GET_ADDRESS (Resource->AddressMin)),
+ ACPI_LODWORD (ACPI_GET_ADDRESS (Resource->AddressMin)));
+
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%8.8X%8.8X,\n",
+ ACPI_HIDWORD (ACPI_GET_ADDRESS (Resource->AddressMax)),
+ ACPI_LODWORD (ACPI_GET_ADDRESS (Resource->AddressMax)));
+
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%8.8X%8.8X,\n",
+ ACPI_HIDWORD (ACPI_GET_ADDRESS (Resource->TranslationOffset)),
+ ACPI_LODWORD (ACPI_GET_ADDRESS (Resource->TranslationOffset)));
+
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%8.8X%8.8X",
+ ACPI_HIDWORD (ACPI_GET_ADDRESS (Resource->AddressLength)),
+ ACPI_LODWORD (ACPI_GET_ADDRESS (Resource->AddressLength)));
+
+ /* Optional fields */
+
+ if (Length > 43)
+ {
+ AcpiOsPrintf (", 0x%2.2X",
+ Resource->OptionalFields[0]);
+ }
+ if (Length > 44)
+ {
+ AcpiOsPrintf (", %s",
+ &Resource->OptionalFields[1]);
+ }
+
+ AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmMemory24Descriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a Memory24 descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmMemory24Descriptor (
+ ASL_MEMORY_24_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("Memory24 (%s, 0x%4.4X, 0x%4.4X, 0x%4.4X, 0x%4.4X)\n",
+ AcpiGbl_RWDecode [Resource->Information & 1],
+ (UINT32) Resource->AddressMin,
+ (UINT32) Resource->AddressMax,
+ (UINT32) Resource->Alignment,
+ (UINT32) Resource->RangeLength);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmMemory32Descriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a Memory32 descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmMemory32Descriptor (
+ ASL_MEMORY_32_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("Memory32 (%s, 0x%8.8X, 0x%8.8X, 0x%8.8X, 0x%8.8X)\n",
+ AcpiGbl_RWDecode [Resource->Information & 1],
+ Resource->AddressMin,
+ Resource->AddressMax,
+ Resource->Alignment,
+ Resource->RangeLength);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmFixedMem32Descriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a Fixed Memory32 descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmFixedMem32Descriptor (
+ ASL_FIXED_MEMORY_32_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("Memory32Fixed (%s, 0x%8.8X, 0x%8.8X)\n",
+ AcpiGbl_RWDecode [Resource->Information & 1],
+ Resource->BaseAddress,
+ Resource->RangeLength);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmGenericRegisterDescriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a Generic Register descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmGenericRegisterDescriptor (
+ ASL_GENERAL_REGISTER_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("Register (");
+
+ AcpiDmAddressSpace (Resource->AddressSpaceId);
+
+ AcpiOsPrintf ("0x%2.2X, 0x%2.2X, 0x%8.8X%8.8X)\n",
+ (UINT32) Resource->BitWidth,
+ (UINT32) Resource->BitOffset,
+ ACPI_HIDWORD (ACPI_GET_ADDRESS (Resource->Address)),
+ ACPI_LODWORD (ACPI_GET_ADDRESS (Resource->Address)));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmInterruptDescriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a extended Interrupt descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmInterruptDescriptor (
+ ASL_EXTENDED_XRUPT_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+ UINT32 i;
+ UINT8 *Rover;
+
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("Interrupt (%s, %s, %s, %s",
+ AcpiGbl_ConsumeDecode [(Resource->Flags & 1)],
+ AcpiGbl_HEDecode [(Resource->Flags >> 1) & 1],
+ AcpiGbl_LLDecode [(Resource->Flags >> 2) & 1],
+ AcpiGbl_SHRDecode [(Resource->Flags >> 3) & 1]);
+
+ /* Resource Index/Source, optional -- at end of descriptor */
+
+ if (Resource->Length > (UINT16) (4 * Resource->TableLength) + 2)
+ {
+ /* Get a pointer past the interrupt values */
+
+ Rover = ((UINT8 *) Resource) + ((4 * Resource->TableLength) + 5);
+
+ /* Resource Index */
+ /* Resource Source */
+
+ AcpiOsPrintf (", 0x%X, \"%s\"", (UINT32) Rover[0], (char *) &Rover[1]);
+ }
+
+ AcpiOsPrintf (")\n");
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("{\n");
+ for (i = 0; i < Resource->TableLength; i++)
+ {
+ AcpiDmIndent (Level + 1);
+ AcpiOsPrintf ("0x%8.8X,\n", (UINT32) Resource->InterruptNumber[i]);
+ }
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("}\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmVendorLargeDescriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a Vendor Large descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmVendorLargeDescriptor (
+ ASL_LARGE_VENDOR_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("VendorLong ()\n");
+ AcpiDmIndent (Level);
+
+ AcpiOsPrintf ("{\n");
+
+ AcpiDmDisasmByteList (Level + 1, (UINT8 *) Resource->VendorDefined, Length);
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("}\n");
+}
+
+
+#endif
+
diff --git a/sys/contrib/dev/acpica/dmresrcs.c b/sys/contrib/dev/acpica/dmresrcs.c
new file mode 100644
index 0000000..3c12a37
--- /dev/null
+++ b/sys/contrib/dev/acpica/dmresrcs.c
@@ -0,0 +1,352 @@
+/*******************************************************************************
+ *
+ * Module Name: dmresrcs.c - "Small" Resource Descriptor disassembly
+ * $Revision: 4 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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"
+
+
+#ifdef ACPI_DISASSEMBLER
+
+#define _COMPONENT ACPI_CA_DEBUGGER
+ ACPI_MODULE_NAME ("dbresrcs")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmIrqDescriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a IRQ descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmIrqDescriptor (
+ ASL_IRQ_FORMAT_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("%s (",
+ AcpiGbl_IrqDecode [Length & 1]);
+
+ if (Length & 1)
+ {
+ AcpiOsPrintf ("%s, %s, %s",
+ AcpiGbl_HEDecode [Resource->Flags & 1],
+ AcpiGbl_LLDecode [(Resource->Flags >> 3) & 1],
+ AcpiGbl_SHRDecode [(Resource->Flags >> 4) & 1]);
+ }
+
+ AcpiDmBitList (Resource->IrqMask);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmDmaDescriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a DMA descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDmaDescriptor (
+ ASL_DMA_FORMAT_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("DMA (%s, %s, %s",
+ AcpiGbl_TYPDecode [(Resource->Flags >> 5) & 3],
+ AcpiGbl_BMDecode [(Resource->Flags >> 2) & 1],
+ AcpiGbl_SIZDecode [(Resource->Flags >> 0) & 3]);
+
+ AcpiDmBitList (Resource->DmaChannelMask);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmIoDescriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode an IO descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmIoDescriptor (
+ ASL_IO_PORT_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("IO (%s, 0x%4.4X, 0x%4.4X, 0x%2.2X, 0x%2.2X)\n",
+ AcpiGbl_IoDecode [(Resource->Information & 1)],
+ (UINT32) Resource->AddressMin,
+ (UINT32) Resource->AddressMax,
+ (UINT32) Resource->Alignment,
+ (UINT32) Resource->Length);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmFixedIoDescriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a Fixed IO descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmFixedIoDescriptor (
+ ASL_FIXED_IO_PORT_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("FixedIO (0x%4.4X, 0x%2.2X)\n",
+ (UINT32) Resource->BaseAddress,
+ (UINT32) Resource->Length);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmStartDependentDescriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a Start Dependendent functions descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmStartDependentDescriptor (
+ ASL_START_DEPENDENT_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+
+ if (Length & 1)
+ {
+ AcpiOsPrintf ("StartDependentFn (0x%2.2X, 0x%2.2X)\n",
+ (UINT32) Resource->Flags & 3,
+ (UINT32) (Resource->Flags >> 2) & 3);
+ }
+ else
+ {
+ AcpiOsPrintf ("StartDependentFnNoPri ()\n");
+ }
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("{\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmEndDependentDescriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode an End Dependent functions descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmEndDependentDescriptor (
+ ASL_START_DEPENDENT_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("}\n");
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("EndDependentFn ()\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmVendorSmallDescriptor
+ *
+ * PARAMETERS: Resource - Pointer to the resource descriptor
+ * Length - Length of the descriptor in bytes
+ * Level - Current source code indentation level
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Decode a Vendor Small Descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmVendorSmallDescriptor (
+ ASL_SMALL_VENDOR_DESC *Resource,
+ UINT32 Length,
+ UINT32 Level)
+{
+
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("VendorShort () {");
+
+ AcpiDmDisasmByteList (0, (UINT8 *) Resource->VendorDefined, Length);
+ AcpiOsPrintf ("}\n");
+}
+
+#endif
+
+
diff --git a/sys/contrib/dev/acpica/dmutils.c b/sys/contrib/dev/acpica/dmutils.c
new file mode 100644
index 0000000..02d2072
--- /dev/null
+++ b/sys/contrib/dev/acpica/dmutils.c
@@ -0,0 +1,464 @@
+/*******************************************************************************
+ *
+ * Module Name: dmutils - AML disassembler utilities
+ * $Revision: 8 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 char *AcpiGbl_FENames[ACPI_NUM_FIELD_NAMES] =
+{
+ "skip",
+ "?access?"
+}; /* FE = Field Element */
+#endif
+
+
+const char *AcpiGbl_MatchOps[ACPI_NUM_MATCH_OPS] =
+{
+ "MTR",
+ "MEQ",
+ "MLE",
+ "MLT",
+ "MGE",
+ "MGT"
+};
+
+
+/* Access type decoding */
+
+const char *AcpiGbl_AccessTypes[ACPI_NUM_ACCESS_TYPES] =
+{
+ "AnyAcc",
+ "ByteAcc",
+ "WordAcc",
+ "DWordAcc",
+ "QWordAcc",
+ "BufferAcc",
+};
+
+
+/* Lock rule decoding */
+
+const char *AcpiGbl_LockRule[ACPI_NUM_LOCK_RULES] =
+{
+ "NoLock",
+ "Lock"
+};
+
+/* Update rule decoding */
+
+const char *AcpiGbl_UpdateRules[ACPI_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/dmwalk.c b/sys/contrib/dev/acpica/dmwalk.c
new file mode 100644
index 0000000..d73db16
--- /dev/null
+++ b/sys/contrib/dev/acpica/dmwalk.c
@@ -0,0 +1,920 @@
+/*******************************************************************************
+ *
+ * Module Name: dmwalk - AML disassembly tree walk
+ * $Revision: 9 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 ("dmwalk")
+
+
+#define DB_FULL_OP_INFO "%5.5X #%4.4hX "
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmDisassemble
+ *
+ * PARAMETERS: Origin - Starting object
+ * NumOpcodes - Max number of opcodes to be displayed
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Disassemble parser object and its children. This is the
+ * main entry point of the disassembler.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDisassemble (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Origin,
+ UINT32 NumOpcodes)
+{
+ ACPI_PARSE_OBJECT *Op = Origin;
+ ACPI_OP_WALK_INFO Info;
+
+
+ if (!Op)
+ {
+ return;
+ }
+
+ Info.Level = 0;
+ AcpiDmWalkParseTree (Op, AcpiDmDescendingOp, AcpiDmAscendingOp, &Info);
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmWalkParseTree
+ *
+ * PARAMETERS: DescendingCallback - Called during tree descent
+ * AscendingCallback - Called during tree ascent
+ * Context - To be passed to the callbacks
+ *
+ * RETURN: Status from callback(s)
+ *
+ * DESCRIPTION: Walk the entire parse tree.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmWalkParseTree (
+ ACPI_PARSE_OBJECT *Op,
+ ASL_WALK_CALLBACK DescendingCallback,
+ ASL_WALK_CALLBACK AscendingCallback,
+ void *Context)
+{
+ BOOLEAN NodePreviouslyVisited;
+ ACPI_PARSE_OBJECT *StartOp = Op;
+ ACPI_STATUS Status;
+ ACPI_PARSE_OBJECT *Next;
+ ACPI_OP_WALK_INFO *Info = Context;
+
+
+ Info->Level = 0;
+ NodePreviouslyVisited = FALSE;
+
+ while (Op)
+ {
+ if (NodePreviouslyVisited)
+ {
+ Status = AscendingCallback (Op, Info->Level, Context);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+ }
+ else
+ {
+ /*
+ * Let the callback process the node.
+ */
+ Status = DescendingCallback (Op, Info->Level, Context);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Visit children first, once */
+
+ Next = AcpiPsGetArg (Op, 0);
+ if (Next)
+ {
+ Info->Level++;
+ Op = Next;
+ continue;
+ }
+ }
+ else if (Status != AE_CTRL_DEPTH)
+ {
+ /* Exit immediately on any error */
+
+ return;
+ }
+ }
+
+ /* Terminate walk at start op */
+
+ if (Op == StartOp)
+ {
+ break;
+ }
+
+ /* No more children, re-visit this node */
+
+ if (!NodePreviouslyVisited)
+ {
+ NodePreviouslyVisited = TRUE;
+ continue;
+ }
+
+ /* No more children, visit peers */
+
+ if (Op->Common.Next)
+ {
+ Op = Op->Common.Next;
+ NodePreviouslyVisited = FALSE;
+ }
+ else
+ {
+ /* No peers, re-visit parent */
+
+ if (Info->Level != 0 )
+ {
+ Info->Level--;
+ }
+
+ Op = Op->Common.Parent;
+ NodePreviouslyVisited = TRUE;
+ }
+ }
+
+ /* If we get here, the walk completed with no errors */
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmBlockType
+ *
+ * PARAMETERS: Op - Object to be examined
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Type of block for this op (parens or braces)
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiDmBlockType (
+ ACPI_PARSE_OBJECT *Op)
+{
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ if (!Op)
+ {
+ return (BLOCK_NONE);
+ }
+
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_ELSE_OP:
+
+ return (BLOCK_BRACE);
+
+ case AML_METHOD_OP:
+ case AML_DEVICE_OP:
+ case AML_SCOPE_OP:
+ case AML_PROCESSOR_OP:
+ case AML_POWER_RES_OP:
+ case AML_THERMAL_ZONE_OP:
+ case AML_IF_OP:
+ case AML_WHILE_OP:
+ case AML_FIELD_OP:
+ case AML_INDEX_FIELD_OP:
+ case AML_BANK_FIELD_OP:
+
+ return (BLOCK_PAREN | BLOCK_BRACE);
+
+ case AML_BUFFER_OP:
+
+ if (Op->Common.DisasmOpcode == ACPI_DASM_UNICODE)
+ {
+ return (BLOCK_NONE);
+ }
+
+ /*lint -fallthrough */
+
+ case AML_PACKAGE_OP:
+ case AML_VAR_PACKAGE_OP:
+
+ return (BLOCK_PAREN | BLOCK_BRACE);
+
+ case AML_EVENT_OP:
+
+ return (BLOCK_PAREN);
+
+ default:
+
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ if (OpInfo->Flags & AML_HAS_ARGS)
+ {
+ return (BLOCK_PAREN);
+ }
+
+ return (BLOCK_NONE);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmListType
+ *
+ * PARAMETERS: Op - Object to be examined
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Type of block for this op (parens or braces)
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiDmListType (
+ ACPI_PARSE_OBJECT *Op)
+{
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ if (!Op)
+ {
+ return (BLOCK_NONE);
+ }
+
+ switch (Op->Common.AmlOpcode)
+ {
+
+ case AML_ELSE_OP:
+ case AML_METHOD_OP:
+ case AML_DEVICE_OP:
+ case AML_SCOPE_OP:
+ case AML_POWER_RES_OP:
+ case AML_PROCESSOR_OP:
+ case AML_THERMAL_ZONE_OP:
+ case AML_IF_OP:
+ case AML_WHILE_OP:
+ case AML_FIELD_OP:
+ case AML_INDEX_FIELD_OP:
+ case AML_BANK_FIELD_OP:
+
+ return (0);
+
+ case AML_BUFFER_OP:
+ case AML_PACKAGE_OP:
+ case AML_VAR_PACKAGE_OP:
+
+ return (BLOCK_COMMA_LIST);
+
+ default:
+
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ if (OpInfo->Flags & AML_HAS_ARGS)
+ {
+ return (BLOCK_COMMA_LIST);
+ }
+
+ return (BLOCK_NONE);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmDescendingOp
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: First visitation of a parse object during tree descent.
+ * Decode opcode name and begin parameter list(s), if any.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDmDescendingOp (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ ACPI_OP_WALK_INFO *Info = Context;
+ const ACPI_OPCODE_INFO *OpInfo;
+ UINT32 Name;
+ ACPI_PARSE_OBJECT *NextOp;
+
+
+ if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE)
+ {
+ /* Ignore this op -- it was handled elsewhere */
+
+ return (AE_CTRL_DEPTH);
+ }
+
+
+ if (Level == 0)
+ {
+ /* In verbose mode, print the AML offset, opcode and depth count */
+
+ VERBOSE_PRINT ((DB_FULL_OP_INFO, (UINT32) Op->Common.AmlOffset,
+ Op->Common.AmlOpcode));
+
+ if (Op->Common.AmlOpcode == AML_SCOPE_OP)
+ {
+ AcpiOsPrintf ("{\n");
+ return (AE_OK);
+ }
+ }
+ else if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
+ (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) &&
+ (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
+ {
+ /* This is a first-level element of a term list, indent a new line */
+
+ AcpiDmIndent (Level);
+ }
+
+ /* Print the opcode name */
+
+ AcpiDmDisassembleOneOp (NULL, Info, Op);
+
+ if ((Op->Common.AmlOpcode == AML_NAME_OP) ||
+ (Op->Common.AmlOpcode == AML_RETURN_OP))
+ {
+ Info->Level--;
+ }
+
+ /*
+ * Start the opcode argument list if necessary
+ */
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+
+ if ((OpInfo->Flags & AML_HAS_ARGS) ||
+ (Op->Common.AmlOpcode == AML_EVENT_OP))
+ {
+ /* This opcode has an argument list */
+
+ if (AcpiDmBlockType (Op) & BLOCK_PAREN)
+ {
+ AcpiOsPrintf (" (");
+ }
+
+ /*
+ * If this is a named opcode, print the associated name value
+ */
+ if (OpInfo->Flags & AML_NAMED)
+ {
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_ALIAS_OP:
+
+ NextOp = AcpiPsGetDepthNext (NULL, Op);
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+ AcpiDmNamestring (NextOp->Common.Value.Name);
+ AcpiOsPrintf (", ");
+
+ /*lint -fallthrough */
+
+ default:
+
+ Name = AcpiPsGetName (Op);
+ if (Op->Named.Path)
+ {
+ AcpiDmNamestring ((char *) Op->Named.Path);
+ }
+ else
+ {
+ AcpiDmDumpName ((char *) &Name);
+ }
+
+
+ if (Op->Common.AmlOpcode != AML_INT_NAMEDFIELD_OP)
+ {
+ AcpiDmValidateName ((char *) &Name, Op);
+ if (AcpiGbl_DbOpt_verbose)
+ {
+ (void) AcpiPsDisplayObjectPathname (NULL, Op);
+ }
+ }
+ break;
+ }
+
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_METHOD_OP:
+
+ AcpiDmMethodFlags (Op);
+ AcpiOsPrintf (")");
+ break;
+
+
+ case AML_NAME_OP:
+
+ /* Check for _HID and related EISAID() */
+
+ AcpiIsEisaId (Op);
+ AcpiOsPrintf (", ");
+ break;
+
+
+ case AML_REGION_OP:
+
+ AcpiDmRegionFlags (Op);
+ break;
+
+
+ case AML_POWER_RES_OP:
+
+ /* Mark the next two Ops as part of the parameter list */
+
+ AcpiOsPrintf (", ");
+ NextOp = AcpiPsGetDepthNext (NULL, Op);
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;
+
+ NextOp = NextOp->Common.Next;
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;
+ return (AE_OK);
+
+
+ case AML_PROCESSOR_OP:
+
+ /* Mark the next three Ops as part of the parameter list */
+
+ AcpiOsPrintf (", ");
+ NextOp = AcpiPsGetDepthNext (NULL, Op);
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;
+
+ NextOp = NextOp->Common.Next;
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;
+
+ NextOp = NextOp->Common.Next;
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;
+ return (AE_OK);
+
+
+ case AML_MUTEX_OP:
+
+ AcpiOsPrintf (", ");
+ return (AE_OK);
+
+
+ case AML_EVENT_OP:
+ case AML_ALIAS_OP:
+
+ return (AE_OK);
+
+
+ case AML_SCOPE_OP:
+ case AML_DEVICE_OP:
+ case AML_THERMAL_ZONE_OP:
+
+ AcpiOsPrintf (")");
+ break;
+
+
+ default:
+
+ AcpiOsPrintf ("*** Unhandled named opcode\n");
+ break;
+ }
+ }
+
+ else switch (Op->Common.AmlOpcode)
+ {
+ case AML_FIELD_OP:
+ case AML_BANK_FIELD_OP:
+ case AML_INDEX_FIELD_OP:
+
+ Info->BitOffset = 0;
+
+ /* Name of the parent OperationRegion */
+
+ NextOp = AcpiPsGetDepthNext (NULL, Op);
+ AcpiDmNamestring (NextOp->Common.Value.Name);
+ AcpiOsPrintf (", ");
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_BANK_FIELD_OP:
+
+ /* Namestring */
+
+ NextOp = AcpiPsGetDepthNext (NULL, NextOp);
+ AcpiDmNamestring (NextOp->Common.Value.Name);
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+ AcpiOsPrintf (", ");
+
+
+ NextOp = NextOp->Common.Next;
+ AcpiDmDisassembleOneOp (NULL, Info, NextOp);
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+ AcpiOsPrintf (", ");
+ break;
+
+ case AML_INDEX_FIELD_OP:
+
+ /* Namestring */
+
+ NextOp = AcpiPsGetDepthNext (NULL, NextOp);
+ AcpiDmNamestring (NextOp->Common.Value.Name);
+ AcpiOsPrintf (", ");
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+ break;
+
+ default:
+
+ break;
+ }
+
+ AcpiDmFieldFlags (NextOp);
+ break;
+
+
+ case AML_BUFFER_OP:
+
+ /* The next op is the size parameter */
+
+ NextOp = AcpiPsGetDepthNext (NULL, Op);
+ if (!NextOp)
+ {
+ /* Single-step support */
+
+ return (AE_OK);
+ }
+
+ if (Op->Common.DisasmOpcode == ACPI_DASM_RESOURCE)
+ {
+ /*
+ * We have a resource list. Don't need to output
+ * the buffer size Op. Open up a new block
+ */
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+ NextOp = NextOp->Common.Next;
+ AcpiOsPrintf (")\n");
+ AcpiDmIndent (Info->Level);
+ AcpiOsPrintf ("{\n");
+ return (AE_OK);
+ }
+
+ /* Normal Buffer, mark size as in the parameter list */
+
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;
+ return (AE_OK);
+
+
+ case AML_VAR_PACKAGE_OP:
+ case AML_IF_OP:
+ case AML_WHILE_OP:
+
+ /* The next op is the size or predicate parameter */
+
+ NextOp = AcpiPsGetDepthNext (NULL, Op);
+ if (NextOp)
+ {
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;
+ }
+ return (AE_OK);
+
+
+ case AML_PACKAGE_OP:
+
+ /* The next op is the size or predicate parameter */
+
+ NextOp = AcpiPsGetDepthNext (NULL, Op);
+ if (NextOp)
+ {
+ NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;
+ }
+ return (AE_OK);
+
+
+ case AML_MATCH_OP:
+
+ AcpiDmMatchOp (Op);
+ break;
+
+
+ default:
+
+ break;
+ }
+
+ if (AcpiDmBlockType (Op) & BLOCK_BRACE)
+ {
+ AcpiOsPrintf ("\n");
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("{\n");
+ }
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmAscendingOp
+ *
+ * PARAMETERS: ASL_WALK_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Second visitation of a parse object, during ascent of parse
+ * tree. Close out any parameter lists and complete the opcode.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDmAscendingOp (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Level,
+ void *Context)
+{
+ ACPI_OP_WALK_INFO *Info = Context;
+
+
+ if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE)
+ {
+ /* Ignore this op -- it was handled elsewhere */
+
+ return (AE_OK);
+ }
+
+ if ((Level == 0) && (Op->Common.AmlOpcode == AML_SCOPE_OP))
+ {
+ /* Indicates the end of the current descriptor block (table) */
+
+ AcpiOsPrintf ("}\n\n");
+ return (AE_OK);
+ }
+
+ switch (AcpiDmBlockType (Op))
+ {
+ case BLOCK_PAREN:
+
+ /* Completed an op that has arguments, add closing paren */
+
+ AcpiOsPrintf (")");
+
+ /* Could be a nested operator, check if comma required */
+
+ if (!AcpiDmCommaIfListMember (Op))
+ {
+ if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
+ (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) &&
+ (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
+ {
+ /* This is a first-level element of a term list, start a new line */
+
+ AcpiOsPrintf ("\n");
+ }
+ }
+ break;
+
+
+ case BLOCK_BRACE:
+ case (BLOCK_BRACE | BLOCK_PAREN):
+
+ /* Completed an op that has a term list, add closing brace */
+
+ if (Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST)
+ {
+ AcpiOsPrintf ("}");
+ }
+ else
+ {
+ AcpiDmIndent (Level);
+ AcpiOsPrintf ("}");
+ }
+
+ AcpiDmCommaIfListMember (Op);
+
+ if (AcpiDmBlockType (Op->Common.Parent) != BLOCK_PAREN)
+ {
+ AcpiOsPrintf ("\n");
+ if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST))
+ {
+ if ((Op->Common.AmlOpcode == AML_IF_OP) &&
+ (Op->Common.Next) &&
+ (Op->Common.Next->Common.AmlOpcode == AML_ELSE_OP))
+ {
+ break;
+ }
+
+ if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
+ (!Op->Common.Next))
+ {
+ break;
+ }
+ AcpiOsPrintf ("\n");
+ }
+ }
+ break;
+
+
+ case BLOCK_NONE:
+ default:
+
+ /* Could be a nested operator, check if comma required */
+
+ if (!AcpiDmCommaIfListMember (Op))
+ {
+ if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
+ (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) &&
+ (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
+ {
+ /* This is a first-level element of a term list, start a new line */
+
+ AcpiOsPrintf ("\n");
+ }
+ }
+ else if (Op->Common.Parent)
+ {
+ switch (Op->Common.Parent->Common.AmlOpcode)
+ {
+ case AML_PACKAGE_OP:
+ case AML_VAR_PACKAGE_OP:
+
+ if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST))
+ {
+ AcpiOsPrintf ("\n");
+ }
+ break;
+
+ default:
+
+ break;
+ }
+ }
+ break;
+ }
+
+ if (Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)
+ {
+ if ((Op->Common.Next) &&
+ (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST))
+ {
+ return (AE_OK);
+ }
+
+ /*
+ * Just completed a parameter node for something like "Buffer (param)".
+ * Close the paren and open up the term list block with a brace
+ */
+ if (Op->Common.Next)
+ {
+ AcpiOsPrintf (")\n");
+ AcpiDmIndent (Level - 1);
+ AcpiOsPrintf ("{\n");
+ }
+ else
+ {
+ Op->Common.Parent->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST;
+ AcpiOsPrintf (") {");
+ }
+ }
+
+ if ((Op->Common.AmlOpcode == AML_NAME_OP) ||
+ (Op->Common.AmlOpcode == AML_RETURN_OP))
+ {
+ Info->Level++;
+ }
+ return (AE_OK);
+}
+
+
+#endif /* ACPI_DISASSEMBLER */
diff --git a/sys/contrib/dev/acpica/dsfield.c b/sys/contrib/dev/acpica/dsfield.c
new file mode 100644
index 0000000..58d35c4
--- /dev/null
+++ b/sys/contrib/dev/acpica/dsfield.c
@@ -0,0 +1,698 @@
+/******************************************************************************
+ *
+ * Module Name: dsfield - Dispatcher field routines
+ * $Revision: 71 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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,
+ 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,
+ (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 = 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 = ACPI_TYPE_LOCAL_REGION_FIELD;
+ break;
+
+ case AML_BANK_FIELD_OP:
+ Arg = AcpiPsGetArg (Op, 4);
+ Type = ACPI_TYPE_LOCAL_BANK_FIELD;
+ break;
+
+ case AML_INDEX_FIELD_OP:
+ Arg = AcpiPsGetArg (Op, 3);
+ 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,
+ (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 (Field) (must already exist) */
+
+ Arg = Arg->Common.Next;
+ 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);
+ }
+
+ /* 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 = 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,
+ 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 = 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/dsinit.c b/sys/contrib/dev/acpica/dsinit.c
new file mode 100644
index 0000000..543621b
--- /dev/null
+++ b/sys/contrib/dev/acpica/dsinit.c
@@ -0,0 +1,316 @@
+/******************************************************************************
+ *
+ * Module Name: dsinit - Object initialization namespace walk
+ * $Revision: 6 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __DSINIT_C__
+
+#include "acpi.h"
+#include "acdispat.h"
+#include "acnamesp.h"
+
+#define _COMPONENT ACPI_DISPATCHER
+ ACPI_MODULE_NAME ("dsinit")
+
+
+/*******************************************************************************
+ *
+ * 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++;
+
+ /* Print a dot for each method unless we are going to print the entire pathname */
+
+ if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
+ {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
+ }
+
+ /*
+ * 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_INIT, "Parsing all Control 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_INIT,
+ "\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);
+}
+
+
diff --git a/sys/contrib/dev/acpica/dsmethod.c b/sys/contrib/dev/acpica/dsmethod.c
new file mode 100644
index 0000000..3916387
--- /dev/null
+++ b/sys/contrib/dev/acpica/dsmethod.c
@@ -0,0 +1,649 @@
+/******************************************************************************
+ *
+ * Module Name: dsmethod - Parser/Interpreter interface - control method parsing
+ * $Revision: 90 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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,
+ 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
new file mode 100644
index 0000000..61a4fc5
--- /dev/null
+++ b/sys/contrib/dev/acpica/dsmthdat.c
@@ -0,0 +1,787 @@
+/*******************************************************************************
+ *
+ * Module Name: dsmthdat - control method arguments and local variables
+ * $Revision: 69 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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"
+#include "acinterp.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 < ACPI_METHOD_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 < ACPI_METHOD_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 < ACPI_METHOD_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 < ACPI_METHOD_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 < ACPI_METHOD_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 > ACPI_METHOD_MAX_LOCAL)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Local index %d is invalid (max %d)\n",
+ Index, ACPI_METHOD_MAX_LOCAL));
+ return_ACPI_STATUS (AE_AML_INVALID_INDEX);
+ }
+
+ /* Return a pointer to the pseudo-node */
+
+ *Node = &WalkState->LocalVariables[Index];
+ break;
+
+ case AML_ARG_OP:
+
+ if (Index > ACPI_METHOD_MAX_ARG)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Arg index %d is invalid (max %d)\n",
+ Index, ACPI_METHOD_MAX_ARG));
+ return_ACPI_STATUS (AE_AML_INVALID_INDEX);
+ }
+
+ /* 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.
+ * Note: There is no "implicit conversion" for locals.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDsMethodDataSetValue (
+ UINT16 Opcode,
+ UINT32 Index,
+ ACPI_OPERAND_OBJECT *Object,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_OPERAND_OBJECT *NewDesc = Object;
+
+
+ ACPI_FUNCTION_TRACE ("DsMethodDataSetValue");
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "obj %p op %X, ref count = %d [%s]\n", Object,
+ Opcode, Object->Common.ReferenceCount,
+ AcpiUtGetTypeName (Object->Common.Type)));
+
+ /* Get the namespace node for the arg/local */
+
+ Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * If the object has just been created and is not attached to anything,
+ * (the reference count is 1), then we can just store it directly into
+ * the arg/local. Otherwise, we must copy it.
+ */
+ if (Object->Common.ReferenceCount > 1)
+ {
+ Status = AcpiUtCopyIobjectToIobject (Object, &NewDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object Copied %p, new %p\n",
+ Object, NewDesc));
+ }
+ else
+ {
+ /* Increment ref count so object can't be deleted while installed */
+
+ AcpiUtAddReference (NewDesc);
+ }
+
+ /* Install the object */
+
+ Node->Object = NewDesc;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * 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 == 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));
+
+ /*
+ * Store this object to the Node
+ * (perform the indirect store)
+ */
+ Status = AcpiExStoreObjectToNode (ObjDesc,
+ CurrentObjDesc->Reference.Object, WalkState);
+ 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
new file mode 100644
index 0000000..aa455c5
--- /dev/null
+++ b/sys/contrib/dev/acpica/dsobject.c
@@ -0,0 +1,720 @@
+/******************************************************************************
+ *
+ * Module Name: dsobject - Dispatcher object management routines
+ * $Revision: 114 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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: 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"));
+ }
+ else
+ {
+ 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 its 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 = (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 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
new file mode 100644
index 0000000..a2ec1dd
--- /dev/null
+++ b/sys/contrib/dev/acpica/dsopcode.c
@@ -0,0 +1,1263 @@
+/******************************************************************************
+ *
+ * Module Name: dsopcode - Dispatcher Op Region support and handling of
+ * "control" opcodes
+ * $Revision: 85 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 (ACPI_TYPE_BUFFER_FIELD, Node, NULL));
+ 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 (ACPI_TYPE_REGION, Node, NULL));
+
+ 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]) == 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
new file mode 100644
index 0000000..11a140a
--- /dev/null
+++ b/sys/contrib/dev/acpica/dsutils.c
@@ -0,0 +1,720 @@
+/*******************************************************************************
+ *
+ * Module Name: dsutils - Dispatcher utilities
+ * $Revision: 99 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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;
+ 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 == 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
new file mode 100644
index 0000000..9e80c37
--- /dev/null
+++ b/sys/contrib/dev/acpica/dswexec.c
@@ -0,0 +1,780 @@
+/******************************************************************************
+ *
+ * Module Name: dswexec - Dispatcher method execution callbacks;
+ * dispatch to interpreter.
+ * $Revision: 98 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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;
+
+
+ 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 */
+
+ 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);
+ }
+
+#if _UNDER_DEVELOPMENT
+
+ if (WalkState->ParserState.Aml == WalkState->ParserState.AmlEnd)
+ {
+ AcpiDbMethodEnd (WalkState);
+ }
+#endif
+
+ /* 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
new file mode 100644
index 0000000..bc9a308
--- /dev/null
+++ b/sys/contrib/dev/acpica/dswload.c
@@ -0,0 +1,1063 @@
+/******************************************************************************
+ *
+ * Module Name: dswload - Dispatcher namespace load callbacks
+ * $Revision: 83 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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;
+ 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)));
+
+ switch (WalkState->Opcode)
+ {
+ case AML_SCOPE_OP:
+
+ /*
+ * 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);
+ }
+
+ /*
+ * Check to make sure that the target is
+ * one of the opcodes that actually opens a scope
+ */
+ switch (Node->Type)
+ {
+ 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:
+
+ /* 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;
+ }
+ }
+
+ if (Op->Common.AmlOpcode == AML_METHOD_OP)
+ {
+ /*
+ * MethodOp PkgLength NameString MethodFlags TermList
+ *
+ * Note: We must create the method node/object pair as soon as we
+ * see the method declaration. This allows later pass1 parsing
+ * of invocations of the method (need to know the number of
+ * arguments.)
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+ "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
+ WalkState, Op, Op->Named.Node));
+
+ if (!AcpiNsGetAttachedObject (Op->Named.Node))
+ {
+ WalkState->Operands[0] = (void *) Op->Named.Node;
+ WalkState->NumOperands = 1;
+
+ Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
+ if (ACPI_SUCCESS (Status))
+ {
+ Status = AcpiExCreateMethod (Op->Named.Data,
+ Op->Named.Length, WalkState);
+ }
+ WalkState->Operands[0] = NULL;
+ WalkState->NumOperands = 0;
+
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+ }
+
+ /* 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;
+ 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 = (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));
+
+
+ switch (WalkState->Opcode)
+ {
+ case AML_FIELD_OP:
+ case AML_BANK_FIELD_OP:
+ case AML_INDEX_FIELD_OP:
+
+ Node = NULL;
+ Status = AE_OK;
+ 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));
+ break;
+
+ case AML_SCOPE_OP:
+
+ /*
+ * The Path is an object reference to an existing object. Don't enter the
+ * name into the namespace, but look it up for use later
+ */
+ Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
+ 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_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:
+
+ /* 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))
+ {
+ goto Cleanup;
+ }
+ }
+
+ /*
+ * 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)
+ {
+#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 */
+ /* Note: Method objects were already created in Pass 1 */
+ 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
new file mode 100644
index 0000000..fb6f579
--- /dev/null
+++ b/sys/contrib/dev/acpica/dswscope.c
@@ -0,0 +1,315 @@
+/******************************************************************************
+ *
+ * Module Name: dswscope - Scope stack manipulation
+ * $Revision: 57 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "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 (!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,
+ "[%.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
new file mode 100644
index 0000000..783dcab
--- /dev/null
+++ b/sys/contrib/dev/acpica/dswstate.c
@@ -0,0 +1,1200 @@
+/******************************************************************************
+ *
+ * Module Name: dswstate - Dispatcher parse tree walk management routines
+ * $Revision: 75 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 >= ACPI_OBJ_NUM_OPERANDS)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Index out of range: %X Obj=%p State=%p Num=%X\n",
+ Index, Object, WalkState, State->Results.NumResults));
+ return (AE_BAD_PARAMETER);
+ }
+
+ if (!Object)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Null Object! Index=%X Obj=%p State=%p Num=%X\n",
+ Index, Object, WalkState, State->Results.NumResults));
+ return (AE_BAD_PARAMETER);
+ }
+
+ State->Results.ObjDesc [Index] = Object;
+ State->Results.NumResults++;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
+ Object, Object ? AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object) : "NULL",
+ WalkState, State->Results.NumResults, WalkState->CurrentResult));
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: 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 >= ACPI_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)
+{
+ ACPI_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 = ACPI_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",
+ (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)
+{
+ ACPI_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 == ACPI_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: 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: 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 < ACPI_OBJ_NUM_OPERANDS; i++)
+ {
+ if (WalkState->Operands[i])
+ {
+ AcpiUtRemoveReference (WalkState->Operands[i]);
+ WalkState->Operands[i] = NULL;
+ }
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDsObjStackPush
+ *
+ * PARAMETERS: Object - Object to push
+ * 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 >= ACPI_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[(ACPI_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, "Current WalkState %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, ACPI_METHOD_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
new file mode 100644
index 0000000..76e8aa2
--- /dev/null
+++ b/sys/contrib/dev/acpica/evevent.c
@@ -0,0 +1,381 @@
+/******************************************************************************
+ *
+ * Module Name: evevent - Fixed Event handling and dispatch
+ * $Revision: 108 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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"
+
+#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 occurring
+ * before handers are installed.
+ */
+ Status = AcpiEvFixedEventInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR ((
+ "Unable to initialize fixed events, %s\n",
+ AcpiFormatException (Status)));
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiEvGpeInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR ((
+ "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 interrupt handlers for the SCI and Global Lock
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvHandlerInitialize (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("EvHandlerInitialize");
+
+
+ /* Install the SCI handler */
+
+ Status = AcpiEvInstallSciHandler ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR ((
+ "Unable to install System Control Interrupt Handler, %s\n",
+ AcpiFormatException (Status)));
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Install the handler for the Global Lock */
+
+ Status = AcpiEvInitGlobalLockHandler ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR ((
+ "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)
+{
+ ACPI_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;
+ ACPI_NATIVE_UINT 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 ((UINT32) 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));
+}
+
+
diff --git a/sys/contrib/dev/acpica/evgpe.c b/sys/contrib/dev/acpica/evgpe.c
new file mode 100644
index 0000000..d19058c
--- /dev/null
+++ b/sys/contrib/dev/acpica/evgpe.c
@@ -0,0 +1,479 @@
+/******************************************************************************
+ *
+ * Module Name: evgpe - General Purpose Event handling and dispatch
+ * $Revision: 12 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 ("evgpe")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvGetGpeEventInfo
+ *
+ * PARAMETERS: GpeNumber - Raw GPE number
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Returns the EventInfo struct
+ * associated with this GPE.
+ *
+ * TBD: this function will go away when full support of GPE block devices
+ * is implemented!
+ *
+ ******************************************************************************/
+
+ACPI_GPE_EVENT_INFO *
+AcpiEvGetGpeEventInfo (
+ UINT32 GpeNumber)
+{
+ ACPI_GPE_BLOCK_INFO *GpeBlock;
+
+
+ /* Examine GPE Block 0 */
+
+ GpeBlock = AcpiGbl_GpeBlockListHead;
+ if (!GpeBlock)
+ {
+ return (NULL);
+ }
+
+ if ((GpeNumber >= GpeBlock->BlockBaseNumber) &&
+ (GpeNumber < GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8)))
+ {
+ return (&GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]);
+ }
+
+ /* Examine GPE Block 1 */
+
+ GpeBlock = GpeBlock->Next;
+ if (!GpeBlock)
+ {
+ return (NULL);
+ }
+
+ if ((GpeNumber >= GpeBlock->BlockBaseNumber) &&
+ (GpeNumber < GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8)))
+ {
+ return (&GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]);
+ }
+
+ return (NULL);
+}
+
+/*******************************************************************************
+ *
+ * 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_GPE_BLOCK_INFO *GpeBlock;
+
+
+ ACPI_FUNCTION_NAME ("EvGpeDetect");
+
+
+ /* Examine all GPE blocks attached to this interrupt level */
+
+ GpeBlock = AcpiGbl_GpeBlockListHead;
+ while (GpeBlock)
+ {
+ /*
+ * Read all of the 8-bit GPE status and enable registers
+ * in this GPE block, saving all of them.
+ * Find all currently active GP events.
+ */
+ for (i = 0; i < GpeBlock->RegisterCount; i++)
+ {
+ /* Get the next status/enable pair */
+
+ GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
+
+ Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &InValue,
+ &GpeRegisterInfo->StatusAddress, 0);
+ GpeRegisterInfo->Status = (UINT8) InValue;
+ if (ACPI_FAILURE (Status))
+ {
+ return (ACPI_INTERRUPT_NOT_HANDLED);
+ }
+
+ Status = AcpiHwLowLevelRead (ACPI_GPE_REGISTER_WIDTH, &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 < ACPI_GPE_REGISTER_WIDTH; j++, BitMask <<= 1)
+ {
+ /* Examine one GPE bit */
+
+ if (EnabledStatusByte & BitMask)
+ {
+ /*
+ * Found an active GPE. Dispatch the event to a handler
+ * or method.
+ */
+ IntStatus |= AcpiEvGpeDispatch (
+ &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) +j]);
+ }
+ }
+ }
+
+ GpeBlock = GpeBlock->Next;
+ }
+
+ return (IntStatus);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvAsynchExecuteGpeMethod
+ *
+ * PARAMETERS: GpeEventInfo - Info for this GPE
+ *
+ * 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)
+{
+ ACPI_GPE_EVENT_INFO *GpeEventInfo = (void *) Context;
+ UINT32 GpeNumber = 0;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("EvAsynchExecuteGpeMethod");
+
+
+ /*
+ * 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;
+ }
+
+ Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+ if (ACPI_FAILURE (Status))
+ {
+ return_VOID;
+ }
+
+ if (GpeEventInfo->MethodNode)
+ {
+ /*
+ * Invoke the GPE Method (_Lxx, _Exx):
+ * (Evaluate the _Lxx/_Exx control method that corresponds to this GPE.)
+ */
+ Status = AcpiNsEvaluateByHandle (GpeEventInfo->MethodNode, NULL, NULL);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("%s while evaluating method [%4.4s] for GPE[%2.2X]\n",
+ AcpiFormatException (Status),
+ GpeEventInfo->MethodNode->Name.Ascii, GpeNumber));
+ }
+ }
+
+ if (GpeEventInfo->Type & ACPI_EVENT_LEVEL_TRIGGERED)
+ {
+ /*
+ * GPE is level-triggered, we clear the GPE status bit after handling
+ * the event.
+ */
+ Status = AcpiHwClearGpe (GpeEventInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ return_VOID;
+ }
+ }
+
+ /* Enable this GPE */
+
+ (void) AcpiHwEnableGpe (GpeEventInfo);
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvGpeDispatch
+ *
+ * PARAMETERS: GpeEventInfo - info for this GPE
+ *
+ * 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 (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo)
+{
+ UINT32 GpeNumber = 0; /* TBD: remove */
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("EvGpeDispatch");
+
+
+ /*
+ * If edge-triggered, clear the GPE status bit now. Note that
+ * level-triggered events are cleared after the GPE is serviced.
+ */
+ if (GpeEventInfo->Type & ACPI_EVENT_EDGE_TRIGGERED)
+ {
+ Status = AcpiHwClearGpe (GpeEventInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("AcpiEvGpeDispatch: Unable to clear GPE[%2.2X]\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 (GpeEventInfo->Handler)
+ {
+ /* Invoke the installed handler (at interrupt level) */
+
+ GpeEventInfo->Handler (GpeEventInfo->Context);
+ }
+ else if (GpeEventInfo->MethodNode)
+ {
+ /*
+ * Disable GPE, so it doesn't keep firing before the method has a
+ * chance to run.
+ */
+ Status = AcpiHwDisableGpe (GpeEventInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("AcpiEvGpeDispatch: Unable to disable GPE[%2.2X]\n",
+ GpeNumber));
+ return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
+ }
+
+ /*
+ * Execute the method associated with the GPE.
+ */
+ if (ACPI_FAILURE (AcpiOsQueueForExecution (OSD_PRIORITY_GPE,
+ AcpiEvAsynchExecuteGpeMethod,
+ GpeEventInfo)))
+ {
+ ACPI_REPORT_ERROR ((
+ "AcpiEvGpeDispatch: Unable to queue handler for GPE[%2.2X], event is disabled\n",
+ GpeNumber));
+ }
+ }
+ else
+ {
+ /* No handler or method to run! */
+
+ ACPI_REPORT_ERROR ((
+ "AcpiEvGpeDispatch: No handler or method for GPE[%2.2X], 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 (GpeEventInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("AcpiEvGpeDispatch: Unable to disable GPE[%2.2X]\n",
+ GpeNumber));
+ return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
+ }
+ }
+
+ /*
+ * It is now safe to clear level-triggered evnets.
+ */
+ if (GpeEventInfo->Type & ACPI_EVENT_LEVEL_TRIGGERED)
+ {
+ Status = AcpiHwClearGpe (GpeEventInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("AcpiEvGpeDispatch: Unable to clear GPE[%2.2X]\n",
+ GpeNumber));
+ return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
+ }
+ }
+
+ return_VALUE (ACPI_INTERRUPT_HANDLED);
+}
+
diff --git a/sys/contrib/dev/acpica/evgpeblk.c b/sys/contrib/dev/acpica/evgpeblk.c
new file mode 100644
index 0000000..89aa409
--- /dev/null
+++ b/sys/contrib/dev/acpica/evgpeblk.c
@@ -0,0 +1,645 @@
+/******************************************************************************
+ *
+ * Module Name: evgpeblk - GPE block creation and initialization.
+ * $Revision: 4 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 ("evgpe")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvSaveMethodInfo
+ *
+ * PARAMETERS: Callback from WalkNamespace
+ *
+ * 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)
+{
+ ACPI_GPE_BLOCK_INFO *GpeBlock = (void *) ObjDesc;
+ ACPI_GPE_EVENT_INFO *GpeEventInfo;
+ UINT32 GpeNumber;
+ 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 is not of form _Lnn or _Enn)\n",
+ Name));
+ return (AE_OK);
+ }
+
+ /* Ensure that we have a valid GPE number for this GPE block */
+
+ if ((GpeNumber < GpeBlock->BlockBaseNumber) ||
+ (GpeNumber - GpeBlock->BlockBaseNumber >= (GpeBlock->RegisterCount * 8)))
+ {
+ /* Not valid, all we can do here is ignore it */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "GPE number associated with method %s is not valid\n", Name));
+ return (AE_OK);
+ }
+
+ /*
+ * Now we can add this information to the GpeEventInfo block
+ * for use during dispatch of this GPE.
+ */
+ GpeEventInfo = &GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber];
+
+ GpeEventInfo->Type = Type;
+ GpeEventInfo->MethodNode = (ACPI_NAMESPACE_NODE *) ObjHandle;
+
+ /*
+ * Enable the GPE (SCIs should be disabled at this point)
+ */
+ Status = AcpiHwEnableGpe (GpeEventInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Registered GPE method %s as GPE number %2.2X\n",
+ Name, GpeNumber));
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvInstallGpeBlock
+ *
+ * PARAMETERS: GpeBlock - New GPE block
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Install new GPE block with mutex support
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvInstallGpeBlock (
+ ACPI_GPE_BLOCK_INFO *GpeBlock)
+{
+ ACPI_GPE_BLOCK_INFO *NextGpeBlock;
+ ACPI_STATUS Status;
+
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Install the new block at the end of the global list */
+
+ if (AcpiGbl_GpeBlockListHead)
+ {
+ NextGpeBlock = AcpiGbl_GpeBlockListHead;
+ while (NextGpeBlock->Next)
+ {
+ NextGpeBlock = NextGpeBlock->Next;
+ }
+
+ NextGpeBlock->Next = GpeBlock;
+ GpeBlock->Previous = NextGpeBlock;
+ }
+ else
+ {
+ AcpiGbl_GpeBlockListHead = GpeBlock;
+ }
+
+ Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvCreateGpeInfoBlocks
+ *
+ * PARAMETERS: GpeBlock - New GPE block
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create the RegisterInfo and EventInfo blocks for this GPE block
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvCreateGpeInfoBlocks (
+ ACPI_GPE_BLOCK_INFO *GpeBlock)
+{
+ ACPI_GPE_REGISTER_INFO *GpeRegisterInfo = NULL;
+ ACPI_GPE_EVENT_INFO *GpeEventInfo = NULL;
+ ACPI_GPE_EVENT_INFO *ThisEvent;
+ ACPI_GPE_REGISTER_INFO *ThisRegister;
+ ACPI_NATIVE_UINT i;
+ ACPI_NATIVE_UINT j;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("EvCreateGpeInfoBlocks");
+
+
+ /* Allocate the GPE register information block */
+
+ GpeRegisterInfo = ACPI_MEM_CALLOCATE (
+ (ACPI_SIZE) GpeBlock->RegisterCount *
+ sizeof (ACPI_GPE_REGISTER_INFO));
+ if (!GpeRegisterInfo)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Could not allocate the GpeRegisterInfo table\n"));
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /*
+ * Allocate the GPE EventInfo block. There are eight distinct GPEs
+ * per register. Initialization to zeros is sufficient.
+ */
+ GpeEventInfo = ACPI_MEM_CALLOCATE (
+ ((ACPI_SIZE) GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH) *
+ sizeof (ACPI_GPE_EVENT_INFO));
+ if (!GpeEventInfo)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not allocate the GpeEventInfo table\n"));
+ Status = AE_NO_MEMORY;
+ goto ErrorExit;
+ }
+
+ /*
+ * Initialize the GPE Register and Event structures. 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.
+ */
+ ThisRegister = GpeRegisterInfo;
+ ThisEvent = GpeEventInfo;
+
+ for (i = 0; i < GpeBlock->RegisterCount; i++)
+ {
+ /* Init the RegisterInfo for this GPE register (8 GPEs) */
+
+ ThisRegister->BaseGpeNumber = (UINT8) (GpeBlock->BlockBaseNumber +
+ (i * ACPI_GPE_REGISTER_WIDTH));
+
+ ACPI_STORE_ADDRESS (ThisRegister->StatusAddress.Address,
+ (ACPI_GET_ADDRESS (GpeBlock->BlockAddress.Address)
+ + i));
+
+ ACPI_STORE_ADDRESS (ThisRegister->EnableAddress.Address,
+ (ACPI_GET_ADDRESS (GpeBlock->BlockAddress.Address)
+ + i
+ + GpeBlock->RegisterCount));
+
+ ThisRegister->StatusAddress.AddressSpaceId = GpeBlock->BlockAddress.AddressSpaceId;
+ ThisRegister->EnableAddress.AddressSpaceId = GpeBlock->BlockAddress.AddressSpaceId;
+ ThisRegister->StatusAddress.RegisterBitWidth = ACPI_GPE_REGISTER_WIDTH;
+ ThisRegister->EnableAddress.RegisterBitWidth = ACPI_GPE_REGISTER_WIDTH;
+ ThisRegister->StatusAddress.RegisterBitOffset = ACPI_GPE_REGISTER_WIDTH;
+ ThisRegister->EnableAddress.RegisterBitOffset = ACPI_GPE_REGISTER_WIDTH;
+
+ /* Init the EventInfo for each GPE within this register */
+
+ for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
+ {
+ ThisEvent->BitMask = AcpiGbl_DecodeTo8bit[j];
+ ThisEvent->RegisterInfo = ThisRegister;
+ ThisEvent++;
+ }
+
+ /*
+ * 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 (ACPI_GPE_REGISTER_WIDTH, 0x00,
+ &ThisRegister->EnableAddress, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+
+ Status = AcpiHwLowLevelWrite (ACPI_GPE_REGISTER_WIDTH, 0xFF,
+ &ThisRegister->StatusAddress, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+
+ ThisRegister++;
+ }
+
+ GpeBlock->RegisterInfo = GpeRegisterInfo;
+ GpeBlock->EventInfo = GpeEventInfo;
+
+ return_ACPI_STATUS (AE_OK);
+
+
+ErrorExit:
+
+ if (GpeRegisterInfo)
+ {
+ ACPI_MEM_FREE (GpeRegisterInfo);
+ }
+ if (GpeEventInfo)
+ {
+ ACPI_MEM_FREE (GpeEventInfo);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvCreateGpeBlock
+ *
+ * PARAMETERS: TBD
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create and Install a block of GPE registers
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvCreateGpeBlock (
+ char *Pathname,
+ ACPI_GENERIC_ADDRESS *GpeBlockAddress,
+ UINT32 RegisterCount,
+ UINT8 GpeBlockBaseNumber,
+ UINT32 InterruptLevel)
+{
+ ACPI_GPE_BLOCK_INFO *GpeBlock;
+ ACPI_STATUS Status;
+ ACPI_HANDLE ObjHandle;
+
+
+ ACPI_FUNCTION_TRACE ("EvCreateGpeBlock");
+
+
+ if (!RegisterCount)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Get a handle to the parent object for this GPE block */
+
+ Status = AcpiGetHandle (NULL, Pathname, &ObjHandle);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Allocate a new GPE block */
+
+ GpeBlock = ACPI_MEM_CALLOCATE (sizeof (ACPI_GPE_BLOCK_INFO));
+ if (!GpeBlock)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Initialize the new GPE block */
+
+ GpeBlock->RegisterCount = RegisterCount;
+ GpeBlock->BlockBaseNumber = GpeBlockBaseNumber;
+
+ ACPI_MEMCPY (&GpeBlock->BlockAddress, GpeBlockAddress, sizeof (ACPI_GENERIC_ADDRESS));
+
+ /* Create the RegisterInfo and EventInfo sub-structures */
+
+ Status = AcpiEvCreateGpeInfoBlocks (GpeBlock);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_MEM_FREE (GpeBlock);
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Install the new block in the global list(s) */
+ /* TBD: Install block in the interrupt handler list */
+
+ Status = AcpiEvInstallGpeBlock (GpeBlock);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_MEM_FREE (GpeBlock);
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Dump info about this GPE block */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "GPE Block: %X registers at %8.8X%8.8X\n",
+ GpeBlock->RegisterCount,
+ ACPI_HIDWORD (ACPI_GET_ADDRESS (GpeBlock->BlockAddress.Address)),
+ ACPI_LODWORD (ACPI_GET_ADDRESS (GpeBlock->BlockAddress.Address))));
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "GPE Block defined as GPE%d to GPE%d\n",
+ GpeBlock->BlockBaseNumber,
+ (UINT32) (GpeBlock->BlockBaseNumber +
+ ((GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH) -1))));
+
+ /* Find all GPE methods (_Lxx, _Exx) for this block */
+
+ Status = AcpiWalkNamespace (ACPI_TYPE_METHOD, ObjHandle,
+ ACPI_UINT32_MAX, AcpiEvSaveMethodInfo,
+ GpeBlock, NULL);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvGpeInitialize
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Initialize the GPE data structures
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvGpeInitialize (void)
+{
+ UINT32 RegisterCount0 = 0;
+ UINT32 RegisterCount1 = 0;
+ UINT32 GpeNumberMax = 0;
+
+
+ ACPI_FUNCTION_TRACE ("EvGpeInitialize");
+
+
+ /*
+ * Initialize the GPE Blocks defined in the FADT
+ *
+ * Why the GPE register block lengths are 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."
+ */
+
+ /*
+ * Determine the maximum GPE number for this machine.
+ *
+ * Note: both GPE0 and GPE1 are optional, and either can exist without
+ * the other.
+ * If EITHER the register length OR the block address are zero, then that
+ * particular block is not supported.
+ */
+ if (AcpiGbl_FADT->Gpe0BlkLen &&
+ ACPI_GET_ADDRESS (AcpiGbl_FADT->XGpe0Blk.Address))
+ {
+ /* GPE block 0 exists (has both length and address > 0) */
+
+ RegisterCount0 = (UINT16) (AcpiGbl_FADT->Gpe0BlkLen / 2);
+
+ GpeNumberMax = (RegisterCount0 * ACPI_GPE_REGISTER_WIDTH) - 1;
+
+ AcpiEvCreateGpeBlock ("\\_GPE", &AcpiGbl_FADT->XGpe0Blk,
+ RegisterCount0, 0, AcpiGbl_FADT->SciInt);
+ }
+
+ if (AcpiGbl_FADT->Gpe1BlkLen &&
+ ACPI_GET_ADDRESS (AcpiGbl_FADT->XGpe1Blk.Address))
+ {
+ /* GPE block 1 exists (has both length and address > 0) */
+
+ RegisterCount1 = (UINT16) (AcpiGbl_FADT->Gpe1BlkLen / 2);
+
+ /* Check for GPE0/GPE1 overlap (if both banks exist) */
+
+ if ((RegisterCount0) &&
+ (GpeNumberMax >= AcpiGbl_FADT->Gpe1Base))
+ {
+ ACPI_REPORT_ERROR ((
+ "GPE0 block (GPE 0 to %d) overlaps the GPE1 block (GPE %d to %d) - Ignoring GPE1\n",
+ GpeNumberMax, AcpiGbl_FADT->Gpe1Base,
+ AcpiGbl_FADT->Gpe1Base +
+ ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1)));
+
+ /* Ignore GPE1 block by setting the register count to zero */
+
+ RegisterCount1 = 0;
+ }
+ else
+ {
+ AcpiEvCreateGpeBlock ("\\_GPE", &AcpiGbl_FADT->XGpe1Blk,
+ RegisterCount1, AcpiGbl_FADT->Gpe1Base, AcpiGbl_FADT->SciInt);
+
+ /*
+ * GPE0 and GPE1 do not have to be contiguous in the GPE number space,
+ * But, GPE0 always starts at zero.
+ */
+ GpeNumberMax = AcpiGbl_FADT->Gpe1Base +
+ ((RegisterCount1 * ACPI_GPE_REGISTER_WIDTH) - 1);
+ }
+ }
+
+ /* Exit if there are no GPE registers */
+
+ if ((RegisterCount0 + RegisterCount1) == 0)
+ {
+ /* GPEs are not required by ACPI, this is OK */
+
+ ACPI_REPORT_INFO (("There are no GPE blocks defined in the FADT\n"));
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Check for Max GPE number out-of-range */
+
+ if (GpeNumberMax > ACPI_GPE_MAX)
+ {
+ ACPI_REPORT_ERROR (("Maximum GPE number from FADT is too large: 0x%X\n",
+ GpeNumberMax));
+ return_ACPI_STATUS (AE_BAD_VALUE);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
diff --git a/sys/contrib/dev/acpica/evmisc.c b/sys/contrib/dev/acpica/evmisc.c
new file mode 100644
index 0000000..cc4d9b1
--- /dev/null
+++ b/sys/contrib/dev/acpica/evmisc.c
@@ -0,0 +1,712 @@
+/******************************************************************************
+ *
+ * Module Name: evmisc - Miscellaneous event manager support functions
+ * $Revision: 64 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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: 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 [%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 (
+ 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_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_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)
+{
+ ACPI_NATIVE_UINT i;
+ ACPI_STATUS Status;
+ ACPI_GPE_BLOCK_INFO *GpeBlock;
+ ACPI_GPE_BLOCK_INFO *NextGpeBlock;
+ ACPI_GPE_EVENT_INFO *GpeEventInfo;
+
+
+ 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 ((UINT32) i, ACPI_EVENT_FIXED, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not disable fixed event %d\n", (UINT32) i));
+ }
+ }
+
+ /*
+ * Disable all GPEs
+ */
+ GpeBlock = AcpiGbl_GpeBlockListHead;
+ while (GpeBlock)
+ {
+ GpeEventInfo = GpeBlock->EventInfo;
+ for (i = 0; i < (GpeBlock->RegisterCount * 8); i++)
+ {
+ Status = AcpiHwDisableGpe (GpeEventInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not disable GPE %d\n", (UINT32) i));
+ }
+
+ GpeEventInfo++;
+ }
+
+ GpeBlock = GpeBlock->Next;
+ }
+
+ /*
+ * 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 GPE blocks and related info structures
+ */
+ GpeBlock = AcpiGbl_GpeBlockListHead;
+ while (GpeBlock)
+ {
+ NextGpeBlock = GpeBlock->Next;
+ ACPI_MEM_FREE (GpeBlock->EventInfo);
+ ACPI_MEM_FREE (GpeBlock->RegisterInfo);
+ ACPI_MEM_FREE (GpeBlock);
+
+ GpeBlock = NextGpeBlock;
+ }
+
+ return_VOID;
+}
+
diff --git a/sys/contrib/dev/acpica/evregion.c b/sys/contrib/dev/acpica/evregion.c
new file mode 100644
index 0000000..db1ab85
--- /dev/null
+++ b/sys/contrib/dev/acpica/evregion.c
@@ -0,0 +1,829 @@
+/******************************************************************************
+ *
+ * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch
+ * $Revision: 137 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __EVREGION_C__
+
+#include "acpi.h"
+#include "acevents.h"
+#include "acnamesp.h"
+#include "acinterp.h"
+
+#define _COMPONENT ACPI_EVENTS
+ ACPI_MODULE_NAME ("evregion")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvInitAddressSpaces
+ *
+ * PARAMETERS:
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Installs the core subsystem address space handlers.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvInitAddressSpaces (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("EvInitAddressSpaces");
+
+
+ /*
+ * All address spaces (PCI Config, EC, SMBus) are scope dependent
+ * and registration must occur for a specific device. In the case
+ * system memory and IO address spaces there is currently no device
+ * associated with the address space. For these we use the root.
+ * We install the default PCI config space handler at the root so
+ * that this space is immediately available even though the we have
+ * not enumerated all the PCI Root Buses yet. This is to conform
+ * to the ACPI specification which states that the PCI config
+ * space must be always available -- even though we are nowhere
+ * near ready to find the PCI root buses at this point.
+ *
+ * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler
+ * has already been installed (via AcpiInstallAddressSpaceHandler)
+ */
+
+ Status = AcpiInstallAddressSpaceHandler ((ACPI_HANDLE) AcpiGbl_RootNode,
+ ACPI_ADR_SPACE_SYSTEM_MEMORY,
+ ACPI_DEFAULT_HANDLER, NULL, NULL);
+ if ((ACPI_FAILURE (Status)) &&
+ (Status != AE_ALREADY_EXISTS))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiInstallAddressSpaceHandler ((ACPI_HANDLE) AcpiGbl_RootNode,
+ ACPI_ADR_SPACE_SYSTEM_IO,
+ ACPI_DEFAULT_HANDLER, NULL, NULL);
+ if ((ACPI_FAILURE (Status)) &&
+ (Status != AE_ALREADY_EXISTS))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiInstallAddressSpaceHandler ((ACPI_HANDLE) AcpiGbl_RootNode,
+ ACPI_ADR_SPACE_PCI_CONFIG,
+ ACPI_DEFAULT_HANDLER, NULL, NULL);
+ if ((ACPI_FAILURE (Status)) &&
+ (Status != AE_ALREADY_EXISTS))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiInstallAddressSpaceHandler ((ACPI_HANDLE) AcpiGbl_RootNode,
+ ACPI_ADR_SPACE_DATA_TABLE,
+ ACPI_DEFAULT_HANDLER, NULL, NULL);
+ if ((ACPI_FAILURE (Status)) &&
+ (Status != AE_ALREADY_EXISTS))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvExecuteRegMethod
+ *
+ * PARAMETERS: RegionObj - Object structure
+ * Function - On (1) or Off (0)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute _REG method for a region
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiEvExecuteRegMethod (
+ ACPI_OPERAND_OBJECT *RegionObj,
+ UINT32 Function)
+{
+ ACPI_OPERAND_OBJECT *Params[3];
+ ACPI_OPERAND_OBJECT *RegionObj2;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("EvExecuteRegMethod");
+
+
+ RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
+ if (!RegionObj2)
+ {
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ if (RegionObj2->Extra.Method_REG == NULL)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * _REG method has two arguments
+ * Arg0: Integer: Operation region space ID
+ * Same value as RegionObj->Region.SpaceId
+ * Arg1: Integer: connection status
+ * 1 for connecting the handler,
+ * 0 for disconnecting the handler
+ * Passed as a parameter
+ */
+ Params[0] = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!Params[0])
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Params[1] = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!Params[1])
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Set up the parameter objects
+ */
+ Params[0]->Integer.Value = RegionObj->Region.SpaceId;
+ Params[1]->Integer.Value = Function;
+ Params[2] = NULL;
+
+ /*
+ * Execute the method, no return value
+ */
+ ACPI_DEBUG_EXEC(AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, RegionObj2->Extra.Method_REG, NULL));
+ Status = AcpiNsEvaluateByHandle (RegionObj2->Extra.Method_REG, Params, NULL);
+
+ AcpiUtRemoveReference (Params[1]);
+
+Cleanup:
+ AcpiUtRemoveReference (Params[0]);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvAddressSpaceDispatch
+ *
+ * PARAMETERS: RegionObj - internal region object
+ * SpaceId - ID of the address space (0-255)
+ * Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, 32, or 64)
+ * Value - Pointer to in or out value
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Dispatch an address space or operation region access to
+ * a previously installed handler.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvAddressSpaceDispatch (
+ ACPI_OPERAND_OBJECT *RegionObj,
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ void *Value)
+{
+ ACPI_STATUS Status;
+ ACPI_STATUS Status2;
+ ACPI_ADR_SPACE_HANDLER Handler;
+ ACPI_ADR_SPACE_SETUP RegionSetup;
+ ACPI_OPERAND_OBJECT *HandlerDesc;
+ ACPI_OPERAND_OBJECT *RegionObj2;
+ void *RegionContext = NULL;
+
+
+ ACPI_FUNCTION_TRACE ("EvAddressSpaceDispatch");
+
+
+ RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
+ if (!RegionObj2)
+ {
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ /*
+ * Ensure that there is a handler associated with this region
+ */
+ HandlerDesc = RegionObj->Region.AddrHandler;
+ if (!HandlerDesc)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "no handler for region(%p) [%s]\n",
+ RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
+
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ /*
+ * It may be the case that the region has never been initialized
+ * Some types of regions require special init code
+ */
+ if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE))
+ {
+ /*
+ * This region has not been initialized yet, do it
+ */
+ RegionSetup = HandlerDesc->AddrHandler.Setup;
+ if (!RegionSetup)
+ {
+ /*
+ * Bad news, no init routine and not init'd
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No init routine for region(%p) [%s]\n",
+ RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
+ return_ACPI_STATUS (AE_UNKNOWN_STATUS);
+ }
+
+ /*
+ * We must exit the interpreter because the region setup will potentially
+ * execute control methods
+ */
+ AcpiExExitInterpreter ();
+
+ Status = RegionSetup (RegionObj, ACPI_REGION_ACTIVATE,
+ HandlerDesc->AddrHandler.Context, &RegionContext);
+
+ /* Re-enter the interpreter */
+
+ Status2 = AcpiExEnterInterpreter ();
+ if (ACPI_FAILURE (Status2))
+ {
+ return_ACPI_STATUS (Status2);
+ }
+
+ /*
+ * Init routine may fail
+ */
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region Init: %s [%s]\n",
+ AcpiFormatException (Status),
+ AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
+ return_ACPI_STATUS (Status);
+ }
+
+ RegionObj->Region.Flags |= AOPOBJ_SETUP_COMPLETE;
+
+ /*
+ * Save the returned context for use in all accesses to
+ * this particular region.
+ */
+ RegionObj2->Extra.RegionContext = RegionContext;
+ }
+
+ /*
+ * We have everything we need, begin the process
+ */
+ Handler = HandlerDesc->AddrHandler.Handler;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+ "Addrhandler %p (%p), Address %8.8X%8.8X\n",
+ &RegionObj->Region.AddrHandler->AddrHandler, Handler,
+ ACPI_HIDWORD (Address), ACPI_LODWORD (Address)));
+
+ if (!(HandlerDesc->AddrHandler.Flags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED))
+ {
+ /*
+ * For handlers other than the default (supplied) handlers, we must
+ * exit the interpreter because the handler *might* block -- we don't
+ * know what it will do, so we can't hold the lock on the intepreter.
+ */
+ AcpiExExitInterpreter();
+ }
+
+ /*
+ * Invoke the handler.
+ */
+ Status = Handler (Function, Address, BitWidth, Value,
+ HandlerDesc->AddrHandler.Context,
+ RegionObj2->Extra.RegionContext);
+
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("Handler for [%s] returned %s\n",
+ AcpiUtGetRegionName (RegionObj->Region.SpaceId),
+ AcpiFormatException (Status)));
+ }
+
+ if (!(HandlerDesc->AddrHandler.Flags & ACPI_ADDR_HANDLER_DEFAULT_INSTALLED))
+ {
+ /*
+ * We just returned from a non-default handler, we must re-enter the
+ * interpreter
+ */
+ Status2 = AcpiExEnterInterpreter ();
+ if (ACPI_FAILURE (Status2))
+ {
+ return_ACPI_STATUS (Status2);
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvDetachRegion
+ *
+ * PARAMETERS: RegionObj - Region Object
+ * AcpiNsIsLocked - Namespace Region Already Locked?
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Break the association between the handler and the region
+ * this is a two way association.
+ *
+ ******************************************************************************/
+
+void
+AcpiEvDetachRegion(
+ ACPI_OPERAND_OBJECT *RegionObj,
+ BOOLEAN AcpiNsIsLocked)
+{
+ ACPI_OPERAND_OBJECT *HandlerObj;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_OPERAND_OBJECT **LastObjPtr;
+ ACPI_ADR_SPACE_SETUP RegionSetup;
+ void *RegionContext;
+ ACPI_OPERAND_OBJECT *RegionObj2;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("EvDetachRegion");
+
+
+ RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
+ if (!RegionObj2)
+ {
+ return_VOID;
+ }
+ RegionContext = RegionObj2->Extra.RegionContext;
+
+ /*
+ * Get the address handler from the region object
+ */
+ HandlerObj = RegionObj->Region.AddrHandler;
+ if (!HandlerObj)
+ {
+ /*
+ * This region has no handler, all done
+ */
+ return_VOID;
+ }
+
+
+ /*
+ * Find this region in the handler's list
+ */
+ ObjDesc = HandlerObj->AddrHandler.RegionList;
+ LastObjPtr = &HandlerObj->AddrHandler.RegionList;
+
+ while (ObjDesc)
+ {
+ /*
+ * See if this is the one
+ */
+ if (ObjDesc == RegionObj)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+ "Removing Region %p from address handler %p\n",
+ RegionObj, HandlerObj));
+ /*
+ * This is it, remove it from the handler's list
+ */
+ *LastObjPtr = ObjDesc->Region.Next;
+ ObjDesc->Region.Next = NULL; /* Must clear field */
+
+ if (AcpiNsIsLocked)
+ {
+ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_VOID;
+ }
+ }
+
+ /*
+ * Now stop region accesses by executing the _REG method
+ */
+ Status = AcpiEvExecuteRegMethod (RegionObj, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region _REG, [%s]\n",
+ AcpiFormatException (Status),
+ AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
+ }
+
+ if (AcpiNsIsLocked)
+ {
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_VOID;
+ }
+ }
+
+ /*
+ * Call the setup handler with the deactivate notification
+ */
+ RegionSetup = HandlerObj->AddrHandler.Setup;
+ Status = RegionSetup (RegionObj, ACPI_REGION_DEACTIVATE,
+ HandlerObj->AddrHandler.Context, &RegionContext);
+
+ /*
+ * Init routine may fail, Just ignore errors
+ */
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s from region init, [%s]\n",
+ AcpiFormatException (Status),
+ AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
+ }
+
+ RegionObj->Region.Flags &= ~(AOPOBJ_SETUP_COMPLETE);
+
+ /*
+ * Remove handler reference in the region
+ *
+ * NOTE: this doesn't mean that the region goes away
+ * The region is just inaccessible as indicated to
+ * the _REG method
+ *
+ * If the region is on the handler's list
+ * this better be the region's handler
+ */
+ RegionObj->Region.AddrHandler = NULL;
+
+ return_VOID;
+
+ } /* found the right handler */
+
+ /*
+ * Move through the linked list of handlers
+ */
+ LastObjPtr = &ObjDesc->Region.Next;
+ ObjDesc = ObjDesc->Region.Next;
+ }
+
+ /*
+ * If we get here, the region was not in the handler's region list
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+ "Cannot remove region %p from address handler %p\n",
+ RegionObj, HandlerObj));
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvAttachRegion
+ *
+ * PARAMETERS: HandlerObj - Handler Object
+ * RegionObj - Region Object
+ * AcpiNsIsLocked - Namespace Region Already Locked?
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Create the association between the handler and the region
+ * this is a two way association.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvAttachRegion (
+ ACPI_OPERAND_OBJECT *HandlerObj,
+ ACPI_OPERAND_OBJECT *RegionObj,
+ BOOLEAN AcpiNsIsLocked)
+{
+ ACPI_STATUS Status;
+ ACPI_STATUS Status2;
+
+
+ ACPI_FUNCTION_TRACE ("EvAttachRegion");
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+ "Adding Region %p to address handler %p [%s]\n",
+ RegionObj, HandlerObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
+
+
+ /*
+ * Link this region to the front of the handler's list
+ */
+ RegionObj->Region.Next = HandlerObj->AddrHandler.RegionList;
+ HandlerObj->AddrHandler.RegionList = RegionObj;
+
+ /*
+ * Set the region's handler
+ */
+ RegionObj->Region.AddrHandler = HandlerObj;
+
+ /*
+ * Tell all users that this region is usable by running the _REG
+ * method
+ */
+ if (AcpiNsIsLocked)
+ {
+ Status2 = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status2))
+ {
+ return_ACPI_STATUS (Status2);
+ }
+ }
+
+ Status = AcpiEvExecuteRegMethod (RegionObj, 1);
+
+ if (AcpiNsIsLocked)
+ {
+ Status2 = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status2))
+ {
+ return_ACPI_STATUS (Status2);
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvAddrHandlerHelper
+ *
+ * PARAMETERS: Handle - Node to be dumped
+ * Level - Nesting level of the handle
+ * Context - Passed into AcpiNsWalkNamespace
+ *
+ * DESCRIPTION: This routine installs an address handler into objects that are
+ * of type Region.
+ *
+ * If the Object is a Device, and the device has a handler of
+ * the same type then the search is terminated in that branch.
+ *
+ * This is because the existing handler is closer in proximity
+ * to any more regions than the one we are trying to install.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvAddrHandlerHelper (
+ ACPI_HANDLE ObjHandle,
+ UINT32 Level,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_OPERAND_OBJECT *HandlerObj;
+ ACPI_OPERAND_OBJECT *TmpObj;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_NAME ("EvAddrHandlerHelper");
+
+
+ HandlerObj = (ACPI_OPERAND_OBJECT *) Context;
+
+ /* Parameter validation */
+
+ if (!HandlerObj)
+ {
+ return (AE_OK);
+ }
+
+ /* Convert and validate the device handle */
+
+ Node = AcpiNsMapHandleToNode (ObjHandle);
+ if (!Node)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * We only care about regions.and objects
+ * that can have address handlers
+ */
+ if ((Node->Type != ACPI_TYPE_DEVICE) &&
+ (Node->Type != ACPI_TYPE_REGION) &&
+ (Node != AcpiGbl_RootNode))
+ {
+ return (AE_OK);
+ }
+
+ /* Check for an existing internal object */
+
+ ObjDesc = AcpiNsGetAttachedObject (Node);
+ if (!ObjDesc)
+ {
+ /*
+ * The object DNE, we don't care about it
+ */
+ return (AE_OK);
+ }
+
+ /*
+ * Devices are handled different than regions
+ */
+ if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_DEVICE)
+ {
+ /*
+ * See if this guy has any handlers
+ */
+ TmpObj = ObjDesc->Device.AddrHandler;
+ while (TmpObj)
+ {
+ /*
+ * Now let's see if it's for the same address space.
+ */
+ if (TmpObj->AddrHandler.SpaceId == HandlerObj->AddrHandler.SpaceId)
+ {
+ /*
+ * It's for the same address space
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+ "Found handler for region [%s] in device %p(%p) handler %p\n",
+ AcpiUtGetRegionName (HandlerObj->AddrHandler.SpaceId),
+ ObjDesc, TmpObj, HandlerObj));
+
+ /*
+ * Since the object we found it on was a device, then it
+ * means that someone has already installed a handler for
+ * the branch of the namespace from this device on. Just
+ * bail out telling the walk routine to not traverse this
+ * branch. This preserves the scoping rule for handlers.
+ */
+ return (AE_CTRL_DEPTH);
+ }
+
+ /*
+ * Move through the linked list of handlers
+ */
+ TmpObj = TmpObj->AddrHandler.Next;
+ }
+
+ /*
+ * As long as the device didn't have a handler for this
+ * space we don't care about it. We just ignore it and
+ * proceed.
+ */
+ return (AE_OK);
+ }
+
+ /*
+ * Only here if it was a region
+ */
+ if (ObjDesc->Region.SpaceId != HandlerObj->AddrHandler.SpaceId)
+ {
+ /*
+ * This region is for a different address space
+ * ignore it
+ */
+ return (AE_OK);
+ }
+
+ /*
+ * Now we have a region and it is for the handler's address
+ * space type.
+ *
+ * First disconnect region for any previous handler (if any)
+ */
+ AcpiEvDetachRegion (ObjDesc, FALSE);
+
+ /*
+ * Then connect the region to the new handler
+ */
+ Status = AcpiEvAttachRegion (HandlerObj, ObjDesc, FALSE);
+
+ return (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/evrgnini.c b/sys/contrib/dev/acpica/evrgnini.c
new file mode 100644
index 0000000..2a53764
--- /dev/null
+++ b/sys/contrib/dev/acpica/evrgnini.c
@@ -0,0 +1,650 @@
+/******************************************************************************
+ *
+ * Module Name: evrgnini- ACPI AddressSpace (OpRegion) init
+ * $Revision: 66 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __EVRGNINI_C__
+
+#include "acpi.h"
+#include "acevents.h"
+#include "acnamesp.h"
+
+#define _COMPONENT ACPI_EVENTS
+ ACPI_MODULE_NAME ("evrgnini")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvSystemMemoryRegionSetup
+ *
+ * PARAMETERS: RegionObj - Region we are interested in
+ * Function - Start or stop
+ * HandlerContext - Address space handler context
+ * RegionContext - Region specific context
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Do any prep work for region handling, a nop for now
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvSystemMemoryRegionSetup (
+ ACPI_HANDLE Handle,
+ UINT32 Function,
+ void *HandlerContext,
+ void **RegionContext)
+{
+ ACPI_OPERAND_OBJECT *RegionDesc = (ACPI_OPERAND_OBJECT *) Handle;
+ ACPI_MEM_SPACE_CONTEXT *LocalRegionContext;
+
+
+ ACPI_FUNCTION_TRACE ("EvSystemMemoryRegionSetup");
+
+
+ if (Function == ACPI_REGION_DEACTIVATE)
+ {
+ if (*RegionContext)
+ {
+ ACPI_MEM_FREE (*RegionContext);
+ *RegionContext = NULL;
+ }
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Create a new context */
+
+ LocalRegionContext = ACPI_MEM_CALLOCATE (sizeof (ACPI_MEM_SPACE_CONTEXT));
+ if (!(LocalRegionContext))
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Save the region length and address for use in the handler */
+
+ LocalRegionContext->Length = RegionDesc->Region.Length;
+ LocalRegionContext->Address = RegionDesc->Region.Address;
+
+ *RegionContext = LocalRegionContext;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvIoSpaceRegionSetup
+ *
+ * PARAMETERS: RegionObj - Region we are interested in
+ * Function - Start or stop
+ * HandlerContext - Address space handler context
+ * RegionContext - Region specific context
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Do any prep work for region handling
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvIoSpaceRegionSetup (
+ ACPI_HANDLE Handle,
+ UINT32 Function,
+ void *HandlerContext,
+ void **RegionContext)
+{
+ ACPI_FUNCTION_TRACE ("EvIoSpaceRegionSetup");
+
+
+ if (Function == ACPI_REGION_DEACTIVATE)
+ {
+ *RegionContext = NULL;
+ }
+ else
+ {
+ *RegionContext = HandlerContext;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvPciConfigRegionSetup
+ *
+ * PARAMETERS: RegionObj - Region we are interested in
+ * Function - Start or stop
+ * HandlerContext - Address space handler context
+ * RegionContext - Region specific context
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Do any prep work for region handling
+ *
+ * MUTEX: Assumes namespace is not locked
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvPciConfigRegionSetup (
+ ACPI_HANDLE Handle,
+ UINT32 Function,
+ void *HandlerContext,
+ void **RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_INTEGER Temp;
+ ACPI_PCI_ID *PciId = *RegionContext;
+ ACPI_OPERAND_OBJECT *HandlerObj;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_OPERAND_OBJECT *RegionObj = (ACPI_OPERAND_OBJECT *) Handle;
+ ACPI_DEVICE_ID ObjectHID;
+
+
+ ACPI_FUNCTION_TRACE ("EvPciConfigRegionSetup");
+
+
+ HandlerObj = RegionObj->Region.AddrHandler;
+ if (!HandlerObj)
+ {
+ /*
+ * No installed handler. This shouldn't happen because the dispatch
+ * routine checks before we get here, but we check again just in case.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+ "Attempting to init a region %p, with no handler\n", RegionObj));
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ if (Function == ACPI_REGION_DEACTIVATE)
+ {
+ if (PciId)
+ {
+ ACPI_MEM_FREE (PciId);
+ *RegionContext = NULL;
+ }
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Create a new context */
+
+ PciId = ACPI_MEM_CALLOCATE (sizeof (ACPI_PCI_ID));
+ if (!PciId)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /*
+ * For PCI Config space access, we have to pass the segment, bus,
+ * device and function numbers. This routine must acquire those.
+ */
+
+ /*
+ * First get device and function numbers from the _ADR object
+ * in the parent's scope.
+ */
+ Node = AcpiNsGetParentNode (RegionObj->Region.Node);
+
+ /* Evaluate the _ADR object */
+
+ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, &Temp);
+
+ /*
+ * The default is zero, and since the allocation above zeroed
+ * the data, just do nothing on failure.
+ */
+ if (ACPI_SUCCESS (Status))
+ {
+ PciId->Device = ACPI_HIWORD (ACPI_LODWORD (Temp));
+ PciId->Function = ACPI_LOWORD (ACPI_LODWORD (Temp));
+ }
+
+ /*
+ * Get the _SEG and _BBN values from the device upon which the handler
+ * is installed.
+ *
+ * We need to get the _SEG and _BBN objects relative to the PCI BUS device.
+ * This is the device the handler has been registered to handle.
+ */
+
+ /*
+ * If the AddrHandler.Node is still pointing to the root, we need
+ * to scan upward for a PCI Root bridge and re-associate the OpRegion
+ * handlers with that device.
+ */
+ if (HandlerObj->AddrHandler.Node == AcpiGbl_RootNode)
+ {
+ /*
+ * Node is currently the parent object
+ */
+ while (Node != AcpiGbl_RootNode)
+ {
+ Status = AcpiUtExecute_HID (Node, &ObjectHID);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Got a valid _HID, check if this is a PCI root */
+
+ if (!(ACPI_STRNCMP (ObjectHID.Buffer, PCI_ROOT_HID_STRING,
+ sizeof (PCI_ROOT_HID_STRING))))
+ {
+ /* Install a handler for this PCI root bridge */
+
+ Status = AcpiInstallAddressSpaceHandler ((ACPI_HANDLE) Node,
+ ACPI_ADR_SPACE_PCI_CONFIG,
+ ACPI_DEFAULT_HANDLER, NULL, NULL);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("Could not install PciConfig handler for %4.4s, %s\n",
+ Node->Name.Ascii, AcpiFormatException (Status)));
+ }
+ break;
+ }
+ }
+
+ Node = AcpiNsGetParentNode (Node);
+ }
+ }
+ else
+ {
+ Node = HandlerObj->AddrHandler.Node;
+ }
+
+ /*
+ * The PCI segment number comes from the _SEG method
+ */
+ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__SEG, Node, &Temp);
+ if (ACPI_SUCCESS (Status))
+ {
+ PciId->Segment = ACPI_LOWORD (Temp);
+ }
+
+ /*
+ * The PCI bus number comes from the _BBN method
+ */
+ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__BBN, Node, &Temp);
+ if (ACPI_SUCCESS (Status))
+ {
+ PciId->Bus = ACPI_LOWORD (Temp);
+ }
+
+ /*
+ * Complete this device's PciId
+ */
+ AcpiOsDerivePciId (Node, RegionObj->Region.Node, &PciId);
+
+ *RegionContext = PciId;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvPciBarRegionSetup
+ *
+ * PARAMETERS: RegionObj - Region we are interested in
+ * Function - Start or stop
+ * HandlerContext - Address space handler context
+ * RegionContext - Region specific context
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Do any prep work for region handling
+ *
+ * MUTEX: Assumes namespace is not locked
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvPciBarRegionSetup (
+ ACPI_HANDLE Handle,
+ UINT32 Function,
+ void *HandlerContext,
+ void **RegionContext)
+{
+ ACPI_FUNCTION_TRACE ("EvPciBarRegionSetup");
+
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvCmosRegionSetup
+ *
+ * PARAMETERS: RegionObj - Region we are interested in
+ * Function - Start or stop
+ * HandlerContext - Address space handler context
+ * RegionContext - Region specific context
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Do any prep work for region handling
+ *
+ * MUTEX: Assumes namespace is not locked
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvCmosRegionSetup (
+ ACPI_HANDLE Handle,
+ UINT32 Function,
+ void *HandlerContext,
+ void **RegionContext)
+{
+ ACPI_FUNCTION_TRACE ("EvCmosRegionSetup");
+
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvDefaultRegionSetup
+ *
+ * PARAMETERS: RegionObj - Region we are interested in
+ * Function - Start or stop
+ * HandlerContext - Address space handler context
+ * RegionContext - Region specific context
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Do any prep work for region handling
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvDefaultRegionSetup (
+ ACPI_HANDLE Handle,
+ UINT32 Function,
+ void *HandlerContext,
+ void **RegionContext)
+{
+ ACPI_FUNCTION_TRACE ("EvDefaultRegionSetup");
+
+
+ if (Function == ACPI_REGION_DEACTIVATE)
+ {
+ *RegionContext = NULL;
+ }
+ else
+ {
+ *RegionContext = HandlerContext;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvInitializeRegion
+ *
+ * PARAMETERS: RegionObj - Region we are initializing
+ * AcpiNsLocked - Is namespace locked?
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Initializes the region, finds any _REG methods and saves them
+ * for execution at a later time
+ *
+ * Get the appropriate address space handler for a newly
+ * created region.
+ *
+ * This also performs address space specific initialization. For
+ * example, PCI regions must have an _ADR object that contains
+ * a PCI address in the scope of the definition. This address is
+ * required to perform an access to PCI config space.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvInitializeRegion (
+ ACPI_OPERAND_OBJECT *RegionObj,
+ BOOLEAN AcpiNsLocked)
+{
+ ACPI_OPERAND_OBJECT *HandlerObj;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_ADR_SPACE_TYPE SpaceId;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *MethodNode;
+ ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG;
+ ACPI_OPERAND_OBJECT *RegionObj2;
+
+
+ ACPI_FUNCTION_TRACE_U32 ("EvInitializeRegion", AcpiNsLocked);
+
+
+ if (!RegionObj)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (RegionObj->Common.Flags & AOPOBJ_OBJECT_INITIALIZED)
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
+ if (!RegionObj2)
+ {
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ Node = AcpiNsGetParentNode (RegionObj->Region.Node);
+ SpaceId = RegionObj->Region.SpaceId;
+
+ RegionObj->Region.AddrHandler = NULL;
+ RegionObj2->Extra.Method_REG = NULL;
+ RegionObj->Common.Flags &= ~(AOPOBJ_SETUP_COMPLETE);
+ RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED;
+
+ /*
+ * Find any "_REG" method associated with this region definition
+ */
+ Status = AcpiNsSearchNode (*RegNamePtr, Node,
+ ACPI_TYPE_METHOD, &MethodNode);
+ if (ACPI_SUCCESS (Status))
+ {
+ /*
+ * The _REG method is optional and there can be only one per region
+ * definition. This will be executed when the handler is attached
+ * or removed
+ */
+ RegionObj2->Extra.Method_REG = MethodNode;
+ }
+
+ /*
+ * The following loop depends upon the root Node having no parent
+ * ie: AcpiGbl_RootNode->ParentEntry being set to NULL
+ */
+ while (Node)
+ {
+ /*
+ * Check to see if a handler exists
+ */
+ HandlerObj = NULL;
+ ObjDesc = AcpiNsGetAttachedObject (Node);
+ if (ObjDesc)
+ {
+ /*
+ * Can only be a handler if the object exists
+ */
+ switch (Node->Type)
+ {
+ case ACPI_TYPE_DEVICE:
+
+ HandlerObj = ObjDesc->Device.AddrHandler;
+ break;
+
+ case ACPI_TYPE_PROCESSOR:
+
+ HandlerObj = ObjDesc->Processor.AddrHandler;
+ break;
+
+ case ACPI_TYPE_THERMAL:
+
+ HandlerObj = ObjDesc->ThermalZone.AddrHandler;
+ break;
+
+ default:
+ /* Ignore other objects */
+ break;
+ }
+
+ while (HandlerObj)
+ {
+ /* Is this handler of the correct type? */
+
+ if (HandlerObj->AddrHandler.SpaceId == SpaceId)
+ {
+ /* Found correct handler */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+ "Found handler %p for region %p in obj %p\n",
+ HandlerObj, RegionObj, ObjDesc));
+
+ Status = AcpiEvAttachRegion (HandlerObj, RegionObj,
+ AcpiNsLocked);
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Try next handler in the list */
+
+ HandlerObj = HandlerObj->AddrHandler.Next;
+ }
+ }
+
+ /*
+ * This node does not have the handler we need;
+ * Pop up one level
+ */
+ Node = AcpiNsGetParentNode (Node);
+ }
+
+ /*
+ * If we get here, there is no handler for this region
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+ "No handler for RegionType %s(%X) (RegionObj %p)\n",
+ AcpiUtGetRegionName (SpaceId), SpaceId, RegionObj));
+
+ return_ACPI_STATUS (AE_NOT_EXIST);
+}
+
diff --git a/sys/contrib/dev/acpica/evsci.c b/sys/contrib/dev/acpica/evsci.c
new file mode 100644
index 0000000..d393387
--- /dev/null
+++ b/sys/contrib/dev/acpica/evsci.c
@@ -0,0 +1,235 @@
+/*******************************************************************************
+ *
+ * Module Name: evsci - System Control Interrupt configuration and
+ * legacy to ACPI mode state transition functions
+ * $Revision: 88 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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"
+
+
+#define _COMPONENT ACPI_EVENTS
+ ACPI_MODULE_NAME ("evsci")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEvSciHandler
+ *
+ * PARAMETERS: Context - Calling Context
+ *
+ * RETURN: Status code indicates whether interrupt was handled.
+ *
+ * DESCRIPTION: Interrupt handler that will figure out what function or
+ * control method to call to deal with a SCI. Installed
+ * using BU interrupt support.
+ *
+ ******************************************************************************/
+
+static UINT32 ACPI_SYSTEM_XFACE
+AcpiEvSciHandler (
+ void *Context)
+{
+ UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED;
+
+
+ ACPI_FUNCTION_TRACE("EvSciHandler");
+
+
+ /*
+ * We are guaranteed by the ACPI CA initialization/shutdown code that
+ * if this interrupt handler is installed, ACPI is enabled.
+ */
+
+ /*
+ * Fixed AcpiEvents:
+ * Check for and dispatch any Fixed AcpiEvents that have occurred
+ */
+ InterruptHandled |= AcpiEvFixedEventDetect ();
+
+ /*
+ * GPEs:
+ * Check for and dispatch any GPEs that have occurred
+ */
+ InterruptHandled |= AcpiEvGpeDetect ();
+
+ return_VALUE (InterruptHandled);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiEvInstallSciHandler
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Installs SCI handler.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiEvInstallSciHandler (void)
+{
+ UINT32 Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE ("EvInstallSciHandler");
+
+
+ Status = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FADT->SciInt,
+ AcpiEvSciHandler, NULL);
+ return_ACPI_STATUS (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiEvRemoveSciHandler
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not
+ * installed to begin with
+ *
+ * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be
+ * taken.
+ *
+ * Note: It doesn't seem important to disable all events or set the event
+ * enable registers to their original values. The OS should disable
+ * the SCI interrupt level when the handler is removed, so no more
+ * events will come in.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvRemoveSciHandler (void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("EvRemoveSciHandler");
+
+
+ /* Just let the OS remove the handler and disable the level */
+
+ Status = AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FADT->SciInt,
+ AcpiEvSciHandler);
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/evxface.c b/sys/contrib/dev/acpica/evxface.c
new file mode 100644
index 0000000..d566c95
--- /dev/null
+++ b/sys/contrib/dev/acpica/evxface.c
@@ -0,0 +1,817 @@
+/******************************************************************************
+ *
+ * Module Name: evxface - External interfaces for ACPI events
+ * $Revision: 135 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 <external> 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 (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;
+ ACPI_GPE_EVENT_INFO *GpeEventInfo;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiInstallGpeHandler");
+
+
+ /* Parameter validation */
+
+ if (!Handler)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Ensure that we have a valid GPE number */
+
+ GpeEventInfo = AcpiEvGetGpeEventInfo (GpeNumber);
+ if (!GpeEventInfo)
+ {
+ 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 (GpeEventInfo->Handler)
+ {
+ Status = AE_ALREADY_EXISTS;
+ goto Cleanup;
+ }
+
+ /* Install the handler */
+
+ GpeEventInfo->Handler = Handler;
+ GpeEventInfo->Context = Context;
+ GpeEventInfo->Type = (UINT8) Type;
+
+ /* Clear the GPE (of stale events), the enable it */
+
+ Status = AcpiHwClearGpe (GpeEventInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ Status = AcpiHwEnableGpe (GpeEventInfo);
+
+
+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;
+ ACPI_GPE_EVENT_INFO *GpeEventInfo;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiRemoveGpeHandler");
+
+
+ /* Parameter validation */
+
+ if (!Handler)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Ensure that we have a valid GPE number */
+
+ GpeEventInfo = AcpiEvGetGpeEventInfo (GpeNumber);
+ if (!GpeEventInfo)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Disable the GPE before removing the handler */
+
+ Status = AcpiHwDisableGpe (GpeEventInfo);
+ 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 (GpeEventInfo->Handler != Handler)
+ {
+ (void) AcpiHwEnableGpe (GpeEventInfo);
+ Status = AE_BAD_PARAMETER;
+ goto Cleanup;
+ }
+
+ /* Remove the handler */
+
+ GpeEventInfo->Handler = NULL;
+ GpeEventInfo->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 (
+ 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/evxfevnt.c b/sys/contrib/dev/acpica/evxfevnt.c
new file mode 100644
index 0000000..753c6d0
--- /dev/null
+++ b/sys/contrib/dev/acpica/evxfevnt.c
@@ -0,0 +1,581 @@
+/******************************************************************************
+ *
+ * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
+ * $Revision: 62 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __EVXFEVNT_C__
+
+#include "acpi.h"
+#include "acevents.h"
+
+#define _COMPONENT ACPI_EVENTS
+ ACPI_MODULE_NAME ("evxfevnt")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEnable
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Transfers the system into ACPI mode.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnable (void)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiEnable");
+
+
+ /* Make sure we have the FADT*/
+
+ if (!AcpiGbl_FADT)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n"));
+ return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+ }
+
+ if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n"));
+ }
+ else
+ {
+ /* Transition to ACPI mode */
+
+ Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("Could not transition to ACPI mode.\n"));
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Transition to ACPI mode successful\n"));
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDisable
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Transfers the system into LEGACY mode.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDisable (void)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiDisable");
+
+ if (!AcpiGbl_FADT)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "No FADT information present!\n"));
+ return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+ }
+
+ if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in legacy (non-ACPI) mode\n"));
+ }
+ else
+ {
+ /* Transition to LEGACY mode */
+
+ Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY);
+
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not exit ACPI mode to legacy mode"));
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n"));
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEnableEvent
+ *
+ * PARAMETERS: Event - The fixed event or GPE to be enabled
+ * Type - The type of event
+ * Flags - Just enable, or also wake enable?
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enable an ACPI event (fixed and general purpose)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnableEvent (
+ UINT32 Event,
+ UINT32 Type,
+ UINT32 Flags)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT32 Value;
+ ACPI_GPE_EVENT_INFO *GpeEventInfo;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiEnableEvent");
+
+
+ /* The Type must be either Fixed Event or GPE */
+
+ switch (Type)
+ {
+ case ACPI_EVENT_FIXED:
+
+ /* Decode the Fixed Event */
+
+ if (Event > ACPI_EVENT_MAX)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Enable the requested fixed event (by writing a one to the
+ * enable register bit)
+ */
+ Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
+ 1, ACPI_MTX_LOCK);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Make sure that the hardware responded */
+
+ Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
+ &Value, ACPI_MTX_LOCK);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (Value != 1)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Could not enable %s event\n", AcpiUtGetEventName (Event)));
+ return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
+ }
+ break;
+
+
+ case ACPI_EVENT_GPE:
+
+ /* Ensure that we have a valid GPE number */
+
+ GpeEventInfo = AcpiEvGetGpeEventInfo (Event);
+ if (!GpeEventInfo)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Enable the requested GPE number */
+
+ Status = AcpiHwEnableGpe (GpeEventInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (Flags & ACPI_EVENT_WAKE_ENABLE)
+ {
+ AcpiHwEnableGpeForWakeup (GpeEventInfo);
+ }
+ break;
+
+
+ default:
+
+ Status = AE_BAD_PARAMETER;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDisableEvent
+ *
+ * PARAMETERS: Event - The fixed event or GPE to be enabled
+ * Type - The type of event, fixed or general purpose
+ * Flags - Wake disable vs. non-wake disable
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Disable an ACPI event (fixed and general purpose)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDisableEvent (
+ UINT32 Event,
+ UINT32 Type,
+ UINT32 Flags)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT32 Value;
+ ACPI_GPE_EVENT_INFO *GpeEventInfo;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiDisableEvent");
+
+
+ /* The Type must be either Fixed Event or GPE */
+
+ switch (Type)
+ {
+ case ACPI_EVENT_FIXED:
+
+ /* Decode the Fixed Event */
+
+ if (Event > ACPI_EVENT_MAX)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Disable the requested fixed event (by writing a zero to the
+ * enable register bit)
+ */
+ Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
+ 0, ACPI_MTX_LOCK);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
+ &Value, ACPI_MTX_LOCK);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (Value != 0)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Could not disable %s events\n", AcpiUtGetEventName (Event)));
+ return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
+ }
+ break;
+
+
+ case ACPI_EVENT_GPE:
+
+ /* Ensure that we have a valid GPE number */
+
+ GpeEventInfo = AcpiEvGetGpeEventInfo (Event);
+ if (!GpeEventInfo)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Only disable the requested GPE number for wake if specified.
+ * Otherwise, turn it totally off
+ */
+
+ if (Flags & ACPI_EVENT_WAKE_DISABLE)
+ {
+ AcpiHwDisableGpeForWakeup (GpeEventInfo);
+ }
+ else
+ {
+ Status = AcpiHwDisableGpe (GpeEventInfo);
+ }
+ break;
+
+
+ default:
+ Status = AE_BAD_PARAMETER;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiClearEvent
+ *
+ * PARAMETERS: Event - The fixed event or GPE to be cleared
+ * Type - The type of event
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Clear an ACPI event (fixed and general purpose)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiClearEvent (
+ UINT32 Event,
+ UINT32 Type)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_GPE_EVENT_INFO *GpeEventInfo;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiClearEvent");
+
+
+ /* The Type must be either Fixed Event or GPE */
+
+ switch (Type)
+ {
+ case ACPI_EVENT_FIXED:
+
+ /* Decode the Fixed Event */
+
+ if (Event > ACPI_EVENT_MAX)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Clear the requested fixed event (By writing a one to the
+ * status register bit)
+ */
+ Status = AcpiSetRegister (AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
+ 1, ACPI_MTX_LOCK);
+ break;
+
+
+ case ACPI_EVENT_GPE:
+
+ /* Ensure that we have a valid GPE number */
+
+ GpeEventInfo = AcpiEvGetGpeEventInfo (Event);
+ if (!GpeEventInfo)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiHwClearGpe (GpeEventInfo);
+ break;
+
+
+ default:
+
+ Status = AE_BAD_PARAMETER;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetEventStatus
+ *
+ * PARAMETERS: Event - The fixed event or GPE
+ * Type - The type of event
+ * Status - Where the current status of the event will
+ * be returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Obtains and returns the current status of the event
+ *
+ ******************************************************************************/
+
+
+ACPI_STATUS
+AcpiGetEventStatus (
+ UINT32 Event,
+ UINT32 Type,
+ ACPI_EVENT_STATUS *EventStatus)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_GPE_EVENT_INFO *GpeEventInfo;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiGetEventStatus");
+
+
+ if (!EventStatus)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+
+ /* The Type must be either Fixed Event or GPE */
+
+ switch (Type)
+ {
+ case ACPI_EVENT_FIXED:
+
+ /* Decode the Fixed Event */
+
+ if (Event > ACPI_EVENT_MAX)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Get the status of the requested fixed event */
+
+ Status = AcpiGetRegister (AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
+ EventStatus, ACPI_MTX_LOCK);
+ break;
+
+
+ case ACPI_EVENT_GPE:
+
+ /* Ensure that we have a valid GPE number */
+
+ GpeEventInfo = AcpiEvGetGpeEventInfo (Event);
+ if (!GpeEventInfo)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Obtain status on the requested GPE number */
+
+ Status = AcpiHwGetGpeStatus (Event, EventStatus);
+ break;
+
+
+ default:
+ Status = AE_BAD_PARAMETER;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/evxfregn.c b/sys/contrib/dev/acpica/evxfregn.c
new file mode 100644
index 0000000..6bd920c
--- /dev/null
+++ b/sys/contrib/dev/acpica/evxfregn.c
@@ -0,0 +1,520 @@
+/******************************************************************************
+ *
+ * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and
+ * Address Spaces.
+ * $Revision: 53 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 %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 (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
new file mode 100644
index 0000000..48190e9
--- /dev/null
+++ b/sys/contrib/dev/acpica/exconfig.c
@@ -0,0 +1,562 @@
+/******************************************************************************
+ *
+ * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes)
+ * $Revision: 71 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 (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;
+
+ 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_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) != 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
new file mode 100644
index 0000000..3b175ae
--- /dev/null
+++ b/sys/contrib/dev/acpica/exconvrt.c
@@ -0,0 +1,813 @@
+/******************************************************************************
+ *
+ * Module Name: exconvrt - Object conversion routines
+ * $Revision: 49 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 */
+
+ 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.
+ * Need enough space for one integer
+ */
+ RetDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth);
+ if (!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));
+ }
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ /*
+ * Create a new Buffer object
+ * Size will be the string length
+ */
+ RetDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) ObjDesc->String.Length);
+ if (!RetDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Copy the string to the buffer */
+
+ 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 */
+
+ 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
+ * DataWidth - Size of data item to be converted
+ *
+ * RETURN: Actual string length
+ *
+ * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiExConvertToAscii (
+ ACPI_INTEGER Integer,
+ UINT32 Base,
+ UINT8 *String,
+ UINT8 DataWidth)
+{
+ UINT32 i;
+ UINT32 j;
+ UINT32 k = 0;
+ char HexDigit;
+ ACPI_INTEGER Digit;
+ UINT32 Remainder;
+ UINT32 Length;
+ BOOLEAN LeadingZero;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+ if (DataWidth < sizeof (ACPI_INTEGER))
+ {
+ LeadingZero = FALSE;
+ Length = DataWidth;
+ }
+ else
+ {
+ LeadingZero = TRUE;
+ Length = sizeof (ACPI_INTEGER);
+ }
+
+
+ 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 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, sizeof (ACPI_INTEGER));
+
+ /* 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;
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ /* Find the string length */
+
+ Pointer = ObjDesc->Buffer.Pointer;
+ for (StringLength = 0; StringLength < ObjDesc->Buffer.Length; StringLength++)
+ {
+ /* Exit on null terminator */
+
+ if (!Pointer[StringLength])
+ {
+ break;
+ }
+ }
+
+ 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);
+ }
+
+ /* Copy the appropriate number of buffer characters */
+
+ ACPI_MEMCPY (NewBuf, Pointer, StringLength);
+
+ /* Null terminate */
+
+ NewBuf [StringLength] = 0;
+ RetDesc->Buffer.Pointer = NewBuf;
+ RetDesc->String.Length = StringLength;
+ break;
+
+
+ default:
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+
+ /*
+ * If we are about to overwrite the original object on the operand stack,
+ * we must remove a reference on the original object because we are
+ * essentially removing it from the stack.
+ */
+ if (*ResultDesc == ObjDesc)
+ {
+ if (WalkState->Opcode != AML_STORE_OP)
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+ }
+
+ *ResultDesc = RetDesc;
+ 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 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 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
new file mode 100644
index 0000000..f5bc176
--- /dev/null
+++ b/sys/contrib/dev/acpica/excreate.c
@@ -0,0 +1,728 @@
+/******************************************************************************
+ *
+ * Module Name: excreate - Named object creation
+ * $Revision: 99 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 = 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 == 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 = 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 (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 (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
new file mode 100644
index 0000000..798b3c0
--- /dev/null
+++ b/sys/contrib/dev/acpica/exdump.c
@@ -0,0 +1,901 @@
+/******************************************************************************
+ *
+ * Module Name: exdump - Interpreter debug output routines
+ * $Revision: 166 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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;
+ 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 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 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 ",
+ ObjDesc->String.Length, ObjDesc->String.Pointer);
+ AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);
+ AcpiOsPrintf ("\n");
+ break;
+
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ AcpiOsPrintf ("BankField\n");
+ break;
+
+
+ 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 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,
+ char *Ident,
+ UINT32 NumLevels,
+ char *Note,
+ char *ModuleName,
+ UINT32 LineNumber)
+{
+ ACPI_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);
+
+ 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 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 ACPI_TYPE_LOCAL_REGION_FIELD:
+ AcpiExOutPointer ("RegionObj", ObjDesc->Field.RegionObj);
+ break;
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ AcpiExOutInteger ("Value", ObjDesc->BankField.Value);
+ AcpiExOutPointer ("RegionObj", ObjDesc->BankField.RegionObj);
+ AcpiExOutPointer ("BankObj", ObjDesc->BankField.BankObj);
+ break;
+
+ 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 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 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 ACPI_TYPE_LOCAL_NOTIFY:
+
+ AcpiExOutPointer ("Node", ObjDesc->NotifyHandler.Node);
+ AcpiExOutPointer ("Context", ObjDesc->NotifyHandler.Context);
+ break;
+
+
+ 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/exdyadic.c b/sys/contrib/dev/acpica/exdyadic.c
new file mode 100644
index 0000000..ef434a2
--- /dev/null
+++ b/sys/contrib/dev/acpica/exdyadic.c
@@ -0,0 +1,939 @@
+/******************************************************************************
+ *
+ * Module Name: exdyadic - ACPI AML execution for dyadic (2-operand) operators
+ * $Revision: 91 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, 2000, 2001, 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 __EXDYADIC_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "acnamesp.h"
+#include "acinterp.h"
+#include "acevents.h"
+#include "amlcode.h"
+#include "acdispat.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ MODULE_NAME ("exdyadic")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDoConcatenate
+ *
+ * PARAMETERS: *ObjDesc - Object to be converted. Must be an
+ * Integer, Buffer, or String
+ * WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Concatenate two objects OF THE SAME TYPE.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDoConcatenate (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT *ObjDesc2,
+ ACPI_OPERAND_OBJECT **ActualRetDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ UINT32 i;
+ ACPI_INTEGER ThisInteger;
+ ACPI_OPERAND_OBJECT *RetDesc;
+ NATIVE_CHAR *NewBuf;
+ UINT32 IntegerSize = sizeof (ACPI_INTEGER);
+
+
+ FUNCTION_ENTRY ();
+
+
+ /*
+ * There are three cases to handle:
+ * 1) Two Integers concatenated to produce a buffer
+ * 2) Two Strings concatenated to produce a string
+ * 3) Two Buffers concatenated to produce a buffer
+ */
+ switch (ObjDesc->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+
+ /* Handle both ACPI 1.0 and ACPI 2.0 Integer widths */
+
+ if (WalkState->MethodNode->Flags & ANOBJ_DATA_WIDTH_32)
+ {
+ /*
+ * 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
+ */
+ IntegerSize = sizeof (UINT32);
+ }
+
+ /* Result of two integers is a buffer */
+
+ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
+ if (!RetDesc)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Need enough space for two integers */
+
+ RetDesc->Buffer.Length = IntegerSize * 2;
+ NewBuf = ACPI_MEM_CALLOCATE (RetDesc->Buffer.Length);
+ if (!NewBuf)
+ {
+ REPORT_ERROR
+ (("ExDoConcatenate: Buffer allocation failure\n"));
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ RetDesc->Buffer.Pointer = (UINT8 *) NewBuf;
+
+ /* Convert the first integer */
+
+ ThisInteger = ObjDesc->Integer.Value;
+ for (i = 0; i < IntegerSize; i++)
+ {
+ NewBuf[i] = (UINT8) ThisInteger;
+ ThisInteger >>= 8;
+ }
+
+ /* Convert the second integer */
+
+ ThisInteger = ObjDesc2->Integer.Value;
+ for (; i < (IntegerSize * 2); i++)
+ {
+ NewBuf[i] = (UINT8) ThisInteger;
+ ThisInteger >>= 8;
+ }
+
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING);
+ if (!RetDesc)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Operand1 is string */
+
+ NewBuf = ACPI_MEM_ALLOCATE (ObjDesc->String.Length +
+ ObjDesc2->String.Length + 1);
+ if (!NewBuf)
+ {
+ REPORT_ERROR
+ (("ExDoConcatenate: String allocation failure\n"));
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ STRCPY (NewBuf, ObjDesc->String.Pointer);
+ STRCPY (NewBuf + ObjDesc->String.Length,
+ ObjDesc2->String.Pointer);
+
+ /* Point the return object to the new string */
+
+ RetDesc->String.Pointer = NewBuf;
+ RetDesc->String.Length = ObjDesc->String.Length +=
+ ObjDesc2->String.Length;
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ /* Operand1 is a buffer */
+
+ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
+ if (!RetDesc)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ NewBuf = ACPI_MEM_ALLOCATE (ObjDesc->Buffer.Length +
+ ObjDesc2->Buffer.Length);
+ if (!NewBuf)
+ {
+ REPORT_ERROR
+ (("ExDoConcatenate: Buffer allocation failure\n"));
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ MEMCPY (NewBuf, ObjDesc->Buffer.Pointer,
+ ObjDesc->Buffer.Length);
+ MEMCPY (NewBuf + ObjDesc->Buffer.Length, ObjDesc2->Buffer.Pointer,
+ ObjDesc2->Buffer.Length);
+
+ /*
+ * Point the return object to the new buffer
+ */
+
+ RetDesc->Buffer.Pointer = (UINT8 *) NewBuf;
+ RetDesc->Buffer.Length = ObjDesc->Buffer.Length +
+ ObjDesc2->Buffer.Length;
+ break;
+
+ default:
+ Status = AE_AML_INTERNAL;
+ RetDesc = NULL;
+ }
+
+
+ *ActualRetDesc = RetDesc;
+ return (AE_OK);
+
+
+Cleanup:
+
+ AcpiUtRemoveReference (RetDesc);
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDyadic1
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 1 dyadic operator with numeric operands:
+ * NotifyOp
+ *
+ * ALLOCATION: Deletes both operands
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDyadic1 (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status = AE_OK;
+
+
+ FUNCTION_TRACE_PTR ("ExDyadic1", WALK_OPERANDS);
+
+
+
+ /* 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];
+ Operand[0] = NULL;
+
+ /* The node must refer to a device or thermal zone */
+
+ if (Node && Operand[1])
+ {
+ switch (Node->Type)
+ {
+ case ACPI_TYPE_DEVICE:
+ case ACPI_TYPE_THERMAL:
+
+ /*
+ * 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_DEBUG_PRINT ((ACPI_DB_ERROR, "Unexpected notify object type %X\n",
+ Node->Type));
+
+ Status = AE_AML_OPERAND_TYPE;
+ break;
+ }
+ }
+ break;
+
+ default:
+
+ REPORT_ERROR (("AcpiExDyadic1: Unknown dyadic opcode %X\n", WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ }
+
+
+ /* Always delete both operands */
+
+ AcpiUtRemoveReference (Operand[1]);
+ AcpiUtRemoveReference (Operand[0]);
+
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDyadic2R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 2 dyadic operator with numeric operands and
+ * one or two result operands.
+ *
+ * ALLOCATION: Deletes one operand descriptor -- other remains on stack
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDyadic2R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *RetDesc = NULL;
+ ACPI_OPERAND_OBJECT *RetDesc2 = NULL;
+ ACPI_STATUS Status = AE_OK;
+
+
+ FUNCTION_TRACE_U32 ("ExDyadic2R", WalkState->Opcode);
+
+
+ /* Create an internal return object if necessary */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_ADD_OP:
+ case AML_BIT_AND_OP:
+ case AML_BIT_NAND_OP:
+ case AML_BIT_OR_OP:
+ case AML_BIT_NOR_OP:
+ case AML_BIT_XOR_OP:
+ case AML_DIVIDE_OP:
+ case AML_MOD_OP:
+ case AML_MULTIPLY_OP:
+ case AML_SHIFT_LEFT_OP:
+ case AML_SHIFT_RIGHT_OP:
+ case AML_SUBTRACT_OP:
+
+ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ break;
+ }
+
+
+ /*
+ * Execute the opcode
+ */
+ switch (WalkState->Opcode)
+ {
+
+ case AML_ADD_OP: /* Add (Operand1, Operand2, Result) */
+
+ RetDesc->Integer.Value = Operand[0]->Integer.Value +
+ Operand[1]->Integer.Value;
+ break;
+
+
+ case AML_BIT_AND_OP: /* And (Operand1, Operand2, Result) */
+
+ RetDesc->Integer.Value = Operand[0]->Integer.Value &
+ Operand[1]->Integer.Value;
+ break;
+
+
+ case AML_BIT_NAND_OP: /* NAnd (Operand1, Operand2, Result) */
+
+ RetDesc->Integer.Value = ~(Operand[0]->Integer.Value &
+ Operand[1]->Integer.Value);
+ break;
+
+
+ case AML_BIT_OR_OP: /* Or (Operand1, Operand2, Result) */
+
+ RetDesc->Integer.Value = Operand[0]->Integer.Value |
+ Operand[1]->Integer.Value;
+ break;
+
+
+ case AML_BIT_NOR_OP: /* NOr (Operand1, Operand2, Result) */
+
+ RetDesc->Integer.Value = ~(Operand[0]->Integer.Value |
+ Operand[1]->Integer.Value);
+ break;
+
+
+ case AML_BIT_XOR_OP: /* XOr (Operand1, Operand2, Result) */
+
+ RetDesc->Integer.Value = Operand[0]->Integer.Value ^
+ Operand[1]->Integer.Value;
+ break;
+
+
+ case AML_DIVIDE_OP: /* Divide (Dividend, Divisor, RemainderResult QuotientRsult) */
+
+ if (!Operand[1]->Integer.Value)
+ {
+ REPORT_ERROR (("DivideOp: Divide by zero\n"));
+
+ Status = AE_AML_DIVIDE_BY_ZERO;
+ goto Cleanup;
+ }
+
+ RetDesc2 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!RetDesc2)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * RetDesc2 will contain the quotient,
+ * RetDesc will contain the remainder
+ */
+ Status = AcpiUtDivide (&Operand[0]->Integer.Value, &Operand[1]->Integer.Value,
+ &RetDesc2->Integer.Value, &RetDesc->Integer.Value);
+
+ break;
+
+
+ case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */
+
+ if (!Operand[1]->Integer.Value)
+ {
+ REPORT_ERROR (("ModOp: Divide by zero\n"));
+
+ Status = AE_AML_DIVIDE_BY_ZERO;
+ goto Cleanup;
+ }
+
+ /* RetDesc will contain the remainder */
+
+ Status = AcpiUtDivide (&Operand[0]->Integer.Value, &Operand[1]->Integer.Value,
+ NULL, &RetDesc->Integer.Value);
+
+ break;
+
+
+ case AML_MULTIPLY_OP: /* Multiply (Operand1, Operand2, Result) */
+
+ RetDesc->Integer.Value = Operand[0]->Integer.Value *
+ Operand[1]->Integer.Value;
+ break;
+
+
+ case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result) */
+
+ RetDesc->Integer.Value = Operand[0]->Integer.Value <<
+ Operand[1]->Integer.Value;
+ break;
+
+
+ case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */
+
+ RetDesc->Integer.Value = Operand[0]->Integer.Value >>
+ Operand[1]->Integer.Value;
+ break;
+
+
+ case AML_SUBTRACT_OP: /* Subtract (Operand1, Operand2, Result) */
+
+ RetDesc->Integer.Value = Operand[0]->Integer.Value -
+ Operand[1]->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 (Operand[0]->Common.Type)
+ {
+ case ACPI_TYPE_INTEGER:
+ Status = AcpiExConvertToInteger (Operand[1], &Operand[1], WalkState);
+ break;
+
+ case ACPI_TYPE_STRING:
+ Status = AcpiExConvertToString (Operand[1], &Operand[1], 16, ACPI_UINT32_MAX, WalkState);
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ Status = AcpiExConvertToBuffer (Operand[1], &Operand[1], 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], Operand[1], &RetDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+ break;
+
+
+ case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */
+
+ Status = AcpiExConvertToString (Operand[0], &RetDesc, 16,
+ (UINT32) Operand[1]->Integer.Value, WalkState);
+ break;
+
+
+ case AML_CONCAT_RES_OP: /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */
+
+ Status = AE_NOT_IMPLEMENTED;
+ goto Cleanup;
+ break;
+
+
+ default:
+
+ REPORT_ERROR (("AcpiExDyadic2R: Unknown dyadic opcode %X\n",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+ /*
+ * Store the result of the operation (which is now in Operand[0]) into
+ * the result descriptor, or the location pointed to by the result
+ * descriptor (Operand[2]).
+ */
+ Status = AcpiExStore (RetDesc, Operand[2], WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ if (AML_DIVIDE_OP == WalkState->Opcode)
+ {
+ Status = AcpiExStore (RetDesc2, Operand[3], WalkState);
+
+ /*
+ * Since the remainder is not returned, remove a reference to
+ * the object we created earlier
+ */
+ AcpiUtRemoveReference (RetDesc);
+ WalkState->ResultObj = RetDesc2;
+ }
+
+ else
+ {
+ WalkState->ResultObj = RetDesc;
+ }
+
+
+Cleanup:
+
+ /* Always delete the operands */
+
+ AcpiUtRemoveReference (Operand[0]);
+ AcpiUtRemoveReference (Operand[1]);
+
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ /* On failure, delete the result ops */
+
+ AcpiUtRemoveReference (Operand[2]);
+ AcpiUtRemoveReference (Operand[3]);
+
+ if (RetDesc)
+ {
+ /* And delete the internal return object */
+
+ AcpiUtRemoveReference (RetDesc);
+ RetDesc = NULL;
+ }
+ }
+
+ /* Set the return object and exit */
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDyadic2S
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 2 dyadic synchronization operator
+ *
+ * ALLOCATION: Deletes one operand descriptor -- other remains on stack
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDyadic2S (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *RetDesc = NULL;
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE_PTR ("ExDyadic2S", WALK_OPERANDS);
+
+
+
+ /* Create the internal return object */
+
+ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /* Default return value is FALSE, operation did not time out */
+
+ RetDesc->Integer.Value = 0;
+
+
+ /* Examine the opcode */
+
+ switch (WalkState->Opcode)
+ {
+
+ case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */
+
+ Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState);
+ break;
+
+
+ case AML_WAIT_OP: /* Wait (EventObject, Timeout) */
+
+ Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]);
+ break;
+
+
+ default:
+
+ REPORT_ERROR (("AcpiExDyadic2S: Unknown dyadic synchronization opcode %X\n", WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+ /*
+ * Return a boolean indicating if operation timed out
+ * (TRUE) or not (FALSE)
+ */
+ if (Status == AE_TIME)
+ {
+ RetDesc->Integer.Value = ACPI_INTEGER_MAX; /* TRUE, op timed out */
+ Status = AE_OK;
+ }
+
+
+Cleanup:
+
+ /* Delete params */
+
+ AcpiUtRemoveReference (Operand[1]);
+ AcpiUtRemoveReference (Operand[0]);
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status) &&
+ (RetDesc))
+ {
+ AcpiUtRemoveReference (RetDesc);
+ RetDesc = NULL;
+ }
+
+
+ /* Set the return object and exit */
+
+ WalkState->ResultObj = RetDesc;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDyadic2
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 2 dyadic operator with numeric operands and
+ * no result operands
+ *
+ * ALLOCATION: Deletes one operand descriptor -- other remains on stack
+ * containing result value
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDyadic2 (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *RetDesc = NULL;
+ ACPI_STATUS Status = AE_OK;
+ BOOLEAN Lboolean;
+
+
+ FUNCTION_TRACE_PTR ("ExDyadic2", WALK_OPERANDS);
+
+
+ /* Create the internal return object */
+
+ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ /*
+ * Execute the WalkState->Opcode
+ */
+ Lboolean = FALSE;
+ switch (WalkState->Opcode)
+ {
+
+ case AML_LAND_OP: /* LAnd (Operand1, Operand2) */
+
+ Lboolean = (BOOLEAN) (Operand[0]->Integer.Value &&
+ Operand[1]->Integer.Value);
+ break;
+
+
+ case AML_LEQUAL_OP: /* LEqual (Operand1, Operand2) */
+
+ Lboolean = (BOOLEAN) (Operand[0]->Integer.Value ==
+ Operand[1]->Integer.Value);
+ break;
+
+
+ case AML_LGREATER_OP: /* LGreater (Operand1, Operand2) */
+
+ Lboolean = (BOOLEAN) (Operand[0]->Integer.Value >
+ Operand[1]->Integer.Value);
+ break;
+
+
+ case AML_LLESS_OP: /* LLess (Operand1, Operand2) */
+
+ Lboolean = (BOOLEAN) (Operand[0]->Integer.Value <
+ Operand[1]->Integer.Value);
+ break;
+
+
+ case AML_LOR_OP: /* LOr (Operand1, Operand2) */
+
+ Lboolean = (BOOLEAN) (Operand[0]->Integer.Value ||
+ Operand[1]->Integer.Value);
+ break;
+
+
+ case AML_COPY_OP: /* Copy (Source, Target) (ACPI 2.0) */
+
+ Status = AE_NOT_IMPLEMENTED;
+ goto Cleanup;
+ break;
+
+
+ default:
+
+ REPORT_ERROR (("AcpiExDyadic2: Unknown dyadic opcode %X\n", WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ break;
+ }
+
+
+ /* Set return value to logical TRUE (all ones) or FALSE (zero) */
+
+ if (Lboolean)
+ {
+ RetDesc->Integer.Value = ACPI_INTEGER_MAX;
+ }
+ else
+ {
+ RetDesc->Integer.Value = 0;
+ }
+
+
+Cleanup:
+
+ /* Always delete operands */
+
+ AcpiUtRemoveReference (Operand[0]);
+ AcpiUtRemoveReference (Operand[1]);
+
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status) &&
+ (RetDesc))
+ {
+ AcpiUtRemoveReference (RetDesc);
+ RetDesc = NULL;
+ }
+
+
+ /* Set the return object and exit */
+
+ WalkState->ResultObj = RetDesc;
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/exfield.c b/sys/contrib/dev/acpica/exfield.c
new file mode 100644
index 0000000..2b253f3
--- /dev/null
+++ b/sys/contrib/dev/acpica/exfield.c
@@ -0,0 +1,463 @@
+/******************************************************************************
+ *
+ * Module Name: exfield - ACPI AML (p-code) execution - field manipulation
+ * $Revision: 118 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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;
+ ACPI_SIZE 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_SIZE) 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 = AcpiUtCreateBufferObject (Length);
+ if (!BufferDesc)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+ 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, (UINT32) 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, (UINT32) Length);
+ 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 **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);
+ 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/exfldio.c b/sys/contrib/dev/acpica/exfldio.c
new file mode 100644
index 0000000..9bfc5d9
--- /dev/null
+++ b/sys/contrib/dev/acpica/exfldio.c
@@ -0,0 +1,1185 @@
+/******************************************************************************
+ *
+ * Module Name: exfldio - Aml Field I/O
+ * $Revision: 92 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __EXFLDIO_C__
+
+#include "acpi.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acevents.h"
+#include "acdispat.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exfldio")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSetupRegion
+ *
+ * PARAMETERS: *ObjDesc - Field to be read or written
+ * FieldDatumByteOffset - Byte offset of this datum within the
+ * parent field
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Common processing for AcpiExExtractFromField and
+ * AcpiExInsertIntoField. Initialize the
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSetupRegion (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *RgnDesc;
+
+
+ ACPI_FUNCTION_TRACE_U32 ("ExSetupRegion", FieldDatumByteOffset);
+
+
+ RgnDesc = ObjDesc->CommonField.RegionObj;
+
+ /* We must have a valid region */
+
+ if (ACPI_GET_OBJECT_TYPE (RgnDesc) != ACPI_TYPE_REGION)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Needed Region, found type %X (%s)\n",
+ ACPI_GET_OBJECT_TYPE (RgnDesc),
+ AcpiUtGetObjectTypeName (RgnDesc)));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * If the Region Address and Length have not been previously evaluated,
+ * evaluate them now and save the results.
+ */
+ if (!(RgnDesc->Region.Flags & AOPOBJ_DATA_VALID))
+ {
+ Status = AcpiDsGetRegionArguments (RgnDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ if (RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
+ {
+ /* SMBus has a non-linear address space */
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Validate the request. The entire request from the byte offset for a
+ * length of one field datum (access width) must fit within the region.
+ * (Region length is specified in bytes)
+ */
+ if (RgnDesc->Region.Length < (ObjDesc->CommonField.BaseByteOffset
+ + FieldDatumByteOffset
+ + ObjDesc->CommonField.AccessByteWidth))
+ {
+ if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth)
+ {
+ /*
+ * This is the case where the AccessType (AccWord, etc.) is wider
+ * than the region itself. For example, a region of length one
+ * byte, and a field with Dword access specified.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)\n",
+ ObjDesc->CommonField.Node->Name.Ascii, ObjDesc->CommonField.AccessByteWidth,
+ RgnDesc->Region.Node->Name.Ascii, RgnDesc->Region.Length));
+ }
+
+ /*
+ * Offset rounded up to next multiple of field width
+ * exceeds region length, indicate an error
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)\n",
+ ObjDesc->CommonField.Node->Name.Ascii, ObjDesc->CommonField.BaseByteOffset,
+ FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth,
+ RgnDesc->Region.Node->Name.Ascii, RgnDesc->Region.Length));
+
+ return_ACPI_STATUS (AE_AML_REGION_LIMIT);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExAccessRegion
+ *
+ * PARAMETERS: *ObjDesc - Field to be read
+ * FieldDatumByteOffset - Byte offset of this datum within the
+ * parent field
+ * *Value - Where to store value (must at least
+ * the size of ACPI_INTEGER)
+ * Function - Read or Write flag plus other region-
+ * dependent flags
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read or Write a single field datum to an Operation Region.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExAccessRegion (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset,
+ ACPI_INTEGER *Value,
+ UINT32 Function)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *RgnDesc;
+ ACPI_PHYSICAL_ADDRESS Address;
+
+
+ ACPI_FUNCTION_TRACE ("ExAccessRegion");
+
+
+ /*
+ * Ensure that the region operands are fully evaluated and verify
+ * the validity of the request
+ */
+ Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * The physical address of this field datum is:
+ *
+ * 1) The base of the region, plus
+ * 2) The base offset of the field, plus
+ * 3) The current offset into the field
+ */
+ RgnDesc = ObjDesc->CommonField.RegionObj;
+ Address = RgnDesc->Region.Address
+ + ObjDesc->CommonField.BaseByteOffset
+ + FieldDatumByteOffset;
+
+ if ((Function & ACPI_IO_MASK) == ACPI_READ)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]"));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]"));
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD,
+ " Region[%s-%X] Access %X Base:Off %X:%X at %8.8X%8.8X\n",
+ AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
+ RgnDesc->Region.SpaceId,
+ ObjDesc->CommonField.AccessByteWidth,
+ ObjDesc->CommonField.BaseByteOffset,
+ FieldDatumByteOffset,
+ ACPI_HIDWORD (Address), ACPI_LODWORD (Address)));
+
+ /* Invoke the appropriate AddressSpace/OpRegion handler */
+
+ Status = AcpiEvAddressSpaceDispatch (RgnDesc, Function,
+ Address, ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value);
+
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_NOT_IMPLEMENTED)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Region %s(%X) not implemented\n",
+ AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
+ RgnDesc->Region.SpaceId));
+ }
+ else if (Status == AE_NOT_EXIST)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Region %s(%X) has no handler\n",
+ AcpiUtGetRegionName (RgnDesc->Region.SpaceId),
+ RgnDesc->Region.SpaceId));
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExRegisterOverflow
+ *
+ * PARAMETERS: *ObjDesc - Register(Field) to be written
+ * Value - Value to be stored
+ *
+ * RETURN: TRUE if value overflows the field, FALSE otherwise
+ *
+ * DESCRIPTION: Check if a value is out of range of the field being written.
+ * Used to check if the values written to Index and Bank registers
+ * are out of range. Normally, the value is simply truncated
+ * to fit the field, but this case is most likely a serious
+ * coding error in the ASL.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiExRegisterOverflow (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_INTEGER Value)
+{
+
+ if (ObjDesc->CommonField.BitLength >= ACPI_INTEGER_BIT_SIZE)
+ {
+ /*
+ * The field is large enough to hold the maximum integer, so we can
+ * never overflow it.
+ */
+ return (FALSE);
+ }
+
+ if (Value >= ((ACPI_INTEGER) 1 << ObjDesc->CommonField.BitLength))
+ {
+ /*
+ * The Value is larger than the maximum value that can fit into
+ * the register.
+ */
+ return (TRUE);
+ }
+
+ /* The Value will fit into the field with no truncation */
+
+ return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExFieldDatumIo
+ *
+ * PARAMETERS: *ObjDesc - Field to be read
+ * FieldDatumByteOffset - Byte offset of this datum within the
+ * parent field
+ * *Value - Where to store value (must be 64 bits)
+ * ReadWrite - Read or Write flag
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Read or Write a single datum of a field. The FieldType is
+ * demultiplexed here to handle the different types of fields
+ * (BufferField, RegionField, IndexField, BankField)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExFieldDatumIo (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ UINT32 FieldDatumByteOffset,
+ ACPI_INTEGER *Value,
+ UINT32 ReadWrite)
+{
+ ACPI_STATUS Status;
+ ACPI_INTEGER LocalValue;
+
+
+ ACPI_FUNCTION_TRACE_U32 ("ExFieldDatumIo", FieldDatumByteOffset);
+
+
+ if (ReadWrite == ACPI_READ)
+ {
+ if (!Value)
+ {
+ LocalValue = 0;
+ Value = &LocalValue; /* To support reads without saving return value */
+ }
+
+ /* Clear the entire return buffer first, [Very Important!] */
+
+ *Value = 0;
+ }
+
+ /*
+ * The four types of fields are:
+ *
+ * BufferFields - Read/write from/to a Buffer
+ * RegionFields - Read/write from/to a Operation Region.
+ * BankFields - Write to a Bank Register, then read/write from/to an OpRegion
+ * IndexFields - Write to an Index Register, then read/write from/to a Data Register
+ */
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
+ {
+ case 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);
+ }
+ }
+
+ if (ReadWrite == ACPI_READ)
+ {
+ /*
+ * Copy the data from the source buffer.
+ * Length is the field width in bytes.
+ */
+ ACPI_MEMCPY (Value, (ObjDesc->BufferField.BufferObj)->Buffer.Pointer
+ + ObjDesc->BufferField.BaseByteOffset
+ + FieldDatumByteOffset,
+ ObjDesc->CommonField.AccessByteWidth);
+ }
+ else
+ {
+ /*
+ * Copy the data to the target buffer.
+ * Length is the field width in bytes.
+ */
+ ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer
+ + ObjDesc->BufferField.BaseByteOffset
+ + FieldDatumByteOffset,
+ Value, ObjDesc->CommonField.AccessByteWidth);
+ }
+
+ Status = AE_OK;
+ break;
+
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ /* Ensure that the BankValue is not beyond the capacity of the register */
+
+ if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj,
+ (ACPI_INTEGER) ObjDesc->BankField.Value))
+ {
+ return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
+ }
+
+ /*
+ * For BankFields, we must write the BankValue to the BankRegister
+ * (itself a RegionField) before we can access the data.
+ */
+ Status = AcpiExInsertIntoField (ObjDesc->BankField.BankObj,
+ &ObjDesc->BankField.Value,
+ sizeof (ObjDesc->BankField.Value));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Now that the Bank has been selected, fall through to the
+ * RegionField case and write the datum to the Operation Region
+ */
+
+ /*lint -fallthrough */
+
+
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ /*
+ * For simple RegionFields, we just directly access the owning
+ * Operation Region.
+ */
+ Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value,
+ ReadWrite);
+ break;
+
+
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+
+ /* Ensure that the IndexValue is not beyond the capacity of the register */
+
+ if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj,
+ (ACPI_INTEGER) ObjDesc->IndexField.Value))
+ {
+ return_ACPI_STATUS (AE_AML_REGISTER_LIMIT);
+ }
+
+ /* Write the index value to the IndexRegister (itself a RegionField) */
+
+ Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj,
+ &ObjDesc->IndexField.Value,
+ sizeof (ObjDesc->IndexField.Value));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ReadWrite == ACPI_READ)
+ {
+ /* Read the datum from the DataRegister */
+
+ Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj,
+ Value, ObjDesc->CommonField.AccessByteWidth);
+ }
+ else
+ {
+ /* Write the datum to the Data register */
+
+ Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj,
+ Value, ObjDesc->CommonField.AccessByteWidth);
+ }
+ break;
+
+
+ default:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%p, Wrong object type - %s\n",
+ ObjDesc, AcpiUtGetObjectTypeName (ObjDesc)));
+ Status = AE_AML_INTERNAL;
+ break;
+ }
+
+ if (ACPI_SUCCESS (Status))
+ {
+ if (ReadWrite == ACPI_READ)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Read=%8.8X%8.8X\n",
+ ACPI_HIDWORD (*Value), ACPI_LODWORD (*Value)));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Value Written=%8.8X%8.8X\n",
+ ACPI_HIDWORD (*Value), ACPI_LODWORD (*Value)));
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExWriteWithUpdateRule
+ *
+ * PARAMETERS: *ObjDesc - Field to be set
+ * Value - Value to store
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Apply the field update rule to a field write
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExWriteWithUpdateRule (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_INTEGER Mask,
+ ACPI_INTEGER FieldValue,
+ UINT32 FieldDatumByteOffset)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_INTEGER MergedValue;
+ ACPI_INTEGER CurrentValue;
+
+
+ ACPI_FUNCTION_TRACE_U32 ("ExWriteWithUpdateRule", Mask);
+
+
+ /* Start with the new bits */
+
+ MergedValue = FieldValue;
+
+ /* If the mask is all ones, we don't need to worry about the update rule */
+
+ if (Mask != ACPI_INTEGER_MAX)
+ {
+ /* Decode the update rule */
+
+ switch (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)
+ {
+ case AML_FIELD_UPDATE_PRESERVE:
+ /*
+ * Check if update rule needs to be applied (not if mask is all
+ * ones) The left shift drops the bits we want to ignore.
+ */
+ if ((~Mask << (ACPI_MUL_8 (sizeof (Mask)) -
+ ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0)
+ {
+ /*
+ * Read the current contents of the byte/word/dword containing
+ * the field, and merge with the new field value.
+ */
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &CurrentValue, ACPI_READ);
+ MergedValue |= (CurrentValue & ~Mask);
+ }
+ break;
+
+ case AML_FIELD_UPDATE_WRITE_AS_ONES:
+
+ /* Set positions outside the field to all ones */
+
+ MergedValue |= ~Mask;
+ break;
+
+ case AML_FIELD_UPDATE_WRITE_AS_ZEROS:
+
+ /* Set positions outside the field to all zeros */
+
+ MergedValue &= Mask;
+ break;
+
+ default:
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "WriteWithUpdateRule: Unknown UpdateRule setting: %X\n",
+ (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK)));
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ }
+ }
+
+ /* Write the merged value */
+
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &MergedValue, ACPI_WRITE);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Mask %8.8X%8.8X DatumOffset %X Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n",
+ ACPI_HIDWORD (Mask), ACPI_LODWORD (Mask),
+ FieldDatumByteOffset,
+ ACPI_HIDWORD (FieldValue), ACPI_LODWORD (FieldValue),
+ ACPI_HIDWORD (MergedValue),ACPI_LODWORD (MergedValue)));
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExGetBufferDatum
+ *
+ * PARAMETERS: Datum - Where the Datum is returned
+ * Buffer - Raw field buffer
+ * ByteGranularity - 1/2/4/8 Granularity of the field
+ * (aka Datum Size)
+ * Offset - Datum offset into the buffer
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Get a datum from the buffer according to the buffer field
+ * byte granularity
+ *
+ ******************************************************************************/
+
+void
+AcpiExGetBufferDatum(
+ ACPI_INTEGER *Datum,
+ void *Buffer,
+ UINT32 ByteGranularity,
+ UINT32 Offset)
+{
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ switch (ByteGranularity)
+ {
+ case ACPI_FIELD_BYTE_GRANULARITY:
+
+ *Datum = ((UINT8 *) Buffer) [Offset];
+ break;
+
+ case ACPI_FIELD_WORD_GRANULARITY:
+
+ ACPI_MOVE_UNALIGNED16_TO_32 (Datum, &(((UINT16 *) Buffer) [Offset]));
+ break;
+
+ case ACPI_FIELD_DWORD_GRANULARITY:
+
+ ACPI_MOVE_UNALIGNED32_TO_32 (Datum, &(((UINT32 *) Buffer) [Offset]));
+ break;
+
+ case ACPI_FIELD_QWORD_GRANULARITY:
+
+ ACPI_MOVE_UNALIGNED64_TO_64 (Datum, &(((UINT64 *) Buffer) [Offset]));
+ break;
+
+ default:
+ /* Should not get here */
+ break;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSetBufferDatum
+ *
+ * PARAMETERS: MergedDatum - Value to store
+ * Buffer - Receiving buffer
+ * ByteGranularity - 1/2/4/8 Granularity of the field
+ * (aka Datum Size)
+ * Offset - Datum offset into the buffer
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Store the merged datum to the buffer according to the
+ * byte granularity
+ *
+ ******************************************************************************/
+
+void
+AcpiExSetBufferDatum (
+ ACPI_INTEGER MergedDatum,
+ void *Buffer,
+ UINT32 ByteGranularity,
+ UINT32 Offset)
+{
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ switch (ByteGranularity)
+ {
+ case ACPI_FIELD_BYTE_GRANULARITY:
+
+ ((UINT8 *) Buffer) [Offset] = (UINT8) MergedDatum;
+ break;
+
+ case ACPI_FIELD_WORD_GRANULARITY:
+
+ ACPI_MOVE_UNALIGNED16_TO_16 (&(((UINT16 *) Buffer)[Offset]), &MergedDatum);
+ break;
+
+ case ACPI_FIELD_DWORD_GRANULARITY:
+
+ ACPI_MOVE_UNALIGNED32_TO_32 (&(((UINT32 *) Buffer)[Offset]), &MergedDatum);
+ break;
+
+ case ACPI_FIELD_QWORD_GRANULARITY:
+
+ ACPI_MOVE_UNALIGNED64_TO_64 (&(((UINT64 *) Buffer)[Offset]), &MergedDatum);
+ break;
+
+ default:
+ /* Should not get here */
+ break;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExExtractFromField
+ *
+ * PARAMETERS: *ObjDesc - Field to be read
+ * *Value - Where to store value
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Retrieve the value of the given field
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExExtractFromField (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ void *Buffer,
+ UINT32 BufferLength)
+{
+ ACPI_STATUS Status;
+ UINT32 FieldDatumByteOffset;
+ UINT32 DatumOffset;
+ ACPI_INTEGER PreviousRawDatum;
+ ACPI_INTEGER ThisRawDatum = 0;
+ ACPI_INTEGER MergedDatum = 0;
+ UINT32 ByteFieldLength;
+ UINT32 DatumCount;
+
+
+ ACPI_FUNCTION_TRACE ("ExExtractFromField");
+
+
+ /*
+ * The field must fit within the caller's buffer
+ */
+ ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength);
+ if (ByteFieldLength > BufferLength)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "Field size %X (bytes) too large for buffer (%X)\n",
+ ByteFieldLength, BufferLength));
+
+ return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+ }
+
+ /* Convert field byte count to datum count, round up if necessary */
+
+ DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength,
+ ObjDesc->CommonField.AccessByteWidth);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "ByteLen=%X, DatumLen=%X, ByteGran=%X\n",
+ ByteFieldLength, DatumCount,ObjDesc->CommonField.AccessByteWidth));
+
+ /*
+ * Clear the caller's buffer (the whole buffer length as given)
+ * This is very important, especially in the cases where a byte is read,
+ * but the buffer is really a UINT32 (4 bytes).
+ */
+ ACPI_MEMSET (Buffer, 0, BufferLength);
+
+ /* Read the first raw datum to prime the loop */
+
+ FieldDatumByteOffset = 0;
+ DatumOffset= 0;
+
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &PreviousRawDatum, ACPI_READ);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+
+ /* We might actually be done if the request fits in one datum */
+
+ if ((DatumCount == 1) &&
+ (ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM))
+ {
+ /* 1) Shift the valid data bits down to start at bit 0 */
+
+ MergedDatum = (PreviousRawDatum >> ObjDesc->CommonField.StartFieldBitOffset);
+
+ /* 2) Mask off any upper unused bits (bits not part of the field) */
+
+ if (ObjDesc->CommonField.EndBufferValidBits)
+ {
+ MergedDatum &= ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndBufferValidBits);
+ }
+
+ /* Store the datum to the caller buffer */
+
+ AcpiExSetBufferDatum (MergedDatum, Buffer, ObjDesc->CommonField.AccessByteWidth,
+ DatumOffset);
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+
+ /* We need to get more raw data to complete one or more field data */
+
+ while (DatumOffset < DatumCount)
+ {
+ FieldDatumByteOffset += ObjDesc->CommonField.AccessByteWidth;
+
+ /*
+ * If the field is aligned on a byte boundary, we don't want
+ * to perform a final read, since this would potentially read
+ * past the end of the region.
+ *
+ * We could just split the aligned and non-aligned cases since the
+ * aligned case is so very simple, but this would require more code.
+ */
+ if ((ObjDesc->CommonField.StartFieldBitOffset != 0) ||
+ ((ObjDesc->CommonField.StartFieldBitOffset == 0) &&
+ (DatumOffset < (DatumCount -1))))
+ {
+ /*
+ * Get the next raw datum, it contains some or all bits
+ * of the current field datum
+ */
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &ThisRawDatum, ACPI_READ);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Create the (possibly) merged datum to be stored to the caller buffer
+ */
+ if (ObjDesc->CommonField.StartFieldBitOffset == 0)
+ {
+ /* Field is not skewed and we can just copy the datum */
+
+ MergedDatum = PreviousRawDatum;
+ }
+ else
+ {
+ /*
+ * Put together the appropriate bits of the two raw data to make a
+ * single complete field datum
+ *
+ * 1) Normalize the first datum down to bit 0
+ */
+ MergedDatum = (PreviousRawDatum >> ObjDesc->CommonField.StartFieldBitOffset);
+
+ /* 2) Insert the second datum "above" the first datum */
+
+ MergedDatum |= (ThisRawDatum << ObjDesc->CommonField.DatumValidBits);
+
+ if ((DatumOffset >= (DatumCount -1)))
+ {
+ /*
+ * This is the last iteration of the loop. We need to clear
+ * any unused bits (bits that are not part of this field) that
+ * came from the last raw datum before we store the final
+ * merged datum into the caller buffer.
+ */
+ if (ObjDesc->CommonField.EndBufferValidBits)
+ {
+ MergedDatum &=
+ ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndBufferValidBits);
+ }
+ }
+ }
+
+ /*
+ * Store the merged field datum in the caller's buffer, according to
+ * the granularity of the field (size of each datum).
+ */
+ AcpiExSetBufferDatum (MergedDatum, Buffer,
+ ObjDesc->CommonField.AccessByteWidth, DatumOffset);
+
+ /*
+ * Save the raw datum that was just acquired since it may contain bits
+ * of the *next* field datum. Update offsets
+ */
+ PreviousRawDatum = ThisRawDatum;
+ DatumOffset++;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExInsertIntoField
+ *
+ * PARAMETERS: *ObjDesc - Field to be set
+ * Buffer - Value to store
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Store the value into the given field
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExInsertIntoField (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ void *Buffer,
+ UINT32 BufferLength)
+{
+ ACPI_STATUS Status;
+ UINT32 FieldDatumByteOffset;
+ UINT32 DatumOffset;
+ ACPI_INTEGER Mask;
+ ACPI_INTEGER MergedDatum;
+ ACPI_INTEGER PreviousRawDatum;
+ ACPI_INTEGER ThisRawDatum;
+ UINT32 ByteFieldLength;
+ UINT32 DatumCount;
+
+
+ ACPI_FUNCTION_TRACE ("ExInsertIntoField");
+
+
+ /*
+ * Incoming buffer must be at least as long as the field, we do not
+ * allow "partial" field writes. We do not care if the buffer is
+ * larger than the field, this typically happens when an integer is
+ * written to a field that is actually smaller than an integer.
+ */
+ ByteFieldLength = ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength);
+ if (BufferLength < ByteFieldLength)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Buffer length %X too small for field %X\n",
+ BufferLength, ByteFieldLength));
+
+ return_ACPI_STATUS (AE_BUFFER_OVERFLOW);
+ }
+
+ /* Convert byte count to datum count, round up if necessary */
+
+ DatumCount = ACPI_ROUND_UP_TO (ByteFieldLength, ObjDesc->CommonField.AccessByteWidth);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD,
+ "ByteLen=%X, DatumLen=%X, ByteGran=%X\n",
+ ByteFieldLength, DatumCount, ObjDesc->CommonField.AccessByteWidth));
+
+ /*
+ * Break the request into up to three parts (similar to an I/O request):
+ * 1) non-aligned part at start
+ * 2) aligned part in middle
+ * 3) non-aligned part at the end
+ */
+ FieldDatumByteOffset = 0;
+ DatumOffset= 0;
+
+ /* Get a single datum from the caller's buffer */
+
+ AcpiExGetBufferDatum (&PreviousRawDatum, Buffer,
+ ObjDesc->CommonField.AccessByteWidth, DatumOffset);
+
+ /*
+ * Part1:
+ * Write a partial field datum if field does not begin on a datum boundary
+ * Note: The code in this section also handles the aligned case
+ *
+ * Construct Mask with 1 bits where the field is, 0 bits elsewhere
+ * (Only the bottom 5 bits of BitLength are valid for a shift operation)
+ *
+ * Mask off bits that are "below" the field (if any)
+ */
+ Mask = ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset);
+
+ /* If the field fits in one datum, may need to mask upper bits */
+
+ if ((ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM) &&
+ ObjDesc->CommonField.EndFieldValidBits)
+ {
+ /* There are bits above the field, mask them off also */
+
+ Mask &= ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits);
+ }
+
+ /* Shift and mask the value into the field position */
+
+ MergedDatum = (PreviousRawDatum << ObjDesc->CommonField.StartFieldBitOffset);
+ MergedDatum &= Mask;
+
+ /* Apply the update rule (if necessary) and write the datum to the field */
+
+ Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, MergedDatum,
+ FieldDatumByteOffset);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* If the entire field fits within one datum, we are done. */
+
+ if ((DatumCount == 1) &&
+ (ObjDesc->CommonField.Flags & AOPOBJ_SINGLE_DATUM))
+ {
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Part2:
+ * Write the aligned data.
+ *
+ * We don't need to worry about the update rule for these data, because
+ * all of the bits in each datum are part of the field.
+ *
+ * The last datum must be special cased because it might contain bits
+ * that are not part of the field -- therefore the "update rule" must be
+ * applied in Part3 below.
+ */
+ while (DatumOffset < DatumCount)
+ {
+ DatumOffset++;
+ FieldDatumByteOffset += ObjDesc->CommonField.AccessByteWidth;
+
+ /*
+ * Get the next raw buffer datum. It may contain bits of the previous
+ * field datum
+ */
+ AcpiExGetBufferDatum (&ThisRawDatum, Buffer,
+ ObjDesc->CommonField.AccessByteWidth, DatumOffset);
+
+ /* Create the field datum based on the field alignment */
+
+ if (ObjDesc->CommonField.StartFieldBitOffset != 0)
+ {
+ /*
+ * Put together appropriate bits of the two raw buffer data to make
+ * a single complete field datum
+ */
+ MergedDatum =
+ (PreviousRawDatum >> ObjDesc->CommonField.DatumValidBits) |
+ (ThisRawDatum << ObjDesc->CommonField.StartFieldBitOffset);
+ }
+ else
+ {
+ /* Field began aligned on datum boundary */
+
+ MergedDatum = ThisRawDatum;
+ }
+
+ /*
+ * Special handling for the last datum if the field does NOT end on
+ * a datum boundary. Update Rule must be applied to the bits outside
+ * the field.
+ */
+ if (DatumOffset == DatumCount)
+ {
+ /*
+ * If there are dangling non-aligned bits, perform one more merged write
+ * Else - field is aligned at the end, no need for any more writes
+ */
+ if (ObjDesc->CommonField.EndFieldValidBits)
+ {
+ /*
+ * Part3:
+ * This is the last datum and the field does not end on a datum boundary.
+ * Build the partial datum and write with the update rule.
+ *
+ * Mask off the unused bits above (after) the end-of-field
+ */
+ Mask = ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.EndFieldValidBits);
+ MergedDatum &= Mask;
+
+ /* Write the last datum with the update rule */
+
+ Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, MergedDatum,
+ FieldDatumByteOffset);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+ }
+ else
+ {
+ /* Normal case -- write the completed datum */
+
+ Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset,
+ &MergedDatum, ACPI_WRITE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Save the most recent datum since it may contain bits of the *next*
+ * field datum. Update current byte offset.
+ */
+ PreviousRawDatum = ThisRawDatum;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/exmisc.c b/sys/contrib/dev/acpica/exmisc.c
new file mode 100644
index 0000000..2479d2d
--- /dev/null
+++ b/sys/contrib/dev/acpica/exmisc.c
@@ -0,0 +1,620 @@
+
+/******************************************************************************
+ *
+ * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes
+ * $Revision: 115 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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) != 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 (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_OPERAND_OBJECT *ReturnDesc;
+ 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);
+ }
+
+ /* 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 */
+
+ /* Create a new buffer object for the result */
+
+ ReturnDesc = AcpiUtCreateBufferObject (Length1 + Length2);
+ if (!ReturnDesc)
+ {
+ 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);
+
+ /* Compute the new checksum */
+
+ NewBuf[ReturnDesc->Buffer.Length - 1] =
+ AcpiUtGenerateChecksum (ReturnDesc->Buffer.Pointer,
+ (ReturnDesc->Buffer.Length - 1));
+
+ /* Return the completed template descriptor */
+
+ *ActualReturnDesc = ReturnDesc;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * 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;
+ 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 = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth * 2);
+ if (!ReturnDesc)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ NewBuf = (char *) ReturnDesc->Buffer.Pointer;
+
+ /* Convert the first integer */
+
+ ThisInteger = ObjDesc1->Integer.Value;
+ for (i = 0; i < AcpiGbl_IntegerByteWidth; i++)
+ {
+ NewBuf[i] = (char) ThisInteger;
+ ThisInteger >>= 8;
+ }
+
+ /* Convert the second integer */
+
+ ThisInteger = ObjDesc2->Integer.Value;
+ for (; i < (ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); i++)
+ {
+ NewBuf[i] = (char) ThisInteger;
+ ThisInteger >>= 8;
+ }
+
+ 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_CALLOCATE ((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 = AcpiUtCreateBufferObject (
+ (ACPI_SIZE) ObjDesc1->Buffer.Length +
+ (ACPI_SIZE) ObjDesc2->Buffer.Length);
+ if (!ReturnDesc)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ NewBuf = (char *) ReturnDesc->Buffer.Pointer;
+
+ /* Concatenate the buffers */
+
+ ACPI_MEMCPY (NewBuf, ObjDesc1->Buffer.Pointer,
+ ObjDesc1->Buffer.Length);
+ ACPI_MEMCPY (NewBuf + ObjDesc1->Buffer.Length, ObjDesc2->Buffer.Pointer,
+ ObjDesc2->Buffer.Length);
+
+ 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/exmonad.c b/sys/contrib/dev/acpica/exmonad.c
new file mode 100644
index 0000000..3e6a969
--- /dev/null
+++ b/sys/contrib/dev/acpica/exmonad.c
@@ -0,0 +1,1083 @@
+
+/******************************************************************************
+ *
+ * Module Name: exmonad - ACPI AML execution for monadic (1 operand) operators
+ * $Revision: 113 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999, 2000, 2001, 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 __EXMONAD_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ MODULE_NAME ("exmonad")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExGetObjectReference
+ *
+ * PARAMETERS: ObjDesc - Create a reference to this object
+ * RetDesc - Where to store the reference
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Obtain and return a "reference" to the target object
+ * Common code for the RefOfOp and the CondRefOfOp.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExGetObjectReference (
+ ACPI_OPERAND_OBJECT *ObjDesc,
+ ACPI_OPERAND_OBJECT **RetDesc,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ FUNCTION_TRACE_PTR ("ExGetObjectReference", ObjDesc);
+
+
+ if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL))
+ {
+ if (ObjDesc->Common.Type != INTERNAL_TYPE_REFERENCE)
+ {
+ *RetDesc = NULL;
+ Status = AE_TYPE;
+ goto Cleanup;
+ }
+
+ /*
+ * Not a Name -- an indirect name pointer would have
+ * been converted to a direct name pointer in AcpiExResolveOperands
+ */
+ switch (ObjDesc->Reference.Opcode)
+ {
+ case AML_LOCAL_OP:
+ case AML_ARG_OP:
+
+ *RetDesc = (void *) AcpiDsMethodDataGetNode (ObjDesc->Reference.Opcode,
+ ObjDesc->Reference.Offset, WalkState);
+ break;
+
+ default:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "(Internal) Unknown Ref subtype %02x\n",
+ ObjDesc->Reference.Opcode));
+ *RetDesc = NULL;
+ Status = AE_AML_INTERNAL;
+ goto Cleanup;
+ }
+
+ }
+
+ else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ /* Must be a named object; Just return the Node */
+
+ *RetDesc = ObjDesc;
+ }
+
+ else
+ {
+ *RetDesc = NULL;
+ Status = AE_TYPE;
+ }
+
+
+Cleanup:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p Ref=%p\n", ObjDesc, *RetDesc));
+ return_ACPI_STATUS (Status);
+}
+
+#define ObjDesc Operand[0]
+#define ResDesc Operand[1]
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExMonadic1
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
+ * object stack
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExMonadic1 (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_STATUS Status;
+
+
+ FUNCTION_TRACE_PTR ("ExMonadic1", WALK_OPERANDS);
+
+
+ /* Examine the opcode */
+
+ switch (WalkState->Opcode)
+ {
+ case AML_RELEASE_OP: /* Release (MutexObject) */
+
+ Status = AcpiExReleaseMutex (ObjDesc, WalkState);
+ break;
+
+
+ case AML_RESET_OP: /* Reset (EventObject) */
+
+ Status = AcpiExSystemResetEvent (ObjDesc);
+ break;
+
+
+ case AML_SIGNAL_OP: /* Signal (EventObject) */
+
+ Status = AcpiExSystemSignalEvent (ObjDesc);
+ break;
+
+
+ case AML_SLEEP_OP: /* Sleep (MsecTime) */
+
+ AcpiExSystemDoSuspend ((UINT32) ObjDesc->Integer.Value);
+ break;
+
+
+ case AML_STALL_OP: /* Stall (UsecTime) */
+
+ AcpiExSystemDoStall ((UINT32) ObjDesc->Integer.Value);
+ break;
+
+
+ default: /* Unknown opcode */
+
+ REPORT_ERROR (("AcpiExMonadic1: Unknown monadic opcode %X\n",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ break;
+ }
+
+
+ /* Always delete the operand */
+
+ AcpiUtRemoveReference (ObjDesc);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExMonadic2R
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 2 monadic operator with numeric operand and
+ * result operand on operand stack
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExMonadic2R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *RetDesc = NULL;
+ ACPI_OPERAND_OBJECT *RetDesc2 = NULL;
+ UINT32 Temp32;
+ UINT32 i;
+ UINT32 j;
+ ACPI_INTEGER Digit;
+
+
+ FUNCTION_TRACE_PTR ("ExMonadic2R", WALK_OPERANDS);
+
+
+
+
+ /* Create a return object of type NUMBER for most opcodes */
+
+ 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:
+
+ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ break;
+ }
+
+
+ switch (WalkState->Opcode)
+ {
+
+ case AML_BIT_NOT_OP: /* Not (Operand, Result) */
+
+ RetDesc->Integer.Value = ~ObjDesc->Integer.Value;
+ break;
+
+
+ case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */
+
+
+ RetDesc->Integer.Value = ObjDesc->Integer.Value;
+
+ /*
+ * Acpi specification describes Integer type as a little
+ * endian unsigned value, so this boundary condition is valid.
+ */
+ for (Temp32 = 0; RetDesc->Integer.Value && Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
+ {
+ RetDesc->Integer.Value >>= 1;
+ }
+
+ RetDesc->Integer.Value = Temp32;
+ break;
+
+
+ case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
+
+
+ RetDesc->Integer.Value = ObjDesc->Integer.Value;
+
+ /*
+ * The Acpi specification describes Integer type as a little
+ * endian unsigned value, so this boundary condition is valid.
+ */
+ for (Temp32 = 0; RetDesc->Integer.Value && Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
+ {
+ RetDesc->Integer.Value <<= 1;
+ }
+
+ /* Since returns must be 1-based, subtract from 33 (65) */
+
+ RetDesc->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
+ */
+ RetDesc->Integer.Value = 0;
+ for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++)
+ {
+ /* Get one BCD digit */
+
+ Digit = (ACPI_INTEGER) ((ObjDesc->Integer.Value >> (i * 4)) & 0xF);
+
+ /* Check the range of the digit */
+
+ if (Digit > 9)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD digit too large: \n",
+ 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;
+ }
+
+ RetDesc->Integer.Value += Digit;
+ }
+ }
+ break;
+
+
+ case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */
+
+ if (ObjDesc->Integer.Value > ACPI_MAX_BCD_VALUE)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "BCD overflow: %d\n",
+ ObjDesc->Integer.Value));
+ Status = AE_AML_NUMERIC_OVERFLOW;
+ goto Cleanup;
+ }
+
+ RetDesc->Integer.Value = 0;
+ for (i = 0; i < ACPI_MAX_BCD_DIGITS; i++)
+ {
+ /* Divide by nth factor of 10 */
+
+ Temp32 = 0;
+ Digit = ObjDesc->Integer.Value;
+ for (j = 0; j < i; j++)
+ {
+ AcpiUtShortDivide (&Digit, 10, &Digit, &Temp32);
+ }
+
+ /* Create the BCD digit from the remainder above */
+
+ if (Digit > 0)
+ {
+ RetDesc->Integer.Value += (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 *) ObjDesc == AcpiGbl_RootNode)
+ {
+ /*
+ * This means that the object does not exist in the namespace,
+ * return FALSE
+ */
+ RetDesc->Integer.Value = 0;
+
+ /*
+ * Must delete the result descriptor since there is no reference
+ * being returned
+ */
+ AcpiUtRemoveReference (ResDesc);
+ goto Cleanup;
+ }
+
+ /* Get the object reference and store it */
+
+ Status = AcpiExGetObjectReference (ObjDesc, &RetDesc2, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+
+ Status = AcpiExStore (RetDesc2, ResDesc, WalkState);
+
+ /* The object exists in the namespace, return TRUE */
+
+ RetDesc->Integer.Value = ACPI_INTEGER_MAX;
+ goto Cleanup;
+ 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.
+ */
+ Temp32 = ObjDesc->Common.ReferenceCount;
+ Status = AcpiExStore (ObjDesc, ResDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ /* On failure, just delete the ObjDesc */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+ }
+
+#if 0
+ if ((ObjDesc->Common.ReferenceCount > Temp32) &&
+ (!AcpiDsIsResultUsed (WalkState->Op, WalkState)))
+ {
+ ObjDesc->Common.ReferenceCount++;
+ }
+#endif
+
+ /*
+ * Normally, we would remove a reference on the ObjDesc 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 = ObjDesc;
+ return_ACPI_STATUS (Status);
+ break;
+
+
+ /*
+ * ACPI 2.0 Opcodes
+ */
+ case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */
+
+ Status = AcpiExConvertToString (ObjDesc, &RetDesc, 10, ACPI_UINT32_MAX, WalkState);
+ break;
+
+
+ case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */
+
+ Status = AcpiExConvertToString (ObjDesc, &RetDesc, 16, ACPI_UINT32_MAX, WalkState);
+ break;
+
+
+ case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */
+
+ Status = AcpiExConvertToBuffer (ObjDesc, &RetDesc, WalkState);
+ break;
+
+
+ case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */
+
+ Status = AcpiExConvertToInteger (ObjDesc, &RetDesc, WalkState);
+ break;
+
+
+ /*
+ * These are two obsolete opcodes
+ */
+ case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */
+ case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s is unimplemented\n",
+ AcpiPsGetOpcodeName (WalkState->Opcode)));
+ Status = AE_SUPPORT;
+ goto Cleanup;
+ break;
+
+
+ default: /* Unknown opcode */
+
+ REPORT_ERROR (("AcpiExMonadic2R: Unknown monadic opcode %X\n",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+ /*
+ * Store the return value computed above into the result object
+ */
+ Status = AcpiExStore (RetDesc, ResDesc, WalkState);
+
+
+Cleanup:
+ /* Always delete the operand object */
+
+ AcpiUtRemoveReference (ObjDesc);
+
+ /* Delete return object(s) on error */
+
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiUtRemoveReference (ResDesc); /* Result descriptor */
+ if (RetDesc)
+ {
+ AcpiUtRemoveReference (RetDesc);
+ RetDesc = NULL;
+ }
+ }
+
+ /* Set the return object and exit */
+
+ WalkState->ResultObj = RetDesc;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExMonadic2
+ *
+ * PARAMETERS: WalkState - Current state (contains AML opcode)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute Type 2 monadic operator with numeric operand:
+ * DerefOfOp, RefOfOp, SizeOfOp, TypeOp, IncrementOp,
+ * DecrementOp, LNotOp,
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExMonadic2 (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *TmpDesc;
+ ACPI_OPERAND_OBJECT *RetDesc = NULL;
+ ACPI_STATUS Status = AE_OK;
+ UINT32 Type;
+ ACPI_INTEGER Value;
+
+
+ FUNCTION_TRACE_PTR ("ExMonadic2", WALK_OPERANDS);
+
+
+
+
+ /* Get the operand and decode the opcode */
+
+ switch (WalkState->Opcode)
+ {
+
+ case AML_LNOT_OP: /* LNot (Operand) */
+
+ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ RetDesc->Integer.Value = !ObjDesc->Integer.Value;
+ break;
+
+
+ case AML_DECREMENT_OP: /* Decrement (Operand) */
+ case AML_INCREMENT_OP: /* Increment (Operand) */
+
+ /*
+ * Since we are expecting an Reference on the top of the stack, it
+ * can be either an Node or an internal object.
+ *
+ * TBD: [Future] This may be the prototype code for all cases where
+ * a Reference is expected!! 10/99
+ */
+ if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ RetDesc = ObjDesc;
+ }
+
+ else
+ {
+ /*
+ * Duplicate the Reference in a new object so that we can resolve it
+ * without destroying the original Reference object
+ */
+ RetDesc = AcpiUtCreateInternalObject (INTERNAL_TYPE_REFERENCE);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ RetDesc->Reference.Opcode = ObjDesc->Reference.Opcode;
+ RetDesc->Reference.Offset = ObjDesc->Reference.Offset;
+ RetDesc->Reference.Object = ObjDesc->Reference.Object;
+ }
+
+
+ /*
+ * Convert the RetDesc Reference to a Number
+ * (This deletes the original RetDesc object)
+ */
+ Status = AcpiExResolveOperands (AML_LNOT_OP, &RetDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s: bad operand(s) %s\n",
+ AcpiPsGetOpcodeName (WalkState->Opcode), AcpiFormatException(Status)));
+
+ goto Cleanup;
+ }
+
+ /* Do the actual increment or decrement */
+
+ if (AML_INCREMENT_OP == WalkState->Opcode)
+ {
+ RetDesc->Integer.Value++;
+ }
+ else
+ {
+ RetDesc->Integer.Value--;
+ }
+
+ /* Store the result back in the original descriptor */
+
+ Status = AcpiExStore (RetDesc, ObjDesc, WalkState);
+
+ /* Objdesc was just deleted (because it is an Reference) */
+
+ ObjDesc = NULL;
+
+ break;
+
+
+ case AML_TYPE_OP: /* ObjectType (SourceObject) */
+
+ if (INTERNAL_TYPE_REFERENCE == ObjDesc->Common.Type)
+ {
+ /*
+ * Not a Name -- an indirect name pointer would have
+ * been converted to a direct name pointer in ResolveOperands
+ */
+ switch (ObjDesc->Reference.Opcode)
+ {
+ case AML_ZERO_OP:
+ case AML_ONE_OP:
+ case AML_ONES_OP:
+ case AML_REVISION_OP:
+
+ /* Constants are of type Number */
+
+ Type = ACPI_TYPE_INTEGER;
+ break;
+
+
+ case AML_DEBUG_OP:
+
+ /* Per 1.0b spec, Debug object is of type "DebugObject" */
+
+ Type = ACPI_TYPE_DEBUG_OBJECT;
+ break;
+
+
+ case AML_INDEX_OP:
+
+ /* Get the type of this reference (index into another object) */
+
+ Type = ObjDesc->Reference.TargetType;
+ if (Type == ACPI_TYPE_PACKAGE)
+ {
+ /*
+ * The main object is a package, we want to get the type
+ * of the individual package element that is referenced by
+ * the index.
+ */
+ Type = (*(ObjDesc->Reference.Where))->Common.Type;
+ }
+
+ break;
+
+
+ case AML_LOCAL_OP:
+ case AML_ARG_OP:
+
+ Type = AcpiDsMethodDataGetType (ObjDesc->Reference.Opcode,
+ ObjDesc->Reference.Offset, WalkState);
+ break;
+
+
+ default:
+
+ REPORT_ERROR (("AcpiExMonadic2/TypeOp: Internal error - Unknown Reference subtype %X\n",
+ ObjDesc->Reference.Opcode));
+ Status = AE_AML_INTERNAL;
+ goto Cleanup;
+ }
+ }
+
+ else
+ {
+ /*
+ * It's not a Reference, so it must be a direct name pointer.
+ */
+ Type = AcpiNsGetType ((ACPI_NAMESPACE_NODE *) ObjDesc);
+
+ /* Convert internal types to external types */
+
+ switch (Type)
+ {
+ case INTERNAL_TYPE_REGION_FIELD:
+ case INTERNAL_TYPE_BANK_FIELD:
+ case INTERNAL_TYPE_INDEX_FIELD:
+
+ Type = ACPI_TYPE_FIELD_UNIT;
+ }
+
+ }
+
+ /* Allocate a descriptor to hold the type. */
+
+ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ RetDesc->Integer.Value = Type;
+ break;
+
+
+ case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */
+
+ if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
+ }
+
+ if (!ObjDesc)
+ {
+ Value = 0;
+ }
+
+ else
+ {
+ switch (ObjDesc->Common.Type)
+ {
+
+ case ACPI_TYPE_BUFFER:
+
+ Value = ObjDesc->Buffer.Length;
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ Value = ObjDesc->String.Length;
+ break;
+
+
+ case ACPI_TYPE_PACKAGE:
+
+ Value = ObjDesc->Package.Count;
+ break;
+
+ case INTERNAL_TYPE_REFERENCE:
+
+ Value = 4;
+ break;
+
+ default:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Not Buf/Str/Pkg - found type %X\n",
+ ObjDesc->Common.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
+ */
+ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ RetDesc->Integer.Value = Value;
+ break;
+
+
+ case AML_REF_OF_OP: /* RefOf (SourceObject) */
+
+ Status = AcpiExGetObjectReference (ObjDesc, &RetDesc, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Cleanup;
+ }
+ break;
+
+
+ case AML_DEREF_OF_OP: /* DerefOf (ObjReference) */
+
+ /* Check for a method local or argument */
+
+ if (!VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ /*
+ * Must resolve/dereference the local/arg reference first
+ */
+ switch (ObjDesc->Reference.Opcode)
+ {
+ /* Set ObjDesc to the value of the local/arg */
+
+ case AML_LOCAL_OP:
+ case AML_ARG_OP:
+
+ AcpiDsMethodDataGetValue (ObjDesc->Reference.Opcode,
+ ObjDesc->Reference.Offset, WalkState, &TmpDesc);
+
+ /*
+ * Delete our reference to the input object and
+ * point to the object just retrieved
+ */
+ AcpiUtRemoveReference (ObjDesc);
+ ObjDesc = TmpDesc;
+ break;
+
+ default:
+
+ /* Index op - handled below */
+ break;
+ }
+ }
+
+
+ /* ObjDesc may have changed from the code above */
+
+ if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
+ {
+ /* Get the actual object from the Node (This is the dereference) */
+
+ RetDesc = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object;
+
+ /* Returning a pointer to the object, add another reference! */
+
+ AcpiUtAddReference (RetDesc);
+ }
+
+ else
+ {
+ /*
+ * This must be a reference object produced by the Index
+ * ASL operation -- check internal opcode
+ */
+ if ((ObjDesc->Reference.Opcode != AML_INDEX_OP) &&
+ (ObjDesc->Reference.Opcode != AML_REF_OF_OP))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown opcode in ref(%p) - %X\n",
+ ObjDesc, ObjDesc->Reference.Opcode));
+
+ Status = AE_TYPE;
+ goto Cleanup;
+ }
+
+
+ switch (ObjDesc->Reference.Opcode)
+ {
+ case AML_INDEX_OP:
+
+ /*
+ * Supported target types for the Index operator are
+ * 1) A Buffer
+ * 2) A Package
+ */
+ if (ObjDesc->Reference.TargetType == ACPI_TYPE_BUFFER_FIELD)
+ {
+ /*
+ * The target is a buffer, we must 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!
+ */
+ RetDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!RetDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+ }
+
+ TmpDesc = ObjDesc->Reference.Object;
+ RetDesc->Integer.Value =
+ TmpDesc->Buffer.Pointer[ObjDesc->Reference.Offset];
+
+ /* TBD: [Investigate] (see below) Don't add an additional
+ * ref!
+ */
+ }
+
+ else if (ObjDesc->Reference.TargetType == ACPI_TYPE_PACKAGE)
+ {
+ /*
+ * The target is a package, we want to return the referenced
+ * element of the package. We must add another reference to
+ * this object, however.
+ */
+ RetDesc = *(ObjDesc->Reference.Where);
+ if (!RetDesc)
+ {
+ /*
+ * 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",
+ ObjDesc));
+ Status = AE_AML_UNINITIALIZED_ELEMENT;
+ goto Cleanup;
+ }
+
+ AcpiUtAddReference (RetDesc);
+ }
+
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown TargetType %X in obj %p\n",
+ ObjDesc->Reference.TargetType, ObjDesc));
+ Status = AE_AML_OPERAND_TYPE;
+ goto Cleanup;
+ }
+
+ break;
+
+
+ case AML_REF_OF_OP:
+
+ RetDesc = ObjDesc->Reference.Object;
+
+ /* Add another reference to the object! */
+
+ AcpiUtAddReference (RetDesc);
+ break;
+ }
+ }
+
+ break;
+
+
+ default:
+
+ REPORT_ERROR (("AcpiExMonadic2: Unknown monadic opcode %X\n",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+Cleanup:
+
+ if (ObjDesc)
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+
+ /* Delete return object on error */
+
+ if (ACPI_FAILURE (Status) &&
+ (RetDesc))
+ {
+ AcpiUtRemoveReference (RetDesc);
+ RetDesc = NULL;
+ }
+
+ WalkState->ResultObj = RetDesc;
+ return_ACPI_STATUS (Status);
+}
+
diff --git a/sys/contrib/dev/acpica/exmutex.c b/sys/contrib/dev/acpica/exmutex.c
new file mode 100644
index 0000000..6b87cc5
--- /dev/null
+++ b/sys/contrib/dev/acpica/exmutex.c
@@ -0,0 +1,445 @@
+
+/******************************************************************************
+ *
+ * Module Name: exmutex - ASL Mutex Acquire/Release functions
+ * $Revision: 18 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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) &&
+ (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->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
new file mode 100644
index 0000000..7eb8e4f
--- /dev/null
+++ b/sys/contrib/dev/acpica/exnames.c
@@ -0,0 +1,531 @@
+
+/******************************************************************************
+ *
+ * Module Name: exnames - interpreter/scanner name load/execute
+ * $Revision: 94 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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.
+ *
+ ******************************************************************************/
+
+char *
+AcpiExAllocateNameString (
+ UINT32 PrefixCount,
+ UINT32 NumNameSegs)
+{
+ char *TempPtr;
+ 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,
+ 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,
+ char **OutNameString,
+ UINT32 *OutNameLength)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT8 *AmlAddress = InAmlAddress;
+ char *NameString = NULL;
+ UINT32 NumSegments;
+ UINT32 PrefixCount = 0;
+ BOOLEAN HasPrefix = FALSE;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("ExGetNameString", AmlAddress);
+
+
+ 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
new file mode 100644
index 0000000..fae1ff8
--- /dev/null
+++ b/sys/contrib/dev/acpica/exoparg1.c
@@ -0,0 +1,984 @@
+
+/******************************************************************************
+ *
+ * Module Name: exoparg1 - AML execution - opcodes with 1 argument
+ * $Revision: 147 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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;
+ 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);
+ }
+
+ /* 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:
+
+ 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 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
new file mode 100644
index 0000000..624470a
--- /dev/null
+++ b/sys/contrib/dev/acpica/exoparg2.c
@@ -0,0 +1,716 @@
+/******************************************************************************
+ *
+ * Module Name: exoparg2 - AML execution - opcodes with 2 arguments
+ * $Revision: 117 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 *ReturnDesc = NULL;
+ ACPI_OPERAND_OBJECT *TempDesc = NULL;
+ UINT32 Index;
+ ACPI_STATUS Status = AE_OK;
+ ACPI_SIZE Length;
+
+
+ ACPI_FUNCTION_TRACE_STR ("ExOpcode_2A_1T_1R", AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ /*
+ * 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 = (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 (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;
+ }
+
+ 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.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;
+ }
+
+ 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
new file mode 100644
index 0000000..1953ec2
--- /dev/null
+++ b/sys/contrib/dev/acpica/exoparg3.c
@@ -0,0 +1,337 @@
+
+/******************************************************************************
+ *
+ * Module Name: exoparg3 - AML execution - opcodes with 3 arguments
+ * $Revision: 17 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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;
+ ACPI_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 = (ACPI_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 */
+
+ if (!WalkState->ResultObj)
+ {
+ WalkState->ResultObj = ReturnDesc;
+ }
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/exoparg6.c b/sys/contrib/dev/acpica/exoparg6.c
new file mode 100644
index 0000000..5676835
--- /dev/null
+++ b/sys/contrib/dev/acpica/exoparg6.c
@@ -0,0 +1,377 @@
+
+/******************************************************************************
+ *
+ * Module Name: exoparg6 - AML execution - opcodes with 6 arguments
+ * $Revision: 12 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __EXOPARG6_C__
+
+#include "acpi.h"
+#include "acinterp.h"
+#include "acparser.h"
+#include "amlcode.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exoparg6")
+
+
+/*!
+ * 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: AcpiExDoMatch
+ *
+ * PARAMETERS: MatchOp - The AML match operand
+ * PackageValue - Value from the target package
+ * MatchValue - Value to be matched
+ *
+ * RETURN: TRUE if the match is successful, FALSE otherwise
+ *
+ * DESCRIPTION: Implements the low-level match for the ASL Match operator
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiExDoMatch (
+ UINT32 MatchOp,
+ ACPI_INTEGER PackageValue,
+ ACPI_INTEGER MatchValue)
+{
+
+ switch (MatchOp)
+ {
+ case MATCH_MTR: /* always true */
+
+ break;
+
+
+ case MATCH_MEQ: /* true if equal */
+
+ if (PackageValue != MatchValue)
+ {
+ return (FALSE);
+ }
+ break;
+
+
+ case MATCH_MLE: /* true if less than or equal */
+
+ if (PackageValue > MatchValue)
+ {
+ return (FALSE);
+ }
+ break;
+
+
+ case MATCH_MLT: /* true if less than */
+
+ if (PackageValue >= MatchValue)
+ {
+ return (FALSE);
+ }
+ break;
+
+
+ case MATCH_MGE: /* true if greater than or equal */
+
+ if (PackageValue < MatchValue)
+ {
+ return (FALSE);
+ }
+ break;
+
+
+ case MATCH_MGT: /* true if greater than */
+
+ if (PackageValue <= MatchValue)
+ {
+ return (FALSE);
+ }
+ break;
+
+
+ default: /* undefined */
+
+ return (FALSE);
+ }
+
+
+ return TRUE;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExOpcode_6A_0T_1R
+ *
+ * PARAMETERS: WalkState - Current walk state
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExOpcode_6A_0T_1R (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
+ ACPI_OPERAND_OBJECT *ReturnDesc = NULL;
+ ACPI_STATUS Status = AE_OK;
+ UINT32 Index;
+ ACPI_OPERAND_OBJECT *ThisElement;
+
+
+ ACPI_FUNCTION_TRACE_STR ("ExOpcode_6A_0T_1R", AcpiPsGetOpcodeName (WalkState->Opcode));
+
+
+ switch (WalkState->Opcode)
+ {
+ case AML_MATCH_OP:
+ /*
+ * Match (SearchPackage[0], MatchOp1[1], MatchObject1[2],
+ * MatchOp2[3], MatchObject2[4], StartIndex[5])
+ */
+
+ /* Validate match comparison sub-opcodes */
+
+ if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) ||
+ (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "operation encoding out of range\n"));
+ Status = AE_AML_OPERAND_VALUE;
+ goto Cleanup;
+ }
+
+ Index = (UINT32) Operand[5]->Integer.Value;
+ if (Index >= (UINT32) Operand[0]->Package.Count)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Index beyond package end\n"));
+ Status = AE_AML_PACKAGE_LIMIT;
+ goto Cleanup;
+ }
+
+ ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
+ if (!ReturnDesc)
+ {
+ Status = AE_NO_MEMORY;
+ goto Cleanup;
+
+ }
+
+ /* Default return value if no match found */
+
+ ReturnDesc->Integer.Value = ACPI_INTEGER_MAX;
+
+ /*
+ * Examine each element until a match is found. Within the loop,
+ * "continue" signifies that the current element does not match
+ * and the next should be examined.
+ *
+ * Upon finding a match, the loop will terminate via "break" at
+ * the bottom. If it terminates "normally", MatchValue will be -1
+ * (its initial value) indicating that no match was found. When
+ * returned as a Number, this will produce the Ones value as specified.
+ */
+ for ( ; Index < Operand[0]->Package.Count; Index++)
+ {
+ ThisElement = Operand[0]->Package.Elements[Index];
+
+ /*
+ * Treat any NULL or non-numeric elements as non-matching.
+ */
+ if (!ThisElement ||
+ ACPI_GET_OBJECT_TYPE (ThisElement) != ACPI_TYPE_INTEGER)
+ {
+ continue;
+ }
+
+ /*
+ * "continue" (proceed to next iteration of enclosing
+ * "for" loop) signifies a non-match.
+ */
+ if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value,
+ ThisElement->Integer.Value, Operand[2]->Integer.Value))
+ {
+ continue;
+ }
+
+ if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value,
+ ThisElement->Integer.Value, Operand[4]->Integer.Value))
+ {
+ continue;
+ }
+
+ /* Match found: Index is the return value */
+
+ ReturnDesc->Integer.Value = Index;
+ break;
+ }
+
+ break;
+
+
+ case AML_LOAD_TABLE_OP:
+
+ Status = AcpiExLoadTableOp (WalkState, &ReturnDesc);
+ break;
+
+
+ default:
+
+ ACPI_REPORT_ERROR (("AcpiExOpcode_3A_0T_0R: Unknown opcode %X\n",
+ WalkState->Opcode));
+ Status = AE_AML_BAD_OPCODE;
+ goto Cleanup;
+ }
+
+
+ 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/exprep.c b/sys/contrib/dev/acpica/exprep.c
new file mode 100644
index 0000000..6071e0d
--- /dev/null
+++ b/sys/contrib/dev/acpica/exprep.c
@@ -0,0 +1,538 @@
+
+/******************************************************************************
+ *
+ * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities
+ * $Revision: 122 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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;
+ break;
+
+ case AML_FIELD_ACCESS_WORD:
+ ByteAlignment = 2;
+ BitLength = 16;
+ break;
+
+ case AML_FIELD_ACCESS_DWORD:
+ ByteAlignment = 4;
+ BitLength = 32;
+ break;
+
+ case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */
+ ByteAlignment = 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 != 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 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 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 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/exregion.c b/sys/contrib/dev/acpica/exregion.c
new file mode 100644
index 0000000..049f5c7
--- /dev/null
+++ b/sys/contrib/dev/acpica/exregion.c
@@ -0,0 +1,615 @@
+
+/******************************************************************************
+ *
+ * Module Name: exregion - ACPI default OpRegion (address space) handlers
+ * $Revision: 82 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __EXREGION_C__
+
+#include "acpi.h"
+#include "acinterp.h"
+
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exregion")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemMemorySpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the System Memory address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemMemorySpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ ACPI_INTEGER *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+ void *LogicalAddrPtr = NULL;
+ ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext;
+ UINT32 Length;
+ ACPI_SIZE WindowSize;
+#ifndef _HW_ALIGNMENT_SUPPORT
+ UINT32 Remainder;
+#endif
+
+ ACPI_FUNCTION_TRACE ("ExSystemMemorySpaceHandler");
+
+
+ /* Validate and translate the bit width */
+
+ switch (BitWidth)
+ {
+ case 8:
+ Length = 1;
+ break;
+
+ case 16:
+ Length = 2;
+ break;
+
+ case 32:
+ Length = 4;
+ break;
+
+ case 64:
+ Length = 8;
+ break;
+
+ default:
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid SystemMemory width %d\n",
+ BitWidth));
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ }
+
+
+#ifndef _HW_ALIGNMENT_SUPPORT
+ /*
+ * Hardware does not support non-aligned data transfers, we must verify
+ * the request.
+ */
+ (void) AcpiUtShortDivide ((ACPI_INTEGER *) &Address, Length, NULL, &Remainder);
+ if (Remainder != 0)
+ {
+ return_ACPI_STATUS (AE_AML_ALIGNMENT);
+ }
+#endif
+
+ /*
+ * Does the request fit into the cached memory mapping?
+ * Is 1) Address below the current mapping? OR
+ * 2) Address beyond the current mapping?
+ */
+ if ((Address < MemInfo->MappedPhysicalAddress) ||
+ (((ACPI_INTEGER) Address + Length) >
+ ((ACPI_INTEGER) MemInfo->MappedPhysicalAddress + MemInfo->MappedLength)))
+ {
+ /*
+ * The request cannot be resolved by the current memory mapping;
+ * Delete the existing mapping and create a new one.
+ */
+ if (MemInfo->MappedLength)
+ {
+ /* Valid mapping, delete it */
+
+ AcpiOsUnmapMemory (MemInfo->MappedLogicalAddress,
+ MemInfo->MappedLength);
+ }
+
+ /*
+ * Don't attempt to map memory beyond the end of the region, and
+ * constrain the maximum mapping size to something reasonable.
+ */
+ WindowSize = (ACPI_SIZE) ((MemInfo->Address + MemInfo->Length) - Address);
+ if (WindowSize > ACPI_SYSMEM_REGION_WINDOW_SIZE)
+ {
+ WindowSize = ACPI_SYSMEM_REGION_WINDOW_SIZE;
+ }
+
+ /* Create a new mapping starting at the address given */
+
+ Status = AcpiOsMapMemory (Address, WindowSize,
+ (void **) &MemInfo->MappedLogicalAddress);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X%8.8X, size %X\n",
+ ACPI_HIDWORD (Address), ACPI_LODWORD (Address), (UINT32) WindowSize));
+ MemInfo->MappedLength = 0;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Save the physical address and mapping size */
+
+ MemInfo->MappedPhysicalAddress = Address;
+ MemInfo->MappedLength = WindowSize;
+ }
+
+ /*
+ * Generate a logical pointer corresponding to the address we want to
+ * access
+ */
+ LogicalAddrPtr = MemInfo->MappedLogicalAddress +
+ ((ACPI_INTEGER) Address - (ACPI_INTEGER) MemInfo->MappedPhysicalAddress);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "SystemMemory %d (%d width) Address=%8.8X%8.8X\n", Function, BitWidth,
+ ACPI_HIDWORD (Address), ACPI_LODWORD (Address)));
+
+ /*
+ * Perform the memory read or write
+ *
+ * Note: For machines that do not support non-aligned transfers, the target
+ * address was checked for alignment above. We do not attempt to break the
+ * transfer up into smaller (byte-size) chunks because the AML specifically
+ * asked for a transfer width that the hardware may require.
+ */
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ *Value = 0;
+ switch (BitWidth)
+ {
+ case 8:
+ *Value = (ACPI_INTEGER) *((UINT8 *) LogicalAddrPtr);
+ break;
+
+ case 16:
+ *Value = (ACPI_INTEGER) *((UINT16 *) LogicalAddrPtr);
+ break;
+
+ case 32:
+ *Value = (ACPI_INTEGER) *((UINT32 *) LogicalAddrPtr);
+ break;
+
+#if ACPI_MACHINE_WIDTH != 16
+ case 64:
+ *Value = (ACPI_INTEGER) *((UINT64 *) LogicalAddrPtr);
+ break;
+#endif
+ default:
+ /* BitWidth was already validated */
+ break;
+ }
+ break;
+
+ case ACPI_WRITE:
+
+ switch (BitWidth)
+ {
+ case 8:
+ *(UINT8 *) LogicalAddrPtr = (UINT8) *Value;
+ break;
+
+ case 16:
+ *(UINT16 *) LogicalAddrPtr = (UINT16) *Value;
+ break;
+
+ case 32:
+ *(UINT32 *) LogicalAddrPtr = (UINT32) *Value;
+ break;
+
+#if ACPI_MACHINE_WIDTH != 16
+ case 64:
+ *(UINT64 *) LogicalAddrPtr = (UINT64) *Value;
+ break;
+#endif
+
+ default:
+ /* BitWidth was already validated */
+ break;
+ }
+ break;
+
+ default:
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemIoSpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the System IO address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemIoSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ ACPI_INTEGER *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE ("ExSystemIoSpaceHandler");
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "SystemIO %d (%d width) Address=%8.8X%8.8X\n", Function, BitWidth,
+ ACPI_HIDWORD (Address), ACPI_LODWORD (Address)));
+
+ /* Decode the function parameter */
+
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ *Value = 0;
+ Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) Address, Value, BitWidth);
+ break;
+
+ case ACPI_WRITE:
+
+ Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) Address, *Value, BitWidth);
+ break;
+
+ default:
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExPciConfigSpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the PCI Config address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExPciConfigSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ ACPI_INTEGER *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_PCI_ID *PciId;
+ UINT16 PciRegister;
+
+
+ ACPI_FUNCTION_TRACE ("ExPciConfigSpaceHandler");
+
+
+ /*
+ * The arguments to AcpiOs(Read|Write)PciConfiguration are:
+ *
+ * PciSegment is the PCI bus segment range 0-31
+ * PciBus is the PCI bus number range 0-255
+ * PciDevice is the PCI device number range 0-31
+ * PciFunction is the PCI device function number
+ * PciRegister is the Config space register range 0-255 bytes
+ *
+ * Value - input value for write, output address for read
+ *
+ */
+ PciId = (ACPI_PCI_ID *) RegionContext;
+ PciRegister = (UINT16) (UINT32) Address;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "PciConfig %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
+ Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device,
+ PciId->Function, PciRegister));
+
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ *Value = 0;
+ Status = AcpiOsReadPciConfiguration (PciId, PciRegister, Value, BitWidth);
+ break;
+
+ case ACPI_WRITE:
+
+ Status = AcpiOsWritePciConfiguration (PciId, PciRegister, *Value, BitWidth);
+ break;
+
+ default:
+
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExCmosSpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the CMOS address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExCmosSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ ACPI_INTEGER *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE ("ExCmosSpaceHandler");
+
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExPciBarSpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the PCI BarTarget address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExPciBarSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ ACPI_INTEGER *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE ("ExPciBarSpaceHandler");
+
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExDataTableSpaceHandler
+ *
+ * PARAMETERS: Function - Read or Write operation
+ * Address - Where in the space to read or write
+ * BitWidth - Field width in bits (8, 16, or 32)
+ * Value - Pointer to in or out value
+ * HandlerContext - Pointer to Handler's context
+ * RegionContext - Pointer to context specific to the
+ * accessed region
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Handler for the Data Table address space (Op Region)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExDataTableSpaceHandler (
+ UINT32 Function,
+ ACPI_PHYSICAL_ADDRESS Address,
+ UINT32 BitWidth,
+ ACPI_INTEGER *Value,
+ void *HandlerContext,
+ void *RegionContext)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT32 ByteWidth = ACPI_DIV_8 (BitWidth);
+ UINT32 i;
+ char *LogicalAddrPtr;
+
+
+ ACPI_FUNCTION_TRACE ("ExDataTableSpaceHandler");
+
+
+ LogicalAddrPtr = ACPI_PHYSADDR_TO_PTR (Address);
+
+
+ /* Perform the memory read or write */
+
+ switch (Function)
+ {
+ case ACPI_READ:
+
+ for (i = 0; i < ByteWidth; i++)
+ {
+ ((char *) Value) [i] = LogicalAddrPtr[i];
+ }
+ break;
+
+ case ACPI_WRITE:
+ default:
+
+ return_ACPI_STATUS (AE_SUPPORT);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/exresnte.c b/sys/contrib/dev/acpica/exresnte.c
new file mode 100644
index 0000000..5e450dd
--- /dev/null
+++ b/sys/contrib/dev/acpica/exresnte.c
@@ -0,0 +1,356 @@
+
+/******************************************************************************
+ *
+ * Module Name: exresnte - AML Interpreter object resolution
+ * $Revision: 62 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 [%s]\n",
+ Node, SourceDesc, AcpiUtGetTypeName (EntryType)));
+
+ 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 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 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
new file mode 100644
index 0000000..fb673e0
--- /dev/null
+++ b/sys/contrib/dev/acpica/exresolv.c
@@ -0,0 +1,570 @@
+
+/******************************************************************************
+ *
+ * Module Name: exresolv - AML Interpreter object resolution
+ * $Revision: 119 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 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 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 ("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) == 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 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
new file mode 100644
index 0000000..2245d7e
--- /dev/null
+++ b/sys/contrib/dev/acpica/exresop.c
@@ -0,0 +1,720 @@
+
+/******************************************************************************
+ *
+ * Module Name: exresop - AML Interpreter operand/object resolution
+ * $Revision: 62 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 == 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 (!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) 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 ACPI_TYPE_LOCAL_REFERENCE */
+
+ if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) /* Node (name) ptr OK as-is */
+ {
+ goto NextOperand;
+ }
+
+ 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) == 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_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);
+ }
+ 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);
+ }
+ 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);
+ }
+ 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_BUFFER_OR_STRING:
+
+ /* Need an operand of type STRING or BUFFER */
+
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
+ {
+ case ACPI_TYPE_STRING:
+ case ACPI_TYPE_BUFFER:
+
+ /* Valid operand */
+ break;
+
+ case ACPI_TYPE_INTEGER:
+
+ /* Highest priority conversion is to type Buffer */
+
+ Status = AcpiExConvertToBuffer (ObjDesc, StackPtr, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ 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 ACPI_TYPE_LOCAL_REFERENCE:
+
+ /* Valid operand */
+ break;
+
+ default:
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Needed [Buffer/String/Package/Reference], 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 [Buffer/String/Package], found [%s] %p\n",
+ AcpiUtGetObjectTypeName (ObjDesc), ObjDesc));
+
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+ goto NextOperand;
+
+
+ case ARGI_REGION_OR_FIELD:
+
+ /* Need an operand of type ACPI_TYPE_REGION or a FIELD in a region */
+
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
+ {
+ case ACPI_TYPE_REGION:
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ /* Valid operand */
+ break;
+
+ default:
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Needed [Region/RegionField], 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
new file mode 100644
index 0000000..bcc926b
--- /dev/null
+++ b/sys/contrib/dev/acpica/exstore.c
@@ -0,0 +1,600 @@
+
+/******************************************************************************
+ *
+ * Module Name: exstore - AML Interpreter object store support
+ * $Revision: 175 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 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 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 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, &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
new file mode 100644
index 0000000..22c5d1f
--- /dev/null
+++ b/sys/contrib/dev/acpica/exstoren.c
@@ -0,0 +1,376 @@
+
+/******************************************************************************
+ *
+ * Module Name: exstoren - AML Interpreter object store support,
+ * Store to Node (namespace object)
+ * $Revision: 55 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 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) == 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 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 ("ExStoreObjectToObject", 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
new file mode 100644
index 0000000..360ab5c
--- /dev/null
+++ b/sys/contrib/dev/acpica/exstorob.c
@@ -0,0 +1,282 @@
+
+/******************************************************************************
+ *
+ * Module Name: exstorob - AML Interpreter object store support, store to object
+ * $Revision: 50 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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_TRACE_PTR ("ExStoreBufferToBuffer", SourceDesc);
+
+
+ /*
+ * 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 or is a static buffer,
+ * allocate a new buffer of the proper length
+ */
+ if ((TargetDesc->Buffer.Length == 0) ||
+ (TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))
+ {
+ TargetDesc->Buffer.Pointer = ACPI_MEM_ALLOCATE (Length);
+ if (!TargetDesc->Buffer.Pointer)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
+ TargetDesc->Buffer.Length = Length;
+ }
+
+ /*
+ * Buffer is a static allocation,
+ * only place what will fit in the buffer.
+ */
+ 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_ACPI_STATUS (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_TRACE_PTR ("ExStoreStringToString", SourceDesc);
+
+
+ /*
+ * We know that SourceDesc is a string by now.
+ */
+ Buffer = (UINT8 *) SourceDesc->String.Pointer;
+ Length = SourceDesc->String.Length;
+
+ /*
+ * Replace existing string value if it will fit and the string
+ * pointer is not a static pointer (part of an ACPI table)
+ */
+ if ((Length < TargetDesc->String.Length) &&
+ (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
+ {
+ /*
+ * String will fit in existing non-static buffer.
+ * Clear old string and copy in the new one
+ */
+ ACPI_MEMSET (TargetDesc->String.Pointer, 0, (ACPI_SIZE) TargetDesc->String.Length + 1);
+ ACPI_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_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER;
+ ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length);
+ }
+
+ /* Set the new target length */
+
+ TargetDesc->String.Length = Length;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
diff --git a/sys/contrib/dev/acpica/exsystem.c b/sys/contrib/dev/acpica/exsystem.c
new file mode 100644
index 0000000..36380f9
--- /dev/null
+++ b/sys/contrib/dev/acpica/exsystem.c
@@ -0,0 +1,461 @@
+
+/******************************************************************************
+ *
+ * Module Name: exsystem - Interface to OS services
+ * $Revision: 75 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __EXSYSTEM_C__
+
+#include "acpi.h"
+#include "acinterp.h"
+#include "acevents.h"
+
+#define _COMPONENT ACPI_EXECUTER
+ ACPI_MODULE_NAME ("exsystem")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemWaitSemaphore
+ *
+ * PARAMETERS: Semaphore - OSD semaphore to wait on
+ * Timeout - Max time to wait
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Implements a semaphore wait with a check to see if the
+ * semaphore is available immediately. If it is not, the
+ * interpreter is released.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemWaitSemaphore (
+ ACPI_HANDLE Semaphore,
+ UINT16 Timeout)
+{
+ ACPI_STATUS Status;
+ ACPI_STATUS Status2;
+
+
+ ACPI_FUNCTION_TRACE ("ExSystemWaitSemaphore");
+
+
+ Status = AcpiOsWaitSemaphore (Semaphore, 1, 0);
+ if (ACPI_SUCCESS (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (Status == AE_TIME)
+ {
+ /* We must wait, so unlock the interpreter */
+
+ AcpiExExitInterpreter ();
+
+ Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*** Thread awake after blocking, %s\n",
+ AcpiFormatException (Status)));
+
+ /* Reacquire the interpreter */
+
+ Status2 = AcpiExEnterInterpreter ();
+ if (ACPI_FAILURE (Status2))
+ {
+ /* Report fatal error, could not acquire interpreter */
+
+ return_ACPI_STATUS (Status2);
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemDoStall
+ *
+ * PARAMETERS: HowLong - The amount of time to stall
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Suspend running thread for specified amount of time.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemDoStall (
+ UINT32 HowLong)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (HowLong > 1000) /* 1 millisecond */
+ {
+ /* Since this thread will sleep, we must release the interpreter */
+
+ AcpiExExitInterpreter ();
+
+ AcpiOsStall (HowLong);
+
+ /* And now we must get the interpreter again */
+
+ Status = AcpiExEnterInterpreter ();
+ }
+
+ else
+ {
+ AcpiOsSleep (0, (HowLong / 1000) + 1);
+ }
+
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemDoSuspend
+ *
+ * PARAMETERS: HowLong - The amount of time to suspend
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Suspend running thread for specified amount of time.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemDoSuspend (
+ UINT32 HowLong)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Since this thread will sleep, we must release the interpreter */
+
+ AcpiExExitInterpreter ();
+
+ AcpiOsSleep ((UINT16) (HowLong / (UINT32) 1000),
+ (UINT16) (HowLong % (UINT32) 1000));
+
+ /* And now we must get the interpreter again */
+
+ Status = AcpiExEnterInterpreter ();
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemAcquireMutex
+ *
+ * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor
+ * *ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Provides an access point to perform synchronization operations
+ * within the AML. This function will cause a lock to be generated
+ * for the Mutex pointed to by ObjDesc.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemAcquireMutex (
+ ACPI_OPERAND_OBJECT *TimeDesc,
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("ExSystemAcquireMutex", ObjDesc);
+
+
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Support for the _GL_ Mutex object -- go get the global lock
+ */
+ if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore)
+ {
+ Status = AcpiEvAcquireGlobalLock ((UINT16) TimeDesc->Integer.Value);
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiExSystemWaitSemaphore (ObjDesc->Mutex.Semaphore,
+ (UINT16) TimeDesc->Integer.Value);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemReleaseMutex
+ *
+ * PARAMETERS: *ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Provides an access point to perform synchronization operations
+ * within the AML. This operation is a request to release a
+ * previously acquired Mutex. If the Mutex variable is set then
+ * it will be decremented.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemReleaseMutex (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE ("ExSystemReleaseMutex");
+
+
+ if (!ObjDesc)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Support for the _GL_ Mutex object -- release the global lock
+ */
+ if (ObjDesc->Mutex.Semaphore == AcpiGbl_GlobalLockSemaphore)
+ {
+ Status = AcpiEvReleaseGlobalLock ();
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiOsSignalSemaphore (ObjDesc->Mutex.Semaphore, 1);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemSignalEvent
+ *
+ * PARAMETERS: *ObjDesc - The object descriptor for this op
+ *
+ * RETURN: AE_OK
+ *
+ * DESCRIPTION: Provides an access point to perform synchronization operations
+ * within the AML.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemSignalEvent (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE ("ExSystemSignalEvent");
+
+
+ if (ObjDesc)
+ {
+ Status = AcpiOsSignalSemaphore (ObjDesc->Event.Semaphore, 1);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemWaitEvent
+ *
+ * PARAMETERS: *TimeDesc - The 'time to delay' object descriptor
+ * *ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Provides an access point to perform synchronization operations
+ * within the AML. This operation is a request to wait for an
+ * event.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemWaitEvent (
+ ACPI_OPERAND_OBJECT *TimeDesc,
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE ("ExSystemWaitEvent");
+
+
+ if (ObjDesc)
+ {
+ Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.Semaphore,
+ (UINT16) TimeDesc->Integer.Value);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiExSystemResetEvent
+ *
+ * PARAMETERS: *ObjDesc - The object descriptor for this op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Reset an event to a known state.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExSystemResetEvent (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+ ACPI_STATUS Status = AE_OK;
+ void *TempSemaphore;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * We are going to simply delete the existing semaphore and
+ * create a new one!
+ */
+ Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &TempSemaphore);
+ if (ACPI_SUCCESS (Status))
+ {
+ (void) AcpiOsDeleteSemaphore (ObjDesc->Event.Semaphore);
+ ObjDesc->Event.Semaphore = TempSemaphore;
+ }
+
+ return (Status);
+}
+
diff --git a/sys/contrib/dev/acpica/exutils.c b/sys/contrib/dev/acpica/exutils.c
new file mode 100644
index 0000000..30760a89
--- /dev/null
+++ b/sys/contrib/dev/acpica/exutils.c
@@ -0,0 +1,462 @@
+
+/******************************************************************************
+ *
+ * Module Name: exutils - interpreter/scanner utilities
+ * $Revision: 108 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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")
+
+
+#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_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,
+ char *OutString)
+{
+ UINT32 EisaId;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Swap ID to big-endian to get contiguous bits */
+
+ EisaId = AcpiUtDwordByteSwap (NumericId);
+
+ 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,
+ 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] = (char) ('0' + Remainder);\
+ Value = Quotient;
+ }
+}
+
+#endif
diff --git a/sys/contrib/dev/acpica/hwacpi.c b/sys/contrib/dev/acpica/hwacpi.c
new file mode 100644
index 0000000..d0bb320
--- /dev/null
+++ b/sys/contrib/dev/acpica/hwacpi.c
@@ -0,0 +1,307 @@
+
+/******************************************************************************
+ *
+ * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface
+ * $Revision: 62 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __HWACPI_C__
+
+#include "acpi.h"
+
+
+#define _COMPONENT ACPI_HARDWARE
+ ACPI_MODULE_NAME ("hwacpi")
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwInitialize
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Initialize and validate various ACPI registers
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwInitialize (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("HwInitialize");
+
+
+ /* We must have the ACPI tables by the time we get here */
+
+ if (!AcpiGbl_FADT)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "A FADT is not loaded\n"));
+
+ return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+ }
+
+ /* Sanity check the FADT for valid values */
+
+ Status = AcpiUtValidateFadt ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwSetMode
+ *
+ * PARAMETERS: Mode - SYS_MODE_ACPI or SYS_MODE_LEGACY
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Transitions the system into the requested mode.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwSetMode (
+ UINT32 Mode)
+{
+
+ ACPI_STATUS Status;
+ UINT32 Retry;
+
+
+ ACPI_FUNCTION_TRACE ("HwSetMode");
+
+ /*
+ * ACPI 2.0 clarified that if SMI_CMD in FADT is zero,
+ * system does not support mode transition.
+ */
+ if (!AcpiGbl_FADT->SmiCmd)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No SMI_CMD in FADT, mode transition failed.\n"));
+ return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
+ }
+
+ /*
+ * ACPI 2.0 clarified the meaning of ACPI_ENABLE and ACPI_DISABLE
+ * in FADT: If it is zero, enabling or disabling is not supported.
+ * As old systems may have used zero for mode transition,
+ * we make sure both the numbers are zero to determine these
+ * transitions are not supported.
+ */
+ if (!AcpiGbl_FADT->AcpiEnable && !AcpiGbl_FADT->AcpiDisable)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "No mode transition supported in this system.\n"));
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ switch (Mode)
+ {
+ case ACPI_SYS_MODE_ACPI:
+
+ /* BIOS should have disabled ALL fixed and GP events */
+
+ Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd,
+ (ACPI_INTEGER) AcpiGbl_FADT->AcpiEnable, 8);
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n"));
+ break;
+
+ case ACPI_SYS_MODE_LEGACY:
+
+ /*
+ * BIOS should clear all fixed status bits and restore fixed event
+ * enable bits to default
+ */
+ Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd,
+ (ACPI_INTEGER) AcpiGbl_FADT->AcpiDisable, 8);
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Attempting to enable Legacy (non-ACPI) mode\n"));
+ break;
+
+ default:
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Some hardware takes a LONG time to switch modes. Give them 3 sec to
+ * do so, but allow faster systems to proceed more quickly.
+ */
+ Retry = 3000;
+ while (Retry)
+ {
+ Status = AE_NO_HARDWARE_RESPONSE;
+
+ if (AcpiHwGetMode() == Mode)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", Mode));
+ Status = AE_OK;
+ break;
+ }
+ AcpiOsStall(1000);
+ Retry--;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwGetMode
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY
+ *
+ * DESCRIPTION: Return current operating state of system. Determined by
+ * querying the SCI_EN bit.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiHwGetMode (void)
+{
+ ACPI_STATUS Status;
+ UINT32 Value;
+
+
+ ACPI_FUNCTION_TRACE ("HwGetMode");
+
+ Status = AcpiGetRegister (ACPI_BITREG_SCI_ENABLE, &Value, ACPI_MTX_LOCK);
+ if (ACPI_FAILURE (Status))
+ {
+ return_VALUE (ACPI_SYS_MODE_LEGACY);
+ }
+
+ if (Value)
+ {
+ return_VALUE (ACPI_SYS_MODE_ACPI);
+ }
+ else
+ {
+ return_VALUE (ACPI_SYS_MODE_LEGACY);
+ }
+}
diff --git a/sys/contrib/dev/acpica/hwgpe.c b/sys/contrib/dev/acpica/hwgpe.c
new file mode 100644
index 0000000..29f8b04
--- /dev/null
+++ b/sys/contrib/dev/acpica/hwgpe.c
@@ -0,0 +1,553 @@
+
+/******************************************************************************
+ *
+ * Module Name: hwgpe - Low level GPE enable/disable/clear functions
+ * $Revision: 47 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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"
+
+#define _COMPONENT ACPI_HARDWARE
+ ACPI_MODULE_NAME ("hwgpe")
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwEnableGpe
+ *
+ * PARAMETERS: GpeNumber - The GPE
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Enable a single GPE.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwEnableGpe (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo)
+{
+ UINT32 InByte;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * Read the current value of the register, set the appropriate bit
+ * to enable the GPE, and write out the new register.
+ */
+ Status = AcpiHwLowLevelRead (8, &InByte,
+ &GpeEventInfo->RegisterInfo->EnableAddress, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Write with the new GPE bit enabled */
+
+ Status = AcpiHwLowLevelWrite (8, (InByte | GpeEventInfo->BitMask),
+ &GpeEventInfo->RegisterInfo->EnableAddress, 0);
+
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwEnableGpeForWakeup
+ *
+ * PARAMETERS: GpeNumber - The GPE
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Keep track of which GPEs the OS has requested not be
+ * disabled when going to sleep.
+ *
+ ******************************************************************************/
+
+void
+AcpiHwEnableGpeForWakeup (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo)
+{
+ ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Get the info block for the entire GPE register */
+
+ GpeRegisterInfo = GpeEventInfo->RegisterInfo;
+ if (!GpeRegisterInfo)
+ {
+ return;
+ }
+
+ /*
+ * Set the bit so we will not disable this when sleeping
+ */
+ GpeRegisterInfo->WakeEnable |= GpeEventInfo->BitMask;
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwDisableGpe
+ *
+ * PARAMETERS: GpeNumber - The GPE
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Disable a single GPE.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwDisableGpe (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo)
+{
+ UINT32 InByte;
+ ACPI_STATUS Status;
+ ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Get the info block for the entire GPE register */
+
+ GpeRegisterInfo = GpeEventInfo->RegisterInfo;
+ if (!GpeRegisterInfo)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Read the current value of the register, clear the appropriate bit,
+ * and write out the new register value to disable the GPE.
+ */
+ Status = AcpiHwLowLevelRead (8, &InByte,
+ &GpeRegisterInfo->EnableAddress, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Write the byte with this GPE bit cleared */
+
+ Status = AcpiHwLowLevelWrite (8, (InByte & ~(GpeEventInfo->BitMask)),
+ &GpeRegisterInfo->EnableAddress, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ AcpiHwDisableGpeForWakeup (GpeEventInfo);
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwDisableGpeForWakeup
+ *
+ * PARAMETERS: GpeNumber - The GPE
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Keep track of which GPEs the OS has requested not be
+ * disabled when going to sleep.
+ *
+ ******************************************************************************/
+
+void
+AcpiHwDisableGpeForWakeup (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo)
+{
+ ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Get the info block for the entire GPE register */
+
+ GpeRegisterInfo = GpeEventInfo->RegisterInfo;
+ if (!GpeRegisterInfo)
+ {
+ return;
+ }
+
+ /*
+ * Clear the bit so we will disable this when sleeping
+ */
+ GpeRegisterInfo->WakeEnable &= ~(GpeEventInfo->BitMask);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwClearGpe
+ *
+ * PARAMETERS: GpeNumber - The GPE
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Clear a single GPE.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwClearGpe (
+ ACPI_GPE_EVENT_INFO *GpeEventInfo)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * Write a one to the appropriate bit in the status register to
+ * clear this GPE.
+ */
+ Status = AcpiHwLowLevelWrite (8, GpeEventInfo->BitMask,
+ &GpeEventInfo->RegisterInfo->StatusAddress, 0);
+
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwGetGpeStatus
+ *
+ * PARAMETERS: GpeNumber - The GPE
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Return the status of a single GPE.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwGetGpeStatus (
+ UINT32 GpeNumber,
+ ACPI_EVENT_STATUS *EventStatus)
+{
+ UINT32 InByte;
+ UINT8 BitMask;
+ ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
+ ACPI_GPE_EVENT_INFO *GpeEventInfo;
+ ACPI_STATUS Status;
+ ACPI_EVENT_STATUS LocalEventStatus = 0;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!EventStatus)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ GpeEventInfo = AcpiEvGetGpeEventInfo (GpeNumber);
+ if (!GpeEventInfo)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Get the info block for the entire GPE register */
+
+ GpeRegisterInfo = GpeEventInfo->RegisterInfo;
+
+ /* Get the register bitmask for this GPE */
+
+ BitMask = GpeEventInfo->BitMask;
+
+ /* GPE Enabled? */
+
+ Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->EnableAddress, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ if (BitMask & InByte)
+ {
+ LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
+ }
+
+ /* GPE Enabled for wake? */
+
+ if (BitMask & GpeRegisterInfo->WakeEnable)
+ {
+ LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED;
+ }
+
+ /* GPE active (set)? */
+
+ Status = AcpiHwLowLevelRead (8, &InByte, &GpeRegisterInfo->StatusAddress, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ if (BitMask & InByte)
+ {
+ LocalEventStatus |= ACPI_EVENT_FLAG_SET;
+ }
+
+ /* Set return value */
+
+ (*EventStatus) = LocalEventStatus;
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwDisableNonWakeupGpes
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Disable all non-wakeup GPEs
+ * Call with interrupts disabled. The interrupt handler also
+ * modifies GpeRegisterInfo->Enable, so it should not be
+ * given the chance to run until after non-wake GPEs are
+ * re-enabled.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwDisableNonWakeupGpes (
+ void)
+{
+ UINT32 i;
+ ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
+ UINT32 InValue;
+ ACPI_STATUS Status;
+ ACPI_GPE_BLOCK_INFO *GpeBlock;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ GpeBlock = AcpiGbl_GpeBlockListHead;
+ while (GpeBlock)
+ {
+ /* Get the register info for the entire GPE block */
+
+ GpeRegisterInfo = GpeBlock->RegisterInfo;
+ if (!GpeRegisterInfo)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ for (i = 0; i < GpeBlock->RegisterCount; i++)
+ {
+ /*
+ * Read the enabled status of all GPEs. We
+ * will be using it to restore all the GPEs later.
+ */
+ Status = AcpiHwLowLevelRead (8, &InValue,
+ &GpeRegisterInfo->EnableAddress, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ GpeRegisterInfo->Enable = (UINT8) InValue;
+
+ /*
+ * Disable all GPEs except wakeup GPEs.
+ */
+ Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->WakeEnable,
+ &GpeRegisterInfo->EnableAddress, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ GpeRegisterInfo++;
+ }
+
+ GpeBlock = GpeBlock->Next;
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwEnableNonWakeupGpes
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Enable all non-wakeup GPEs we previously enabled.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwEnableNonWakeupGpes (
+ void)
+{
+ UINT32 i;
+ ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
+ ACPI_STATUS Status;
+ ACPI_GPE_BLOCK_INFO *GpeBlock;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ GpeBlock = AcpiGbl_GpeBlockListHead;
+ while (GpeBlock)
+ {
+ /* Get the register info for the entire GPE block */
+
+ GpeRegisterInfo = GpeBlock->RegisterInfo;
+ if (!GpeRegisterInfo)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ for (i = 0; i < GpeBlock->RegisterCount; i++)
+ {
+ /*
+ * We previously stored the enabled status of all GPEs.
+ * Blast them back in.
+ */
+ Status = AcpiHwLowLevelWrite (8, GpeRegisterInfo->Enable,
+ &GpeRegisterInfo->EnableAddress, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ GpeRegisterInfo++;
+ }
+
+ GpeBlock = GpeBlock->Next;
+ }
+
+ return (AE_OK);
+}
diff --git a/sys/contrib/dev/acpica/hwregs.c b/sys/contrib/dev/acpica/hwregs.c
new file mode 100644
index 0000000..6b74e27
--- /dev/null
+++ b/sys/contrib/dev/acpica/hwregs.c
@@ -0,0 +1,982 @@
+
+/*******************************************************************************
+ *
+ * Module Name: hwregs - Read/write access functions for the various ACPI
+ * control and status registers.
+ * $Revision: 142 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __HWREGS_C__
+
+#include "acpi.h"
+#include "acnamesp.h"
+
+#define _COMPONENT ACPI_HARDWARE
+ ACPI_MODULE_NAME ("hwregs")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwClearAcpiStatus
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Clears all fixed and general purpose status bits
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwClearAcpiStatus (void)
+{
+ ACPI_NATIVE_UINT i;
+ ACPI_STATUS Status;
+ ACPI_GPE_BLOCK_INFO *GpeBlock;
+
+
+ ACPI_FUNCTION_TRACE ("HwClearAcpiStatus");
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %04X\n",
+ ACPI_BITMASK_ALL_FIXED_STATUS,
+ (UINT16) ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm1aEvtBlk.Address)));
+
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS,
+ ACPI_BITMASK_ALL_FIXED_STATUS);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ /* Clear the fixed events */
+
+ if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm1bEvtBlk.Address))
+ {
+ Status = AcpiHwLowLevelWrite (16, ACPI_BITMASK_ALL_FIXED_STATUS,
+ &AcpiGbl_FADT->XPm1bEvtBlk, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+ }
+
+ /* Clear the GPE Bits in all GPE registers in all GPE blocks */
+
+ GpeBlock = AcpiGbl_GpeBlockListHead;
+ while (GpeBlock)
+ {
+ for (i = 0; i < GpeBlock->RegisterCount; i++)
+ {
+ Status = AcpiHwLowLevelWrite (8, 0xFF,
+ &GpeBlock->RegisterInfo[i].StatusAddress, (UINT32) 0);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+ }
+
+ GpeBlock = GpeBlock->Next;
+ }
+
+UnlockAndExit:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetSleepTypeData
+ *
+ * PARAMETERS: SleepState - Numeric sleep state
+ * *SleepTypeA - Where SLP_TYPa is returned
+ * *SleepTypeB - Where SLP_TYPb is returned
+ *
+ * RETURN: Status - ACPI status
+ *
+ * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep
+ * state.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetSleepTypeData (
+ UINT8 SleepState,
+ UINT8 *SleepTypeA,
+ UINT8 *SleepTypeB)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiGetSleepTypeData");
+
+
+ /*
+ * Validate parameters
+ */
+ if ((SleepState > ACPI_S_STATES_MAX) ||
+ !SleepTypeA || !SleepTypeB)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Evaluate the namespace object containing the values for this state
+ */
+ Status = AcpiNsEvaluateByName ((char *) AcpiGbl_DbSleepStates[SleepState],
+ NULL, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s while evaluating SleepState [%s]\n",
+ AcpiFormatException (Status), AcpiGbl_DbSleepStates[SleepState]));
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Must have a return object */
+
+ if (!ObjDesc)
+ {
+ ACPI_REPORT_ERROR (("Missing Sleep State object\n"));
+ Status = AE_NOT_EXIST;
+ }
+
+ /* It must be of type Package */
+
+ else if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_PACKAGE)
+ {
+ ACPI_REPORT_ERROR (("Sleep State object not a Package\n"));
+ Status = AE_AML_OPERAND_TYPE;
+ }
+
+ /* The package must have at least two elements */
+
+ else if (ObjDesc->Package.Count < 2)
+ {
+ ACPI_REPORT_ERROR (("Sleep State package does not have at least two elements\n"));
+ Status = AE_AML_NO_OPERAND;
+ }
+
+ /* The first two elements must both be of type Integer */
+
+ else if ((ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[0]) != ACPI_TYPE_INTEGER) ||
+ (ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[1]) != ACPI_TYPE_INTEGER))
+ {
+ ACPI_REPORT_ERROR (("Sleep State package elements are not both Integers (%s, %s)\n",
+ AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[0]),
+ AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[1])));
+ Status = AE_AML_OPERAND_TYPE;
+ }
+ else
+ {
+ /*
+ * Valid _Sx_ package size, type, and value
+ */
+ *SleepTypeA = (UINT8) (ObjDesc->Package.Elements[0])->Integer.Value;
+ *SleepTypeB = (UINT8) (ObjDesc->Package.Elements[1])->Integer.Value;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While evaluating SleepState [%s], bad Sleep object %p type %s\n",
+ AcpiGbl_DbSleepStates[SleepState], ObjDesc, AcpiUtGetObjectTypeName (ObjDesc)));
+ }
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiHwGetRegisterBitMask
+ *
+ * PARAMETERS: RegisterId - Index of ACPI Register to access
+ *
+ * RETURN: The bit mask to be used when accessing the register
+ *
+ * DESCRIPTION: Map RegisterId into a register bit mask.
+ *
+ ******************************************************************************/
+
+ACPI_BIT_REGISTER_INFO *
+AcpiHwGetBitRegisterInfo (
+ UINT32 RegisterId)
+{
+ ACPI_FUNCTION_NAME ("HwGetBitRegisterInfo");
+
+
+ if (RegisterId > ACPI_BITREG_MAX)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid BitRegister ID: %X\n", RegisterId));
+ return (NULL);
+ }
+
+ return (&AcpiGbl_BitRegisterInfo[RegisterId]);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetRegister
+ *
+ * PARAMETERS: RegisterId - Index of ACPI Register to access
+ * UseLock - Lock the hardware
+ *
+ * RETURN: Value is read from specified Register. Value returned is
+ * normalized to bit0 (is shifted all the way right)
+ *
+ * DESCRIPTION: ACPI BitRegister read function.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetRegister (
+ UINT32 RegisterId,
+ UINT32 *ReturnValue,
+ UINT32 Flags)
+{
+ UINT32 RegisterValue = 0;
+ ACPI_BIT_REGISTER_INFO *BitRegInfo;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiGetRegister");
+
+
+ /* Get the info structure corresponding to the requested ACPI Register */
+
+ BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
+ if (!BitRegInfo)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (Flags & ACPI_MTX_LOCK)
+ {
+ Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK,
+ BitRegInfo->ParentRegister, &RegisterValue);
+
+ if (Flags & ACPI_MTX_LOCK)
+ {
+ (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
+ }
+
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Normalize the value that was read */
+
+ RegisterValue = ((RegisterValue & BitRegInfo->AccessBitMask)
+ >> BitRegInfo->BitPosition);
+
+ *ReturnValue = RegisterValue;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read value %X\n", RegisterValue));
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiSetRegister
+ *
+ * PARAMETERS: RegisterId - ID of ACPI BitRegister to access
+ * Value - (only used on write) value to write to the
+ * Register, NOT pre-normalized to the bit pos.
+ * Flags - Lock the hardware or not
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: ACPI Bit Register write function.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiSetRegister (
+ UINT32 RegisterId,
+ UINT32 Value,
+ UINT32 Flags)
+{
+ UINT32 RegisterValue = 0;
+ ACPI_BIT_REGISTER_INFO *BitRegInfo;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_U32 ("AcpiSetRegister", RegisterId);
+
+
+ /* Get the info structure corresponding to the requested ACPI Register */
+
+ BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
+ if (!BitRegInfo)
+ {
+ ACPI_REPORT_ERROR (("Bad ACPI HW RegisterId: %X\n", RegisterId));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (Flags & ACPI_MTX_LOCK)
+ {
+ Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /* Always do a register read first so we can insert the new bits */
+
+ Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK,
+ BitRegInfo->ParentRegister, &RegisterValue);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ /*
+ * Decode the Register ID
+ * Register id = Register block id | bit id
+ *
+ * Check bit id to fine locate Register offset.
+ * Check Mask to determine Register offset, and then read-write.
+ */
+ switch (BitRegInfo->ParentRegister)
+ {
+ case ACPI_REGISTER_PM1_STATUS:
+
+ /*
+ * Status Registers are different from the rest. Clear by
+ * writing 1, writing 0 has no effect. So, the only relevant
+ * information is the single bit we're interested in, all others should
+ * be written as 0 so they will be left unchanged
+ */
+ Value = ACPI_REGISTER_PREPARE_BITS (Value,
+ BitRegInfo->BitPosition, BitRegInfo->AccessBitMask);
+ if (Value)
+ {
+ Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
+ ACPI_REGISTER_PM1_STATUS, (UINT16) Value);
+ RegisterValue = 0;
+ }
+ break;
+
+
+ case ACPI_REGISTER_PM1_ENABLE:
+
+ ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
+ BitRegInfo->AccessBitMask, Value);
+
+ Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
+ ACPI_REGISTER_PM1_ENABLE, (UINT16) RegisterValue);
+ break;
+
+
+ case ACPI_REGISTER_PM1_CONTROL:
+
+ /*
+ * Read the PM1 Control register.
+ * Note that at this level, the fact that there are actually TWO
+ * registers (A and B - and that B may not exist) is abstracted.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM1 control: Read %X\n", RegisterValue));
+
+ ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
+ BitRegInfo->AccessBitMask, Value);
+
+ Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, RegisterId,
+ (UINT16) RegisterValue);
+ break;
+
+
+ case ACPI_REGISTER_PM2_CONTROL:
+
+ Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK,
+ ACPI_REGISTER_PM2_CONTROL, &RegisterValue);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n",
+ RegisterValue,
+ ACPI_HIDWORD (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)),
+ ACPI_LODWORD (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address))));
+
+ ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
+ BitRegInfo->AccessBitMask, Value);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n",
+ RegisterValue,
+ ACPI_HIDWORD (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)),
+ ACPI_LODWORD (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address))));
+
+ Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
+ ACPI_REGISTER_PM2_CONTROL, (UINT8) (RegisterValue));
+ break;
+
+
+ default:
+ break;
+ }
+
+
+UnlockAndExit:
+
+ if (Flags & ACPI_MTX_LOCK)
+ {
+ (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
+ }
+
+ /* Normalize the value that was read */
+
+ ACPI_DEBUG_EXEC (RegisterValue = ((RegisterValue & BitRegInfo->AccessBitMask) >> BitRegInfo->BitPosition));
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_IO, "ACPI Register Write actual %X\n", RegisterValue));
+ return_ACPI_STATUS (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwRegisterRead
+ *
+ * PARAMETERS: UseLock - Mutex hw access.
+ * RegisterId - RegisterID + Offset.
+ *
+ * RETURN: Value read or written.
+ *
+ * DESCRIPTION: Acpi register read function. Registers are read at the
+ * given offset.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwRegisterRead (
+ BOOLEAN UseLock,
+ UINT32 RegisterId,
+ UINT32 *ReturnValue)
+{
+ UINT32 Value1 = 0;
+ UINT32 Value2 = 0;
+ UINT32 BankOffset;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("HwRegisterRead");
+
+
+ if (ACPI_MTX_LOCK == UseLock)
+ {
+ Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ switch (RegisterId)
+ {
+ case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
+
+ Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aEvtBlk, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bEvtBlk, 0);
+ Value1 |= Value2;
+ break;
+
+
+ case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access*/
+
+ BankOffset = ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen);
+ Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aEvtBlk, BankOffset);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bEvtBlk, BankOffset);
+ Value1 |= Value2;
+ break;
+
+
+ case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
+
+ Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aCntBlk, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bCntBlk, 0);
+ Value1 |= Value2;
+ break;
+
+
+ case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
+
+ Status = AcpiHwLowLevelRead (8, &Value1, &AcpiGbl_FADT->XPm2CntBlk, 0);
+ break;
+
+
+ case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
+
+ Status = AcpiHwLowLevelRead (32, &Value1, &AcpiGbl_FADT->XPmTmrBlk, 0);
+ break;
+
+ case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
+
+ Status = AcpiOsReadPort (AcpiGbl_FADT->SmiCmd, &Value1, 8);
+ break;
+
+ default:
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", RegisterId));
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+UnlockAndExit:
+ if (ACPI_MTX_LOCK == UseLock)
+ {
+ (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
+ }
+
+ if (ACPI_SUCCESS (Status))
+ {
+ *ReturnValue = Value1;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwRegisterWrite
+ *
+ * PARAMETERS: UseLock - Mutex hw access.
+ * RegisterId - RegisterID + Offset.
+ *
+ * RETURN: Value read or written.
+ *
+ * DESCRIPTION: Acpi register Write function. Registers are written at the
+ * given offset.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwRegisterWrite (
+ BOOLEAN UseLock,
+ UINT32 RegisterId,
+ UINT32 Value)
+{
+ UINT32 BankOffset;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("HwRegisterWrite");
+
+
+ if (ACPI_MTX_LOCK == UseLock)
+ {
+ Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ switch (RegisterId)
+ {
+ case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
+
+ Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aEvtBlk, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bEvtBlk, 0);
+ break;
+
+
+ case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access*/
+
+ BankOffset = ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen);
+ Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aEvtBlk, BankOffset);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bEvtBlk, BankOffset);
+ break;
+
+
+ case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
+
+ Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aCntBlk, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bCntBlk, 0);
+ break;
+
+
+ case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */
+
+ Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aCntBlk, 0);
+ break;
+
+
+ case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */
+
+ Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bCntBlk, 0);
+ break;
+
+
+ case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
+
+ Status = AcpiHwLowLevelWrite (8, Value, &AcpiGbl_FADT->XPm2CntBlk, 0);
+ break;
+
+
+ case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
+
+ Status = AcpiHwLowLevelWrite (32, Value, &AcpiGbl_FADT->XPmTmrBlk, 0);
+ break;
+
+
+ case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
+
+ /* SMI_CMD is currently always in IO space */
+
+ Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, (ACPI_INTEGER) Value, 8);
+ break;
+
+
+ default:
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+UnlockAndExit:
+ if (ACPI_MTX_LOCK == UseLock)
+ {
+ (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwLowLevelRead
+ *
+ * PARAMETERS: Register - GAS register structure
+ * Offset - Offset from the base address in the GAS
+ * Width - 8, 16, or 32
+ *
+ * RETURN: Value read
+ *
+ * DESCRIPTION: Read from either memory, IO, or PCI config space.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwLowLevelRead (
+ UINT32 Width,
+ UINT32 *Value,
+ ACPI_GENERIC_ADDRESS *Reg,
+ UINT32 Offset)
+{
+ ACPI_PHYSICAL_ADDRESS MemAddress;
+ ACPI_IO_ADDRESS IoAddress;
+ ACPI_PCI_ID PciId;
+ UINT16 PciRegister;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_NAME ("HwLowLevelRead");
+
+
+ /*
+ * Must have a valid pointer to a GAS structure, and
+ * a non-zero address within. However, don't return an error
+ * because the PM1A/B code must not fail if B isn't present.
+ */
+ if ((!Reg) ||
+ (!ACPI_VALID_ADDRESS (Reg->Address)))
+ {
+ return (AE_OK);
+ }
+ *Value = 0;
+
+ /*
+ * Three address spaces supported:
+ * Memory, Io, or PCI config.
+ */
+ switch (Reg->AddressSpaceId)
+ {
+ case ACPI_ADR_SPACE_SYSTEM_MEMORY:
+
+ MemAddress = (ACPI_GET_ADDRESS (Reg->Address)
+ + (ACPI_PHYSICAL_ADDRESS) Offset);
+
+ Status = AcpiOsReadMemory (MemAddress, Value, Width);
+ break;
+
+
+ case ACPI_ADR_SPACE_SYSTEM_IO:
+
+ IoAddress = (ACPI_IO_ADDRESS) (ACPI_GET_ADDRESS (Reg->Address)
+ + (ACPI_PHYSICAL_ADDRESS) Offset);
+
+ Status = AcpiOsReadPort (IoAddress, Value, Width);
+ break;
+
+
+ case ACPI_ADR_SPACE_PCI_CONFIG:
+
+ PciId.Segment = 0;
+ PciId.Bus = 0;
+ PciId.Device = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (Reg->Address));
+ PciId.Function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (Reg->Address));
+ PciRegister = (UINT16) (ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (Reg->Address))
+ + Offset);
+
+ Status = AcpiOsReadPciConfiguration (&PciId, PciRegister, Value, Width);
+ break;
+
+
+ default:
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported address space: %X\n", Reg->AddressSpaceId));
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiHwLowLevelWrite
+ *
+ * PARAMETERS: Width - 8, 16, or 32
+ * Value - To be written
+ * Register - GAS register structure
+ * Offset - Offset from the base address in the GAS
+ *
+ *
+ * RETURN: Value read
+ *
+ * DESCRIPTION: Read from either memory, IO, or PCI config space.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiHwLowLevelWrite (
+ UINT32 Width,
+ UINT32 Value,
+ ACPI_GENERIC_ADDRESS *Reg,
+ UINT32 Offset)
+{
+ ACPI_PHYSICAL_ADDRESS MemAddress;
+ ACPI_IO_ADDRESS IoAddress;
+ ACPI_PCI_ID PciId;
+ UINT16 PciRegister;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_NAME ("HwLowLevelWrite");
+
+
+ /*
+ * Must have a valid pointer to a GAS structure, and
+ * a non-zero address within. However, don't return an error
+ * because the PM1A/B code must not fail if B isn't present.
+ */
+ if ((!Reg) ||
+ (!ACPI_VALID_ADDRESS (Reg->Address)))
+ {
+ return (AE_OK);
+ }
+ /*
+ * Three address spaces supported:
+ * Memory, Io, or PCI config.
+ */
+ switch (Reg->AddressSpaceId)
+ {
+ case ACPI_ADR_SPACE_SYSTEM_MEMORY:
+
+ MemAddress = (ACPI_GET_ADDRESS (Reg->Address)
+ + (ACPI_PHYSICAL_ADDRESS) Offset);
+
+ Status = AcpiOsWriteMemory (MemAddress, (ACPI_INTEGER) Value, Width);
+ break;
+
+
+ case ACPI_ADR_SPACE_SYSTEM_IO:
+
+ IoAddress = (ACPI_IO_ADDRESS) (ACPI_GET_ADDRESS (Reg->Address)
+ + (ACPI_PHYSICAL_ADDRESS) Offset);
+
+ Status = AcpiOsWritePort (IoAddress, (ACPI_INTEGER) Value, Width);
+ break;
+
+
+ case ACPI_ADR_SPACE_PCI_CONFIG:
+
+ PciId.Segment = 0;
+ PciId.Bus = 0;
+ PciId.Device = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (Reg->Address));
+ PciId.Function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (Reg->Address));
+ PciRegister = (UINT16) (ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (Reg->Address))
+ + Offset);
+
+ Status = AcpiOsWritePciConfiguration (&PciId, PciRegister, (ACPI_INTEGER) Value, Width);
+ break;
+
+
+ default:
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported address space: %X\n", Reg->AddressSpaceId));
+ Status = AE_BAD_PARAMETER;
+ break;
+ }
+
+ return (Status);
+}
diff --git a/sys/contrib/dev/acpica/hwsleep.c b/sys/contrib/dev/acpica/hwsleep.c
new file mode 100644
index 0000000..47c5155
--- /dev/null
+++ b/sys/contrib/dev/acpica/hwsleep.c
@@ -0,0 +1,553 @@
+
+/******************************************************************************
+ *
+ * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface
+ * $Revision: 52 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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"
+
+#define _COMPONENT ACPI_HARDWARE
+ ACPI_MODULE_NAME ("hwsleep")
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiSetFirmwareWakingVector
+ *
+ * PARAMETERS: PhysicalAddress - Physical address of ACPI real mode
+ * entry point.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Access function for dFirmwareWakingVector field in FACS
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiSetFirmwareWakingVector (
+ ACPI_PHYSICAL_ADDRESS PhysicalAddress)
+{
+
+ ACPI_FUNCTION_TRACE ("AcpiSetFirmwareWakingVector");
+
+
+ /* Set the vector */
+
+ if (AcpiGbl_CommonFACS.VectorWidth == 32)
+ {
+ *(ACPI_CAST_PTR (UINT32, AcpiGbl_CommonFACS.FirmwareWakingVector))
+ = (UINT32) PhysicalAddress;
+ }
+ else
+ {
+ *AcpiGbl_CommonFACS.FirmwareWakingVector
+ = PhysicalAddress;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiGetFirmwareWakingVector
+ *
+ * PARAMETERS: *PhysicalAddress - Output buffer where contents of
+ * the FirmwareWakingVector field of
+ * the FACS will be stored.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Access function for FirmwareWakingVector field in FACS
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetFirmwareWakingVector (
+ ACPI_PHYSICAL_ADDRESS *PhysicalAddress)
+{
+
+ ACPI_FUNCTION_TRACE ("AcpiGetFirmwareWakingVector");
+
+
+ if (!PhysicalAddress)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Get the vector */
+
+ if (AcpiGbl_CommonFACS.VectorWidth == 32)
+ {
+ *PhysicalAddress = (ACPI_PHYSICAL_ADDRESS)
+ *(ACPI_CAST_PTR (UINT32, AcpiGbl_CommonFACS.FirmwareWakingVector));
+ }
+ else
+ {
+ *PhysicalAddress =
+ *AcpiGbl_CommonFACS.FirmwareWakingVector;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiEnterSleepStatePrep
+ *
+ * PARAMETERS: SleepState - Which sleep state to enter
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231)
+ * This function must execute with interrupts enabled.
+ * We break sleeping into 2 stages so that OSPM can handle
+ * various OS-specific tasks between the two steps.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnterSleepStatePrep (
+ UINT8 SleepState)
+{
+ ACPI_STATUS Status;
+ ACPI_OBJECT_LIST ArgList;
+ ACPI_OBJECT Arg;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiEnterSleepStatePrep");
+
+
+ /*
+ * _PSW methods could be run here to enable wake-on keyboard, LAN, etc.
+ */
+ Status = AcpiGetSleepTypeData (SleepState,
+ &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Setup parameter object */
+
+ ArgList.Count = 1;
+ ArgList.Pointer = &Arg;
+
+ Arg.Type = ACPI_TYPE_INTEGER;
+ Arg.Integer.Value = SleepState;
+
+ /* Run the _PTS and _GTS methods */
+
+ Status = AcpiEvaluateObject (NULL, "\\_PTS", &ArgList, NULL);
+ if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiEvaluateObject (NULL, "\\_GTS", &ArgList, NULL);
+ if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiEnterSleepState
+ *
+ * PARAMETERS: SleepState - Which sleep state to enter
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
+ * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnterSleepState (
+ UINT8 SleepState)
+{
+ UINT32 PM1AControl;
+ UINT32 PM1BControl;
+ ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo;
+ ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo;
+ UINT32 InValue;
+ UINT32 Retry;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiEnterSleepState");
+
+
+ if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) ||
+ (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX))
+ {
+ ACPI_REPORT_ERROR (("Sleep values out of range: A=%X B=%X\n",
+ AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB));
+ return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
+ }
+
+
+ SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE_A);
+ SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE);
+
+ /* Clear wake status */
+
+ Status = AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_LOCK);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiHwClearAcpiStatus();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Disable BM arbitration */
+
+ Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 1, ACPI_MTX_LOCK);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiHwDisableNonWakeupGpes();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Get current value of PM1A control */
+
+ Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL, &PM1AControl);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Entering sleep state [S%d]\n", SleepState));
+
+ /* Clear SLP_EN and SLP_TYP fields */
+
+ PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask | SleepEnableRegInfo->AccessBitMask);
+ PM1BControl = PM1AControl;
+
+ /* Insert SLP_TYP bits */
+
+ PM1AControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition);
+ PM1BControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition);
+
+ /* Write #1: fill in SLP_TYP data */
+
+ Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Insert SLP_ENABLE bit */
+
+ PM1AControl |= SleepEnableRegInfo->AccessBitMask;
+ PM1BControl |= SleepEnableRegInfo->AccessBitMask;
+
+ /* Write #2: SLP_TYP + SLP_EN */
+
+ ACPI_FLUSH_CPU_CACHE ();
+
+ Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Wait a second, then try again. This is to get S4/5 to work on all machines.
+ */
+ if (SleepState > ACPI_STATE_S3)
+ {
+ /*
+ * We wait so long to allow chipsets that poll this reg very slowly to
+ * still read the right value. Ideally, this entire block would go
+ * away entirely.
+ */
+ AcpiOsStall (10000000);
+
+ Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL,
+ SleepEnableRegInfo->AccessBitMask);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /* Wait until we enter sleep state */
+
+ Retry = 1000;
+ do
+ {
+ Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, ACPI_MTX_DO_NOT_LOCK);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Some BIOSes don't set WAK_STS at all,
+ * give up waiting for wakeup if we time out.
+ */
+ if (Retry-- == 0)
+ {
+ break; /* giving up */
+ }
+
+ /* Spin until we wake */
+
+ } while (!InValue);
+
+ Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiEnterSleepStateS4bios
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform a S4 bios request.
+ * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnterSleepStateS4bios (
+ void)
+{
+ UINT32 InValue;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiEnterSleepStateS4bios");
+
+ AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK);
+ AcpiHwClearAcpiStatus();
+
+ AcpiHwDisableNonWakeupGpes();
+
+ ACPI_FLUSH_CPU_CACHE();
+
+ Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, (ACPI_INTEGER) AcpiGbl_FADT->S4BiosReq, 8);
+
+ do {
+ AcpiOsStall(1000);
+ Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, ACPI_MTX_DO_NOT_LOCK);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ } while (!InValue);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiLeaveSleepState
+ *
+ * PARAMETERS: SleepState - Which sleep state we just exited
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiLeaveSleepState (
+ UINT8 SleepState)
+{
+ ACPI_OBJECT_LIST ArgList;
+ ACPI_OBJECT Arg;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiLeaveSleepState");
+
+
+ /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */
+
+ AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID;
+
+ /* Setup parameter object */
+
+ ArgList.Count = 1;
+ ArgList.Pointer = &Arg;
+
+ Arg.Type = ACPI_TYPE_INTEGER;
+ Arg.Integer.Value = SleepState;
+
+ /* Ignore any errors from these methods */
+
+ Status = AcpiEvaluateObject (NULL, "\\_BFS", &ArgList, NULL);
+ if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
+ {
+ ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", AcpiFormatException (Status)));
+ }
+
+ Status = AcpiEvaluateObject (NULL, "\\_WAK", &ArgList, NULL);
+ if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND)
+ {
+ ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", AcpiFormatException (Status)));
+ }
+
+ /* _WAK returns stuff - do we want to look at it? */
+
+ Status = AcpiHwEnableNonWakeupGpes();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Disable BM arbitration */
+ Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_LOCK);
+
+ return_ACPI_STATUS (Status);
+}
diff --git a/sys/contrib/dev/acpica/hwtimer.c b/sys/contrib/dev/acpica/hwtimer.c
new file mode 100644
index 0000000..92267a6
--- /dev/null
+++ b/sys/contrib/dev/acpica/hwtimer.c
@@ -0,0 +1,290 @@
+
+/******************************************************************************
+ *
+ * Name: hwtimer.c - ACPI Power Management Timer Interface
+ * $Revision: 24 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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"
+
+#define _COMPONENT ACPI_HARDWARE
+ ACPI_MODULE_NAME ("hwtimer")
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiGetTimerResolution
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: Number of bits of resolution in the PM Timer (24 or 32).
+ *
+ * DESCRIPTION: Obtains resolution of the ACPI PM Timer.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetTimerResolution (
+ UINT32 *Resolution)
+{
+ ACPI_FUNCTION_TRACE ("AcpiGetTimerResolution");
+
+
+ if (!Resolution)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ if (0 == AcpiGbl_FADT->TmrValExt)
+ {
+ *Resolution = 24;
+ }
+ else
+ {
+ *Resolution = 32;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiGetTimer
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: Current value of the ACPI PM Timer (in ticks).
+ *
+ * DESCRIPTION: Obtains current value of ACPI PM Timer.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetTimer (
+ UINT32 *Ticks)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiGetTimer");
+
+
+ if (!Ticks)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiHwLowLevelRead (32, Ticks, &AcpiGbl_FADT->XPmTmrBlk, 0);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiGetTimerDuration
+ *
+ * PARAMETERS: StartTicks
+ * EndTicks
+ * TimeElapsed
+ *
+ * RETURN: TimeElapsed
+ *
+ * DESCRIPTION: Computes the time elapsed (in microseconds) between two
+ * PM Timer time stamps, taking into account the possibility of
+ * rollovers, the timer resolution, and timer frequency.
+ *
+ * The PM Timer's clock ticks at roughly 3.6 times per
+ * _microsecond_, and its clock continues through Cx state
+ * transitions (unlike many CPU timestamp counters) -- making it
+ * a versatile and accurate timer.
+ *
+ * Note that this function accommodates only a single timer
+ * rollover. Thus for 24-bit timers, this function should only
+ * be used for calculating durations less than ~4.6 seconds
+ * (~20 minutes for 32-bit timers) -- calculations below
+ *
+ * 2**24 Ticks / 3,600,000 Ticks/Sec = 4.66 sec
+ * 2**32 Ticks / 3,600,000 Ticks/Sec = 1193 sec or 19.88 minutes
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetTimerDuration (
+ UINT32 StartTicks,
+ UINT32 EndTicks,
+ UINT32 *TimeElapsed)
+{
+ UINT32 DeltaTicks = 0;
+ UINT64_OVERLAY NormalizedTicks;
+ ACPI_STATUS Status;
+ ACPI_INTEGER OutQuotient;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiGetTimerDuration");
+
+
+ if (!TimeElapsed)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Compute Tick Delta:
+ * -------------------
+ * Handle (max one) timer rollovers on 24- versus 32-bit timers.
+ */
+ if (StartTicks < EndTicks)
+ {
+ DeltaTicks = EndTicks - StartTicks;
+ }
+ else if (StartTicks > EndTicks)
+ {
+ if (0 == AcpiGbl_FADT->TmrValExt)
+ {
+ /* 24-bit Timer */
+
+ DeltaTicks = (((0x00FFFFFF - StartTicks) + EndTicks) & 0x00FFFFFF);
+ }
+ else
+ {
+ /* 32-bit Timer */
+
+ DeltaTicks = (0xFFFFFFFF - StartTicks) + EndTicks;
+ }
+ }
+ else
+ {
+ *TimeElapsed = 0;
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Compute Duration:
+ * -----------------
+ *
+ * Requires a 64-bit divide:
+ *
+ * TimeElapsed = (DeltaTicks * 1000000) / PM_TIMER_FREQUENCY;
+ */
+ NormalizedTicks.Full = ((UINT64) DeltaTicks) * 1000000;
+
+ Status = AcpiUtShortDivide (&NormalizedTicks.Full, PM_TIMER_FREQUENCY,
+ &OutQuotient, NULL);
+
+ *TimeElapsed = (UINT32) OutQuotient;
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/nsaccess.c b/sys/contrib/dev/acpica/nsaccess.c
new file mode 100644
index 0000000..ca46558
--- /dev/null
+++ b/sys/contrib/dev/acpica/nsaccess.c
@@ -0,0 +1,724 @@
+/*******************************************************************************
+ *
+ * Module Name: nsaccess - Top-level functions for accessing ACPI namespace
+ * $Revision: 171 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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)
+ {
+ ACPI_STRING Val;
+
+ Status = AcpiOsPredefinedOverride(InitVal, &Val);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not override predefined %s\n",
+ InitVal->Name));
+ }
+
+ if (!Val)
+ {
+ Val = 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 (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 (Val, NULL, 10);
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ /*
+ * Build an object around the static string
+ */
+ ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val);
+ ObjDesc->String.Pointer = Val;
+ ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
+ break;
+
+
+ case ACPI_TYPE_MUTEX:
+
+ ObjDesc->Mutex.Node = NewNode;
+ ObjDesc->Mutex.SyncLevel =
+ (UINT16) ACPI_STRTOUL (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,
+ char *Pathname,
+ ACPI_OBJECT_TYPE Type,
+ ACPI_INTERPRETER_MODE InterpreterMode,
+ UINT32 Flags,
+ ACPI_WALK_STATE *WalkState,
+ ACPI_NAMESPACE_NODE **ReturnNode)
+{
+ ACPI_STATUS Status;
+ 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);
+ }
+ }
+
+ /* Save type TBD: may be no longer necessary */
+
+ 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 [%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,
+ "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_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 != 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: 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 (Type))
+ {
+ Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+ }
+
+ *ReturnNode = ThisNode;
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/nsalloc.c b/sys/contrib/dev/acpica/nsalloc.c
new file mode 100644
index 0000000..74220f3
--- /dev/null
+++ b/sys/contrib/dev/acpica/nsalloc.c
@@ -0,0 +1,762 @@
+/*******************************************************************************
+ *
+ * Module Name: nsalloc - Namespace allocation and deletion utilities
+ * $Revision: 79 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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. 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->Type = (UINT8) Type;
+
+ 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
new file mode 100644
index 0000000..085565d
--- /dev/null
+++ b/sys/contrib/dev/acpica/nsdump.c
@@ -0,0 +1,776 @@
+/******************************************************************************
+ *
+ * Module Name: nsdump - table dumping routines for debug
+ * $Revision: 151 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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
+ *
+ ******************************************************************************/
+
+void
+AcpiNsDumpPathname (
+ ACPI_HANDLE Handle,
+ char *Msg,
+ UINT32 Level,
+ UINT32 Component)
+{
+
+ ACPI_FUNCTION_TRACE ("NsDumpPathname");
+
+
+ /* Do this only if the requested debug level and component are enabled */
+
+ if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
+ {
+ return_VOID;
+ }
+
+ /* Convert handle to a full pathname and print it (with supplied message) */
+
+ AcpiNsPrintNodePathname (Handle, Msg);
+ AcpiOsPrintf ("\n");
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * 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 DbgLevel;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_NAME ("NsDumpOneObject");
+
+
+ /* 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 */
+
+ AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
+
+ /* Check the node type and name */
+
+ if (Type > ACPI_TYPE_LOCAL_MAX)
+ {
+ ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", Type));
+ }
+
+ if (!AcpiUtValidAcpiName (ThisNode->Name.Integer))
+ {
+ ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", ThisNode->Name.Integer));
+ }
+
+ /*
+ * Now we can print out the pertinent information
+ */
+ 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",
+ ObjDesc->Processor.ProcId,
+ ObjDesc->Processor.Length,
+ (char *) ObjDesc->Processor.Address);
+ break;
+
+
+ case ACPI_TYPE_DEVICE:
+
+ AcpiOsPrintf ("Notify object: %p", ObjDesc);
+ break;
+
+
+ case ACPI_TYPE_METHOD:
+
+ 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",
+ 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",
+ ObjDesc->Package.Count);
+ }
+ else
+ {
+ AcpiOsPrintf ("[Length not yet evaluated]\n");
+ }
+ break;
+
+
+ case ACPI_TYPE_BUFFER:
+
+ if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
+ {
+ 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");
+ }
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
+ AcpiUtPrintString (ObjDesc->String.Pointer, 32);
+ AcpiOsPrintf ("\n");
+ break;
+
+
+ case ACPI_TYPE_REGION:
+
+ 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 ACPI_TYPE_LOCAL_REFERENCE:
+
+ 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]",
+ ObjDesc->BufferField.BufferObj->Buffer.Node->Name.Ascii);
+ }
+ break;
+
+
+ case ACPI_TYPE_LOCAL_REGION_FIELD:
+
+ AcpiOsPrintf ("Rgn [%4.4s]",
+ ObjDesc->CommonField.RegionObj->Region.Node->Name.Ascii);
+ break;
+
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+
+ AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
+ ObjDesc->CommonField.RegionObj->Region.Node->Name.Ascii,
+ ObjDesc->BankField.BankObj->CommonField.Node->Name.Ascii);
+ break;
+
+
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+
+ AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
+ ObjDesc->IndexField.IndexObj->CommonField.Node->Name.Ascii,
+ ObjDesc->IndexField.DataObj->CommonField.Node->Name.Ascii);
+ break;
+
+
+ case ACPI_TYPE_LOCAL_ALIAS:
+
+ AcpiOsPrintf ("Target %4.4s (%p)\n", ((ACPI_NAMESPACE_NODE *) ObjDesc)->Name.Ascii, ObjDesc);
+ break;
+
+ default:
+
+ AcpiOsPrintf ("Object %p\n", ObjDesc);
+ break;
+ }
+
+ /* Common field handling */
+
+ switch (Type)
+ {
+ case ACPI_TYPE_BUFFER_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 ("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 = 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 > 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 ACPI_TYPE_LOCAL_REGION_FIELD:
+ ObjDesc = (void *) ObjDesc->Field.RegionObj;
+ break;
+
+ case ACPI_TYPE_LOCAL_BANK_FIELD:
+ ObjDesc = (void *) ObjDesc->BankField.RegionObj;
+ break;
+
+ case ACPI_TYPE_LOCAL_INDEX_FIELD:
+ ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
+ break;
+
+ default:
+ goto Cleanup;
+ }
+
+ 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/nsdumpdv.c b/sys/contrib/dev/acpica/nsdumpdv.c
new file mode 100644
index 0000000..d8058ac6
--- /dev/null
+++ b/sys/contrib/dev/acpica/nsdumpdv.c
@@ -0,0 +1,220 @@
+/******************************************************************************
+ *
+ * Module Name: nsdump - table dumping routines for debug
+ * $Revision: 5 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __NSDUMPDV_C__
+
+#include "acpi.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsdumpdv")
+
+
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDumpOneDevice
+ *
+ * PARAMETERS: Handle - Node to be dumped
+ * Level - Nesting level of the handle
+ * Context - Passed into WalkNamespace
+ *
+ * DESCRIPTION: Dump a single Node that represents a device
+ * This procedure is a UserFunction called by AcpiNsWalkNamespace.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsDumpOneDevice (
+ ACPI_HANDLE ObjHandle,
+ UINT32 Level,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_DEVICE_INFO Info;
+ ACPI_STATUS Status;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_NAME ("NsDumpOneDevice");
+
+
+ Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue);
+
+ Status = AcpiGetObjectInfo (ObjHandle, &Info);
+ if (ACPI_SUCCESS (Status))
+ {
+ for (i = 0; i < Level; i++)
+ {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " "));
+ }
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " HID: %s, ADR: %8.8X%8.8X, Status: %X\n",
+ Info.HardwareId,
+ ACPI_HIDWORD (Info.Address), ACPI_LODWORD (Info.Address),
+ Info.CurrentStatus));
+ }
+
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDumpRootDevices
+ *
+ * PARAMETERS: None
+ *
+ * DESCRIPTION: Dump all objects of type "device"
+ *
+ ******************************************************************************/
+
+void
+AcpiNsDumpRootDevices (void)
+{
+ ACPI_HANDLE SysBusHandle;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_NAME ("NsDumpRootDevices");
+
+
+ /* Only dump the table if tracing is enabled */
+
+ if (!(ACPI_LV_TABLES & AcpiDbgLevel))
+ {
+ return;
+ }
+
+ Status = AcpiGetHandle (0, ACPI_NS_SYSTEM_BUS, &SysBusHandle);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Display of all devices in the namespace:\n"));
+
+ Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle,
+ ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
+ AcpiNsDumpOneDevice, NULL, NULL);
+}
+
+#endif
+
+
diff --git a/sys/contrib/dev/acpica/nseval.c b/sys/contrib/dev/acpica/nseval.c
new file mode 100644
index 0000000..e325a7b
--- /dev/null
+++ b/sys/contrib/dev/acpica/nseval.c
@@ -0,0 +1,614 @@
+/*******************************************************************************
+ *
+ * Module Name: nseval - Object evaluation interfaces -- includes control
+ * method lookup and execution.
+ * $Revision: 121 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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,
+ char *Pathname,
+ ACPI_OPERAND_OBJECT **Params,
+ ACPI_OPERAND_OBJECT **ReturnObject)
+{
+ ACPI_NAMESPACE_NODE *PrefixNode;
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node = NULL;
+ 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 (
+ char *Pathname,
+ ACPI_OPERAND_OBJECT **Params,
+ ACPI_OPERAND_OBJECT **ReturnObject)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node = NULL;
+ 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, "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
new file mode 100644
index 0000000..87cae8d
--- /dev/null
+++ b/sys/contrib/dev/acpica/nsinit.c
@@ -0,0 +1,513 @@
+/******************************************************************************
+ *
+ * Module Name: nsinit - namespace initialization
+ * $Revision: 55 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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_INIT, "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_INIT,
+ "\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_INIT, "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_INIT,
+ "\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)));
+ }
+
+ /* Print a dot for each object unless we are going to print the entire pathname */
+
+ if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
+ {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
+ }
+
+ /*
+ * We ignore errors from above, and always return OK, since
+ * we don't want to abort the walk on any single error.
+ */
+ 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_ALL_EXCEPTIONS) && (!(AcpiDbgLevel & ACPI_LV_INFO)))
+ {
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
+ }
+
+ 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 (ACPI_TYPE_METHOD, Node, "_STA"));
+ 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 (ACPI_TYPE_METHOD, ObjHandle, "_INI"));
+ 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
+ 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/nsload.c b/sys/contrib/dev/acpica/nsload.c
new file mode 100644
index 0000000..eb8cd5d
--- /dev/null
+++ b/sys/contrib/dev/acpica/nsload.c
@@ -0,0 +1,555 @@
+/******************************************************************************
+ *
+ * Module Name: nsload - namespace loading/expanding/contracting procedures
+ * $Revision: 64 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __NSLOAD_C__
+
+#include "acpi.h"
+#include "acnamesp.h"
+#include "acdispat.h"
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsload")
+
+
+#ifndef ACPI_NO_METHOD_EXECUTION
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsLoadTable
+ *
+ * PARAMETERS: TableDesc - Descriptor for table to be loaded
+ * Node - Owning NS node
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Load one ACPI table into the namespace
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsLoadTable (
+ ACPI_TABLE_DESC *TableDesc,
+ ACPI_NAMESPACE_NODE *Node)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("NsLoadTable");
+
+
+ /* Check if table contains valid AML (must be DSDT, PSDT, SSDT, etc.) */
+
+ if (!(AcpiGbl_AcpiTableData[TableDesc->Type].Flags & ACPI_TABLE_EXECUTABLE))
+ {
+ /* Just ignore this table */
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Check validity of the AML start and length */
+
+ if (!TableDesc->AmlStart)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null AML pointer\n"));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n", TableDesc->AmlStart));
+
+ /* Ignore table if there is no AML contained within */
+
+ if (!TableDesc->AmlLength)
+ {
+ ACPI_REPORT_WARNING (("Zero-length AML block in table [%4.4s]\n", TableDesc->Pointer->Signature));
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Parse the table and load the namespace with all named
+ * objects found within. Control methods are NOT parsed
+ * at this time. In fact, the control methods cannot be
+ * parsed until the entire namespace is loaded, because
+ * if a control method makes a forward reference (call)
+ * to another control method, we can't continue parsing
+ * because we don't know how many arguments to parse next!
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Loading table into namespace ****\n"));
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiNsParseTable (TableDesc, Node->Child);
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Now we can parse the control methods. We always parse
+ * them here for a sanity check, and if configured for
+ * just-in-time parsing, we delete the control method
+ * parse trees.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "**** Begin Table Method Parsing and Object Initialization ****\n"));
+
+ Status = AcpiDsInitializeObjects (TableDesc, Node);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "**** Completed Table Method Parsing and Object Initialization ****\n"));
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsLoadTableByType
+ *
+ * PARAMETERS: TableType - Id of the table type to load
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Load an ACPI table or tables into the namespace. All tables
+ * of the given type are loaded. The mechanism allows this
+ * routine to be called repeatedly.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsLoadTableByType (
+ ACPI_TABLE_TYPE TableType)
+{
+ UINT32 i;
+ ACPI_STATUS Status;
+ ACPI_TABLE_DESC *TableDesc;
+
+
+ ACPI_FUNCTION_TRACE ("NsLoadTableByType");
+
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Table types supported are:
+ * DSDT (one), SSDT/PSDT (multiple)
+ */
+ switch (TableType)
+ {
+ case ACPI_TABLE_DSDT:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading DSDT\n"));
+
+ TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_DSDT];
+
+ /* If table already loaded into namespace, just return */
+
+ if (TableDesc->LoadedIntoNamespace)
+ {
+ goto UnlockAndExit;
+ }
+
+ TableDesc->TableId = TABLE_ID_DSDT;
+
+ /* Now load the single DSDT */
+
+ Status = AcpiNsLoadTable (TableDesc, AcpiGbl_RootNode);
+ if (ACPI_SUCCESS (Status))
+ {
+ TableDesc->LoadedIntoNamespace = TRUE;
+ }
+
+ break;
+
+
+ case ACPI_TABLE_SSDT:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d SSDTs\n",
+ AcpiGbl_AcpiTables[ACPI_TABLE_SSDT].Count));
+
+ /*
+ * Traverse list of SSDT tables
+ */
+ TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_SSDT];
+ for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_SSDT].Count; i++)
+ {
+ /*
+ * Only attempt to load table if it is not
+ * already loaded!
+ */
+ if (!TableDesc->LoadedIntoNamespace)
+ {
+ Status = AcpiNsLoadTable (TableDesc, AcpiGbl_RootNode);
+ if (ACPI_FAILURE (Status))
+ {
+ break;
+ }
+
+ TableDesc->LoadedIntoNamespace = TRUE;
+ }
+
+ TableDesc = TableDesc->Next;
+ }
+ break;
+
+
+ case ACPI_TABLE_PSDT:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d PSDTs\n",
+ AcpiGbl_AcpiTables[ACPI_TABLE_PSDT].Count));
+
+ /*
+ * Traverse list of PSDT tables
+ */
+ TableDesc = &AcpiGbl_AcpiTables[ACPI_TABLE_PSDT];
+
+ for (i = 0; i < AcpiGbl_AcpiTables[ACPI_TABLE_PSDT].Count; i++)
+ {
+ /* Only attempt to load table if it is not already loaded! */
+
+ if (!TableDesc->LoadedIntoNamespace)
+ {
+ Status = AcpiNsLoadTable (TableDesc, AcpiGbl_RootNode);
+ if (ACPI_FAILURE (Status))
+ {
+ break;
+ }
+
+ TableDesc->LoadedIntoNamespace = TRUE;
+ }
+
+ TableDesc = TableDesc->Next;
+ }
+
+ break;
+
+
+ default:
+ Status = AE_SUPPORT;
+ break;
+ }
+
+
+UnlockAndExit:
+ (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiLoadNamespace
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Load the name space from what ever is pointed to by DSDT.
+ * (DSDT points to either the BIOS or a buffer.)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsLoadNamespace (
+ void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiLoadNameSpace");
+
+
+ /* There must be at least a DSDT installed */
+
+ if (AcpiGbl_DSDT == NULL)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "DSDT is not in memory\n"));
+ return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+ }
+
+ /*
+ * Load the namespace. The DSDT is required,
+ * but the SSDT and PSDT tables are optional.
+ */
+ Status = AcpiNsLoadTableByType (ACPI_TABLE_DSDT);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Ignore exceptions from these */
+
+ (void) AcpiNsLoadTableByType (ACPI_TABLE_SSDT);
+ (void) AcpiNsLoadTableByType (ACPI_TABLE_PSDT);
+
+ ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+ "ACPI Namespace successfully loaded at root %p\n",
+ AcpiGbl_RootNode));
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsDeleteSubtree
+ *
+ * PARAMETERS: StartHandle - Handle in namespace where search begins
+ *
+ * RETURNS Status
+ *
+ * DESCRIPTION: Walks the namespace starting at the given handle and deletes
+ * all objects, entries, and scopes in the entire subtree.
+ *
+ * Namespace/Interpreter should be locked or the subsystem should
+ * be in shutdown before this routine is called.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsDeleteSubtree (
+ ACPI_HANDLE StartHandle)
+{
+ ACPI_STATUS Status;
+ ACPI_HANDLE ChildHandle;
+ ACPI_HANDLE ParentHandle;
+ ACPI_HANDLE NextChildHandle;
+ ACPI_HANDLE Dummy;
+ UINT32 Level;
+
+
+ ACPI_FUNCTION_TRACE ("NsDeleteSubtree");
+
+
+ ParentHandle = StartHandle;
+ ChildHandle = 0;
+ Level = 1;
+
+ /*
+ * Traverse the tree of objects until we bubble back up
+ * to where we started.
+ */
+ while (Level > 0)
+ {
+ /* Attempt to get the next object in this scope */
+
+ Status = AcpiGetNextObject (ACPI_TYPE_ANY, ParentHandle,
+ ChildHandle, &NextChildHandle);
+
+ ChildHandle = NextChildHandle;
+
+ /* Did we get a new object? */
+
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Check if this object has any children */
+
+ if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, ChildHandle,
+ 0, &Dummy)))
+ {
+ /*
+ * There is at least one child of this object,
+ * visit the object
+ */
+ Level++;
+ ParentHandle = ChildHandle;
+ ChildHandle = 0;
+ }
+ }
+ else
+ {
+ /*
+ * No more children in this object, go back up to
+ * the object's parent
+ */
+ Level--;
+
+ /* Delete all children now */
+
+ AcpiNsDeleteChildren (ChildHandle);
+
+ ChildHandle = ParentHandle;
+ Status = AcpiGetParent (ParentHandle, &ParentHandle);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+ }
+
+ /* Now delete the starting object, and we are done */
+
+ AcpiNsDeleteNode (ChildHandle);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsUnloadNameSpace
+ *
+ * PARAMETERS: Handle - Root of namespace subtree to be deleted
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Shrinks the namespace, typically in response to an undocking
+ * event. Deletes an entire subtree starting from (and
+ * including) the given handle.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsUnloadNamespace (
+ ACPI_HANDLE Handle)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("NsUnloadNameSpace");
+
+
+ /* Parameter validation */
+
+ if (!AcpiGbl_RootNode)
+ {
+ return_ACPI_STATUS (AE_NO_NAMESPACE);
+ }
+
+ if (!Handle)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* This function does the real work */
+
+ Status = AcpiNsDeleteSubtree (Handle);
+
+ return_ACPI_STATUS (Status);
+}
+
+#endif
+
diff --git a/sys/contrib/dev/acpica/nsnames.c b/sys/contrib/dev/acpica/nsnames.c
new file mode 100644
index 0000000..f69239f
--- /dev/null
+++ b/sys/contrib/dev/acpica/nsnames.c
@@ -0,0 +1,341 @@
+/*******************************************************************************
+ *
+ * Module Name: nsnames - Name manipulation and search
+ * $Revision: 82 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __NSNAMES_C__
+
+#include "acpi.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsnames")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsBuildExternalPath
+ *
+ * PARAMETERS: Node - NS node whose pathname is needed
+ * Size - Size of the pathname
+ * *NameBuffer - Where to return the pathname
+ *
+ * RETURN: Places the pathname into the NameBuffer, in external format
+ * (name segments separated by path separators)
+ *
+ * DESCRIPTION: Generate a full pathaname
+ *
+ ******************************************************************************/
+
+void
+AcpiNsBuildExternalPath (
+ ACPI_NAMESPACE_NODE *Node,
+ ACPI_SIZE Size,
+ char *NameBuffer)
+{
+ ACPI_SIZE Index;
+ ACPI_NAMESPACE_NODE *ParentNode;
+
+
+ ACPI_FUNCTION_NAME ("NsBuildExternalPath");
+
+
+ /* Special case for root */
+
+ Index = Size - 1;
+ if (Index < ACPI_NAME_SIZE)
+ {
+ NameBuffer[0] = AML_ROOT_PREFIX;
+ NameBuffer[1] = 0;
+ return;
+ }
+
+ /* Store terminator byte, then build name backwards */
+
+ ParentNode = Node;
+ NameBuffer[Index] = 0;
+
+ while ((Index > ACPI_NAME_SIZE) && (ParentNode != AcpiGbl_RootNode))
+ {
+ Index -= ACPI_NAME_SIZE;
+
+ /* Put the name into the buffer */
+
+ ACPI_MOVE_UNALIGNED32_TO_32 ((NameBuffer + Index), &ParentNode->Name);
+ ParentNode = AcpiNsGetParentNode (ParentNode);
+
+ /* Prefix name with the path separator */
+
+ Index--;
+ NameBuffer[Index] = ACPI_PATH_SEPARATOR;
+ }
+
+ /* Overwrite final separator with the root prefix character */
+
+ NameBuffer[Index] = AML_ROOT_PREFIX;
+
+ if (Index != 0)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Could not construct pathname; index=%X, size=%X, Path=%s\n",
+ (UINT32) Index, (UINT32) Size, &NameBuffer[Size]));
+ }
+
+ return;
+}
+
+
+#ifdef ACPI_DEBUG_OUTPUT
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetExternalPathname
+ *
+ * PARAMETERS: Node - NS node whose pathname is needed
+ *
+ * RETURN: Pointer to storage containing the fully qualified name of
+ * the node, In external format (name segments separated by path
+ * separators.)
+ *
+ * DESCRIPTION: Used for debug printing in AcpiNsSearchTable().
+ *
+ ******************************************************************************/
+
+char *
+AcpiNsGetExternalPathname (
+ ACPI_NAMESPACE_NODE *Node)
+{
+ char *NameBuffer;
+ ACPI_SIZE Size;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("NsGetExternalPathname", Node);
+
+
+ /* Calculate required buffer size based on depth below root */
+
+ Size = AcpiNsGetPathnameLength (Node);
+
+ /* Allocate a buffer to be returned to caller */
+
+ NameBuffer = ACPI_MEM_CALLOCATE (Size);
+ if (!NameBuffer)
+ {
+ ACPI_REPORT_ERROR (("NsGetTablePathname: allocation failure\n"));
+ return_PTR (NULL);
+ }
+
+ /* Build the path in the allocated buffer */
+
+ AcpiNsBuildExternalPath (Node, Size, NameBuffer);
+ return_PTR (NameBuffer);
+}
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetPathnameLength
+ *
+ * PARAMETERS: Node - Namespace node
+ *
+ * RETURN: Length of path, including prefix
+ *
+ * DESCRIPTION: Get the length of the pathname string for this node
+ *
+ ******************************************************************************/
+
+ACPI_SIZE
+AcpiNsGetPathnameLength (
+ ACPI_NAMESPACE_NODE *Node)
+{
+ ACPI_SIZE Size;
+ ACPI_NAMESPACE_NODE *NextNode;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * Compute length of pathname as 5 * number of name segments.
+ * Go back up the parent tree to the root
+ */
+ Size = 0;
+ NextNode = Node;
+
+ while (NextNode && (NextNode != AcpiGbl_RootNode))
+ {
+ Size += ACPI_PATH_SEGMENT_LENGTH;
+ NextNode = AcpiNsGetParentNode (NextNode);
+ }
+
+ return (Size + 1);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsHandleToPathname
+ *
+ * PARAMETERS: TargetHandle - Handle of named object whose name is
+ * to be found
+ * Buffer - Where the pathname is returned
+ *
+ * RETURN: Status, Buffer is filled with pathname if status is AE_OK
+ *
+ * DESCRIPTION: Build and return a full namespace pathname
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsHandleToPathname (
+ ACPI_HANDLE TargetHandle,
+ ACPI_BUFFER *Buffer)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_SIZE RequiredSize;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("NsHandleToPathname", TargetHandle);
+
+
+ Node = AcpiNsMapHandleToNode (TargetHandle);
+ if (!Node)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Determine size required for the caller buffer */
+
+ RequiredSize = AcpiNsGetPathnameLength (Node);
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (Buffer, RequiredSize);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Build the path in the caller buffer */
+
+ AcpiNsBuildExternalPath (Node, RequiredSize, Buffer->Pointer);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X] \n", (char *) Buffer->Pointer, (UINT32) RequiredSize));
+ return_ACPI_STATUS (AE_OK);
+}
+
+
diff --git a/sys/contrib/dev/acpica/nsobject.c b/sys/contrib/dev/acpica/nsobject.c
new file mode 100644
index 0000000..6a6250d
--- /dev/null
+++ b/sys/contrib/dev/acpica/nsobject.c
@@ -0,0 +1,562 @@
+/*******************************************************************************
+ *
+ * Module Name: nsobject - Utilities for objects attached to namespace
+ * table entries
+ * $Revision: 87 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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;
+
+ /* Use the given type */
+
+ 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 node whose object will be detached
+ *
+ * RETURN: None.
+ *
+ * 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) == 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) != 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) == 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.
+ *
+ * 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) == 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: Node - Namespace node
+ * Handler - Handler to be associated with the data
+ * Data - Data to be attached
+ *
+ * RETURN: Status
+ *
+ * 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) == 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 (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: Node - Namespace node
+ * Handler - Handler associated with the data
+ *
+ * RETURN: Status
+ *
+ * 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) == 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: Node - Namespace node
+ * Handler - Handler associated with the data
+ * Data - Where the data is returned
+ *
+ * RETURN: Status
+ *
+ * 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) == 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/nsparse.c b/sys/contrib/dev/acpica/nsparse.c
new file mode 100644
index 0000000..3314efe
--- /dev/null
+++ b/sys/contrib/dev/acpica/nsparse.c
@@ -0,0 +1,250 @@
+/******************************************************************************
+ *
+ * Module Name: nsparse - namespace interface to AML parser
+ * $Revision: 3 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __NSPARSE_C__
+
+#include "acpi.h"
+#include "acnamesp.h"
+#include "acparser.h"
+#include "acdispat.h"
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsparse")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: NsOneCompleteParse
+ *
+ * PARAMETERS: PassNumber - 1 or 2
+ * TableDesc - The table to be parsed.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform one complete parse of an ACPI/AML table.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsOneCompleteParse (
+ UINT32 PassNumber,
+ ACPI_TABLE_DESC *TableDesc)
+{
+ ACPI_PARSE_OBJECT *ParseRoot;
+ ACPI_STATUS Status;
+ ACPI_WALK_STATE *WalkState;
+
+
+ ACPI_FUNCTION_TRACE ("NsOneCompleteParse");
+
+
+ /* Create and init a Root Node */
+
+ ParseRoot = AcpiPsCreateScopeOp ();
+ if (!ParseRoot)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+
+ /* Create and initialize a new walk state */
+
+ WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT,
+ NULL, NULL, NULL);
+ if (!WalkState)
+ {
+ AcpiPsFreeOp (ParseRoot);
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, TableDesc->AmlStart,
+ TableDesc->AmlLength, NULL, NULL, PassNumber);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiDsDeleteWalkState (WalkState);
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Parse the AML */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", PassNumber));
+ Status = AcpiPsParseAml (WalkState);
+
+ AcpiPsDeleteParseTree (ParseRoot);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsParseTable
+ *
+ * PARAMETERS: TableDesc - An ACPI table descriptor for table to parse
+ * StartNode - Where to enter the table into the namespace
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsParseTable (
+ ACPI_TABLE_DESC *TableDesc,
+ ACPI_NAMESPACE_NODE *StartNode)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("NsParseTable");
+
+
+ /*
+ * AML Parse, pass 1
+ *
+ * In this pass, we load most of the namespace. Control methods
+ * are not parsed until later. A parse tree is not created. Instead,
+ * each Parser Op subtree is deleted when it is finished. This saves
+ * a great deal of memory, and allows a small cache of parse objects
+ * to service the entire parse. The second pass of the parse then
+ * performs another complete parse of the AML..
+ */
+ Status = AcpiNsOneCompleteParse (1, TableDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * AML Parse, pass 2
+ *
+ * In this pass, we resolve forward references and other things
+ * that could not be completed during the first pass.
+ * Another complete parse of the AML is performed, but the
+ * overhead of this is compensated for by the fact that the
+ * parse objects are all cached.
+ */
+ Status = AcpiNsOneCompleteParse (2, TableDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/nssearch.c b/sys/contrib/dev/acpica/nssearch.c
new file mode 100644
index 0000000..56763a5
--- /dev/null
+++ b/sys/contrib/dev/acpica/nssearch.c
@@ -0,0 +1,460 @@
+/*******************************************************************************
+ *
+ * Module Name: nssearch - Namespace search
+ * $Revision: 95 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 node where search will begin
+ * Type - Object type to match
+ * **ReturnNode - Where the matched Named obj is returned
+ *
+ * RETURN: Status
+ *
+ * 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)
+ {
+ char *ScopeName;
+
+ ScopeName = AcpiNsGetExternalPathname (Node);
+ if (ScopeName)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Searching %s [%p] For %4.4s (%s)\n",
+ ScopeName, Node, (char *) &TargetName, AcpiUtGetTypeName (Type)));
+
+ ACPI_MEM_FREE (ScopeName);
+ }
+ }
+#endif
+
+ /*
+ * 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.
+ */
+ 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 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 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
+ * 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 (i.e., we are at the root) or
+ * type is "local", we won't be searching the parent tree.
+ */
+ if (!ParentNode)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n",
+ (char *) &TargetName));
+ return_ACPI_STATUS (AE_NOT_FOUND);
+ }
+
+ 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 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 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 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_REPORT_ERROR (("NsSearchAndEnter: Bad character in ACPI Name: %X\n",
+ TargetName));
+ return_ACPI_STATUS (AE_BAD_CHARACTER);
+ }
+
+ /* 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 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
new file mode 100644
index 0000000..321cb30
--- /dev/null
+++ b/sys/contrib/dev/acpica/nsutils.c
@@ -0,0 +1,1197 @@
+/******************************************************************************
+ *
+ * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
+ * parents and siblings and Scope manipulation
+ * $Revision: 122 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 with full pathname
+ *
+ ******************************************************************************/
+
+void
+AcpiNsReportError (
+ 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);
+
+ /* 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: AcpiNsReportMethodError
+ *
+ * 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 with full pathname
+ *
+ ******************************************************************************/
+
+void
+AcpiNsReportMethodError (
+ char *ModuleName,
+ UINT32 LineNumber,
+ UINT32 ComponentId,
+ char *Message,
+ ACPI_NAMESPACE_NODE *PrefixNode,
+ char *Path,
+ ACPI_STATUS MethodStatus)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node = PrefixNode;
+
+
+ if (Path)
+ {
+ Status = AcpiNsGetNodeByPath (Path, PrefixNode, ACPI_NS_NO_UPSEARCH, &Node);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsPrintf ("ReportMethodError: Could not get node\n");
+ return;
+ }
+ }
+
+ AcpiOsPrintf ("%8s-%04d: *** Error: ", ModuleName, LineNumber);
+ AcpiNsPrintNodePathname (Node, Message);
+ AcpiOsPrintf (", %s\n", AcpiFormatException (MethodStatus));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsPrintNodePathname
+ *
+ * PARAMETERS: Node - Object
+ * Msg - Prefix message
+ *
+ * DESCRIPTION: Print an object's full namespace pathname
+ * Manages allocation/freeing of a pathname buffer
+ *
+ ******************************************************************************/
+
+void
+AcpiNsPrintNodePathname (
+ ACPI_NAMESPACE_NODE *Node,
+ char *Msg)
+{
+ ACPI_BUFFER Buffer;
+ ACPI_STATUS Status;
+
+
+ /* Convert handle to a full pathname and print it (with supplied message) */
+
+ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+
+ Status = AcpiNsHandleToPathname (Node, &Buffer);
+ if (ACPI_SUCCESS (Status))
+ {
+ AcpiOsPrintf ("%s [%s] (Node %p)", Msg, (char *) Buffer.Pointer, Node);
+ ACPI_MEM_FREE (Buffer.Pointer);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * 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 (
+ 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 (
+ 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)
+{
+ 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;
+ char *InternalName = Info->InternalName;
+ char *ExternalName = Info->NextExternalChar;
+ char *Result = NULL;
+ ACPI_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[(ACPI_NATIVE_UINT) (i+1)];
+ }
+ else
+ {
+ InternalName[i] = AML_MULTI_NAME_PREFIX_OP;
+ InternalName[(ACPI_NATIVE_UINT) (i+1)] = (char) NumSegments;
+ Result = &InternalName[(ACPI_NATIVE_UINT) (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 (
+ char *ExternalName,
+ char **ConvertedName)
+{
+ 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)
+{
+ ACPI_NATIVE_UINT NamesIndex = 0;
+ ACPI_NATIVE_UINT NumSegments = 0;
+ ACPI_NATIVE_UINT RequiredLength;
+ ACPI_NATIVE_UINT PrefixLength = 0;
+ ACPI_NATIVE_UINT i = 0;
+ ACPI_NATIVE_UINT j = 0;
+
+
+ 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:
+
+ /* <count> 4-byte names */
+
+ NamesIndex = PrefixLength + 2;
+ NumSegments = (UINT32) (UINT8) InternalName[(ACPI_NATIVE_UINT) (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_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 (
+ char *Pathname,
+ ACPI_NAMESPACE_NODE *StartNode,
+ UINT32 Flags,
+ ACPI_NAMESPACE_NODE **ReturnNode)
+{
+ ACPI_GENERIC_STATE ScopeInfo;
+ ACPI_STATUS Status;
+ char *InternalPath = NULL;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("NsGetNodeByPath", Pathname);
+
+
+ if (Pathname)
+ {
+ /* 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);
+
+ if (InternalPath)
+ {
+ 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);
+}
+
+
+/*******************************************************************************
+ *
+ * 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/nswalk.c b/sys/contrib/dev/acpica/nswalk.c
new file mode 100644
index 0000000..abe25a8
--- /dev/null
+++ b/sys/contrib/dev/acpica/nswalk.c
@@ -0,0 +1,382 @@
+/******************************************************************************
+ *
+ * Module Name: nswalk - Functions for walking the ACPI namespace
+ * $Revision: 34 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __NSWALK_C__
+
+#include "acpi.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nswalk")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsGetNextNode
+ *
+ * PARAMETERS: Type - Type of node to be searched for
+ * ParentNode - Parent node whose children we are
+ * getting
+ * ChildNode - Previous child that was found.
+ * The NEXT child will be returned
+ *
+ * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if
+ * none is found.
+ *
+ * DESCRIPTION: Return the next peer node within the namespace. If Handle
+ * is valid, Scope is ignored. Otherwise, the first node
+ * within Scope is returned.
+ *
+ ******************************************************************************/
+
+ACPI_NAMESPACE_NODE *
+AcpiNsGetNextNode (
+ ACPI_OBJECT_TYPE Type,
+ ACPI_NAMESPACE_NODE *ParentNode,
+ ACPI_NAMESPACE_NODE *ChildNode)
+{
+ ACPI_NAMESPACE_NODE *NextNode = NULL;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!ChildNode)
+ {
+ /* It's really the parent's _scope_ that we want */
+
+ if (ParentNode->Child)
+ {
+ NextNode = ParentNode->Child;
+ }
+ }
+
+ else
+ {
+ /* Start search at the NEXT node */
+
+ NextNode = AcpiNsGetNextValidNode (ChildNode);
+ }
+
+ /* If any type is OK, we are done */
+
+ if (Type == ACPI_TYPE_ANY)
+ {
+ /* NextNode is NULL if we are at the end-of-list */
+
+ return (NextNode);
+ }
+
+ /* Must search for the node -- but within this scope only */
+
+ while (NextNode)
+ {
+ /* If type matches, we are done */
+
+ if (NextNode->Type == Type)
+ {
+ return (NextNode);
+ }
+
+ /* Otherwise, move on to the next node */
+
+ NextNode = AcpiNsGetNextValidNode (NextNode);
+ }
+
+ /* Not found */
+
+ return (NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsWalkNamespace
+ *
+ * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for
+ * StartNode - Handle in namespace where search begins
+ * MaxDepth - Depth to which search is to reach
+ * UnlockBeforeCallback- Whether to unlock the NS before invoking
+ * the callback routine
+ * UserFunction - Called when an object of "Type" is found
+ * Context - Passed to user function
+ * ReturnValue - from the UserFunction if terminated early.
+ * Otherwise, returns NULL.
+ * RETURNS: Status
+ *
+ * DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
+ * starting (and ending) at the node specified by StartHandle.
+ * The UserFunction is called whenever a node 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
+AcpiNsWalkNamespace (
+ ACPI_OBJECT_TYPE Type,
+ ACPI_HANDLE StartNode,
+ UINT32 MaxDepth,
+ BOOLEAN UnlockBeforeCallback,
+ ACPI_WALK_CALLBACK UserFunction,
+ void *Context,
+ void **ReturnValue)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *ChildNode;
+ ACPI_NAMESPACE_NODE *ParentNode;
+ ACPI_OBJECT_TYPE ChildType;
+ UINT32 Level;
+
+
+ ACPI_FUNCTION_TRACE ("NsWalkNamespace");
+
+
+ /* Special case for the namespace Root Node */
+
+ if (StartNode == ACPI_ROOT_OBJECT)
+ {
+ StartNode = AcpiGbl_RootNode;
+ }
+
+ /* Null child means "get first node" */
+
+ ParentNode = StartNode;
+ ChildNode = 0;
+ ChildType = ACPI_TYPE_ANY;
+ Level = 1;
+
+ /*
+ * Traverse the tree of nodes until we bubble back up to where we
+ * started. When Level is zero, the loop is done because we have
+ * bubbled up to (and passed) the original parent handle (StartEntry)
+ */
+ while (Level > 0)
+ {
+ /* Get the next node in this scope. Null if not found */
+
+ Status = AE_OK;
+ ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode, ChildNode);
+ if (ChildNode)
+ {
+ /*
+ * Found node, Get the type if we are not
+ * searching for ANY
+ */
+ if (Type != ACPI_TYPE_ANY)
+ {
+ ChildType = ChildNode->Type;
+ }
+
+ if (ChildType == Type)
+ {
+ /*
+ * Found a matching node, invoke the user
+ * callback function
+ */
+ if (UnlockBeforeCallback)
+ {
+ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ Status = UserFunction (ChildNode, Level,
+ Context, ReturnValue);
+
+ if (UnlockBeforeCallback)
+ {
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ switch (Status)
+ {
+ case AE_OK:
+ case AE_CTRL_DEPTH:
+
+ /* Just keep going */
+ break;
+
+ case AE_CTRL_TERMINATE:
+
+ /* Exit now, with OK status */
+
+ return_ACPI_STATUS (AE_OK);
+
+ default:
+
+ /* All others are valid exceptions */
+
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Depth first search:
+ * Attempt to go down another level in the namespace
+ * if we are allowed to. Don't go any further if we
+ * have reached the caller specified maximum depth
+ * or if the user function has specified that the
+ * maximum depth has been reached.
+ */
+ if ((Level < MaxDepth) && (Status != AE_CTRL_DEPTH))
+ {
+ if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, 0))
+ {
+ /*
+ * There is at least one child of this
+ * node, visit the onde
+ */
+ Level++;
+ ParentNode = ChildNode;
+ ChildNode = 0;
+ }
+ }
+ }
+ else
+ {
+ /*
+ * No more children of this node (AcpiNsGetNextNode
+ * failed), go back upwards in the namespace tree to
+ * the node's parent.
+ */
+ Level--;
+ ChildNode = ParentNode;
+ ParentNode = AcpiNsGetParentNode (ParentNode);
+ }
+ }
+
+ /* Complete walk, not terminated by user function */
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
diff --git a/sys/contrib/dev/acpica/nsxfeval.c b/sys/contrib/dev/acpica/nsxfeval.c
new file mode 100644
index 0000000..3e732b0
--- /dev/null
+++ b/sys/contrib/dev/acpica/nsxfeval.c
@@ -0,0 +1,870 @@
+/*******************************************************************************
+ *
+ * Module Name: nsxfeval - Public interfaces to the ACPI subsystem
+ * ACPI Object evaluation interfaces
+ * $Revision: 7 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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_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 (
+ 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: ObjHandle - Namespace node
+ * Handler - Handler for this attachment
+ * Data - Pointer to data to be attached
+ *
+ * RETURN: Status
+ *
+ * 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: ObjHandle - Namespace node handle
+ * Handler - Handler used in call to AcpiAttachData
+ *
+ * RETURN: Status
+ *
+ * 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: ObjHandle - Namespace node
+ * Handler - Handler used in call to AttachData
+ * Data - Where the data is returned
+ *
+ * RETURN: Status
+ *
+ * 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/nsxfname.c b/sys/contrib/dev/acpica/nsxfname.c
new file mode 100644
index 0000000..ed33940
--- /dev/null
+++ b/sys/contrib/dev/acpica/nsxfname.c
@@ -0,0 +1,420 @@
+/******************************************************************************
+ *
+ * Module Name: nsxfname - Public interfaces to the ACPI subsystem
+ * ACPI Namespace oriented interfaces
+ * $Revision: 94 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __NSXFNAME_C__
+
+#include "acpi.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsxfname")
+
+
+/****************************************************************************
+ *
+ * FUNCTION: AcpiGetHandle
+ *
+ * PARAMETERS: Parent - Object to search under (search scope).
+ * PathName - Pointer to an asciiz string containing the
+ * name
+ * RetHandle - Where the return handle is placed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This routine will search for a caller specified name in the
+ * name space. The caller can restrict the search region by
+ * specifying a non NULL parent. The parent value is itself a
+ * namespace handle.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetHandle (
+ ACPI_HANDLE Parent,
+ ACPI_STRING Pathname,
+ ACPI_HANDLE *RetHandle)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node = NULL;
+ ACPI_NAMESPACE_NODE *PrefixNode = NULL;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Parameter Validation */
+
+ if (!RetHandle || !Pathname)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Convert a parent handle to a prefix node */
+
+ if (Parent)
+ {
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ PrefixNode = AcpiNsMapHandleToNode (Parent);
+ if (!PrefixNode)
+ {
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ }
+
+ /* Special case for root, since we can't search for it */
+
+ if (ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH) == 0)
+ {
+ *RetHandle = AcpiNsConvertEntryToHandle (AcpiGbl_RootNode);
+ return (AE_OK);
+ }
+
+ /*
+ * Find the Node and convert to a handle
+ */
+ Status = AcpiNsGetNodeByPath (Pathname, PrefixNode, ACPI_NS_NO_UPSEARCH, &Node);
+
+ *RetHandle = NULL;
+ if (ACPI_SUCCESS (Status))
+ {
+ *RetHandle = AcpiNsConvertEntryToHandle (Node);
+ }
+
+ return (Status);
+}
+
+
+/****************************************************************************
+ *
+ * FUNCTION: AcpiGetName
+ *
+ * PARAMETERS: Handle - Handle to be converted to a pathname
+ * NameType - Full pathname or single segment
+ * Buffer - Buffer for returned path
+ *
+ * RETURN: Pointer to a string containing the fully qualified Name.
+ *
+ * DESCRIPTION: This routine returns the fully qualified name associated with
+ * the Handle parameter. This and the AcpiPathnameToHandle are
+ * complementary functions.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetName (
+ ACPI_HANDLE Handle,
+ UINT32 NameType,
+ ACPI_BUFFER *Buffer)
+{
+ ACPI_STATUS Status;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ /* Parameter validation */
+
+ if (NameType > ACPI_NAME_TYPE_MAX)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtValidateBuffer (Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ if (NameType == ACPI_FULL_PATHNAME)
+ {
+ /* Get the full pathname (From the namespace root) */
+
+ Status = AcpiNsHandleToPathname (Handle, Buffer);
+ return (Status);
+ }
+
+ /*
+ * Wants the single segment ACPI name.
+ * Validate handle and convert to a namespace Node
+ */
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Node = AcpiNsMapHandleToNode (Handle);
+ if (!Node)
+ {
+ Status = AE_BAD_PARAMETER;
+ goto UnlockAndExit;
+ }
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH);
+ if (ACPI_FAILURE (Status))
+ {
+ goto UnlockAndExit;
+ }
+
+ /* Just copy the ACPI name from the Node and zero terminate it */
+
+ ACPI_STRNCPY (Buffer->Pointer, Node->Name.Ascii,
+ ACPI_NAME_SIZE);
+ ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0;
+ Status = AE_OK;
+
+
+UnlockAndExit:
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (Status);
+}
+
+
+/****************************************************************************
+ *
+ * FUNCTION: AcpiGetObjectInfo
+ *
+ * PARAMETERS: Handle - Object Handle
+ * Info - Where the info is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Returns information about an object as gleaned from the
+ * namespace node and possibly by running several standard
+ * control methods (Such as in the case of a device.)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetObjectInfo (
+ ACPI_HANDLE Handle,
+ ACPI_DEVICE_INFO *Info)
+{
+ ACPI_DEVICE_ID Hid;
+ ACPI_DEVICE_ID Uid;
+ ACPI_STATUS Status;
+ UINT32 DeviceStatus = 0;
+ ACPI_INTEGER Address = 0;
+ ACPI_NAMESPACE_NODE *Node;
+
+
+ /* Parameter validation */
+
+ if (!Handle || !Info)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Node = AcpiNsMapHandleToNode (Handle);
+ if (!Node)
+ {
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (AE_BAD_PARAMETER);
+ }
+
+ Info->Type = Node->Type;
+ Info->Name = Node->Name.Integer;
+
+ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /*
+ * If not a device, we are all done.
+ */
+ if (Info->Type != ACPI_TYPE_DEVICE)
+ {
+ return (AE_OK);
+ }
+
+
+ /*
+ * Get extra info for ACPI devices only. Run the
+ * _HID, _UID, _STA, and _ADR methods. Note: none
+ * of these methods are required, so they may or may
+ * not be present. The Info->Valid bits are used
+ * to indicate which methods ran successfully.
+ */
+ Info->Valid = 0;
+
+ /* Execute the _HID method and save the result */
+
+ Status = AcpiUtExecute_HID (Node, &Hid);
+ if (ACPI_SUCCESS (Status))
+ {
+ ACPI_STRNCPY (Info->HardwareId, Hid.Buffer, sizeof(Info->HardwareId));
+ Info->Valid |= ACPI_VALID_HID;
+ }
+
+ /* Execute the _UID method and save the result */
+
+ Status = AcpiUtExecute_UID (Node, &Uid);
+ if (ACPI_SUCCESS (Status))
+ {
+ ACPI_STRCPY (Info->UniqueId, Uid.Buffer);
+ Info->Valid |= ACPI_VALID_UID;
+ }
+
+ /*
+ * Execute the _STA method and save the result
+ * _STA is not always present
+ */
+ Status = AcpiUtExecute_STA (Node, &DeviceStatus);
+ if (ACPI_SUCCESS (Status))
+ {
+ Info->CurrentStatus = DeviceStatus;
+ Info->Valid |= ACPI_VALID_STA;
+ }
+
+ /*
+ * Execute the _ADR method and save result if successful
+ * _ADR is not always present
+ */
+ Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR,
+ Node, &Address);
+
+ if (ACPI_SUCCESS (Status))
+ {
+ Info->Address = Address;
+ Info->Valid |= ACPI_VALID_ADR;
+ }
+
+ return (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/nsxfobj.c b/sys/contrib/dev/acpica/nsxfobj.c
new file mode 100644
index 0000000..49310ca
--- /dev/null
+++ b/sys/contrib/dev/acpica/nsxfobj.c
@@ -0,0 +1,351 @@
+/*******************************************************************************
+ *
+ * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
+ * ACPI Object oriented interfaces
+ * $Revision: 116 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 exception 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_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
new file mode 100644
index 0000000..3db9b7a
--- /dev/null
+++ b/sys/contrib/dev/acpica/psargs.c
@@ -0,0 +1,846 @@
+/******************************************************************************
+ *
+ * Module Name: psargs - Parse AML opcode arguments
+ * $Revision: 69 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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;
+ ACPI_NATIVE_UINT Length;
+
+
+ ACPI_FUNCTION_TRACE ("PsGetNextPackageEnd");
+
+
+ /* Function below changes ParserState->Aml */
+
+ Length = (ACPI_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.)
+ *
+ ******************************************************************************/
+
+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 += 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) * ACPI_NAME_SIZE);
+ break;
+
+ default:
+
+ /* Single name segment */
+
+ End += ACPI_NAME_SIZE;
+ break;
+ }
+
+ ParserState->Aml = (UINT8*) End;
+ return_PTR ((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 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,
+ BOOLEAN MethodCall)
+{
+ 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);
+ 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",
+ 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",
+ Node));
+ return_ACPI_STATUS (AE_AML_INTERNAL);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Control Method - %p Args %X\n",
+ Node, 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);
+ 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 += 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,
+ 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->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 (WalkState, ParserState, Arg, 0);
+ }
+ else
+ {
+ /* single complex argument, nothing returned */
+
+ WalkState->ArgCount = 1;
+ }
+ break;
+
+
+ case ARGP_DATAOBJ:
+ case ARGP_TERMARG:
+
+ /* single complex argument, nothing returned */
+
+ 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 */
+
+ 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/psfind.c b/sys/contrib/dev/acpica/psfind.c
new file mode 100644
index 0000000..6862843
--- /dev/null
+++ b/sys/contrib/dev/acpica/psfind.c
@@ -0,0 +1,485 @@
+
+/******************************************************************************
+ *
+ * Module Name: psfind - Parse tree search routine
+ * $Revision: 42 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 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 __PSFIND_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "amlcode.h"
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("psfind")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetParent
+ *
+ * PARAMETERS: Op - Get the parent of this Op
+ *
+ * RETURN: The Parent op.
+ *
+ * DESCRIPTION: Get op's parent
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT*
+AcpiPsGetParent (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Parent = Op;
+
+
+ /* Traverse the tree upward (to root if necessary) */
+
+ while (Parent)
+ {
+ switch (Parent->Common.AmlOpcode)
+ {
+ case AML_SCOPE_OP:
+ case AML_PACKAGE_OP:
+ case AML_METHOD_OP:
+ case AML_DEVICE_OP:
+ case AML_POWER_RES_OP:
+ case AML_THERMAL_ZONE_OP:
+
+ return (Parent->Common.Parent);
+
+ default:
+ break;
+ }
+
+ Parent = Parent->Common.Parent;
+ }
+
+ return (Parent);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsFindName
+ *
+ * PARAMETERS: Scope - Scope to search
+ * Name - ACPI name to search for
+ * Opcode - Opcode to search for
+ *
+ * RETURN: Op containing the name
+ *
+ * DESCRIPTION: Find name segment from a list of acpi_ops. Searches a single
+ * scope, no more.
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+AcpiPsFindName (
+ ACPI_PARSE_OBJECT *Scope,
+ UINT32 Name,
+ UINT32 Opcode)
+{
+ ACPI_PARSE_OBJECT *Op;
+ ACPI_PARSE_OBJECT *Field;
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ /* search scope level for matching name segment */
+
+ Op = AcpiPsGetChild (Scope);
+
+ while (Op)
+ {
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+
+ /* Check AML_CREATE first (since some opcodes have AML_FIELD set also )*/
+
+ if (OpInfo->Flags & AML_CREATE)
+ {
+ if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
+ {
+ Field = AcpiPsGetArg (Op, 3);
+ }
+ else
+ {
+ /* CreateXXXField, check name */
+
+ Field = AcpiPsGetArg (Op, 2);
+ }
+
+ if ((Field) &&
+ (Field->Common.Value.String) &&
+ (!ACPI_STRNCMP (Field->Common.Value.String, (char *) &Name, ACPI_NAME_SIZE)))
+ {
+ return (Op);
+ }
+ }
+ else if (OpInfo->Flags & AML_FIELD)
+ {
+ /* Field, search named fields */
+
+ Field = AcpiPsGetChild (Op);
+ while (Field)
+ {
+ OpInfo = AcpiPsGetOpcodeInfo (Field->Common.AmlOpcode);
+
+ if ((OpInfo->Flags & AML_NAMED) &&
+ AcpiPsGetName (Field) == Name &&
+ (!Opcode || Field->Common.AmlOpcode == Opcode))
+ {
+ return (Field);
+ }
+
+ Field = Field->Common.Next;
+ }
+ }
+ else if ((OpInfo->Flags & AML_NAMED) &&
+ (AcpiPsGetName (Op) == Name) &&
+ (!Opcode || Op->Common.AmlOpcode == Opcode || Opcode == AML_SCOPE_OP))
+ {
+ break;
+ }
+
+ Op = Op->Common.Next;
+ }
+
+ return (Op);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsFind
+ *
+ * PARAMETERS: Scope - Where to begin the search
+ * Path - ACPI Path to the named object
+ * Opcode - Opcode associated with the object
+ * Create - if TRUE, create the object if not found.
+ *
+ * RETURN: Op if found, NULL otherwise.
+ *
+ * DESCRIPTION: Find object within scope
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT*
+AcpiPsFind (
+ ACPI_PARSE_OBJECT *Scope,
+ NATIVE_CHAR *Path,
+ UINT16 Opcode,
+ UINT32 Create)
+{
+ UINT32 SegCount;
+ UINT32 Name;
+ UINT32 NameOp;
+ ACPI_PARSE_OBJECT *Op = NULL;
+ BOOLEAN Unprefixed = TRUE;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("PsFind", Scope);
+
+
+ if (!Scope || !Path)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Null path (%p) or scope (%p)!\n",
+ Path, Scope));
+ return_PTR (NULL);
+ }
+
+ AcpiGbl_PsFindCount++;
+
+#if 0
+ if ((Create) && (Opcode == AML_SCOPE_OP))
+ {
+ Op = AcpiPsAllocOp (AML_SCOPE_OP);
+ if (Op)
+ {
+ AcpiPsSetName (Op, 'XXXX');
+ AcpiPsAppendArg (Scope, Op);
+ }
+/* return_PTR (Op);*/
+ }
+#endif
+
+ /* Handle all prefixes in the name path */
+
+ while (AcpiPsIsPrefixChar (ACPI_GET8 (Path)))
+ {
+ switch (ACPI_GET8 (Path))
+ {
+ case '\\':
+
+ /* Could just use a global for "root scope" here */
+
+ while (Scope->Common.Parent)
+ {
+ Scope = Scope->Common.Parent;
+ }
+ break;
+
+
+ case '^':
+
+ /* Go up to the next valid scoping Op (method, scope, etc.) */
+
+ if (AcpiPsGetParent (Scope))
+ {
+ Scope = AcpiPsGetParent (Scope);
+ }
+ break;
+
+ default:
+ /* Should not get here */
+ break;
+ }
+
+ Unprefixed = FALSE;
+ Path++;
+ }
+
+
+ /* get name segment count */
+
+ switch (ACPI_GET8 (Path))
+ {
+ case 0:
+ SegCount = 0;
+
+ /* Null name case */
+
+ if (Unprefixed)
+ {
+ Op = NULL;
+ }
+ else
+ {
+ Op = Scope;
+ }
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Null path, returning current root scope Op=%p\n", Op));
+ return_PTR (Op);
+
+ case AML_DUAL_NAME_PREFIX:
+ SegCount = 2;
+ Path++;
+ break;
+
+ case AML_MULTI_NAME_PREFIX_OP:
+ SegCount = ACPI_GET8 (Path + 1);
+ Path += 2;
+ break;
+
+ default:
+ SegCount = 1;
+ break;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Search scope %p Segs=%d Opcode=%4.4hX Create=%d\n",
+ Scope, SegCount, Opcode, Create));
+
+
+ /* match each name segment */
+
+ while (Scope && SegCount)
+ {
+ ACPI_MOVE_UNALIGNED32_TO_32 (&Name, Path);
+ Path += 4;
+ SegCount --;
+
+ if (SegCount)
+ {
+ NameOp = 0;
+ }
+ else
+ {
+ NameOp = Opcode;
+ }
+
+ Op = AcpiPsFindName (Scope, Name, NameOp);
+ if (Op)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "[%4.4s] Found! Op=%p Opcode=%4.4hX\n",
+ (char *) &Name, Op, Op->Common.AmlOpcode));
+ }
+
+ if (!Op)
+ {
+ if (Create)
+ {
+ /* Create a new Scope level */
+
+ if (SegCount)
+ {
+ Op = AcpiPsAllocOp (AML_SCOPE_OP);
+ }
+ else
+ {
+ Op = AcpiPsAllocOp (Opcode);
+ }
+
+ if (Op)
+ {
+ AcpiPsSetName (Op, Name);
+ AcpiPsAppendArg (Scope, Op);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "[%4.4s] Not found, created Op=%p Opcode=%4.4hX\n",
+ (char *) &Name, Op, Opcode));
+ }
+ }
+
+ else if (Unprefixed)
+ {
+ /* Search higher scopes for unprefixed name */
+
+ while (!Op && Scope->Common.Parent)
+ {
+ Scope = Scope->Common.Parent;
+ Op = AcpiPsFindName (Scope, Name, Opcode);
+ if (Op)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "[%4.4s] Found in parent tree! Op=%p Opcode=%4.4hX\n",
+ (char *) &Name, Op, Op->Common.AmlOpcode));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "[%4.4s] Not found in parent=%p\n",
+ (char *) &Name, Scope));
+ }
+ }
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Segment [%4.4s] Not Found in scope %p!\n",
+ (char *) &Name, Scope));
+ }
+ }
+
+ Unprefixed = FALSE;
+ Scope = Op;
+ }
+
+ return_PTR (Op);
+}
+
+
diff --git a/sys/contrib/dev/acpica/psopcode.c b/sys/contrib/dev/acpica/psopcode.c
new file mode 100644
index 0000000..4a94a3a
--- /dev/null
+++ b/sys/contrib/dev/acpica/psopcode.c
@@ -0,0 +1,846 @@
+/******************************************************************************
+ *
+ * Module Name: psopcode - Parser/Interpreter opcode information table
+ * $Revision: 77 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 <opcode, type, name, operands>
+ * 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_OR_FIELD,ARGI_TARGETREF)
+#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE)
+#define ARGI_LOCAL0 ARG_NONE
+#define ARGI_LOCAL1 ARG_NONE
+#define ARGI_LOCAL2 ARG_NONE
+#define ARGI_LOCAL3 ARG_NONE
+#define ARGI_LOCAL4 ARG_NONE
+#define ARGI_LOCAL5 ARG_NONE
+#define ARGI_LOCAL6 ARG_NONE
+#define ARGI_LOCAL7 ARG_NONE
+#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
+#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER)
+#define ARGI_METHOD_OP ARGI_INVALID_OPCODE
+#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE
+#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE
+#define ARGI_NAME_OP ARGI_INVALID_OPCODE
+#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE
+#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE
+#define ARGI_NOOP_OP ARG_NONE
+#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER)
+#define ARGI_ONE_OP ARG_NONE
+#define ARGI_ONES_OP ARG_NONE
+#define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER)
+#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE
+#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE
+#define ARGI_QWORD_OP ARGI_INVALID_OPCODE
+#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF)
+#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER)
+#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX)
+#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE
+#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT)
+#define ARGI_RETURN_OP ARGI_INVALID_OPCODE
+#define ARGI_REVISION_OP ARG_NONE
+#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE
+#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF)
+#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT)
+#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_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, 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, 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, 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, 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
+ *
+ ******************************************************************************/
+
+char *
+AcpiPsGetOpcodeName (
+ UINT16 Opcode)
+{
+#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT)
+
+ 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/psparse.c b/sys/contrib/dev/acpica/psparse.c
new file mode 100644
index 0000000..ce6f530
--- /dev/null
+++ b/sys/contrib/dev/acpica/psparse.c
@@ -0,0 +1,1396 @@
+/******************************************************************************
+ *
+ * Module Name: psparse - Parser top level AML parse routines
+ * $Revision: 139 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
+ * All rights reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+
+/*
+ * Parse the AML and build an operation tree as most interpreters,
+ * like Perl, do. Parsing is done by hand rather than with a YACC
+ * generated parser to tightly constrain stack and dynamic memory
+ * usage. At the same time, parsing is kept flexible and the code
+ * fairly compact by parsing based on a list of AML opcode
+ * templates in AmlOpInfo[]
+ */
+
+#include "acpi.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "acinterp.h"
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("psparse")
+
+
+static UINT32 AcpiGbl_Depth = 0;
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetOpcodeSize
+ *
+ * PARAMETERS: Opcode - An AML opcode
+ *
+ * RETURN: Size of the opcode, in bytes (1 or 2)
+ *
+ * DESCRIPTION: Get the size of the current opcode.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiPsGetOpcodeSize (
+ UINT32 Opcode)
+{
+
+ /* Extended (2-byte) opcode if > 255 */
+
+ if (Opcode > 0x00FF)
+ {
+ return (2);
+ }
+
+ /* Otherwise, just a single byte opcode */
+
+ return (1);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsPeekOpcode
+ *
+ * PARAMETERS: ParserState - A parser state object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Get next AML opcode (without incrementing AML pointer)
+ *
+ ******************************************************************************/
+
+UINT16
+AcpiPsPeekOpcode (
+ ACPI_PARSE_STATE *ParserState)
+{
+ UINT8 *Aml;
+ UINT16 Opcode;
+
+
+ Aml = ParserState->Aml;
+ Opcode = (UINT16) ACPI_GET8 (Aml);
+
+
+ if (Opcode == AML_EXTOP)
+ {
+ /* Extended opcode */
+
+ Aml++;
+ Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml));
+ }
+
+ return (Opcode);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsCompleteThisOp
+ *
+ * PARAMETERS: WalkState - Current State
+ * Op - Op to complete
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Perform any cleanup at the completion of an Op.
+ *
+ ******************************************************************************/
+
+void
+AcpiPsCompleteThisOp (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Prev;
+ ACPI_PARSE_OBJECT *Next;
+ const ACPI_OPCODE_INFO *ParentInfo;
+ ACPI_PARSE_OBJECT *ReplacementOp = NULL;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("PsCompleteThisOp", Op);
+
+
+ /* Check for null Op, can happen if AML code is corrupt */
+
+ if (!Op)
+ {
+ return_VOID;
+ }
+
+ /* Delete this op and the subtree below it if asked to */
+
+ if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) == ACPI_PARSE_DELETE_TREE) &&
+ (WalkState->OpInfo->Class != AML_CLASS_ARGUMENT))
+ {
+ /* Make sure that we only delete this subtree */
+
+ if (Op->Common.Parent)
+ {
+ /*
+ * Check if we need to replace the operator and its subtree
+ * with a return value op (placeholder op)
+ */
+ ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
+
+ switch (ParentInfo->Class)
+ {
+ case AML_CLASS_CONTROL:
+ break;
+
+ case AML_CLASS_CREATE:
+
+ /*
+ * These opcodes contain TermArg operands. The current
+ * op must be replaced by a placeholder return op
+ */
+ ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
+ if (!ReplacementOp)
+ {
+ return_VOID;
+ }
+ break;
+
+ case AML_CLASS_NAMED_OBJECT:
+
+ /*
+ * These opcodes contain TermArg operands. The current
+ * op must be replaced by a placeholder return op
+ */
+ if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) ||
+ (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) ||
+ (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) ||
+ (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
+ (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
+ {
+ ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
+ if (!ReplacementOp)
+ {
+ return_VOID;
+ }
+ }
+
+ if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
+ (WalkState->DescendingCallback != AcpiDsExecBeginOp))
+
+ {
+ if ((Op->Common.AmlOpcode == AML_BUFFER_OP) ||
+ (Op->Common.AmlOpcode == AML_PACKAGE_OP) ||
+ (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
+ {
+ ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode);
+ if (!ReplacementOp)
+ {
+ return_VOID;
+ }
+
+ ReplacementOp->Named.Data = Op->Named.Data;
+ ReplacementOp->Named.Length = Op->Named.Length;
+ }
+ }
+ break;
+
+ default:
+ ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
+ if (!ReplacementOp)
+ {
+ return_VOID;
+ }
+ }
+
+ /* We must unlink this op from the parent tree */
+
+ Prev = Op->Common.Parent->Common.Value.Arg;
+ if (Prev == Op)
+ {
+ /* This op is the first in the list */
+
+ if (ReplacementOp)
+ {
+ ReplacementOp->Common.Parent = Op->Common.Parent;
+ ReplacementOp->Common.Value.Arg = NULL;
+ ReplacementOp->Common.Node = Op->Common.Node;
+ Op->Common.Parent->Common.Value.Arg = ReplacementOp;
+ ReplacementOp->Common.Next = Op->Common.Next;
+ }
+ else
+ {
+ Op->Common.Parent->Common.Value.Arg = Op->Common.Next;
+ }
+ }
+
+ /* Search the parent list */
+
+ else while (Prev)
+ {
+ /* Traverse all siblings in the parent's argument list */
+
+ Next = Prev->Common.Next;
+ if (Next == Op)
+ {
+ if (ReplacementOp)
+ {
+ ReplacementOp->Common.Parent = Op->Common.Parent;
+ ReplacementOp->Common.Value.Arg = NULL;
+ ReplacementOp->Common.Node = Op->Common.Node;
+ Prev->Common.Next = ReplacementOp;
+ ReplacementOp->Common.Next = Op->Common.Next;
+ Next = NULL;
+ }
+ else
+ {
+ Prev->Common.Next = Op->Common.Next;
+ Next = NULL;
+ }
+ }
+
+ Prev = Next;
+ }
+ }
+
+ /* Now we can actually delete the subtree rooted at op */
+
+ AcpiPsDeleteParseTree (Op);
+
+ return_VOID;
+ }
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsNextParseState
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Update the parser state based upon the return exception from
+ * the parser callback.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsNextParseState (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_STATUS CallbackStatus)
+{
+ ACPI_PARSE_STATE *ParserState = &WalkState->ParserState;
+ ACPI_STATUS Status = AE_CTRL_PENDING;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("PsNextParseState", Op);
+
+
+ switch (CallbackStatus)
+ {
+ case AE_CTRL_TERMINATE:
+
+ /*
+ * A control method was terminated via a RETURN statement.
+ * The walk of this method is complete.
+ */
+ ParserState->Aml = ParserState->AmlEnd;
+ Status = AE_CTRL_TERMINATE;
+ break;
+
+
+ case AE_CTRL_BREAK:
+
+ ParserState->Aml = WalkState->AmlLastWhile;
+ WalkState->ControlState->Common.Value = FALSE;
+ Status = AE_CTRL_BREAK;
+ break;
+
+ case AE_CTRL_CONTINUE:
+
+
+ ParserState->Aml = WalkState->AmlLastWhile;
+ Status = AE_CTRL_CONTINUE;
+ break;
+
+ case AE_CTRL_PENDING:
+
+ ParserState->Aml = WalkState->AmlLastWhile;
+ break;
+
+#if 0
+ case AE_CTRL_SKIP:
+
+ ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
+ Status = AE_OK;
+ break;
+#endif
+
+ case AE_CTRL_TRUE:
+
+ /*
+ * Predicate of an IF was true, and we are at the matching ELSE.
+ * Just close out this package
+ */
+ ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState);
+ break;
+
+
+ case AE_CTRL_FALSE:
+
+ /*
+ * Either an IF/WHILE Predicate was false or we encountered a BREAK
+ * opcode. In both cases, we do not execute the rest of the
+ * package; We simply close out the parent (finishing the walk of
+ * this branch of the tree) and continue execution at the parent
+ * level.
+ */
+ ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
+
+ /* In the case of a BREAK, just force a predicate (if any) to FALSE */
+
+ WalkState->ControlState->Common.Value = FALSE;
+ Status = AE_CTRL_END;
+ break;
+
+
+ case AE_CTRL_TRANSFER:
+
+ /*
+ * A method call (invocation) -- transfer control
+ */
+ Status = AE_CTRL_TRANSFER;
+ WalkState->PrevOp = Op;
+ WalkState->MethodCallOp = Op;
+ WalkState->MethodCallNode = (Op->Common.Value.Arg)->Common.Node;
+
+ /* Will return value (if any) be used by the caller? */
+
+ WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState);
+ break;
+
+
+ default:
+ Status = CallbackStatus;
+ if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL)
+ {
+ Status = AE_OK;
+ }
+ break;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsParseLoop
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
+ * a tree of ops.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsParseLoop (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_PARSE_OBJECT *Op = NULL; /* current op */
+ ACPI_PARSE_OBJECT *Arg = NULL;
+ ACPI_PARSE_OBJECT PreOp;
+ ACPI_PARSE_STATE *ParserState;
+ UINT8 *AmlOpStart = NULL;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("PsParseLoop", WalkState);
+
+ if (WalkState->DescendingCallback == NULL)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+
+ ParserState = &WalkState->ParserState;
+ WalkState->ArgTypes = 0;
+
+#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
+ if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART)
+ {
+ /* We are restarting a preempted control method */
+
+ if (AcpiPsHasCompletedScope (ParserState))
+ {
+ /*
+ * We must check if a predicate to an IF or WHILE statement
+ * was just completed
+ */
+ if ((ParserState->Scope->ParseScope.Op) &&
+ ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) ||
+ (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) &&
+ (WalkState->ControlState) &&
+ (WalkState->ControlState->Common.State ==
+ ACPI_CONTROL_PREDICATE_EXECUTING))
+ {
+ /*
+ * A predicate was just completed, get the value of the
+ * predicate and branch based on that value
+ */
+ WalkState->Op = NULL;
+ Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE));
+ if (ACPI_FAILURE (Status) &&
+ ((Status & AE_CODE_MASK) != AE_CODE_CONTROL))
+ {
+ if (Status == AE_AML_NO_RETURN_VALUE)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Invoked method did not return a value, %s\n",
+ AcpiFormatException (Status)));
+
+ }
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "GetPredicate Failed, %s\n",
+ AcpiFormatException (Status)));
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiPsNextParseState (WalkState, Op, Status);
+ }
+
+ AcpiPsPopScope (ParserState, &Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op));
+ }
+ else if (WalkState->PrevOp)
+ {
+ /* We were in the middle of an op */
+
+ Op = WalkState->PrevOp;
+ WalkState->ArgTypes = WalkState->PrevArgTypes;
+ }
+ }
+#endif
+
+ /*
+ * Iterative parsing loop, while there is more aml to process:
+ */
+ while ((ParserState->Aml < ParserState->AmlEnd) || (Op))
+ {
+ AmlOpStart = ParserState->Aml;
+ if (!Op)
+ {
+ /* Get the next opcode from the AML stream */
+
+ WalkState->AmlOffset = ACPI_PTR_DIFF (ParserState->Aml,
+ ParserState->AmlStart);
+ WalkState->Opcode = AcpiPsPeekOpcode (ParserState);
+
+ /*
+ * First cut to determine what we have found:
+ * 1) A valid AML opcode
+ * 2) A name string
+ * 3) An unknown/invalid opcode
+ */
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
+ switch (WalkState->OpInfo->Class)
+ {
+ case AML_CLASS_ASCII:
+ case AML_CLASS_PREFIX:
+ /*
+ * Starts with a valid prefix or ASCII char, this is a name
+ * string. Convert the bare name string to a namepath.
+ */
+ WalkState->Opcode = AML_INT_NAMEPATH_OP;
+ WalkState->ArgTypes = ARGP_NAMESTRING;
+ break;
+
+ case AML_CLASS_UNKNOWN:
+
+ /* The opcode is unrecognized. Just skip unknown opcodes */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Found unknown opcode %X at AML address %p offset %X, ignoring\n",
+ WalkState->Opcode, ParserState->Aml, WalkState->AmlOffset));
+
+ ACPI_DUMP_BUFFER (ParserState->Aml, 128);
+
+ /* Assume one-byte bad opcode */
+
+ ParserState->Aml++;
+ continue;
+
+ default:
+
+ /* Found opcode info, this is a normal opcode */
+
+ ParserState->Aml += AcpiPsGetOpcodeSize (WalkState->Opcode);
+ WalkState->ArgTypes = WalkState->OpInfo->ParseArgs;
+ break;
+ }
+
+ /* Create Op structure and append to parent's argument list */
+
+ if (WalkState->OpInfo->Flags & AML_NAMED)
+ {
+ PreOp.Common.Value.Arg = NULL;
+ PreOp.Common.AmlOpcode = WalkState->Opcode;
+
+ /*
+ * Get and append arguments until we find the node that contains
+ * the name (the type ARGP_NAME).
+ */
+ while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) &&
+ (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME))
+ {
+ Status = AcpiPsGetNextArg (WalkState, ParserState,
+ GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
+ if (ACPI_FAILURE (Status))
+ {
+ goto CloseThisOp;
+ }
+
+ AcpiPsAppendArg (&PreOp, Arg);
+ INCREMENT_ARG_LIST (WalkState->ArgTypes);
+ }
+
+ /* Make sure that we found a NAME and didn't run out of arguments */
+
+ if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes))
+ {
+ return_ACPI_STATUS (AE_AML_NO_OPERAND);
+ }
+
+ /* We know that this arg is a name, move to next arg */
+
+ INCREMENT_ARG_LIST (WalkState->ArgTypes);
+
+ /*
+ * Find the object. This will either insert the object into
+ * the namespace or simply look it up
+ */
+ WalkState->Op = NULL;
+
+ Status = WalkState->DescendingCallback (WalkState, &Op);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "During name lookup/catalog, %s\n",
+ AcpiFormatException (Status)));
+ goto CloseThisOp;
+ }
+
+ if (Op == NULL)
+ {
+ continue;
+ }
+
+ Status = AcpiPsNextParseState (WalkState, Op, Status);
+ if (Status == AE_CTRL_PENDING)
+ {
+ Status = AE_OK;
+ goto CloseThisOp;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ goto CloseThisOp;
+ }
+
+ AcpiPsAppendArg (Op, PreOp.Common.Value.Arg);
+ AcpiGbl_Depth++;
+
+ if (Op->Common.AmlOpcode == AML_REGION_OP)
+ {
+ /*
+ * Defer final parsing of an OperationRegion body,
+ * because we don't have enough info in the first pass
+ * to parse it correctly (i.e., there may be method
+ * calls within the TermArg elements of the body.)
+ *
+ * However, we must continue parsing because
+ * the opregion is not a standalone package --
+ * we don't know where the end is at this point.
+ *
+ * (Length is unknown until parse of the body complete)
+ */
+ Op->Named.Data = AmlOpStart;
+ Op->Named.Length = 0;
+ }
+ }
+ else
+ {
+ /* Not a named opcode, just allocate Op and append to parent */
+
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode);
+ Op = AcpiPsAllocOp (WalkState->Opcode);
+ if (!Op)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ if (WalkState->OpInfo->Flags & AML_CREATE)
+ {
+ /*
+ * Backup to beginning of CreateXXXfield declaration
+ * BodyLength is unknown until we parse the body
+ */
+ Op->Named.Data = AmlOpStart;
+ Op->Named.Length = 0;
+ }
+
+ AcpiPsAppendArg (AcpiPsGetParentScope (ParserState), Op);
+
+ if ((WalkState->DescendingCallback != NULL))
+ {
+ /*
+ * Find the object. This will either insert the object into
+ * the namespace or simply look it up
+ */
+ WalkState->Op = Op;
+
+ Status = WalkState->DescendingCallback (WalkState, &Op);
+ Status = AcpiPsNextParseState (WalkState, Op, Status);
+ if (Status == AE_CTRL_PENDING)
+ {
+ Status = AE_OK;
+ goto CloseThisOp;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ goto CloseThisOp;
+ }
+ }
+ }
+
+ Op->Common.AmlOffset = WalkState->AmlOffset;
+
+ if (WalkState->OpInfo)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n",
+ (UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name,
+ Op, ParserState->Aml, Op->Common.AmlOffset));
+ }
+ }
+
+
+ /* Start ArgCount at zero because we don't know if there are any args yet */
+
+ WalkState->ArgCount = 0;
+
+ if (WalkState->ArgTypes) /* Are there any arguments that must be processed? */
+ {
+ /* Get arguments */
+
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
+ case AML_WORD_OP: /* AML_WORDDATA_ARG */
+ case AML_DWORD_OP: /* AML_DWORDATA_ARG */
+ case AML_QWORD_OP: /* AML_QWORDATA_ARG */
+ case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
+
+ /* Fill in constant or string argument directly */
+
+ AcpiPsGetNextSimpleArg (ParserState,
+ GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op);
+ break;
+
+ case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
+
+ Status = AcpiPsGetNextNamepath (WalkState, ParserState, Op, 1);
+ if (ACPI_FAILURE (Status))
+ {
+ goto CloseThisOp;
+ }
+
+ WalkState->ArgTypes = 0;
+ break;
+
+
+ default:
+
+ /* Op is not a constant or string, append each argument */
+
+ while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) &&
+ !WalkState->ArgCount)
+ {
+ WalkState->AmlOffset = ACPI_PTR_DIFF (ParserState->Aml,
+ ParserState->AmlStart);
+ Status = AcpiPsGetNextArg (WalkState, ParserState,
+ GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg);
+ if (ACPI_FAILURE (Status))
+ {
+ goto CloseThisOp;
+ }
+
+ if (Arg)
+ {
+ Arg->Common.AmlOffset = WalkState->AmlOffset;
+ AcpiPsAppendArg (Op, Arg);
+ }
+ INCREMENT_ARG_LIST (WalkState->ArgTypes);
+ }
+
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_METHOD_OP:
+
+ /* For a method, save the length and address of the body */
+
+ /*
+ * Skip parsing of control method or opregion body,
+ * because we don't have enough info in the first pass
+ * to parse them correctly.
+ */
+ Op->Named.Data = ParserState->Aml;
+ Op->Named.Length = (UINT32) (ParserState->PkgEnd - ParserState->Aml);
+ /*
+ * Skip body of method. For OpRegions, we must continue
+ * parsing because the opregion is not a standalone
+ * package (We don't know where the end is).
+ */
+ ParserState->Aml = ParserState->PkgEnd;
+ WalkState->ArgCount = 0;
+ break;
+
+ case AML_BUFFER_OP:
+ case AML_PACKAGE_OP:
+ case AML_VAR_PACKAGE_OP:
+
+ if ((Op->Common.Parent) &&
+ (Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) &&
+ (WalkState->DescendingCallback != AcpiDsExecBeginOp))
+ {
+ /*
+ * Skip parsing of
+ * because we don't have enough info in the first pass
+ * to parse them correctly.
+ */
+ Op->Named.Data = AmlOpStart;
+ Op->Named.Length = (UINT32) (ParserState->PkgEnd - AmlOpStart);
+ /*
+ * Skip body
+ */
+ ParserState->Aml = ParserState->PkgEnd;
+ WalkState->ArgCount = 0;
+ }
+ break;
+
+ case AML_WHILE_OP:
+
+ if (WalkState->ControlState)
+ {
+ WalkState->ControlState->Control.PackageEnd = ParserState->PkgEnd;
+ }
+ break;
+
+ default:
+ /* No action for all other opcodes */
+ break;
+ }
+ break;
+ }
+ }
+
+ /* Check for arguments that need to be processed */
+
+ if (WalkState->ArgCount)
+ {
+ /* There are arguments (complex ones), push Op and prepare for argument */
+
+ Status = AcpiPsPushScope (ParserState, Op,
+ WalkState->ArgTypes, WalkState->ArgCount);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ Op = NULL;
+ continue;
+ }
+
+ /* All arguments have been processed -- Op is complete, prepare for next */
+
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ if (WalkState->OpInfo->Flags & AML_NAMED)
+ {
+ if (AcpiGbl_Depth)
+ {
+ AcpiGbl_Depth--;
+ }
+
+ if (Op->Common.AmlOpcode == AML_REGION_OP)
+ {
+ /*
+ * Skip parsing of control method or opregion body,
+ * because we don't have enough info in the first pass
+ * to parse them correctly.
+ *
+ * Completed parsing an OpRegion declaration, we now
+ * know the length.
+ */
+ Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
+ }
+ }
+
+ if (WalkState->OpInfo->Flags & AML_CREATE)
+ {
+ /*
+ * Backup to beginning of CreateXXXfield declaration (1 for
+ * Opcode)
+ *
+ * BodyLength is unknown until we parse the body
+ */
+ Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data);
+ }
+
+ /* This op complete, notify the dispatcher */
+
+ if (WalkState->AscendingCallback != NULL)
+ {
+ WalkState->Op = Op;
+ WalkState->Opcode = Op->Common.AmlOpcode;
+
+ Status = WalkState->AscendingCallback (WalkState);
+ Status = AcpiPsNextParseState (WalkState, Op, Status);
+ if (Status == AE_CTRL_PENDING)
+ {
+ Status = AE_OK;
+ goto CloseThisOp;
+ }
+ }
+
+
+CloseThisOp:
+ /*
+ * Finished one argument of the containing scope
+ */
+ ParserState->Scope->ParseScope.ArgCount--;
+
+ /* Close this Op (will result in parse subtree deletion) */
+
+ AcpiPsCompleteThisOp (WalkState, Op);
+ Op = NULL;
+
+ switch (Status)
+ {
+ case AE_OK:
+ break;
+
+
+ case AE_CTRL_TRANSFER:
+
+ /*
+ * We are about to transfer to a called method.
+ */
+ WalkState->PrevOp = Op;
+ WalkState->PrevArgTypes = WalkState->ArgTypes;
+ return_ACPI_STATUS (Status);
+
+
+ case AE_CTRL_END:
+
+ AcpiPsPopScope (ParserState, &Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+
+ if (Op)
+ {
+ WalkState->Op = Op;
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ WalkState->Opcode = Op->Common.AmlOpcode;
+
+ Status = WalkState->AscendingCallback (WalkState);
+ Status = AcpiPsNextParseState (WalkState, Op, Status);
+
+ AcpiPsCompleteThisOp (WalkState, Op);
+ Op = NULL;
+ }
+ Status = AE_OK;
+ break;
+
+
+ case AE_CTRL_BREAK:
+ case AE_CTRL_CONTINUE:
+
+ /* Pop off scopes until we find the While */
+
+ while (!Op || (Op->Common.AmlOpcode != AML_WHILE_OP))
+ {
+ AcpiPsPopScope (ParserState, &Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+ }
+
+ /* Close this iteration of the While loop */
+
+ WalkState->Op = Op;
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ WalkState->Opcode = Op->Common.AmlOpcode;
+
+ Status = WalkState->AscendingCallback (WalkState);
+ Status = AcpiPsNextParseState (WalkState, Op, Status);
+
+ AcpiPsCompleteThisOp (WalkState, Op);
+ Op = NULL;
+
+ Status = AE_OK;
+ break;
+
+
+ case AE_CTRL_TERMINATE:
+
+ Status = AE_OK;
+
+ /* Clean up */
+ do
+ {
+ if (Op)
+ {
+ AcpiPsCompleteThisOp (WalkState, Op);
+ }
+ AcpiPsPopScope (ParserState, &Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+
+ } while (Op);
+
+ return_ACPI_STATUS (Status);
+
+
+ default: /* All other non-AE_OK status */
+
+ do
+ {
+ if (Op)
+ {
+ AcpiPsCompleteThisOp (WalkState, Op);
+ }
+ AcpiPsPopScope (ParserState, &Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+
+ } while (Op);
+
+
+ /*
+ * TBD: Cleanup parse ops on error
+ */
+#if 0
+ if (Op == NULL)
+ {
+ AcpiPsPopScope (ParserState, &Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+ }
+#endif
+ WalkState->PrevOp = Op;
+ WalkState->PrevArgTypes = WalkState->ArgTypes;
+ return_ACPI_STATUS (Status);
+ }
+
+ /* This scope complete? */
+
+ if (AcpiPsHasCompletedScope (ParserState))
+ {
+ AcpiPsPopScope (ParserState, &Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op));
+ }
+ else
+ {
+ Op = NULL;
+ }
+
+ } /* while ParserState->Aml */
+
+
+ /*
+ * Complete the last Op (if not completed), and clear the scope stack.
+ * It is easily possible to end an AML "package" with an unbounded number
+ * of open scopes (such as when several ASL blocks are closed with
+ * sequential closing braces). We want to terminate each one cleanly.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op));
+ do
+ {
+ if (Op)
+ {
+ if (WalkState->AscendingCallback != NULL)
+ {
+ WalkState->Op = Op;
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ WalkState->Opcode = Op->Common.AmlOpcode;
+
+ Status = WalkState->AscendingCallback (WalkState);
+ Status = AcpiPsNextParseState (WalkState, Op, Status);
+ if (Status == AE_CTRL_PENDING)
+ {
+ Status = AE_OK;
+ goto CloseThisOp;
+ }
+
+ if (Status == AE_CTRL_TERMINATE)
+ {
+ Status = AE_OK;
+
+ /* Clean up */
+ do
+ {
+ if (Op)
+ {
+ AcpiPsCompleteThisOp (WalkState, Op);
+ }
+
+ AcpiPsPopScope (ParserState, &Op,
+ &WalkState->ArgTypes, &WalkState->ArgCount);
+
+ } while (Op);
+
+ return_ACPI_STATUS (Status);
+ }
+
+ else if (ACPI_FAILURE (Status))
+ {
+ AcpiPsCompleteThisOp (WalkState, Op);
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ AcpiPsCompleteThisOp (WalkState, Op);
+ }
+
+ AcpiPsPopScope (ParserState, &Op, &WalkState->ArgTypes,
+ &WalkState->ArgCount);
+
+ } while (Op);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsParseAml
+ *
+ * PARAMETERS: StartScope - The starting point of the parse. Becomes the
+ * root of the parsed op tree.
+ * Aml - Pointer to the raw AML code to parse
+ * AmlSize - Length of the AML to parse
+ *
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Parse raw AML and return a tree of ops
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsParseAml (
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status;
+ ACPI_STATUS TerminateStatus;
+ ACPI_THREAD_STATE *Thread;
+ ACPI_THREAD_STATE *PrevWalkList = AcpiGbl_CurrentWalkList;
+ ACPI_WALK_STATE *PreviousWalkState;
+ ACPI_OPERAND_OBJECT **CallerReturnDesc = WalkState->CallerReturnDesc;
+ ACPI_OPERAND_OBJECT *EffectiveReturnDesc = NULL;
+
+
+
+ ACPI_FUNCTION_TRACE ("PsParseAml");
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Entered with WalkState=%p Aml=%p size=%X\n",
+ WalkState, WalkState->ParserState.Aml, WalkState->ParserState.AmlSize));
+
+
+ /* Create and initialize a new thread state */
+
+ Thread = AcpiUtCreateThreadState ();
+ if (!Thread)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ WalkState->Thread = Thread;
+ AcpiDsPushWalkState (WalkState, Thread);
+
+ /*
+ * This global allows the AML debugger to get a handle to the currently
+ * executing control method.
+ */
+ AcpiGbl_CurrentWalkList = Thread;
+
+ /*
+ * Execute the walk loop as long as there is a valid Walk State. This
+ * handles nested control method invocations without recursion.
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", WalkState));
+
+ Status = AE_OK;
+ while (WalkState)
+ {
+ if (ACPI_SUCCESS (Status))
+ {
+ /*
+ * The ParseLoop executes AML until the method terminates
+ * or calls another method.
+ */
+ Status = AcpiPsParseLoop (WalkState);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "Completed one call to walk loop, %s State=%p\n",
+ AcpiFormatException (Status), WalkState));
+
+ if (Status == AE_CTRL_TRANSFER)
+ {
+ /*
+ * A method call was detected.
+ * Transfer control to the called control method
+ */
+ Status = AcpiDsCallControlMethod (Thread, WalkState, NULL);
+
+ /*
+ * If the transfer to the new method method call worked, a new walk
+ * state was created -- get it
+ */
+ WalkState = AcpiDsGetCurrentWalkState (Thread);
+ continue;
+ }
+ else if (Status == AE_CTRL_TERMINATE)
+ {
+ Status = AE_OK;
+ }
+ else if (Status != AE_OK)
+ {
+ ACPI_REPORT_METHOD_ERROR ("Method execution failed",
+ WalkState->MethodNode, NULL, Status);
+ }
+
+ /* We are done with this walk, move on to the parent if any */
+
+ WalkState = AcpiDsPopWalkState (Thread);
+ /* Save the last effective return value */
+
+ if (CallerReturnDesc && WalkState->ReturnDesc)
+ {
+ AcpiUtRemoveReference (EffectiveReturnDesc);
+ EffectiveReturnDesc = WalkState->ReturnDesc;
+ AcpiUtAddReference (EffectiveReturnDesc);
+ }
+
+ /* Reset the current scope to the beginning of scope stack */
+
+ AcpiDsScopeStackClear (WalkState);
+
+ /*
+ * If we just returned from the execution of a control method,
+ * there's lots of cleanup to do
+ */
+ if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE)
+ {
+ TerminateStatus = AcpiDsTerminateControlMethod (WalkState);
+ if (ACPI_FAILURE (TerminateStatus))
+ {
+ ACPI_REPORT_ERROR ((
+ "Could not terminate control method properly\n"));
+
+ /* Ignore error and continue */
+ }
+ }
+
+ /* Delete this walk state and all linked control states */
+
+ AcpiPsCleanupScope (&WalkState->ParserState);
+
+ PreviousWalkState = WalkState;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "ReturnValue=%p, State=%p\n",
+ WalkState->ReturnDesc, WalkState));
+
+ /* Check if we have restarted a preempted walk */
+
+ WalkState = AcpiDsGetCurrentWalkState (Thread);
+ if (WalkState)
+ {
+ if (ACPI_SUCCESS (Status))
+ {
+ /*
+ * There is another walk state, restart it.
+ * If the method return value is not used by the parent,
+ * The object is deleted
+ */
+ Status = AcpiDsRestartControlMethod (WalkState,
+ PreviousWalkState->ReturnDesc);
+ if (ACPI_SUCCESS (Status))
+ {
+ WalkState->WalkType |= ACPI_WALK_METHOD_RESTART;
+ }
+ }
+ else
+ {
+ /* On error, delete any return object */
+
+ AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
+ }
+ }
+
+ /*
+ * Just completed a 1st-level method, save the final internal return
+ * value (if any)
+ */
+ else if (PreviousWalkState->CallerReturnDesc)
+ {
+ /*
+ * Some AML code expects return value w/o ReturnOp.
+ * Return the saved effective return value instead.
+ */
+
+ if (PreviousWalkState->ReturnDesc == NULL && EffectiveReturnDesc != NULL)
+ {
+ PreviousWalkState->ReturnDesc = EffectiveReturnDesc;
+ AcpiUtAddReference (PreviousWalkState->ReturnDesc);
+ }
+
+ *(PreviousWalkState->CallerReturnDesc) = PreviousWalkState->ReturnDesc; /* NULL if no return value */
+ }
+ else if (PreviousWalkState->ReturnDesc)
+ {
+ /* Caller doesn't want it, must delete it */
+
+ AcpiUtRemoveReference (PreviousWalkState->ReturnDesc);
+ }
+
+ AcpiDsDeleteWalkState (PreviousWalkState);
+ }
+
+ /* Normal exit */
+
+ AcpiUtRemoveReference (EffectiveReturnDesc);
+ AcpiExReleaseAllMutexes (Thread);
+ AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread));
+ AcpiGbl_CurrentWalkList = PrevWalkList;
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/psscope.c b/sys/contrib/dev/acpica/psscope.c
new file mode 100644
index 0000000..4c64aa6
--- /dev/null
+++ b/sys/contrib/dev/acpica/psscope.c
@@ -0,0 +1,376 @@
+/******************************************************************************
+ *
+ * Module Name: psscope - Parser scope stack management routines
+ * $Revision: 36 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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"
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("psscope")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetParentScope
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ *
+ * RETURN: Pointer to an Op object
+ *
+ * DESCRIPTION: Get parent of current op being parsed
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+AcpiPsGetParentScope (
+ ACPI_PARSE_STATE *ParserState)
+{
+ return (ParserState->Scope->ParseScope.Op);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsHasCompletedScope
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ *
+ * RETURN: Boolean, TRUE = scope completed.
+ *
+ * DESCRIPTION: Is parsing of current argument complete? Determined by
+ * 1) AML pointer is at or beyond the end of the scope
+ * 2) The scope argument count has reached zero.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiPsHasCompletedScope (
+ ACPI_PARSE_STATE *ParserState)
+{
+ return ((BOOLEAN) ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd ||
+ !ParserState->Scope->ParseScope.ArgCount)));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsInitScope
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ * Root - the Root Node of this new scope
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Allocate and init a new scope object
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsInitScope (
+ ACPI_PARSE_STATE *ParserState,
+ ACPI_PARSE_OBJECT *RootOp)
+{
+ ACPI_GENERIC_STATE *Scope;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("PsInitScope", RootOp);
+
+
+ Scope = AcpiUtCreateGenericState ();
+ if (!Scope)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Scope->Common.DataType = ACPI_DESC_TYPE_STATE_RPSCOPE;
+ Scope->ParseScope.Op = RootOp;
+ Scope->ParseScope.ArgCount = ACPI_VAR_ARGS;
+ Scope->ParseScope.ArgEnd = ParserState->AmlEnd;
+ Scope->ParseScope.PkgEnd = ParserState->AmlEnd;
+
+ ParserState->Scope = Scope;
+ ParserState->StartOp = RootOp;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsPushScope
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ * Op - Current op to be pushed
+ * RemainingArgs - List of args remaining
+ * ArgCount - Fixed or variable number of args
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Push current op to begin parsing its argument
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsPushScope (
+ ACPI_PARSE_STATE *ParserState,
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 RemainingArgs,
+ UINT32 ArgCount)
+{
+ ACPI_GENERIC_STATE *Scope;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("PsPushScope", Op);
+
+
+ Scope = AcpiUtCreateGenericState ();
+ if (!Scope)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+
+ Scope->Common.DataType = ACPI_DESC_TYPE_STATE_PSCOPE;
+ Scope->ParseScope.Op = Op;
+ Scope->ParseScope.ArgList = RemainingArgs;
+ Scope->ParseScope.ArgCount = ArgCount;
+ Scope->ParseScope.PkgEnd = ParserState->PkgEnd;
+
+ /* Push onto scope stack */
+
+ AcpiUtPushGenericState (&ParserState->Scope, Scope);
+
+
+ if (ArgCount == ACPI_VAR_ARGS)
+ {
+ /* multiple arguments */
+
+ Scope->ParseScope.ArgEnd = ParserState->PkgEnd;
+ }
+
+ else
+ {
+ /* single argument */
+
+ Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsPopScope
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ * Op - Where the popped op is returned
+ * ArgList - Where the popped "next argument" is
+ * returned
+ * ArgCount - Count of objects in ArgList
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Return to parsing a previous op
+ *
+ ******************************************************************************/
+
+void
+AcpiPsPopScope (
+ ACPI_PARSE_STATE *ParserState,
+ ACPI_PARSE_OBJECT **Op,
+ UINT32 *ArgList,
+ UINT32 *ArgCount)
+{
+ ACPI_GENERIC_STATE *Scope = ParserState->Scope;
+
+
+ ACPI_FUNCTION_TRACE ("PsPopScope");
+
+
+ /*
+ * Only pop the scope if there is in fact a next scope
+ */
+ if (Scope->Common.Next)
+ {
+ Scope = AcpiUtPopGenericState (&ParserState->Scope);
+
+ /* return to parsing previous op */
+
+ *Op = Scope->ParseScope.Op;
+ *ArgList = Scope->ParseScope.ArgList;
+ *ArgCount = Scope->ParseScope.ArgCount;
+ ParserState->PkgEnd = Scope->ParseScope.PkgEnd;
+
+ /* All done with this scope state structure */
+
+ AcpiUtDeleteGenericState (Scope);
+ }
+
+ else
+ {
+ /* empty parse stack, prepare to fetch next opcode */
+
+ *Op = NULL;
+ *ArgList = 0;
+ *ArgCount = 0;
+ }
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped Op %p Args %X\n", *Op, *ArgCount));
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsCleanupScope
+ *
+ * PARAMETERS: ParserState - Current parser state object
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Destroy available list, remaining stack levels, and return
+ * root scope
+ *
+ ******************************************************************************/
+
+void
+AcpiPsCleanupScope (
+ ACPI_PARSE_STATE *ParserState)
+{
+ ACPI_GENERIC_STATE *Scope;
+
+ ACPI_FUNCTION_TRACE_PTR ("PsCleanupScope", ParserState);
+
+
+ if (!ParserState)
+ {
+ return;
+ }
+
+
+ /* Delete anything on the scope stack */
+
+ while (ParserState->Scope)
+ {
+ Scope = AcpiUtPopGenericState (&ParserState->Scope);
+ AcpiUtDeleteGenericState (Scope);
+ }
+
+ return_VOID;
+}
+
diff --git a/sys/contrib/dev/acpica/pstree.c b/sys/contrib/dev/acpica/pstree.c
new file mode 100644
index 0000000..f4f1d48
--- /dev/null
+++ b/sys/contrib/dev/acpica/pstree.c
@@ -0,0 +1,418 @@
+/******************************************************************************
+ *
+ * Module Name: pstree - Parser op tree manipulation/traversal/search
+ * $Revision: 41 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __PSTREE_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "amlcode.h"
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("pstree")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetArg
+ *
+ * PARAMETERS: Op - Get an argument for this op
+ * Argn - Nth argument to get
+ *
+ * RETURN: The argument (as an Op object). NULL if argument does not exist
+ *
+ * DESCRIPTION: Get the specified op's argument.
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+AcpiPsGetArg (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 Argn)
+{
+ ACPI_PARSE_OBJECT *Arg = NULL;
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Get the info structure for this opcode */
+
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ if (OpInfo->Class == AML_CLASS_UNKNOWN)
+ {
+ /* Invalid opcode or ASCII character */
+
+ return (NULL);
+ }
+
+ /* Check if this opcode requires argument sub-objects */
+
+ if (!(OpInfo->Flags & AML_HAS_ARGS))
+ {
+ /* Has no linked argument objects */
+
+ return (NULL);
+ }
+
+ /* Get the requested argument object */
+
+ Arg = Op->Common.Value.Arg;
+ while (Arg && Argn)
+ {
+ Argn--;
+ Arg = Arg->Common.Next;
+ }
+
+ return (Arg);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsAppendArg
+ *
+ * PARAMETERS: Op - Append an argument to this Op.
+ * Arg - Argument Op to append
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Append an argument to an op's argument list (a NULL arg is OK)
+ *
+ ******************************************************************************/
+
+void
+AcpiPsAppendArg (
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_PARSE_OBJECT *Arg)
+{
+ ACPI_PARSE_OBJECT *PrevArg;
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!Op)
+ {
+ return;
+ }
+
+ /* Get the info structure for this opcode */
+
+ OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ if (OpInfo->Class == AML_CLASS_UNKNOWN)
+ {
+ /* Invalid opcode */
+
+ ACPI_REPORT_ERROR (("PsAppendArg: Invalid AML Opcode: 0x%2.2X\n",
+ Op->Common.AmlOpcode));
+ return;
+ }
+
+ /* Check if this opcode requires argument sub-objects */
+
+ if (!(OpInfo->Flags & AML_HAS_ARGS))
+ {
+ /* Has no linked argument objects */
+
+ return;
+ }
+
+
+ /* Append the argument to the linked argument list */
+
+ if (Op->Common.Value.Arg)
+ {
+ /* Append to existing argument list */
+
+ PrevArg = Op->Common.Value.Arg;
+ while (PrevArg->Common.Next)
+ {
+ PrevArg = PrevArg->Common.Next;
+ }
+ PrevArg->Common.Next = Arg;
+ }
+
+ else
+ {
+ /* No argument list, this will be the first argument */
+
+ Op->Common.Value.Arg = Arg;
+ }
+
+
+ /* Set the parent in this arg and any args linked after it */
+
+ while (Arg)
+ {
+ Arg->Common.Parent = Op;
+ Arg = Arg->Common.Next;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetChild
+ *
+ * PARAMETERS: Op - Get the child of this Op
+ *
+ * RETURN: Child Op, Null if none is found.
+ *
+ * DESCRIPTION: Get op's children or NULL if none
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+AcpiPsGetChild (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Child = NULL;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ switch (Op->Common.AmlOpcode)
+ {
+ case AML_SCOPE_OP:
+ case AML_ELSE_OP:
+ case AML_DEVICE_OP:
+ case AML_THERMAL_ZONE_OP:
+ case AML_INT_METHODCALL_OP:
+
+ Child = AcpiPsGetArg (Op, 0);
+ break;
+
+
+ case AML_BUFFER_OP:
+ case AML_PACKAGE_OP:
+ case AML_METHOD_OP:
+ case AML_IF_OP:
+ case AML_WHILE_OP:
+ case AML_FIELD_OP:
+
+ Child = AcpiPsGetArg (Op, 1);
+ break;
+
+
+ case AML_POWER_RES_OP:
+ case AML_INDEX_FIELD_OP:
+
+ Child = AcpiPsGetArg (Op, 2);
+ break;
+
+
+ case AML_PROCESSOR_OP:
+ case AML_BANK_FIELD_OP:
+
+ Child = AcpiPsGetArg (Op, 3);
+ break;
+
+
+ default:
+ /* All others have no children */
+ break;
+ }
+
+ return (Child);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetDepthNext
+ *
+ * PARAMETERS: Origin - Root of subtree to search
+ * Op - Last (previous) Op that was found
+ *
+ * RETURN: Next Op found in the search.
+ *
+ * DESCRIPTION: Get next op in tree (walking the tree in depth-first order)
+ * Return NULL when reaching "origin" or when walking up from root
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+AcpiPsGetDepthNext (
+ ACPI_PARSE_OBJECT *Origin,
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_PARSE_OBJECT *Next = NULL;
+ ACPI_PARSE_OBJECT *Parent;
+ ACPI_PARSE_OBJECT *Arg;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (!Op)
+ {
+ return (NULL);
+ }
+
+ /* look for an argument or child */
+
+ Next = AcpiPsGetArg (Op, 0);
+ if (Next)
+ {
+ return (Next);
+ }
+
+ /* look for a sibling */
+
+ Next = Op->Common.Next;
+ if (Next)
+ {
+ return (Next);
+ }
+
+ /* look for a sibling of parent */
+
+ Parent = Op->Common.Parent;
+
+ while (Parent)
+ {
+ Arg = AcpiPsGetArg (Parent, 0);
+ while (Arg && (Arg != Origin) && (Arg != Op))
+ {
+ Arg = Arg->Common.Next;
+ }
+
+ if (Arg == Origin)
+ {
+ /* reached parent of origin, end search */
+
+ return (NULL);
+ }
+
+ if (Parent->Common.Next)
+ {
+ /* found sibling of parent */
+
+ return (Parent->Common.Next);
+ }
+
+ Op = Parent;
+ Parent = Parent->Common.Parent;
+ }
+
+ return (Next);
+}
+
+
diff --git a/sys/contrib/dev/acpica/psutils.c b/sys/contrib/dev/acpica/psutils.c
new file mode 100644
index 0000000..78a005b
--- /dev/null
+++ b/sys/contrib/dev/acpica/psutils.c
@@ -0,0 +1,396 @@
+/******************************************************************************
+ *
+ * Module Name: psutils - Parser miscellaneous utilities (Parser only)
+ * $Revision: 55 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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"
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("psutils")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsCreateScopeOp
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: ScopeOp
+ *
+ * DESCRIPTION: Create a Scope and associated namepath op with the root name
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT *
+AcpiPsCreateScopeOp (
+ void)
+{
+ ACPI_PARSE_OBJECT *ScopeOp;
+
+
+ ScopeOp = AcpiPsAllocOp (AML_SCOPE_OP);
+ if (!ScopeOp)
+ {
+ return (NULL);
+ }
+
+
+ ScopeOp->Named.Name = ACPI_ROOT_NAME;
+ return (ScopeOp);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsInitOp
+ *
+ * PARAMETERS: Op - A newly allocated Op object
+ * Opcode - Opcode to store in the Op
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on
+ * opcode
+ *
+ ******************************************************************************/
+
+void
+AcpiPsInitOp (
+ ACPI_PARSE_OBJECT *Op,
+ UINT16 Opcode)
+{
+ ACPI_FUNCTION_ENTRY ();
+
+
+ Op->Common.DataType = ACPI_DESC_TYPE_PARSER;
+ Op->Common.AmlOpcode = Opcode;
+
+ ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (Op->Common.AmlOpName,
+ (AcpiPsGetOpcodeInfo (Opcode))->Name, sizeof (Op->Common.AmlOpName)));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsAllocOp
+ *
+ * PARAMETERS: Opcode - Opcode that will be stored in the new Op
+ *
+ * RETURN: Pointer to the new Op.
+ *
+ * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on
+ * opcode. A cache of opcodes is available for the pure
+ * GENERIC_OP, since this is by far the most commonly used.
+ *
+ ******************************************************************************/
+
+ACPI_PARSE_OBJECT*
+AcpiPsAllocOp (
+ UINT16 Opcode)
+{
+ ACPI_PARSE_OBJECT *Op = NULL;
+ UINT32 Size;
+ UINT8 Flags;
+ const ACPI_OPCODE_INFO *OpInfo;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ OpInfo = AcpiPsGetOpcodeInfo (Opcode);
+
+ /* Allocate the minimum required size object */
+
+ if (OpInfo->Flags & AML_DEFER)
+ {
+ Size = sizeof (ACPI_PARSE_OBJ_NAMED);
+ Flags = ACPI_PARSEOP_DEFERRED;
+ }
+ else if (OpInfo->Flags & AML_NAMED)
+ {
+ Size = sizeof (ACPI_PARSE_OBJ_NAMED);
+ Flags = ACPI_PARSEOP_NAMED;
+ }
+ else if (Opcode == AML_INT_BYTELIST_OP)
+ {
+ Size = sizeof (ACPI_PARSE_OBJ_NAMED);
+ Flags = ACPI_PARSEOP_BYTELIST;
+ }
+ else
+ {
+ Size = sizeof (ACPI_PARSE_OBJ_COMMON);
+ Flags = ACPI_PARSEOP_GENERIC;
+ }
+
+ if (Size == sizeof (ACPI_PARSE_OBJ_COMMON))
+ {
+ /*
+ * The generic op is by far the most common (16 to 1)
+ */
+ Op = AcpiUtAcquireFromCache (ACPI_MEM_LIST_PSNODE);
+ }
+ else
+ {
+ Op = AcpiUtAcquireFromCache (ACPI_MEM_LIST_PSNODE_EXT);
+ }
+
+ /* Initialize the Op */
+
+ if (Op)
+ {
+ AcpiPsInitOp (Op, Opcode);
+ Op->Common.Flags = Flags;
+ }
+
+ return (Op);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsFreeOp
+ *
+ * PARAMETERS: Op - Op to be freed
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list
+ * or actually free it.
+ *
+ ******************************************************************************/
+
+void
+AcpiPsFreeOp (
+ ACPI_PARSE_OBJECT *Op)
+{
+ ACPI_FUNCTION_NAME ("PsFreeOp");
+
+
+ if (Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", Op));
+ }
+
+ if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
+ {
+ AcpiUtReleaseToCache (ACPI_MEM_LIST_PSNODE, Op);
+ }
+ else
+ {
+ AcpiUtReleaseToCache (ACPI_MEM_LIST_PSNODE_EXT, Op);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsDeleteParseCache
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Free all objects that are on the parse cache list.
+ *
+ ******************************************************************************/
+
+void
+AcpiPsDeleteParseCache (
+ void)
+{
+ ACPI_FUNCTION_TRACE ("PsDeleteParseCache");
+
+
+ AcpiUtDeleteGenericCache (ACPI_MEM_LIST_PSNODE);
+ AcpiUtDeleteGenericCache (ACPI_MEM_LIST_PSNODE_EXT);
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Utility functions
+ *
+ * DESCRIPTION: Low level character and object functions
+ *
+ ******************************************************************************/
+
+
+/*
+ * Is "c" a namestring lead character?
+ */
+BOOLEAN
+AcpiPsIsLeadingChar (
+ UINT32 c)
+{
+ return ((BOOLEAN) (c == '_' || (c >= 'A' && c <= 'Z')));
+}
+
+
+/*
+ * Is "c" a namestring prefix character?
+ */
+BOOLEAN
+AcpiPsIsPrefixChar (
+ UINT32 c)
+{
+ return ((BOOLEAN) (c == '\\' || c == '^'));
+}
+
+
+/*
+ * Get op's name (4-byte name segment) or 0 if unnamed
+ */
+UINT32
+AcpiPsGetName (
+ ACPI_PARSE_OBJECT *Op)
+{
+
+
+ /* The "generic" object has no name associated with it */
+
+ if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
+ {
+ return (0);
+ }
+
+ /* Only the "Extended" parse objects have a name */
+
+ return (Op->Named.Name);
+}
+
+
+/*
+ * Set op's name
+ */
+void
+AcpiPsSetName (
+ ACPI_PARSE_OBJECT *Op,
+ UINT32 name)
+{
+
+ /* The "generic" object has no name associated with it */
+
+ if (Op->Common.Flags & ACPI_PARSEOP_GENERIC)
+ {
+ return;
+ }
+
+ Op->Named.Name = name;
+}
+
diff --git a/sys/contrib/dev/acpica/pswalk.c b/sys/contrib/dev/acpica/pswalk.c
new file mode 100644
index 0000000..9cb6a70
--- /dev/null
+++ b/sys/contrib/dev/acpica/pswalk.c
@@ -0,0 +1,393 @@
+/******************************************************************************
+ *
+ * Module Name: pswalk - Parser routines to walk parsed op tree(s)
+ * $Revision: 68 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 "acdispat.h"
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("pswalk")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsGetNextWalkOp
+ *
+ * PARAMETERS: WalkState - Current state of the walk
+ * Op - Current Op to be walked
+ * AscendingCallback - Procedure called when Op is complete
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Get the next Op in a walk of the parse tree.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsGetNextWalkOp (
+ ACPI_WALK_STATE *WalkState,
+ ACPI_PARSE_OBJECT *Op,
+ ACPI_PARSE_UPWARDS AscendingCallback)
+{
+ ACPI_PARSE_OBJECT *Next;
+ ACPI_PARSE_OBJECT *Parent;
+ ACPI_PARSE_OBJECT *GrandParent;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("PsGetNextWalkOp", Op);
+
+
+ /* Check for a argument only if we are descending in the tree */
+
+ if (WalkState->NextOpInfo != ACPI_NEXT_OP_UPWARD)
+ {
+ /* Look for an argument or child of the current op */
+
+ Next = AcpiPsGetArg (Op, 0);
+ if (Next)
+ {
+ /* Still going downward in tree (Op is not completed yet) */
+
+ WalkState->PrevOp = Op;
+ WalkState->NextOp = Next;
+ WalkState->NextOpInfo = ACPI_NEXT_OP_DOWNWARD;
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * No more children, this Op is complete. Save Next and Parent
+ * in case the Op object gets deleted by the callback routine
+ */
+ Next = Op->Common.Next;
+ Parent = Op->Common.Parent;
+
+ WalkState->Op = Op;
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+ WalkState->Opcode = Op->Common.AmlOpcode;
+
+ Status = AscendingCallback (WalkState);
+
+ /*
+ * If we are back to the starting point, the walk is complete.
+ */
+ if (Op == WalkState->Origin)
+ {
+ /* Reached the point of origin, the walk is complete */
+
+ WalkState->PrevOp = Op;
+ WalkState->NextOp = NULL;
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Check for a sibling to the current op. A sibling means
+ * we are still going "downward" in the tree.
+ */
+ if (Next)
+ {
+ /* There is a sibling, it will be next */
+
+ WalkState->PrevOp = Op;
+ WalkState->NextOp = Next;
+ WalkState->NextOpInfo = ACPI_NEXT_OP_DOWNWARD;
+
+ /* Continue downward */
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Drop into the loop below because we are moving upwards in
+ * the tree
+ */
+ }
+ else
+ {
+ /*
+ * We are resuming a walk, and we were (are) going upward in the tree.
+ * So, we want to drop into the parent loop below.
+ */
+ Parent = Op;
+ }
+
+ /*
+ * Look for a sibling of the current Op's parent
+ * Continue moving up the tree until we find a node that has not been
+ * visited, or we get back to where we started.
+ */
+ while (Parent)
+ {
+ /* We are moving up the tree, therefore this parent Op is complete */
+
+ GrandParent = Parent->Common.Parent;
+ Next = Parent->Common.Next;
+
+ WalkState->Op = Parent;
+ WalkState->OpInfo = AcpiPsGetOpcodeInfo (Parent->Common.AmlOpcode);
+ WalkState->Opcode = Parent->Common.AmlOpcode;
+
+ Status = AscendingCallback (WalkState);
+
+ /*
+ * If we are back to the starting point, the walk is complete.
+ */
+ if (Parent == WalkState->Origin)
+ {
+ /* Reached the point of origin, the walk is complete */
+
+ WalkState->PrevOp = Parent;
+ WalkState->NextOp = NULL;
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * If there is a sibling to this parent (it is not the starting point
+ * Op), then we will visit it.
+ */
+ if (Next)
+ {
+ /* found sibling of parent */
+
+ WalkState->PrevOp = Parent;
+ WalkState->NextOp = Next;
+ WalkState->NextOpInfo = ACPI_NEXT_OP_DOWNWARD;
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /* No siblings, no errors, just move up one more level in the tree */
+
+ Op = Parent;
+ Parent = GrandParent;
+ WalkState->PrevOp = Op;
+ }
+
+
+ /*
+ * Got all the way to the top of the tree, we must be done!
+ * However, the code should have terminated in the loop above
+ */
+ WalkState->NextOp = NULL;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsDeleteCompletedOp
+ *
+ * PARAMETERS: State - Walk state
+ * Op - Completed op
+ *
+ * RETURN: AE_OK
+ *
+ * DESCRIPTION: Callback function for AcpiPsGetNextWalkOp(). Used during
+ * AcpiPsDeleteParse tree to delete Op objects when all sub-objects
+ * have been visited (and deleted.)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsDeleteCompletedOp (
+ ACPI_WALK_STATE *WalkState)
+{
+
+ AcpiPsFreeOp (WalkState->Op);
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsDeleteParseTree
+ *
+ * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Delete a portion of or an entire parse tree.
+ *
+ ******************************************************************************/
+
+void
+AcpiPsDeleteParseTree (
+ ACPI_PARSE_OBJECT *SubtreeRoot)
+{
+ ACPI_WALK_STATE *WalkState;
+ ACPI_THREAD_STATE *Thread;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("PsDeleteParseTree", SubtreeRoot);
+
+
+ if (!SubtreeRoot)
+ {
+ return_VOID;
+ }
+
+ /* Create and initialize a new walk list */
+
+ Thread = AcpiUtCreateThreadState ();
+ if (!Thread)
+ {
+ return_VOID;
+ }
+
+ WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, Thread);
+ if (!WalkState)
+ {
+ return_VOID;
+ }
+
+ WalkState->ParseFlags = 0;
+ WalkState->DescendingCallback = NULL;
+ WalkState->AscendingCallback = NULL;
+
+ WalkState->Origin = SubtreeRoot;
+ WalkState->NextOp = SubtreeRoot;
+
+ /* Head downward in the tree */
+
+ WalkState->NextOpInfo = ACPI_NEXT_OP_DOWNWARD;
+
+ /* Visit all nodes in the subtree */
+
+ while (WalkState->NextOp)
+ {
+ Status = AcpiPsGetNextWalkOp (WalkState, WalkState->NextOp,
+ AcpiPsDeleteCompletedOp);
+ if (ACPI_FAILURE (Status))
+ {
+ break;
+ }
+ }
+
+ /* We are done with this walk */
+
+ AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread));
+ AcpiDsDeleteWalkState (WalkState);
+
+ return_VOID;
+}
+
+
diff --git a/sys/contrib/dev/acpica/psxface.c b/sys/contrib/dev/acpica/psxface.c
new file mode 100644
index 0000000..ef9addc
--- /dev/null
+++ b/sys/contrib/dev/acpica/psxface.c
@@ -0,0 +1,312 @@
+/******************************************************************************
+ *
+ * Module Name: psxface - Parser external interfaces
+ * $Revision: 67 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __PSXFACE_C__
+
+#include "acpi.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "acinterp.h"
+#include "acnamesp.h"
+
+
+#define _COMPONENT ACPI_PARSER
+ ACPI_MODULE_NAME ("psxface")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiPsxExecute
+ *
+ * PARAMETERS: MethodNode - A method object containing both the AML
+ * address and length.
+ * **Params - List of parameters to pass to method,
+ * terminated by NULL. Params itself may be
+ * NULL if no parameters are being passed.
+ * **ReturnObjDesc - Return object from execution of the
+ * method.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Execute a control method
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiPsxExecute (
+ ACPI_NAMESPACE_NODE *MethodNode,
+ ACPI_OPERAND_OBJECT **Params,
+ ACPI_OPERAND_OBJECT **ReturnObjDesc)
+{
+ ACPI_STATUS Status;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ UINT32 i;
+ ACPI_PARSE_OBJECT *Op;
+ ACPI_WALK_STATE *WalkState;
+
+
+ ACPI_FUNCTION_TRACE ("PsxExecute");
+
+
+ /* Validate the Node and get the attached object */
+
+ 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, NULL);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (Params)
+ {
+ /*
+ * The caller "owns" the parameters, so give each one an extra
+ * reference
+ */
+ for (i = 0; Params[i]; i++)
+ {
+ AcpiUtAddReference (Params[i]);
+ }
+ }
+
+ /*
+ * 1) Perform the first pass parse of the method to enter any
+ * named objects that it creates into the namespace
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "**** Begin Method Parse **** Entry=%p obj=%p\n",
+ MethodNode, ObjDesc));
+
+ /* Create and init a Root Node */
+
+ Op = AcpiPsCreateScopeOp ();
+ if (!Op)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /*
+ * Get a new OwnerId for objects created by this method. Namespace
+ * objects (such as Operation Regions) can be created during the
+ * first pass parse.
+ */
+ ObjDesc->Method.OwningId = AcpiUtAllocateOwnerId (ACPI_OWNER_TYPE_METHOD);
+
+ /* Create and initialize a new walk state */
+
+ WalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwningId,
+ NULL, NULL, NULL);
+ if (!WalkState)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Status = AcpiDsInitAmlWalk (WalkState, Op, MethodNode, ObjDesc->Method.AmlStart,
+ ObjDesc->Method.AmlLength, NULL, NULL, 1);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiDsDeleteWalkState (WalkState);
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Parse the AML */
+
+ Status = AcpiPsParseAml (WalkState);
+ AcpiPsDeleteParseTree (Op);
+
+ /*
+ * 2) Execute the method. Performs second pass parse simultaneously
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+ "**** Begin Method Execution **** Entry=%p obj=%p\n",
+ MethodNode, ObjDesc));
+
+ /* Create and init a Root Node */
+
+ Op = AcpiPsCreateScopeOp ();
+ if (!Op)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Init new op with the method name and pointer back to the NS node */
+
+ AcpiPsSetName (Op, MethodNode->Name.Integer);
+ Op->Common.Node = MethodNode;
+
+ /* Create and initialize a new walk state */
+
+ WalkState = AcpiDsCreateWalkState (TABLE_ID_DSDT, NULL, NULL, NULL);
+ if (!WalkState)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ Status = AcpiDsInitAmlWalk (WalkState, Op, MethodNode, ObjDesc->Method.AmlStart,
+ ObjDesc->Method.AmlLength, Params, ReturnObjDesc, 3);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiDsDeleteWalkState (WalkState);
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * The walk of the parse tree is where we actually execute the method
+ */
+ Status = AcpiPsParseAml (WalkState);
+ AcpiPsDeleteParseTree (Op);
+
+ if (Params)
+ {
+ /* Take away the extra reference that we gave the parameters above */
+
+ for (i = 0; Params[i]; i++)
+ {
+ /* Ignore errors, just do them all */
+
+ (void) AcpiUtUpdateObjectReference (Params[i], REF_DECREMENT);
+ }
+ }
+
+ /*
+ * If the method has returned an object, signal this to the caller with
+ * a control exception code
+ */
+ if (*ReturnObjDesc)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n",
+ *ReturnObjDesc));
+ ACPI_DUMP_STACK_ENTRY (*ReturnObjDesc);
+
+ Status = AE_CTRL_RETURN_VALUE;
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
diff --git a/sys/contrib/dev/acpica/rsaddr.c b/sys/contrib/dev/acpica/rsaddr.c
new file mode 100644
index 0000000..4787ffa
--- /dev/null
+++ b/sys/contrib/dev/acpica/rsaddr.c
@@ -0,0 +1,1318 @@
+/*******************************************************************************
+ *
+ * Module Name: rsaddr - Address resource descriptors (16/32/64)
+ * $Revision: 29 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __RSADDR_C__
+
+#include "acpi.h"
+#include "acresrc.h"
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsaddr")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsAddress16Resource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsAddress16Resource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ UINT8 *TempPtr;
+ ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS16);
+ UINT32 Index;
+ UINT16 Temp16;
+ UINT8 Temp8;
+
+
+ ACPI_FUNCTION_TRACE ("RsAddress16Resource");
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ *BytesConsumed = Temp16 + 3;
+ OutputStruct->Id = ACPI_RSTYPE_ADDRESS16;
+
+ /*
+ * Get the Resource Type (Byte3)
+ */
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ /* Values 0-2 are valid */
+
+ if (Temp8 > 2)
+ {
+ return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
+ }
+
+ OutputStruct->Data.Address16.ResourceType = Temp8 & 0x03;
+
+ /*
+ * Get the General Flags (Byte4)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ /* Producer / Consumer */
+
+ OutputStruct->Data.Address16.ProducerConsumer = Temp8 & 0x01;
+
+ /* Decode */
+
+ OutputStruct->Data.Address16.Decode = (Temp8 >> 1) & 0x01;
+
+ /* Min Address Fixed */
+
+ OutputStruct->Data.Address16.MinAddressFixed = (Temp8 >> 2) & 0x01;
+
+ /* Max Address Fixed */
+
+ OutputStruct->Data.Address16.MaxAddressFixed = (Temp8 >> 3) & 0x01;
+
+ /*
+ * Get the Type Specific Flags (Byte5)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address16.ResourceType)
+ {
+ OutputStruct->Data.Address16.Attribute.Memory.ReadWriteAttribute =
+ (UINT16) (Temp8 & 0x01);
+ OutputStruct->Data.Address16.Attribute.Memory.CacheAttribute =
+ (UINT16) ((Temp8 >> 1) & 0x0F);
+ }
+ else
+ {
+ if (ACPI_IO_RANGE == OutputStruct->Data.Address16.ResourceType)
+ {
+ OutputStruct->Data.Address16.Attribute.Io.RangeAttribute =
+ (UINT16) (Temp8 & 0x03);
+ OutputStruct->Data.Address16.Attribute.Io.TranslationAttribute =
+ (UINT16) ((Temp8 >> 4) & 0x03);
+ }
+ else
+ {
+ /* BUS_NUMBER_RANGE == Address16.Data->ResourceType */
+ /* Nothing needs to be filled in */
+ }
+ }
+
+ /*
+ * Get Granularity (Bytes 6-7)
+ */
+ Buffer += 1;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.Granularity,
+ Buffer);
+
+ /*
+ * Get MinAddressRange (Bytes 8-9)
+ */
+ Buffer += 2;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.MinAddressRange,
+ Buffer);
+
+ /*
+ * Get MaxAddressRange (Bytes 10-11)
+ */
+ Buffer += 2;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.MaxAddressRange,
+ Buffer);
+
+ /*
+ * Get AddressTranslationOffset (Bytes 12-13)
+ */
+ Buffer += 2;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.AddressTranslationOffset,
+ Buffer);
+
+ /*
+ * Get AddressLength (Bytes 14-15)
+ */
+ Buffer += 2;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&OutputStruct->Data.Address16.AddressLength,
+ Buffer);
+
+ /*
+ * Resource Source Index (if present)
+ */
+ Buffer += 2;
+
+ /*
+ * This will leave us pointing to the Resource Source Index
+ * If it is present, then save it off and calculate the
+ * pointer to where the null terminated string goes:
+ * Each Interrupt takes 32-bits + the 5 bytes of the
+ * stream that are default.
+ */
+ if (*BytesConsumed > 16)
+ {
+ /* Dereference the Index */
+
+ Temp8 = *Buffer;
+ OutputStruct->Data.Address16.ResourceSource.Index = (UINT32) Temp8;
+
+ /* Point to the String */
+
+ Buffer += 1;
+
+ /* Point the String pointer to the end of this structure */
+
+ OutputStruct->Data.Address16.ResourceSource.StringPtr =
+ (char *)((UINT8 * )OutputStruct + StructSize);
+
+ TempPtr = (UINT8 *) OutputStruct->Data.Address16.ResourceSource.StringPtr;
+
+ /* Copy the string into the buffer */
+
+ Index = 0;
+
+ while (0x00 != *Buffer)
+ {
+ *TempPtr = *Buffer;
+
+ TempPtr += 1;
+ Buffer += 1;
+ Index += 1;
+ }
+
+ /*
+ * Add the terminating null
+ */
+ *TempPtr = 0x00;
+
+ OutputStruct->Data.Address16.ResourceSource.StringLength = Index + 1;
+
+ /*
+ * In order for the StructSize to fall on a 32-bit boundary,
+ * calculate the length of the string and expand the
+ * StructSize to the next 32-bit boundary.
+ */
+ Temp8 = (UINT8) (Index + 1);
+ StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8);
+ }
+ else
+ {
+ OutputStruct->Data.Address16.ResourceSource.Index = 0x00;
+ OutputStruct->Data.Address16.ResourceSource.StringLength = 0;
+ OutputStruct->Data.Address16.ResourceSource.StringPtr = NULL;
+ }
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsAddress16Stream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsAddress16Stream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT8 *LengthField;
+ UINT8 Temp8;
+ char *TempPointer = NULL;
+ ACPI_SIZE ActualBytes;
+
+
+ ACPI_FUNCTION_TRACE ("RsAddress16Stream");
+
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x88;
+ Buffer += 1;
+
+ /*
+ * Save a pointer to the Length field - to be filled in later
+ */
+ LengthField = Buffer;
+ Buffer += 2;
+
+ /*
+ * Set the Resource Type (Memory, Io, BusNumber)
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Address16.ResourceType & 0x03);
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the general flags
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Address16.ProducerConsumer & 0x01);
+
+ Temp8 |= (LinkedList->Data.Address16.Decode & 0x01) << 1;
+ Temp8 |= (LinkedList->Data.Address16.MinAddressFixed & 0x01) << 2;
+ Temp8 |= (LinkedList->Data.Address16.MaxAddressFixed & 0x01) << 3;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the type specific flags
+ */
+ Temp8 = 0;
+
+ if (ACPI_MEMORY_RANGE == LinkedList->Data.Address16.ResourceType)
+ {
+ Temp8 = (UINT8)
+ (LinkedList->Data.Address16.Attribute.Memory.ReadWriteAttribute &
+ 0x01);
+
+ Temp8 |=
+ (LinkedList->Data.Address16.Attribute.Memory.CacheAttribute &
+ 0x0F) << 1;
+ }
+ else if (ACPI_IO_RANGE == LinkedList->Data.Address16.ResourceType)
+ {
+ Temp8 = (UINT8)
+ (LinkedList->Data.Address16.Attribute.Io.RangeAttribute &
+ 0x03);
+ Temp8 |=
+ (LinkedList->Data.Address16.Attribute.Io.TranslationAttribute &
+ 0x03) << 4;
+ }
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the address space granularity
+ */
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer,
+ &LinkedList->Data.Address16.Granularity);
+ Buffer += 2;
+
+ /*
+ * Set the address range minimum
+ */
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer,
+ &LinkedList->Data.Address16.MinAddressRange);
+ Buffer += 2;
+
+ /*
+ * Set the address range maximum
+ */
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer,
+ &LinkedList->Data.Address16.MaxAddressRange);
+ Buffer += 2;
+
+ /*
+ * Set the address translation offset
+ */
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer,
+ &LinkedList->Data.Address16.AddressTranslationOffset);
+ Buffer += 2;
+
+ /*
+ * Set the address length
+ */
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer,
+ &LinkedList->Data.Address16.AddressLength);
+ Buffer += 2;
+
+ /*
+ * Resource Source Index and Resource Source are optional
+ */
+ if (0 != LinkedList->Data.Address16.ResourceSource.StringLength)
+ {
+ Temp8 = (UINT8) LinkedList->Data.Address16.ResourceSource.Index;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ TempPointer = (char *) Buffer;
+
+ /*
+ * Copy the string
+ */
+ ACPI_STRCPY (TempPointer,
+ LinkedList->Data.Address16.ResourceSource.StringPtr);
+
+ /*
+ * Buffer needs to be set to the length of the sting + one for the
+ * terminating null
+ */
+ Buffer += (ACPI_STRLEN (LinkedList->Data.Address16.ResourceSource.StringPtr) + 1);
+ }
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ ActualBytes = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+ *BytesConsumed = ActualBytes;
+
+ /*
+ * Set the length field to the number of bytes consumed
+ * minus the header size (3 bytes)
+ */
+ ActualBytes -= 3;
+ ACPI_MOVE_UNALIGNED16_TO_16 (LengthField, &ActualBytes);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsAddress32Resource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsAddress32Resource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ UINT8 *Buffer;
+ ACPI_RESOURCE *OutputStruct= (void *) *OutputBuffer;
+ UINT16 Temp16;
+ UINT8 Temp8;
+ UINT8 *TempPtr;
+ ACPI_SIZE StructSize;
+ UINT32 Index;
+
+
+ ACPI_FUNCTION_TRACE ("RsAddress32Resource");
+
+
+ Buffer = ByteStreamBuffer;
+ StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS32);
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ *BytesConsumed = Temp16 + 3;
+
+ OutputStruct->Id = ACPI_RSTYPE_ADDRESS32;
+
+ /*
+ * Get the Resource Type (Byte3)
+ */
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ /* Values 0-2 are valid */
+ if(Temp8 > 2)
+ {
+ return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
+ }
+
+ OutputStruct->Data.Address32.ResourceType = Temp8 & 0x03;
+
+ /*
+ * Get the General Flags (Byte4)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ /*
+ * Producer / Consumer
+ */
+ OutputStruct->Data.Address32.ProducerConsumer = Temp8 & 0x01;
+
+ /*
+ * Decode
+ */
+ OutputStruct->Data.Address32.Decode = (Temp8 >> 1) & 0x01;
+
+ /*
+ * Min Address Fixed
+ */
+ OutputStruct->Data.Address32.MinAddressFixed = (Temp8 >> 2) & 0x01;
+
+ /*
+ * Max Address Fixed
+ */
+ OutputStruct->Data.Address32.MaxAddressFixed = (Temp8 >> 3) & 0x01;
+
+ /*
+ * Get the Type Specific Flags (Byte5)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address32.ResourceType)
+ {
+ OutputStruct->Data.Address32.Attribute.Memory.ReadWriteAttribute =
+ (UINT16) (Temp8 & 0x01);
+
+ OutputStruct->Data.Address32.Attribute.Memory.CacheAttribute =
+ (UINT16) ((Temp8 >> 1) & 0x0F);
+ }
+ else
+ {
+ if (ACPI_IO_RANGE == OutputStruct->Data.Address32.ResourceType)
+ {
+ OutputStruct->Data.Address32.Attribute.Io.RangeAttribute =
+ (UINT16) (Temp8 & 0x03);
+ OutputStruct->Data.Address32.Attribute.Io.TranslationAttribute =
+ (UINT16) ((Temp8 >> 4) & 0x03);
+ }
+ else
+ {
+ /* BUS_NUMBER_RANGE == OutputStruct->Data.Address32.ResourceType */
+ /* Nothing needs to be filled in */
+ }
+ }
+
+ /*
+ * Get Granularity (Bytes 6-9)
+ */
+ Buffer += 1;
+ ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.Granularity,
+ Buffer);
+
+ /*
+ * Get MinAddressRange (Bytes 10-13)
+ */
+ Buffer += 4;
+ ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.MinAddressRange,
+ Buffer);
+
+ /*
+ * Get MaxAddressRange (Bytes 14-17)
+ */
+ Buffer += 4;
+ ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.MaxAddressRange,
+ Buffer);
+
+ /*
+ * Get AddressTranslationOffset (Bytes 18-21)
+ */
+ Buffer += 4;
+ ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.AddressTranslationOffset,
+ Buffer);
+
+ /*
+ * Get AddressLength (Bytes 22-25)
+ */
+ Buffer += 4;
+ ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Address32.AddressLength,
+ Buffer);
+
+ /*
+ * Resource Source Index (if present)
+ */
+ Buffer += 4;
+
+ /*
+ * This will leave us pointing to the Resource Source Index
+ * If it is present, then save it off and calculate the
+ * pointer to where the null terminated string goes:
+ */
+ if (*BytesConsumed > 26)
+ {
+ /* Dereference the Index */
+
+ Temp8 = *Buffer;
+ OutputStruct->Data.Address32.ResourceSource.Index =
+ (UINT32) Temp8;
+
+ /* Point to the String */
+
+ Buffer += 1;
+
+ /* Point the String pointer to the end of this structure */
+
+ OutputStruct->Data.Address32.ResourceSource.StringPtr =
+ (char *)((UINT8 *)OutputStruct + StructSize);
+
+ TempPtr = (UINT8 *) OutputStruct->Data.Address32.ResourceSource.StringPtr;
+
+ /* Copy the string into the buffer */
+
+ Index = 0;
+ while (0x00 != *Buffer)
+ {
+ *TempPtr = *Buffer;
+
+ TempPtr += 1;
+ Buffer += 1;
+ Index += 1;
+ }
+
+ /*
+ * Add the terminating null
+ */
+ *TempPtr = 0x00;
+ OutputStruct->Data.Address32.ResourceSource.StringLength = Index + 1;
+
+ /*
+ * In order for the StructSize to fall on a 32-bit boundary,
+ * calculate the length of the string and expand the
+ * StructSize to the next 32-bit boundary.
+ */
+ Temp8 = (UINT8) (Index + 1);
+ StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8);
+ }
+ else
+ {
+ OutputStruct->Data.Address32.ResourceSource.Index = 0x00;
+ OutputStruct->Data.Address32.ResourceSource.StringLength = 0;
+ OutputStruct->Data.Address32.ResourceSource.StringPtr = NULL;
+ }
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsAddress32Stream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsAddress32Stream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer;
+ UINT16 *LengthField;
+ UINT8 Temp8;
+ char *TempPointer;
+
+
+ ACPI_FUNCTION_TRACE ("RsAddress32Stream");
+
+
+ Buffer = *OutputBuffer;
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x87;
+ Buffer += 1;
+
+ /*
+ * Set a pointer to the Length field - to be filled in later
+ */
+ LengthField = ACPI_CAST_PTR (UINT16, Buffer);
+ Buffer += 2;
+
+ /*
+ * Set the Resource Type (Memory, Io, BusNumber)
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Address32.ResourceType & 0x03);
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the general flags
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Address32.ProducerConsumer & 0x01);
+ Temp8 |= (LinkedList->Data.Address32.Decode & 0x01) << 1;
+ Temp8 |= (LinkedList->Data.Address32.MinAddressFixed & 0x01) << 2;
+ Temp8 |= (LinkedList->Data.Address32.MaxAddressFixed & 0x01) << 3;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the type specific flags
+ */
+ Temp8 = 0;
+
+ if (ACPI_MEMORY_RANGE == LinkedList->Data.Address32.ResourceType)
+ {
+ Temp8 = (UINT8)
+ (LinkedList->Data.Address32.Attribute.Memory.ReadWriteAttribute &
+ 0x01);
+
+ Temp8 |=
+ (LinkedList->Data.Address32.Attribute.Memory.CacheAttribute &
+ 0x0F) << 1;
+ }
+ else if (ACPI_IO_RANGE == LinkedList->Data.Address32.ResourceType)
+ {
+ Temp8 = (UINT8)
+ (LinkedList->Data.Address32.Attribute.Io.RangeAttribute &
+ 0x03);
+ Temp8 |=
+ (LinkedList->Data.Address32.Attribute.Io.TranslationAttribute &
+ 0x03) << 4;
+ }
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the address space granularity
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.Address32.Granularity);
+ Buffer += 4;
+
+ /*
+ * Set the address range minimum
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.Address32.MinAddressRange);
+ Buffer += 4;
+
+ /*
+ * Set the address range maximum
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.Address32.MaxAddressRange);
+ Buffer += 4;
+
+ /*
+ * Set the address translation offset
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.Address32.AddressTranslationOffset);
+ Buffer += 4;
+
+ /*
+ * Set the address length
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.Address32.AddressLength);
+ Buffer += 4;
+
+ /*
+ * Resource Source Index and Resource Source are optional
+ */
+ if (0 != LinkedList->Data.Address32.ResourceSource.StringLength)
+ {
+ Temp8 = (UINT8) LinkedList->Data.Address32.ResourceSource.Index;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ TempPointer = (char *) Buffer;
+
+ /*
+ * Copy the string
+ */
+ ACPI_STRCPY (TempPointer,
+ LinkedList->Data.Address32.ResourceSource.StringPtr);
+
+ /*
+ * Buffer needs to be set to the length of the sting + one for the
+ * terminating null
+ */
+ Buffer += (ACPI_STRLEN (LinkedList->Data.Address32.ResourceSource.StringPtr) + 1);
+ }
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+
+ /*
+ * Set the length field to the number of bytes consumed
+ * minus the header size (3 bytes)
+ */
+ *LengthField = (UINT16) (*BytesConsumed - 3);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsAddress64Resource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsAddress64Resource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ UINT8 *Buffer;
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ UINT16 Temp16;
+ UINT8 Temp8;
+ UINT8 *TempPtr;
+ ACPI_SIZE StructSize;
+ UINT32 Index;
+
+
+ ACPI_FUNCTION_TRACE ("RsAddress64Resource");
+
+
+ Buffer = ByteStreamBuffer;
+ StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_ADDRESS64);
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ *BytesConsumed = Temp16 + 3;
+ OutputStruct->Id = ACPI_RSTYPE_ADDRESS64;
+
+ /*
+ * Get the Resource Type (Byte3)
+ */
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ /* Values 0-2 are valid */
+
+ if(Temp8 > 2)
+ {
+ return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE);
+ }
+
+ OutputStruct->Data.Address64.ResourceType = Temp8 & 0x03;
+
+ /*
+ * Get the General Flags (Byte4)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ /*
+ * Producer / Consumer
+ */
+ OutputStruct->Data.Address64.ProducerConsumer = Temp8 & 0x01;
+
+ /*
+ * Decode
+ */
+ OutputStruct->Data.Address64.Decode = (Temp8 >> 1) & 0x01;
+
+ /*
+ * Min Address Fixed
+ */
+ OutputStruct->Data.Address64.MinAddressFixed = (Temp8 >> 2) & 0x01;
+
+ /*
+ * Max Address Fixed
+ */
+ OutputStruct->Data.Address64.MaxAddressFixed = (Temp8 >> 3) & 0x01;
+
+ /*
+ * Get the Type Specific Flags (Byte5)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ if (ACPI_MEMORY_RANGE == OutputStruct->Data.Address64.ResourceType)
+ {
+ OutputStruct->Data.Address64.Attribute.Memory.ReadWriteAttribute =
+ (UINT16) (Temp8 & 0x01);
+
+ OutputStruct->Data.Address64.Attribute.Memory.CacheAttribute =
+ (UINT16) ((Temp8 >> 1) & 0x0F);
+ }
+ else
+ {
+ if (ACPI_IO_RANGE == OutputStruct->Data.Address64.ResourceType)
+ {
+ OutputStruct->Data.Address64.Attribute.Io.RangeAttribute =
+ (UINT16) (Temp8 & 0x03);
+ OutputStruct->Data.Address64.Attribute.Io.TranslationAttribute =
+ (UINT16) ((Temp8 >> 4) & 0x03);
+ }
+ else
+ {
+ /* BUS_NUMBER_RANGE == OutputStruct->Data.Address64.ResourceType */
+ /* Nothing needs to be filled in */
+ }
+ }
+
+ /*
+ * Get Granularity (Bytes 6-13)
+ */
+ Buffer += 1;
+ ACPI_MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.Granularity,
+ Buffer);
+
+ /*
+ * Get MinAddressRange (Bytes 14-21)
+ */
+ Buffer += 8;
+ ACPI_MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.MinAddressRange,
+ Buffer);
+
+ /*
+ * Get MaxAddressRange (Bytes 22-29)
+ */
+ Buffer += 8;
+ ACPI_MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.MaxAddressRange,
+ Buffer);
+
+ /*
+ * Get AddressTranslationOffset (Bytes 30-37)
+ */
+ Buffer += 8;
+ ACPI_MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.AddressTranslationOffset,
+ Buffer);
+
+ /*
+ * Get AddressLength (Bytes 38-45)
+ */
+ Buffer += 8;
+ ACPI_MOVE_UNALIGNED64_TO_64 (&OutputStruct->Data.Address64.AddressLength,
+ Buffer);
+
+ /*
+ * Resource Source Index (if present)
+ */
+ Buffer += 8;
+
+ /*
+ * This will leave us pointing to the Resource Source Index
+ * If it is present, then save it off and calculate the
+ * pointer to where the null terminated string goes:
+ * Each Interrupt takes 32-bits + the 5 bytes of the
+ * stream that are default.
+ */
+ if (*BytesConsumed > 46)
+ {
+ /* Dereference the Index */
+
+ Temp8 = *Buffer;
+ OutputStruct->Data.Address64.ResourceSource.Index =
+ (UINT32) Temp8;
+
+ /* Point to the String */
+
+ Buffer += 1;
+
+ /* Point the String pointer to the end of this structure */
+
+ OutputStruct->Data.Address64.ResourceSource.StringPtr =
+ (char *)((UINT8 *)OutputStruct + StructSize);
+
+ TempPtr = (UINT8 *) OutputStruct->Data.Address64.ResourceSource.StringPtr;
+
+ /* Copy the string into the buffer */
+
+ Index = 0;
+ while (0x00 != *Buffer)
+ {
+ *TempPtr = *Buffer;
+
+ TempPtr += 1;
+ Buffer += 1;
+ Index += 1;
+ }
+
+ /*
+ * Add the terminating null
+ */
+ *TempPtr = 0x00;
+
+ OutputStruct->Data.Address64.ResourceSource.StringLength = Index + 1;
+
+ /*
+ * In order for the StructSize to fall on a 32-bit boundary,
+ * calculate the length of the string and expand the
+ * StructSize to the next 32-bit boundary.
+ */
+ Temp8 = (UINT8) (Index + 1);
+ StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8);
+ }
+ else
+ {
+ OutputStruct->Data.Address64.ResourceSource.Index = 0x00;
+ OutputStruct->Data.Address64.ResourceSource.StringLength = 0;
+ OutputStruct->Data.Address64.ResourceSource.StringPtr = NULL;
+ }
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsAddress64Stream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsAddress64Stream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer;
+ UINT16 *LengthField;
+ UINT8 Temp8;
+ char *TempPointer;
+
+
+ ACPI_FUNCTION_TRACE ("RsAddress64Stream");
+
+
+ Buffer = *OutputBuffer;
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x8A;
+ Buffer += 1;
+
+ /*
+ * Set a pointer to the Length field - to be filled in later
+ */
+
+ LengthField = ACPI_CAST_PTR (UINT16, Buffer);
+ Buffer += 2;
+
+ /*
+ * Set the Resource Type (Memory, Io, BusNumber)
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Address64.ResourceType & 0x03);
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the general flags
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Address64.ProducerConsumer & 0x01);
+ Temp8 |= (LinkedList->Data.Address64.Decode & 0x01) << 1;
+ Temp8 |= (LinkedList->Data.Address64.MinAddressFixed & 0x01) << 2;
+ Temp8 |= (LinkedList->Data.Address64.MaxAddressFixed & 0x01) << 3;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the type specific flags
+ */
+ Temp8 = 0;
+
+ if (ACPI_MEMORY_RANGE == LinkedList->Data.Address64.ResourceType)
+ {
+ Temp8 = (UINT8)
+ (LinkedList->Data.Address64.Attribute.Memory.ReadWriteAttribute &
+ 0x01);
+
+ Temp8 |=
+ (LinkedList->Data.Address64.Attribute.Memory.CacheAttribute &
+ 0x0F) << 1;
+ }
+ else if (ACPI_IO_RANGE == LinkedList->Data.Address64.ResourceType)
+ {
+ Temp8 = (UINT8)
+ (LinkedList->Data.Address64.Attribute.Io.RangeAttribute &
+ 0x03);
+ Temp8 |=
+ (LinkedList->Data.Address64.Attribute.Io.RangeAttribute &
+ 0x03) << 4;
+ }
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the address space granularity
+ */
+ ACPI_MOVE_UNALIGNED64_TO_64 (Buffer,
+ &LinkedList->Data.Address64.Granularity);
+ Buffer += 8;
+
+ /*
+ * Set the address range minimum
+ */
+ ACPI_MOVE_UNALIGNED64_TO_64 (Buffer,
+ &LinkedList->Data.Address64.MinAddressRange);
+ Buffer += 8;
+
+ /*
+ * Set the address range maximum
+ */
+ ACPI_MOVE_UNALIGNED64_TO_64 (Buffer,
+ &LinkedList->Data.Address64.MaxAddressRange);
+ Buffer += 8;
+
+ /*
+ * Set the address translation offset
+ */
+ ACPI_MOVE_UNALIGNED64_TO_64 (Buffer,
+ &LinkedList->Data.Address64.AddressTranslationOffset);
+ Buffer += 8;
+
+ /*
+ * Set the address length
+ */
+ ACPI_MOVE_UNALIGNED64_TO_64 (Buffer,
+ &LinkedList->Data.Address64.AddressLength);
+ Buffer += 8;
+
+ /*
+ * Resource Source Index and Resource Source are optional
+ */
+ if (0 != LinkedList->Data.Address64.ResourceSource.StringLength)
+ {
+ Temp8 = (UINT8) LinkedList->Data.Address64.ResourceSource.Index;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ TempPointer = (char *) Buffer;
+
+ /*
+ * Copy the string
+ */
+ ACPI_STRCPY (TempPointer, LinkedList->Data.Address64.ResourceSource.StringPtr);
+
+ /*
+ * Buffer needs to be set to the length of the sting + one for the
+ * terminating null
+ */
+ Buffer += (ACPI_STRLEN (LinkedList->Data.Address64.ResourceSource.StringPtr) + 1);
+ }
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+
+ /*
+ * Set the length field to the number of bytes consumed
+ * minus the header size (3 bytes)
+ */
+ *LengthField = (UINT16) (*BytesConsumed - 3);
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/rscalc.c b/sys/contrib/dev/acpica/rscalc.c
new file mode 100644
index 0000000..5d2277a
--- /dev/null
+++ b/sys/contrib/dev/acpica/rscalc.c
@@ -0,0 +1,953 @@
+/*******************************************************************************
+ *
+ * Module Name: rscalc - Calculate stream and list lengths
+ * $Revision: 47 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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)) ||
+ ((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 does not include the
+ * terminating NULL, add 1
+ */
+ TempSizeNeeded += ((ACPI_SIZE) (*SubObjectList)->String.Length + 1);
+ }
+ 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/rscreate.c b/sys/contrib/dev/acpica/rscreate.c
new file mode 100644
index 0000000..83fee4f
--- /dev/null
+++ b/sys/contrib/dev/acpica/rscreate.c
@@ -0,0 +1,522 @@
+/*******************************************************************************
+ *
+ * Module Name: rscreate - Create resource lists/tables
+ * $Revision: 64 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __RSCREATE_C__
+
+#include "acpi.h"
+#include "acresrc.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rscreate")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsCreateResourceList
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource byte stream
+ * OutputBuffer - Pointer to the user's buffer
+ *
+ * RETURN: Status - AE_OK if okay, else a valid ACPI_STATUS code
+ * If OutputBuffer is not large enough, OutputBufferLength
+ * indicates how large OutputBuffer should be, else it
+ * indicates how may UINT8 elements of OutputBuffer are valid.
+ *
+ * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method
+ * execution and parses the stream to create a linked list
+ * of device resources.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsCreateResourceList (
+ ACPI_OPERAND_OBJECT *ByteStreamBuffer,
+ ACPI_BUFFER *OutputBuffer)
+{
+
+ ACPI_STATUS Status;
+ UINT8 *ByteStreamStart;
+ ACPI_SIZE ListSizeNeeded = 0;
+ UINT32 ByteStreamBufferLength;
+
+
+ ACPI_FUNCTION_TRACE ("RsCreateResourceList");
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ByteStreamBuffer = %p\n",
+ ByteStreamBuffer));
+
+ /*
+ * Params already validated, so we don't re-validate here
+ */
+ ByteStreamBufferLength = ByteStreamBuffer->Buffer.Length;
+ ByteStreamStart = ByteStreamBuffer->Buffer.Pointer;
+
+ /*
+ * Pass the ByteStreamBuffer into a module that can calculate
+ * the buffer size needed for the linked list
+ */
+ Status = AcpiRsGetListLength (ByteStreamStart, ByteStreamBufferLength,
+ &ListSizeNeeded);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n",
+ Status, (UINT32) ListSizeNeeded));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Do the conversion */
+
+ Status = AcpiRsByteStreamToList (ByteStreamStart, ByteStreamBufferLength,
+ OutputBuffer->Pointer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
+ OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsCreatePciRoutingTable
+ *
+ * PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT
+ * package
+ * OutputBuffer - Pointer to the user's buffer
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
+ * If the OutputBuffer is too small, the error will be
+ * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
+ * to the size buffer needed.
+ *
+ * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a
+ * linked list of PCI interrupt descriptions
+ *
+ * NOTE: It is the caller's responsibility to ensure that the start of the
+ * output buffer is aligned properly (if necessary).
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsCreatePciRoutingTable (
+ ACPI_OPERAND_OBJECT *PackageObject,
+ ACPI_BUFFER *OutputBuffer)
+{
+ UINT8 *Buffer;
+ ACPI_OPERAND_OBJECT **TopObjectList;
+ ACPI_OPERAND_OBJECT **SubObjectList;
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_SIZE BufferSizeNeeded = 0;
+ UINT32 NumberOfElements;
+ UINT32 Index;
+ ACPI_PCI_ROUTING_TABLE *UserPrt;
+ ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
+ ACPI_BUFFER PathBuffer;
+
+
+ ACPI_FUNCTION_TRACE ("RsCreatePciRoutingTable");
+
+
+ /* Params already validated, so we don't re-validate here */
+
+ /*
+ * Get the required buffer length
+ */
+ Status = AcpiRsGetPciRoutingTableLength (PackageObject,
+ &BufferSizeNeeded);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n",
+ (UINT32) BufferSizeNeeded));
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Loop through the ACPI_INTERNAL_OBJECTS - Each object
+ * should be a package that in turn contains an
+ * ACPI_INTEGER Address, a UINT8 Pin, a Name and a UINT8 SourceIndex.
+ */
+ TopObjectList = PackageObject->Package.Elements;
+ NumberOfElements = PackageObject->Package.Count;
+ Buffer = OutputBuffer->Pointer;
+ UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
+
+ for (Index = 0; Index < NumberOfElements; Index++)
+ {
+ /*
+ * Point UserPrt past this current structure
+ *
+ * NOTE: On the first iteration, UserPrt->Length will
+ * be zero because we cleared the return buffer earlier
+ */
+ Buffer += UserPrt->Length;
+ UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
+
+ /*
+ * Fill in the Length field with the information we have at this point.
+ * The minus four is to subtract the size of the UINT8 Source[4] member
+ * because it is added below.
+ */
+ UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
+
+ /*
+ * Each element of the top-level package must also be a package
+ */
+ if (ACPI_GET_OBJECT_TYPE (*TopObjectList) != ACPI_TYPE_PACKAGE)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "(PRT[%X]) Need sub-package, found %s\n",
+ Index, AcpiUtGetObjectTypeName (*TopObjectList)));
+ return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+ }
+
+ /* Each sub-package must be of length 4 */
+
+ if ((*TopObjectList)->Package.Count != 4)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "(PRT[%X]) Need package of length 4, found length %d\n",
+ Index, (*TopObjectList)->Package.Count));
+ return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT);
+ }
+
+ /*
+ * Dereference the sub-package.
+ * The SubObjectList will now point to an array of the four IRQ
+ * elements: [Address, Pin, Source, SourceIndex]
+ */
+ SubObjectList = (*TopObjectList)->Package.Elements;
+
+ /*
+ * 1) First subobject: Dereference the PRT.Address
+ */
+ ObjDesc = SubObjectList[0];
+ if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)
+ {
+ UserPrt->Address = ObjDesc->Integer.Value;
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "(PRT[%X].Address) Need Integer, found %s\n",
+ Index, AcpiUtGetObjectTypeName (ObjDesc)));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ /*
+ * 2) Second subobject: Dereference the PRT.Pin
+ */
+ ObjDesc = SubObjectList[1];
+ if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)
+ {
+ UserPrt->Pin = (UINT32) ObjDesc->Integer.Value;
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "(PRT[%X].Pin) Need Integer, found %s\n",
+ Index, AcpiUtGetObjectTypeName (ObjDesc)));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ /*
+ * 3) Third subobject: Dereference the PRT.SourceName
+ */
+ ObjDesc = SubObjectList[2];
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
+ {
+ case ACPI_TYPE_LOCAL_REFERENCE:
+
+ if (ObjDesc->Reference.Opcode != AML_INT_NAMEPATH_OP)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "(PRT[%X].Source) Need name, found reference op %X\n",
+ Index, ObjDesc->Reference.Opcode));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ Node = ObjDesc->Reference.Node;
+
+ /* Use *remaining* length of the buffer as max for pathname */
+
+ PathBuffer.Length = OutputBuffer->Length -
+ (UINT32) ((UINT8 *) UserPrt->Source -
+ (UINT8 *) OutputBuffer->Pointer);
+ PathBuffer.Pointer = UserPrt->Source;
+
+ Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer);
+
+ UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; /* include null terminator */
+ break;
+
+
+ case ACPI_TYPE_STRING:
+
+ ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer);
+
+ /* Add to the Length field the length of the string (add 1 for terminator) */
+
+ UserPrt->Length += ObjDesc->String.Length + 1;
+ break;
+
+
+ case ACPI_TYPE_INTEGER:
+ /*
+ * If this is a number, then the Source Name is NULL, since the
+ * entire buffer was zeroed out, we can leave this alone.
+ *
+ * Add to the Length field the length of the UINT32 NULL
+ */
+ UserPrt->Length += sizeof (UINT32);
+ break;
+
+
+ default:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "(PRT[%X].Source) Need Ref/String/Integer, found %s\n",
+ Index, AcpiUtGetObjectTypeName (ObjDesc)));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ /* Now align the current length */
+
+ UserPrt->Length = ACPI_ROUND_UP_TO_64BITS (UserPrt->Length);
+
+ /*
+ * 4) Fourth subobject: Dereference the PRT.SourceIndex
+ */
+ ObjDesc = SubObjectList[3];
+ if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)
+ {
+ UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value;
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "(PRT[%X].SourceIndex) Need Integer, found %s\n",
+ Index, AcpiUtGetObjectTypeName (ObjDesc)));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ /* Point to the next ACPI_OPERAND_OBJECT in the top level package */
+
+ TopObjectList++;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
+ OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsCreateByteStream
+ *
+ * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's buffer
+ *
+ * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
+ * If the OutputBuffer is too small, the error will be
+ * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
+ * to the size buffer needed.
+ *
+ * DESCRIPTION: Takes the linked list of device resources and
+ * creates a bytestream to be used as input for the
+ * _SRS control method.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsCreateByteStream (
+ ACPI_RESOURCE *LinkedListBuffer,
+ ACPI_BUFFER *OutputBuffer)
+{
+ ACPI_STATUS Status;
+ ACPI_SIZE ByteStreamSizeNeeded = 0;
+
+
+ ACPI_FUNCTION_TRACE ("RsCreateByteStream");
+
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n",
+ LinkedListBuffer));
+
+ /*
+ * Params already validated, so we don't re-validate here
+ *
+ * Pass the LinkedListBuffer into a module that calculates
+ * the buffer size needed for the byte stream.
+ */
+ Status = AcpiRsGetByteStreamLength (LinkedListBuffer,
+ &ByteStreamSizeNeeded);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ByteStreamSizeNeeded=%X, %s\n",
+ (UINT32) ByteStreamSizeNeeded, AcpiFormatException (Status)));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (OutputBuffer, ByteStreamSizeNeeded);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Do the conversion */
+
+ Status = AcpiRsListToByteStream (LinkedListBuffer, ByteStreamSizeNeeded,
+ OutputBuffer->Pointer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
+ OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/rsdump.c b/sys/contrib/dev/acpica/rsdump.c
new file mode 100644
index 0000000..23b9e49
--- /dev/null
+++ b/sys/contrib/dev/acpica/rsdump.c
@@ -0,0 +1,1255 @@
+/*******************************************************************************
+ *
+ * Module Name: rsdump - Functions to display the resource structures.
+ * $Revision: 36 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __RSDUMP_C__
+
+#include "acpi.h"
+#include "acresrc.h"
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsdump")
+
+
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpIrq
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpIrq (
+ ACPI_RESOURCE_DATA *Data)
+{
+ ACPI_RESOURCE_IRQ *IrqData = (ACPI_RESOURCE_IRQ *) Data;
+ UINT8 Index = 0;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ AcpiOsPrintf ("IRQ Resource\n");
+
+ AcpiOsPrintf (" %s Triggered\n",
+ ACPI_LEVEL_SENSITIVE == IrqData->EdgeLevel ? "Level" : "Edge");
+
+ AcpiOsPrintf (" Active %s\n",
+ ACPI_ACTIVE_LOW == IrqData->ActiveHighLow ? "Low" : "High");
+
+ AcpiOsPrintf (" %s\n",
+ ACPI_SHARED == IrqData->SharedExclusive ? "Shared" : "Exclusive");
+
+ AcpiOsPrintf (" %X Interrupts ( ", IrqData->NumberOfInterrupts);
+
+ for (Index = 0; Index < IrqData->NumberOfInterrupts; Index++)
+ {
+ AcpiOsPrintf ("%X ", IrqData->Interrupts[Index]);
+ }
+
+ AcpiOsPrintf (")\n");
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpDma
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpDma (
+ ACPI_RESOURCE_DATA *Data)
+{
+ ACPI_RESOURCE_DMA *DmaData = (ACPI_RESOURCE_DMA *) Data;
+ UINT8 Index = 0;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ AcpiOsPrintf ("DMA Resource\n");
+
+ switch (DmaData->Type)
+ {
+ case ACPI_COMPATIBILITY:
+ AcpiOsPrintf (" Compatibility mode\n");
+ break;
+
+ case ACPI_TYPE_A:
+ AcpiOsPrintf (" Type A\n");
+ break;
+
+ case ACPI_TYPE_B:
+ AcpiOsPrintf (" Type B\n");
+ break;
+
+ case ACPI_TYPE_F:
+ AcpiOsPrintf (" Type F\n");
+ break;
+
+ default:
+ AcpiOsPrintf (" Invalid DMA type\n");
+ break;
+ }
+
+ AcpiOsPrintf (" %sBus Master\n",
+ ACPI_BUS_MASTER == DmaData->BusMaster ? "" : "Not a ");
+
+
+ switch (DmaData->Transfer)
+ {
+ case ACPI_TRANSFER_8:
+ AcpiOsPrintf (" 8-bit only transfer\n");
+ break;
+
+ case ACPI_TRANSFER_8_16:
+ AcpiOsPrintf (" 8 and 16-bit transfer\n");
+ break;
+
+ case ACPI_TRANSFER_16:
+ AcpiOsPrintf (" 16 bit only transfer\n");
+ break;
+
+ default:
+ AcpiOsPrintf (" Invalid transfer preference\n");
+ break;
+ }
+
+ AcpiOsPrintf (" Number of Channels: %X ( ", DmaData->NumberOfChannels);
+
+ for (Index = 0; Index < DmaData->NumberOfChannels; Index++)
+ {
+ AcpiOsPrintf ("%X ", DmaData->Channels[Index]);
+ }
+
+ AcpiOsPrintf (")\n");
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpStartDependFns
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpStartDependFns (
+ ACPI_RESOURCE_DATA *Data)
+{
+ ACPI_RESOURCE_START_DPF *SdfData = (ACPI_RESOURCE_START_DPF *) Data;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ AcpiOsPrintf ("Start Dependent Functions Resource\n");
+
+ switch (SdfData->CompatibilityPriority)
+ {
+ case ACPI_GOOD_CONFIGURATION:
+ AcpiOsPrintf (" Good configuration\n");
+ break;
+
+ case ACPI_ACCEPTABLE_CONFIGURATION:
+ AcpiOsPrintf (" Acceptable configuration\n");
+ break;
+
+ case ACPI_SUB_OPTIMAL_CONFIGURATION:
+ AcpiOsPrintf (" Sub-optimal configuration\n");
+ break;
+
+ default:
+ AcpiOsPrintf (" Invalid compatibility priority\n");
+ break;
+ }
+
+ switch(SdfData->PerformanceRobustness)
+ {
+ case ACPI_GOOD_CONFIGURATION:
+ AcpiOsPrintf (" Good configuration\n");
+ break;
+
+ case ACPI_ACCEPTABLE_CONFIGURATION:
+ AcpiOsPrintf (" Acceptable configuration\n");
+ break;
+
+ case ACPI_SUB_OPTIMAL_CONFIGURATION:
+ AcpiOsPrintf (" Sub-optimal configuration\n");
+ break;
+
+ default:
+ AcpiOsPrintf (" Invalid performance "
+ "robustness preference\n");
+ break;
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpIo
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpIo (
+ ACPI_RESOURCE_DATA *Data)
+{
+ ACPI_RESOURCE_IO *IoData = (ACPI_RESOURCE_IO *) Data;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ AcpiOsPrintf ("Io Resource\n");
+
+ AcpiOsPrintf (" %d bit decode\n",
+ ACPI_DECODE_16 == IoData->IoDecode ? 16 : 10);
+
+ AcpiOsPrintf (" Range minimum base: %08X\n",
+ IoData->MinBaseAddress);
+
+ AcpiOsPrintf (" Range maximum base: %08X\n",
+ IoData->MaxBaseAddress);
+
+ AcpiOsPrintf (" Alignment: %08X\n",
+ IoData->Alignment);
+
+ AcpiOsPrintf (" Range Length: %08X\n",
+ IoData->RangeLength);
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpFixedIo
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpFixedIo (
+ ACPI_RESOURCE_DATA *Data)
+{
+ ACPI_RESOURCE_FIXED_IO *FixedIoData = (ACPI_RESOURCE_FIXED_IO *) Data;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ AcpiOsPrintf ("Fixed Io Resource\n");
+ AcpiOsPrintf (" Range base address: %08X",
+ FixedIoData->BaseAddress);
+
+ AcpiOsPrintf (" Range length: %08X",
+ FixedIoData->RangeLength);
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpVendorSpecific
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpVendorSpecific (
+ ACPI_RESOURCE_DATA *Data)
+{
+ ACPI_RESOURCE_VENDOR *VendorData = (ACPI_RESOURCE_VENDOR *) Data;
+ UINT16 Index = 0;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ AcpiOsPrintf ("Vendor Specific Resource\n");
+
+ AcpiOsPrintf (" Length: %08X\n", VendorData->Length);
+
+ for (Index = 0; Index < VendorData->Length; Index++)
+ {
+ AcpiOsPrintf (" Byte %X: %08X\n",
+ Index, VendorData->Reserved[Index]);
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpMemory24
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpMemory24 (
+ ACPI_RESOURCE_DATA *Data)
+{
+ ACPI_RESOURCE_MEM24 *Memory24Data = (ACPI_RESOURCE_MEM24 *) Data;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ AcpiOsPrintf ("24-Bit Memory Range Resource\n");
+
+ AcpiOsPrintf (" Read%s\n",
+ ACPI_READ_WRITE_MEMORY ==
+ Memory24Data->ReadWriteAttribute ?
+ "/Write" : " only");
+
+ AcpiOsPrintf (" Range minimum base: %08X\n",
+ Memory24Data->MinBaseAddress);
+
+ AcpiOsPrintf (" Range maximum base: %08X\n",
+ Memory24Data->MaxBaseAddress);
+
+ AcpiOsPrintf (" Alignment: %08X\n",
+ Memory24Data->Alignment);
+
+ AcpiOsPrintf (" Range length: %08X\n",
+ Memory24Data->RangeLength);
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpMemory32
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpMemory32 (
+ ACPI_RESOURCE_DATA *Data)
+{
+ ACPI_RESOURCE_MEM32 *Memory32Data = (ACPI_RESOURCE_MEM32 *) Data;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ AcpiOsPrintf ("32-Bit Memory Range Resource\n");
+
+ AcpiOsPrintf (" Read%s\n",
+ ACPI_READ_WRITE_MEMORY ==
+ Memory32Data->ReadWriteAttribute ?
+ "/Write" : " only");
+
+ AcpiOsPrintf (" Range minimum base: %08X\n",
+ Memory32Data->MinBaseAddress);
+
+ AcpiOsPrintf (" Range maximum base: %08X\n",
+ Memory32Data->MaxBaseAddress);
+
+ AcpiOsPrintf (" Alignment: %08X\n",
+ Memory32Data->Alignment);
+
+ AcpiOsPrintf (" Range length: %08X\n",
+ Memory32Data->RangeLength);
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpFixedMemory32
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpFixedMemory32 (
+ ACPI_RESOURCE_DATA *Data)
+{
+ ACPI_RESOURCE_FIXED_MEM32 *FixedMemory32Data = (ACPI_RESOURCE_FIXED_MEM32 *) Data;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ AcpiOsPrintf ("32-Bit Fixed Location Memory Range Resource\n");
+
+ AcpiOsPrintf (" Read%s\n",
+ ACPI_READ_WRITE_MEMORY ==
+ FixedMemory32Data->ReadWriteAttribute ?
+ "/Write" : " Only");
+
+ AcpiOsPrintf (" Range base address: %08X\n",
+ FixedMemory32Data->RangeBaseAddress);
+
+ AcpiOsPrintf (" Range length: %08X\n",
+ FixedMemory32Data->RangeLength);
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpAddress16
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpAddress16 (
+ ACPI_RESOURCE_DATA *Data)
+{
+ ACPI_RESOURCE_ADDRESS16 *Address16Data = (ACPI_RESOURCE_ADDRESS16 *) Data;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ AcpiOsPrintf ("16-Bit Address Space Resource\n");
+ AcpiOsPrintf (" Resource Type: ");
+
+ switch (Address16Data->ResourceType)
+ {
+ case ACPI_MEMORY_RANGE:
+
+ AcpiOsPrintf ("Memory Range\n");
+
+ switch (Address16Data->Attribute.Memory.CacheAttribute)
+ {
+ case ACPI_NON_CACHEABLE_MEMORY:
+ AcpiOsPrintf (" Type Specific: "
+ "Noncacheable memory\n");
+ break;
+
+ case ACPI_CACHABLE_MEMORY:
+ AcpiOsPrintf (" Type Specific: "
+ "Cacheable memory\n");
+ break;
+
+ case ACPI_WRITE_COMBINING_MEMORY:
+ AcpiOsPrintf (" Type Specific: "
+ "Write-combining memory\n");
+ break;
+
+ case ACPI_PREFETCHABLE_MEMORY:
+ AcpiOsPrintf (" Type Specific: "
+ "Prefetchable memory\n");
+ break;
+
+ default:
+ AcpiOsPrintf (" Type Specific: "
+ "Invalid cache attribute\n");
+ break;
+ }
+
+ AcpiOsPrintf (" Type Specific: Read%s\n",
+ ACPI_READ_WRITE_MEMORY ==
+ Address16Data->Attribute.Memory.ReadWriteAttribute ?
+ "/Write" : " Only");
+ break;
+
+ case ACPI_IO_RANGE:
+
+ AcpiOsPrintf ("I/O Range\n");
+
+ switch (Address16Data->Attribute.Io.RangeAttribute)
+ {
+ case ACPI_NON_ISA_ONLY_RANGES:
+ AcpiOsPrintf (" Type Specific: "
+ "Non-ISA Io Addresses\n");
+ break;
+
+ case ACPI_ISA_ONLY_RANGES:
+ AcpiOsPrintf (" Type Specific: "
+ "ISA Io Addresses\n");
+ break;
+
+ case ACPI_ENTIRE_RANGE:
+ AcpiOsPrintf (" Type Specific: "
+ "ISA and non-ISA Io Addresses\n");
+ break;
+
+ default:
+ AcpiOsPrintf (" Type Specific: "
+ "Invalid range attribute\n");
+ break;
+ }
+
+ AcpiOsPrintf (" Type Specific: %s Translation\n",
+ ACPI_SPARSE_TRANSLATION ==
+ Address16Data->Attribute.Io.TranslationAttribute ?
+ "Sparse" : "Dense");
+ break;
+
+ case ACPI_BUS_NUMBER_RANGE:
+
+ AcpiOsPrintf ("Bus Number Range\n");
+ break;
+
+ default:
+
+ AcpiOsPrintf ("Invalid resource type. Exiting.\n");
+ return;
+ }
+
+ AcpiOsPrintf (" Resource %s\n",
+ ACPI_CONSUMER == Address16Data->ProducerConsumer ?
+ "Consumer" : "Producer");
+
+ AcpiOsPrintf (" %s decode\n",
+ ACPI_SUB_DECODE == Address16Data->Decode ?
+ "Subtractive" : "Positive");
+
+ AcpiOsPrintf (" Min address is %s fixed\n",
+ ACPI_ADDRESS_FIXED == Address16Data->MinAddressFixed ?
+ "" : "not");
+
+ AcpiOsPrintf (" Max address is %s fixed\n",
+ ACPI_ADDRESS_FIXED == Address16Data->MaxAddressFixed ?
+ "" : "not");
+
+ AcpiOsPrintf (" Granularity: %08X\n",
+ Address16Data->Granularity);
+
+ AcpiOsPrintf (" Address range min: %08X\n",
+ Address16Data->MinAddressRange);
+
+ AcpiOsPrintf (" Address range max: %08X\n",
+ Address16Data->MaxAddressRange);
+
+ AcpiOsPrintf (" Address translation offset: %08X\n",
+ Address16Data->AddressTranslationOffset);
+
+ AcpiOsPrintf (" Address Length: %08X\n",
+ Address16Data->AddressLength);
+
+ if (0xFF != Address16Data->ResourceSource.Index)
+ {
+ AcpiOsPrintf (" Resource Source Index: %X\n",
+ Address16Data->ResourceSource.Index);
+ AcpiOsPrintf (" Resource Source: %s\n",
+ Address16Data->ResourceSource.StringPtr);
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpAddress32
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpAddress32 (
+ ACPI_RESOURCE_DATA *Data)
+{
+ ACPI_RESOURCE_ADDRESS32 *Address32Data = (ACPI_RESOURCE_ADDRESS32 *) Data;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ AcpiOsPrintf ("32-Bit Address Space Resource\n");
+
+ switch (Address32Data->ResourceType)
+ {
+ case ACPI_MEMORY_RANGE:
+
+ AcpiOsPrintf (" Resource Type: Memory Range\n");
+
+ switch (Address32Data->Attribute.Memory.CacheAttribute)
+ {
+ case ACPI_NON_CACHEABLE_MEMORY:
+ AcpiOsPrintf (" Type Specific: "
+ "Noncacheable memory\n");
+ break;
+
+ case ACPI_CACHABLE_MEMORY:
+ AcpiOsPrintf (" Type Specific: "
+ "Cacheable memory\n");
+ break;
+
+ case ACPI_WRITE_COMBINING_MEMORY:
+ AcpiOsPrintf (" Type Specific: "
+ "Write-combining memory\n");
+ break;
+
+ case ACPI_PREFETCHABLE_MEMORY:
+ AcpiOsPrintf (" Type Specific: "
+ "Prefetchable memory\n");
+ break;
+
+ default:
+ AcpiOsPrintf (" Type Specific: "
+ "Invalid cache attribute\n");
+ break;
+ }
+
+ AcpiOsPrintf (" Type Specific: Read%s\n",
+ ACPI_READ_WRITE_MEMORY ==
+ Address32Data->Attribute.Memory.ReadWriteAttribute ?
+ "/Write" : " Only");
+ break;
+
+ case ACPI_IO_RANGE:
+
+ AcpiOsPrintf (" Resource Type: Io Range\n");
+
+ switch (Address32Data->Attribute.Io.RangeAttribute)
+ {
+ case ACPI_NON_ISA_ONLY_RANGES:
+ AcpiOsPrintf (" Type Specific: "
+ "Non-ISA Io Addresses\n");
+ break;
+
+ case ACPI_ISA_ONLY_RANGES:
+ AcpiOsPrintf (" Type Specific: "
+ "ISA Io Addresses\n");
+ break;
+
+ case ACPI_ENTIRE_RANGE:
+ AcpiOsPrintf (" Type Specific: "
+ "ISA and non-ISA Io Addresses\n");
+ break;
+
+ default:
+ AcpiOsPrintf (" Type Specific: "
+ "Invalid Range attribute");
+ break;
+ }
+
+ AcpiOsPrintf (" Type Specific: %s Translation\n",
+ ACPI_SPARSE_TRANSLATION ==
+ Address32Data->Attribute.Io.TranslationAttribute ?
+ "Sparse" : "Dense");
+ break;
+
+ case ACPI_BUS_NUMBER_RANGE:
+
+ AcpiOsPrintf (" Resource Type: Bus Number Range\n");
+ break;
+
+ default:
+
+ AcpiOsPrintf (" Invalid Resource Type..exiting.\n");
+ return;
+ }
+
+ AcpiOsPrintf (" Resource %s\n",
+ ACPI_CONSUMER == Address32Data->ProducerConsumer ?
+ "Consumer" : "Producer");
+
+ AcpiOsPrintf (" %s decode\n",
+ ACPI_SUB_DECODE == Address32Data->Decode ?
+ "Subtractive" : "Positive");
+
+ AcpiOsPrintf (" Min address is %s fixed\n",
+ ACPI_ADDRESS_FIXED == Address32Data->MinAddressFixed ?
+ "" : "not ");
+
+ AcpiOsPrintf (" Max address is %s fixed\n",
+ ACPI_ADDRESS_FIXED == Address32Data->MaxAddressFixed ?
+ "" : "not ");
+
+ AcpiOsPrintf (" Granularity: %08X\n",
+ Address32Data->Granularity);
+
+ AcpiOsPrintf (" Address range min: %08X\n",
+ Address32Data->MinAddressRange);
+
+ AcpiOsPrintf (" Address range max: %08X\n",
+ Address32Data->MaxAddressRange);
+
+ AcpiOsPrintf (" Address translation offset: %08X\n",
+ Address32Data->AddressTranslationOffset);
+
+ AcpiOsPrintf (" Address Length: %08X\n",
+ Address32Data->AddressLength);
+
+ if(0xFF != Address32Data->ResourceSource.Index)
+ {
+ AcpiOsPrintf (" Resource Source Index: %X\n",
+ Address32Data->ResourceSource.Index);
+ AcpiOsPrintf (" Resource Source: %s\n",
+ Address32Data->ResourceSource.StringPtr);
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpAddress64
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpAddress64 (
+ ACPI_RESOURCE_DATA *Data)
+{
+ ACPI_RESOURCE_ADDRESS64 *Address64Data = (ACPI_RESOURCE_ADDRESS64 *) Data;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ AcpiOsPrintf ("64-Bit Address Space Resource\n");
+
+ switch (Address64Data->ResourceType)
+ {
+ case ACPI_MEMORY_RANGE:
+
+ AcpiOsPrintf (" Resource Type: Memory Range\n");
+
+ switch (Address64Data->Attribute.Memory.CacheAttribute)
+ {
+ case ACPI_NON_CACHEABLE_MEMORY:
+ AcpiOsPrintf (" Type Specific: "
+ "Noncacheable memory\n");
+ break;
+
+ case ACPI_CACHABLE_MEMORY:
+ AcpiOsPrintf (" Type Specific: "
+ "Cacheable memory\n");
+ break;
+
+ case ACPI_WRITE_COMBINING_MEMORY:
+ AcpiOsPrintf (" Type Specific: "
+ "Write-combining memory\n");
+ break;
+
+ case ACPI_PREFETCHABLE_MEMORY:
+ AcpiOsPrintf (" Type Specific: "
+ "Prefetchable memory\n");
+ break;
+
+ default:
+ AcpiOsPrintf (" Type Specific: "
+ "Invalid cache attribute\n");
+ break;
+ }
+
+ AcpiOsPrintf (" Type Specific: Read%s\n",
+ ACPI_READ_WRITE_MEMORY ==
+ Address64Data->Attribute.Memory.ReadWriteAttribute ?
+ "/Write" : " Only");
+ break;
+
+ case ACPI_IO_RANGE:
+
+ AcpiOsPrintf (" Resource Type: Io Range\n");
+
+ switch (Address64Data->Attribute.Io.RangeAttribute)
+ {
+ case ACPI_NON_ISA_ONLY_RANGES:
+ AcpiOsPrintf (" Type Specific: "
+ "Non-ISA Io Addresses\n");
+ break;
+
+ case ACPI_ISA_ONLY_RANGES:
+ AcpiOsPrintf (" Type Specific: "
+ "ISA Io Addresses\n");
+ break;
+
+ case ACPI_ENTIRE_RANGE:
+ AcpiOsPrintf (" Type Specific: "
+ "ISA and non-ISA Io Addresses\n");
+ break;
+
+ default:
+ AcpiOsPrintf (" Type Specific: "
+ "Invalid Range attribute");
+ break;
+ }
+
+ AcpiOsPrintf (" Type Specific: %s Translation\n",
+ ACPI_SPARSE_TRANSLATION ==
+ Address64Data->Attribute.Io.TranslationAttribute ?
+ "Sparse" : "Dense");
+ break;
+
+ case ACPI_BUS_NUMBER_RANGE:
+
+ AcpiOsPrintf (" Resource Type: Bus Number Range\n");
+ break;
+
+ default:
+
+ AcpiOsPrintf (" Invalid Resource Type..exiting.\n");
+ return;
+ }
+
+ AcpiOsPrintf (" Resource %s\n",
+ ACPI_CONSUMER == Address64Data->ProducerConsumer ?
+ "Consumer" : "Producer");
+
+ AcpiOsPrintf (" %s decode\n",
+ ACPI_SUB_DECODE == Address64Data->Decode ?
+ "Subtractive" : "Positive");
+
+ AcpiOsPrintf (" Min address is %s fixed\n",
+ ACPI_ADDRESS_FIXED == Address64Data->MinAddressFixed ?
+ "" : "not ");
+
+ AcpiOsPrintf (" Max address is %s fixed\n",
+ ACPI_ADDRESS_FIXED == Address64Data->MaxAddressFixed ?
+ "" : "not ");
+
+ AcpiOsPrintf (" Granularity: %8.8X%8.8X\n",
+ ACPI_HIDWORD (Address64Data->Granularity),
+ ACPI_LODWORD (Address64Data->Granularity));
+
+ AcpiOsPrintf (" Address range min: %8.8X%8.8X\n",
+ ACPI_HIDWORD (Address64Data->MinAddressRange),
+ ACPI_HIDWORD (Address64Data->MinAddressRange));
+
+ AcpiOsPrintf (" Address range max: %8.8X%8.8X\n",
+ ACPI_HIDWORD (Address64Data->MaxAddressRange),
+ ACPI_HIDWORD (Address64Data->MaxAddressRange));
+
+ AcpiOsPrintf (" Address translation offset: %8.8X%8.8X\n",
+ ACPI_HIDWORD (Address64Data->AddressTranslationOffset),
+ ACPI_HIDWORD (Address64Data->AddressTranslationOffset));
+
+ AcpiOsPrintf (" Address Length: %8.8X%8.8X\n",
+ ACPI_HIDWORD (Address64Data->AddressLength),
+ ACPI_HIDWORD (Address64Data->AddressLength));
+
+ if(0xFF != Address64Data->ResourceSource.Index)
+ {
+ AcpiOsPrintf (" Resource Source Index: %X\n",
+ Address64Data->ResourceSource.Index);
+ AcpiOsPrintf (" Resource Source: %s\n",
+ Address64Data->ResourceSource.StringPtr);
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpExtendedIrq
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Prints out the various members of the Data structure type.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpExtendedIrq (
+ ACPI_RESOURCE_DATA *Data)
+{
+ ACPI_RESOURCE_EXT_IRQ *ExtIrqData = (ACPI_RESOURCE_EXT_IRQ *) Data;
+ UINT8 Index = 0;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ AcpiOsPrintf ("Extended IRQ Resource\n");
+
+ AcpiOsPrintf (" Resource %s\n",
+ ACPI_CONSUMER == ExtIrqData->ProducerConsumer ?
+ "Consumer" : "Producer");
+
+ AcpiOsPrintf (" %s\n",
+ ACPI_LEVEL_SENSITIVE == ExtIrqData->EdgeLevel ?
+ "Level" : "Edge");
+
+ AcpiOsPrintf (" Active %s\n",
+ ACPI_ACTIVE_LOW == ExtIrqData->ActiveHighLow ?
+ "low" : "high");
+
+ AcpiOsPrintf (" %s\n",
+ ACPI_SHARED == ExtIrqData->SharedExclusive ?
+ "Shared" : "Exclusive");
+
+ AcpiOsPrintf (" Interrupts : %X ( ",
+ ExtIrqData->NumberOfInterrupts);
+
+ for (Index = 0; Index < ExtIrqData->NumberOfInterrupts; Index++)
+ {
+ AcpiOsPrintf ("%X ", ExtIrqData->Interrupts[Index]);
+ }
+
+ AcpiOsPrintf (")\n");
+
+ if(0xFF != ExtIrqData->ResourceSource.Index)
+ {
+ AcpiOsPrintf (" Resource Source Index: %X",
+ ExtIrqData->ResourceSource.Index);
+ AcpiOsPrintf (" Resource Source: %s",
+ ExtIrqData->ResourceSource.StringPtr);
+ }
+
+ return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpResourceList
+ *
+ * PARAMETERS: Data - pointer to the resource structure to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dispatches the structure to the correct dump routine.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpResourceList (
+ ACPI_RESOURCE *Resource)
+{
+ UINT8 Count = 0;
+ BOOLEAN Done = FALSE;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (AcpiDbgLevel & ACPI_LV_RESOURCES && _COMPONENT & AcpiDbgLayer)
+ {
+ while (!Done)
+ {
+ AcpiOsPrintf ("Resource structure %X.\n", Count++);
+
+ switch (Resource->Id)
+ {
+ case ACPI_RSTYPE_IRQ:
+ AcpiRsDumpIrq (&Resource->Data);
+ break;
+
+ case ACPI_RSTYPE_DMA:
+ AcpiRsDumpDma (&Resource->Data);
+ break;
+
+ case ACPI_RSTYPE_START_DPF:
+ AcpiRsDumpStartDependFns (&Resource->Data);
+ break;
+
+ case ACPI_RSTYPE_END_DPF:
+ AcpiOsPrintf ("EndDependentFunctions Resource\n");
+ /* AcpiRsDumpEndDependentFunctions (Resource->Data);*/
+ break;
+
+ case ACPI_RSTYPE_IO:
+ AcpiRsDumpIo (&Resource->Data);
+ break;
+
+ case ACPI_RSTYPE_FIXED_IO:
+ AcpiRsDumpFixedIo (&Resource->Data);
+ break;
+
+ case ACPI_RSTYPE_VENDOR:
+ AcpiRsDumpVendorSpecific (&Resource->Data);
+ break;
+
+ case ACPI_RSTYPE_END_TAG:
+ /*RsDumpEndTag (Resource->Data);*/
+ AcpiOsPrintf ("EndTag Resource\n");
+ Done = TRUE;
+ break;
+
+ case ACPI_RSTYPE_MEM24:
+ AcpiRsDumpMemory24 (&Resource->Data);
+ break;
+
+ case ACPI_RSTYPE_MEM32:
+ AcpiRsDumpMemory32 (&Resource->Data);
+ break;
+
+ case ACPI_RSTYPE_FIXED_MEM32:
+ AcpiRsDumpFixedMemory32 (&Resource->Data);
+ break;
+
+ case ACPI_RSTYPE_ADDRESS16:
+ AcpiRsDumpAddress16 (&Resource->Data);
+ break;
+
+ case ACPI_RSTYPE_ADDRESS32:
+ AcpiRsDumpAddress32 (&Resource->Data);
+ break;
+
+ case ACPI_RSTYPE_ADDRESS64:
+ AcpiRsDumpAddress64 (&Resource->Data);
+ break;
+
+ case ACPI_RSTYPE_EXT_IRQ:
+ AcpiRsDumpExtendedIrq (&Resource->Data);
+ break;
+
+ default:
+ AcpiOsPrintf ("Invalid resource type\n");
+ break;
+
+ }
+
+ Resource = ACPI_PTR_ADD (ACPI_RESOURCE, Resource, Resource->Length);
+ }
+ }
+
+ return;
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDumpIrqList
+ *
+ * PARAMETERS: Data - pointer to the routing table to dump.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Dispatches the structures to the correct dump routine.
+ *
+ ******************************************************************************/
+
+void
+AcpiRsDumpIrqList (
+ UINT8 *RouteTable)
+{
+ UINT8 *Buffer = RouteTable;
+ UINT8 Count = 0;
+ BOOLEAN Done = FALSE;
+ ACPI_PCI_ROUTING_TABLE *PrtElement;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (AcpiDbgLevel & ACPI_LV_RESOURCES && _COMPONENT & AcpiDbgLayer)
+ {
+ PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
+
+ while (!Done)
+ {
+ AcpiOsPrintf ("PCI IRQ Routing Table structure %X.\n", Count++);
+
+ AcpiOsPrintf (" Address: %8.8X%8.8X\n",
+ ACPI_HIDWORD (PrtElement->Address),
+ ACPI_LODWORD (PrtElement->Address));
+
+ AcpiOsPrintf (" Pin: %X\n", PrtElement->Pin);
+
+ AcpiOsPrintf (" Source: %s\n", PrtElement->Source);
+
+ AcpiOsPrintf (" SourceIndex: %X\n",
+ PrtElement->SourceIndex);
+
+ Buffer += PrtElement->Length;
+
+ PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
+
+ if(0 == PrtElement->Length)
+ {
+ Done = TRUE;
+ }
+ }
+ }
+
+ return;
+}
+
+#endif
+
diff --git a/sys/contrib/dev/acpica/rsio.c b/sys/contrib/dev/acpica/rsio.c
new file mode 100644
index 0000000..fc63577
--- /dev/null
+++ b/sys/contrib/dev/acpica/rsio.c
@@ -0,0 +1,624 @@
+/*******************************************************************************
+ *
+ * Module Name: rsio - IO and DMA resource descriptors
+ * $Revision: 23 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __RSIO_C__
+
+#include "acpi.h"
+#include "acresrc.h"
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsio")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsIoResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsIoResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_IO);
+
+
+ ACPI_FUNCTION_TRACE ("RsIoResource");
+
+
+ /*
+ * The number of bytes consumed are Constant
+ */
+ *BytesConsumed = 8;
+
+ OutputStruct->Id = ACPI_RSTYPE_IO;
+
+ /*
+ * Check Decode
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ OutputStruct->Data.Io.IoDecode = Temp8 & 0x01;
+
+ /*
+ * Check MinBase Address
+ */
+ Buffer += 1;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ OutputStruct->Data.Io.MinBaseAddress = Temp16;
+
+ /*
+ * Check MaxBase Address
+ */
+ Buffer += 2;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ OutputStruct->Data.Io.MaxBaseAddress = Temp16;
+
+ /*
+ * Check Base alignment
+ */
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ OutputStruct->Data.Io.Alignment = Temp8;
+
+ /*
+ * Check RangeLength
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ OutputStruct->Data.Io.RangeLength = Temp8;
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsFixedIoResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsFixedIoResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_FIXED_IO);
+
+
+ ACPI_FUNCTION_TRACE ("RsFixedIoResource");
+
+
+ /*
+ * The number of bytes consumed are Constant
+ */
+ *BytesConsumed = 4;
+
+ OutputStruct->Id = ACPI_RSTYPE_FIXED_IO;
+
+ /*
+ * Check Range Base Address
+ */
+ Buffer += 1;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ OutputStruct->Data.FixedIo.BaseAddress = Temp16;
+
+ /*
+ * Check RangeLength
+ */
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ OutputStruct->Data.FixedIo.RangeLength = Temp8;
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsIoStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsIoStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+
+
+ ACPI_FUNCTION_TRACE ("RsIoStream");
+
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x47;
+ Buffer += 1;
+
+ /*
+ * Io Information Byte
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Io.IoDecode & 0x01);
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the Range minimum base address
+ */
+ Temp16 = (UINT16) LinkedList->Data.Io.MinBaseAddress;
+
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the Range maximum base address
+ */
+ Temp16 = (UINT16) LinkedList->Data.Io.MaxBaseAddress;
+
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the base alignment
+ */
+ Temp8 = (UINT8) LinkedList->Data.Io.Alignment;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the range length
+ */
+ Temp8 = (UINT8) LinkedList->Data.Io.RangeLength;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsFixedIoStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsFixedIoStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+
+
+ ACPI_FUNCTION_TRACE ("RsFixedIoStream");
+
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x4B;
+
+ Buffer += 1;
+
+ /*
+ * Set the Range base address
+ */
+ Temp16 = (UINT16) LinkedList->Data.FixedIo.BaseAddress;
+
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the range length
+ */
+ Temp8 = (UINT8) LinkedList->Data.FixedIo.RangeLength;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDmaResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsDmaResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+ UINT8 i;
+ ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_DMA);
+
+
+ ACPI_FUNCTION_TRACE ("RsDmaResource");
+
+
+ /*
+ * The number of bytes consumed are Constant
+ */
+ *BytesConsumed = 3;
+ OutputStruct->Id = ACPI_RSTYPE_DMA;
+
+ /*
+ * Point to the 8-bits of Byte 1
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ /* Decode the DMA channel bits */
+
+ for (i = 0, Index = 0; Index < 8; Index++)
+ {
+ if ((Temp8 >> Index) & 0x01)
+ {
+ OutputStruct->Data.Dma.Channels[i] = Index;
+ i++;
+ }
+ }
+
+ /* Zero DMA channels is valid */
+
+ OutputStruct->Data.Dma.NumberOfChannels = i;
+ if (i > 0)
+ {
+ /*
+ * Calculate the structure size based upon the number of interrupts
+ */
+ StructSize += ((ACPI_SIZE) i - 1) * 4;
+ }
+
+ /*
+ * Point to Byte 2
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ /*
+ * Check for transfer preference (Bits[1:0])
+ */
+ OutputStruct->Data.Dma.Transfer = Temp8 & 0x03;
+
+ if (0x03 == OutputStruct->Data.Dma.Transfer)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid DMA.Transfer preference (3)\n"));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+
+ /*
+ * Get bus master preference (Bit[2])
+ */
+ OutputStruct->Data.Dma.BusMaster = (Temp8 >> 2) & 0x01;
+
+ /*
+ * Get channel speed support (Bits[6:5])
+ */
+ OutputStruct->Data.Dma.Type = (Temp8 >> 5) & 0x03;
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsDmaStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsDmaStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+
+
+ ACPI_FUNCTION_TRACE ("RsDmaStream");
+
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x2A;
+ Buffer += 1;
+ Temp8 = 0;
+
+ /*
+ * Loop through all of the Channels and set the mask bits
+ */
+ for (Index = 0;
+ Index < LinkedList->Data.Dma.NumberOfChannels;
+ Index++)
+ {
+ Temp16 = (UINT16) LinkedList->Data.Dma.Channels[Index];
+ Temp8 |= 0x1 << Temp16;
+ }
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the DMA Info
+ */
+ Temp8 = (UINT8) ((LinkedList->Data.Dma.Type & 0x03) << 5);
+ Temp8 |= ((LinkedList->Data.Dma.BusMaster & 0x01) << 2);
+ Temp8 |= (LinkedList->Data.Dma.Transfer & 0x03);
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/rsirq.c b/sys/contrib/dev/acpica/rsirq.c
new file mode 100644
index 0000000..7da1fdc
--- /dev/null
+++ b/sys/contrib/dev/acpica/rsirq.c
@@ -0,0 +1,671 @@
+/*******************************************************************************
+ *
+ * Module Name: rsirq - IRQ resource descriptors
+ * $Revision: 32 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __RSIRQ_C__
+
+#include "acpi.h"
+#include "acresrc.h"
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsirq")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsIrqResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsIrqResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+ UINT8 i;
+ ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_IRQ);
+
+
+ ACPI_FUNCTION_TRACE ("RsIrqResource");
+
+
+ /*
+ * The number of bytes consumed are contained in the descriptor
+ * (Bits:0-1)
+ */
+ Temp8 = *Buffer;
+ *BytesConsumed = (Temp8 & 0x03) + 1;
+ OutputStruct->Id = ACPI_RSTYPE_IRQ;
+
+ /*
+ * Point to the 16-bits of Bytes 1 and 2
+ */
+ Buffer += 1;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ OutputStruct->Data.Irq.NumberOfInterrupts = 0;
+
+ /* Decode the IRQ bits */
+
+ for (i = 0, Index = 0; Index < 16; Index++)
+ {
+ if ((Temp16 >> Index) & 0x01)
+ {
+ OutputStruct->Data.Irq.Interrupts[i] = Index;
+ i++;
+ }
+ }
+
+ /* Zero interrupts is valid */
+
+ OutputStruct->Data.Irq.NumberOfInterrupts = i;
+ if (i > 0)
+ {
+ /*
+ * Calculate the structure size based upon the number of interrupts
+ */
+ StructSize += ((ACPI_SIZE) i - 1) * 4;
+ }
+
+ /*
+ * Point to Byte 3 if it is used
+ */
+ if (4 == *BytesConsumed)
+ {
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ /*
+ * Check for HE, LL or HL
+ */
+ if (Temp8 & 0x01)
+ {
+ OutputStruct->Data.Irq.EdgeLevel = ACPI_EDGE_SENSITIVE;
+ OutputStruct->Data.Irq.ActiveHighLow = ACPI_ACTIVE_HIGH;
+ }
+ else
+ {
+ if (Temp8 & 0x8)
+ {
+ OutputStruct->Data.Irq.EdgeLevel = ACPI_LEVEL_SENSITIVE;
+ OutputStruct->Data.Irq.ActiveHighLow = ACPI_ACTIVE_LOW;
+ }
+ else
+ {
+ /*
+ * Only _LL and _HE polarity/trigger interrupts
+ * are allowed (ACPI spec v1.0b ection 6.4.2.1),
+ * so an error will occur if we reach this point
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid interrupt polarity/trigger in resource list\n"));
+ return_ACPI_STATUS (AE_BAD_DATA);
+ }
+ }
+
+ /*
+ * Check for sharable
+ */
+ OutputStruct->Data.Irq.SharedExclusive = (Temp8 >> 3) & 0x01;
+ }
+ else
+ {
+ /*
+ * Assume Edge Sensitive, Active High, Non-Sharable
+ * per ACPI Specification
+ */
+ OutputStruct->Data.Irq.EdgeLevel = ACPI_EDGE_SENSITIVE;
+ OutputStruct->Data.Irq.ActiveHighLow = ACPI_ACTIVE_HIGH;
+ OutputStruct->Data.Irq.SharedExclusive = ACPI_EXCLUSIVE;
+ }
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsIrqStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsIrqStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+ BOOLEAN IRQInfoByteNeeded;
+
+
+ ACPI_FUNCTION_TRACE ("RsIrqStream");
+
+
+ /*
+ * The descriptor field is set based upon whether a third byte is
+ * needed to contain the IRQ Information.
+ */
+ if (ACPI_EDGE_SENSITIVE == LinkedList->Data.Irq.EdgeLevel &&
+ ACPI_ACTIVE_HIGH == LinkedList->Data.Irq.ActiveHighLow &&
+ ACPI_EXCLUSIVE == LinkedList->Data.Irq.SharedExclusive)
+ {
+ *Buffer = 0x22;
+ IRQInfoByteNeeded = FALSE;
+ }
+ else
+ {
+ *Buffer = 0x23;
+ IRQInfoByteNeeded = TRUE;
+ }
+
+ Buffer += 1;
+ Temp16 = 0;
+
+ /*
+ * Loop through all of the interrupts and set the mask bits
+ */
+ for(Index = 0;
+ Index < LinkedList->Data.Irq.NumberOfInterrupts;
+ Index++)
+ {
+ Temp8 = (UINT8) LinkedList->Data.Irq.Interrupts[Index];
+ Temp16 |= 0x1 << Temp8;
+ }
+
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the IRQ Info byte if needed.
+ */
+ if (IRQInfoByteNeeded)
+ {
+ Temp8 = 0;
+ Temp8 = (UINT8) ((LinkedList->Data.Irq.SharedExclusive &
+ 0x01) << 4);
+
+ if (ACPI_LEVEL_SENSITIVE == LinkedList->Data.Irq.EdgeLevel &&
+ ACPI_ACTIVE_LOW == LinkedList->Data.Irq.ActiveHighLow)
+ {
+ Temp8 |= 0x08;
+ }
+ else
+ {
+ Temp8 |= 0x01;
+ }
+
+ *Buffer = Temp8;
+ Buffer += 1;
+ }
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsExtendedIrqResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsExtendedIrqResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT8 *TempPtr;
+ UINT8 Index;
+ ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_EXT_IRQ);
+
+
+ ACPI_FUNCTION_TRACE ("RsExtendedIrqResource");
+
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ *BytesConsumed = Temp16 + 3;
+ OutputStruct->Id = ACPI_RSTYPE_EXT_IRQ;
+
+ /*
+ * Point to the Byte3
+ */
+ Buffer += 2;
+ Temp8 = *Buffer;
+
+ OutputStruct->Data.ExtendedIrq.ProducerConsumer = Temp8 & 0x01;
+
+ /*
+ * Check for Interrupt Mode
+ *
+ * The definition of an Extended IRQ changed between ACPI spec v1.0b
+ * and ACPI spec 2.0 (section 6.4.3.6 in both).
+ *
+ * - Edge/Level are defined opposite in the table vs the headers
+ */
+ OutputStruct->Data.ExtendedIrq.EdgeLevel =
+ (Temp8 & 0x2) ? ACPI_EDGE_SENSITIVE : ACPI_LEVEL_SENSITIVE;
+
+ /*
+ * Check Interrupt Polarity
+ */
+ OutputStruct->Data.ExtendedIrq.ActiveHighLow = (Temp8 >> 2) & 0x1;
+
+ /*
+ * Check for sharable
+ */
+ OutputStruct->Data.ExtendedIrq.SharedExclusive = (Temp8 >> 3) & 0x01;
+
+ /*
+ * Point to Byte4 (IRQ Table length)
+ */
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ OutputStruct->Data.ExtendedIrq.NumberOfInterrupts = Temp8;
+
+ /*
+ * Add any additional structure size to properly calculate
+ * the next pointer at the end of this function
+ */
+ StructSize += (Temp8 - 1) * 4;
+
+ /*
+ * Point to Byte5 (First IRQ Number)
+ */
+ Buffer += 1;
+
+ /*
+ * Cycle through every IRQ in the table
+ */
+ for (Index = 0; Index < Temp8; Index++)
+ {
+ ACPI_MOVE_UNALIGNED32_TO_32 (
+ &OutputStruct->Data.ExtendedIrq.Interrupts[Index], Buffer);
+
+ /* Point to the next IRQ */
+
+ Buffer += 4;
+ }
+
+ /*
+ * This will leave us pointing to the Resource Source Index
+ * If it is present, then save it off and calculate the
+ * pointer to where the null terminated string goes:
+ * Each Interrupt takes 32-bits + the 5 bytes of the
+ * stream that are default.
+ */
+ if (*BytesConsumed >
+ ((ACPI_SIZE) OutputStruct->Data.ExtendedIrq.NumberOfInterrupts * 4) + 5)
+ {
+ /* Dereference the Index */
+
+ Temp8 = *Buffer;
+ OutputStruct->Data.ExtendedIrq.ResourceSource.Index = (UINT32) Temp8;
+
+ /* Point to the String */
+
+ Buffer += 1;
+
+ /*
+ * Point the String pointer to the end of this structure.
+ */
+ OutputStruct->Data.ExtendedIrq.ResourceSource.StringPtr =
+ (char *)(OutputStruct + StructSize);
+
+ TempPtr = (UINT8 *) OutputStruct->Data.ExtendedIrq.ResourceSource.StringPtr;
+
+ /* Copy the string into the buffer */
+
+ Index = 0;
+ while (0x00 != *Buffer)
+ {
+ *TempPtr = *Buffer;
+
+ TempPtr += 1;
+ Buffer += 1;
+ Index += 1;
+ }
+
+ /*
+ * Add the terminating null
+ */
+ *TempPtr = 0x00;
+ OutputStruct->Data.ExtendedIrq.ResourceSource.StringLength = Index + 1;
+
+ /*
+ * In order for the StructSize to fall on a 32-bit boundary,
+ * calculate the length of the string and expand the
+ * StructSize to the next 32-bit boundary.
+ */
+ Temp8 = (UINT8) (Index + 1);
+ StructSize += ACPI_ROUND_UP_TO_32BITS (Temp8);
+ }
+ else
+ {
+ OutputStruct->Data.ExtendedIrq.ResourceSource.Index = 0x00;
+ OutputStruct->Data.ExtendedIrq.ResourceSource.StringLength = 0;
+ OutputStruct->Data.ExtendedIrq.ResourceSource.StringPtr = NULL;
+ }
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsExtendedIrqStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsExtendedIrqStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 *LengthField;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+ char *TempPointer = NULL;
+
+
+ ACPI_FUNCTION_TRACE ("RsExtendedIrqStream");
+
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x89;
+ Buffer += 1;
+
+ /*
+ * Set a pointer to the Length field - to be filled in later
+ */
+ LengthField = ACPI_CAST_PTR (UINT16, Buffer);
+ Buffer += 2;
+
+ /*
+ * Set the Interrupt vector flags
+ */
+ Temp8 = (UINT8)(LinkedList->Data.ExtendedIrq.ProducerConsumer & 0x01);
+ Temp8 |= ((LinkedList->Data.ExtendedIrq.SharedExclusive & 0x01) << 3);
+
+ /*
+ * Set the Interrupt Mode
+ *
+ * The definition of an Extended IRQ changed between ACPI spec v1.0b
+ * and ACPI spec 2.0 (section 6.4.3.6 in both). This code does not
+ * implement the more restrictive definition of 1.0b
+ *
+ * - Edge/Level are defined opposite in the table vs the headers
+ */
+ if (ACPI_EDGE_SENSITIVE == LinkedList->Data.ExtendedIrq.EdgeLevel)
+ {
+ Temp8 |= 0x2;
+ }
+
+ /*
+ * Set the Interrupt Polarity
+ */
+ Temp8 |= ((LinkedList->Data.ExtendedIrq.ActiveHighLow & 0x1) << 2);
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the Interrupt table length
+ */
+ Temp8 = (UINT8) LinkedList->Data.ExtendedIrq.NumberOfInterrupts;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ for (Index = 0; Index < LinkedList->Data.ExtendedIrq.NumberOfInterrupts;
+ Index++)
+ {
+ ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.ExtendedIrq.Interrupts[Index]);
+ Buffer += 4;
+ }
+
+ /*
+ * Resource Source Index and Resource Source are optional
+ */
+ if (0 != LinkedList->Data.ExtendedIrq.ResourceSource.StringLength)
+ {
+ *Buffer = (UINT8) LinkedList->Data.ExtendedIrq.ResourceSource.Index;
+ Buffer += 1;
+
+ TempPointer = (char *) Buffer;
+
+ /*
+ * Copy the string
+ */
+ ACPI_STRCPY (TempPointer,
+ LinkedList->Data.ExtendedIrq.ResourceSource.StringPtr);
+
+ /*
+ * Buffer needs to be set to the length of the sting + one for the
+ * terminating null
+ */
+ Buffer += (ACPI_STRLEN (LinkedList->Data.ExtendedIrq.ResourceSource.StringPtr) + 1);
+ }
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+
+ /*
+ * Set the length field to the number of bytes consumed
+ * minus the header size (3 bytes)
+ */
+ *LengthField = (UINT16) (*BytesConsumed - 3);
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/rslist.c b/sys/contrib/dev/acpica/rslist.c
new file mode 100644
index 0000000..fd802c0
--- /dev/null
+++ b/sys/contrib/dev/acpica/rslist.c
@@ -0,0 +1,599 @@
+/*******************************************************************************
+ *
+ * Module Name: rslist - Linked list utilities
+ * $Revision: 32 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __RSLIST_C__
+
+#include "acpi.h"
+#include "acresrc.h"
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rslist")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetResourceType
+ *
+ * PARAMETERS: ResourceStartByte - Byte 0 of a resource descriptor
+ *
+ * RETURN: The Resource Type (Name) with no extraneous bits
+ *
+ * DESCRIPTION: Extract the Resource Type/Name from the first byte of
+ * a resource descriptor.
+ *
+ ******************************************************************************/
+
+UINT8
+AcpiRsGetResourceType (
+ UINT8 ResourceStartByte)
+{
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /*
+ * Determine if this is a small or large resource
+ */
+ switch (ResourceStartByte & ACPI_RDESC_TYPE_MASK)
+ {
+ case ACPI_RDESC_TYPE_SMALL:
+
+ /*
+ * Small Resource Type -- Only bits 6:3 are valid
+ */
+ return ((UINT8) (ResourceStartByte & ACPI_RDESC_SMALL_MASK));
+
+
+ case ACPI_RDESC_TYPE_LARGE:
+
+ /*
+ * Large Resource Type -- All bits are valid
+ */
+ return (ResourceStartByte);
+
+
+ default:
+ /* No other types of resource descriptor */
+ break;
+ }
+
+ return (0xFF);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsByteStreamToList
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource byte stream
+ * ByteStreamBufferLength - Length of ByteStreamBuffer
+ * OutputBuffer - Pointer to the buffer that will
+ * contain the output structures
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Takes the resource byte stream and parses it, creating a
+ * linked list of resources in the caller's output buffer
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsByteStreamToList (
+ UINT8 *ByteStreamBuffer,
+ UINT32 ByteStreamBufferLength,
+ UINT8 *OutputBuffer)
+{
+ ACPI_STATUS Status;
+ ACPI_SIZE BytesParsed = 0;
+ UINT8 ResourceType = 0;
+ ACPI_SIZE BytesConsumed = 0;
+ UINT8 *Buffer = OutputBuffer;
+ ACPI_SIZE StructureSize = 0;
+ BOOLEAN EndTagProcessed = FALSE;
+ ACPI_RESOURCE *Resource;
+
+ ACPI_FUNCTION_TRACE ("RsByteStreamToList");
+
+
+ while (BytesParsed < ByteStreamBufferLength &&
+ !EndTagProcessed)
+ {
+ /*
+ * 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
+ */
+ Status = AcpiRsMemory24Resource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_LARGE_VENDOR:
+ /*
+ * Vendor Defined Resource
+ */
+ Status = AcpiRsVendorResource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_MEMORY_32:
+ /*
+ * 32-Bit Memory Range Resource
+ */
+ Status = AcpiRsMemory32RangeResource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_FIXED_MEMORY_32:
+ /*
+ * 32-Bit Fixed Memory Resource
+ */
+ Status = AcpiRsFixedMemory32Resource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE:
+ /*
+ * 64-Bit Address Resource
+ */
+ Status = AcpiRsAddress64Resource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE:
+ /*
+ * 32-Bit Address Resource
+ */
+ Status = AcpiRsAddress32Resource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE:
+ /*
+ * 16-Bit Address Resource
+ */
+ Status = AcpiRsAddress16Resource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_EXTENDED_XRUPT:
+ /*
+ * Extended IRQ
+ */
+ Status = AcpiRsExtendedIrqResource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_IRQ_FORMAT:
+ /*
+ * IRQ Resource
+ */
+ Status = AcpiRsIrqResource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_DMA_FORMAT:
+ /*
+ * DMA Resource
+ */
+ Status = AcpiRsDmaResource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_START_DEPENDENT:
+ /*
+ * Start Dependent Functions Resource
+ */
+ Status = AcpiRsStartDependFnsResource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_END_DEPENDENT:
+ /*
+ * End Dependent Functions Resource
+ */
+ Status = AcpiRsEndDependFnsResource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_IO_PORT:
+ /*
+ * IO Port Resource
+ */
+ Status = AcpiRsIoResource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_FIXED_IO_PORT:
+ /*
+ * Fixed IO Port Resource
+ */
+ Status = AcpiRsFixedIoResource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_SMALL_VENDOR:
+ /*
+ * Vendor Specific Resource
+ */
+ Status = AcpiRsVendorResource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ case ACPI_RDESC_TYPE_END_TAG:
+ /*
+ * End Tag
+ */
+ EndTagProcessed = TRUE;
+ Status = AcpiRsEndTagResource (ByteStreamBuffer,
+ &BytesConsumed, &Buffer, &StructureSize);
+ break;
+
+
+ default:
+ /*
+ * Invalid/Unknown resource type
+ */
+ Status = AE_AML_INVALID_RESOURCE_TYPE;
+ break;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Update the return value and counter
+ */
+ BytesParsed += BytesConsumed;
+
+ /*
+ * Set the byte stream to point to the next resource
+ */
+ ByteStreamBuffer += BytesConsumed;
+
+ /*
+ * Set the Buffer to the next structure
+ */
+ Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer);
+ Resource->Length = ACPI_ALIGN_RESOURCE_SIZE(Resource->Length);
+ Buffer += ACPI_ALIGN_RESOURCE_SIZE(StructureSize);
+
+ } /* end while */
+
+ /*
+ * Check the reason for exiting the while loop
+ */
+ if (!EndTagProcessed)
+ {
+ return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsListToByteStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * ByteSteamSizeNeeded - Calculated size of the byte stream
+ * needed from calling
+ * AcpiRsGetByteStreamLength()
+ * The size of the OutputBuffer is
+ * guaranteed to be >=
+ * ByteStreamSizeNeeded
+ * OutputBuffer - Pointer to the buffer that will
+ * contain the byte stream
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Takes the resource linked list and parses it, creating a
+ * byte stream of resources in the caller's output buffer
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsListToByteStream (
+ ACPI_RESOURCE *LinkedList,
+ ACPI_SIZE ByteStreamSizeNeeded,
+ UINT8 *OutputBuffer)
+{
+ ACPI_STATUS Status;
+ UINT8 *Buffer = OutputBuffer;
+ ACPI_SIZE BytesConsumed = 0;
+ BOOLEAN Done = FALSE;
+
+
+ ACPI_FUNCTION_TRACE ("RsListToByteStream");
+
+
+ while (!Done)
+ {
+ switch (LinkedList->Id)
+ {
+ case ACPI_RSTYPE_IRQ:
+ /*
+ * IRQ Resource
+ */
+ Status = AcpiRsIrqStream (LinkedList, &Buffer, &BytesConsumed);
+ break;
+
+ case ACPI_RSTYPE_DMA:
+ /*
+ * DMA Resource
+ */
+ Status = AcpiRsDmaStream (LinkedList, &Buffer, &BytesConsumed);
+ break;
+
+ case ACPI_RSTYPE_START_DPF:
+ /*
+ * Start Dependent Functions Resource
+ */
+ Status = AcpiRsStartDependFnsStream (LinkedList,
+ &Buffer, &BytesConsumed);
+ break;
+
+ case ACPI_RSTYPE_END_DPF:
+ /*
+ * End Dependent Functions Resource
+ */
+ Status = AcpiRsEndDependFnsStream (LinkedList,
+ &Buffer, &BytesConsumed);
+ break;
+
+ case ACPI_RSTYPE_IO:
+ /*
+ * IO Port Resource
+ */
+ Status = AcpiRsIoStream (LinkedList, &Buffer, &BytesConsumed);
+ break;
+
+ case ACPI_RSTYPE_FIXED_IO:
+ /*
+ * Fixed IO Port Resource
+ */
+ Status = AcpiRsFixedIoStream (LinkedList, &Buffer, &BytesConsumed);
+ break;
+
+ case ACPI_RSTYPE_VENDOR:
+ /*
+ * Vendor Defined Resource
+ */
+ Status = AcpiRsVendorStream (LinkedList, &Buffer, &BytesConsumed);
+ break;
+
+ case ACPI_RSTYPE_END_TAG:
+ /*
+ * End Tag
+ */
+ Status = AcpiRsEndTagStream (LinkedList, &Buffer, &BytesConsumed);
+
+ /*
+ * An End Tag indicates the end of the Resource Template
+ */
+ Done = TRUE;
+ break;
+
+ case ACPI_RSTYPE_MEM24:
+ /*
+ * 24-Bit Memory Resource
+ */
+ Status = AcpiRsMemory24Stream (LinkedList, &Buffer, &BytesConsumed);
+ break;
+
+ case ACPI_RSTYPE_MEM32:
+ /*
+ * 32-Bit Memory Range Resource
+ */
+ Status = AcpiRsMemory32RangeStream (LinkedList, &Buffer,
+ &BytesConsumed);
+ break;
+
+ case ACPI_RSTYPE_FIXED_MEM32:
+ /*
+ * 32-Bit Fixed Memory Resource
+ */
+ Status = AcpiRsFixedMemory32Stream (LinkedList, &Buffer,
+ &BytesConsumed);
+ break;
+
+ case ACPI_RSTYPE_ADDRESS16:
+ /*
+ * 16-Bit Address Descriptor Resource
+ */
+ Status = AcpiRsAddress16Stream (LinkedList, &Buffer,
+ &BytesConsumed);
+ break;
+
+ case ACPI_RSTYPE_ADDRESS32:
+ /*
+ * 32-Bit Address Descriptor Resource
+ */
+ Status = AcpiRsAddress32Stream (LinkedList, &Buffer,
+ &BytesConsumed);
+ break;
+
+ case ACPI_RSTYPE_ADDRESS64:
+ /*
+ * 64-Bit Address Descriptor Resource
+ */
+ Status = AcpiRsAddress64Stream (LinkedList, &Buffer,
+ &BytesConsumed);
+ break;
+
+ case ACPI_RSTYPE_EXT_IRQ:
+ /*
+ * Extended IRQ Resource
+ */
+ Status = AcpiRsExtendedIrqStream (LinkedList, &Buffer,
+ &BytesConsumed);
+ break;
+
+ default:
+ /*
+ * If we get here, everything is out of sync,
+ * so exit with an error
+ */
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid descriptor type (%X) in resource list\n",
+ LinkedList->Id));
+ Status = AE_BAD_DATA;
+ break;
+
+ } /* switch (LinkedList->Id) */
+
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Set the Buffer to point to the open byte
+ */
+ Buffer += BytesConsumed;
+
+ /*
+ * Point to the next object
+ */
+ LinkedList = ACPI_PTR_ADD (ACPI_RESOURCE,
+ LinkedList, LinkedList->Length);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/rsmemory.c b/sys/contrib/dev/acpica/rsmemory.c
new file mode 100644
index 0000000..d33e352
--- /dev/null
+++ b/sys/contrib/dev/acpica/rsmemory.c
@@ -0,0 +1,644 @@
+/*******************************************************************************
+ *
+ * Module Name: rsmem24 - Memory resource descriptors
+ * $Revision: 22 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __RSMEMORY_C__
+
+#include "acpi.h"
+#include "acresrc.h"
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsmemory")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsMemory24Resource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsMemory24Resource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_MEM24);
+
+
+ ACPI_FUNCTION_TRACE ("RsMemory24Resource");
+
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ Buffer += 2;
+ *BytesConsumed = (ACPI_SIZE) Temp16 + 3;
+ OutputStruct->Id = ACPI_RSTYPE_MEM24;
+
+ /*
+ * Check Byte 3 the Read/Write bit
+ */
+ Temp8 = *Buffer;
+ Buffer += 1;
+ OutputStruct->Data.Memory24.ReadWriteAttribute = Temp8 & 0x01;
+
+ /*
+ * Get MinBaseAddress (Bytes 4-5)
+ */
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ Buffer += 2;
+ OutputStruct->Data.Memory24.MinBaseAddress = Temp16;
+
+ /*
+ * Get MaxBaseAddress (Bytes 6-7)
+ */
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ Buffer += 2;
+ OutputStruct->Data.Memory24.MaxBaseAddress = Temp16;
+
+ /*
+ * Get Alignment (Bytes 8-9)
+ */
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ Buffer += 2;
+ OutputStruct->Data.Memory24.Alignment = Temp16;
+
+ /*
+ * Get RangeLength (Bytes 10-11)
+ */
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ OutputStruct->Data.Memory24.RangeLength = Temp16;
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsMemory24Stream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsMemory24Stream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+
+
+ ACPI_FUNCTION_TRACE ("RsMemory24Stream");
+
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x81;
+ Buffer += 1;
+
+ /*
+ * The length field is static
+ */
+ Temp16 = 0x09;
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the Information Byte
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Memory24.ReadWriteAttribute & 0x01);
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the Range minimum base address
+ */
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.MinBaseAddress);
+ Buffer += 2;
+
+ /*
+ * Set the Range maximum base address
+ */
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.MaxBaseAddress);
+ Buffer += 2;
+
+ /*
+ * Set the base alignment
+ */
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.Alignment);
+ Buffer += 2;
+
+ /*
+ * Set the range length
+ */
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &LinkedList->Data.Memory24.RangeLength);
+ Buffer += 2;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsMemory32RangeResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsMemory32RangeResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_MEM32);
+
+
+ ACPI_FUNCTION_TRACE ("RsMemory32RangeResource");
+
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+ Buffer += 2;
+ *BytesConsumed = (ACPI_SIZE) Temp16 + 3;
+
+ OutputStruct->Id = ACPI_RSTYPE_MEM32;
+
+ /*
+ * Point to the place in the output buffer where the data portion will
+ * begin.
+ * 1. Set the RESOURCE_DATA * Data to point to its own address, then
+ * 2. Set the pointer to the next address.
+ *
+ * NOTE: OutputStruct->Data is cast to UINT8, otherwise, this addition adds
+ * 4 * sizeof(RESOURCE_DATA) instead of 4 * sizeof(UINT8)
+ */
+
+ /*
+ * Check Byte 3 the Read/Write bit
+ */
+ Temp8 = *Buffer;
+ Buffer += 1;
+
+ OutputStruct->Data.Memory32.ReadWriteAttribute = Temp8 & 0x01;
+
+ /*
+ * Get MinBaseAddress (Bytes 4-7)
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.MinBaseAddress,
+ Buffer);
+ Buffer += 4;
+
+ /*
+ * Get MaxBaseAddress (Bytes 8-11)
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.MaxBaseAddress,
+ Buffer);
+ Buffer += 4;
+
+ /*
+ * Get Alignment (Bytes 12-15)
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.Alignment, Buffer);
+ Buffer += 4;
+
+ /*
+ * Get RangeLength (Bytes 16-19)
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.Memory32.RangeLength, Buffer);
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsFixedMemory32Resource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsFixedMemory32Resource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_FIXED_MEM32);
+
+
+ ACPI_FUNCTION_TRACE ("RsFixedMemory32Resource");
+
+
+ /*
+ * Point past the Descriptor to get the number of bytes consumed
+ */
+ Buffer += 1;
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ Buffer += 2;
+ *BytesConsumed = (ACPI_SIZE) Temp16 + 3;
+
+ OutputStruct->Id = ACPI_RSTYPE_FIXED_MEM32;
+
+ /*
+ * Check Byte 3 the Read/Write bit
+ */
+ Temp8 = *Buffer;
+ Buffer += 1;
+ OutputStruct->Data.FixedMemory32.ReadWriteAttribute = Temp8 & 0x01;
+
+ /*
+ * Get RangeBaseAddress (Bytes 4-7)
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeBaseAddress,
+ Buffer);
+ Buffer += 4;
+
+ /*
+ * Get RangeLength (Bytes 8-11)
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (&OutputStruct->Data.FixedMemory32.RangeLength,
+ Buffer);
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsMemory32RangeStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsMemory32RangeStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+
+
+ ACPI_FUNCTION_TRACE ("RsMemory32RangeStream");
+
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x85;
+ Buffer += 1;
+
+ /*
+ * The length field is static
+ */
+ Temp16 = 0x11;
+
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the Information Byte
+ */
+ Temp8 = (UINT8) (LinkedList->Data.Memory32.ReadWriteAttribute & 0x01);
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the Range minimum base address
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.MinBaseAddress);
+ Buffer += 4;
+
+ /*
+ * Set the Range maximum base address
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.MaxBaseAddress);
+ Buffer += 4;
+
+ /*
+ * Set the base alignment
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.Alignment);
+ Buffer += 4;
+
+ /*
+ * Set the range length
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (Buffer, &LinkedList->Data.Memory32.RangeLength);
+ Buffer += 4;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsFixedMemory32Stream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsFixedMemory32Stream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+
+
+ ACPI_FUNCTION_TRACE ("RsFixedMemory32Stream");
+
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x86;
+ Buffer += 1;
+
+ /*
+ * The length field is static
+ */
+ Temp16 = 0x09;
+
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+
+ /*
+ * Set the Information Byte
+ */
+ Temp8 = (UINT8) (LinkedList->Data.FixedMemory32.ReadWriteAttribute & 0x01);
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Set the Range base address
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.FixedMemory32.RangeBaseAddress);
+ Buffer += 4;
+
+ /*
+ * Set the range length
+ */
+ ACPI_MOVE_UNALIGNED32_TO_32 (Buffer,
+ &LinkedList->Data.FixedMemory32.RangeLength);
+ Buffer += 4;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/rsmisc.c b/sys/contrib/dev/acpica/rsmisc.c
new file mode 100644
index 0000000..83b109f
--- /dev/null
+++ b/sys/contrib/dev/acpica/rsmisc.c
@@ -0,0 +1,683 @@
+/*******************************************************************************
+ *
+ * Module Name: rsmisc - Miscellaneous resource descriptors
+ * $Revision: 25 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __RSMISC_C__
+
+#include "acpi.h"
+#include "acresrc.h"
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsmisc")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsEndTagResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsEndTagResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ ACPI_SIZE StructSize = ACPI_RESOURCE_LENGTH;
+
+
+ ACPI_FUNCTION_TRACE ("RsEndTagResource");
+
+
+ /*
+ * The number of bytes consumed is static
+ */
+ *BytesConsumed = 2;
+
+ /*
+ * Fill out the structure
+ */
+ OutputStruct->Id = ACPI_RSTYPE_END_TAG;
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = 0;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsEndTagStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsEndTagStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT8 Temp8 = 0;
+
+
+ ACPI_FUNCTION_TRACE ("RsEndTagStream");
+
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x79;
+ Buffer += 1;
+
+ /*
+ * Set the Checksum - zero means that the resource data is treated as if
+ * the checksum operation succeeded (ACPI Spec 1.0b Section 6.4.2.8)
+ */
+ Temp8 = 0;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsVendorResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsVendorResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+ ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_VENDOR);
+
+
+ ACPI_FUNCTION_TRACE ("RsVendorResource");
+
+
+ /*
+ * Dereference the Descriptor to find if this is a large or small item.
+ */
+ Temp8 = *Buffer;
+
+ if (Temp8 & 0x80)
+ {
+ /*
+ * Large Item, point to the length field
+ */
+ Buffer += 1;
+
+ /* Dereference */
+
+ ACPI_MOVE_UNALIGNED16_TO_16 (&Temp16, Buffer);
+
+ /* Calculate bytes consumed */
+
+ *BytesConsumed = (ACPI_SIZE) Temp16 + 3;
+
+ /* Point to the first vendor byte */
+
+ Buffer += 2;
+ }
+ else
+ {
+ /*
+ * Small Item, dereference the size
+ */
+ Temp16 = (UINT8)(*Buffer & 0x07);
+
+ /* Calculate bytes consumed */
+
+ *BytesConsumed = (ACPI_SIZE) Temp16 + 1;
+
+ /* Point to the first vendor byte */
+
+ Buffer += 1;
+ }
+
+ OutputStruct->Id = ACPI_RSTYPE_VENDOR;
+ OutputStruct->Data.VendorSpecific.Length = Temp16;
+
+ for (Index = 0; Index < Temp16; Index++)
+ {
+ OutputStruct->Data.VendorSpecific.Reserved[Index] = *Buffer;
+ Buffer += 1;
+ }
+
+ /*
+ * In order for the StructSize to fall on a 32-bit boundary,
+ * calculate the length of the vendor string and expand the
+ * StructSize to the next 32-bit boundary.
+ */
+ StructSize += ACPI_ROUND_UP_TO_32BITS (Temp16);
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsVendorStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsVendorStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT16 Temp16 = 0;
+ UINT8 Temp8 = 0;
+ UINT8 Index;
+
+
+ ACPI_FUNCTION_TRACE ("RsVendorStream");
+
+
+ /*
+ * Dereference the length to find if this is a large or small item.
+ */
+ if(LinkedList->Data.VendorSpecific.Length > 7)
+ {
+ /*
+ * Large Item, Set the descriptor field and length bytes
+ */
+ *Buffer = 0x84;
+ Buffer += 1;
+
+ Temp16 = (UINT16) LinkedList->Data.VendorSpecific.Length;
+
+ ACPI_MOVE_UNALIGNED16_TO_16 (Buffer, &Temp16);
+ Buffer += 2;
+ }
+ else
+ {
+ /*
+ * Small Item, Set the descriptor field
+ */
+ Temp8 = 0x70;
+ Temp8 |= (UINT8) LinkedList->Data.VendorSpecific.Length;
+
+ *Buffer = Temp8;
+ Buffer += 1;
+ }
+
+ /*
+ * Loop through all of the Vendor Specific fields
+ */
+ for (Index = 0; Index < LinkedList->Data.VendorSpecific.Length; Index++)
+ {
+ Temp8 = LinkedList->Data.VendorSpecific.Reserved[Index];
+
+ *Buffer = Temp8;
+ Buffer += 1;
+ }
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsStartDependFnsResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsStartDependFnsResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ UINT8 *Buffer = ByteStreamBuffer;
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ UINT8 Temp8 = 0;
+ ACPI_SIZE StructSize = ACPI_SIZEOF_RESOURCE (ACPI_RESOURCE_START_DPF);
+
+
+ ACPI_FUNCTION_TRACE ("RsStartDependFnsResource");
+
+
+ /*
+ * The number of bytes consumed are contained in the descriptor (Bits:0-1)
+ */
+ Temp8 = *Buffer;
+
+ *BytesConsumed = (Temp8 & 0x01) + 1;
+
+ OutputStruct->Id = ACPI_RSTYPE_START_DPF;
+
+ /*
+ * Point to Byte 1 if it is used
+ */
+ if (2 == *BytesConsumed)
+ {
+ Buffer += 1;
+ Temp8 = *Buffer;
+
+ /*
+ * Check Compatibility priority
+ */
+ OutputStruct->Data.StartDpf.CompatibilityPriority = Temp8 & 0x03;
+
+ if (3 == OutputStruct->Data.StartDpf.CompatibilityPriority)
+ {
+ return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
+ }
+
+ /*
+ * Check Performance/Robustness preference
+ */
+ OutputStruct->Data.StartDpf.PerformanceRobustness = (Temp8 >> 2) & 0x03;
+
+ if (3 == OutputStruct->Data.StartDpf.PerformanceRobustness)
+ {
+ return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE);
+ }
+ }
+ else
+ {
+ OutputStruct->Data.StartDpf.CompatibilityPriority =
+ ACPI_ACCEPTABLE_CONFIGURATION;
+
+ OutputStruct->Data.StartDpf.PerformanceRobustness =
+ ACPI_ACCEPTABLE_CONFIGURATION;
+ }
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsEndDependFnsResource
+ *
+ * PARAMETERS: ByteStreamBuffer - Pointer to the resource input byte
+ * stream
+ * BytesConsumed - Pointer to where the number of bytes
+ * consumed the ByteStreamBuffer is
+ * returned
+ * OutputBuffer - Pointer to the return data buffer
+ * StructureSize - Pointer to where the number of bytes
+ * in the return data struct is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the resource byte stream and fill out the appropriate
+ * structure pointed to by the OutputBuffer. Return the
+ * number of bytes consumed from the byte stream.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsEndDependFnsResource (
+ UINT8 *ByteStreamBuffer,
+ ACPI_SIZE *BytesConsumed,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *StructureSize)
+{
+ ACPI_RESOURCE *OutputStruct = (void *) *OutputBuffer;
+ ACPI_SIZE StructSize = ACPI_RESOURCE_LENGTH;
+
+
+ ACPI_FUNCTION_TRACE ("RsEndDependFnsResource");
+
+
+ /*
+ * The number of bytes consumed is static
+ */
+ *BytesConsumed = 1;
+
+ /*
+ * Fill out the structure
+ */
+ OutputStruct->Id = ACPI_RSTYPE_END_DPF;
+
+ /*
+ * Set the Length parameter
+ */
+ OutputStruct->Length = (UINT32) StructSize;
+
+ /*
+ * Return the final size of the structure
+ */
+ *StructureSize = StructSize;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsStartDependFnsStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - UINT32 pointer that is filled with
+ * the number of bytes of the
+ * OutputBuffer used
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsStartDependFnsStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+ UINT8 Temp8 = 0;
+
+
+ ACPI_FUNCTION_TRACE ("RsStartDependFnsStream");
+
+
+ /*
+ * The descriptor field is set based upon whether a byte is needed
+ * to contain Priority data.
+ */
+ if (ACPI_ACCEPTABLE_CONFIGURATION ==
+ LinkedList->Data.StartDpf.CompatibilityPriority &&
+ ACPI_ACCEPTABLE_CONFIGURATION ==
+ LinkedList->Data.StartDpf.PerformanceRobustness)
+ {
+ *Buffer = 0x30;
+ }
+ else
+ {
+ *Buffer = 0x31;
+ Buffer += 1;
+
+ /*
+ * Set the Priority Byte Definition
+ */
+ Temp8 = 0;
+ Temp8 = (UINT8) ((LinkedList->Data.StartDpf.PerformanceRobustness &
+ 0x03) << 2);
+ Temp8 |= (LinkedList->Data.StartDpf.CompatibilityPriority &
+ 0x03);
+ *Buffer = Temp8;
+ }
+
+ Buffer += 1;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsEndDependFnsStream
+ *
+ * PARAMETERS: LinkedList - Pointer to the resource linked list
+ * OutputBuffer - Pointer to the user's return buffer
+ * BytesConsumed - Pointer to where the number of bytes
+ * used in the OutputBuffer is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Take the linked list resource structure and fills in the
+ * the appropriate bytes in a byte stream
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsEndDependFnsStream (
+ ACPI_RESOURCE *LinkedList,
+ UINT8 **OutputBuffer,
+ ACPI_SIZE *BytesConsumed)
+{
+ UINT8 *Buffer = *OutputBuffer;
+
+
+ ACPI_FUNCTION_TRACE ("RsEndDependFnsStream");
+
+
+ /*
+ * The descriptor field is static
+ */
+ *Buffer = 0x38;
+ Buffer += 1;
+
+ /*
+ * Return the number of bytes consumed in this operation
+ */
+ *BytesConsumed = ACPI_PTR_DIFF (Buffer, *OutputBuffer);
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/rsutils.c b/sys/contrib/dev/acpica/rsutils.c
new file mode 100644
index 0000000..e4e35a9
--- /dev/null
+++ b/sys/contrib/dev/acpica/rsutils.c
@@ -0,0 +1,423 @@
+/*******************************************************************************
+ *
+ * Module Name: rsutils - Utilities for the resource manager
+ * $Revision: 37 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __RSUTILS_C__
+
+#include "acpi.h"
+#include "acnamesp.h"
+#include "acresrc.h"
+
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsutils")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetPrtMethodData
+ *
+ * PARAMETERS: Handle - a handle to the containing object
+ * RetBuffer - a pointer to a buffer structure for the
+ * results
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the _PRT value of an object
+ * contained in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetPrtMethodData (
+ ACPI_HANDLE Handle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("RsGetPrtMethodData");
+
+
+ /* Parameters guaranteed valid by caller */
+
+ /*
+ * Execute the method, no parameters
+ */
+ Status = AcpiUtEvaluateObject (Handle, "_PRT", ACPI_BTYPE_PACKAGE, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Create a resource linked list from the byte stream buffer that comes
+ * back from the _CRS method execution.
+ */
+ Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
+
+ /* On exit, we must delete the object returned by EvaluateObject */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetCrsMethodData
+ *
+ * PARAMETERS: Handle - a handle to the containing object
+ * RetBuffer - a pointer to a buffer structure for the
+ * results
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the _CRS value of an object
+ * contained in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetCrsMethodData (
+ ACPI_HANDLE Handle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("RsGetCrsMethodData");
+
+
+ /* Parameters guaranteed valid by caller */
+
+ /*
+ * Execute the method, no parameters
+ */
+ Status = AcpiUtEvaluateObject (Handle, "_CRS", ACPI_BTYPE_BUFFER, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Make the call to create a resource linked list from the
+ * byte stream buffer that comes back from the _CRS method
+ * execution.
+ */
+ Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
+
+ /* On exit, we must delete the object returned by evaluateObject */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetPrsMethodData
+ *
+ * PARAMETERS: Handle - a handle to the containing object
+ * RetBuffer - a pointer to a buffer structure for the
+ * results
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the _PRS value of an object
+ * contained in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetPrsMethodData (
+ ACPI_HANDLE Handle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("RsGetPrsMethodData");
+
+
+ /* Parameters guaranteed valid by caller */
+
+ /*
+ * Execute the method, no parameters
+ */
+ Status = AcpiUtEvaluateObject (Handle, "_PRS", ACPI_BTYPE_BUFFER, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Make the call to create a resource linked list from the
+ * byte stream buffer that comes back from the _CRS method
+ * execution.
+ */
+ Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
+
+ /* On exit, we must delete the object returned by evaluateObject */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsGetMethodData
+ *
+ * PARAMETERS: Handle - a handle to the containing object
+ * RetBuffer - a pointer to a buffer structure for the
+ * results
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
+ * object contained in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsGetMethodData (
+ ACPI_HANDLE Handle,
+ char *Path,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("RsGetMethodData");
+
+
+ /* Parameters guaranteed valid by caller */
+
+ /*
+ * Execute the method, no parameters
+ */
+ Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc);
+ if (ACPI_FAILURE (Status)) {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Make the call to create a resource linked list from the
+ * byte stream buffer that comes back from the method
+ * execution.
+ */
+ Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
+
+ /* On exit, we must delete the object returned by EvaluateObject */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiRsSetSrsMethodData
+ *
+ * PARAMETERS: Handle - a handle to the containing object
+ * InBuffer - a pointer to a buffer structure of the
+ * parameter
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to set the _SRS of an object contained
+ * in an object specified by the handle passed in
+ *
+ * If the function fails an appropriate status will be returned
+ * and the contents of the callers buffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRsSetSrsMethodData (
+ ACPI_HANDLE Handle,
+ ACPI_BUFFER *InBuffer)
+{
+ ACPI_OPERAND_OBJECT *Params[2];
+ ACPI_STATUS Status;
+ ACPI_BUFFER Buffer;
+
+
+ ACPI_FUNCTION_TRACE ("RsSetSrsMethodData");
+
+
+ /* Parameters guaranteed valid by caller */
+
+ /*
+ * The InBuffer parameter will point to a linked list of
+ * resource parameters. It needs to be formatted into a
+ * byte stream to be sent in as an input parameter to _SRS
+ *
+ * Convert the linked list into a byte stream
+ */
+ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ Status = AcpiRsCreateByteStream (InBuffer->Pointer, &Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Init the param object
+ */
+ Params[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
+ if (!Params[0])
+ {
+ AcpiOsFree (Buffer.Pointer);
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /*
+ * Set up the parameter object
+ */
+ Params[0]->Buffer.Length = (UINT32) Buffer.Length;
+ Params[0]->Buffer.Pointer = Buffer.Pointer;
+ Params[0]->Common.Flags = AOPOBJ_DATA_VALID;
+ Params[1] = NULL;
+
+ /*
+ * Execute the method, no return value
+ */
+ Status = AcpiNsEvaluateRelative (Handle, "_SRS", Params, NULL);
+
+ /*
+ * Clean up and return the status from AcpiNsEvaluateRelative
+ */
+ AcpiUtRemoveReference (Params[0]);
+ return_ACPI_STATUS (Status);
+}
+
diff --git a/sys/contrib/dev/acpica/rsxface.c b/sys/contrib/dev/acpica/rsxface.c
new file mode 100644
index 0000000..5ec7c337
--- /dev/null
+++ b/sys/contrib/dev/acpica/rsxface.c
@@ -0,0 +1,494 @@
+/*******************************************************************************
+ *
+ * Module Name: rsxface - Public interfaces to the resource manager
+ * $Revision: 24 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __RSXFACE_C__
+
+#include "acpi.h"
+#include "acresrc.h"
+
+#define _COMPONENT ACPI_RESOURCES
+ ACPI_MODULE_NAME ("rsxface")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetIrqRoutingTable
+ *
+ * PARAMETERS: DeviceHandle - a handle to the Bus device we are querying
+ * RetBuffer - a pointer to a buffer to receive the
+ * current resources for the device
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the IRQ routing table for a
+ * specific bus. The caller must first acquire a handle for the
+ * desired bus. The routine table is placed in the buffer pointed
+ * to by the RetBuffer variable parameter.
+ *
+ * If the function fails an appropriate status will be returned
+ * and the value of RetBuffer is undefined.
+ *
+ * This function attempts to execute the _PRT method contained in
+ * the object indicated by the passed DeviceHandle.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetIrqRoutingTable (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiGetIrqRoutingTable ");
+
+
+ /*
+ * Must have a valid handle and buffer, So we have to have a handle
+ * and a return buffer structure, and if there is a non-zero buffer length
+ * we also need a valid pointer in the buffer. If it's a zero buffer length,
+ * we'll be returning the needed buffer size, so keep going.
+ */
+ if (!DeviceHandle)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtValidateBuffer (RetBuffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiRsGetPrtMethodData (DeviceHandle, RetBuffer);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetCurrentResources
+ *
+ * PARAMETERS: DeviceHandle - a handle to the device object for the
+ * device we are querying
+ * RetBuffer - a pointer to a buffer to receive the
+ * current resources for the device
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the current resources for a
+ * specific device. The caller must first acquire a handle for
+ * the desired device. The resource data is placed in the buffer
+ * pointed to by the RetBuffer variable parameter.
+ *
+ * If the function fails an appropriate status will be returned
+ * and the value of RetBuffer is undefined.
+ *
+ * This function attempts to execute the _CRS method contained in
+ * the object indicated by the passed DeviceHandle.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetCurrentResources (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiGetCurrentResources");
+
+
+ /*
+ * Must have a valid handle and buffer, So we have to have a handle
+ * and a return buffer structure, and if there is a non-zero buffer length
+ * we also need a valid pointer in the buffer. If it's a zero buffer length,
+ * we'll be returning the needed buffer size, so keep going.
+ */
+ if (!DeviceHandle)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtValidateBuffer (RetBuffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiRsGetCrsMethodData (DeviceHandle, RetBuffer);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetPossibleResources
+ *
+ * PARAMETERS: DeviceHandle - a handle to the device object for the
+ * device we are querying
+ * RetBuffer - a pointer to a buffer to receive the
+ * resources for the device
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get a list of the possible resources
+ * for a specific device. The caller must first acquire a handle
+ * for the desired device. The resource data is placed in the
+ * buffer pointed to by the RetBuffer variable.
+ *
+ * If the function fails an appropriate status will be returned
+ * and the value of RetBuffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetPossibleResources (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiGetPossibleResources");
+
+
+ /*
+ * Must have a valid handle and buffer, So we have to have a handle
+ * and a return buffer structure, and if there is a non-zero buffer length
+ * we also need a valid pointer in the buffer. If it's a zero buffer length,
+ * we'll be returning the needed buffer size, so keep going.
+ */
+ if (!DeviceHandle)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtValidateBuffer (RetBuffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Status = AcpiRsGetPrsMethodData (DeviceHandle, RetBuffer);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiWalkResources
+ *
+ * PARAMETERS: DeviceHandle - a handle to the device object for the
+ * device we are querying
+ * Path - method name of the resources we want
+ * (METHOD_NAME__CRS or METHOD_NAME__PRS)
+ * UserFunction - called for each resource
+ * Context - passed to UserFunction
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Retrieves the current or possible resource list for the
+ * specified device. The UserFunction is called once for
+ * each resource in the list.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiWalkResources (
+ ACPI_HANDLE DeviceHandle,
+ char *Path,
+ ACPI_WALK_RESOURCE_CALLBACK UserFunction,
+ void *Context)
+{
+ ACPI_STATUS Status;
+ ACPI_BUFFER Buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+ ACPI_RESOURCE *Resource;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiWalkResources");
+
+
+ if (!DeviceHandle ||
+ (ACPI_STRNCMP (Path, METHOD_NAME__CRS, sizeof (METHOD_NAME__CRS)) &&
+ ACPI_STRNCMP (Path, METHOD_NAME__PRS, sizeof (METHOD_NAME__PRS))))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiRsGetMethodData (DeviceHandle, Path, &Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ Resource = (ACPI_RESOURCE *) Buffer.Pointer;
+ for (;;)
+ {
+ if (!Resource || Resource->Id == ACPI_RSTYPE_END_TAG)
+ {
+ break;
+ }
+
+ Status = UserFunction (Resource, Context);
+
+ switch (Status)
+ {
+ case AE_OK:
+ case AE_CTRL_DEPTH:
+
+ /* Just keep going */
+ Status = AE_OK;
+ break;
+
+ case AE_CTRL_TERMINATE:
+
+ /* Exit now, with OK stats */
+
+ Status = AE_OK;
+ goto Cleanup;
+
+ default:
+
+ /* All others are valid exceptions */
+
+ goto Cleanup;
+ }
+
+ Resource = ACPI_NEXT_RESOURCE (Resource);
+ }
+
+Cleanup:
+
+ AcpiOsFree (Buffer.Pointer);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiSetCurrentResources
+ *
+ * PARAMETERS: DeviceHandle - a handle to the device object for the
+ * device we are changing the resources of
+ * InBuffer - a pointer to a buffer containing the
+ * resources to be set for the device
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to set the current resources for a
+ * specific device. The caller must first acquire a handle for
+ * the desired device. The resource data is passed to the routine
+ * the buffer pointed to by the InBuffer variable.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiSetCurrentResources (
+ ACPI_HANDLE DeviceHandle,
+ ACPI_BUFFER *InBuffer)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiSetCurrentResources");
+
+
+ /*
+ * Must have a valid handle and buffer
+ */
+ if ((!DeviceHandle) ||
+ (!InBuffer) ||
+ (!InBuffer->Pointer) ||
+ (!InBuffer->Length))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiRsSetSrsMethodData (DeviceHandle, InBuffer);
+ return_ACPI_STATUS (Status);
+}
+
+
+
+#define COPY_FIELD(Out, In, Field) Out->Field = In->Field
+#define COPY_ADDRESS(Out, In) \
+ COPY_FIELD(Out, In, ResourceType); \
+ COPY_FIELD(Out, In, ProducerConsumer); \
+ COPY_FIELD(Out, In, Decode); \
+ COPY_FIELD(Out, In, MinAddressFixed); \
+ COPY_FIELD(Out, In, MaxAddressFixed); \
+ COPY_FIELD(Out, In, Attribute); \
+ COPY_FIELD(Out, In, Granularity); \
+ COPY_FIELD(Out, In, MinAddressRange); \
+ COPY_FIELD(Out, In, MaxAddressRange); \
+ COPY_FIELD(Out, In, AddressTranslationOffset); \
+ COPY_FIELD(Out, In, AddressLength); \
+ COPY_FIELD(Out, In, ResourceSource);
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiResourceToAddress64
+ *
+ * PARAMETERS: resource - Pointer to a resource
+ * out - Pointer to the users's return
+ * buffer (a struct
+ * acpi_resource_address64)
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: If the resource is an address16, address32, or address64,
+ * copy it to the address64 return buffer. This saves the
+ * caller from having to duplicate code for different-sized
+ * addresses.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiResourceToAddress64 (
+ ACPI_RESOURCE *Resource,
+ ACPI_RESOURCE_ADDRESS64 *Out)
+{
+ ACPI_RESOURCE_ADDRESS16 *Address16;
+ ACPI_RESOURCE_ADDRESS32 *Address32;
+ ACPI_RESOURCE_ADDRESS64 *Address64;
+
+
+ switch (Resource->Id) {
+ case ACPI_RSTYPE_ADDRESS16:
+ Address16 = (ACPI_RESOURCE_ADDRESS16 *) &Resource->Data;
+ COPY_ADDRESS(Out, Address16);
+ break;
+
+ case ACPI_RSTYPE_ADDRESS32:
+ Address32 = (ACPI_RESOURCE_ADDRESS32 *) &Resource->Data;
+ COPY_ADDRESS(Out, Address32);
+ break;
+
+ case ACPI_RSTYPE_ADDRESS64:
+ Address64 = (ACPI_RESOURCE_ADDRESS64 *) &Resource->Data;
+ COPY_ADDRESS(Out, Address64);
+ break;
+
+ default:
+ return (AE_BAD_PARAMETER);
+ }
+
+ return (AE_OK);
+}
diff --git a/sys/contrib/dev/acpica/tbconvrt.c b/sys/contrib/dev/acpica/tbconvrt.c
new file mode 100644
index 0000000..1bf7535
--- /dev/null
+++ b/sys/contrib/dev/acpica/tbconvrt.c
@@ -0,0 +1,573 @@
+/******************************************************************************
+ *
+ * Module Name: tbconvrt - ACPI Table conversion utilities
+ * $Revision: 47 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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: RSDP - Pointer to the RSDP
+ * RSDT - Pointer to the RSDT/XSDT
+ *
+ * RETURN: The number of tables pointed to by the RSDT or XSDT.
+ *
+ * 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: TableInfo - Info about the RSDT
+ *
+ * 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->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, 0, LocalFadt->V1_Gpe0Blk);
+ ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XGpe1Blk, 0, 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,
+ 0, LocalFadt->V1_Gpe0Blk);
+ }
+
+ if (!(ACPI_GET_ADDRESS (LocalFadt->XGpe1Blk.Address)))
+ {
+ ASL_BUILD_GAS_FROM_V1_ENTRY (LocalFadt->XGpe1Blk,
+ 0, LocalFadt->V1_Gpe1Blk);
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbConvertTableFadt
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * 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->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/tbget.c b/sys/contrib/dev/acpica/tbget.c
new file mode 100644
index 0000000..9dc70b6
--- /dev/null
+++ b/sys/contrib/dev/acpica/tbget.c
@@ -0,0 +1,585 @@
+/******************************************************************************
+ *
+ * Module Name: tbget - ACPI Table get* routines
+ * $Revision: 83 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __TBGET_C__
+
+#include "acpi.h"
+#include "actables.h"
+
+
+#define _COMPONENT ACPI_TABLES
+ ACPI_MODULE_NAME ("tbget")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbGetTable
+ *
+ * PARAMETERS: Address - Address of table to retrieve. Can be
+ * Logical or Physical
+ * TableInfo - Where table info is returned
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Get entire table of unknown size.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbGetTable (
+ ACPI_POINTER *Address,
+ ACPI_TABLE_DESC *TableInfo)
+{
+ ACPI_STATUS Status;
+ ACPI_TABLE_HEADER Header;
+
+
+ ACPI_FUNCTION_TRACE ("TbGetTable");
+
+
+ /*
+ * Get the header in order to get signature and table size
+ */
+ Status = AcpiTbGetTableHeader (Address, &Header);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Get the entire table */
+
+ Status = AcpiTbGetTableBody (Address, &Header, TableInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("Could not get ACPI table (size %X), %s\n",
+ Header.Length, AcpiFormatException (Status)));
+ return_ACPI_STATUS (Status);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbGetTableHeader
+ *
+ * PARAMETERS: Address - Address of table to retrieve. Can be
+ * Logical or Physical
+ * ReturnHeader - Where the table header is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Get an ACPI table header. Works in both physical or virtual
+ * addressing mode. Works with both physical or logical pointers.
+ * Table is either copied or mapped, depending on the pointer
+ * type and mode of the processor.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbGetTableHeader (
+ ACPI_POINTER *Address,
+ ACPI_TABLE_HEADER *ReturnHeader)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_TABLE_HEADER *Header = NULL;
+
+
+ ACPI_FUNCTION_TRACE ("TbGetTableHeader");
+
+
+ /*
+ * Flags contains the current processor mode (Virtual or Physical addressing)
+ * The PointerType is either Logical or Physical
+ */
+ switch (Address->PointerType)
+ {
+ case ACPI_PHYSMODE_PHYSPTR:
+ case ACPI_LOGMODE_LOGPTR:
+
+ /* Pointer matches processor mode, copy the header */
+
+ ACPI_MEMCPY (ReturnHeader, Address->Pointer.Logical, sizeof (ACPI_TABLE_HEADER));
+ break;
+
+
+ case ACPI_LOGMODE_PHYSPTR:
+
+ /* Create a logical address for the physical pointer*/
+
+ Status = AcpiOsMapMemory (Address->Pointer.Physical, sizeof (ACPI_TABLE_HEADER),
+ (void **) &Header);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("Could not map memory at %8.8X%8.8X for length %X\n",
+ ACPI_HIDWORD (Address->Pointer.Physical),
+ ACPI_LODWORD (Address->Pointer.Physical),
+ sizeof (ACPI_TABLE_HEADER)));
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Copy header and delete mapping */
+
+ ACPI_MEMCPY (ReturnHeader, Header, sizeof (ACPI_TABLE_HEADER));
+ AcpiOsUnmapMemory (Header, sizeof (ACPI_TABLE_HEADER));
+ break;
+
+
+ default:
+
+ ACPI_REPORT_ERROR (("Invalid address flags %X\n",
+ Address->PointerType));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbGetTableBody
+ *
+ * PARAMETERS: Address - Address of table to retrieve. Can be
+ * Logical or Physical
+ * Header - Header of the table to retrieve
+ * TableInfo - Where the table info is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Get an entire ACPI table with support to allow the host OS to
+ * replace the table with a newer version (table override.)
+ * Works in both physical or virtual
+ * addressing mode. Works with both physical or logical pointers.
+ * Table is either copied or mapped, depending on the pointer
+ * type and mode of the processor.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbGetTableBody (
+ ACPI_POINTER *Address,
+ ACPI_TABLE_HEADER *Header,
+ ACPI_TABLE_DESC *TableInfo)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("TbGetTableBody");
+
+
+ if (!TableInfo || !Address)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Attempt table override.
+ */
+ Status = AcpiTbTableOverride (Header, TableInfo);
+ if (ACPI_SUCCESS (Status))
+ {
+ /* Table was overridden by the host OS */
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /* No override, get the original table */
+
+ Status = AcpiTbGetThisTable (Address, Header, TableInfo);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbTableOverride
+ *
+ * PARAMETERS: Header - Pointer to table header
+ * TableInfo - Return info if table is overridden
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Attempts override of current table with a new one if provided
+ * by the host OS.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbTableOverride (
+ ACPI_TABLE_HEADER *Header,
+ ACPI_TABLE_DESC *TableInfo)
+{
+ ACPI_TABLE_HEADER *NewTable;
+ ACPI_STATUS Status;
+ ACPI_POINTER Address;
+
+
+ ACPI_FUNCTION_TRACE ("TbTableOverride");
+
+
+ /*
+ * The OSL will examine the header and decide whether to override this
+ * table. If it decides to override, a table will be returned in NewTable,
+ * which we will then copy.
+ */
+ Status = AcpiOsTableOverride (Header, &NewTable);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Some severe error from the OSL, but we basically ignore it */
+
+ ACPI_REPORT_ERROR (("Could not override ACPI table, %s\n",
+ AcpiFormatException (Status)));
+ return_ACPI_STATUS (Status);
+ }
+
+ if (!NewTable)
+ {
+ /* No table override */
+
+ return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+ }
+
+ /*
+ * We have a new table to override the old one. Get a copy of
+ * the new one. We know that the new table has a logical pointer.
+ */
+ Address.PointerType = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING;
+ Address.Pointer.Logical = NewTable;
+
+ Status = AcpiTbGetThisTable (&Address, NewTable, TableInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("Could not copy override ACPI table, %s\n",
+ AcpiFormatException (Status)));
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Copy the table info */
+
+ ACPI_REPORT_INFO (("Table [%4.4s] replaced by host OS\n",
+ TableInfo->Pointer->Signature));
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbGetThisTable
+ *
+ * PARAMETERS: Address - Address of table to retrieve. Can be
+ * Logical or Physical
+ * Header - Header of the table to retrieve
+ * TableInfo - Where the table info is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Get an entire ACPI table. Works in both physical or virtual
+ * addressing mode. Works with both physical or logical pointers.
+ * Table is either copied or mapped, depending on the pointer
+ * type and mode of the processor.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbGetThisTable (
+ ACPI_POINTER *Address,
+ ACPI_TABLE_HEADER *Header,
+ ACPI_TABLE_DESC *TableInfo)
+{
+ ACPI_TABLE_HEADER *FullTable = NULL;
+ UINT8 Allocation;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE ("TbGetThisTable");
+
+
+ /*
+ * Flags contains the current processor mode (Virtual or Physical addressing)
+ * The PointerType is either Logical or Physical
+ */
+ switch (Address->PointerType)
+ {
+ case ACPI_PHYSMODE_PHYSPTR:
+ case ACPI_LOGMODE_LOGPTR:
+
+ /* Pointer matches processor mode, copy the table to a new buffer */
+
+ FullTable = ACPI_MEM_ALLOCATE (Header->Length);
+ if (!FullTable)
+ {
+ ACPI_REPORT_ERROR (("Could not allocate table memory for [%4.4s] length %X\n",
+ Header->Signature, Header->Length));
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ /* Copy the entire table (including header) to the local buffer */
+
+ ACPI_MEMCPY (FullTable, Address->Pointer.Logical, Header->Length);
+
+ /* Save allocation type */
+
+ Allocation = ACPI_MEM_ALLOCATED;
+ break;
+
+
+ case ACPI_LOGMODE_PHYSPTR:
+
+ /*
+ * Just map the table's physical memory
+ * into our address space.
+ */
+ Status = AcpiOsMapMemory (Address->Pointer.Physical, (ACPI_SIZE) Header->Length,
+ (void **) &FullTable);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("Could not map memory for table [%4.4s] at %8.8X%8.8X for length %X\n",
+ Header->Signature,
+ ACPI_HIDWORD (Address->Pointer.Physical),
+ ACPI_LODWORD (Address->Pointer.Physical), Header->Length));
+ return (Status);
+ }
+
+ /* Save allocation type */
+
+ Allocation = ACPI_MEM_MAPPED;
+ break;
+
+
+ default:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid address flags %X\n",
+ Address->PointerType));
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * Validate checksum for _most_ tables,
+ * even the ones whose signature we don't recognize
+ */
+ if (TableInfo->Type != ACPI_TABLE_FACS)
+ {
+ Status = AcpiTbVerifyTableChecksum (FullTable);
+
+#if (!ACPI_CHECKSUM_ABORT)
+ if (ACPI_FAILURE (Status))
+ {
+ /* Ignore the error if configuration says so */
+
+ Status = AE_OK;
+ }
+#endif
+ }
+
+ /* Return values */
+
+ TableInfo->Pointer = FullTable;
+ TableInfo->Length = (ACPI_SIZE) Header->Length;
+ TableInfo->Allocation = Allocation;
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Found table [%4.4s] at %8.8X%8.8X, mapped/copied to %p\n",
+ FullTable->Signature,
+ ACPI_HIDWORD (Address->Pointer.Physical),
+ ACPI_LODWORD (Address->Pointer.Physical), FullTable));
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTbGetTablePtr
+ *
+ * PARAMETERS: TableType - one of the defined table types
+ * Instance - Which table of this type
+ * TablePtrLoc - pointer to location to place the pointer for
+ * return
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to get the pointer to an ACPI table.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbGetTablePtr (
+ ACPI_TABLE_TYPE TableType,
+ UINT32 Instance,
+ ACPI_TABLE_HEADER **TablePtrLoc)
+{
+ ACPI_TABLE_DESC *TableDesc;
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE ("TbGetTablePtr");
+
+
+ if (!AcpiGbl_DSDT)
+ {
+ return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+ }
+
+ if (TableType > ACPI_TABLE_MAX)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /*
+ * For all table types (Single/Multiple), the first
+ * instance is always in the list head.
+ */
+ if (Instance == 1)
+ {
+ /*
+ * Just pluck the pointer out of the global table!
+ * Will be null if no table is present
+ */
+ *TablePtrLoc = AcpiGbl_AcpiTables[TableType].Pointer;
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Check for instance out of range
+ */
+ if (Instance > AcpiGbl_AcpiTables[TableType].Count)
+ {
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ /* Walk the list to get the desired table
+ * Since the if (Instance == 1) check above checked for the
+ * first table, setting TableDesc equal to the .Next member
+ * is actually pointing to the second table. Therefore, we
+ * need to walk from the 2nd table until we reach the Instance
+ * that the user is looking for and return its table pointer.
+ */
+ TableDesc = AcpiGbl_AcpiTables[TableType].Next;
+ for (i = 2; i < Instance; i++)
+ {
+ TableDesc = TableDesc->Next;
+ }
+
+ /* We are now pointing to the requested table's descriptor */
+
+ *TablePtrLoc = TableDesc->Pointer;
+
+ return_ACPI_STATUS (AE_OK);
+}
+
diff --git a/sys/contrib/dev/acpica/tbgetall.c b/sys/contrib/dev/acpica/tbgetall.c
new file mode 100644
index 0000000..3e7989a
--- /dev/null
+++ b/sys/contrib/dev/acpica/tbgetall.c
@@ -0,0 +1,403 @@
+/******************************************************************************
+ *
+ * Module Name: tbgetall - Get all required ACPI tables
+ * $Revision: 5 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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.
+ */
+ 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
new file mode 100644
index 0000000..5e5f017
--- /dev/null
+++ b/sys/contrib/dev/acpica/tbinstal.c
@@ -0,0 +1,682 @@
+/******************************************************************************
+ *
+ * Module Name: tbinstal - ACPI table installation and removal
+ * $Revision: 68 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 (
+ char *Signature,
+ ACPI_TABLE_DESC *TableInfo,
+ UINT8 SearchType)
+{
+ ACPI_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 & 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] is an ACPI table consumed by the core subsystem\n",
+ (char *) AcpiGbl_AcpiTableData[i].Signature));
+
+ return_ACPI_STATUS (AE_OK);
+ }
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+ "Table [%4.4s] is not an ACPI table consumed by the core subsystem - 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 [%4.4s], %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->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->Pointer);
+ break;
+
+ case ACPI_MEM_MAPPED:
+
+ 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
new file mode 100644
index 0000000..c93684c
--- /dev/null
+++ b/sys/contrib/dev/acpica/tbrsdt.c
@@ -0,0 +1,406 @@
+/******************************************************************************
+ *
+ * Module Name: tbrsdt - ACPI RSDT table utilities
+ * $Revision: 7 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 ((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;
+
+ /* 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 *) (ACPI_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
new file mode 100644
index 0000000..d3cb75b
--- /dev/null
+++ b/sys/contrib/dev/acpica/tbutils.c
@@ -0,0 +1,323 @@
+/******************************************************************************
+ *
+ * Module Name: tbutils - Table manipulation utilities
+ * $Revision: 58 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 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/tbxface.c b/sys/contrib/dev/acpica/tbxface.c
new file mode 100644
index 0000000..6a345dc
--- /dev/null
+++ b/sys/contrib/dev/acpica/tbxface.c
@@ -0,0 +1,541 @@
+/******************************************************************************
+ *
+ * Module Name: tbxface - Public interfaces to the ACPI subsystem
+ * ACPI table oriented interfaces
+ * $Revision: 61 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __TBXFACE_C__
+
+#include "acpi.h"
+#include "acnamesp.h"
+#include "actables.h"
+
+
+#define _COMPONENT ACPI_TABLES
+ ACPI_MODULE_NAME ("tbxface")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiLoadTables
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to load the ACPI tables from the
+ * provided RSDT
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiLoadTables (void)
+{
+ ACPI_POINTER RsdpAddress;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiLoadTables");
+
+
+ /* Get the RSDP */
+
+ Status = AcpiOsGetRootPointer (ACPI_LOGICAL_ADDRESSING,
+ &RsdpAddress);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("AcpiLoadTables: Could not get RSDP, %s\n",
+ AcpiFormatException (Status)));
+ goto ErrorExit;
+ }
+
+ /* Map and validate the RSDP */
+
+ AcpiGbl_TableFlags = RsdpAddress.PointerType;
+
+ Status = AcpiTbVerifyRsdp (&RsdpAddress);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("AcpiLoadTables: RSDP Failed validation: %s\n",
+ AcpiFormatException (Status)));
+ goto ErrorExit;
+ }
+
+ /* Get the RSDT via the RSDP */
+
+ Status = AcpiTbGetTableRsdt ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("AcpiLoadTables: Could not load RSDT: %s\n",
+ AcpiFormatException (Status)));
+ goto ErrorExit;
+ }
+
+ /* Now get the tables needed by this subsystem (FADT, DSDT, etc.) */
+
+ Status = AcpiTbGetRequiredTables ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("AcpiLoadTables: Error getting required tables (DSDT/FADT/FACS): %s\n",
+ AcpiFormatException (Status)));
+ goto ErrorExit;
+ }
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
+
+
+ /* Load the namespace from the tables */
+
+ Status = AcpiNsLoadNamespace ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("AcpiLoadTables: Could not load namespace: %s\n",
+ AcpiFormatException (Status)));
+ goto ErrorExit;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+
+
+ErrorExit:
+ ACPI_REPORT_ERROR (("AcpiLoadTables: Could not load tables: %s\n",
+ AcpiFormatException (Status)));
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiLoadTable
+ *
+ * PARAMETERS: TablePtr - pointer to a buffer containing the entire
+ * table to be loaded
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to load a table from the caller's
+ * buffer. The buffer must contain an entire ACPI Table including
+ * a valid header. The header fields will be verified, and if it
+ * is determined that the table is invalid, the call will fail.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiLoadTable (
+ ACPI_TABLE_HEADER *TablePtr)
+{
+ ACPI_STATUS Status;
+ ACPI_TABLE_DESC TableInfo;
+ ACPI_POINTER Address;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiLoadTable");
+
+
+ if (!TablePtr)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Copy the table to a local buffer */
+
+ Address.PointerType = ACPI_LOGICAL_POINTER | ACPI_LOGICAL_ADDRESSING;
+ Address.Pointer.Logical = TablePtr;
+
+ Status = AcpiTbGetTableBody (&Address, TablePtr, &TableInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Install the new table into the local data structures */
+
+ Status = AcpiTbInstallTable (&TableInfo);
+ if (ACPI_FAILURE (Status))
+ {
+ /* Free table allocated by AcpiTbGetTableBody */
+
+ AcpiTbDeleteSingleTable (&TableInfo);
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Convert the table to common format if necessary */
+
+ switch (TableInfo.Type)
+ {
+ case ACPI_TABLE_FADT:
+
+ Status = AcpiTbConvertTableFadt ();
+ break;
+
+ case ACPI_TABLE_FACS:
+
+ Status = AcpiTbBuildCommonFacs (&TableInfo);
+ break;
+
+ default:
+ /* Load table into namespace if it contains executable AML */
+
+ Status = AcpiNsLoadTable (TableInfo.InstalledDesc, AcpiGbl_RootNode);
+ break;
+ }
+
+ if (ACPI_FAILURE (Status))
+ {
+ /* Uninstall table and free the buffer */
+
+ (void) AcpiTbUninstallTable (TableInfo.InstalledDesc);
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUnloadTable
+ *
+ * PARAMETERS: TableType - Type of table to be unloaded
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This routine is used to force the unload of a table
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUnloadTable (
+ ACPI_TABLE_TYPE TableType)
+{
+ ACPI_TABLE_DESC *ListHead;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiUnloadTable");
+
+
+ /* Parameter validation */
+
+ if (TableType > ACPI_TABLE_MAX)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+
+ /* Find all tables of the requested type */
+
+ ListHead = &AcpiGbl_AcpiTables[TableType];
+ do
+ {
+ /*
+ * Delete all namespace entries owned by this table. Note that these
+ * entries can appear anywhere in the namespace by virtue of the AML
+ * "Scope" operator. Thus, we need to track ownership by an ID, not
+ * simply a position within the hierarchy
+ */
+ AcpiNsDeleteNamespaceByOwner (ListHead->TableId);
+
+ /* Delete (or unmap) the actual table */
+
+ AcpiTbDeleteAcpiTable (TableType);
+
+ } while (ListHead != &AcpiGbl_AcpiTables[TableType]);
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetTableHeader
+ *
+ * PARAMETERS: TableType - one of the defined table types
+ * Instance - the non zero instance of the table, allows
+ * support for multiple tables of the same type
+ * see AcpiGbl_AcpiTableFlag
+ * OutTableHeader - pointer to the ACPI_TABLE_HEADER if successful
+ *
+ * DESCRIPTION: This function is called to get an ACPI table header. The caller
+ * supplies an pointer to a data area sufficient to contain an ACPI
+ * ACPI_TABLE_HEADER structure.
+ *
+ * The header contains a length field that can be used to determine
+ * the size of the buffer needed to contain the entire table. This
+ * function is not valid for the RSD PTR table since it does not
+ * have a standard header and is fixed length.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetTableHeader (
+ ACPI_TABLE_TYPE TableType,
+ UINT32 Instance,
+ ACPI_TABLE_HEADER *OutTableHeader)
+{
+ ACPI_TABLE_HEADER *TblPtr;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiGetTableHeader");
+
+
+ if ((Instance == 0) ||
+ (TableType == ACPI_TABLE_RSDP) ||
+ (!OutTableHeader))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ /* Check the table type and instance */
+
+ if ((TableType > ACPI_TABLE_MAX) ||
+ (ACPI_IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags) &&
+ Instance > 1))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+
+ /* Get a pointer to the entire table */
+
+ Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * The function will return a NULL pointer if the table is not loaded
+ */
+ if (TblPtr == NULL)
+ {
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ /*
+ * Copy the header to the caller's buffer
+ */
+ ACPI_MEMCPY ((void *) OutTableHeader, (void *) TblPtr,
+ sizeof (ACPI_TABLE_HEADER));
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiGetTable
+ *
+ * PARAMETERS: TableType - one of the defined table types
+ * Instance - the non zero instance of the table, allows
+ * support for multiple tables of the same type
+ * see AcpiGbl_AcpiTableFlag
+ * 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. The caller should call the AcpiGetTableHeader function
+ * first to determine the buffer size needed. 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
+AcpiGetTable (
+ ACPI_TABLE_TYPE TableType,
+ UINT32 Instance,
+ ACPI_BUFFER *RetBuffer)
+{
+ ACPI_TABLE_HEADER *TblPtr;
+ ACPI_STATUS Status;
+ ACPI_SIZE TableLength;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiGetTable");
+
+
+ /* Parameter validation */
+
+ if (Instance == 0)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ Status = AcpiUtValidateBuffer (RetBuffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Check the table type and instance */
+
+ if ((TableType > ACPI_TABLE_MAX) ||
+ (ACPI_IS_SINGLE_TABLE (AcpiGbl_AcpiTableData[TableType].Flags) &&
+ Instance > 1))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+
+ /* Get a pointer to the entire table */
+
+ Status = AcpiTbGetTablePtr (TableType, Instance, &TblPtr);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * AcpiTbGetTablePtr will return a NULL pointer if the
+ * table is not loaded.
+ */
+ if (TblPtr == NULL)
+ {
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ /* Get the table length */
+
+ if (TableType == ACPI_TABLE_RSDP)
+ {
+ /*
+ * RSD PTR is the only "table" without a header
+ */
+ TableLength = sizeof (RSDP_DESCRIPTOR);
+ }
+ else
+ {
+ TableLength = (ACPI_SIZE) TblPtr->Length;
+ }
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (RetBuffer, TableLength);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Copy the table to the buffer */
+
+ ACPI_MEMCPY ((void *) RetBuffer->Pointer, (void *) TblPtr, TableLength);
+ return_ACPI_STATUS (AE_OK);
+}
+
+
diff --git a/sys/contrib/dev/acpica/tbxfroot.c b/sys/contrib/dev/acpica/tbxfroot.c
new file mode 100644
index 0000000..42c39bc
--- /dev/null
+++ b/sys/contrib/dev/acpica/tbxfroot.c
@@ -0,0 +1,611 @@
+/******************************************************************************
+ *
+ * Module Name: tbxfroot - Find the root ACPI table (RSDT)
+ * $Revision: 68 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 (
+ char *Signature,
+ char *OemId,
+ 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 ((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, %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 += ACPI_RSDP_SCAN_STEP, MemRover += ACPI_RSDP_SCAN_STEP)
+ {
+
+ /* The signature and checksum must both be correct */
+
+ if (ACPI_STRNCMP ((char *) MemRover,
+ RSDP_SIG, sizeof (RSDP_SIG)-1) == 0 &&
+ AcpiTbChecksum (MemRover, ACPI_RSDP_CHECKSUM_LENGTH) == 0)
+ {
+ /* If 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) ACPI_LO_RSDP_WINDOW_BASE, ACPI_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",
+ ACPI_LO_RSDP_WINDOW_BASE, ACPI_LO_RSDP_WINDOW_SIZE));
+ return_ACPI_STATUS (Status);
+ }
+
+ MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_LO_RSDP_WINDOW_SIZE);
+ AcpiOsUnmapMemory (TablePtr, ACPI_LO_RSDP_WINDOW_SIZE);
+
+ if (MemRover)
+ {
+ /* Found it, return the physical address */
+
+ PhysAddr = ACPI_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) ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE,
+ (void **) &TablePtr);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %X for length %X\n",
+ ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE));
+ return_ACPI_STATUS (Status);
+ }
+
+ MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
+ AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
+
+ if (MemRover)
+ {
+ /* Found it, return the physical address */
+
+ PhysAddr = ACPI_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 (ACPI_LO_RSDP_WINDOW_BASE),
+ ACPI_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 (ACPI_HI_RSDP_WINDOW_BASE),
+ ACPI_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/utalloc.c b/sys/contrib/dev/acpica/utalloc.c
new file mode 100644
index 0000000..a05795d
--- /dev/null
+++ b/sys/contrib/dev/acpica/utalloc.c
@@ -0,0 +1,1119 @@
+/******************************************************************************
+ *
+ * Module Name: utalloc - local cache and memory allocation routines
+ * $Revision: 131 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __UTALLOC_C__
+
+#include "acpi.h"
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utalloc")
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiUtReleaseToCache
+ *
+ * PARAMETERS: ListId - Memory list/cache ID
+ * Object - The object to be released
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Release an object to the specified cache. If cache is full,
+ * the object is deleted.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtReleaseToCache (
+ UINT32 ListId,
+ void *Object)
+{
+ ACPI_MEMORY_LIST *CacheInfo;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* If walk cache is full, just free this wallkstate object */
+
+ CacheInfo = &AcpiGbl_MemoryLists[ListId];
+ if (CacheInfo->CacheDepth >= CacheInfo->MaxCacheDepth)
+ {
+ ACPI_MEM_FREE (Object);
+ ACPI_MEM_TRACKING (CacheInfo->TotalFreed++);
+ }
+
+ /* Otherwise put this object back into the cache */
+
+ else
+ {
+ if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
+ {
+ return;
+ }
+
+ /* Mark the object as cached */
+
+ ACPI_MEMSET (Object, 0xCA, CacheInfo->ObjectSize);
+ ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED);
+
+ /* Put the object at the head of the cache list */
+
+ * (ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset]))) = CacheInfo->ListHead;
+ CacheInfo->ListHead = Object;
+ CacheInfo->CacheDepth++;
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
+ }
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiUtAcquireFromCache
+ *
+ * PARAMETERS: ListId - Memory list ID
+ *
+ * RETURN: A requested object. NULL if the object could not be
+ * allocated.
+ *
+ * DESCRIPTION: Get an object from the specified cache. If cache is empty,
+ * the object is allocated.
+ *
+ ******************************************************************************/
+
+void *
+AcpiUtAcquireFromCache (
+ UINT32 ListId)
+{
+ ACPI_MEMORY_LIST *CacheInfo;
+ void *Object;
+
+
+ ACPI_FUNCTION_NAME ("UtAcquireFromCache");
+
+
+ CacheInfo = &AcpiGbl_MemoryLists[ListId];
+ if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
+ {
+ return (NULL);
+ }
+
+ ACPI_MEM_TRACKING (CacheInfo->CacheRequests++);
+
+ /* Check the cache first */
+
+ if (CacheInfo->ListHead)
+ {
+ /* There is an object available, use it */
+
+ Object = CacheInfo->ListHead;
+ CacheInfo->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset])));
+
+ ACPI_MEM_TRACKING (CacheInfo->CacheHits++);
+ CacheInfo->CacheDepth--;
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p from %s\n",
+ Object, AcpiGbl_MemoryLists[ListId].ListName));
+#endif
+
+ if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES)))
+ {
+ return (NULL);
+ }
+
+ /* Clear (zero) the previously used Object */
+
+ ACPI_MEMSET (Object, 0, CacheInfo->ObjectSize);
+ }
+
+ else
+ {
+ /* The cache is empty, create a new object */
+
+ /* Avoid deadlock with ACPI_MEM_CALLOCATE */
+
+ if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES)))
+ {
+ return (NULL);
+ }
+
+ Object = ACPI_MEM_CALLOCATE (CacheInfo->ObjectSize);
+ ACPI_MEM_TRACKING (CacheInfo->TotalAllocated++);
+ }
+
+ return (Object);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiUtDeleteGenericCache
+ *
+ * PARAMETERS: ListId - Memory list ID
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Free all objects within the requested cache.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtDeleteGenericCache (
+ UINT32 ListId)
+{
+ ACPI_MEMORY_LIST *CacheInfo;
+ char *Next;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ CacheInfo = &AcpiGbl_MemoryLists[ListId];
+ while (CacheInfo->ListHead)
+ {
+ /* Delete one cached state object */
+
+ Next = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) CacheInfo->ListHead)[CacheInfo->LinkOffset])));
+ ACPI_MEM_FREE (CacheInfo->ListHead);
+
+ CacheInfo->ListHead = Next;
+ CacheInfo->CacheDepth--;
+ }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtValidateBuffer
+ *
+ * PARAMETERS: Buffer - Buffer descriptor to be validated
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Perform parameter validation checks on an ACPI_BUFFER
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtValidateBuffer (
+ ACPI_BUFFER *Buffer)
+{
+
+ /* Obviously, the structure pointer must be valid */
+
+ if (!Buffer)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ /* Special semantics for the length */
+
+ if ((Buffer->Length == ACPI_NO_BUFFER) ||
+ (Buffer->Length == ACPI_ALLOCATE_BUFFER) ||
+ (Buffer->Length == ACPI_ALLOCATE_LOCAL_BUFFER))
+ {
+ return (AE_OK);
+ }
+
+ /* Length is valid, the buffer pointer must be also */
+
+ if (!Buffer->Pointer)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtInitializeBuffer
+ *
+ * PARAMETERS: RequiredLength - Length needed
+ * Buffer - Buffer to be validated
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Validate that the buffer is of the required length or
+ * allocate a new buffer.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtInitializeBuffer (
+ ACPI_BUFFER *Buffer,
+ ACPI_SIZE RequiredLength)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ switch (Buffer->Length)
+ {
+ case ACPI_NO_BUFFER:
+
+ /* Set the exception and returned the required length */
+
+ Status = AE_BUFFER_OVERFLOW;
+ break;
+
+
+ case ACPI_ALLOCATE_BUFFER:
+
+ /* Allocate a new buffer */
+
+ Buffer->Pointer = AcpiOsAllocate (RequiredLength);
+ if (!Buffer->Pointer)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Clear the buffer */
+
+ ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
+ break;
+
+
+ case ACPI_ALLOCATE_LOCAL_BUFFER:
+
+ /* Allocate a new buffer with local interface to allow tracking */
+
+ Buffer->Pointer = ACPI_MEM_ALLOCATE (RequiredLength);
+ if (!Buffer->Pointer)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /* Clear the buffer */
+
+ ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
+ break;
+
+
+ default:
+
+ /* Validate the size of the buffer */
+
+ if (Buffer->Length < RequiredLength)
+ {
+ Status = AE_BUFFER_OVERFLOW;
+ }
+ break;
+ }
+
+ Buffer->Length = RequiredLength;
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtAllocate
+ *
+ * PARAMETERS: Size - Size of the allocation
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN: Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: The subsystem's equivalent of malloc.
+ *
+ ******************************************************************************/
+
+void *
+AcpiUtAllocate (
+ ACPI_SIZE Size,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line)
+{
+ void *Allocation;
+
+
+ ACPI_FUNCTION_TRACE_U32 ("UtAllocate", Size);
+
+
+ /* Check for an inadvertent size of zero bytes */
+
+ if (!Size)
+ {
+ _ACPI_REPORT_ERROR (Module, Line, Component,
+ ("UtAllocate: Attempt to allocate zero bytes\n"));
+ Size = 1;
+ }
+
+ Allocation = AcpiOsAllocate (Size);
+ if (!Allocation)
+ {
+ /* Report allocation error */
+
+ _ACPI_REPORT_ERROR (Module, Line, Component,
+ ("UtAllocate: Could not allocate size %X\n", (UINT32) Size));
+
+ return_PTR (NULL);
+ }
+
+ return_PTR (Allocation);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCallocate
+ *
+ * PARAMETERS: Size - Size of the allocation
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN: Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: Subsystem equivalent of calloc.
+ *
+ ******************************************************************************/
+
+void *
+AcpiUtCallocate (
+ ACPI_SIZE Size,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line)
+{
+ void *Allocation;
+
+
+ ACPI_FUNCTION_TRACE_U32 ("UtCallocate", Size);
+
+
+ /* Check for an inadvertent size of zero bytes */
+
+ if (!Size)
+ {
+ _ACPI_REPORT_ERROR (Module, Line, Component,
+ ("UtCallocate: Attempt to allocate zero bytes\n"));
+ return_PTR (NULL);
+ }
+
+ Allocation = AcpiOsAllocate (Size);
+ if (!Allocation)
+ {
+ /* Report allocation error */
+
+ _ACPI_REPORT_ERROR (Module, Line, Component,
+ ("UtCallocate: Could not allocate size %X\n", (UINT32) Size));
+ return_PTR (NULL);
+ }
+
+ /* Clear the memory block */
+
+ ACPI_MEMSET (Allocation, 0, Size);
+ return_PTR (Allocation);
+}
+
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+/*
+ * These procedures are used for tracking memory leaks in the subsystem, and
+ * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
+ *
+ * Each memory allocation is tracked via a doubly linked list. Each
+ * element contains the caller's component, module name, function name, and
+ * line number. AcpiUtAllocate and AcpiUtCallocate call
+ * AcpiUtTrackAllocation to add an element to the list; deletion
+ * occurs in the body of AcpiUtFree.
+ */
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtAllocateAndTrack
+ *
+ * PARAMETERS: Size - Size of the allocation
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN: Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: The subsystem's equivalent of malloc.
+ *
+ ******************************************************************************/
+
+void *
+AcpiUtAllocateAndTrack (
+ ACPI_SIZE Size,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line)
+{
+ ACPI_DEBUG_MEM_BLOCK *Allocation;
+ ACPI_STATUS Status;
+
+
+ Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component,
+ Module, Line);
+ if (!Allocation)
+ {
+ return (NULL);
+ }
+
+ Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size,
+ ACPI_MEM_MALLOC, Component, Module, Line);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsFree (Allocation);
+ return (NULL);
+ }
+
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++;
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += (UINT32) Size;
+
+ return ((void *) &Allocation->UserSpace);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtCallocateAndTrack
+ *
+ * PARAMETERS: Size - Size of the allocation
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN: Address of the allocated memory on success, NULL on failure.
+ *
+ * DESCRIPTION: Subsystem equivalent of calloc.
+ *
+ ******************************************************************************/
+
+void *
+AcpiUtCallocateAndTrack (
+ ACPI_SIZE Size,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line)
+{
+ ACPI_DEBUG_MEM_BLOCK *Allocation;
+ ACPI_STATUS Status;
+
+
+ Allocation = AcpiUtCallocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component,
+ Module, Line);
+ if (!Allocation)
+ {
+ /* Report allocation error */
+
+ _ACPI_REPORT_ERROR (Module, Line, Component,
+ ("UtCallocate: Could not allocate size %X\n", (UINT32) Size));
+ return (NULL);
+ }
+
+ Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size,
+ ACPI_MEM_CALLOC, Component, Module, Line);
+ if (ACPI_FAILURE (Status))
+ {
+ AcpiOsFree (Allocation);
+ return (NULL);
+ }
+
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++;
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += (UINT32) Size;
+
+ return ((void *) &Allocation->UserSpace);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtFreeAndTrack
+ *
+ * PARAMETERS: Allocation - Address of the memory to deallocate
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Frees the memory at Allocation
+ *
+ ******************************************************************************/
+
+void
+AcpiUtFreeAndTrack (
+ void *Allocation,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line)
+{
+ ACPI_DEBUG_MEM_BLOCK *DebugBlock;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("UtFree", Allocation);
+
+
+ if (NULL == Allocation)
+ {
+ _ACPI_REPORT_ERROR (Module, Line, Component,
+ ("AcpiUtFree: Attempt to delete a NULL address\n"));
+
+ return_VOID;
+ }
+
+ DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK,
+ (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER)));
+
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalFreed++;
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize -= DebugBlock->Size;
+
+ Status = AcpiUtRemoveAllocation (ACPI_MEM_LIST_GLOBAL, DebugBlock,
+ Component, Module, Line);
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n",
+ AcpiFormatException (Status)));
+ }
+
+ AcpiOsFree (DebugBlock);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation));
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtFindAllocation
+ *
+ * PARAMETERS: Allocation - Address of allocated memory
+ *
+ * RETURN: A list element if found; NULL otherwise.
+ *
+ * DESCRIPTION: Searches for an element in the global allocation tracking list.
+ *
+ ******************************************************************************/
+
+ACPI_DEBUG_MEM_BLOCK *
+AcpiUtFindAllocation (
+ UINT32 ListId,
+ void *Allocation)
+{
+ ACPI_DEBUG_MEM_BLOCK *Element;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ if (ListId > ACPI_MEM_LIST_MAX)
+ {
+ return (NULL);
+ }
+
+ Element = AcpiGbl_MemoryLists[ListId].ListHead;
+
+ /* Search for the address. */
+
+ while (Element)
+ {
+ if (Element == Allocation)
+ {
+ return (Element);
+ }
+
+ Element = Element->Next;
+ }
+
+ return (NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtTrackAllocation
+ *
+ * PARAMETERS: Allocation - Address of allocated memory
+ * Size - Size of the allocation
+ * AllocType - MEM_MALLOC or MEM_CALLOC
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Inserts an element into the global allocation tracking list.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtTrackAllocation (
+ UINT32 ListId,
+ ACPI_DEBUG_MEM_BLOCK *Allocation,
+ ACPI_SIZE Size,
+ UINT8 AllocType,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line)
+{
+ ACPI_MEMORY_LIST *MemList;
+ ACPI_DEBUG_MEM_BLOCK *Element;
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE_PTR ("UtTrackAllocation", Allocation);
+
+
+ if (ListId > ACPI_MEM_LIST_MAX)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ MemList = &AcpiGbl_MemoryLists[ListId];
+ Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Search list for this address to make sure it is not already on the list.
+ * This will catch several kinds of problems.
+ */
+
+ Element = AcpiUtFindAllocation (ListId, Allocation);
+ if (Element)
+ {
+ ACPI_REPORT_ERROR (("UtTrackAllocation: Allocation already present in list! (%p)\n",
+ Allocation));
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", Element, Allocation));
+
+ goto UnlockAndExit;
+ }
+
+ /* Fill in the instance data. */
+
+ Allocation->Size = (UINT32) Size;
+ Allocation->AllocType = AllocType;
+ Allocation->Component = Component;
+ Allocation->Line = Line;
+
+ ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
+
+ /* Insert at list head */
+
+ if (MemList->ListHead)
+ {
+ ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation;
+ }
+
+ Allocation->Next = MemList->ListHead;
+ Allocation->Previous = NULL;
+
+ MemList->ListHead = Allocation;
+
+
+UnlockAndExit:
+ Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtRemoveAllocation
+ *
+ * PARAMETERS: Allocation - Address of allocated memory
+ * Component - Component type of caller
+ * Module - Source file name of caller
+ * Line - Line number of caller
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Deletes an element from the global allocation tracking list.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtRemoveAllocation (
+ UINT32 ListId,
+ ACPI_DEBUG_MEM_BLOCK *Allocation,
+ UINT32 Component,
+ char *Module,
+ UINT32 Line)
+{
+ ACPI_MEMORY_LIST *MemList;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("UtRemoveAllocation");
+
+
+ if (ListId > ACPI_MEM_LIST_MAX)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
+ MemList = &AcpiGbl_MemoryLists[ListId];
+ if (NULL == MemList->ListHead)
+ {
+ /* No allocations! */
+
+ _ACPI_REPORT_ERROR (Module, Line, Component,
+ ("UtRemoveAllocation: Empty allocation list, nothing to free!\n"));
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Unlink */
+
+ if (Allocation->Previous)
+ {
+ (Allocation->Previous)->Next = Allocation->Next;
+ }
+ else
+ {
+ MemList->ListHead = Allocation->Next;
+ }
+
+ if (Allocation->Next)
+ {
+ (Allocation->Next)->Previous = Allocation->Previous;
+ }
+
+ /* Mark the segment as deleted */
+
+ ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size %X\n", Allocation->Size));
+
+ Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDumpAllocationInfo
+ *
+ * PARAMETERS:
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print some info about the outstanding allocations.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtDumpAllocationInfo (
+ void)
+{
+/*
+ ACPI_MEMORY_LIST *MemList;
+*/
+
+ ACPI_FUNCTION_TRACE ("UtDumpAllocationInfo");
+
+/*
+ ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
+ ("%30s: %4d (%3d Kb)\n", "Current allocations",
+ MemList->CurrentCount,
+ ROUND_UP_TO_1K (MemList->CurrentSize)));
+
+ ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
+ ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
+ MemList->MaxConcurrentCount,
+ ROUND_UP_TO_1K (MemList->MaxConcurrentSize)));
+
+
+ ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
+ ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
+ RunningObjectCount,
+ ROUND_UP_TO_1K (RunningObjectSize)));
+
+ ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
+ ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
+ RunningAllocCount,
+ ROUND_UP_TO_1K (RunningAllocSize)));
+
+
+ ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
+ ("%30s: %4d (%3d Kb)\n", "Current Nodes",
+ AcpiGbl_CurrentNodeCount,
+ ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize)));
+
+ ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
+ ("%30s: %4d (%3d Kb)\n", "Max Nodes",
+ AcpiGbl_MaxConcurrentNodeCount,
+ ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * sizeof (ACPI_NAMESPACE_NODE)))));
+*/
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDumpAllocations
+ *
+ * PARAMETERS: Component - Component(s) to dump info for.
+ * Module - Module to dump info for. NULL means all.
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print a list of all outstanding allocations.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtDumpAllocations (
+ UINT32 Component,
+ char *Module)
+{
+ ACPI_DEBUG_MEM_BLOCK *Element;
+ ACPI_DESCRIPTOR *Descriptor;
+ UINT32 NumOutstanding = 0;
+
+
+ ACPI_FUNCTION_TRACE ("UtDumpAllocations");
+
+
+ /*
+ * Walk the allocation list.
+ */
+ if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))
+ {
+ return;
+ }
+
+ Element = AcpiGbl_MemoryLists[0].ListHead;
+ while (Element)
+ {
+ if ((Element->Component & Component) &&
+ ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module))))
+ {
+ /* Ignore allocated objects that are in a cache */
+
+ Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace);
+ if (Descriptor->DescriptorId != ACPI_DESC_TYPE_CACHED)
+ {
+ AcpiOsPrintf ("%p Len %04X %9.9s-%d ",
+ Descriptor, Element->Size, Element->Module,
+ Element->Line);
+
+ /* Most of the elements will be internal objects. */
+
+ switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor))
+ {
+ case ACPI_DESC_TYPE_OPERAND:
+ AcpiOsPrintf ("ObjType %12.12s R%hd",
+ AcpiUtGetTypeName (Descriptor->Object.Common.Type),
+ Descriptor->Object.Common.ReferenceCount);
+ break;
+
+ case ACPI_DESC_TYPE_PARSER:
+ AcpiOsPrintf ("ParseObj AmlOpcode %04hX",
+ Descriptor->Op.Asl.AmlOpcode);
+ break;
+
+ case ACPI_DESC_TYPE_NAMED:
+ AcpiOsPrintf ("Node %4.4s",
+ Descriptor->Node.Name.Ascii);
+ break;
+
+ case ACPI_DESC_TYPE_STATE:
+ AcpiOsPrintf ("Untyped StateObj");
+ break;
+
+ case ACPI_DESC_TYPE_STATE_UPDATE:
+ AcpiOsPrintf ("UPDATE StateObj");
+ break;
+
+ case ACPI_DESC_TYPE_STATE_PACKAGE:
+ AcpiOsPrintf ("PACKAGE StateObj");
+ break;
+
+ case ACPI_DESC_TYPE_STATE_CONTROL:
+ AcpiOsPrintf ("CONTROL StateObj");
+ break;
+
+ case ACPI_DESC_TYPE_STATE_RPSCOPE:
+ AcpiOsPrintf ("ROOT-PARSE-SCOPE StateObj");
+ break;
+
+ case ACPI_DESC_TYPE_STATE_PSCOPE:
+ AcpiOsPrintf ("PARSE-SCOPE StateObj");
+ break;
+
+ case ACPI_DESC_TYPE_STATE_WSCOPE:
+ AcpiOsPrintf ("WALK-SCOPE StateObj");
+ break;
+
+ case ACPI_DESC_TYPE_STATE_RESULT:
+ AcpiOsPrintf ("RESULT StateObj");
+ break;
+
+ case ACPI_DESC_TYPE_STATE_NOTIFY:
+ AcpiOsPrintf ("NOTIFY StateObj");
+ break;
+
+ case ACPI_DESC_TYPE_STATE_THREAD:
+ AcpiOsPrintf ("THREAD StateObj");
+ break;
+
+ default:
+ /* All types should appear above */
+ break;
+ }
+
+ AcpiOsPrintf ( "\n");
+ NumOutstanding++;
+ }
+ }
+ Element = Element->Next;
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
+
+ /* Print summary */
+
+ if (!NumOutstanding)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "No outstanding allocations.\n"));
+ }
+ else
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "%d(%X) Outstanding allocations\n",
+ NumOutstanding, NumOutstanding));
+ }
+
+ return_VOID;
+}
+
+
+#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */
+
diff --git a/sys/contrib/dev/acpica/utclib.c b/sys/contrib/dev/acpica/utclib.c
new file mode 100644
index 0000000..42b6422
--- /dev/null
+++ b/sys/contrib/dev/acpica/utclib.c
@@ -0,0 +1,892 @@
+/******************************************************************************
+ *
+ * Module Name: cmclib - Local implementation of C library functions
+ * $Revision: 51 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __CMCLIB_C__
+
+#include "acpi.h"
+
+/*
+ * These implementations of standard C Library routines can optionally be
+ * used if a C library is not available. In general, they are less efficient
+ * than an inline or assembly implementation
+ */
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("cmclib")
+
+
+#ifndef ACPI_USE_SYSTEM_CLIBRARY
+
+/*******************************************************************************
+ *
+ * FUNCTION: strlen
+ *
+ * PARAMETERS: String - Null terminated string
+ *
+ * RETURN: Length
+ *
+ * DESCRIPTION: Returns the length of the input string
+ *
+ ******************************************************************************/
+
+
+ACPI_SIZE
+AcpiUtStrlen (
+ const char *String)
+{
+ UINT32 Length = 0;
+
+
+ /* Count the string until a null is encountered */
+
+ while (*String)
+ {
+ Length++;
+ String++;
+ }
+
+ return (Length);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: strcpy
+ *
+ * PARAMETERS: DstString - Target of the copy
+ * SrcString - The source string to copy
+ *
+ * RETURN: DstString
+ *
+ * DESCRIPTION: Copy a null terminated string
+ *
+ ******************************************************************************/
+
+char *
+AcpiUtStrcpy (
+ char *DstString,
+ const char *SrcString)
+{
+ char *String = DstString;
+
+
+ /* Move bytes brute force */
+
+ while (*SrcString)
+ {
+ *String = *SrcString;
+
+ String++;
+ SrcString++;
+ }
+
+ /* Null terminate */
+
+ *String = 0;
+ return (DstString);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: strncpy
+ *
+ * PARAMETERS: DstString - Target of the copy
+ * SrcString - The source string to copy
+ * Count - Maximum # of bytes to copy
+ *
+ * RETURN: DstString
+ *
+ * DESCRIPTION: Copy a null terminated string, with a maximum length
+ *
+ ******************************************************************************/
+
+char *
+AcpiUtStrncpy (
+ char *DstString,
+ const char *SrcString,
+ ACPI_SIZE Count)
+{
+ char *String = DstString;
+
+
+ /* Copy the string */
+
+ for (String = DstString;
+ Count && (Count--, (*String++ = *SrcString++)); )
+ {;}
+
+ /* Pad with nulls if necessary */
+
+ while (Count--)
+ {
+ *String = 0;
+ String++;
+ }
+
+ /* Return original pointer */
+
+ return (DstString);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: strcmp
+ *
+ * PARAMETERS: String1 - First string
+ * String2 - Second string
+ *
+ * RETURN: Index where strings mismatched, or 0 if strings matched
+ *
+ * DESCRIPTION: Compare two null terminated strings
+ *
+ ******************************************************************************/
+
+int
+AcpiUtStrcmp (
+ const char *String1,
+ const char *String2)
+{
+
+
+ for ( ; (*String1 == *String2); String2++)
+ {
+ if (!*String1++)
+ {
+ return (0);
+ }
+ }
+
+ return ((unsigned char) *String1 - (unsigned char) *String2);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: strncmp
+ *
+ * PARAMETERS: String1 - First string
+ * String2 - Second string
+ * Count - Maximum # of bytes to compare
+ *
+ * RETURN: Index where strings mismatched, or 0 if strings matched
+ *
+ * DESCRIPTION: Compare two null terminated strings, with a maximum length
+ *
+ ******************************************************************************/
+
+int
+AcpiUtStrncmp (
+ const char *String1,
+ const char *String2,
+ ACPI_SIZE Count)
+{
+
+
+ for ( ; Count-- && (*String1 == *String2); String2++)
+ {
+ if (!*String1++)
+ {
+ return (0);
+ }
+ }
+
+ return ((Count == ACPI_SIZE_MAX) ? 0 : ((unsigned char) *String1 -
+ (unsigned char) *String2));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: Strcat
+ *
+ * PARAMETERS: DstString - Target of the copy
+ * SrcString - The source string to copy
+ *
+ * RETURN: DstString
+ *
+ * DESCRIPTION: Append a null terminated string to a null terminated string
+ *
+ ******************************************************************************/
+
+char *
+AcpiUtStrcat (
+ char *DstString,
+ const char *SrcString)
+{
+ char *String;
+
+
+ /* Find end of the destination string */
+
+ for (String = DstString; *String++; )
+ { ; }
+
+ /* Concatenate the string */
+
+ for (--String; (*String++ = *SrcString++); )
+ { ; }
+
+ return (DstString);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: strncat
+ *
+ * PARAMETERS: DstString - Target of the copy
+ * SrcString - The source string to copy
+ * Count - Maximum # of bytes to copy
+ *
+ * RETURN: DstString
+ *
+ * DESCRIPTION: Append a null terminated string to a null terminated string,
+ * with a maximum count.
+ *
+ ******************************************************************************/
+
+char *
+AcpiUtStrncat (
+ char *DstString,
+ const char *SrcString,
+ ACPI_SIZE Count)
+{
+ char *String;
+
+
+ if (Count)
+ {
+ /* Find end of the destination string */
+
+ for (String = DstString; *String++; )
+ { ; }
+
+ /* Concatenate the string */
+
+ for (--String; (*String++ = *SrcString++) && --Count; )
+ { ; }
+
+ /* Null terminate if necessary */
+
+ if (!Count)
+ {
+ *String = 0;
+ }
+ }
+
+ return (DstString);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: memcpy
+ *
+ * PARAMETERS: Dest - Target of the copy
+ * Src - Source buffer to copy
+ * Count - Number of bytes to copy
+ *
+ * RETURN: Dest
+ *
+ * DESCRIPTION: Copy arbitrary bytes of memory
+ *
+ ******************************************************************************/
+
+void *
+AcpiUtMemcpy (
+ void *Dest,
+ const void *Src,
+ ACPI_SIZE Count)
+{
+ char *New = (char *) Dest;
+ char *Old = (char *) Src;
+
+
+ while (Count)
+ {
+ *New = *Old;
+ New++;
+ Old++;
+ Count--;
+ }
+
+ return (Dest);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: memset
+ *
+ * PARAMETERS: Dest - Buffer to set
+ * Value - Value to set each byte of memory
+ * Count - Number of bytes to set
+ *
+ * RETURN: Dest
+ *
+ * DESCRIPTION: Initialize a buffer to a known value.
+ *
+ ******************************************************************************/
+
+void *
+AcpiUtMemset (
+ void *Dest,
+ ACPI_NATIVE_UINT Value,
+ ACPI_SIZE Count)
+{
+ char *New = (char *) Dest;
+
+
+ while (Count)
+ {
+ *New = (char) Value;
+ New++;
+ Count--;
+ }
+
+ return (Dest);
+}
+
+
+#define NEGATIVE 1
+#define POSITIVE 0
+
+const UINT8 _acpi_ctype[257] = {
+ _ACPI_CN, /* 0x0 0. */
+ _ACPI_CN, /* 0x1 1. */
+ _ACPI_CN, /* 0x2 2. */
+ _ACPI_CN, /* 0x3 3. */
+ _ACPI_CN, /* 0x4 4. */
+ _ACPI_CN, /* 0x5 5. */
+ _ACPI_CN, /* 0x6 6. */
+ _ACPI_CN, /* 0x7 7. */
+ _ACPI_CN, /* 0x8 8. */
+ _ACPI_CN|_ACPI_SP, /* 0x9 9. */
+ _ACPI_CN|_ACPI_SP, /* 0xA 10. */
+ _ACPI_CN|_ACPI_SP, /* 0xB 11. */
+ _ACPI_CN|_ACPI_SP, /* 0xC 12. */
+ _ACPI_CN|_ACPI_SP, /* 0xD 13. */
+ _ACPI_CN, /* 0xE 14. */
+ _ACPI_CN, /* 0xF 15. */
+ _ACPI_CN, /* 0x10 16. */
+ _ACPI_CN, /* 0x11 17. */
+ _ACPI_CN, /* 0x12 18. */
+ _ACPI_CN, /* 0x13 19. */
+ _ACPI_CN, /* 0x14 20. */
+ _ACPI_CN, /* 0x15 21. */
+ _ACPI_CN, /* 0x16 22. */
+ _ACPI_CN, /* 0x17 23. */
+ _ACPI_CN, /* 0x18 24. */
+ _ACPI_CN, /* 0x19 25. */
+ _ACPI_CN, /* 0x1A 26. */
+ _ACPI_CN, /* 0x1B 27. */
+ _ACPI_CN, /* 0x1C 28. */
+ _ACPI_CN, /* 0x1D 29. */
+ _ACPI_CN, /* 0x1E 30. */
+ _ACPI_CN, /* 0x1F 31. */
+ _ACPI_XS|_ACPI_SP, /* 0x20 32. ' ' */
+ _ACPI_PU, /* 0x21 33. '!' */
+ _ACPI_PU, /* 0x22 34. '"' */
+ _ACPI_PU, /* 0x23 35. '#' */
+ _ACPI_PU, /* 0x24 36. '$' */
+ _ACPI_PU, /* 0x25 37. '%' */
+ _ACPI_PU, /* 0x26 38. '&' */
+ _ACPI_PU, /* 0x27 39. ''' */
+ _ACPI_PU, /* 0x28 40. '(' */
+ _ACPI_PU, /* 0x29 41. ')' */
+ _ACPI_PU, /* 0x2A 42. '*' */
+ _ACPI_PU, /* 0x2B 43. '+' */
+ _ACPI_PU, /* 0x2C 44. ',' */
+ _ACPI_PU, /* 0x2D 45. '-' */
+ _ACPI_PU, /* 0x2E 46. '.' */
+ _ACPI_PU, /* 0x2F 47. '/' */
+ _ACPI_XD|_ACPI_DI, /* 0x30 48. '0' */
+ _ACPI_XD|_ACPI_DI, /* 0x31 49. '1' */
+ _ACPI_XD|_ACPI_DI, /* 0x32 50. '2' */
+ _ACPI_XD|_ACPI_DI, /* 0x33 51. '3' */
+ _ACPI_XD|_ACPI_DI, /* 0x34 52. '4' */
+ _ACPI_XD|_ACPI_DI, /* 0x35 53. '5' */
+ _ACPI_XD|_ACPI_DI, /* 0x36 54. '6' */
+ _ACPI_XD|_ACPI_DI, /* 0x37 55. '7' */
+ _ACPI_XD|_ACPI_DI, /* 0x38 56. '8' */
+ _ACPI_XD|_ACPI_DI, /* 0x39 57. '9' */
+ _ACPI_PU, /* 0x3A 58. ':' */
+ _ACPI_PU, /* 0x3B 59. ';' */
+ _ACPI_PU, /* 0x3C 60. '<' */
+ _ACPI_PU, /* 0x3D 61. '=' */
+ _ACPI_PU, /* 0x3E 62. '>' */
+ _ACPI_PU, /* 0x3F 63. '?' */
+ _ACPI_PU, /* 0x40 64. '@' */
+ _ACPI_XD|_ACPI_UP, /* 0x41 65. 'A' */
+ _ACPI_XD|_ACPI_UP, /* 0x42 66. 'B' */
+ _ACPI_XD|_ACPI_UP, /* 0x43 67. 'C' */
+ _ACPI_XD|_ACPI_UP, /* 0x44 68. 'D' */
+ _ACPI_XD|_ACPI_UP, /* 0x45 69. 'E' */
+ _ACPI_XD|_ACPI_UP, /* 0x46 70. 'F' */
+ _ACPI_UP, /* 0x47 71. 'G' */
+ _ACPI_UP, /* 0x48 72. 'H' */
+ _ACPI_UP, /* 0x49 73. 'I' */
+ _ACPI_UP, /* 0x4A 74. 'J' */
+ _ACPI_UP, /* 0x4B 75. 'K' */
+ _ACPI_UP, /* 0x4C 76. 'L' */
+ _ACPI_UP, /* 0x4D 77. 'M' */
+ _ACPI_UP, /* 0x4E 78. 'N' */
+ _ACPI_UP, /* 0x4F 79. 'O' */
+ _ACPI_UP, /* 0x50 80. 'P' */
+ _ACPI_UP, /* 0x51 81. 'Q' */
+ _ACPI_UP, /* 0x52 82. 'R' */
+ _ACPI_UP, /* 0x53 83. 'S' */
+ _ACPI_UP, /* 0x54 84. 'T' */
+ _ACPI_UP, /* 0x55 85. 'U' */
+ _ACPI_UP, /* 0x56 86. 'V' */
+ _ACPI_UP, /* 0x57 87. 'W' */
+ _ACPI_UP, /* 0x58 88. 'X' */
+ _ACPI_UP, /* 0x59 89. 'Y' */
+ _ACPI_UP, /* 0x5A 90. 'Z' */
+ _ACPI_PU, /* 0x5B 91. '[' */
+ _ACPI_PU, /* 0x5C 92. '\' */
+ _ACPI_PU, /* 0x5D 93. ']' */
+ _ACPI_PU, /* 0x5E 94. '^' */
+ _ACPI_PU, /* 0x5F 95. '_' */
+ _ACPI_PU, /* 0x60 96. '`' */
+ _ACPI_XD|_ACPI_LO, /* 0x61 97. 'a' */
+ _ACPI_XD|_ACPI_LO, /* 0x62 98. 'b' */
+ _ACPI_XD|_ACPI_LO, /* 0x63 99. 'c' */
+ _ACPI_XD|_ACPI_LO, /* 0x64 100. 'd' */
+ _ACPI_XD|_ACPI_LO, /* 0x65 101. 'e' */
+ _ACPI_XD|_ACPI_LO, /* 0x66 102. 'f' */
+ _ACPI_LO, /* 0x67 103. 'g' */
+ _ACPI_LO, /* 0x68 104. 'h' */
+ _ACPI_LO, /* 0x69 105. 'i' */
+ _ACPI_LO, /* 0x6A 106. 'j' */
+ _ACPI_LO, /* 0x6B 107. 'k' */
+ _ACPI_LO, /* 0x6C 108. 'l' */
+ _ACPI_LO, /* 0x6D 109. 'm' */
+ _ACPI_LO, /* 0x6E 110. 'n' */
+ _ACPI_LO, /* 0x6F 111. 'o' */
+ _ACPI_LO, /* 0x70 112. 'p' */
+ _ACPI_LO, /* 0x71 113. 'q' */
+ _ACPI_LO, /* 0x72 114. 'r' */
+ _ACPI_LO, /* 0x73 115. 's' */
+ _ACPI_LO, /* 0x74 116. 't' */
+ _ACPI_LO, /* 0x75 117. 'u' */
+ _ACPI_LO, /* 0x76 118. 'v' */
+ _ACPI_LO, /* 0x77 119. 'w' */
+ _ACPI_LO, /* 0x78 120. 'x' */
+ _ACPI_LO, /* 0x79 121. 'y' */
+ _ACPI_LO, /* 0x7A 122. 'z' */
+ _ACPI_PU, /* 0x7B 123. '{' */
+ _ACPI_PU, /* 0x7C 124. '|' */
+ _ACPI_PU, /* 0x7D 125. '}' */
+ _ACPI_PU, /* 0x7E 126. '~' */
+ _ACPI_CN, /* 0x7F 127. */
+
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80 to 0x8F */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90 to 0x9F */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xA0 to 0xAF */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xB0 to 0xBF */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xC0 to 0xCF */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xD0 to 0xDF */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xE0 to 0xEF */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xF0 to 0x100 */
+};
+
+#define IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
+#define IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
+#define IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI))
+#define IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP))
+#define IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtToUpper
+ *
+ * PARAMETERS:
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Convert character to uppercase
+ *
+ ******************************************************************************/
+
+int
+AcpiUtToUpper (
+ int c)
+{
+
+ return (IS_LOWER(c) ? ((c)-0x20) : (c));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtToLower
+ *
+ * PARAMETERS:
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Convert character to lowercase
+ *
+ ******************************************************************************/
+
+int
+AcpiUtToLower (
+ int c)
+{
+
+ return (IS_UPPER(c) ? ((c)+0x20) : (c));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: strstr
+ *
+ * PARAMETERS: String1 -
+ * String2
+ *
+ * RETURN:
+ *
+ * DESCRIPTION: Checks if String2 occurs in String1. This is not really a
+ * full implementation of strstr, only sufficient for command
+ * matching
+ *
+ ******************************************************************************/
+
+char *
+AcpiUtStrstr (
+ char *String1,
+ char *String2)
+{
+ char *String;
+
+
+ if (AcpiUtStrlen (String2) > AcpiUtStrlen (String1))
+ {
+ return (NULL);
+ }
+
+ /* Walk entire string, comparing the letters */
+
+ for (String = String1; *String2; )
+ {
+ if (*String2 != *String)
+ {
+ return (NULL);
+ }
+
+ String2++;
+ String++;
+ }
+
+ return (String1);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: strtoul
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiUtStrtoul (
+ const char *String,
+ char **Terminator,
+ UINT32 Base)
+{
+ UINT32 converted = 0;
+ UINT32 index;
+ UINT32 sign;
+ const char *StringStart;
+ UINT32 ReturnValue = 0;
+ ACPI_STATUS Status = AE_OK;
+
+
+ /*
+ * Save the value of the pointer to the buffer's first
+ * character, save the current errno value, and then
+ * skip over any white space in the buffer:
+ */
+ StringStart = String;
+ while (IS_SPACE (*String) || *String == '\t')
+ {
+ ++String;
+ }
+
+ /*
+ * The buffer may contain an optional plus or minus sign.
+ * If it does, then skip over it but remember what is was:
+ */
+ if (*String == '-')
+ {
+ sign = NEGATIVE;
+ ++String;
+ }
+ else if (*String == '+')
+ {
+ ++String;
+ sign = POSITIVE;
+ }
+ else
+ {
+ sign = POSITIVE;
+ }
+
+ /*
+ * 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 (AcpiUtToLower (*(++String)) == 'x')
+ {
+ Base = 16;
+ ++String;
+ }
+ else
+ {
+ Base = 8;
+ }
+ }
+ else
+ {
+ Base = 10;
+ }
+ }
+ else if (Base < 2 || Base > 36)
+ {
+ /*
+ * The specified Base parameter is not in the domain of
+ * this function:
+ */
+ goto done;
+ }
+
+ /*
+ * 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' &&
+ AcpiUtToLower (*(++String)) == 'x')
+ {
+ String++;
+ }
+
+
+ /*
+ * Main loop: convert the string to an unsigned long:
+ */
+ while (*String)
+ {
+ if (IS_DIGIT (*String))
+ {
+ index = (UINT32) ((UINT8) *String - '0');
+ }
+ else
+ {
+ index = (UINT32) AcpiUtToUpper (*String);
+ if (IS_UPPER (index))
+ {
+ index = index - 'A' + 10;
+ }
+ else
+ {
+ goto done;
+ }
+ }
+
+ if (index >= Base)
+ {
+ goto done;
+ }
+
+ /*
+ * Check to see if value is out of range:
+ */
+
+ if (ReturnValue > ((ACPI_UINT32_MAX - (UINT32) index) /
+ (UINT32) Base))
+ {
+ Status = AE_ERROR;
+ ReturnValue = 0; /* reset */
+ }
+ else
+ {
+ ReturnValue *= Base;
+ ReturnValue += index;
+ converted = 1;
+ }
+
+ ++String;
+ }
+
+done:
+ /*
+ * If appropriate, update the caller's pointer to the next
+ * unconverted character in the buffer.
+ */
+ if (Terminator)
+ {
+ if (converted == 0 && ReturnValue == 0 && String != NULL)
+ {
+ *Terminator = (char *) StringStart;
+ }
+ else
+ {
+ *Terminator = (char *) String;
+ }
+ }
+
+ if (Status == AE_ERROR)
+ {
+ ReturnValue = ACPI_UINT32_MAX;
+ }
+
+ /*
+ * If a minus sign was present, then "the conversion is negated":
+ */
+ if (sign == NEGATIVE)
+ {
+ ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1;
+ }
+
+ return (ReturnValue);
+}
+
+#endif /* ACPI_USE_SYSTEM_CLIBRARY */
+
diff --git a/sys/contrib/dev/acpica/utcopy.c b/sys/contrib/dev/acpica/utcopy.c
new file mode 100644
index 0000000..2153f17
--- /dev/null
+++ b/sys/contrib/dev/acpica/utcopy.c
@@ -0,0 +1,1009 @@
+/******************************************************************************
+ *
+ * Module Name: utcopy - Internal to external object translation utilities
+ * $Revision: 112 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 = (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 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
+ *
+ * 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;
+
+ /*
+ * Allocate and copy the actual buffer if and only if:
+ * 1) There is a valid buffer pointer
+ * 2) The buffer is not static (not in an ACPI table) (in this case,
+ * the actual pointer was already copied above)
+ */
+ if ((SourceDesc->Buffer.Pointer) &&
+ (!(SourceDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
+ {
+ DestDesc->Buffer.Pointer = ACPI_MEM_ALLOCATE (SourceDesc->Buffer.Length);
+ if (!DestDesc->Buffer.Pointer)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ ACPI_MEMCPY (DestDesc->Buffer.Pointer, SourceDesc->Buffer.Pointer,
+ SourceDesc->Buffer.Length);
+ }
+ break;
+
+ case ACPI_TYPE_STRING:
+
+ /*
+ * Allocate and copy the actual string if and only if:
+ * 1) There is a valid string pointer
+ * 2) The string is not static (not in an ACPI table) (in this case,
+ * the actual pointer was already copied above)
+ */
+ if ((SourceDesc->String.Pointer) &&
+ (!(SourceDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
+ {
+ DestDesc->String.Pointer = ACPI_MEM_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1);
+ if (!DestDesc->String.Pointer)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer,
+ (ACPI_SIZE) SourceDesc->String.Length + 1);
+ }
+ 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 ACPI_COPY_TYPE_SIMPLE:
+
+ /* A null source object indicates a (legal) null package element */
+
+ if (SourceObject)
+ {
+ /*
+ * 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;
+ }
+ else
+ {
+ /* Pass through a null element */
+
+ *ThisTargetPtr = NULL;
+ }
+ break;
+
+
+ case ACPI_COPY_TYPE_PACKAGE:
+
+ /*
+ * 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;
+
+ /*
+ * Create the object array
+ */
+ TargetObject->Package.Elements =
+ ACPI_MEM_CALLOCATE (((ACPI_SIZE) SourceObject->Package.Count + 1) *
+ sizeof (void *));
+ if (!TargetObject->Package.Elements)
+ {
+ ACPI_MEM_FREE (TargetObject);
+ return (AE_NO_MEMORY);
+ }
+
+ /*
+ * 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/utdebug.c b/sys/contrib/dev/acpica/utdebug.c
new file mode 100644
index 0000000..842c7d6
--- /dev/null
+++ b/sys/contrib/dev/acpica/utdebug.c
@@ -0,0 +1,714 @@
+/******************************************************************************
+ *
+ * Module Name: utdebug - Debug print routines
+ * $Revision: 108 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __UTDEBUG_C__
+
+#include "acpi.h"
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utdebug")
+
+
+#ifdef ACPI_DEBUG_OUTPUT
+
+static UINT32 AcpiGbl_PrevThreadId = 0xFFFFFFFF;
+static char *AcpiGbl_FnEntryStr = "----Entry";
+static char *AcpiGbl_FnExitStr = "----Exit-";
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtInitStackPtrTrace
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Save the current stack pointer
+ *
+ ****************************************************************************/
+
+void
+AcpiUtInitStackPtrTrace (
+ void)
+{
+ UINT32 CurrentSp;
+
+
+ AcpiGbl_EntryStackPointer = ACPI_PTR_DIFF (&CurrentSp, NULL);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtTrackStackPtr
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Save the current stack pointer
+ *
+ ****************************************************************************/
+
+void
+AcpiUtTrackStackPtr (
+ void)
+{
+ ACPI_SIZE CurrentSp;
+
+
+ CurrentSp = ACPI_PTR_DIFF (&CurrentSp, NULL);
+
+ if (CurrentSp < AcpiGbl_LowestStackPointer)
+ {
+ AcpiGbl_LowestStackPointer = CurrentSp;
+ }
+
+ if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting)
+ {
+ AcpiGbl_DeepestNesting = AcpiGbl_NestingLevel;
+ }
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtDebugPrint
+ *
+ * PARAMETERS: DebugLevel - Requested debug print level
+ * ProcName - Caller's procedure name
+ * ModuleName - Caller's module name (for error output)
+ * LineNumber - Caller's line number (for error output)
+ * ComponentId - Caller's component ID (for error output)
+ *
+ * Format - Printf format field
+ * ... - Optional printf arguments
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print error message with prefix consisting of the module name,
+ * line number, and component ID.
+ *
+ ****************************************************************************/
+
+void ACPI_INTERNAL_VAR_XFACE
+AcpiUtDebugPrint (
+ UINT32 RequestedDebugLevel,
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ char *Format,
+ ...)
+{
+ UINT32 ThreadId;
+ va_list args;
+
+
+ /*
+ * Stay silent if the debug level or component ID is disabled
+ */
+ if (!(RequestedDebugLevel & AcpiDbgLevel) ||
+ !(DbgInfo->ComponentId & AcpiDbgLayer))
+ {
+ return;
+ }
+
+ /*
+ * Thread tracking and context switch notification
+ */
+ ThreadId = AcpiOsGetThreadId ();
+
+ if (ThreadId != AcpiGbl_PrevThreadId)
+ {
+ if (ACPI_LV_THREADS & AcpiDbgLevel)
+ {
+ AcpiOsPrintf ("\n**** Context Switch from TID %X to TID %X ****\n\n",
+ AcpiGbl_PrevThreadId, ThreadId);
+ }
+
+ AcpiGbl_PrevThreadId = ThreadId;
+ }
+
+ /*
+ * Display the module name, current line number, thread ID (if requested),
+ * current procedure nesting level, and the current procedure name
+ */
+ AcpiOsPrintf ("%8s-%04ld ", DbgInfo->ModuleName, LineNumber);
+
+ if (ACPI_LV_THREADS & AcpiDbgLevel)
+ {
+ AcpiOsPrintf ("[%04lX] ", ThreadId);
+ }
+
+ AcpiOsPrintf ("[%02ld] %-22.22s: ", AcpiGbl_NestingLevel, DbgInfo->ProcName);
+
+ va_start (args, Format);
+ AcpiOsVprintf (Format, args);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtDebugPrintRaw
+ *
+ * PARAMETERS: RequestedDebugLevel - Requested debug print level
+ * LineNumber - Caller's line number
+ * DbgInfo - Contains:
+ * ProcName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * Format - Printf format field
+ * ... - Optional printf arguments
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Print message with no headers. Has same interface as
+ * DebugPrint so that the same macros can be used.
+ *
+ ****************************************************************************/
+
+void ACPI_INTERNAL_VAR_XFACE
+AcpiUtDebugPrintRaw (
+ UINT32 RequestedDebugLevel,
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ char *Format,
+ ...)
+{
+ va_list args;
+
+
+ if (!(RequestedDebugLevel & AcpiDbgLevel) ||
+ !(DbgInfo->ComponentId & AcpiDbgLayer))
+ {
+ return;
+ }
+
+ va_start (args, Format);
+ AcpiOsVprintf (Format, args);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtTrace
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * DbgInfo - Contains:
+ * ProcName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel
+ *
+ ****************************************************************************/
+
+void
+AcpiUtTrace (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo)
+{
+
+ AcpiGbl_NestingLevel++;
+ AcpiUtTrackStackPtr ();
+
+ AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
+ "%s\n", AcpiGbl_FnEntryStr);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtTracePtr
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * DbgInfo - Contains:
+ * ProcName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * Pointer - Pointer to display
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel
+ *
+ ****************************************************************************/
+
+void
+AcpiUtTracePtr (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ void *Pointer)
+{
+ AcpiGbl_NestingLevel++;
+ AcpiUtTrackStackPtr ();
+
+ AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
+ "%s %p\n", AcpiGbl_FnEntryStr, Pointer);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtTraceStr
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * DbgInfo - Contains:
+ * ProcName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * String - Additional string to display
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel
+ *
+ ****************************************************************************/
+
+void
+AcpiUtTraceStr (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ char *String)
+{
+
+ AcpiGbl_NestingLevel++;
+ AcpiUtTrackStackPtr ();
+
+ AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
+ "%s %s\n", AcpiGbl_FnEntryStr, String);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtTraceU32
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * DbgInfo - Contains:
+ * ProcName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * Integer - Integer to display
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel
+ *
+ ****************************************************************************/
+
+void
+AcpiUtTraceU32 (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ UINT32 Integer)
+{
+
+ AcpiGbl_NestingLevel++;
+ AcpiUtTrackStackPtr ();
+
+ AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
+ "%s %08X\n", AcpiGbl_FnEntryStr, Integer);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtExit
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * DbgInfo - Contains:
+ * ProcName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel
+ *
+ ****************************************************************************/
+
+void
+AcpiUtExit (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo)
+{
+
+ AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
+ "%s\n", AcpiGbl_FnExitStr);
+
+ AcpiGbl_NestingLevel--;
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtStatusExit
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * DbgInfo - Contains:
+ * ProcName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * Status - Exit status code
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel. Prints exit status also.
+ *
+ ****************************************************************************/
+
+void
+AcpiUtStatusExit (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ ACPI_STATUS Status)
+{
+
+ if (ACPI_SUCCESS (Status))
+ {
+ AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
+ "%s %s\n", AcpiGbl_FnExitStr,
+ AcpiFormatException (Status));
+ }
+ else
+ {
+ AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
+ "%s ****Exception****: %s\n", AcpiGbl_FnExitStr,
+ AcpiFormatException (Status));
+ }
+
+ AcpiGbl_NestingLevel--;
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtValueExit
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * DbgInfo - Contains:
+ * ProcName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * Value - Value to be printed with exit msg
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel. Prints exit value also.
+ *
+ ****************************************************************************/
+
+void
+AcpiUtValueExit (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ ACPI_INTEGER Value)
+{
+
+ AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
+ "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr,
+ ACPI_HIDWORD (Value), ACPI_LODWORD (Value));
+
+ AcpiGbl_NestingLevel--;
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtPtrExit
+ *
+ * PARAMETERS: LineNumber - Caller's line number
+ * DbgInfo - Contains:
+ * ProcName - Caller's procedure name
+ * ModuleName - Caller's module name
+ * ComponentId - Caller's component ID
+ * Value - Value to be printed with exit msg
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
+ * set in DebugLevel. Prints exit value also.
+ *
+ ****************************************************************************/
+
+void
+AcpiUtPtrExit (
+ UINT32 LineNumber,
+ ACPI_DEBUG_PRINT_INFO *DbgInfo,
+ UINT8 *Ptr)
+{
+
+ AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
+ "%s %p\n", AcpiGbl_FnExitStr, Ptr);
+
+ AcpiGbl_NestingLevel--;
+}
+
+#endif
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtDumpBuffer
+ *
+ * PARAMETERS: Buffer - Buffer to dump
+ * Count - Amount to dump, in bytes
+ * Display - BYTE, WORD, DWORD, or QWORD display
+ * ComponentID - Caller's component ID
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Generic dump buffer in both hex and ascii.
+ *
+ ****************************************************************************/
+
+void
+AcpiUtDumpBuffer (
+ UINT8 *Buffer,
+ UINT32 Count,
+ UINT32 Display,
+ UINT32 ComponentId)
+{
+ ACPI_NATIVE_UINT i = 0;
+ ACPI_NATIVE_UINT j;
+ UINT32 Temp32;
+ UINT8 BufChar;
+
+
+ /* Only dump the buffer if tracing is enabled */
+
+ if (!((ACPI_LV_TABLES & AcpiDbgLevel) &&
+ (ComponentId & AcpiDbgLayer)))
+ {
+ return;
+ }
+
+ if ((Count < 4) || (Count & 0x01))
+ {
+ Display = DB_BYTE_DISPLAY;
+ }
+
+ AcpiOsPrintf ("\nOffset Value\n");
+
+ /*
+ * Nasty little dump buffer routine!
+ */
+ while (i < Count)
+ {
+ /* Print current offset */
+
+ AcpiOsPrintf ("%05X ", (UINT32) i);
+
+ /* Print 16 hex chars */
+
+ for (j = 0; j < 16;)
+ {
+ if (i + j >= Count)
+ {
+ AcpiOsPrintf ("\n");
+ return;
+ }
+
+ /* Make sure that the INT8 doesn't get sign-extended! */
+
+ switch (Display)
+ {
+ /* Default is BYTE display */
+
+ default:
+
+ AcpiOsPrintf ("%02X ",
+ *((UINT8 *) &Buffer[i + j]));
+ j += 1;
+ break;
+
+
+ case DB_WORD_DISPLAY:
+
+ ACPI_MOVE_UNALIGNED16_TO_32 (&Temp32,
+ &Buffer[i + j]);
+ AcpiOsPrintf ("%04X ", Temp32);
+ j += 2;
+ break;
+
+
+ case DB_DWORD_DISPLAY:
+
+ ACPI_MOVE_UNALIGNED32_TO_32 (&Temp32,
+ &Buffer[i + j]);
+ AcpiOsPrintf ("%08X ", Temp32);
+ j += 4;
+ break;
+
+
+ case DB_QWORD_DISPLAY:
+
+ ACPI_MOVE_UNALIGNED32_TO_32 (&Temp32,
+ &Buffer[i + j]);
+ AcpiOsPrintf ("%08X", Temp32);
+
+ ACPI_MOVE_UNALIGNED32_TO_32 (&Temp32,
+ &Buffer[i + j + 4]);
+ AcpiOsPrintf ("%08X ", Temp32);
+ j += 8;
+ break;
+ }
+ }
+
+ /*
+ * Print the ASCII equivalent characters
+ * But watch out for the bad unprintable ones...
+ */
+ for (j = 0; j < 16; j++)
+ {
+ if (i + j >= Count)
+ {
+ AcpiOsPrintf ("\n");
+ return;
+ }
+
+ BufChar = Buffer[i + j];
+ if ((BufChar > 0x1F && BufChar < 0x2E) ||
+ (BufChar > 0x2F && BufChar < 0x61) ||
+ (BufChar > 0x60 && BufChar < 0x7F))
+ {
+ AcpiOsPrintf ("%c", BufChar);
+ }
+ else
+ {
+ AcpiOsPrintf (".");
+ }
+ }
+
+ /* Done with that line. */
+
+ AcpiOsPrintf ("\n");
+ i += 16;
+ }
+
+ return;
+}
+
diff --git a/sys/contrib/dev/acpica/utdelete.c b/sys/contrib/dev/acpica/utdelete.c
new file mode 100644
index 0000000..890973e
--- /dev/null
+++ b/sys/contrib/dev/acpica/utdelete.c
@@ -0,0 +1,756 @@
+/*******************************************************************************
+ *
+ * Module Name: utdelete - object deletion and reference count utilities
+ * $Revision: 95 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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))
+ {
+ /* But only if it is NOT a pointer into an ACPI table */
+
+ 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 */
+
+ if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER))
+ {
+ /* But only if it is NOT a pointer into an ACPI table */
+
+ 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 > ACPI_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 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 ACPI_TYPE_LOCAL_REGION_FIELD:
+
+ Status = AcpiUtCreateUpdateStateAndPush (
+ Object->Field.RegionObj, Action, &StateList);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+ break;
+
+
+ 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 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 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/uteval.c b/sys/contrib/dev/acpica/uteval.c
new file mode 100644
index 0000000..6d69728
--- /dev/null
+++ b/sys/contrib/dev/acpica/uteval.c
@@ -0,0 +1,532 @@
+/******************************************************************************
+ *
+ * Module Name: uteval - Object evaluation
+ * $Revision: 45 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __UTEVAL_C__
+
+#include "acpi.h"
+#include "acnamesp.h"
+#include "acinterp.h"
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("uteval")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtEvaluateObject
+ *
+ * PARAMETERS: PrefixNode - Starting node
+ * Path - Path to object from starting node
+ * ExpectedReturnTypes - Bitmap of allowed return types
+ * ReturnDesc - Where a return value is stored
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Evaluates a namespace object and verifies the type of the
+ * return object. Common code that simplifies accessing objects
+ * that have required return objects of fixed types.
+ *
+ * NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtEvaluateObject (
+ ACPI_NAMESPACE_NODE *PrefixNode,
+ char *Path,
+ UINT32 ExpectedReturnBtypes,
+ ACPI_OPERAND_OBJECT **ReturnDesc)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+ UINT32 ReturnBtype;
+
+
+ ACPI_FUNCTION_TRACE ("UtEvaluateObject");
+
+
+ /* Evaluate the object/method */
+
+ Status = AcpiNsEvaluateRelative (PrefixNode, Path, NULL, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ if (Status == AE_NOT_FOUND)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n",
+ PrefixNode->Name.Ascii, Path));
+ }
+ else
+ {
+ ACPI_REPORT_METHOD_ERROR ("Method execution failed",
+ PrefixNode, Path, Status);
+ }
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Did we get a return object? */
+
+ if (!ObjDesc)
+ {
+ if (ExpectedReturnBtypes)
+ {
+ ACPI_REPORT_METHOD_ERROR ("No object was returned from",
+ PrefixNode, Path, AE_NOT_EXIST);
+
+ return_ACPI_STATUS (AE_NOT_EXIST);
+ }
+
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /* Map the return object type to the bitmapped type */
+
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
+ {
+ case ACPI_TYPE_INTEGER:
+ ReturnBtype = ACPI_BTYPE_INTEGER;
+ break;
+
+ case ACPI_TYPE_BUFFER:
+ ReturnBtype = ACPI_BTYPE_BUFFER;
+ break;
+
+ case ACPI_TYPE_STRING:
+ ReturnBtype = ACPI_BTYPE_STRING;
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+ ReturnBtype = ACPI_BTYPE_PACKAGE;
+ break;
+
+ default:
+ ReturnBtype = 0;
+ break;
+ }
+
+ /* Is the return object one of the expected types? */
+
+ if (!(ExpectedReturnBtypes & ReturnBtype))
+ {
+ ACPI_REPORT_METHOD_ERROR ("Return object type is incorrect",
+ PrefixNode, Path, AE_TYPE);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Type returned from %s was incorrect: %X\n",
+ Path, ACPI_GET_OBJECT_TYPE (ObjDesc)));
+
+ /* On error exit, we must delete the return object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (AE_TYPE);
+ }
+
+ /* Object type is OK, return it */
+
+ *ReturnDesc = ObjDesc;
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtEvaluateNumericObject
+ *
+ * PARAMETERS: *ObjectName - Object name to be evaluated
+ * DeviceNode - Node for the device
+ * *Address - Where the value is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Evaluates a numeric namespace object for a selected device
+ * and stores result in *Address.
+ *
+ * NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtEvaluateNumericObject (
+ char *ObjectName,
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ ACPI_INTEGER *Address)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("UtEvaluateNumericObject");
+
+
+ Status = AcpiUtEvaluateObject (DeviceNode, ObjectName,
+ ACPI_BTYPE_INTEGER, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Get the returned Integer */
+
+ *Address = ObjDesc->Integer.Value;
+
+ /* On exit, we must delete the return object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtExecute_HID
+ *
+ * PARAMETERS: DeviceNode - Node for the device
+ * *Hid - Where the HID is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Executes the _HID control method that returns the hardware
+ * ID of the device.
+ *
+ * NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtExecute_HID (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ ACPI_DEVICE_ID *Hid)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("UtExecute_HID");
+
+
+ Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID,
+ ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)
+ {
+ /* Convert the Numeric HID to string */
+
+ AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Hid->Buffer);
+ }
+ else
+ {
+ /* Copy the String HID from the returned object */
+
+ ACPI_STRNCPY (Hid->Buffer, ObjDesc->String.Pointer, sizeof(Hid->Buffer));
+ }
+
+ /* On exit, we must delete the return object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtExecute_CID
+ *
+ * PARAMETERS: DeviceNode - Node for the device
+ * *Cid - Where the CID is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Executes the _CID control method that returns one or more
+ * compatible hardware IDs for the device.
+ *
+ * NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtExecute_CID (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ ACPI_DEVICE_ID *Cid)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("UtExecute_CID");
+
+
+ Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID,
+ ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * A _CID can return either a single compatible ID or a package of compatible
+ * IDs. Each compatible ID can be a Number (32 bit compressed EISA ID) or
+ * string (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss").
+ */
+ switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
+ {
+ case ACPI_TYPE_INTEGER:
+
+ /* Convert the Numeric CID to string */
+
+ AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Cid->Buffer);
+ break;
+
+ case ACPI_TYPE_STRING:
+
+ /* Copy the String CID from the returned object */
+
+ ACPI_STRNCPY (Cid->Buffer, ObjDesc->String.Pointer, sizeof (Cid->Buffer));
+ break;
+
+ case ACPI_TYPE_PACKAGE:
+
+ /* TBD: Parse package elements; need different return struct, etc. */
+
+ Status = AE_SUPPORT;
+ break;
+
+ default:
+
+ Status = AE_TYPE;
+ break;
+ }
+
+ /* On exit, we must delete the return object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtExecute_UID
+ *
+ * PARAMETERS: DeviceNode - Node for the device
+ * *Uid - Where the UID is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Executes the _UID control method that returns the hardware
+ * ID of the device.
+ *
+ * NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtExecute_UID (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ ACPI_DEVICE_ID *Uid)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("UtExecute_UID");
+
+
+ Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID,
+ ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)
+ {
+ /* Convert the Numeric UID to string */
+
+ AcpiExUnsignedIntegerToString (ObjDesc->Integer.Value, Uid->Buffer);
+ }
+ else
+ {
+ /* Copy the String UID from the returned object */
+
+ ACPI_STRNCPY (Uid->Buffer, ObjDesc->String.Pointer, sizeof (Uid->Buffer));
+ }
+
+ /* On exit, we must delete the return object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtExecute_STA
+ *
+ * PARAMETERS: DeviceNode - Node for the device
+ * *Flags - Where the status flags are returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Executes _STA for selected device and stores results in
+ * *Flags.
+ *
+ * NOTE: Internal function, no parameter validation
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtExecute_STA (
+ ACPI_NAMESPACE_NODE *DeviceNode,
+ UINT32 *Flags)
+{
+ ACPI_OPERAND_OBJECT *ObjDesc;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("UtExecute_STA");
+
+
+ Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA,
+ ACPI_BTYPE_INTEGER, &ObjDesc);
+ if (ACPI_FAILURE (Status))
+ {
+ if (AE_NOT_FOUND == Status)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+ "_STA on %4.4s was not found, assuming device is present\n",
+ DeviceNode->Name.Ascii));
+
+ *Flags = 0x0F;
+ Status = AE_OK;
+ }
+
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Extract the status flags */
+
+ *Flags = (UINT32) ObjDesc->Integer.Value;
+
+ /* On exit, we must delete the return object */
+
+ AcpiUtRemoveReference (ObjDesc);
+ return_ACPI_STATUS (Status);
+}
diff --git a/sys/contrib/dev/acpica/utglobal.c b/sys/contrib/dev/acpica/utglobal.c
new file mode 100644
index 0000000..2611ea2
--- /dev/null
+++ b/sys/contrib/dev/acpica/utglobal.c
@@ -0,0 +1,876 @@
+/******************************************************************************
+ *
+ * Module Name: utglobal - Global variables for the ACPI subsystem
+ * $Revision: 180 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __UTGLOBAL_C__
+#define DEFINE_ACPI_GLOBALS
+
+#include "acpi.h"
+#include "acnamesp.h"
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utglobal")
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiFormatException
+ *
+ * PARAMETERS: Status - The ACPI_STATUS code to be formatted
+ *
+ * RETURN: A string containing the exception text
+ *
+ * DESCRIPTION: This function translates an ACPI exception into an ASCII string.
+ *
+ ******************************************************************************/
+
+const char *
+AcpiFormatException (
+ ACPI_STATUS Status)
+{
+ const char *Exception = "UNKNOWN_STATUS_CODE";
+ ACPI_STATUS SubStatus;
+
+
+ ACPI_FUNCTION_NAME ("FormatException");
+
+
+ SubStatus = (Status & ~AE_CODE_MASK);
+
+ switch (Status & AE_CODE_MASK)
+ {
+ case AE_CODE_ENVIRONMENTAL:
+
+ if (SubStatus <= AE_CODE_ENV_MAX)
+ {
+ Exception = AcpiGbl_ExceptionNames_Env [SubStatus];
+ break;
+ }
+ goto Unknown;
+
+ case AE_CODE_PROGRAMMER:
+
+ if (SubStatus <= AE_CODE_PGM_MAX)
+ {
+ Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus -1];
+ break;
+ }
+ goto Unknown;
+
+ case AE_CODE_ACPI_TABLES:
+
+ if (SubStatus <= AE_CODE_TBL_MAX)
+ {
+ Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1];
+ break;
+ }
+ goto Unknown;
+
+ case AE_CODE_AML:
+
+ if (SubStatus <= AE_CODE_AML_MAX)
+ {
+ Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1];
+ break;
+ }
+ goto Unknown;
+
+ case AE_CODE_CONTROL:
+
+ if (SubStatus <= AE_CODE_CTRL_MAX)
+ {
+ Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1];
+ break;
+ }
+ goto Unknown;
+
+ default:
+ goto Unknown;
+ }
+
+
+ return ((const char *) Exception);
+
+Unknown:
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown exception code: 0x%8.8X\n", Status));
+ return ((const char *) Exception);
+}
+
+
+/******************************************************************************
+ *
+ * Static global variable initialization.
+ *
+ ******************************************************************************/
+
+/*
+ * We want the debug switches statically initialized so they
+ * are already set when the debugger is entered.
+ */
+
+/* Debug switch - level and trace mask */
+
+#ifdef ACPI_DEBUG_OUTPUT
+UINT32 AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
+#else
+UINT32 AcpiDbgLevel = ACPI_NORMAL_DEFAULT;
+#endif
+
+/* Debug switch - layer (component) mask */
+
+UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT;
+UINT32 AcpiGbl_NestingLevel = 0;
+
+
+/* Debugger globals */
+
+BOOLEAN AcpiGbl_DbTerminateThreads = FALSE;
+BOOLEAN AcpiGbl_AbortMethod = FALSE;
+BOOLEAN AcpiGbl_MethodExecuting = FALSE;
+
+/* System flags */
+
+UINT32 AcpiGbl_StartupFlags = 0;
+
+/* System starts uninitialized */
+
+BOOLEAN AcpiGbl_Shutdown = TRUE;
+
+const UINT8 AcpiGbl_DecodeTo8bit [8] = {1,2,4,8,16,32,64,128};
+
+const char *AcpiGbl_DbSleepStates[ACPI_S_STATE_COUNT] = {
+ "\\_S0_",
+ "\\_S1_",
+ "\\_S2_",
+ "\\_S3_",
+ "\\_S4_",
+ "\\_S5_"};
+
+
+/******************************************************************************
+ *
+ * Namespace globals
+ *
+ ******************************************************************************/
+
+
+/*
+ * Predefined ACPI Names (Built-in to the Interpreter)
+ *
+ * Initial values are currently supported only for types String and Number.
+ * Both are specified as strings in this table.
+ *
+ * NOTES:
+ * 1) _SB_ is defined to be a device to allow _SB_/_INI to be run
+ * during the initialization sequence.
+ */
+
+const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] =
+{
+ {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
+ {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
+ {"_SB_", ACPI_TYPE_DEVICE, NULL},
+ {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
+ {"_TZ_", ACPI_TYPE_LOCAL_SCOPE, NULL},
+ {"_REV", ACPI_TYPE_INTEGER, "2"},
+ {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
+ {"_GL_", ACPI_TYPE_MUTEX, "0"},
+
+#if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
+ {"_OSI", ACPI_TYPE_METHOD, "1"},
+#endif
+ {NULL, ACPI_TYPE_ANY, NULL} /* Table terminator */
+};
+
+
+/*
+ * Properties of the ACPI Object Types, both internal and external.
+ * The table is indexed by values of ACPI_OBJECT_TYPE
+ */
+
+const UINT8 AcpiGbl_NsProperties[] =
+{
+ ACPI_NS_NORMAL, /* 00 Any */
+ ACPI_NS_NORMAL, /* 01 Number */
+ ACPI_NS_NORMAL, /* 02 String */
+ ACPI_NS_NORMAL, /* 03 Buffer */
+ ACPI_NS_NORMAL, /* 04 Package */
+ ACPI_NS_NORMAL, /* 05 FieldUnit */
+ ACPI_NS_NEWSCOPE, /* 06 Device */
+ ACPI_NS_NORMAL, /* 07 Event */
+ ACPI_NS_NEWSCOPE, /* 08 Method */
+ ACPI_NS_NORMAL, /* 09 Mutex */
+ ACPI_NS_NORMAL, /* 10 Region */
+ ACPI_NS_NEWSCOPE, /* 11 Power */
+ ACPI_NS_NEWSCOPE, /* 12 Processor */
+ ACPI_NS_NEWSCOPE, /* 13 Thermal */
+ ACPI_NS_NORMAL, /* 14 BufferField */
+ ACPI_NS_NORMAL, /* 15 DdbHandle */
+ ACPI_NS_NORMAL, /* 16 Debug Object */
+ ACPI_NS_NORMAL, /* 17 DefField */
+ ACPI_NS_NORMAL, /* 18 BankField */
+ ACPI_NS_NORMAL, /* 19 IndexField */
+ ACPI_NS_NORMAL, /* 20 Reference */
+ ACPI_NS_NORMAL, /* 21 Alias */
+ ACPI_NS_NORMAL, /* 22 Notify */
+ ACPI_NS_NORMAL, /* 23 Address Handler */
+ ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 24 Resource Desc */
+ ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Field */
+ ACPI_NS_NEWSCOPE, /* 26 Scope */
+ ACPI_NS_NORMAL, /* 27 Extra */
+ ACPI_NS_NORMAL, /* 28 Data */
+ ACPI_NS_NORMAL /* 29 Invalid */
+};
+
+
+/* Hex to ASCII conversion table */
+
+static const char AcpiGbl_HexToAscii[] =
+ {'0','1','2','3','4','5','6','7',
+ '8','9','A','B','C','D','E','F'};
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtHexToAsciiChar
+ *
+ * PARAMETERS: Integer - Contains the hex digit
+ * Position - bit position of the digit within the
+ * integer
+ *
+ * RETURN: Ascii character
+ *
+ * DESCRIPTION: Convert a hex digit to an ascii character
+ *
+ ****************************************************************************/
+
+char
+AcpiUtHexToAsciiChar (
+ ACPI_INTEGER Integer,
+ UINT32 Position)
+{
+
+ return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]);
+}
+
+
+/******************************************************************************
+ *
+ * Table name globals
+ *
+ * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
+ * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables
+ * that are not used by the subsystem are simply ignored.
+ *
+ * Do NOT add any table to this list that is not consumed directly by this
+ * subsystem.
+ *
+ ******************************************************************************/
+
+
+ACPI_TABLE_DESC AcpiGbl_AcpiTables[NUM_ACPI_TABLES];
+
+
+ACPI_TABLE_SUPPORT AcpiGbl_AcpiTableData[NUM_ACPI_TABLES] =
+{
+ /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */
+
+ /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE},
+ /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void **) &AcpiGbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE | ACPI_TABLE_EXECUTABLE},
+ /* FADT 2 */ {FADT_SIG, FADT_SIG, (void **) &AcpiGbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE},
+ /* FACS 3 */ {FACS_SIG, FACS_SIG, (void **) &AcpiGbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE},
+ /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
+ /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
+ /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE},
+};
+
+
+/******************************************************************************
+ *
+ * Event and Hardware globals
+ *
+ ******************************************************************************/
+
+ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] =
+{
+ /* Name Parent Register Register Bit Position Register Bit Mask */
+
+ /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS},
+ /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS},
+ /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS},
+ /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS},
+ /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS},
+ /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS},
+ /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS},
+
+ /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE},
+ /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
+ /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE},
+ /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
+ /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE},
+ /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
+
+ /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE},
+ /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD},
+ /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
+ /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X},
+ /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X},
+ /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE},
+
+ /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE}
+};
+
+
+ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] =
+{
+ /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE},
+ /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
+ /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE},
+ /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
+ /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, 0, 0},
+};
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtGetRegionName
+ *
+ * PARAMETERS: None.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Translate a Space ID into a name string (Debug only)
+ *
+ ****************************************************************************/
+
+/* Region type decoding */
+
+const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
+{
+/*! [Begin] no source code translation (keep these ASL Keywords as-is) */
+ "SystemMemory",
+ "SystemIO",
+ "PCI_Config",
+ "EmbeddedControl",
+ "SMBus",
+ "CMOS",
+ "PCIBARTarget",
+ "DataTable"
+/*! [End] no source code translation !*/
+};
+
+
+char *
+AcpiUtGetRegionName (
+ UINT8 SpaceId)
+{
+
+ if (SpaceId >= ACPI_USER_REGION_BEGIN)
+ {
+ return ("UserDefinedRegion");
+ }
+
+ else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
+ {
+ return ("InvalidSpaceId");
+ }
+
+ return ((char *) AcpiGbl_RegionTypes[SpaceId]);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtGetEventName
+ *
+ * PARAMETERS: None.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Translate a Event ID into a name string (Debug only)
+ *
+ ****************************************************************************/
+
+/* Event type decoding */
+
+static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
+{
+ "PM_Timer",
+ "GlobalLock",
+ "PowerButton",
+ "SleepButton",
+ "RealTimeClock",
+};
+
+
+char *
+AcpiUtGetEventName (
+ UINT32 EventId)
+{
+
+ if (EventId > ACPI_EVENT_MAX)
+ {
+ return ("InvalidEventID");
+ }
+
+ return ((char *) AcpiGbl_EventTypes[EventId]);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtGetTypeName
+ *
+ * PARAMETERS: None.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Translate a Type ID into a name string (Debug only)
+ *
+ ****************************************************************************/
+
+/*
+ * Elements of AcpiGbl_NsTypeNames below must match
+ * one-to-one with values of ACPI_OBJECT_TYPE
+ *
+ * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when
+ * stored in a table it really means that we have thus far seen no evidence to
+ * indicatewhat type is actually going to be stored for this entry.
+ */
+
+static const char AcpiGbl_BadType[] = "UNDEFINED";
+#define TYPE_NAME_LENGTH 12 /* Maximum length of each string */
+
+static const char *AcpiGbl_NsTypeNames[] = /* printable names of ACPI types */
+{
+ /* 00 */ "Untyped",
+ /* 01 */ "Integer",
+ /* 02 */ "String",
+ /* 03 */ "Buffer",
+ /* 04 */ "Package",
+ /* 05 */ "FieldUnit",
+ /* 06 */ "Device",
+ /* 07 */ "Event",
+ /* 08 */ "Method",
+ /* 09 */ "Mutex",
+ /* 10 */ "Region",
+ /* 11 */ "Power",
+ /* 12 */ "Processor",
+ /* 13 */ "Thermal",
+ /* 14 */ "BufferField",
+ /* 15 */ "DdbHandle",
+ /* 16 */ "DebugObject",
+ /* 17 */ "RegionField",
+ /* 18 */ "BankField",
+ /* 19 */ "IndexField",
+ /* 20 */ "Reference",
+ /* 21 */ "Alias",
+ /* 22 */ "Notify",
+ /* 23 */ "AddrHandler",
+ /* 24 */ "ResourceDesc",
+ /* 25 */ "ResourceFld",
+ /* 26 */ "Scope",
+ /* 27 */ "Extra",
+ /* 28 */ "Data",
+ /* 39 */ "Invalid"
+};
+
+
+char *
+AcpiUtGetTypeName (
+ ACPI_OBJECT_TYPE Type)
+{
+
+ if (Type > ACPI_TYPE_INVALID)
+ {
+ return ((char *) AcpiGbl_BadType);
+ }
+
+ return ((char *) AcpiGbl_NsTypeNames[Type]);
+}
+
+
+char *
+AcpiUtGetObjectTypeName (
+ ACPI_OPERAND_OBJECT *ObjDesc)
+{
+
+ if (!ObjDesc)
+ {
+ return ("[NULL Object Descriptor]");
+ }
+
+ return (AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc)));
+}
+
+
+#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
+
+/*
+ * Strings and procedures used for debug only
+ */
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtGetMutexName
+ *
+ * PARAMETERS: None.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
+ *
+ ****************************************************************************/
+
+char *
+AcpiUtGetMutexName (
+ UINT32 MutexId)
+{
+
+ if (MutexId > MAX_MTX)
+ {
+ return ("Invalid Mutex ID");
+ }
+
+ return (AcpiGbl_MutexNames[MutexId]);
+}
+
+
+#endif
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiUtValidObjectType
+ *
+ * PARAMETERS: Type - Object type to be validated
+ *
+ * RETURN: TRUE if valid object type
+ *
+ * DESCRIPTION: Validate an object type
+ *
+ ****************************************************************************/
+
+BOOLEAN
+AcpiUtValidObjectType (
+ ACPI_OBJECT_TYPE Type)
+{
+
+ if (Type > ACPI_TYPE_LOCAL_MAX)
+ {
+ /* Note: Assumes all TYPEs are contiguous (external/local) */
+
+ return (FALSE);
+ }
+
+ return (TRUE);
+}
+
+
+/****************************************************************************
+ *
+ * FUNCTION: AcpiUtAllocateOwnerId
+ *
+ * PARAMETERS: IdType - Type of ID (method or table)
+ *
+ * DESCRIPTION: Allocate a table or method owner id
+ *
+ ***************************************************************************/
+
+ACPI_OWNER_ID
+AcpiUtAllocateOwnerId (
+ UINT32 IdType)
+{
+ ACPI_OWNER_ID OwnerId = 0xFFFF;
+
+
+ ACPI_FUNCTION_TRACE ("UtAllocateOwnerId");
+
+
+ if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
+ {
+ return (0);
+ }
+
+ switch (IdType)
+ {
+ case ACPI_OWNER_TYPE_TABLE:
+
+ OwnerId = AcpiGbl_NextTableOwnerId;
+ AcpiGbl_NextTableOwnerId++;
+
+ if (AcpiGbl_NextTableOwnerId == ACPI_FIRST_METHOD_ID)
+ {
+ AcpiGbl_NextTableOwnerId = ACPI_FIRST_TABLE_ID;
+ }
+ break;
+
+
+ case ACPI_OWNER_TYPE_METHOD:
+
+ OwnerId = AcpiGbl_NextMethodOwnerId;
+ AcpiGbl_NextMethodOwnerId++;
+
+ if (AcpiGbl_NextMethodOwnerId == ACPI_FIRST_TABLE_ID)
+ {
+ AcpiGbl_NextMethodOwnerId = ACPI_FIRST_METHOD_ID;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
+ return_VALUE (OwnerId);
+}
+
+
+/****************************************************************************
+ *
+ * FUNCTION: AcpiUtInitGlobals
+ *
+ * PARAMETERS: none
+ *
+ * DESCRIPTION: Init library globals. All globals that require specific
+ * initialization should be initialized here!
+ *
+ ***************************************************************************/
+
+void
+AcpiUtInitGlobals (
+ void)
+{
+ UINT32 i;
+
+
+ ACPI_FUNCTION_TRACE ("UtInitGlobals");
+
+ /* Memory allocation and cache lists */
+
+ ACPI_MEMSET (AcpiGbl_MemoryLists, 0, sizeof (ACPI_MEMORY_LIST) * ACPI_NUM_MEM_LISTS);
+
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_GENERIC_STATE *) NULL)->Common.Next), NULL);
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL);
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL);
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_OPERAND_OBJECT *) NULL)->Cache.Next), NULL);
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_WALK_STATE *) NULL)->Next), NULL);
+
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ObjectSize = sizeof (ACPI_NAMESPACE_NODE);
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ObjectSize = sizeof (ACPI_GENERIC_STATE);
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ObjectSize = sizeof (ACPI_PARSE_OBJ_COMMON);
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ObjectSize = sizeof (ACPI_PARSE_OBJ_NAMED);
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ObjectSize = sizeof (ACPI_OPERAND_OBJECT);
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ObjectSize = sizeof (ACPI_WALK_STATE);
+
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].MaxCacheDepth = ACPI_MAX_STATE_CACHE_DEPTH;
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].MaxCacheDepth = ACPI_MAX_PARSE_CACHE_DEPTH;
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].MaxCacheDepth = ACPI_MAX_EXTPARSE_CACHE_DEPTH;
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].MaxCacheDepth = ACPI_MAX_OBJECT_CACHE_DEPTH;
+ AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].MaxCacheDepth = ACPI_MAX_WALK_CACHE_DEPTH;
+
+ ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].ListName = "Global Memory Allocation");
+ ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ListName = "Namespace Nodes");
+ ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ListName = "State Object Cache");
+ ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ListName = "Parse Node Cache");
+ ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ListName = "Extended Parse Node Cache");
+ ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ListName = "Operand Object Cache");
+ ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ListName = "Tree Walk Node Cache");
+
+ /* ACPI table structure */
+
+ for (i = 0; i < NUM_ACPI_TABLES; i++)
+ {
+ AcpiGbl_AcpiTables[i].Prev = &AcpiGbl_AcpiTables[i];
+ AcpiGbl_AcpiTables[i].Next = &AcpiGbl_AcpiTables[i];
+ AcpiGbl_AcpiTables[i].Pointer = NULL;
+ AcpiGbl_AcpiTables[i].Length = 0;
+ AcpiGbl_AcpiTables[i].Allocation = ACPI_MEM_NOT_ALLOCATED;
+ AcpiGbl_AcpiTables[i].Count = 0;
+ }
+
+ /* Mutex locked flags */
+
+ for (i = 0; i < NUM_MTX; i++)
+ {
+ AcpiGbl_AcpiMutexInfo[i].Mutex = NULL;
+ AcpiGbl_AcpiMutexInfo[i].OwnerId = ACPI_MUTEX_NOT_ACQUIRED;
+ AcpiGbl_AcpiMutexInfo[i].UseCount = 0;
+ }
+
+ /* GPE support */
+
+ AcpiGbl_GpeBlockListHead = NULL;
+
+ /* Global notify handlers */
+
+ AcpiGbl_SysNotify.Handler = NULL;
+ AcpiGbl_DrvNotify.Handler = NULL;
+ AcpiGbl_InitHandler = NULL;
+
+ /* Global "typed" ACPI table pointers */
+
+ AcpiGbl_RSDP = NULL;
+ AcpiGbl_XSDT = NULL;
+ AcpiGbl_FACS = NULL;
+ AcpiGbl_FADT = NULL;
+ AcpiGbl_DSDT = NULL;
+
+ /* Global Lock support */
+
+ AcpiGbl_GlobalLockAcquired = FALSE;
+ AcpiGbl_GlobalLockThreadCount = 0;
+ AcpiGbl_GlobalLockHandle = 0;
+
+ /* Miscellaneous variables */
+
+ AcpiGbl_TableFlags = ACPI_PHYSICAL_POINTER;
+ AcpiGbl_RsdpOriginalLocation = 0;
+ AcpiGbl_CmSingleStep = FALSE;
+ AcpiGbl_DbTerminateThreads = FALSE;
+ AcpiGbl_Shutdown = FALSE;
+ AcpiGbl_NsLookupCount = 0;
+ AcpiGbl_PsFindCount = 0;
+ AcpiGbl_AcpiHardwarePresent = TRUE;
+ AcpiGbl_NextTableOwnerId = ACPI_FIRST_TABLE_ID;
+ AcpiGbl_NextMethodOwnerId = ACPI_FIRST_METHOD_ID;
+ AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING;
+ AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT;
+
+ /* Hardware oriented */
+
+ AcpiGbl_EventsInitialized = FALSE;
+
+ /* Namespace */
+
+ AcpiGbl_RootNode = NULL;
+
+ AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
+ AcpiGbl_RootNodeStruct.Descriptor = ACPI_DESC_TYPE_NAMED;
+ AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE;
+ AcpiGbl_RootNodeStruct.Child = NULL;
+ AcpiGbl_RootNodeStruct.Peer = NULL;
+ AcpiGbl_RootNodeStruct.Object = NULL;
+ AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST;
+
+
+#ifdef ACPI_DEBUG_OUTPUT
+ AcpiGbl_LowestStackPointer = ACPI_SIZE_MAX;
+#endif
+
+ return_VOID;
+}
+
+
diff --git a/sys/contrib/dev/acpica/utinit.c b/sys/contrib/dev/acpica/utinit.c
new file mode 100644
index 0000000..10e52eb
--- /dev/null
+++ b/sys/contrib/dev/acpica/utinit.c
@@ -0,0 +1,329 @@
+/******************************************************************************
+ *
+ * Module Name: utinit - Common ACPI subsystem initialization
+ * $Revision: 116 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __UTINIT_C__
+
+#include "acpi.h"
+#include "acnamesp.h"
+#include "acevents.h"
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utinit")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtFadtRegisterError
+ *
+ * PARAMETERS: *RegisterName - Pointer to string identifying register
+ * Value - Actual register contents value
+ * AcpiTestSpecSection - TDS section containing assertion
+ * AcpiAssertion - Assertion number being tested
+ *
+ * RETURN: AE_BAD_VALUE
+ *
+ * DESCRIPTION: Display failure message and link failure to TDS assertion
+ *
+ ******************************************************************************/
+
+static void
+AcpiUtFadtRegisterError (
+ char *RegisterName,
+ UINT32 Value,
+ ACPI_SIZE Offset)
+{
+
+ ACPI_REPORT_WARNING (
+ ("Invalid FADT value %s=%X at offset %X FADT=%p\n",
+ RegisterName, Value, (UINT32) Offset, AcpiGbl_FADT));
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiUtValidateFadt
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Validate various ACPI registers in the FADT
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtValidateFadt (
+ void)
+{
+
+ /*
+ * Verify Fixed ACPI Description Table fields,
+ * but don't abort on any problems, just display error
+ */
+ if (AcpiGbl_FADT->Pm1EvtLen < 4)
+ {
+ AcpiUtFadtRegisterError ("PM1_EVT_LEN",
+ (UINT32) AcpiGbl_FADT->Pm1EvtLen,
+ ACPI_FADT_OFFSET (Pm1EvtLen));
+ }
+
+ if (!AcpiGbl_FADT->Pm1CntLen)
+ {
+ AcpiUtFadtRegisterError ("PM1_CNT_LEN", 0,
+ ACPI_FADT_OFFSET (Pm1CntLen));
+ }
+
+ if (!ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm1aEvtBlk.Address))
+ {
+ AcpiUtFadtRegisterError ("X_PM1a_EVT_BLK", 0,
+ ACPI_FADT_OFFSET (XPm1aEvtBlk.Address));
+ }
+
+ if (!ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm1aCntBlk.Address))
+ {
+ AcpiUtFadtRegisterError ("X_PM1a_CNT_BLK", 0,
+ ACPI_FADT_OFFSET (XPm1aCntBlk.Address));
+ }
+
+ if (!ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPmTmrBlk.Address))
+ {
+ AcpiUtFadtRegisterError ("X_PM_TMR_BLK", 0,
+ ACPI_FADT_OFFSET (XPmTmrBlk.Address));
+ }
+
+ if ((ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address) &&
+ !AcpiGbl_FADT->Pm2CntLen))
+ {
+ AcpiUtFadtRegisterError ("PM2_CNT_LEN",
+ (UINT32) AcpiGbl_FADT->Pm2CntLen,
+ ACPI_FADT_OFFSET (Pm2CntLen));
+ }
+
+ if (AcpiGbl_FADT->PmTmLen < 4)
+ {
+ AcpiUtFadtRegisterError ("PM_TM_LEN",
+ (UINT32) AcpiGbl_FADT->PmTmLen,
+ ACPI_FADT_OFFSET (PmTmLen));
+ }
+
+ /* Length of GPE blocks must be a multiple of 2 */
+
+ if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XGpe0Blk.Address) &&
+ (AcpiGbl_FADT->Gpe0BlkLen & 1))
+ {
+ AcpiUtFadtRegisterError ("(x)GPE0_BLK_LEN",
+ (UINT32) AcpiGbl_FADT->Gpe0BlkLen,
+ ACPI_FADT_OFFSET (Gpe0BlkLen));
+ }
+
+ if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XGpe1Blk.Address) &&
+ (AcpiGbl_FADT->Gpe1BlkLen & 1))
+ {
+ AcpiUtFadtRegisterError ("(x)GPE1_BLK_LEN",
+ (UINT32) AcpiGbl_FADT->Gpe1BlkLen,
+ ACPI_FADT_OFFSET (Gpe1BlkLen));
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiUtTerminate
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: free memory allocated for table storage.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtTerminate (void)
+{
+
+ ACPI_FUNCTION_TRACE ("UtTerminate");
+
+
+ /* Free global tables, etc. */
+
+ /* Nothing to do at this time */
+
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtSubsystemShutdown
+ *
+ * PARAMETERS: none
+ *
+ * RETURN: none
+ *
+ * DESCRIPTION: Shutdown the various subsystems. Don't delete the mutex
+ * objects here -- because the AML debugger may be still running.
+ *
+ ******************************************************************************/
+
+void
+AcpiUtSubsystemShutdown (void)
+{
+
+ ACPI_FUNCTION_TRACE ("UtSubsystemShutdown");
+
+ /* Just exit if subsystem is already shutdown */
+
+ if (AcpiGbl_Shutdown)
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "ACPI Subsystem is already terminated\n"));
+ return_VOID;
+ }
+
+ /* Subsystem appears active, go ahead and shut it down */
+
+ AcpiGbl_Shutdown = TRUE;
+ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem...\n"));
+
+ /* Close the AcpiEvent Handling */
+
+ AcpiEvTerminate ();
+
+ /* Close the Namespace */
+
+ AcpiNsTerminate ();
+
+ /* Close the globals */
+
+ AcpiUtTerminate ();
+
+ /* Purge the local caches */
+
+ (void) AcpiPurgeCachedObjects ();
+
+ /* Debug only - display leftover memory allocation, if any */
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+ AcpiUtDumpAllocations (ACPI_UINT32_MAX, NULL);
+#endif
+
+ return_VOID;
+}
+
+
diff --git a/sys/contrib/dev/acpica/utmath.c b/sys/contrib/dev/acpica/utmath.c
new file mode 100644
index 0000000..f519cd2
--- /dev/null
+++ b/sys/contrib/dev/acpica/utmath.c
@@ -0,0 +1,428 @@
+/*******************************************************************************
+ *
+ * Module Name: utmath - Integer math support routines
+ * $Revision: 12 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __UTMATH_C__
+
+#include "acpi.h"
+
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utmath")
+
+/*
+ * Support for double-precision integer divide. This code is included here
+ * in order to support kernel environments where the double-precision math
+ * library is not available.
+ */
+
+#ifndef ACPI_USE_NATIVE_DIVIDE
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtShortDivide
+ *
+ * PARAMETERS: InDividend - Pointer to the dividend
+ * Divisor - 32-bit divisor
+ * OutQuotient - Pointer to where the quotient is returned
+ * OutRemainder - Pointer to where the remainder is returned
+ *
+ * RETURN: Status (Checks for divide-by-zero)
+ *
+ * DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits)
+ * divide and modulo. The result is a 64-bit quotient and a
+ * 32-bit remainder.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtShortDivide (
+ ACPI_INTEGER *InDividend,
+ UINT32 Divisor,
+ ACPI_INTEGER *OutQuotient,
+ UINT32 *OutRemainder)
+{
+ UINT64_OVERLAY Dividend;
+ UINT64_OVERLAY Quotient;
+ UINT32 Remainder32;
+
+
+ ACPI_FUNCTION_TRACE ("UtShortDivide");
+
+ Dividend.Full = *InDividend;
+
+ /* Always check for a zero divisor */
+
+ if (Divisor == 0)
+ {
+ ACPI_REPORT_ERROR (("AcpiUtShortDivide: Divide by zero\n"));
+ return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
+ }
+
+ /*
+ * The quotient is 64 bits, the remainder is always 32 bits,
+ * and is generated by the second divide.
+ */
+ ACPI_DIV_64_BY_32 (0, Dividend.Part.Hi, Divisor,
+ Quotient.Part.Hi, Remainder32);
+ ACPI_DIV_64_BY_32 (Remainder32, Dividend.Part.Lo, Divisor,
+ Quotient.Part.Lo, Remainder32);
+
+ /* Return only what was requested */
+
+ if (OutQuotient)
+ {
+ *OutQuotient = Quotient.Full;
+ }
+ if (OutRemainder)
+ {
+ *OutRemainder = Remainder32;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtDivide
+ *
+ * PARAMETERS: InDividend - Pointer to the dividend
+ * InDivisor - Pointer to the divisor
+ * OutQuotient - Pointer to where the quotient is returned
+ * OutRemainder - Pointer to where the remainder is returned
+ *
+ * RETURN: Status (Checks for divide-by-zero)
+ *
+ * DESCRIPTION: Perform a divide and modulo.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtDivide (
+ ACPI_INTEGER *InDividend,
+ ACPI_INTEGER *InDivisor,
+ ACPI_INTEGER *OutQuotient,
+ ACPI_INTEGER *OutRemainder)
+{
+ UINT64_OVERLAY Dividend;
+ UINT64_OVERLAY Divisor;
+ UINT64_OVERLAY Quotient;
+ UINT64_OVERLAY Remainder;
+ UINT64_OVERLAY NormalizedDividend;
+ UINT64_OVERLAY NormalizedDivisor;
+ UINT32 Partial1;
+ UINT64_OVERLAY Partial2;
+ UINT64_OVERLAY Partial3;
+
+
+ ACPI_FUNCTION_TRACE ("UtDivide");
+
+
+ /* Always check for a zero divisor */
+
+ if (*InDivisor == 0)
+ {
+ ACPI_REPORT_ERROR (("AcpiUtDivide: Divide by zero\n"));
+ return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
+ }
+
+ Divisor.Full = *InDivisor;
+ Dividend.Full = *InDividend;
+ if (Divisor.Part.Hi == 0)
+ {
+ /*
+ * 1) Simplest case is where the divisor is 32 bits, we can
+ * just do two divides
+ */
+ Remainder.Part.Hi = 0;
+
+ /*
+ * The quotient is 64 bits, the remainder is always 32 bits,
+ * and is generated by the second divide.
+ */
+ ACPI_DIV_64_BY_32 (0, Dividend.Part.Hi, Divisor.Part.Lo,
+ Quotient.Part.Hi, Partial1);
+ ACPI_DIV_64_BY_32 (Partial1, Dividend.Part.Lo, Divisor.Part.Lo,
+ Quotient.Part.Lo, Remainder.Part.Lo);
+ }
+
+ else
+ {
+ /*
+ * 2) The general case where the divisor is a full 64 bits
+ * is more difficult
+ */
+ Quotient.Part.Hi = 0;
+ NormalizedDividend = Dividend;
+ NormalizedDivisor = Divisor;
+
+ /* Normalize the operands (shift until the divisor is < 32 bits) */
+
+ do
+ {
+ ACPI_SHIFT_RIGHT_64 (NormalizedDivisor.Part.Hi,
+ NormalizedDivisor.Part.Lo);
+ ACPI_SHIFT_RIGHT_64 (NormalizedDividend.Part.Hi,
+ NormalizedDividend.Part.Lo);
+
+ } while (NormalizedDivisor.Part.Hi != 0);
+
+ /* Partial divide */
+
+ ACPI_DIV_64_BY_32 (NormalizedDividend.Part.Hi,
+ NormalizedDividend.Part.Lo,
+ NormalizedDivisor.Part.Lo,
+ Quotient.Part.Lo, Partial1);
+
+ /*
+ * The quotient is always 32 bits, and simply requires adjustment.
+ * The 64-bit remainder must be generated.
+ */
+ Partial1 = Quotient.Part.Lo * Divisor.Part.Hi;
+ Partial2.Full = (ACPI_INTEGER) Quotient.Part.Lo * Divisor.Part.Lo;
+ Partial3.Full = (ACPI_INTEGER) Partial2.Part.Hi + Partial1;
+
+ Remainder.Part.Hi = Partial3.Part.Lo;
+ Remainder.Part.Lo = Partial2.Part.Lo;
+
+ if (Partial3.Part.Hi == 0)
+ {
+ if (Partial3.Part.Lo >= Dividend.Part.Hi)
+ {
+ if (Partial3.Part.Lo == Dividend.Part.Hi)
+ {
+ if (Partial2.Part.Lo > Dividend.Part.Lo)
+ {
+ Quotient.Part.Lo--;
+ Remainder.Full -= Divisor.Full;
+ }
+ }
+ else
+ {
+ Quotient.Part.Lo--;
+ Remainder.Full -= Divisor.Full;
+ }
+ }
+
+ Remainder.Full = Remainder.Full - Dividend.Full;
+ Remainder.Part.Hi = (UINT32) -((INT32) Remainder.Part.Hi);
+ Remainder.Part.Lo = (UINT32) -((INT32) Remainder.Part.Lo);
+
+ if (Remainder.Part.Lo)
+ {
+ Remainder.Part.Hi--;
+ }
+ }
+ }
+
+ /* Return only what was requested */
+
+ if (OutQuotient)
+ {
+ *OutQuotient = Quotient.Full;
+ }
+ if (OutRemainder)
+ {
+ *OutRemainder = Remainder.Full;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+#else
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtShortDivide, AcpiUtDivide
+ *
+ * DESCRIPTION: Native versions of the UtDivide functions. Use these if either
+ * 1) The target is a 64-bit platform and therefore 64-bit
+ * integer math is supported directly by the machine.
+ * 2) The target is a 32-bit or 16-bit platform, and the
+ * double-precision integer math library is available to
+ * perform the divide.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtShortDivide (
+ ACPI_INTEGER *InDividend,
+ UINT32 Divisor,
+ ACPI_INTEGER *OutQuotient,
+ UINT32 *OutRemainder)
+{
+
+ ACPI_FUNCTION_TRACE ("UtShortDivide");
+
+
+ /* Always check for a zero divisor */
+
+ if (Divisor == 0)
+ {
+ ACPI_REPORT_ERROR (("AcpiUtShortDivide: Divide by zero\n"));
+ return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
+ }
+
+ /* Return only what was requested */
+
+ if (OutQuotient)
+ {
+ *OutQuotient = *InDividend / Divisor;
+ }
+ if (OutRemainder)
+ {
+ *OutRemainder = (UINT32) *InDividend % Divisor;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+ACPI_STATUS
+AcpiUtDivide (
+ ACPI_INTEGER *InDividend,
+ ACPI_INTEGER *InDivisor,
+ ACPI_INTEGER *OutQuotient,
+ ACPI_INTEGER *OutRemainder)
+{
+ ACPI_FUNCTION_TRACE ("UtDivide");
+
+
+ /* Always check for a zero divisor */
+
+ if (*InDivisor == 0)
+ {
+ ACPI_REPORT_ERROR (("AcpiUtDivide: Divide by zero\n"));
+ return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO);
+ }
+
+
+ /* Return only what was requested */
+
+ if (OutQuotient)
+ {
+ *OutQuotient = *InDividend / *InDivisor;
+ }
+ if (OutRemainder)
+ {
+ *OutRemainder = *InDividend % *InDivisor;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+#endif
+
+
diff --git a/sys/contrib/dev/acpica/utmisc.c b/sys/contrib/dev/acpica/utmisc.c
new file mode 100644
index 0000000..91b2382
--- /dev/null
+++ b/sys/contrib/dev/acpica/utmisc.c
@@ -0,0 +1,1651 @@
+/*******************************************************************************
+ *
+ * Module Name: utmisc - common utility procedures
+ * $Revision: 93 $
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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.
+ * (NULL if no extra path)
+ *
+ * RETURN: ACPI_STATUS
+ *
+ * DESCRIPTION: Display full pathname of an object, DEBUG ONLY
+ *
+ ******************************************************************************/
+
+void
+AcpiUtDisplayInitPathname (
+ UINT8 Type,
+ ACPI_NAMESPACE_NODE *ObjHandle,
+ char *Path)
+{
+ ACPI_STATUS Status;
+ ACPI_BUFFER Buffer;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Only print the path if the appropriate debug level is enabled */
+
+ if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
+ {
+ return;
+ }
+
+ /* Get the full pathname to the node */
+
+ Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+ Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ /* Print what we're doing */
+
+ switch (Type)
+ {
+ case ACPI_TYPE_METHOD:
+ AcpiOsPrintf ("Executing ");
+ break;
+
+ default:
+ AcpiOsPrintf ("Initializing ");
+ break;
+ }
+
+ /* Print the object type and pathname */
+
+ AcpiOsPrintf ("%-12s %s", AcpiUtGetTypeName (Type), (char *) Buffer.Pointer);
+
+ /* Extra path is used to append names like _STA, _INI, etc. */
+
+ if (Path)
+ {
+ AcpiOsPrintf (".%s", Path);
+ }
+ AcpiOsPrintf ("\n");
+
+ 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)
+{
+ char *NamePtr = (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 (
+ 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 (
+ 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
+ *
+ ******************************************************************************/
+
+char *
+AcpiUtStrupr (
+ char *SrcString)
+{
+ char *String;
+
+
+ ACPI_FUNCTION_ENTRY ();
+
+
+ /* Walk entire string, uppercasing the letters */
+
+ for (String = SrcString; *String; )
+ {
+ *String = (char) ACPI_TOUPPER (*String);
+ String++;
+ }
+
+ return (SrcString);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiUtMutexInitialize
+ *
+ * PARAMETERS: None.
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create the system mutex objects.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUtMutexInitialize (
+ void)
+{
+ UINT32 i;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("UtMutexInitialize");
+
+
+ /*
+ * Create each of the predefined mutex objects
+ */
+ for (i = 0; i < NUM_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, 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)
+ {
+ /* Get one element of the package */
+
+ 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 (
+ 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 (
+ 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 (
+ 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
new file mode 100644
index 0000000..babdcf6
--- /dev/null
+++ b/sys/contrib/dev/acpica/utobject.c
@@ -0,0 +1,721 @@
+/******************************************************************************
+ *
+ * Module Name: utobject - ACPI object create/delete/size/cache routines
+ * $Revision: 82 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 (
+ 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 = 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"));
+ 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_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 (
+ 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 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);
+}
+
+
diff --git a/sys/contrib/dev/acpica/utxface.c b/sys/contrib/dev/acpica/utxface.c
new file mode 100644
index 0000000..6a99631
--- /dev/null
+++ b/sys/contrib/dev/acpica/utxface.c
@@ -0,0 +1,602 @@
+/******************************************************************************
+ *
+ * Module Name: utxface - External interfaces for "global" ACPI functions
+ * $Revision: 101 $
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2003, 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 __UTXFACE_C__
+
+#include "acpi.h"
+#include "acevents.h"
+#include "acnamesp.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "acdebug.h"
+
+#define _COMPONENT ACPI_UTILITIES
+ ACPI_MODULE_NAME ("utxface")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiInitializeSubsystem
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Initializes all global variables. This is the first function
+ * called, so any early initialization belongs here.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiInitializeSubsystem (
+ void)
+{
+ ACPI_STATUS Status;
+
+ ACPI_FUNCTION_TRACE ("AcpiInitializeSubsystem");
+
+
+ ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());
+
+
+ /* Initialize all globals used by the subsystem */
+
+ AcpiUtInitGlobals ();
+
+ /* Initialize the OS-Dependent layer */
+
+ Status = AcpiOsInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("OSD failed to initialize, %s\n",
+ AcpiFormatException (Status)));
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Create the default mutex objects */
+
+ Status = AcpiUtMutexInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("Global mutex creation failure, %s\n",
+ AcpiFormatException (Status)));
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Initialize the namespace manager and
+ * the root of the namespace tree
+ */
+
+ Status = AcpiNsRootInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_REPORT_ERROR (("Namespace initialization failure, %s\n",
+ AcpiFormatException (Status)));
+ return_ACPI_STATUS (Status);
+ }
+
+
+ /* If configured, initialize the AML debugger */
+
+ ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ());
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiEnableSubsystem
+ *
+ * PARAMETERS: Flags - Init/enable Options
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Completes the subsystem initialization including hardware.
+ * Puts system into ACPI mode if it isn't already.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnableSubsystem (
+ UINT32 Flags)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiEnableSubsystem");
+
+
+ /*
+ * Install the default OpRegion handlers. These are installed unless
+ * other handlers have already been installed via the
+ * InstallAddressSpaceHandler interface
+ */
+ if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing default address space handlers\n"));
+
+ Status = AcpiEvInitAddressSpaces ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * We must initialize the hardware before we can enable ACPI.
+ * FADT values are validated here.
+ */
+ if (!(Flags & ACPI_NO_HARDWARE_INIT))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI hardware\n"));
+
+ Status = AcpiHwInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Enable ACPI on this platform
+ */
+ if (!(Flags & ACPI_NO_ACPI_ENABLE))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
+
+ AcpiGbl_OriginalMode = AcpiHwGetMode();
+
+ Status = AcpiEnable ();
+ if (ACPI_FAILURE (Status))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_WARN, "AcpiEnable failed.\n"));
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Note:
+ * We must have the hardware AND events initialized before we can execute
+ * ANY control methods SAFELY. Any control method can require ACPI hardware
+ * support, so the hardware MUST be initialized before execution!
+ */
+ if (!(Flags & ACPI_NO_EVENT_INIT))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI events\n"));
+
+ Status = AcpiEvInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /* Install SCI handler, Global Lock handler, GPE handlers */
+
+ if (!(Flags & ACPI_NO_HANDLER_INIT))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Installing SCI/GL/GPE handlers\n"));
+
+ Status = AcpiEvHandlerInitialize ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ return_ACPI_STATUS (Status);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiInitializeObjects
+ *
+ * PARAMETERS: Flags - Init/enable Options
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Completes namespace initialization by initializing device
+ * objects and executing AML code for Regions, buffers, etc.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiInitializeObjects (
+ UINT32 Flags)
+{
+ ACPI_STATUS Status = AE_OK;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiInitializeObjects");
+
+ /*
+ * Initialize all device objects in the namespace
+ * This runs the _STA and _INI methods.
+ */
+ if (!(Flags & ACPI_NO_DEVICE_INIT))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI Devices\n"));
+
+ Status = AcpiNsInitializeDevices ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Initialize the objects that remain uninitialized. This
+ * runs the executable AML that is part of the declaration of OpRegions
+ * and Fields.
+ */
+ if (!(Flags & ACPI_NO_OBJECT_INIT))
+ {
+ ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Initializing ACPI Objects\n"));
+
+ Status = AcpiNsInitializeObjects ();
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+ }
+
+ /*
+ * Empty the caches (delete the cached objects) on the assumption that
+ * the table load filled them up more than they will be at runtime --
+ * thus wasting non-paged memory.
+ */
+ Status = AcpiPurgeCachedObjects ();
+
+ AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiTerminate
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Shutdown the ACPI subsystem. Release all resources.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTerminate (void)
+{
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiTerminate");
+
+
+ /* Terminate the AML Debugger if present */
+
+ ACPI_DEBUGGER_EXEC(AcpiGbl_DbTerminateThreads = TRUE);
+
+ /* Shutdown and free all resources */
+
+ AcpiUtSubsystemShutdown ();
+
+
+ /* Free the mutex objects */
+
+ AcpiUtMutexTerminate ();
+
+
+#ifdef ACPI_DEBUGGER
+
+ /* Shut down the debugger */
+
+ AcpiDbTerminate ();
+#endif
+
+ /* Now we can shutdown the OS-dependent layer */
+
+ Status = AcpiOsTerminate ();
+ return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiSubsystemStatus
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status of the ACPI subsystem
+ *
+ * DESCRIPTION: Other drivers that use the ACPI subsystem should call this
+ * before making any other calls, to ensure the subsystem initial-
+ * ized successfully.
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiSubsystemStatus (void)
+{
+ if (AcpiGbl_StartupFlags & ACPI_INITIALIZED_OK)
+ {
+ return (AE_OK);
+ }
+ else
+ {
+ return (AE_ERROR);
+ }
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiGetSystemInfo
+ *
+ * PARAMETERS: OutBuffer - a pointer to a buffer to receive the
+ * resources for the device
+ * BufferLength - the number of bytes available in the buffer
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: This function is called to get information about the current
+ * state of the ACPI subsystem. It will return system information
+ * in the OutBuffer.
+ *
+ * If the function fails an appropriate status will be returned
+ * and the value of OutBuffer is undefined.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetSystemInfo (
+ ACPI_BUFFER *OutBuffer)
+{
+ ACPI_SYSTEM_INFO *InfoPtr;
+ UINT32 i;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE ("AcpiGetSystemInfo");
+
+
+ /* Parameter validation */
+
+ Status = AcpiUtValidateBuffer (OutBuffer);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (OutBuffer, sizeof (ACPI_SYSTEM_INFO));
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
+ /*
+ * Populate the return buffer
+ */
+ InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer;
+
+ InfoPtr->AcpiCaVersion = ACPI_CA_VERSION;
+
+ /* System flags (ACPI capabilities) */
+
+ InfoPtr->Flags = ACPI_SYS_MODE_ACPI;
+
+ /* Timer resolution - 24 or 32 bits */
+
+ if (!AcpiGbl_FADT)
+ {
+ InfoPtr->TimerResolution = 0;
+ }
+ else if (AcpiGbl_FADT->TmrValExt == 0)
+ {
+ InfoPtr->TimerResolution = 24;
+ }
+ else
+ {
+ InfoPtr->TimerResolution = 32;
+ }
+
+ /* Clear the reserved fields */
+
+ InfoPtr->Reserved1 = 0;
+ InfoPtr->Reserved2 = 0;
+
+ /* Current debug levels */
+
+ InfoPtr->DebugLayer = AcpiDbgLayer;
+ InfoPtr->DebugLevel = AcpiDbgLevel;
+
+ /* Current status of the ACPI tables, per table type */
+
+ InfoPtr->NumTableTypes = NUM_ACPI_TABLES;
+ for (i = 0; i < NUM_ACPI_TABLES; i++)
+ {
+ InfoPtr->TableInfo[i].Count = AcpiGbl_AcpiTables[i].Count;
+ }
+
+ return_ACPI_STATUS (AE_OK);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiInstallInitializationHandler
+ *
+ * PARAMETERS: Handler - Callback procedure
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Install an initialization handler
+ *
+ * TBD: When a second function is added, must save the Function also.
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiInstallInitializationHandler (
+ ACPI_INIT_HANDLER Handler,
+ UINT32 Function)
+{
+
+ if (!Handler)
+ {
+ return (AE_BAD_PARAMETER);
+ }
+
+ if (AcpiGbl_InitHandler)
+ {
+ return (AE_ALREADY_EXISTS);
+ }
+
+ AcpiGbl_InitHandler = Handler;
+ return AE_OK;
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION: AcpiPurgeCachedObjects
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Empty all caches (delete the cached objects)
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiPurgeCachedObjects (void)
+{
+ ACPI_FUNCTION_TRACE ("AcpiPurgeCachedObjects");
+
+
+ AcpiUtDeleteGenericStateCache ();
+ AcpiUtDeleteObjectCache ();
+ AcpiDsDeleteWalkStateCache ();
+ AcpiPsDeleteParseCache ();
+
+ return_ACPI_STATUS (AE_OK);
+}
OpenPOWER on IntegriCloud