[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Fri Mar 2 15:39:12 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/4bbaa78c297d
changeset: 381:4bbaa78c297d
user:      ray at terran.dlink.ua
date:      Fri Mar 02 17:09:07 2012 +0200
description:
Update to FreeBSD-HEAD @232391

diffstat:

 head/sys/contrib/dev/acpica/acpica_prep.sh                        |     8 +-
 head/sys/contrib/dev/acpica/changes.txt                           |    92 +
 head/sys/contrib/dev/acpica/compiler/aslrestype2s.c               |    24 +-
 head/sys/contrib/dev/acpica/compiler/aslstubs.c                   |    16 +-
 head/sys/contrib/dev/acpica/components/debugger/dbcmds.c          |  1084 +++++++
 head/sys/contrib/dev/acpica/components/debugger/dbdisply.c        |  1057 +++++++
 head/sys/contrib/dev/acpica/components/debugger/dbexec.c          |  1105 ++++++++
 head/sys/contrib/dev/acpica/components/debugger/dbfileio.c        |   578 ++++
 head/sys/contrib/dev/acpica/components/debugger/dbhistry.c        |   220 +
 head/sys/contrib/dev/acpica/components/debugger/dbinput.c         |  1091 +++++++
 head/sys/contrib/dev/acpica/components/debugger/dbmethod.c        |   529 +++
 head/sys/contrib/dev/acpica/components/debugger/dbnames.c         |   934 ++++++
 head/sys/contrib/dev/acpica/components/debugger/dbstats.c         |   549 ++++
 head/sys/contrib/dev/acpica/components/debugger/dbutils.c         |   526 +++
 head/sys/contrib/dev/acpica/components/debugger/dbxface.c         |   542 +++
 head/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c    |   542 +++
 head/sys/contrib/dev/acpica/components/disassembler/dmnames.c     |   453 +++
 head/sys/contrib/dev/acpica/components/disassembler/dmobject.c    |   589 ++++
 head/sys/contrib/dev/acpica/components/disassembler/dmopcode.c    |   607 ++++
 head/sys/contrib/dev/acpica/components/disassembler/dmresrc.c     |   434 +++
 head/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c    |  1052 +++++++
 head/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c   |   700 +++++
 head/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c    |   358 ++
 head/sys/contrib/dev/acpica/components/disassembler/dmutils.c     |   321 ++
 head/sys/contrib/dev/acpica/components/disassembler/dmwalk.c      |   935 ++++++
 head/sys/contrib/dev/acpica/components/dispatcher/dsargs.c        |   438 +++
 head/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c     |   424 +++
 head/sys/contrib/dev/acpica/components/dispatcher/dsfield.c       |   748 +++++
 head/sys/contrib/dev/acpica/components/dispatcher/dsinit.c        |   238 +
 head/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c      |   726 +++++
 head/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c      |   772 +++++
 head/sys/contrib/dev/acpica/components/dispatcher/dsobject.c      |   867 ++++++
 head/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c      |   809 +++++
 head/sys/contrib/dev/acpica/components/dispatcher/dsutils.c       |   937 ++++++
 head/sys/contrib/dev/acpica/components/dispatcher/dswexec.c       |   797 +++++
 head/sys/contrib/dev/acpica/components/dispatcher/dswload.c       |   551 ++++
 head/sys/contrib/dev/acpica/components/dispatcher/dswload2.c      |   747 +++++
 head/sys/contrib/dev/acpica/components/dispatcher/dswscope.c      |   239 +
 head/sys/contrib/dev/acpica/components/dispatcher/dswstate.c      |   846 ++++++
 head/sys/contrib/dev/acpica/components/events/evevent.c           |   336 ++
 head/sys/contrib/dev/acpica/components/events/evglock.c           |   377 ++
 head/sys/contrib/dev/acpica/components/events/evgpe.c             |   831 ++++++
 head/sys/contrib/dev/acpica/components/events/evgpeblk.c          |   550 ++++
 head/sys/contrib/dev/acpica/components/events/evgpeinit.c         |   462 +++
 head/sys/contrib/dev/acpica/components/events/evgpeutil.c         |   425 +++
 head/sys/contrib/dev/acpica/components/events/evmisc.c            |   377 ++
 head/sys/contrib/dev/acpica/components/events/evregion.c          |  1366 ++++++++++
 head/sys/contrib/dev/acpica/components/events/evrgnini.c          |   732 +++++
 head/sys/contrib/dev/acpica/components/events/evsci.c             |   209 +
 head/sys/contrib/dev/acpica/components/events/evxface.c           |   979 +++++++
 head/sys/contrib/dev/acpica/components/events/evxfevnt.c          |   381 ++
 head/sys/contrib/dev/acpica/components/events/evxfgpe.c           |   903 ++++++
 head/sys/contrib/dev/acpica/components/events/evxfregn.c          |   313 ++
 head/sys/contrib/dev/acpica/components/executer/exconfig.c        |   688 +++++
 head/sys/contrib/dev/acpica/components/executer/exconvrt.c        |   754 +++++
 head/sys/contrib/dev/acpica/components/executer/excreate.c        |   574 ++++
 head/sys/contrib/dev/acpica/components/executer/exdebug.c         |   278 ++
 head/sys/contrib/dev/acpica/components/executer/exdump.c          |  1124 ++++++++
 head/sys/contrib/dev/acpica/components/executer/exfield.c         |   406 ++
 head/sys/contrib/dev/acpica/components/executer/exfldio.c         |  1055 +++++++
 head/sys/contrib/dev/acpica/components/executer/exmisc.c          |   800 +++++
 head/sys/contrib/dev/acpica/components/executer/exmutex.c         |   554 ++++
 head/sys/contrib/dev/acpica/components/executer/exnames.c         |   488 +++
 head/sys/contrib/dev/acpica/components/executer/exoparg1.c        |  1111 ++++++++
 head/sys/contrib/dev/acpica/components/executer/exoparg2.c        |   642 ++++
 head/sys/contrib/dev/acpica/components/executer/exoparg3.c        |   304 ++
 head/sys/contrib/dev/acpica/components/executer/exoparg6.c        |   365 ++
 head/sys/contrib/dev/acpica/components/executer/exprep.c          |   648 ++++
 head/sys/contrib/dev/acpica/components/executer/exregion.c        |   565 ++++
 head/sys/contrib/dev/acpica/components/executer/exresnte.c        |   302 ++
 head/sys/contrib/dev/acpica/components/executer/exresolv.c        |   580 ++++
 head/sys/contrib/dev/acpica/components/executer/exresop.c         |   738 +++++
 head/sys/contrib/dev/acpica/components/executer/exstore.c         |   531 +++
 head/sys/contrib/dev/acpica/components/executer/exstoren.c        |   314 ++
 head/sys/contrib/dev/acpica/components/executer/exstorob.c        |   244 +
 head/sys/contrib/dev/acpica/components/executer/exsystem.c        |   355 ++
 head/sys/contrib/dev/acpica/components/executer/exutils.c         |   532 +++
 head/sys/contrib/dev/acpica/components/hardware/hwacpi.c          |   209 +
 head/sys/contrib/dev/acpica/components/hardware/hwesleep.c        |   263 +
 head/sys/contrib/dev/acpica/components/hardware/hwgpe.c           |   543 +++
 head/sys/contrib/dev/acpica/components/hardware/hwpci.c           |   459 +++
 head/sys/contrib/dev/acpica/components/hardware/hwregs.c          |   741 +++++
 head/sys/contrib/dev/acpica/components/hardware/hwsleep.c         |   398 ++
 head/sys/contrib/dev/acpica/components/hardware/hwtimer.c         |   218 +
 head/sys/contrib/dev/acpica/components/hardware/hwvalid.c         |   368 ++
 head/sys/contrib/dev/acpica/components/hardware/hwxface.c         |   617 ++++
 head/sys/contrib/dev/acpica/components/hardware/hwxfsleep.c       |   474 +++
 head/sys/contrib/dev/acpica/components/namespace/nsaccess.c       |   700 +++++
 head/sys/contrib/dev/acpica/components/namespace/nsalloc.c        |   588 ++++
 head/sys/contrib/dev/acpica/components/namespace/nsdump.c         |   769 +++++
 head/sys/contrib/dev/acpica/components/namespace/nsdumpdv.c       |   161 +
 head/sys/contrib/dev/acpica/components/namespace/nseval.c         |   485 +++
 head/sys/contrib/dev/acpica/components/namespace/nsinit.c         |   665 ++++
 head/sys/contrib/dev/acpica/components/namespace/nsload.c         |   356 ++
 head/sys/contrib/dev/acpica/components/namespace/nsnames.c        |   303 ++
 head/sys/contrib/dev/acpica/components/namespace/nsobject.c       |   505 +++
 head/sys/contrib/dev/acpica/components/namespace/nsparse.c        |   225 +
 head/sys/contrib/dev/acpica/components/namespace/nspredef.c       |  1243 +++++++++
 head/sys/contrib/dev/acpica/components/namespace/nsrepair.c       |   802 +++++
 head/sys/contrib/dev/acpica/components/namespace/nsrepair2.c      |   827 ++++++
 head/sys/contrib/dev/acpica/components/namespace/nssearch.c       |   424 +++
 head/sys/contrib/dev/acpica/components/namespace/nsutils.c        |   875 ++++++
 head/sys/contrib/dev/acpica/components/namespace/nswalk.c         |   386 ++
 head/sys/contrib/dev/acpica/components/namespace/nsxfeval.c       |   960 +++++++
 head/sys/contrib/dev/acpica/components/namespace/nsxfname.c       |   702 +++++
 head/sys/contrib/dev/acpica/components/namespace/nsxfobj.c        |   285 ++
 head/sys/contrib/dev/acpica/components/parser/psargs.c            |   940 ++++++
 head/sys/contrib/dev/acpica/components/parser/psloop.c            |  1268 +++++++++
 head/sys/contrib/dev/acpica/components/parser/psopcode.c          |   522 +++
 head/sys/contrib/dev/acpica/components/parser/psparse.c           |   711 +++++
 head/sys/contrib/dev/acpica/components/parser/psscope.c           |   302 ++
 head/sys/contrib/dev/acpica/components/parser/pstree.c            |   360 ++
 head/sys/contrib/dev/acpica/components/parser/psutils.c           |   290 ++
 head/sys/contrib/dev/acpica/components/parser/pswalk.c            |   121 +
 head/sys/contrib/dev/acpica/components/parser/psxface.c           |   442 +++
 head/sys/contrib/dev/acpica/components/resources/rsaddr.c         |   407 ++
 head/sys/contrib/dev/acpica/components/resources/rscalc.c         |   730 +++++
 head/sys/contrib/dev/acpica/components/resources/rscreate.c       |   534 +++
 head/sys/contrib/dev/acpica/components/resources/rsdump.c         |   946 ++++++
 head/sys/contrib/dev/acpica/components/resources/rsinfo.c         |   265 +
 head/sys/contrib/dev/acpica/components/resources/rsio.c           |   304 ++
 head/sys/contrib/dev/acpica/components/resources/rsirq.c          |   308 ++
 head/sys/contrib/dev/acpica/components/resources/rslist.c         |   275 ++
 head/sys/contrib/dev/acpica/components/resources/rsmemory.c       |   251 +
 head/sys/contrib/dev/acpica/components/resources/rsmisc.c         |   869 ++++++
 head/sys/contrib/dev/acpica/components/resources/rsserial.c       |   425 +++
 head/sys/contrib/dev/acpica/components/resources/rsutils.c        |   861 ++++++
 head/sys/contrib/dev/acpica/components/resources/rsxface.c        |   689 +++++
 head/sys/contrib/dev/acpica/components/tables/tbfadt.c            |   704 +++++
 head/sys/contrib/dev/acpica/components/tables/tbfind.c            |   143 +
 head/sys/contrib/dev/acpica/components/tables/tbinstal.c          |   806 +++++
 head/sys/contrib/dev/acpica/components/tables/tbutils.c           |   775 +++++
 head/sys/contrib/dev/acpica/components/tables/tbxface.c           |   722 +++++
 head/sys/contrib/dev/acpica/components/tables/tbxfroot.c          |   299 ++
 head/sys/contrib/dev/acpica/components/utilities/utaddress.c      |   322 ++
 head/sys/contrib/dev/acpica/components/utilities/utalloc.c        |   416 +++
 head/sys/contrib/dev/acpica/components/utilities/utcache.c        |   361 ++
 head/sys/contrib/dev/acpica/components/utilities/utcopy.c         |  1078 +++++++
 head/sys/contrib/dev/acpica/components/utilities/utdebug.c        |   741 +++++
 head/sys/contrib/dev/acpica/components/utilities/utdecode.c       |   637 ++++
 head/sys/contrib/dev/acpica/components/utilities/utdelete.c       |   766 +++++
 head/sys/contrib/dev/acpica/components/utilities/uteval.c         |   370 ++
 head/sys/contrib/dev/acpica/components/utilities/utglobal.c       |   365 ++
 head/sys/contrib/dev/acpica/components/utilities/utids.c          |   380 ++
 head/sys/contrib/dev/acpica/components/utilities/utinit.c         |   192 +
 head/sys/contrib/dev/acpica/components/utilities/utlock.c         |   205 +
 head/sys/contrib/dev/acpica/components/utilities/utmath.c         |   379 ++
 head/sys/contrib/dev/acpica/components/utilities/utmisc.c         |  1299 +++++++++
 head/sys/contrib/dev/acpica/components/utilities/utmutex.c        |   397 ++
 head/sys/contrib/dev/acpica/components/utilities/utobject.c       |   787 +++++
 head/sys/contrib/dev/acpica/components/utilities/utosi.c          |   422 +++
 head/sys/contrib/dev/acpica/components/utilities/utresrc.c        |   923 ++++++
 head/sys/contrib/dev/acpica/components/utilities/utstate.c        |   398 ++
 head/sys/contrib/dev/acpica/components/utilities/uttrack.c        |   711 +++++
 head/sys/contrib/dev/acpica/components/utilities/utxface.c        |   837 ++++++
 head/sys/contrib/dev/acpica/components/utilities/utxferror.c      |   483 +++
 head/sys/contrib/dev/acpica/components/utilities/utxfmutex.c      |   213 +
 head/sys/contrib/dev/acpica/debugger/dbcmds.c                     |  1061 -------
 head/sys/contrib/dev/acpica/debugger/dbdisply.c                   |  1051 -------
 head/sys/contrib/dev/acpica/debugger/dbexec.c                     |  1105 --------
 head/sys/contrib/dev/acpica/debugger/dbfileio.c                   |   578 ----
 head/sys/contrib/dev/acpica/debugger/dbhistry.c                   |   220 -
 head/sys/contrib/dev/acpica/debugger/dbinput.c                    |  1088 -------
 head/sys/contrib/dev/acpica/debugger/dbmethod.c                   |   529 ---
 head/sys/contrib/dev/acpica/debugger/dbnames.c                    |   934 ------
 head/sys/contrib/dev/acpica/debugger/dbstats.c                    |   549 ----
 head/sys/contrib/dev/acpica/debugger/dbutils.c                    |   526 ---
 head/sys/contrib/dev/acpica/debugger/dbxface.c                    |   542 ---
 head/sys/contrib/dev/acpica/disassembler/dmbuffer.c               |   542 ---
 head/sys/contrib/dev/acpica/disassembler/dmnames.c                |   453 ---
 head/sys/contrib/dev/acpica/disassembler/dmobject.c               |   589 ----
 head/sys/contrib/dev/acpica/disassembler/dmopcode.c               |   607 ----
 head/sys/contrib/dev/acpica/disassembler/dmresrc.c                |   434 ---
 head/sys/contrib/dev/acpica/disassembler/dmresrcl.c               |  1052 -------
 head/sys/contrib/dev/acpica/disassembler/dmresrcl2.c              |   700 -----
 head/sys/contrib/dev/acpica/disassembler/dmresrcs.c               |   358 --
 head/sys/contrib/dev/acpica/disassembler/dmutils.c                |   321 --
 head/sys/contrib/dev/acpica/disassembler/dmwalk.c                 |   935 ------
 head/sys/contrib/dev/acpica/dispatcher/dsargs.c                   |   438 ---
 head/sys/contrib/dev/acpica/dispatcher/dscontrol.c                |   424 ---
 head/sys/contrib/dev/acpica/dispatcher/dsfield.c                  |   748 -----
 head/sys/contrib/dev/acpica/dispatcher/dsinit.c                   |   238 -
 head/sys/contrib/dev/acpica/dispatcher/dsmethod.c                 |   726 -----
 head/sys/contrib/dev/acpica/dispatcher/dsmthdat.c                 |   772 -----
 head/sys/contrib/dev/acpica/dispatcher/dsobject.c                 |   867 ------
 head/sys/contrib/dev/acpica/dispatcher/dsopcode.c                 |   809 -----
 head/sys/contrib/dev/acpica/dispatcher/dsutils.c                  |   937 ------
 head/sys/contrib/dev/acpica/dispatcher/dswexec.c                  |   797 -----
 head/sys/contrib/dev/acpica/dispatcher/dswload.c                  |   551 ----
 head/sys/contrib/dev/acpica/dispatcher/dswload2.c                 |   747 -----
 head/sys/contrib/dev/acpica/dispatcher/dswscope.c                 |   239 -
 head/sys/contrib/dev/acpica/dispatcher/dswstate.c                 |   846 ------
 head/sys/contrib/dev/acpica/events/evevent.c                      |   332 --
 head/sys/contrib/dev/acpica/events/evglock.c                      |   374 --
 head/sys/contrib/dev/acpica/events/evgpe.c                        |   828 ------
 head/sys/contrib/dev/acpica/events/evgpeblk.c                     |   547 ----
 head/sys/contrib/dev/acpica/events/evgpeinit.c                    |   459 ---
 head/sys/contrib/dev/acpica/events/evgpeutil.c                    |   424 ---
 head/sys/contrib/dev/acpica/events/evmisc.c                       |   372 --
 head/sys/contrib/dev/acpica/events/evregion.c                     |  1366 ----------
 head/sys/contrib/dev/acpica/events/evrgnini.c                     |   732 -----
 head/sys/contrib/dev/acpica/events/evsci.c                        |   207 -
 head/sys/contrib/dev/acpica/events/evxface.c                      |   977 -------
 head/sys/contrib/dev/acpica/events/evxfevnt.c                     |   380 --
 head/sys/contrib/dev/acpica/events/evxfgpe.c                      |   900 ------
 head/sys/contrib/dev/acpica/events/evxfregn.c                     |   313 --
 head/sys/contrib/dev/acpica/executer/exconfig.c                   |   688 -----
 head/sys/contrib/dev/acpica/executer/exconvrt.c                   |   754 -----
 head/sys/contrib/dev/acpica/executer/excreate.c                   |   574 ----
 head/sys/contrib/dev/acpica/executer/exdebug.c                    |   278 --
 head/sys/contrib/dev/acpica/executer/exdump.c                     |  1124 --------
 head/sys/contrib/dev/acpica/executer/exfield.c                    |   406 --
 head/sys/contrib/dev/acpica/executer/exfldio.c                    |  1057 -------
 head/sys/contrib/dev/acpica/executer/exmisc.c                     |   800 -----
 head/sys/contrib/dev/acpica/executer/exmutex.c                    |   554 ----
 head/sys/contrib/dev/acpica/executer/exnames.c                    |   488 ---
 head/sys/contrib/dev/acpica/executer/exoparg1.c                   |  1111 --------
 head/sys/contrib/dev/acpica/executer/exoparg2.c                   |   642 ----
 head/sys/contrib/dev/acpica/executer/exoparg3.c                   |   304 --
 head/sys/contrib/dev/acpica/executer/exoparg6.c                   |   365 --
 head/sys/contrib/dev/acpica/executer/exprep.c                     |   648 ----
 head/sys/contrib/dev/acpica/executer/exregion.c                   |   565 ----
 head/sys/contrib/dev/acpica/executer/exresnte.c                   |   302 --
 head/sys/contrib/dev/acpica/executer/exresolv.c                   |   580 ----
 head/sys/contrib/dev/acpica/executer/exresop.c                    |   738 -----
 head/sys/contrib/dev/acpica/executer/exstore.c                    |   531 ---
 head/sys/contrib/dev/acpica/executer/exstoren.c                   |   314 --
 head/sys/contrib/dev/acpica/executer/exstorob.c                   |   244 -
 head/sys/contrib/dev/acpica/executer/exsystem.c                   |   355 --
 head/sys/contrib/dev/acpica/executer/exutils.c                    |   532 ---
 head/sys/contrib/dev/acpica/hardware/hwacpi.c                     |   206 -
 head/sys/contrib/dev/acpica/hardware/hwgpe.c                      |   540 ---
 head/sys/contrib/dev/acpica/hardware/hwpci.c                      |   459 ---
 head/sys/contrib/dev/acpica/hardware/hwregs.c                     |   733 -----
 head/sys/contrib/dev/acpica/hardware/hwsleep.c                    |   653 ----
 head/sys/contrib/dev/acpica/hardware/hwtimer.c                    |   216 -
 head/sys/contrib/dev/acpica/hardware/hwvalid.c                    |   368 --
 head/sys/contrib/dev/acpica/hardware/hwxface.c                    |   638 ----
 head/sys/contrib/dev/acpica/include/acconfig.h                    |    19 +-
 head/sys/contrib/dev/acpica/include/acdebug.h                     |     6 +-
 head/sys/contrib/dev/acpica/include/acevents.h                    |    16 +-
 head/sys/contrib/dev/acpica/include/acexcep.h                     |     6 +-
 head/sys/contrib/dev/acpica/include/acglobal.h                    |    10 +-
 head/sys/contrib/dev/acpica/include/achware.h                     |    55 +-
 head/sys/contrib/dev/acpica/include/acmacros.h                    |     9 +-
 head/sys/contrib/dev/acpica/include/acpiosxf.h                    |    10 +-
 head/sys/contrib/dev/acpica/include/acpixf.h                      |   160 +-
 head/sys/contrib/dev/acpica/include/actables.h                    |     5 +
 head/sys/contrib/dev/acpica/include/actbl.h                       |     7 +
 head/sys/contrib/dev/acpica/include/actypes.h                     |    19 +-
 head/sys/contrib/dev/acpica/namespace/nsaccess.c                  |   700 -----
 head/sys/contrib/dev/acpica/namespace/nsalloc.c                   |   588 ----
 head/sys/contrib/dev/acpica/namespace/nsdump.c                    |   769 -----
 head/sys/contrib/dev/acpica/namespace/nsdumpdv.c                  |   161 -
 head/sys/contrib/dev/acpica/namespace/nseval.c                    |   485 ---
 head/sys/contrib/dev/acpica/namespace/nsinit.c                    |   665 ----
 head/sys/contrib/dev/acpica/namespace/nsload.c                    |   356 --
 head/sys/contrib/dev/acpica/namespace/nsnames.c                   |   303 --
 head/sys/contrib/dev/acpica/namespace/nsobject.c                  |   505 ---
 head/sys/contrib/dev/acpica/namespace/nsparse.c                   |   225 -
 head/sys/contrib/dev/acpica/namespace/nspredef.c                  |  1243 ---------
 head/sys/contrib/dev/acpica/namespace/nsrepair.c                  |   802 -----
 head/sys/contrib/dev/acpica/namespace/nsrepair2.c                 |   827 ------
 head/sys/contrib/dev/acpica/namespace/nssearch.c                  |   424 ---
 head/sys/contrib/dev/acpica/namespace/nsutils.c                   |   875 ------
 head/sys/contrib/dev/acpica/namespace/nswalk.c                    |   386 --
 head/sys/contrib/dev/acpica/namespace/nsxfeval.c                  |   960 -------
 head/sys/contrib/dev/acpica/namespace/nsxfname.c                  |   702 -----
 head/sys/contrib/dev/acpica/namespace/nsxfobj.c                   |   285 --
 head/sys/contrib/dev/acpica/os_specific/service_layers/osunixxf.c |    39 +-
 head/sys/contrib/dev/acpica/parser/psargs.c                       |   940 ------
 head/sys/contrib/dev/acpica/parser/psloop.c                       |  1268 ---------
 head/sys/contrib/dev/acpica/parser/psopcode.c                     |   522 ---
 head/sys/contrib/dev/acpica/parser/psparse.c                      |   711 -----
 head/sys/contrib/dev/acpica/parser/psscope.c                      |   302 --
 head/sys/contrib/dev/acpica/parser/pstree.c                       |   360 --
 head/sys/contrib/dev/acpica/parser/psutils.c                      |   290 --
 head/sys/contrib/dev/acpica/parser/pswalk.c                       |   121 -
 head/sys/contrib/dev/acpica/parser/psxface.c                      |   442 ---
 head/sys/contrib/dev/acpica/resources/rsaddr.c                    |   407 --
 head/sys/contrib/dev/acpica/resources/rscalc.c                    |   730 -----
 head/sys/contrib/dev/acpica/resources/rscreate.c                  |   534 ---
 head/sys/contrib/dev/acpica/resources/rsdump.c                    |   946 ------
 head/sys/contrib/dev/acpica/resources/rsinfo.c                    |   265 -
 head/sys/contrib/dev/acpica/resources/rsio.c                      |   304 --
 head/sys/contrib/dev/acpica/resources/rsirq.c                     |   308 --
 head/sys/contrib/dev/acpica/resources/rslist.c                    |   275 --
 head/sys/contrib/dev/acpica/resources/rsmemory.c                  |   251 -
 head/sys/contrib/dev/acpica/resources/rsmisc.c                    |   869 ------
 head/sys/contrib/dev/acpica/resources/rsserial.c                  |   425 ---
 head/sys/contrib/dev/acpica/resources/rsutils.c                   |   861 ------
 head/sys/contrib/dev/acpica/resources/rsxface.c                   |   689 -----
 head/sys/contrib/dev/acpica/tables/tbfadt.c                       |   704 -----
 head/sys/contrib/dev/acpica/tables/tbfind.c                       |   143 -
 head/sys/contrib/dev/acpica/tables/tbinstal.c                     |   731 -----
 head/sys/contrib/dev/acpica/tables/tbutils.c                      |   775 -----
 head/sys/contrib/dev/acpica/tables/tbxface.c                      |   722 -----
 head/sys/contrib/dev/acpica/tables/tbxfroot.c                     |   299 --
 head/sys/contrib/dev/acpica/utilities/utaddress.c                 |   322 --
 head/sys/contrib/dev/acpica/utilities/utalloc.c                   |   416 ---
 head/sys/contrib/dev/acpica/utilities/utcache.c                   |   361 --
 head/sys/contrib/dev/acpica/utilities/utcopy.c                    |  1078 -------
 head/sys/contrib/dev/acpica/utilities/utdebug.c                   |   741 -----
 head/sys/contrib/dev/acpica/utilities/utdecode.c                  |   632 ----
 head/sys/contrib/dev/acpica/utilities/utdelete.c                  |   766 -----
 head/sys/contrib/dev/acpica/utilities/uteval.c                    |   370 --
 head/sys/contrib/dev/acpica/utilities/utglobal.c                  |   358 --
 head/sys/contrib/dev/acpica/utilities/utids.c                     |   380 --
 head/sys/contrib/dev/acpica/utilities/utinit.c                    |   161 -
 head/sys/contrib/dev/acpica/utilities/utlock.c                    |   205 -
 head/sys/contrib/dev/acpica/utilities/utmath.c                    |   379 --
 head/sys/contrib/dev/acpica/utilities/utmisc.c                    |  1299 ---------
 head/sys/contrib/dev/acpica/utilities/utmutex.c                   |   397 --
 head/sys/contrib/dev/acpica/utilities/utobject.c                  |   787 -----
 head/sys/contrib/dev/acpica/utilities/utosi.c                     |   422 ---
 head/sys/contrib/dev/acpica/utilities/utresrc.c                   |   923 ------
 head/sys/contrib/dev/acpica/utilities/utstate.c                   |   398 --
 head/sys/contrib/dev/acpica/utilities/uttrack.c                   |   711 -----
 head/sys/contrib/dev/acpica/utilities/utxface.c                   |   832 ------
 head/sys/contrib/dev/acpica/utilities/utxferror.c                 |   483 ---
 head/sys/contrib/dev/acpica/utilities/utxfmutex.c                 |   213 -
 321 files changed, 89441 insertions(+), 88480 deletions(-)

diffs (179739 lines):

diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/acpica_prep.sh
--- a/head/sys/contrib/dev/acpica/acpica_prep.sh	Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/acpica_prep.sh	Fri Mar 02 17:09:07 2012 +0200
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $FreeBSD: head/sys/contrib/dev/acpica/acpica_prep.sh 228110 2011-11-28 23:36:48Z jkim $
+# $FreeBSD: head/sys/contrib/dev/acpica/acpica_prep.sh 231844 2012-02-16 22:59:29Z jkim $
 #
 # Unpack an ACPI CA drop and restructure it to fit the FreeBSD layout
 #
@@ -14,12 +14,10 @@
 dst=`realpath ./acpi_ca_destination`
 
 # files that should keep their full directory path
-fulldirs="common compiler debugger disassembler dispatcher events	\
-	executer hardware include namespace os_specific parser		\
-	resources tables utilities"
+fulldirs="common compiler components include os_specific"
 
 # files to remove
-stripdirs="generate tests tools"
+stripdirs="generate libraries tests tools"
 stripfiles="Makefile README acintel.h aclinux.h acmsvc.h acnetbsd.h	\
 	acos2.h accygwin.h acefi.h acwin.h acwin64.h osunixdir.c	\
 	oswindir.c oswintbl.c oswinxf.c readme.txt utclib.c"
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/changes.txt
--- a/head/sys/contrib/dev/acpica/changes.txt	Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/changes.txt	Fri Mar 02 17:09:07 2012 +0200
@@ -1,3 +1,95 @@
+----------------------------------------
+15 February 2012. Summary of changes for version 20120215:
+
+This release is available at www.acpica.org/downloads.
+The ACPI 5.0 specification is available at www.acpi.info.
+
+1) ACPICA Core Subsystem:
+
+There have been some major changes to the sleep/wake support code, as 
+described below (a - e).
+
+a) The AcpiLeaveSleepState has been split into two interfaces, similar to 
+AcpiEnterSleepStatePrep and AcpiEnterSleepState. The new interface is 
+AcpiLeaveSleepStatePrep. This allows the host to perform actions between the 
+time the _BFS method is called and the _WAK method is called. NOTE: all hosts 
+must update their wake/resume code or else sleep/wake will not work properly. 
+Rafael Wysocki.
+
+b) In AcpiLeaveSleepState, now enable all runtime GPEs before calling the _WAK 
+method. Some machines require that the GPEs are enabled before the _WAK method 
+is executed. Thomas Renninger.
+
+c) In AcpiLeaveSleepState, now always clear the WAK_STS (wake status) bit. 
+Some BIOS code assumes that WAK_STS will be cleared on resume and use it to 
+determine whether the system is rebooting or resuming. Matthew Garrett.
+
+d) Move the invocations of _GTS (Going To Sleep) and _BFS (Back From Sleep) to 
+match the ACPI specification requirement. Rafael Wysocki.
+
+e) Implemented full support for the ACPI 5.0 SleepStatus and SleepControl 
+registers within the V5 FADT. This support adds two new files: 
+hardware/hwesleep.c implements the support for the new registers. Moved all 
+sleep/wake external interfaces to hardware/hwxfsleep.c.
+
+
+Added a new OSL interface for ACPI table overrides, 
+AcpiOsPhysicalTableOverride. This interface allows the host to override a 
+table via a physical address, instead of the logical address required by 
+AcpiOsTableOverride. This simplifies the host implementation. Initial 
+implementation by Thomas Renninger. The ACPICA implementation creates a single 
+shared function for table overrides that attempts both a logical and a 
+physical override.
+
+Expanded the OSL memory read/write interfaces to 64-bit data 
+(AcpiOsReadMemory, AcpiOsWriteMemory.) This enables full 64-bit memory 
+transfer support for GAS register structures passed to AcpiRead and AcpiWrite.
+
+Implemented the ACPI_REDUCED_HARDWARE option to allow the creation of a custom 
+build of ACPICA that supports only the ACPI 5.0 reduced hardware (SoC) model. 
+See the ACPICA reference for details. ACPICA BZ 942. This option removes about 
+10% of the code and 5% of the static data, and the following hardware ACPI 
+features become unavailable:
+    PM Event and Control registers
+    SCI interrupt (and handler)
+    Fixed Events
+    General Purpose Events (GPEs)
+    Global Lock
+    ACPI PM timer
+    FACS table (Waking vectors and Global Lock)
+
+Updated the unix tarball directory structure to match the ACPICA git source 
+tree. This ensures that the generic unix makefiles work properly (in 
+generate/unix).  Also updated the Linux makefiles to match. ACPICA BZ 867.
+
+Updated the return value of the _REV predefined method to integer value 5 to 
+reflect ACPI 5.0 support.
+
+Moved the external ACPI PM timer interface prototypes to the public acpixf.h 
+file where they belong.
+
+Example Code and Data Size: These are the sizes for the OS-independent 
+acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The debug 
+version of the code includes the debug output trace mechanism and has a much 
+larger code and data size.
+
+  Previous Release:
+    Non-Debug Version:  92.8K Code, 24.9K Data, 117.7K Total
+    Debug Version:     171.7K Code, 72.9K Data, 244.5K Total
+  Current Release:
+    Non-Debug Version:  93.0K Code, 25.0K Data, 118.0K Total
+    Debug Version:     172.5K Code, 73.2K Data, 245.7K Total
+
+
+2) iASL Compiler/Disassembler and Tools:
+
+Disassembler: Fixed a problem with the new ACPI 5.0 serial resource 
+descriptors (I2C, SPI, UART) where the resource produce/consumer bit was 
+incorrectly displayed.
+
+AcpiHelp: Add display of ACPI/PNP device IDs that are defined in the ACPI 
+specification.
+
 ----------------------------------------
 11 January 2012. Summary of changes for version 20120111:
 
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/compiler/aslrestype2s.c
--- a/head/sys/contrib/dev/acpica/compiler/aslrestype2s.c	Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/compiler/aslrestype2s.c	Fri Mar 02 17:09:07 2012 +0200
@@ -192,7 +192,7 @@
     UINT16                  ActualLength = 0;
 
 
-    /* VendorData field is always optional */
+    /* Vendor Data field is always optional */
 
     if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
     {
@@ -374,7 +374,7 @@
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.PinConfig));
             break;
 
-        case 4: /* DebounceTimeout [WORD] (_DBT) */
+        case 4: /* Debounce Timeout [WORD] (_DBT) */
 
             Descriptor->Gpio.DebounceTimeout = (UINT16) InitializerOp->Asl.Value.Integer;
             RsCreateWordField (InitializerOp, ACPI_RESTAG_DEBOUNCETIME,
@@ -405,7 +405,7 @@
             RsSetFlagBits16 (&Descriptor->Gpio.Flags, InitializerOp, 0, 1);
             break;
 
-        case 8: /* ResourceTag (Descriptor Name) */
+        case 8: /* Resource Tag (Descriptor Name) */
 
             UtAttachNamepathToOwner (Op, InitializerOp);
             break;
@@ -566,7 +566,7 @@
                 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.PinConfig));
             break;
 
-        case 2: /* DebounceTimeout [WORD] (_DBT) */
+        case 2: /* Debounce Timeout [WORD] (_DBT) */
 
             Descriptor->Gpio.DebounceTimeout = (UINT16) InitializerOp->Asl.Value.Integer;
             RsCreateWordField (InitializerOp, ACPI_RESTAG_DEBOUNCETIME,
@@ -611,7 +611,7 @@
             RsSetFlagBits16 (&Descriptor->Gpio.Flags, InitializerOp, 0, 1);
             break;
 
-        case 8: /* ResourceTag (Descriptor Name) */
+        case 8: /* Resource Tag (Descriptor Name) */
 
             UtAttachNamepathToOwner (Op, InitializerOp);
             break;
@@ -762,14 +762,14 @@
                 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.Flags), 0);
             break;
 
-        case 2: /* ConnectionSpeed [DWORD] (_SPE) */
+        case 2: /* Connection Speed [DWORD] (_SPE) */
 
             Descriptor->I2cSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
                 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.ConnectionSpeed));
             break;
 
-        case 3: /* Addresssing Mode [Flag] (_MOD) */
+        case 3: /* Addressing Mode [Flag] (_MOD) */
 
             RsSetFlagBits16 (&Descriptor->I2cSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
             RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
@@ -800,7 +800,7 @@
             RsSetFlagBits (&Descriptor->I2cSerialBus.Flags, InitializerOp, 1, 1);
             break;
 
-        case 7: /* ResourceTag (Descriptor Name) */
+        case 7: /* Resource Tag (Descriptor Name) */
 
             UtAttachNamepathToOwner (Op, InitializerOp);
             break;
@@ -929,7 +929,7 @@
                 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.Flags), 0);
             break;
 
-        case 5: /* ConnectionSpeed [DWORD] (_SPE) */
+        case 5: /* Connection Speed [DWORD] (_SPE) */
 
             Descriptor->SpiSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
@@ -974,7 +974,7 @@
             RsSetFlagBits (&Descriptor->SpiSerialBus.Flags, InitializerOp, 1, 1);
             break;
 
-        case 11: /* ResourceTag (Descriptor Name) */
+        case 11: /* Resource Tag (Descriptor Name) */
 
             UtAttachNamepathToOwner (Op, InitializerOp);
             break;
@@ -1068,7 +1068,7 @@
     {
         switch (i)
         {
-        case 0: /* ConnectionSpeed (Baud Rate) [DWORD] (_SPE) */
+        case 0: /* Connection Speed (Baud Rate) [DWORD] (_SPE) */
 
             Descriptor->UartSerialBus.DefaultBaudRate = (UINT32) InitializerOp->Asl.Value.Integer;
             RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
@@ -1165,7 +1165,7 @@
                 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.Flags), 0);
             break;
 
-        case 12: /* ResourceTag (Descriptor Name) */
+        case 12: /* Resource Tag (Descriptor Name) */
 
             UtAttachNamepathToOwner (Op, InitializerOp);
             break;
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/compiler/aslstubs.c
--- a/head/sys/contrib/dev/acpica/compiler/aslstubs.c	Fri Mar 02 17:08:15 2012 +0200
+++ b/head/sys/contrib/dev/acpica/compiler/aslstubs.c	Fri Mar 02 17:09:07 2012 +0200
@@ -128,13 +128,6 @@
 }
 
 ACPI_STATUS
-AcpiEvDeleteGpeBlock (
-    ACPI_GPE_BLOCK_INFO     *GpeBlock)
-{
-    return (AE_OK);
-}
-
-ACPI_STATUS
 AcpiEvQueueNotifyRequest (
     ACPI_NAMESPACE_NODE     *Node,
     UINT32                  NotifyValue)
@@ -149,6 +142,14 @@
     return (FALSE);
 }
 
+#if (!ACPI_REDUCED_HARDWARE)
+ACPI_STATUS
+AcpiEvDeleteGpeBlock (
+    ACPI_GPE_BLOCK_INFO     *GpeBlock)
+{
+    return (AE_OK);
+}
+
 ACPI_STATUS
 AcpiEvAcquireGlobalLock (
     UINT16                  Timeout)
@@ -162,6 +163,7 @@
 {
     return (AE_OK);
 }
+#endif /* !ACPI_REDUCED_HARDWARE */
 
 ACPI_STATUS
 AcpiEvInitializeRegion (
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/debugger/dbcmds.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/debugger/dbcmds.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,1084 @@
+/*******************************************************************************
+ *
+ * Module Name: dbcmds - Miscellaneous debug commands and output routines
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acevents.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acresrc.h>
+#include <contrib/dev/acpica/include/actables.h>
+
+#ifdef ACPI_DEBUGGER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dbcmds")
+
+
+/* Local prototypes */
+
+static void
+AcpiDmCompareAmlResources (
+    UINT8                   *Aml1Buffer,
+    ACPI_RSDESC_SIZE        Aml1BufferLength,
+    UINT8                   *Aml2Buffer,
+    ACPI_RSDESC_SIZE        Aml2BufferLength);
+
+static ACPI_STATUS
+AcpiDmTestResourceConversion (
+    ACPI_NAMESPACE_NODE     *Node,
+    char                    *Name);
+
+static ACPI_STATUS
+AcpiDbResourceCallback (
+    ACPI_RESOURCE           *Resource,
+    void                    *Context);
+
+static ACPI_STATUS
+AcpiDbDeviceResources (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbConvertToNode
+ *
+ * PARAMETERS:  InString        - String to convert
+ *
+ * RETURN:      Pointer to a NS node
+ *
+ * DESCRIPTION: Convert a string to a valid NS pointer.  Handles numeric or
+ *              alpha strings.
+ *
+ ******************************************************************************/
+
+ACPI_NAMESPACE_NODE *
+AcpiDbConvertToNode (
+    char                    *InString)
+{
+    ACPI_NAMESPACE_NODE     *Node;
+
+
+    if ((*InString >= 0x30) && (*InString <= 0x39))
+    {
+        /* Numeric argument, convert */
+
+        Node = ACPI_TO_POINTER (ACPI_STRTOUL (InString, NULL, 16));
+        if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
+        {
+            AcpiOsPrintf ("Address %p is invalid in this address space\n",
+                Node);
+            return (NULL);
+        }
+
+        /* Make sure pointer is valid NS node */
+
+        if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
+        {
+            AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n",
+                    Node, AcpiUtGetDescriptorName (Node));
+            return (NULL);
+        }
+    }
+    else
+    {
+        /* Alpha argument */
+        /* The parameter is a name string that must be resolved to a
+         * Named obj
+         */
+        Node = AcpiDbLocalNsLookup (InString);
+        if (!Node)
+        {
+            Node = AcpiGbl_RootNode;
+        }
+    }
+
+    return (Node);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbSleep
+ *
+ * PARAMETERS:  ObjectArg       - Desired sleep state (0-5)
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Simulate a sleep/wake sequence
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbSleep (
+    char                    *ObjectArg)
+{
+    ACPI_STATUS             Status;
+    UINT8                   SleepState;
+
+
+    ACPI_FUNCTION_TRACE (AcpiDbSleep);
+
+
+    SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
+
+    AcpiOsPrintf ("**** Prepare to sleep ****\n");
+    Status = AcpiEnterSleepStatePrep (SleepState);
+    if (ACPI_FAILURE (Status))
+    {
+        goto ErrorExit;
+    }
+
+    AcpiOsPrintf ("**** Going to sleep ****\n");
+    Status = AcpiEnterSleepState (SleepState);
+    if (ACPI_FAILURE (Status))
+    {
+        goto ErrorExit;
+    }
+
+    AcpiOsPrintf ("**** Prepare to return from sleep ****\n");
+    Status = AcpiLeaveSleepStatePrep (SleepState);
+    if (ACPI_FAILURE (Status))
+    {
+        goto ErrorExit;
+    }
+
+    AcpiOsPrintf ("**** Returning from sleep ****\n");
+    Status = AcpiLeaveSleepState (SleepState);
+    if (ACPI_FAILURE (Status))
+    {
+        goto ErrorExit;
+    }
+
+    return (Status);
+
+
+ErrorExit:
+
+    ACPI_EXCEPTION ((AE_INFO, Status, "During sleep test"));
+    return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbDisplayLocks
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display information about internal mutexes.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayLocks (
+    void)
+{
+    UINT32                  i;
+
+
+    for (i = 0; i < ACPI_MAX_MUTEX; i++)
+    {
+        AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
+            AcpiGbl_MutexInfo[i].ThreadId == 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;
+    ACPI_TABLE_DESC         *TableDesc;
+    ACPI_STATUS             Status;
+
+
+    /* Walk the entire root table list */
+
+    for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
+    {
+        TableDesc = &AcpiGbl_RootTableList.Tables[i];
+        AcpiOsPrintf ("%u ", i);
+
+        /* Make sure that the table is mapped */
+
+        Status = AcpiTbVerifyTable (TableDesc);
+        if (ACPI_FAILURE (Status))
+        {
+            return;
+        }
+
+        /* Dump the table header */
+
+        if (TableDesc->Pointer)
+        {
+            AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
+        }
+        else
+        {
+            /* If the pointer is null, the table has been unloaded */
+
+            ACPI_INFO ((AE_INFO, "%4.4s - Table has been unloaded",
+                TableDesc->Signature.Ascii));
+        }
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * 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)
+{
+/* TBD: Need to reimplement for new data structures */
+
+#if 0
+    UINT32                  i;
+    ACPI_STATUS             Status;
+
+
+    /* Search all tables for the target type */
+
+    for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++)
+    {
+        if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature,
+                AcpiGbl_TableData[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);
+#endif
+}
+
+
+/*******************************************************************************
+ *
+ * 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 = AcpiDbConvertToNode (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:    AcpiDbDisplayInterfaces
+ *
+ * PARAMETERS:  ActionArg           - Null, "install", or "remove"
+ *              InterfaceNameArg    - Name for install/remove options
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display or modify the global _OSI interface list
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayInterfaces (
+    char                    *ActionArg,
+    char                    *InterfaceNameArg)
+{
+    ACPI_INTERFACE_INFO     *NextInterface;
+    char                    *SubString;
+    ACPI_STATUS             Status;
+
+
+    /* If no arguments, just display current interface list */
+
+    if (!ActionArg)
+    {
+        (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex,
+                    ACPI_WAIT_FOREVER);
+
+        NextInterface = AcpiGbl_SupportedInterfaces;
+
+        while (NextInterface)
+        {
+            if (!(NextInterface->Flags & ACPI_OSI_INVALID))
+            {
+                AcpiOsPrintf ("%s\n", NextInterface->Name);
+            }
+            NextInterface = NextInterface->Next;
+        }
+
+        AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
+        return;
+    }
+
+    /* If ActionArg exists, so must InterfaceNameArg */
+
+    if (!InterfaceNameArg)
+    {
+        AcpiOsPrintf ("Missing Interface Name argument\n");
+        return;
+    }
+
+    /* Uppercase the action for match below */
+
+    AcpiUtStrupr (ActionArg);
+
+    /* Install - install an interface */
+
+    SubString = ACPI_STRSTR ("INSTALL", ActionArg);
+    if (SubString)
+    {
+        Status = AcpiInstallInterface (InterfaceNameArg);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("%s, while installing \"%s\"\n",
+                AcpiFormatException (Status), InterfaceNameArg);
+        }
+        return;
+    }
+
+    /* Remove - remove an interface */
+
+    SubString = ACPI_STRSTR ("REMOVE", ActionArg);
+    if (SubString)
+    {
+        Status = AcpiRemoveInterface (InterfaceNameArg);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("%s, while removing \"%s\"\n",
+                AcpiFormatException (Status), InterfaceNameArg);
+        }
+        return;
+    }
+
+    /* Invalid ActionArg */
+
+    AcpiOsPrintf ("Invalid action argument: %s\n", ActionArg);
+    return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbDisplayTemplate
+ *
+ * PARAMETERS:  BufferArg           - Buffer name or addrss
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Dump a buffer that contains a resource template
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayTemplate (
+    char                    *BufferArg)
+{
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_STATUS             Status;
+    ACPI_BUFFER             ReturnObj;
+
+
+    /* Translate BufferArg to an Named object */
+
+    Node = AcpiDbConvertToNode (BufferArg);
+    if (!Node || (Node == AcpiGbl_RootNode))
+    {
+        AcpiOsPrintf ("Invalid argument: %s\n", BufferArg);
+        return;
+    }
+
+    /* We must have a buffer object */
+
+    if (Node->Type != ACPI_TYPE_BUFFER)
+    {
+        AcpiOsPrintf ("Not a Buffer object, cannot be a template: %s\n",
+            BufferArg);
+        return;
+    }
+
+    ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
+    ReturnObj.Pointer = AcpiGbl_DbBuffer;
+
+    /* Attempt to convert the raw buffer to a resource list */
+
+    Status = AcpiRsCreateResourceList (Node->Object, &ReturnObj);
+
+    AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
+    AcpiDbgLevel |= ACPI_LV_RESOURCES;
+
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiOsPrintf ("Could not convert Buffer to a resource list: %s, %s\n",
+            BufferArg, AcpiFormatException (Status));
+        goto DumpBuffer;
+    }
+
+    /* Now we can dump the resource list */
+
+    AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
+        ReturnObj.Pointer));
+
+DumpBuffer:
+    AcpiOsPrintf ("\nRaw data buffer:\n");
+    AcpiUtDumpBuffer ((UINT8 *) Node->Object->Buffer.Pointer,
+        Node->Object->Buffer.Length,
+        DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
+
+    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+    return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmCompareAmlResources
+ *
+ * PARAMETERS:  Aml1Buffer          - Contains first resource list
+ *              Aml1BufferLength    - Length of first resource list
+ *              Aml2Buffer          - Contains second resource list
+ *              Aml2BufferLength    - Length of second resource list
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
+ *              order to isolate a miscompare to an individual resource)
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmCompareAmlResources (
+    UINT8                   *Aml1Buffer,
+    ACPI_RSDESC_SIZE        Aml1BufferLength,
+    UINT8                   *Aml2Buffer,
+    ACPI_RSDESC_SIZE        Aml2BufferLength)
+{
+    UINT8                   *Aml1;
+    UINT8                   *Aml2;
+    UINT8                   *Aml1End;
+    UINT8                   *Aml2End;
+    ACPI_RSDESC_SIZE        Aml1Length;
+    ACPI_RSDESC_SIZE        Aml2Length;
+    ACPI_RSDESC_SIZE        Offset = 0;
+    UINT8                   ResourceType;
+    UINT32                  Count = 0;
+    UINT32                  i;
+
+
+    /* Compare overall buffer sizes (may be different due to size rounding) */
+
+    if (Aml1BufferLength != Aml2BufferLength)
+    {
+        AcpiOsPrintf (
+            "**** Buffer length mismatch in converted AML: Original %X, New %X ****\n",
+            Aml1BufferLength, Aml2BufferLength);
+    }
+
+    Aml1 = Aml1Buffer;
+    Aml2 = Aml2Buffer;
+    Aml1End = Aml1Buffer + Aml1BufferLength;
+    Aml2End = Aml2Buffer + Aml2BufferLength;
+
+    /* Walk the descriptor lists, comparing each descriptor */
+
+    while ((Aml1 < Aml1End) && (Aml2 < Aml2End))
+    {
+        /* Get the lengths of each descriptor */
+
+        Aml1Length = AcpiUtGetDescriptorLength (Aml1);
+        Aml2Length = AcpiUtGetDescriptorLength (Aml2);
+        ResourceType = AcpiUtGetResourceType (Aml1);
+
+        /* Check for descriptor length match */
+
+        if (Aml1Length != Aml2Length)
+        {
+            AcpiOsPrintf (
+                "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X Len1 %X, Len2 %X ****\n",
+                Count, ResourceType, Offset, Aml1Length, Aml2Length);
+        }
+
+        /* Check for descriptor byte match */
+
+        else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length))
+        {
+            AcpiOsPrintf (
+                "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n",
+                Count, ResourceType, Offset);
+
+            for (i = 0; i < Aml1Length; i++)
+            {
+                if (Aml1[i] != Aml2[i])
+                {
+                    AcpiOsPrintf ("Mismatch at byte offset %.2X: is %2.2X, should be %2.2X\n",
+                        i, Aml2[i], Aml1[i]);
+                }
+            }
+        }
+
+        /* Exit on EndTag descriptor */
+
+        if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
+        {
+            return;
+        }
+
+        /* Point to next descriptor in each buffer */
+
+        Count++;
+        Offset += Aml1Length;
+        Aml1 += Aml1Length;
+        Aml2 += Aml2Length;
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmTestResourceConversion
+ *
+ * PARAMETERS:  Node            - Parent device node
+ *              Name            - resource method name (_CRS)
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Compare the original AML with a conversion of the AML to
+ *              internal resource list, then back to AML.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDmTestResourceConversion (
+    ACPI_NAMESPACE_NODE     *Node,
+    char                    *Name)
+{
+    ACPI_STATUS             Status;
+    ACPI_BUFFER             ReturnObj;
+    ACPI_BUFFER             ResourceObj;
+    ACPI_BUFFER             NewAml;
+    ACPI_OBJECT             *OriginalAml;
+
+
+    AcpiOsPrintf ("Resource Conversion Comparison:\n");
+
+    NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+    ReturnObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+    ResourceObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+
+    /* Get the original _CRS AML resource template */
+
+    Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnObj);
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiOsPrintf ("Could not obtain %s: %s\n",
+            Name, AcpiFormatException (Status));
+        return (Status);
+    }
+
+    /* Get the AML resource template, converted to internal resource structs */
+
+    Status = AcpiGetCurrentResources (Node, &ResourceObj);
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
+            AcpiFormatException (Status));
+        goto Exit1;
+    }
+
+    /* Convert internal resource list to external AML resource template */
+
+    Status = AcpiRsCreateAmlResources (ResourceObj.Pointer, &NewAml);
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
+            AcpiFormatException (Status));
+        goto Exit2;
+    }
+
+    /* Compare original AML to the newly created AML resource list */
+
+    OriginalAml = ReturnObj.Pointer;
+
+    AcpiDmCompareAmlResources (
+        OriginalAml->Buffer.Pointer, (ACPI_RSDESC_SIZE) OriginalAml->Buffer.Length,
+        NewAml.Pointer, (ACPI_RSDESC_SIZE) NewAml.Length);
+
+    /* Cleanup and exit */
+
+    ACPI_FREE (NewAml.Pointer);
+Exit2:
+    ACPI_FREE (ResourceObj.Pointer);
+Exit1:
+    ACPI_FREE (ReturnObj.Pointer);
+    return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbResourceCallback
+ *
+ * PARAMETERS:  ACPI_WALK_RESOURCE_CALLBACK
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Simple callback to exercise AcpiWalkResources
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbResourceCallback (
+    ACPI_RESOURCE           *Resource,
+    void                    *Context)
+{
+
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbDeviceResources
+ *
+ * PARAMETERS:  ACPI_WALK_CALLBACK
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Display the _PRT/_CRS/_PRS resources for a device object.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbDeviceResources (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue)
+{
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_NAMESPACE_NODE     *PrtNode = NULL;
+    ACPI_NAMESPACE_NODE     *CrsNode = NULL;
+    ACPI_NAMESPACE_NODE     *PrsNode = NULL;
+    ACPI_NAMESPACE_NODE     *AeiNode = NULL;
+    char                    *ParentPath;
+    ACPI_BUFFER             ReturnObj;
+    ACPI_STATUS             Status;
+
+
+    Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
+    ParentPath = AcpiNsGetExternalPathname (Node);
+    if (!ParentPath)
+    {
+        return (AE_NO_MEMORY);
+    }
+
+    /* Get handles to the resource methods for this device */
+
+    (void) AcpiGetHandle (Node, METHOD_NAME__PRT, ACPI_CAST_PTR (ACPI_HANDLE, &PrtNode));
+    (void) AcpiGetHandle (Node, METHOD_NAME__CRS, ACPI_CAST_PTR (ACPI_HANDLE, &CrsNode));
+    (void) AcpiGetHandle (Node, METHOD_NAME__PRS, ACPI_CAST_PTR (ACPI_HANDLE, &PrsNode));
+    (void) AcpiGetHandle (Node, METHOD_NAME__AEI, ACPI_CAST_PTR (ACPI_HANDLE, &AeiNode));
+    if (!PrtNode && !CrsNode && !PrsNode && !AeiNode)
+    {
+        goto Cleanup;   /* Nothing to do */
+    }
+
+    AcpiOsPrintf ("\nDevice: %s\n", ParentPath);
+
+    /* Prepare for a return object of arbitrary size */
+
+    ReturnObj.Pointer = AcpiGbl_DbBuffer;
+    ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
+
+
+    /* _PRT */
+
+    if (PrtNode)
+    {
+        AcpiOsPrintf ("Evaluating _PRT\n");
+
+        Status = AcpiEvaluateObject (PrtNode, NULL, NULL, &ReturnObj);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("Could not evaluate _PRT: %s\n",
+                AcpiFormatException (Status));
+            goto GetCrs;
+        }
+
+        ReturnObj.Pointer = AcpiGbl_DbBuffer;
+        ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
+
+        Status = AcpiGetIrqRoutingTable (Node, &ReturnObj);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
+                AcpiFormatException (Status));
+            goto GetCrs;
+        }
+
+        AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
+    }
+
+
+    /* _CRS */
+
+GetCrs:
+    if (CrsNode)
+    {
+        AcpiOsPrintf ("Evaluating _CRS\n");
+
+        ReturnObj.Pointer = AcpiGbl_DbBuffer;
+        ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
+
+        Status = AcpiEvaluateObject (CrsNode, NULL, NULL, &ReturnObj);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("Could not evaluate _CRS: %s\n",
+                AcpiFormatException (Status));
+            goto GetPrs;
+        }
+
+        /* This code is here to exercise the AcpiWalkResources interface */
+
+        Status = AcpiWalkResources (Node, METHOD_NAME__CRS,
+            AcpiDbResourceCallback, NULL);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("AcpiWalkResources failed: %s\n",
+                AcpiFormatException (Status));
+            goto GetPrs;
+        }
+
+        /* Get the _CRS resource list */
+
+        ReturnObj.Pointer = AcpiGbl_DbBuffer;
+        ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
+
+        Status = AcpiGetCurrentResources (Node, &ReturnObj);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
+                AcpiFormatException (Status));
+            goto GetPrs;
+        }
+
+        /* Dump the _CRS resource list */
+
+        AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
+            ReturnObj.Pointer));
+
+        /*
+         * Perform comparison of original AML to newly created AML. This tests both
+         * the AML->Resource conversion and the Resource->Aml conversion.
+         */
+        Status = AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS);
+
+        /* Execute _SRS with the resource list */
+
+        Status = AcpiSetCurrentResources (Node, &ReturnObj);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
+                AcpiFormatException (Status));
+            goto GetPrs;
+        }
+    }
+
+
+    /* _PRS */
+
+GetPrs:
+    if (PrsNode)
+    {
+        AcpiOsPrintf ("Evaluating _PRS\n");
+
+        ReturnObj.Pointer = AcpiGbl_DbBuffer;
+        ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
+
+        Status = AcpiEvaluateObject (PrsNode, NULL, NULL, &ReturnObj);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("Could not evaluate _PRS: %s\n",
+                AcpiFormatException (Status));
+            goto GetAei;
+        }
+
+        ReturnObj.Pointer = AcpiGbl_DbBuffer;
+        ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
+
+        Status = AcpiGetPossibleResources (Node, &ReturnObj);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
+                AcpiFormatException (Status));
+            goto GetAei;
+        }
+
+        AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
+    }
+
+
+    /* _AEI */
+
+GetAei:
+    if (AeiNode)
+    {
+        AcpiOsPrintf ("Evaluating _AEI\n");
+
+        ReturnObj.Pointer = AcpiGbl_DbBuffer;
+        ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
+
+        Status = AcpiEvaluateObject (AeiNode, NULL, NULL, &ReturnObj);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("Could not evaluate _AEI: %s\n",
+                AcpiFormatException (Status));
+            goto Cleanup;
+        }
+
+        ReturnObj.Pointer = AcpiGbl_DbBuffer;
+        ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
+
+        Status = AcpiGetEventResources (Node, &ReturnObj);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("AcpiGetEventResources failed: %s\n",
+                AcpiFormatException (Status));
+            goto Cleanup;
+        }
+
+        AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
+    }
+
+
+Cleanup:
+    ACPI_FREE (ParentPath);
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbDisplayResources
+ *
+ * PARAMETERS:  ObjectArg       - String object name or object pointer.
+ *                                "*" means "display resources for all devices"
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display the resource objects associated with a device.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayResources (
+    char                    *ObjectArg)
+{
+    ACPI_NAMESPACE_NODE     *Node;
+
+
+    AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
+    AcpiDbgLevel |= ACPI_LV_RESOURCES;
+
+    /* Asterisk means "display resources for all devices" */
+
+    if (!ACPI_STRCMP (ObjectArg, "*"))
+    {
+        (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+                    ACPI_UINT32_MAX, AcpiDbDeviceResources, NULL, NULL, NULL);
+    }
+    else
+    {
+        /* Convert string to object pointer */
+
+        Node = AcpiDbConvertToNode (ObjectArg);
+        if (Node)
+        {
+            if (Node->Type != ACPI_TYPE_DEVICE)
+            {
+                AcpiOsPrintf ("%4.4s: Name is not a device object (%s)\n",
+                    Node->Name.Ascii, AcpiUtGetTypeName (Node->Type));
+            }
+            else
+            {
+                (void) AcpiDbDeviceResources (Node, 0, NULL, NULL);
+            }
+        }
+    }
+
+    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+}
+
+
+#if (!ACPI_REDUCED_HARDWARE)
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbGenerateGpe
+ *
+ * PARAMETERS:  GpeArg          - Raw GPE number, ascii string
+ *              BlockArg        - GPE block number, ascii string
+ *                                0 or 1 for FADT GPE blocks
+ *
+ * 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, 0);
+    BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0);
+
+
+    GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber),
+        GpeNumber);
+    if (!GpeEventInfo)
+    {
+        AcpiOsPrintf ("Invalid GPE\n");
+        return;
+    }
+
+    (void) AcpiEvGpeDispatch (NULL, GpeEventInfo, GpeNumber);
+}
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+#endif /* ACPI_DEBUGGER */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/debugger/dbdisply.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/debugger/dbdisply.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,1057 @@
+/*******************************************************************************
+ *
+ * Module Name: dbdisply - debug display commands
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acparser.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+
+
+#ifdef ACPI_DEBUGGER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dbdisply")
+
+/* Local prototypes */
+
+static void
+AcpiDbDumpParserDescriptor (
+    ACPI_PARSE_OBJECT       *Op);
+
+static void *
+AcpiDbGetPointer (
+    void                    *Target);
+
+
+/*
+ * System handler information.
+ * Used for Handlers command, in AcpiDbDisplayHandlers.
+ */
+#define ACPI_PREDEFINED_PREFIX          "%25s (%.2X) : "
+#define ACPI_HANDLER_NAME_STRING               "%30s : "
+#define ACPI_HANDLER_PRESENT_STRING                    "%-9s (%p)\n"
+#define ACPI_HANDLER_NOT_PRESENT_STRING                "%-9s\n"
+
+/* All predefined Address Space IDs */
+
+static ACPI_ADR_SPACE_TYPE  AcpiGbl_SpaceIdList[] =
+{
+    ACPI_ADR_SPACE_SYSTEM_MEMORY,
+    ACPI_ADR_SPACE_SYSTEM_IO,
+    ACPI_ADR_SPACE_PCI_CONFIG,
+    ACPI_ADR_SPACE_EC,
+    ACPI_ADR_SPACE_SMBUS,
+    ACPI_ADR_SPACE_CMOS,
+    ACPI_ADR_SPACE_PCI_BAR_TARGET,
+    ACPI_ADR_SPACE_IPMI,
+    ACPI_ADR_SPACE_GPIO,
+    ACPI_ADR_SPACE_GSBUS,
+    ACPI_ADR_SPACE_DATA_TABLE,
+    ACPI_ADR_SPACE_FIXED_HARDWARE
+};
+
+/* Global handler information */
+
+typedef struct acpi_handler_info
+{
+    void                    *Handler;
+    char                    *Name;
+
+} ACPI_HANDLER_INFO;
+
+static ACPI_HANDLER_INFO    AcpiGbl_HandlerList[] =
+{
+    {&AcpiGbl_SystemNotify.Handler,     "System Notifications"},
+    {&AcpiGbl_DeviceNotify.Handler,     "Device Notifications"},
+    {&AcpiGbl_TableHandler,             "ACPI Table Events"},
+    {&AcpiGbl_ExceptionHandler,         "Control Method Exceptions"},
+    {&AcpiGbl_InterfaceHandler,         "OSI Invocations"}
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbGetPointer
+ *
+ * PARAMETERS:  Target          - Pointer to string to be converted
+ *
+ * RETURN:      Converted pointer
+ *
+ * DESCRIPTION: Convert an ascii pointer value to a real value
+ *
+ ******************************************************************************/
+
+static void *
+AcpiDbGetPointer (
+    void                    *Target)
+{
+    void                    *ObjPtr;
+
+
+    ObjPtr = ACPI_TO_POINTER (ACPI_STRTOUL (Target, NULL, 16));
+    return (ObjPtr);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbDumpParserDescriptor
+ *
+ * PARAMETERS:  Op              - A parser Op descriptor
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display a formatted parser object
+ *
+ ******************************************************************************/
+
+static 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)
+    {
+        AcpiUtStrupr (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 DumpNode;
+
+
+        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;
+    }
+
+
+DumpNode:
+    /* Now dump the NS node */
+
+    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);
+    AcpiExDumpNamespaceNode (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:    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;
+    BOOLEAN                 CountRemaining = FALSE;
+
+
+    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
+    if (!WalkState)
+    {
+        AcpiOsPrintf ("There is no method currently executing\n");
+        return;
+    }
+
+    ObjDesc = WalkState->MethodDesc;
+    Node    = WalkState->MethodNode;
+
+    AcpiOsPrintf ("Currently executing control method is [%4.4s]\n",
+            AcpiUtGetNodeName (Node));
+    AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n",
+            (UINT32) ObjDesc->Method.ParamCount,
+            (UINT32) ObjDesc->Method.SyncLevel);
+
+
+    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)
+{
+    ACPI_WALK_STATE         *WalkState;
+
+
+    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
+    if (!WalkState)
+    {
+        AcpiOsPrintf ("There is no method currently executing\n");
+        return;
+    }
+
+    AcpiDmDisplayLocals (WalkState);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbDisplayArguments
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display all arguments for the currently running control method
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayArguments (
+    void)
+{
+    ACPI_WALK_STATE         *WalkState;
+
+
+    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
+    if (!WalkState)
+    {
+        AcpiOsPrintf ("There is no method currently executing\n");
+        return;
+    }
+
+    AcpiDmDisplayArguments (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                  ResultCount = 0;
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_GENERIC_STATE      *Frame;
+    UINT32                  Index; /* Index onto current frame */
+
+
+    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
+    if (!WalkState)
+    {
+        AcpiOsPrintf ("There is no method currently executing\n");
+        return;
+    }
+
+    ObjDesc = WalkState->MethodDesc;
+    Node    = WalkState->MethodNode;
+
+    if (WalkState->Results)
+    {
+        ResultCount = WalkState->ResultCount;
+    }
+
+    AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n",
+            AcpiUtGetNodeName (Node), ResultCount);
+
+    /* From the top element of result stack */
+
+    Frame = WalkState->Results;
+    Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
+
+    for (i = 0; i < ResultCount; i++)
+    {
+        ObjDesc = Frame->Results.ObjDesc[Index];
+        AcpiOsPrintf ("Result%u: ", i);
+        AcpiDmDisplayInternalObject (ObjDesc, WalkState);
+        if (Index == 0)
+        {
+            Frame = Frame->Results.Next;
+            Index = ACPI_RESULTS_FRAME_OBJ_NUM;
+        }
+        Index--;
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * 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", AcpiUtGetNodeName (Node));
+
+        WalkState = WalkState->Next;
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbDisplayObjectType
+ *
+ * PARAMETERS:  ObjectArg       - User entered NS node handle
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display type of an arbitrary NS node
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayObjectType (
+    char                    *ObjectArg)
+{
+    ACPI_HANDLE             Handle;
+    ACPI_DEVICE_INFO        *Info;
+    ACPI_STATUS             Status;
+    UINT32                  i;
+
+
+    Handle = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
+
+    Status = AcpiGetObjectInfo (Handle, &Info);
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiOsPrintf ("Could not get object info, %s\n",
+            AcpiFormatException (Status));
+        return;
+    }
+
+    AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n",
+        ACPI_FORMAT_UINT64 (Info->Address),
+        Info->CurrentStatus, Info->Flags);
+
+    AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",
+        Info->HighestDstates[0], Info->HighestDstates[1],
+        Info->HighestDstates[2], Info->HighestDstates[3]);
+
+    AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",
+        Info->LowestDstates[0], Info->LowestDstates[1],
+        Info->LowestDstates[2], Info->LowestDstates[3],
+        Info->LowestDstates[4]);
+
+    if (Info->Valid & ACPI_VALID_HID)
+    {
+        AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String);
+    }
+    if (Info->Valid & ACPI_VALID_UID)
+    {
+        AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String);
+    }
+    if (Info->Valid & ACPI_VALID_CID)
+    {
+        for (i = 0; i < Info->CompatibleIdList.Count; i++)
+        {
+            AcpiOsPrintf ("CID %u: %s\n", i,
+                Info->CompatibleIdList.Ids[i].String);
+        }
+    }
+
+    ACPI_FREE (Info);
+}
+
+
+/*******************************************************************************
+ *
+ * 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: ");
+    AcpiDmDisplayInternalObject (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:    ");
+    AcpiDmDisplayInternalObject (ObjDesc, WalkState);
+}
+
+
+#if (!ACPI_REDUCED_HARDWARE)
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbDisplayGpes
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display the current GPE structures
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayGpes (
+    void)
+{
+    ACPI_GPE_BLOCK_INFO     *GpeBlock;
+    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo;
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
+    char                    *GpeType;
+    UINT32                  GpeIndex;
+    UINT32                  Block = 0;
+    UINT32                  i;
+    UINT32                  j;
+    char                    Buffer[80];
+    ACPI_BUFFER             RetBuf;
+    ACPI_STATUS             Status;
+
+
+    RetBuf.Length = sizeof (Buffer);
+    RetBuf.Pointer = Buffer;
+
+    Block = 0;
+
+    /* Walk the GPE lists */
+
+    GpeXruptInfo = AcpiGbl_GpeXruptListHead;
+    while (GpeXruptInfo)
+    {
+        GpeBlock = GpeXruptInfo->GpeBlockListHead;
+        while (GpeBlock)
+        {
+            Status = AcpiGetName (GpeBlock->Node, ACPI_FULL_PATHNAME, &RetBuf);
+            if (ACPI_FAILURE (Status))
+            {
+                AcpiOsPrintf ("Could not convert name to pathname\n");
+            }
+
+            if (GpeBlock->Node == AcpiGbl_FadtGpeDevice)
+            {
+                GpeType = "FADT-defined GPE block";
+            }
+            else
+            {
+                GpeType = "GPE Block Device";
+            }
+
+            AcpiOsPrintf ("\nBlock %u - Info %p  DeviceNode %p [%s] - %s\n",
+                Block, GpeBlock, GpeBlock->Node, Buffer, GpeType);
+
+            AcpiOsPrintf ("    Registers:    %u (%u GPEs)\n",
+                GpeBlock->RegisterCount, GpeBlock->GpeCount);
+
+            AcpiOsPrintf ("    GPE range:    0x%X to 0x%X on interrupt %u\n",
+                GpeBlock->BlockBaseNumber,
+                GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1),
+                GpeXruptInfo->InterruptNumber);
+
+            AcpiOsPrintf (
+                "    RegisterInfo: %p  Status %8.8X%8.8X Enable %8.8X%8.8X\n",
+                GpeBlock->RegisterInfo,
+                ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->StatusAddress.Address),
+                ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->EnableAddress.Address));
+
+            AcpiOsPrintf ("    EventInfo:    %p\n", GpeBlock->EventInfo);
+
+            /* Examine each GPE Register within the block */
+
+            for (i = 0; i < GpeBlock->RegisterCount; i++)
+            {
+                GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
+
+                AcpiOsPrintf (
+                    "    Reg %u: (GPE %.2X-%.2X)  RunEnable %2.2X WakeEnable %2.2X"
+                    " Status %8.8X%8.8X Enable %8.8X%8.8X\n",
+                    i, GpeRegisterInfo->BaseGpeNumber,
+                    GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1),
+                    GpeRegisterInfo->EnableForRun,
+                    GpeRegisterInfo->EnableForWake,
+                    ACPI_FORMAT_UINT64 (GpeRegisterInfo->StatusAddress.Address),
+                    ACPI_FORMAT_UINT64 (GpeRegisterInfo->EnableAddress.Address));
+
+                /* Now look at the individual GPEs in this byte register */
+
+                for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
+                {
+                    GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j;
+                    GpeEventInfo = &GpeBlock->EventInfo[GpeIndex];
+
+                    if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
+                        ACPI_GPE_DISPATCH_NONE)
+                    {
+                        /* This GPE is not used (no method or handler), ignore it */
+
+                        continue;
+                    }
+
+                    AcpiOsPrintf (
+                        "        GPE %.2X: %p  RunRefs %2.2X Flags %2.2X (",
+                        GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo,
+                        GpeEventInfo->RuntimeCount, GpeEventInfo->Flags);
+
+                    /* Decode the flags byte */
+
+                    if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED)
+                    {
+                        AcpiOsPrintf ("Level, ");
+                    }
+                    else
+                    {
+                        AcpiOsPrintf ("Edge,  ");
+                    }
+
+                    if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)
+                    {
+                        AcpiOsPrintf ("CanWake, ");
+                    }
+                    else
+                    {
+                        AcpiOsPrintf ("RunOnly, ");
+                    }
+
+                    switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)
+                    {
+                    case ACPI_GPE_DISPATCH_NONE:
+                        AcpiOsPrintf ("NotUsed");
+                        break;
+                    case ACPI_GPE_DISPATCH_METHOD:
+                        AcpiOsPrintf ("Method");
+                        break;
+                    case ACPI_GPE_DISPATCH_HANDLER:
+                        AcpiOsPrintf ("Handler");
+                        break;
+                    case ACPI_GPE_DISPATCH_NOTIFY:
+                        AcpiOsPrintf ("Notify");
+                        break;
+                    default:
+                        AcpiOsPrintf ("UNKNOWN: %X",
+                            GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK);
+                        break;
+                    }
+
+                    AcpiOsPrintf (")\n");
+                }
+            }
+            Block++;
+            GpeBlock = GpeBlock->Next;
+        }
+        GpeXruptInfo = GpeXruptInfo->Next;
+    }
+}
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbDisplayHandlers
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display the currently installed global handlers
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDisplayHandlers (
+    void)
+{
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_OPERAND_OBJECT     *HandlerObj;
+    ACPI_ADR_SPACE_TYPE     SpaceId;
+    UINT32                  i;
+
+
+    /* Operation region handlers */
+
+    AcpiOsPrintf ("\nOperation Region Handlers:\n");
+
+    ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
+    if (ObjDesc)
+    {
+        for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++)
+        {
+            SpaceId = AcpiGbl_SpaceIdList[i];
+            HandlerObj = ObjDesc->Device.Handler;
+
+            AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
+                AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId);
+
+            while (HandlerObj)
+            {
+                if (AcpiGbl_SpaceIdList[i] == HandlerObj->AddressSpace.SpaceId)
+                {
+                    AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
+                        (HandlerObj->AddressSpace.HandlerFlags &
+                            ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
+                        HandlerObj->AddressSpace.Handler);
+                    goto FoundHandler;
+                }
+
+                HandlerObj = HandlerObj->AddressSpace.Next;
+            }
+
+            /* There is no handler for this SpaceId */
+
+            AcpiOsPrintf ("None\n");
+
+        FoundHandler:;
+        }
+
+        /* Find all handlers for user-defined SpaceIDs */
+
+        HandlerObj = ObjDesc->Device.Handler;
+        while (HandlerObj)
+        {
+            if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN)
+            {
+                AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
+                    "User-defined ID", HandlerObj->AddressSpace.SpaceId);
+                AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
+                    (HandlerObj->AddressSpace.HandlerFlags &
+                        ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",
+                    HandlerObj->AddressSpace.Handler);
+            }
+
+            HandlerObj = HandlerObj->AddressSpace.Next;
+        }
+    }
+
+#if (!ACPI_REDUCED_HARDWARE)
+
+    /* Fixed event handlers */
+
+    AcpiOsPrintf ("\nFixed Event Handlers:\n");
+
+    for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
+    {
+        AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetEventName (i), i);
+        if (AcpiGbl_FixedEventHandlers[i].Handler)
+        {
+            AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
+                AcpiGbl_FixedEventHandlers[i].Handler);
+        }
+        else
+        {
+            AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
+        }
+    }
+
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+    /* Miscellaneous global handlers */
+
+    AcpiOsPrintf ("\nMiscellaneous Global Handlers:\n");
+
+    for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_HandlerList); i++)
+    {
+        AcpiOsPrintf (ACPI_HANDLER_NAME_STRING, AcpiGbl_HandlerList[i].Name);
+        if (AcpiGbl_HandlerList[i].Handler)
+        {
+            AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",
+                AcpiGbl_HandlerList[i].Handler);
+        }
+        else
+        {
+            AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");
+        }
+    }
+}
+
+#endif /* ACPI_DEBUGGER */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/debugger/dbexec.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/debugger/dbexec.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,1105 @@
+/*******************************************************************************
+ *
+ * Module Name: dbexec - debugger control method execution
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#ifdef ACPI_DEBUGGER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dbexec")
+
+
+static ACPI_DB_METHOD_INFO          AcpiGbl_DbMethodInfo;
+#define DB_DEFAULT_PKG_ELEMENTS     33
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiDbExecuteMethod (
+    ACPI_DB_METHOD_INFO     *Info,
+    ACPI_BUFFER             *ReturnObj);
+
+static void
+AcpiDbExecuteSetup (
+    ACPI_DB_METHOD_INFO     *Info);
+
+static UINT32
+AcpiDbGetOutstandingAllocations (
+    void);
+
+static void ACPI_SYSTEM_XFACE
+AcpiDbMethodThread (
+    void                    *Context);
+
+static ACPI_STATUS
+AcpiDbExecutionWalk (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue);
+
+static ACPI_STATUS
+AcpiDbHexCharToValue (
+    int                     HexChar,
+    UINT8                   *ReturnValue);
+
+static ACPI_STATUS
+AcpiDbConvertToPackage (
+    char                    *String,
+    ACPI_OBJECT             *Object);
+
+static ACPI_STATUS
+AcpiDbConvertToObject (
+    ACPI_OBJECT_TYPE        Type,
+    char                    *String,
+    ACPI_OBJECT             *Object);
+
+static void
+AcpiDbDeleteObjects (
+    UINT32                  Count,
+    ACPI_OBJECT             *Objects);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbHexCharToValue
+ *
+ * PARAMETERS:  HexChar             - Ascii Hex digit, 0-9|a-f|A-F
+ *              ReturnValue         - Where the converted value is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Convert a single hex character to a 4-bit number (0-16).
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbHexCharToValue (
+    int                     HexChar,
+    UINT8                   *ReturnValue)
+{
+    UINT8                   Value;
+
+
+    /* Digit must be ascii [0-9a-fA-F] */
+
+    if (!ACPI_IS_XDIGIT (HexChar))
+    {
+        return (AE_BAD_HEX_CONSTANT);
+    }
+
+    if (HexChar <= 0x39)
+    {
+        Value = (UINT8) (HexChar - 0x30);
+    }
+    else
+    {
+        Value = (UINT8) (ACPI_TOUPPER (HexChar) - 0x37);
+    }
+
+    *ReturnValue = Value;
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbHexByteToBinary
+ *
+ * PARAMETERS:  HexByte             - Double hex digit (0x00 - 0xFF) in format:
+ *                                    HiByte then LoByte.
+ *              ReturnValue         - Where the converted value is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Convert two hex characters to an 8 bit number (0 - 255).
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbHexByteToBinary (
+    char                    *HexByte,
+    UINT8                   *ReturnValue)
+{
+    UINT8                   Local0;
+    UINT8                   Local1;
+    ACPI_STATUS             Status;
+
+
+    /* High byte */
+
+    Status = AcpiDbHexCharToValue (HexByte[0], &Local0);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    /* Low byte */
+
+    Status = AcpiDbHexCharToValue (HexByte[1], &Local1);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    *ReturnValue = (UINT8) ((Local0 << 4) | Local1);
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbConvertToBuffer
+ *
+ * PARAMETERS:  String              - Input string to be converted
+ *              Object              - Where the buffer object is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Convert a string to a buffer object. String is treated a list
+ *              of buffer elements, each separated by a space or comma.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbConvertToBuffer (
+    char                    *String,
+    ACPI_OBJECT             *Object)
+{
+    UINT32                  i;
+    UINT32                  j;
+    UINT32                  Length;
+    UINT8                   *Buffer;
+    ACPI_STATUS             Status;
+
+
+    /* Generate the final buffer length */
+
+    for (i = 0, Length = 0; String[i];)
+    {
+        i+=2;
+        Length++;
+
+        while (String[i] &&
+              ((String[i] == ',') || (String[i] == ' ')))
+        {
+            i++;
+        }
+    }
+
+    Buffer = ACPI_ALLOCATE (Length);
+    if (!Buffer)
+    {
+        return (AE_NO_MEMORY);
+    }
+
+    /* Convert the command line bytes to the buffer */
+
+    for (i = 0, j = 0; String[i];)
+    {
+        Status = AcpiDbHexByteToBinary (&String[i], &Buffer[j]);
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_FREE (Buffer);
+            return (Status);
+        }
+
+        j++;
+        i+=2;
+        while (String[i] &&
+              ((String[i] == ',') || (String[i] == ' ')))
+        {
+            i++;
+        }
+    }
+
+    Object->Type = ACPI_TYPE_BUFFER;
+    Object->Buffer.Pointer = Buffer;
+    Object->Buffer.Length = Length;
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbConvertToPackage
+ *
+ * PARAMETERS:  String              - Input string to be converted
+ *              Object              - Where the package object is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Convert a string to a package object. Handles nested packages
+ *              via recursion with AcpiDbConvertToObject.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbConvertToPackage (
+    char                    *String,
+    ACPI_OBJECT             *Object)
+{
+    char                    *This;
+    char                    *Next;
+    UINT32                  i;
+    ACPI_OBJECT_TYPE        Type;
+    ACPI_OBJECT             *Elements;
+    ACPI_STATUS             Status;
+
+
+    Elements = ACPI_ALLOCATE_ZEROED (
+        DB_DEFAULT_PKG_ELEMENTS * sizeof (ACPI_OBJECT));
+
+    This = String;
+    for (i = 0; i < (DB_DEFAULT_PKG_ELEMENTS - 1); i++)
+    {
+        This = AcpiDbGetNextToken (This, &Next, &Type);
+        if (!This)
+        {
+            break;
+        }
+
+        /* Recursive call to convert each package element */
+
+        Status = AcpiDbConvertToObject (Type, This, &Elements[i]);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiDbDeleteObjects (i + 1, Elements);
+            ACPI_FREE (Elements);
+            return (Status);
+        }
+
+        This = Next;
+    }
+
+    Object->Type = ACPI_TYPE_PACKAGE;
+    Object->Package.Count = i;
+    Object->Package.Elements = Elements;
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbConvertToObject
+ *
+ * PARAMETERS:  Type                - Object type as determined by parser
+ *              String              - Input string to be converted
+ *              Object              - Where the new object is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Convert a typed and tokenized string to an ACPI_OBJECT. Typing:
+ *              1) String objects were surrounded by quotes.
+ *              2) Buffer objects were surrounded by parentheses.
+ *              3) Package objects were surrounded by brackets "[]".
+ *              4) All standalone tokens are treated as integers.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbConvertToObject (
+    ACPI_OBJECT_TYPE        Type,
+    char                    *String,
+    ACPI_OBJECT             *Object)
+{
+    ACPI_STATUS             Status = AE_OK;
+
+
+    switch (Type)
+    {
+    case ACPI_TYPE_STRING:
+        Object->Type = ACPI_TYPE_STRING;
+        Object->String.Pointer = String;
+        Object->String.Length = (UINT32) ACPI_STRLEN (String);
+        break;
+
+    case ACPI_TYPE_BUFFER:
+        Status = AcpiDbConvertToBuffer (String, Object);
+        break;
+
+    case ACPI_TYPE_PACKAGE:
+        Status = AcpiDbConvertToPackage (String, Object);
+        break;
+
+    default:
+        Object->Type = ACPI_TYPE_INTEGER;
+        Status = AcpiUtStrtoul64 (String, 16, &Object->Integer.Value);
+        break;
+    }
+
+    return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbDeleteObjects
+ *
+ * PARAMETERS:  Count               - Count of objects in the list
+ *              Objects             - Array of ACPI_OBJECTs to be deleted
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Delete a list of ACPI_OBJECTS. Handles packages and nested
+ *              packages via recursion.
+ *
+ ******************************************************************************/
+
+static void
+AcpiDbDeleteObjects (
+    UINT32                  Count,
+    ACPI_OBJECT             *Objects)
+{
+    UINT32                  i;
+
+
+    for (i = 0; i < Count; i++)
+    {
+        switch (Objects[i].Type)
+        {
+        case ACPI_TYPE_BUFFER:
+            ACPI_FREE (Objects[i].Buffer.Pointer);
+            break;
+
+        case ACPI_TYPE_PACKAGE:
+
+            /* Recursive call to delete package elements */
+
+            AcpiDbDeleteObjects (Objects[i].Package.Count,
+                Objects[i].Package.Elements);
+
+            /* Free the elements array */
+
+            ACPI_FREE (Objects[i].Package.Elements);
+            break;
+
+        default:
+            break;
+        }
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbExecuteMethod
+ *
+ * PARAMETERS:  Info            - Valid info segment
+ *              ReturnObj       - Where to put return object
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Execute a control method.
+ *
+ ******************************************************************************/
+
+static 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];
+    ACPI_HANDLE             Handle;
+    ACPI_DEVICE_INFO        *ObjInfo;
+    UINT32                  i;
+
+
+    ACPI_FUNCTION_TRACE (DbExecuteMethod);
+
+
+    if (AcpiGbl_DbOutputToFile && !AcpiDbgLevel)
+    {
+        AcpiOsPrintf ("Warning: debug output is not enabled!\n");
+    }
+
+    /* Get the NS node, determines existence also */
+
+    Status = AcpiGetHandle (NULL, Info->Pathname, &Handle);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Get the object info for number of method parameters */
+
+    Status = AcpiGetObjectInfo (Handle, &ObjInfo);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    ParamObjects.Pointer = NULL;
+    ParamObjects.Count   = 0;
+
+    if (ObjInfo->Type == ACPI_TYPE_METHOD)
+    {
+        /* Are there arguments to the method? */
+
+        i = 0;
+        if (Info->Args && Info->Args[0])
+        {
+            /* Get arguments passed on the command line */
+
+            for (; Info->Args[i] &&
+                (i < ACPI_METHOD_NUM_ARGS) &&
+                (i < ObjInfo->ParamCount);
+                i++)
+            {
+                /* Convert input string (token) to an actual ACPI_OBJECT */
+
+                Status = AcpiDbConvertToObject (Info->Types[i],
+                    Info->Args[i], &Params[i]);
+                if (ACPI_FAILURE (Status))
+                {
+                    ACPI_EXCEPTION ((AE_INFO, Status,
+                        "While parsing method arguments"));
+                    goto Cleanup;
+                }
+            }
+        }
+
+        /* Create additional "default" parameters as needed */
+
+        if (i < ObjInfo->ParamCount)
+        {
+            AcpiOsPrintf ("Adding %u arguments containing default values\n",
+                ObjInfo->ParamCount - i);
+
+            for (; i < ObjInfo->ParamCount; i++)
+            {
+                switch (i)
+                {
+                case 0:
+
+                    Params[0].Type           = ACPI_TYPE_INTEGER;
+                    Params[0].Integer.Value  = 0x01020304;
+                    break;
+
+                case 1:
+
+                    Params[1].Type           = ACPI_TYPE_STRING;
+                    Params[1].String.Length  = 12;
+                    Params[1].String.Pointer = "AML Debugger";
+                    break;
+
+                default:
+
+                    Params[i].Type           = ACPI_TYPE_INTEGER;
+                    Params[i].Integer.Value  = i * (UINT64) 0x1000;
+                    break;
+                }
+            }
+        }
+
+        ParamObjects.Count = ObjInfo->ParamCount;
+        ParamObjects.Pointer = Params;
+    }
+
+    /* 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;
+
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_EXCEPTION ((AE_INFO, Status,
+            "while executing %s from debugger", Info->Pathname));
+
+        if (Status == AE_BUFFER_OVERFLOW)
+        {
+            ACPI_ERROR ((AE_INFO,
+                "Possible overflow of internal debugger buffer (size 0x%X needed 0x%X)",
+                ACPI_DEBUG_BUFFER_SIZE, (UINT32) ReturnObj->Length));
+        }
+    }
+
+Cleanup:
+    AcpiDbDeleteObjects (ObjInfo->ParamCount, Params);
+    ACPI_FREE (ObjInfo);
+
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbExecuteSetup
+ *
+ * PARAMETERS:  Info            - Valid method info
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Setup info segment prior to method execution
+ *
+ ******************************************************************************/
+
+static 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);
+    }
+}
+
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+UINT32
+AcpiDbGetCacheInfo (
+    ACPI_MEMORY_LIST        *Cache)
+{
+
+    return (Cache->TotalAllocated - Cache->TotalFreed - Cache->CurrentDepth);
+}
+#endif
+
+/*******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiDbGetOutstandingAllocations (
+    void)
+{
+    UINT32                  Outstanding = 0;
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+
+    Outstanding += AcpiDbGetCacheInfo (AcpiGbl_StateCache);
+    Outstanding += AcpiDbGetCacheInfo (AcpiGbl_PsNodeCache);
+    Outstanding += AcpiDbGetCacheInfo (AcpiGbl_PsNodeExtCache);
+    Outstanding += AcpiDbGetCacheInfo (AcpiGbl_OperandCache);
+#endif
+
+    return (Outstanding);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbExecutionWalk
+ *
+ * PARAMETERS:  WALK_CALLBACK
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Execute a control method.  Name is relative to the current
+ *              scope.
+ *
+ ******************************************************************************/
+
+static 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", AcpiUtGetNodeName (Node),
+            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:      None
+ *
+ * DESCRIPTION: Execute a control method.  Name is relative to the current
+ *              scope.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbExecute (
+    char                    *Name,
+    char                    **Args,
+    ACPI_OBJECT_TYPE        *Types,
+    UINT32                  Flags)
+{
+    ACPI_STATUS             Status;
+    ACPI_BUFFER             ReturnObj;
+    char                    *NameString;
+
+
+#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, NULL);
+        return;
+    }
+    else
+    {
+        NameString = ACPI_ALLOCATE (ACPI_STRLEN (Name) + 1);
+        if (!NameString)
+        {
+            return;
+        }
+
+        ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO));
+
+        ACPI_STRCPY (NameString, Name);
+        AcpiUtStrupr (NameString);
+        AcpiGbl_DbMethodInfo.Name = NameString;
+        AcpiGbl_DbMethodInfo.Args = Args;
+        AcpiGbl_DbMethodInfo.Types = Types;
+        AcpiGbl_DbMethodInfo.Flags = Flags;
+
+        ReturnObj.Pointer = NULL;
+        ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
+
+        AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo);
+        Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo, &ReturnObj);
+        ACPI_FREE (NameString);
+    }
+
+    /*
+     * Allow any handlers in separate threads to complete.
+     * (Such as Notify handlers invoked from AML executed above).
+     */
+    AcpiOsSleep ((UINT64) 10);
+
+
+#ifdef ACPI_DEBUG_OUTPUT
+
+    /* Memory allocation tracking */
+
+    Allocations = AcpiDbGetOutstandingAllocations () - PreviousAllocations;
+
+    AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
+
+    if (Allocations > 0)
+    {
+        AcpiOsPrintf ("Outstanding: 0x%X 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);
+            AcpiDbDumpExternalObject (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.
+ *
+ ******************************************************************************/
+
+static void ACPI_SYSTEM_XFACE
+AcpiDbMethodThread (
+    void                    *Context)
+{
+    ACPI_STATUS             Status;
+    ACPI_DB_METHOD_INFO     *Info = Context;
+    ACPI_DB_METHOD_INFO     LocalInfo;
+    UINT32                  i;
+    UINT8                   Allow;
+    ACPI_BUFFER             ReturnObj;
+
+
+    /*
+     * AcpiGbl_DbMethodInfo.Arguments will be passed as method arguments.
+     * Prevent AcpiGbl_DbMethodInfo from being modified by multiple threads
+     * concurrently.
+     *
+     * Note: The arguments we are passing are used by the ASL test suite
+     * (aslts). Do not change them without updating the tests.
+     */
+    (void) AcpiOsWaitSemaphore (Info->InfoGate, 1, ACPI_WAIT_FOREVER);
+
+    if (Info->InitArgs)
+    {
+        AcpiDbUInt32ToHexString (Info->NumCreated, Info->IndexOfThreadStr);
+        AcpiDbUInt32ToHexString ((UINT32) AcpiOsGetThreadId (), Info->IdOfThreadStr);
+    }
+
+    if (Info->Threads && (Info->NumCreated < Info->NumThreads))
+    {
+        Info->Threads[Info->NumCreated++] = AcpiOsGetThreadId();
+    }
+
+    LocalInfo = *Info;
+    LocalInfo.Args = LocalInfo.Arguments;
+    LocalInfo.Arguments[0] = LocalInfo.NumThreadsStr;
+    LocalInfo.Arguments[1] = LocalInfo.IdOfThreadStr;
+    LocalInfo.Arguments[2] = LocalInfo.IndexOfThreadStr;
+    LocalInfo.Arguments[3] = NULL;
+
+    LocalInfo.Types = LocalInfo.ArgTypes;
+
+    (void) AcpiOsSignalSemaphore (Info->InfoGate, 1);
+
+    for (i = 0; i < Info->NumLoops; i++)
+    {
+        Status = AcpiDbExecuteMethod (&LocalInfo, &ReturnObj);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("%s During execution of %s at iteration %X\n",
+                AcpiFormatException (Status), Info->Pathname, i);
+            if (Status == AE_ABORT_METHOD)
+            {
+                break;
+            }
+        }
+
+#if 0
+        if ((i % 100) == 0)
+        {
+            AcpiOsPrintf ("%u executions, Thread 0x%x\n", i, AcpiOsGetThreadId ());
+        }
+
+        if (ReturnObj.Length)
+        {
+            AcpiOsPrintf ("Execution of %s returned object %p Buflen %X\n",
+                Info->Pathname, ReturnObj.Pointer, (UINT32) ReturnObj.Length);
+            AcpiDbDumpExternalObject (ReturnObj.Pointer, 1);
+        }
+#endif
+    }
+
+    /* Signal our completion */
+
+    Allow = 0;
+    (void) AcpiOsWaitSemaphore (Info->ThreadCompleteGate, 1, ACPI_WAIT_FOREVER);
+    Info->NumCompleted++;
+
+    if (Info->NumCompleted == Info->NumThreads)
+    {
+        /* Do signal for main thread once only */
+        Allow = 1;
+    }
+
+    (void) AcpiOsSignalSemaphore (Info->ThreadCompleteGate, 1);
+
+    if (Allow)
+    {
+        Status = AcpiOsSignalSemaphore (Info->MainThreadGate, 1);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("Could not signal debugger thread sync semaphore, %s\n",
+                AcpiFormatException (Status));
+        }
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * 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;
+    UINT32                  Size;
+    ACPI_MUTEX              MainThreadGate;
+    ACPI_MUTEX              ThreadCompleteGate;
+    ACPI_MUTEX              InfoGate;
+
+
+    /* 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 semaphore for synchronization of
+     * the created threads with the main thread.
+     */
+    Status = AcpiOsCreateSemaphore (1, 0, &MainThreadGate);
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiOsPrintf ("Could not create semaphore for synchronization with the main thread, %s\n",
+            AcpiFormatException (Status));
+        return;
+    }
+
+    /*
+     * Create the semaphore for synchronization
+     * between the created threads.
+     */
+    Status = AcpiOsCreateSemaphore (1, 1, &ThreadCompleteGate);
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiOsPrintf ("Could not create semaphore for synchronization between the created threads, %s\n",
+            AcpiFormatException (Status));
+        (void) AcpiOsDeleteSemaphore (MainThreadGate);
+        return;
+    }
+
+    Status = AcpiOsCreateSemaphore (1, 1, &InfoGate);
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiOsPrintf ("Could not create semaphore for synchronization of AcpiGbl_DbMethodInfo, %s\n",
+            AcpiFormatException (Status));
+        (void) AcpiOsDeleteSemaphore (ThreadCompleteGate);
+        (void) AcpiOsDeleteSemaphore (MainThreadGate);
+        return;
+    }
+
+    ACPI_MEMSET (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO));
+
+    /* Array to store IDs of threads */
+
+    AcpiGbl_DbMethodInfo.NumThreads = NumThreads;
+    Size = sizeof (ACPI_THREAD_ID) * AcpiGbl_DbMethodInfo.NumThreads;
+    AcpiGbl_DbMethodInfo.Threads = AcpiOsAllocate (Size);
+    if (AcpiGbl_DbMethodInfo.Threads == NULL)
+    {
+        AcpiOsPrintf ("No memory for thread IDs array\n");
+        (void) AcpiOsDeleteSemaphore (MainThreadGate);
+        (void) AcpiOsDeleteSemaphore (ThreadCompleteGate);
+        (void) AcpiOsDeleteSemaphore (InfoGate);
+        return;
+    }
+    ACPI_MEMSET (AcpiGbl_DbMethodInfo.Threads, 0, Size);
+
+    /* Setup the context to be passed to each thread */
+
+    AcpiGbl_DbMethodInfo.Name = MethodNameArg;
+    AcpiGbl_DbMethodInfo.Flags = 0;
+    AcpiGbl_DbMethodInfo.NumLoops = NumLoops;
+    AcpiGbl_DbMethodInfo.MainThreadGate = MainThreadGate;
+    AcpiGbl_DbMethodInfo.ThreadCompleteGate = ThreadCompleteGate;
+    AcpiGbl_DbMethodInfo.InfoGate = InfoGate;
+
+    /* Init arguments to be passed to method */
+
+    AcpiGbl_DbMethodInfo.InitArgs = 1;
+    AcpiGbl_DbMethodInfo.Args = AcpiGbl_DbMethodInfo.Arguments;
+    AcpiGbl_DbMethodInfo.Arguments[0] = AcpiGbl_DbMethodInfo.NumThreadsStr;
+    AcpiGbl_DbMethodInfo.Arguments[1] = AcpiGbl_DbMethodInfo.IdOfThreadStr;
+    AcpiGbl_DbMethodInfo.Arguments[2] = AcpiGbl_DbMethodInfo.IndexOfThreadStr;
+    AcpiGbl_DbMethodInfo.Arguments[3] = NULL;
+
+    AcpiGbl_DbMethodInfo.Types = AcpiGbl_DbMethodInfo.ArgTypes;
+    AcpiGbl_DbMethodInfo.ArgTypes[0] = ACPI_TYPE_INTEGER;
+    AcpiGbl_DbMethodInfo.ArgTypes[1] = ACPI_TYPE_INTEGER;
+    AcpiGbl_DbMethodInfo.ArgTypes[2] = ACPI_TYPE_INTEGER;
+
+    AcpiDbUInt32ToHexString (NumThreads, AcpiGbl_DbMethodInfo.NumThreadsStr);
+
+    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 = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbMethodThread,
+            &AcpiGbl_DbMethodInfo);
+        if (ACPI_FAILURE (Status))
+        {
+            break;
+        }
+    }
+
+    /* Wait for all threads to complete */
+
+    (void) AcpiOsWaitSemaphore (MainThreadGate, 1, ACPI_WAIT_FOREVER);
+
+    AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
+    AcpiOsPrintf ("All threads (%X) have completed\n", NumThreads);
+    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+
+    /* Cleanup and exit */
+
+    (void) AcpiOsDeleteSemaphore (MainThreadGate);
+    (void) AcpiOsDeleteSemaphore (ThreadCompleteGate);
+    (void) AcpiOsDeleteSemaphore (InfoGate);
+
+    AcpiOsFree (AcpiGbl_DbMethodInfo.Threads);
+    AcpiGbl_DbMethodInfo.Threads = NULL;
+}
+
+#endif /* ACPI_DEBUGGER */
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/debugger/dbfileio.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/debugger/dbfileio.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,578 @@
+/*******************************************************************************
+ *
+ * Module Name: dbfileio - Debugger file I/O commands. These can't usually
+ *              be used when running the debugger in Ring 0 (Kernel mode)
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+
+#ifdef ACPI_APPLICATION
+#include <contrib/dev/acpica/include/actables.h>
+#endif
+
+#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
+
+/* Local prototypes */
+
+#ifdef ACPI_APPLICATION
+
+static ACPI_STATUS
+AcpiDbCheckTextModeCorruption (
+    UINT8                   *Table,
+    UINT32                  TableLength,
+    UINT32                  FileLength);
+
+#endif
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbCloseDebugFile
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * 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:      None
+ *
+ * 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:    AcpiDbCheckTextModeCorruption
+ *
+ * PARAMETERS:  Table           - Table buffer
+ *              TableLength     - Length of table from the table header
+ *              FileLength      - Length of the file that contains the table
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Check table for text mode file corruption where all linefeed
+ *              characters (LF) have been replaced by carriage return linefeed
+ *              pairs (CR/LF).
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbCheckTextModeCorruption (
+    UINT8                   *Table,
+    UINT32                  TableLength,
+    UINT32                  FileLength)
+{
+    UINT32                  i;
+    UINT32                  Pairs = 0;
+
+
+    if (TableLength != FileLength)
+    {
+        ACPI_WARNING ((AE_INFO,
+            "File length (0x%X) is not the same as the table length (0x%X)",
+            FileLength, TableLength));
+    }
+
+    /* Scan entire table to determine if each LF has been prefixed with a CR */
+
+    for (i = 1; i < FileLength; i++)
+    {
+        if (Table[i] == 0x0A)
+        {
+            if (Table[i - 1] != 0x0D)
+            {
+                /* The LF does not have a preceding CR, table not corrupted */
+
+                return (AE_OK);
+            }
+            else
+            {
+                /* Found a CR/LF pair */
+
+                Pairs++;
+            }
+            i++;
+        }
+    }
+
+    if (!Pairs)
+    {
+        return (AE_OK);
+    }
+
+    /*
+     * Entire table scanned, each CR is part of a CR/LF pair --
+     * meaning that the table was treated as a text file somewhere.
+     *
+     * NOTE: We can't "fix" the table, because any existing CR/LF pairs in the
+     * original table are left untouched by the text conversion process --
+     * meaning that we cannot simply replace CR/LF pairs with LFs.
+     */
+    AcpiOsPrintf ("Table has been corrupted by text mode conversion\n");
+    AcpiOsPrintf ("All LFs (%u) were changed to CR/LF pairs\n", Pairs);
+    AcpiOsPrintf ("Table cannot be repaired!\n");
+    return (AE_BAD_VALUE);
+}
+
+
+/*******************************************************************************
+ *
+ * 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;
+    UINT32                  Actual;
+    ACPI_STATUS             Status;
+    UINT32                  FileSize;
+    BOOLEAN                 StandardHeader = TRUE;
+
+
+    /* Get the file size */
+
+    fseek (fp, 0, SEEK_END);
+    FileSize = (UINT32) ftell (fp);
+    fseek (fp, 0, SEEK_SET);
+
+    if (FileSize < 4)
+    {
+        return (AE_BAD_HEADER);
+    }
+
+    /* Read the signature */
+
+    if (fread (&TableHeader, 1, 4, fp) != 4)
+    {
+        AcpiOsPrintf ("Could not read the table signature\n");
+        return (AE_BAD_HEADER);
+    }
+
+    fseek (fp, 0, SEEK_SET);
+
+    /* The RSDT, FACS and S3PT tables do not have standard ACPI headers */
+
+    if (ACPI_COMPARE_NAME (TableHeader.Signature, "RSD ") ||
+        ACPI_COMPARE_NAME (TableHeader.Signature, "FACS") ||
+        ACPI_COMPARE_NAME (TableHeader.Signature, "S3PT"))
+    {
+        *TableLength = FileSize;
+        StandardHeader = FALSE;
+    }
+    else
+    {
+        /* Read the table header */
+
+        if (fread (&TableHeader, 1, sizeof (TableHeader), fp) !=
+                sizeof (ACPI_TABLE_HEADER))
+        {
+            AcpiOsPrintf ("Could not read the table header\n");
+            return (AE_BAD_HEADER);
+        }
+
+#if 0
+        /* Validate the table header/length */
+
+        Status = AcpiTbValidateTableHeader (&TableHeader);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("Table header is invalid!\n");
+            return (Status);
+        }
+#endif
+
+        /* File size must be at least as long as the Header-specified length */
+
+        if (TableHeader.Length > FileSize)
+        {
+            AcpiOsPrintf (
+                "TableHeader length [0x%X] greater than the input file size [0x%X]\n",
+                TableHeader.Length, FileSize);
+            return (AE_BAD_HEADER);
+        }
+
+#ifdef ACPI_OBSOLETE_CODE
+        /* 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 [%4.4s] is invalid or not supported\n",
+                (char *) TableHeader.Signature);
+            ACPI_DUMP_BUFFER (&TableHeader, sizeof (ACPI_TABLE_HEADER));
+            return (AE_ERROR);
+        }
+#endif
+
+        *TableLength = TableHeader.Length;
+    }
+
+    /* Allocate a buffer for the table */
+
+    *Table = AcpiOsAllocate ((size_t) FileSize);
+    if (!*Table)
+    {
+        AcpiOsPrintf (
+            "Could not allocate memory for ACPI table %4.4s (size=0x%X)\n",
+            TableHeader.Signature, *TableLength);
+        return (AE_NO_MEMORY);
+    }
+
+    /* Get the rest of the table */
+
+    fseek (fp, 0, SEEK_SET);
+    Actual = fread (*Table, 1, (size_t) FileSize, fp);
+    if (Actual == FileSize)
+    {
+        if (StandardHeader)
+        {
+            /* Now validate the checksum */
+
+            Status = AcpiTbVerifyChecksum ((void *) *Table,
+                        ACPI_CAST_PTR (ACPI_TABLE_HEADER, *Table)->Length);
+
+            if (Status == AE_BAD_CHECKSUM)
+            {
+                Status = AcpiDbCheckTextModeCorruption ((UINT8 *) *Table,
+                            FileSize, (*Table)->Length);
+                return (Status);
+            }
+        }
+        return (AE_OK);
+    }
+
+    if (Actual > 0)
+    {
+        AcpiOsPrintf ("Warning - reading table, asked for %X got %X\n",
+            FileSize, Actual);
+        return (AE_OK);
+    }
+
+    AcpiOsPrintf ("Error - could not read the table file\n");
+    AcpiOsFree (*Table);
+    *Table = NULL;
+    *TableLength = 0;
+
+    return (AE_ERROR);
+}
+
+
+/*******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AeLocalLoadTable (
+    ACPI_TABLE_HEADER       *Table)
+{
+    ACPI_STATUS             Status = AE_OK;
+/*    ACPI_TABLE_DESC         TableInfo; */
+
+
+    ACPI_FUNCTION_TRACE (AeLocalLoadTable);
+#if 0
+
+
+    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))
+    {
+        if (Status == AE_ALREADY_EXISTS)
+        {
+            /* Table already exists, no error */
+
+            Status = AE_OK;
+        }
+
+        /* 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 */
+
+        AcpiTbDeleteTablesByType (ACPI_TABLE_ID_DSDT);
+        return_ACPI_STATUS (Status);
+    }
+#endif
+#endif
+
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * 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 ("Could not get table from the file\n");
+        return (Status);
+    }
+
+    return (AE_OK);
+ }
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbGetTableFromFile
+ *
+ * PARAMETERS:  Filename        - File where table is located
+ *              ReturnTable     - 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;
+    BOOLEAN                 IsAmlTable = TRUE;
+
+
+    Status = AcpiDbReadTableFromFile (Filename, &Table);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+#ifdef ACPI_DATA_TABLE_DISASSEMBLY
+    IsAmlTable = AcpiUtIsAmlTable (Table);
+#endif
+
+    if (IsAmlTable)
+    {
+        /* 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 -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/debugger/dbhistry.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/debugger/dbhistry.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,220 @@
+/******************************************************************************
+ *
+ * Module Name: dbhistry - debugger HISTORY command
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/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)
+{
+    UINT32                  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:      Pointer to the retrieved command. Null on error.
+ *
+ * DESCRIPTION: Get a command from the history buffer
+ *
+ ******************************************************************************/
+
+char *
+AcpiDbGetFromHistory (
+    char                    *CommandNumArg)
+{
+    UINT32                  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: %u\n", HistoryIndex);
+    return (NULL);
+}
+
+#endif /* ACPI_DEBUGGER */
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/debugger/dbinput.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/debugger/dbinput.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,1091 @@
+/*******************************************************************************
+ *
+ * Module Name: dbinput - user front-end to the AML debugger
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+
+
+#ifdef ACPI_DEBUGGER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dbinput")
+
+/* Local prototypes */
+
+static UINT32
+AcpiDbGetLine (
+    char                    *InputBuffer);
+
+static UINT32
+AcpiDbMatchCommand (
+    char                    *UserCommand);
+
+static void
+AcpiDbSingleThread (
+    void);
+
+static void
+AcpiDbDisplayHelp (
+    void);
+
+
+/*
+ * 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_BATCH,
+    CMD_BREAKPOINT,
+    CMD_BUSINFO,
+    CMD_CALL,
+    CMD_CLOSE,
+    CMD_DEBUG,
+    CMD_DISASSEMBLE,
+    CMD_DUMP,
+    CMD_ENABLEACPI,
+    CMD_EVENT,
+    CMD_EXECUTE,
+    CMD_EXIT,
+    CMD_FIND,
+    CMD_GO,
+    CMD_GPE,
+    CMD_GPES,
+    CMD_HANDLERS,
+    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_OSI,
+    CMD_OWNER,
+    CMD_PREDEFINED,
+    CMD_PREFIX,
+    CMD_QUIT,
+    CMD_REFERENCES,
+    CMD_RESOURCES,
+    CMD_RESULTS,
+    CMD_SET,
+    CMD_SLEEP,
+    CMD_STATS,
+    CMD_STOP,
+    CMD_TABLES,
+    CMD_TEMPLATE,
+    CMD_TERMINATE,
+    CMD_THREADS,
+    CMD_TRACE,
+    CMD_TREE,
+    CMD_TYPE,
+    CMD_UNLOAD
+};
+
+#define CMD_FIRST_VALID     2
+
+
+/* Second parameter is the required argument count */
+
+static const COMMAND_INFO       AcpiGbl_DbCommands[] =
+{
+    {"<NOT FOUND>",  0},
+    {"<NULL>",       0},
+    {"ALLOCATIONS",  0},
+    {"ARGS",         0},
+    {"ARGUMENTS",    0},
+    {"BATCH",        0},
+    {"BREAKPOINT",   1},
+    {"BUSINFO",      0},
+    {"CALL",         0},
+    {"CLOSE",        0},
+    {"DEBUG",        1},
+    {"DISASSEMBLE",  1},
+    {"DUMP",         1},
+    {"ENABLEACPI",   0},
+    {"EVENT",        1},
+    {"EXECUTE",      1},
+    {"EXIT",         0},
+    {"FIND",         1},
+    {"GO",           0},
+    {"GPE",          2},
+    {"GPES",         0},
+    {"HANDLERS",     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},
+    {"OSI",          0},
+    {"OWNER",        1},
+    {"PREDEFINED",   0},
+    {"PREFIX",       0},
+    {"QUIT",         0},
+    {"REFERENCES",   1},
+    {"RESOURCES",    1},
+    {"RESULTS",      0},
+    {"SET",          3},
+    {"SLEEP",        1},
+    {"STATS",        0},
+    {"STOP",         0},
+    {"TABLES",       0},
+    {"TEMPLATE",     1},
+    {"TERMINATE",    0},
+    {"THREADS",      3},
+    {"TRACE",        1},
+    {"TREE",         0},
+    {"TYPE",         1},
+    {"UNLOAD",       1},
+    {NULL,           0}
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbDisplayHelp
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Print a usage message.
+ *
+ ******************************************************************************/
+
+static void
+AcpiDbDisplayHelp (
+    void)
+{
+
+    AcpiOsPrintf ("\nGeneral-Purpose Commands:\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 ("  Handlers                            Info about global handlers\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 ("  Osi [Install|Remove <name>]         Display or modify global _OSI list\n");
+    AcpiOsPrintf ("  Quit or Exit                        Exit this command\n");
+    AcpiOsPrintf ("  Stats [Allocations|Memory|Misc|\n");
+    AcpiOsPrintf ("        Objects|Sizes|Stack|Tables]   Display namespace and memory statistics\n");
+    AcpiOsPrintf ("     Allocations                      Display list of current memory allocations\n");
+    AcpiOsPrintf ("     Memory                           Dump internal memory lists\n");
+    AcpiOsPrintf ("     Misc                             Namespace search and mutex stats\n");
+    AcpiOsPrintf ("     Objects                          Summary of namespace objects\n");
+    AcpiOsPrintf ("     Sizes                            Sizes for each of the internal objects\n");
+    AcpiOsPrintf ("     Stack                            Display CPU stack usage\n");
+    AcpiOsPrintf ("     Tables                           Info about current ACPI table(s)\n");
+    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");
+
+    AcpiOsPrintf ("\nNamespace Access Commands:\n");
+    AcpiOsPrintf ("  Businfo                             Display system bus info\n");
+    AcpiOsPrintf ("  Disassemble <Method>                Disassemble a control method\n");
+    AcpiOsPrintf ("  Event <F|G> <Value>                 Generate AcpiEvent (Fixed/GPE)\n");
+    AcpiOsPrintf ("  Find <AcpiName>  (? is wildcard)    Find ACPI name(s) with wildcards\n");
+    AcpiOsPrintf ("  Gpe <GpeNum> <GpeBlock>             Simulate a GPE\n");
+    AcpiOsPrintf ("  Gpes                                Display info on all GPEs\n");
+    AcpiOsPrintf ("  Integrity                           Validate namespace integrity\n");
+    AcpiOsPrintf ("  Methods                             Display list of loaded control methods\n");
+    AcpiOsPrintf ("  Namespace [Object] [Depth]          Display loaded namespace tree/subtree\n");
+    AcpiOsPrintf ("  Notify <Object> <Value>             Send a notification on Object\n");
+    AcpiOsPrintf ("  Objects <ObjectType>                Display all objects of the given type\n");
+    AcpiOsPrintf ("  Owner <OwnerId> [Depth]             Display loaded namespace by object owner\n");
+    AcpiOsPrintf ("  Predefined                          Check all predefined names\n");
+    AcpiOsPrintf ("  Prefix [<NamePath>]                 Set or Get current execution prefix\n");
+    AcpiOsPrintf ("  References <Addr>                   Find all references to object at addr\n");
+    AcpiOsPrintf ("  Resources <DeviceName | *>          Display Device resources (* = all devices)\n");
+    AcpiOsPrintf ("  Set N <NamedObject> <Value>         Set value for named integer\n");
+    AcpiOsPrintf ("  Sleep <SleepState>                  Simulate sleep/wake sequence\n");
+    AcpiOsPrintf ("  Template <Object>                   Format/dump a Buffer/ResourceTemplate\n");
+    AcpiOsPrintf ("  Terminate                           Delete namespace and all internal objects\n");
+    AcpiOsPrintf ("  Type <Object>                       Display object type\n");
+
+    AcpiOsPrintf ("\nControl Method Execution Commands:\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 ("     Hex Integer                      Integer method argument\n");
+    AcpiOsPrintf ("     \"Ascii String\"                   String method argument\n");
+    AcpiOsPrintf ("     (Byte List)                      Buffer method argument\n");
+    AcpiOsPrintf ("     [Package Element List]           Package method argument\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 ("  Thread <Threads><Loops><NamePath>   Spawn threads to execute method(s)\n");
+    AcpiOsPrintf ("  Trace <method name>                 Trace method execution\n");
+    AcpiOsPrintf ("  Tree                                Display control method calling tree\n");
+    AcpiOsPrintf ("  <Enter>                             Single step next AML opcode (over calls)\n");
+
+    AcpiOsPrintf ("\nFile I/O Commands:\n");
+    AcpiOsPrintf ("  Close                               Close debug output file\n");
+    AcpiOsPrintf ("  Load <Input Filename>               Load ACPI table from a file\n");
+    AcpiOsPrintf ("  Open <Output Filename>              Open a file for debug output\n");
+}
+
+
+/*******************************************************************************
+ *
+ * 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,
+    ACPI_OBJECT_TYPE        *ReturnType)
+{
+    char                    *Start;
+    UINT32                  Depth;
+    ACPI_OBJECT_TYPE        Type = ACPI_TYPE_INTEGER;
+
+
+    /* At end of buffer? */
+
+    if (!String || !(*String))
+    {
+        return (NULL);
+    }
+
+    /* Remove any spaces at the beginning */
+
+    if (*String == ' ')
+    {
+        while (*String && (*String == ' '))
+        {
+            String++;
+        }
+
+        if (!(*String))
+        {
+            return (NULL);
+        }
+    }
+
+    switch (*String)
+    {
+    case '"':
+
+        /* This is a quoted string, scan until closing quote */
+
+        String++;
+        Start = String;
+        Type = ACPI_TYPE_STRING;
+
+        /* Find end of string */
+
+        while (*String && (*String != '"'))
+        {
+            String++;
+        }
+        break;
+
+    case '(':
+
+        /* This is the start of a buffer, scan until closing paren */
+
+        String++;
+        Start = String;
+        Type = ACPI_TYPE_BUFFER;
+
+        /* Find end of buffer */
+
+        while (*String && (*String != ')'))
+        {
+            String++;
+        }
+        break;
+
+    case '[':
+
+        /* This is the start of a package, scan until closing bracket */
+
+        String++;
+        Depth = 1;
+        Start = String;
+        Type = ACPI_TYPE_PACKAGE;
+
+        /* Find end of package (closing bracket) */
+
+        while (*String)
+        {
+            /* Handle String package elements */
+
+            if (*String == '"')
+            {
+                /* Find end of string */
+
+                String++;
+                while (*String && (*String != '"'))
+                {
+                    String++;
+                }
+                if (!(*String))
+                {
+                    break;
+                }
+            }
+            else if (*String == '[')
+            {
+                Depth++;         /* A nested package declaration */
+            }
+            else if (*String == ']')
+            {
+                Depth--;
+                if (Depth == 0) /* Found final package closing bracket */
+                {
+                    break;
+                }
+            }
+
+            String++;
+        }
+        break;
+
+    default:
+
+        Start = String;
+
+        /* Find end of token */
+
+        while (*String && (*String != ' '))
+        {
+            String++;
+        }
+        break;
+    }
+
+    if (!(*String))
+    {
+        *Next = NULL;
+    }
+    else
+    {
+        *String = 0;
+        *Next = String + 1;
+    }
+
+    *ReturnType = Type;
+    return (Start);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbGetLine
+ *
+ * PARAMETERS:  InputBuffer         - Command line buffer
+ *
+ * RETURN:      Count of arguments to the command
+ *
+ * DESCRIPTION: Get the next command line from the user.  Gets entire line
+ *              up to the next newline
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiDbGetLine (
+    char                    *InputBuffer)
+{
+    UINT32                  i;
+    UINT32                  Count;
+    char                    *Next;
+    char                    *This;
+
+
+    ACPI_STRCPY (AcpiGbl_DbParsedBuf, InputBuffer);
+
+    This = AcpiGbl_DbParsedBuf;
+    for (i = 0; i < ACPI_DEBUGGER_MAX_ARGS; i++)
+    {
+        AcpiGbl_DbArgs[i] = AcpiDbGetNextToken (This, &Next,
+            &AcpiGbl_DbArgTypes[i]);
+        if (!AcpiGbl_DbArgs[i])
+        {
+            break;
+        }
+
+        This = Next;
+    }
+
+    /* Uppercase the actual command */
+
+    if (AcpiGbl_DbArgs[0])
+    {
+        AcpiUtStrupr (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
+ *
+ ******************************************************************************/
+
+static 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.
+ *
+ ******************************************************************************/
+
+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 ("%u parameters entered, [%s] requires %u 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_BATCH:
+        AcpiDbBatchExecute (AcpiGbl_DbArgs[1]);
+        break;
+
+    case CMD_BREAKPOINT:
+        AcpiDbSetMethodBreakpoint (AcpiGbl_DbArgs[1], WalkState, Op);
+        break;
+
+    case CMD_BUSINFO:
+        AcpiDbGetBusInfo ();
+        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], &AcpiGbl_DbArgTypes[2], EX_SINGLE_STEP);
+        break;
+
+    case CMD_DISASSEMBLE:
+        (void) AcpiDbDisassembleMethod (AcpiGbl_DbArgs[1]);
+        break;
+
+    case CMD_DUMP:
+        AcpiDbDecodeAndDisplayObject (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
+        break;
+
+    case CMD_ENABLEACPI:
+#if (!ACPI_REDUCED_HARDWARE)
+
+        Status = AcpiEnable();
+        if (ACPI_FAILURE(Status))
+        {
+            AcpiOsPrintf("AcpiEnable failed (Status=%X)\n", Status);
+            return (Status);
+        }
+#endif /* !ACPI_REDUCED_HARDWARE */
+        break;
+
+    case CMD_EVENT:
+        AcpiOsPrintf ("Event command not implemented\n");
+        break;
+
+    case CMD_EXECUTE:
+        AcpiDbExecute (AcpiGbl_DbArgs[1],
+            &AcpiGbl_DbArgs[2], &AcpiGbl_DbArgTypes[2], EX_NO_SINGLE_STEP);
+        break;
+
+    case CMD_FIND:
+        Status = 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_HANDLERS:
+        AcpiDbDisplayHandlers ();
+        break;
+
+    case CMD_HELP:
+    case CMD_HELP2:
+        AcpiDbDisplayHelp ();
+        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);
+        return (Status);
+
+    case CMD_HISTORY_LAST:
+        CommandLine = AcpiDbGetFromHistory (NULL);
+        if (!CommandLine)
+        {
+            return (AE_CTRL_TRUE);
+        }
+
+        Status = AcpiDbCommandDispatch (CommandLine, WalkState, Op);
+        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);
+        break;
+
+    case CMD_LOCKS:
+        AcpiDbDisplayLocks ();
+        break;
+
+    case CMD_LOCALS:
+        AcpiDbDisplayLocals ();
+        break;
+
+    case CMD_METHODS:
+        Status = 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:
+        AcpiUtStrupr (AcpiGbl_DbArgs[1]);
+        Status = AcpiDbDisplayObjects (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
+        break;
+
+    case CMD_OPEN:
+        AcpiDbOpenDebugFile (AcpiGbl_DbArgs[1]);
+        break;
+
+    case CMD_OSI:
+        AcpiDbDisplayInterfaces (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
+        break;
+
+    case CMD_OWNER:
+        AcpiDbDumpNamespaceByOwner (AcpiGbl_DbArgs[1], AcpiGbl_DbArgs[2]);
+        break;
+
+    case CMD_PREDEFINED:
+        AcpiDbCheckPredefinedNames ();
+        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_SLEEP:
+        Status = AcpiDbSleep (AcpiGbl_DbArgs[1]);
+        break;
+
+    case CMD_STATS:
+        Status = AcpiDbDisplayStatistics (AcpiGbl_DbArgs[1]);
+        break;
+
+    case CMD_STOP:
+        return (AE_NOT_IMPLEMENTED);
+
+    case CMD_TABLES:
+        AcpiDbDisplayTableInfo (AcpiGbl_DbArgs[1]);
+        break;
+
+    case CMD_TEMPLATE:
+        AcpiDbDisplayTemplate (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_TRACE:
+        (void) AcpiDebugTrace (AcpiGbl_DbArgs[1],0,0,1);
+        break;
+
+    case CMD_TREE:
+        AcpiDbDisplayCallingTree ();
+        break;
+
+    case CMD_TYPE:
+        AcpiDbDisplayObjectType (AcpiGbl_DbArgs[1]);
+        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;
+        }
+
+        AcpiDbCloseDebugFile ();
+        AcpiGbl_DbTerminateThreads = TRUE;
+        return (AE_CTRL_TERMINATE);
+
+    case CMD_NOT_FOUND:
+    default:
+        AcpiOsPrintf ("Unknown Command\n");
+        return (AE_CTRL_TRUE);
+    }
+
+    if (ACPI_SUCCESS (Status))
+    {
+        Status = 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.
+ *
+ ******************************************************************************/
+
+static void
+AcpiDbSingleThread (
+    void)
+{
+
+    AcpiGbl_MethodExecuting = FALSE;
+    AcpiGbl_StepToNextCall = FALSE;
+
+    (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbUserCommands
+ *
+ * PARAMETERS:  Prompt              - User prompt (depends on mode)
+ *              Op                  - Current executing parse op
+ *
+ * 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 */
+
+        Status = AcpiOsGetLine (AcpiGbl_DbLineBuf,
+            ACPI_DB_LINE_BUFFER_SIZE, NULL);
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));
+            return (Status);
+        }
+
+        /* 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 -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/debugger/dbmethod.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/debugger/dbmethod.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,529 @@
+/*******************************************************************************
+ *
+ * Module Name: dbmethod - Debug commands for control methods
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+#include <contrib/dev/acpica/include/acparser.h>
+
+
+#ifdef ACPI_DEBUGGER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dbmethod")
+
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiDbWalkForExecute (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue);
+
+
+/*******************************************************************************
+ *
+ * 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:    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;
+    ACPI_NAMESPACE_NODE     *Node;
+
+
+    /* Validate TypeArg */
+
+    AcpiUtStrupr (TypeArg);
+    Type = TypeArg[0];
+    if ((Type != 'L') &&
+        (Type != 'A') &&
+        (Type != 'N'))
+    {
+        AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
+        return;
+    }
+
+    Value = ACPI_STRTOUL (ValueArg, NULL, 16);
+
+    if (Type == 'N')
+    {
+        Node = AcpiDbConvertToNode (IndexArg);
+        if (Node->Type != ACPI_TYPE_INTEGER)
+        {
+            AcpiOsPrintf ("Can only set Integer nodes\n");
+            return;
+        }
+        ObjDesc = Node->Object;
+        ObjDesc->Integer.Value = Value;
+        return;
+    }
+
+    /* Get the index and value */
+
+    Index = ACPI_STRTOUL (IndexArg, NULL, 16);
+
+    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
+    if (!WalkState)
+    {
+        AcpiOsPrintf ("There is no method currently executing\n");
+        return;
+    }
+
+    /* Create and initialize the new object */
+
+    ObjDesc = AcpiUtCreateIntegerObject ((UINT64) Value);
+    if (!ObjDesc)
+    {
+        AcpiOsPrintf ("Could not create an internal object\n");
+        return;
+    }
+
+    /* Store the new object into the target */
+
+    switch (Type)
+    {
+    case 'A':
+
+        /* Set a method argument */
+
+        if (Index > ACPI_METHOD_MAX_ARG)
+        {
+            AcpiOsPrintf ("Arg%u - Invalid argument name\n", Index);
+            goto Cleanup;
+        }
+
+        Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_ARG, Index, ObjDesc,
+                    WalkState);
+        if (ACPI_FAILURE (Status))
+        {
+            goto Cleanup;
+        }
+
+        ObjDesc = WalkState->Arguments[Index].Object;
+
+        AcpiOsPrintf ("Arg%u: ", Index);
+        AcpiDmDisplayInternalObject (ObjDesc, WalkState);
+        break;
+
+    case 'L':
+
+        /* Set a method local */
+
+        if (Index > ACPI_METHOD_MAX_LOCAL)
+        {
+            AcpiOsPrintf ("Local%u - Invalid local variable name\n", Index);
+            goto Cleanup;
+        }
+
+        Status = AcpiDsStoreObjectToLocal (ACPI_REFCLASS_LOCAL, Index, ObjDesc,
+                    WalkState);
+        if (ACPI_FAILURE (Status))
+        {
+            goto Cleanup;
+        }
+
+        ObjDesc = WalkState->LocalVariables[Index].Object;
+
+        AcpiOsPrintf ("Local%u: ", Index);
+        AcpiDmDisplayInternalObject (ObjDesc, WalkState);
+        break;
+
+    default:
+        break;
+    }
+
+Cleanup:
+    AcpiUtRemoveReference (ObjDesc);
+}
+
+
+/*******************************************************************************
+ *
+ * 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:    AcpiDbDisassembleMethod
+ *
+ * PARAMETERS:  Name            - Name of control method
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
+ *              of statements specified.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbDisassembleMethod (
+    char                    *Name)
+{
+    ACPI_STATUS             Status;
+    ACPI_PARSE_OBJECT       *Op;
+    ACPI_WALK_STATE         *WalkState;
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_NAMESPACE_NODE     *Method;
+
+
+    Method = AcpiDbConvertToNode (Name);
+    if (!Method)
+    {
+        return (AE_BAD_PARAMETER);
+    }
+
+    ObjDesc = Method->Object;
+
+    Op = AcpiPsCreateScopeOp ();
+    if (!Op)
+    {
+        return (AE_NO_MEMORY);
+    }
+
+    /* Create and initialize a new walk state */
+
+    WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
+    if (!WalkState)
+    {
+        return (AE_NO_MEMORY);
+    }
+
+    Status = AcpiDsInitAmlWalk (WalkState, Op, NULL,
+                    ObjDesc->Method.AmlStart,
+                    ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    /* Parse the AML */
+
+    WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
+    WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
+    Status = AcpiPsParseAml (WalkState);
+
+#ifdef ACPI_DISASSEMBLER
+    AcpiDmDisassemble (NULL, Op, 0);
+#endif
+    AcpiPsDeleteParseTree (Op);
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbWalkForExecute
+ *
+ * PARAMETERS:  Callback from WalkNamespace
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Batch execution module. Currently only executes predefined
+ *              ACPI names.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbWalkForExecute (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue)
+{
+    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
+    ACPI_EXECUTE_WALK       *Info = (ACPI_EXECUTE_WALK *) Context;
+    ACPI_BUFFER             ReturnObj;
+    ACPI_STATUS             Status;
+    char                    *Pathname;
+    UINT32                  i;
+    ACPI_DEVICE_INFO        *ObjInfo;
+    ACPI_OBJECT_LIST        ParamObjects;
+    ACPI_OBJECT             Params[ACPI_METHOD_NUM_ARGS];
+    const ACPI_PREDEFINED_INFO *Predefined;
+
+
+    Predefined = AcpiNsCheckForPredefinedName (Node);
+    if (!Predefined)
+    {
+        return (AE_OK);
+    }
+
+    if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
+    {
+        return (AE_OK);
+    }
+
+    Pathname = AcpiNsGetExternalPathname (Node);
+    if (!Pathname)
+    {
+        return (AE_OK);
+    }
+
+    /* Get the object info for number of method parameters */
+
+    Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    ParamObjects.Pointer = NULL;
+    ParamObjects.Count   = 0;
+
+    if (ObjInfo->Type == ACPI_TYPE_METHOD)
+    {
+        /* Setup default parameters */
+
+        for (i = 0; i < ObjInfo->ParamCount; i++)
+        {
+            Params[i].Type           = ACPI_TYPE_INTEGER;
+            Params[i].Integer.Value  = 1;
+        }
+
+        ParamObjects.Pointer     = Params;
+        ParamObjects.Count       = ObjInfo->ParamCount;
+    }
+
+    ACPI_FREE (ObjInfo);
+    ReturnObj.Pointer = NULL;
+    ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
+
+    /* Do the actual method execution */
+
+    AcpiGbl_MethodExecuting = TRUE;
+
+    Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
+
+    AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status));
+    AcpiGbl_MethodExecuting = FALSE;
+    ACPI_FREE (Pathname);
+
+    /* Ignore status from method execution */
+
+    Status = AE_OK;
+
+    /* Update count, check if we have executed enough methods */
+
+    Info->Count++;
+    if (Info->Count >= Info->MaxCount)
+    {
+        Status = AE_CTRL_TERMINATE;
+    }
+
+    return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbBatchExecute
+ *
+ * PARAMETERS:  CountArg            - Max number of methods to execute
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Namespace batch execution. Execute predefined names in the
+ *              namespace, up to the max count, if specified.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbBatchExecute (
+    char                    *CountArg)
+{
+    ACPI_EXECUTE_WALK       Info;
+
+
+    Info.Count = 0;
+    Info.MaxCount = ACPI_UINT32_MAX;
+
+    if (CountArg)
+    {
+        Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0);
+    }
+
+
+    /* Search all nodes in namespace */
+
+    (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+                AcpiDbWalkForExecute, NULL, (void *) &Info, NULL);
+
+    AcpiOsPrintf ("Executed %u predefined names in the namespace\n", Info.Count);
+}
+
+#endif /* ACPI_DEBUGGER */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/debugger/dbnames.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/debugger/dbnames.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,934 @@
+/*******************************************************************************
+ *
+ * Module Name: dbnames - Debugger commands for the acpi namespace
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+
+
+#ifdef ACPI_DEBUGGER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dbnames")
+
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiDbWalkAndMatchName (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue);
+
+static ACPI_STATUS
+AcpiDbWalkForPredefinedNames (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue);
+
+static ACPI_STATUS
+AcpiDbWalkForSpecificObjects (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue);
+
+static ACPI_STATUS
+AcpiDbIntegrityWalk (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue);
+
+static ACPI_STATUS
+AcpiDbWalkForReferences (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue);
+
+static ACPI_STATUS
+AcpiDbBusWalk (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue);
+
+/*
+ * Arguments for the Objects command
+ * These object types map directly to the ACPI_TYPES
+ */
+static ARGUMENT_INFO        AcpiDbObjectTypes [] =
+{
+    {"ANY"},
+    {"INTEGERS"},
+    {"STRINGS"},
+    {"BUFFERS"},
+    {"PACKAGES"},
+    {"FIELDS"},
+    {"DEVICES"},
+    {"EVENTS"},
+    {"METHODS"},
+    {"MUTEXES"},
+    {"REGIONS"},
+    {"POWERRESOURCES"},
+    {"PROCESSORS"},
+    {"THERMALZONES"},
+    {"BUFFERFIELDS"},
+    {"DDBHANDLES"},
+    {"DEBUG"},
+    {"REGIONFIELDS"},
+    {"BANKFIELDS"},
+    {"INDEXFIELDS"},
+    {"REFERENCES"},
+    {"ALIAS"},
+    {NULL}           /* Must be null terminated */
+};
+
+
+/*******************************************************************************
+ *
+ * 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 = AcpiNsGetNode (AcpiGbl_RootNode, Name, 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 = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, 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:    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)
+    {
+        SubtreeEntry = AcpiDbConvertToNode (StartArg);
+        if (!SubtreeEntry)
+        {
+            return;
+        }
+
+        /* 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 %4.4s (%p) subtree):\n",
+        ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry);
+
+    /* Display the subtree */
+
+    AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
+    AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
+        ACPI_OWNER_ID_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;
+    ACPI_OWNER_ID           OwnerId;
+
+
+    OwnerId = (ACPI_OWNER_ID) 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:    AcpiDbWalkAndMatchName
+ *
+ * PARAMETERS:  Callback from WalkNamespace
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Find a particular name/names within the namespace.  Wildcards
+ *              are supported -- '?' matches any character.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbWalkAndMatchName (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue)
+{
+    ACPI_STATUS             Status;
+    char                    *RequestedName = (char *) Context;
+    UINT32                  i;
+    ACPI_BUFFER             Buffer;
+    ACPI_WALK_INFO          Info;
+
+
+    /* 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
+    {
+        Info.OwnerId = ACPI_OWNER_ID_MAX;
+        Info.DebugLevel = ACPI_UINT32_MAX;
+        Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
+
+        AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
+        (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL);
+        ACPI_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)
+{
+    char                    AcpiName[5] = "____";
+    char                    *AcpiNamePtr = AcpiName;
+
+
+    if (ACPI_STRLEN (NameArg) > 4)
+    {
+        AcpiOsPrintf ("Name must be no longer than 4 characters\n");
+        return (AE_OK);
+    }
+
+    /* Pad out name with underscores as necessary to create a 4-char name */
+
+    AcpiUtStrupr (NameArg);
+    while (*NameArg)
+    {
+        *AcpiNamePtr = *NameArg;
+        AcpiNamePtr++;
+        NameArg++;
+    }
+
+    /* Walk the namespace from the root */
+
+    (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+                        AcpiDbWalkAndMatchName, NULL, AcpiName, NULL);
+
+    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbWalkForPredefinedNames
+ *
+ * PARAMETERS:  Callback from WalkNamespace
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Detect and display predefined ACPI names (names that start with
+ *              an underscore)
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbWalkForPredefinedNames (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue)
+{
+    ACPI_NAMESPACE_NODE         *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
+    UINT32                      *Count = (UINT32 *) Context;
+    const ACPI_PREDEFINED_INFO  *Predefined;
+    const ACPI_PREDEFINED_INFO  *Package = NULL;
+    char                        *Pathname;
+
+
+    Predefined = AcpiNsCheckForPredefinedName (Node);
+    if (!Predefined)
+    {
+        return (AE_OK);
+    }
+
+    Pathname = AcpiNsGetExternalPathname (Node);
+    if (!Pathname)
+    {
+        return (AE_OK);
+    }
+
+    /* If method returns a package, the info is in the next table entry */
+
+    if (Predefined->Info.ExpectedBtypes & ACPI_BTYPE_PACKAGE)
+    {
+        Package = Predefined + 1;
+    }
+
+    AcpiOsPrintf ("%-32s arg %X ret %2.2X", Pathname,
+        Predefined->Info.ParamCount, Predefined->Info.ExpectedBtypes);
+
+    if (Package)
+    {
+        AcpiOsPrintf (" PkgType %2.2X ObjType %2.2X Count %2.2X",
+            Package->RetInfo.Type, Package->RetInfo.ObjectType1,
+            Package->RetInfo.Count1);
+    }
+
+    AcpiOsPrintf("\n");
+
+    AcpiNsCheckParameterCount (Pathname, Node, ACPI_UINT32_MAX, Predefined);
+    ACPI_FREE (Pathname);
+    (*Count)++;
+
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbCheckPredefinedNames
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Validate all predefined names in the namespace
+ *
+ ******************************************************************************/
+
+void
+AcpiDbCheckPredefinedNames (
+    void)
+{
+    UINT32                  Count = 0;
+
+
+    /* Search all nodes in namespace */
+
+    (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+                AcpiDbWalkForPredefinedNames, NULL, (void *) &Count, NULL);
+
+    AcpiOsPrintf ("Found %u predefined names in the namespace\n", Count);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbWalkForSpecificObjects
+ *
+ * PARAMETERS:  Callback from WalkNamespace
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Display short info about objects in the namespace
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbWalkForSpecificObjects (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue)
+{
+    ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
+    ACPI_BUFFER             Buffer;
+    ACPI_STATUS             Status;
+
+
+    Info->Count++;
+
+    /* 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_FREE (Buffer.Pointer);
+
+    /* Dump short info about the object */
+
+    (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL);
+    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_WALK_INFO          Info;
+    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);
+
+    Info.Count = 0;
+    Info.OwnerId = ACPI_OWNER_ID_MAX;
+    Info.DebugLevel = ACPI_UINT32_MAX;
+    Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
+
+    /* Walk the namespace from the root */
+
+    (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+                AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL);
+
+    AcpiOsPrintf (
+        "\nFound %u objects of type [%s] in the current ACPI Namespace\n",
+        Info.Count, AcpiUtGetTypeName (Type));
+
+    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbIntegrityWalk
+ *
+ * PARAMETERS:  Callback from WalkNamespace
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Examine one NS node for valid values.
+ *
+ ******************************************************************************/
+
+static 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;
+    BOOLEAN                 Alias = TRUE;
+
+
+    Info->Nodes++;
+
+    /* Verify the NS node, and dereference aliases */
+
+    while (Alias)
+    {
+        if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
+        {
+            AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s] - is %2.2X should be %2.2X\n",
+                Node, AcpiUtGetDescriptorName (Node), ACPI_GET_DESCRIPTOR_TYPE (Node),
+                ACPI_DESC_TYPE_NAMED);
+            return (AE_OK);
+        }
+
+        if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS)  ||
+            (Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
+        {
+            Node = (ACPI_NAMESPACE_NODE *) Node->Object;
+        }
+        else
+        {
+            Alias = FALSE;
+        }
+    }
+
+    if (Node->Type > ACPI_TYPE_LOCAL_MAX)
+    {
+        AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
+            Node, Node->Type);
+        return (AE_OK);
+    }
+
+    if (!AcpiUtValidAcpiName (Node->Name.Integer))
+    {
+        AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
+        return (AE_OK);
+    }
+
+    Object = AcpiNsGetAttachedObject (Node);
+    if (Object)
+    {
+        Info->Objects++;
+        if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
+        {
+            AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
+                Object, AcpiUtGetDescriptorName (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, NULL, (void *) &Info, NULL);
+
+    AcpiOsPrintf ("Verified %u namespace nodes with %u Objects\n",
+        Info.Nodes, Info.Objects);
+}
+
+
+/*******************************************************************************
+ *
+ * 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
+ *
+ ******************************************************************************/
+
+static 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",
+            AcpiUtGetNodeName (Node));
+    }
+
+    /* Check for match against the object attached to the node */
+
+    if (AcpiNsGetAttachedObject (Node) == ObjDesc)
+    {
+        AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
+            Node, AcpiUtGetNodeName (Node));
+    }
+
+    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, NULL, (void *) ObjDesc, NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbBusWalk
+ *
+ * PARAMETERS:  Callback from WalkNamespace
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Display info about device objects that have a corresponding
+ *              _PRT method.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbBusWalk (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue)
+{
+    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
+    ACPI_STATUS             Status;
+    ACPI_BUFFER             Buffer;
+    ACPI_NAMESPACE_NODE     *TempNode;
+    ACPI_DEVICE_INFO        *Info;
+    UINT32                  i;
+
+
+    if ((Node->Type != ACPI_TYPE_DEVICE) &&
+        (Node->Type != ACPI_TYPE_PROCESSOR))
+    {
+        return (AE_OK);
+    }
+
+    /* Exit if there is no _PRT under this device */
+
+    Status = AcpiGetHandle (Node, METHOD_NAME__PRT,
+                ACPI_CAST_PTR (ACPI_HANDLE, &TempNode));
+    if (ACPI_FAILURE (Status))
+    {
+        return (AE_OK);
+    }
+
+    /* Get the full path to this device object */
+
+    Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
+    Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
+        return (AE_OK);
+    }
+
+    Status = AcpiGetObjectInfo (ObjHandle, &Info);
+    if (ACPI_FAILURE (Status))
+    {
+        return (AE_OK);
+    }
+
+    /* Display the full path */
+
+    AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type);
+    ACPI_FREE (Buffer.Pointer);
+
+    if (Info->Flags & ACPI_PCI_ROOT_BRIDGE)
+    {
+        AcpiOsPrintf ("  - Is PCI Root Bridge");
+    }
+    AcpiOsPrintf ("\n");
+
+    /* _PRT info */
+
+    AcpiOsPrintf ("_PRT: %p\n", TempNode);
+
+    /* Dump _ADR, _HID, _UID, _CID */
+
+    if (Info->Valid & ACPI_VALID_ADR)
+    {
+        AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Info->Address));
+    }
+    else
+    {
+        AcpiOsPrintf ("_ADR: <Not Present>\n");
+    }
+
+    if (Info->Valid & ACPI_VALID_HID)
+    {
+        AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String);
+    }
+    else
+    {
+        AcpiOsPrintf ("_HID: <Not Present>\n");
+    }
+
+    if (Info->Valid & ACPI_VALID_UID)
+    {
+        AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String);
+    }
+    else
+    {
+        AcpiOsPrintf ("_UID: <Not Present>\n");
+    }
+
+    if (Info->Valid & ACPI_VALID_CID)
+    {
+        for (i = 0; i < Info->CompatibleIdList.Count; i++)
+        {
+            AcpiOsPrintf ("_CID: %s\n",
+                Info->CompatibleIdList.Ids[i].String);
+        }
+    }
+    else
+    {
+        AcpiOsPrintf ("_CID: <Not Present>\n");
+    }
+
+    ACPI_FREE (Info);
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbGetBusInfo
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display info about system busses.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbGetBusInfo (
+    void)
+{
+    /* Search all nodes in namespace */
+
+    (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+                    AcpiDbBusWalk, NULL, NULL, NULL);
+}
+
+#endif /* ACPI_DEBUGGER */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/debugger/dbstats.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/debugger/dbstats.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,549 @@
+/*******************************************************************************
+ *
+ * Module Name: dbstats - Generation and display of ACPI table statistics
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#ifdef ACPI_DEBUGGER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dbstats")
+
+/* Local prototypes */
+
+static void
+AcpiDbCountNamespaceObjects (
+    void);
+
+static void
+AcpiDbEnumerateObject (
+    ACPI_OPERAND_OBJECT     *ObjDesc);
+
+static ACPI_STATUS
+AcpiDbClassifyOneObject (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue);
+
+#if defined ACPI_DBG_TRACK_ALLOCATIONS || defined ACPI_USE_LOCAL_CACHE
+static void
+AcpiDbListInfo (
+    ACPI_MEMORY_LIST        *List);
+#endif
+
+
+/*
+ * 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
+
+
+#if defined ACPI_DBG_TRACK_ALLOCATIONS || defined ACPI_USE_LOCAL_CACHE
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbListInfo
+ *
+ * PARAMETERS:  List            - Memory list/cache to be displayed
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display information about the input memory list or cache.
+ *
+ ******************************************************************************/
+
+static void
+AcpiDbListInfo (
+    ACPI_MEMORY_LIST        *List)
+{
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+    UINT32                  Outstanding;
+#endif
+
+    AcpiOsPrintf ("\n%s\n", List->ListName);
+
+    /* MaxDepth > 0 indicates a cache object */
+
+    if (List->MaxDepth > 0)
+    {
+        AcpiOsPrintf (
+            "    Cache: [Depth    MaxD Avail  Size]                %8.2X %8.2X %8.2X %8.2X\n",
+            List->CurrentDepth,
+            List->MaxDepth,
+            List->MaxDepth - List->CurrentDepth,
+            (List->CurrentDepth * List->ObjectSize));
+    }
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+    if (List->MaxDepth > 0)
+    {
+        AcpiOsPrintf (
+            "    Cache: [Requests Hits Misses ObjSize]             %8.2X %8.2X %8.2X %8.2X\n",
+            List->Requests,
+            List->Hits,
+            List->Requests - List->Hits,
+            List->ObjectSize);
+    }
+
+    Outstanding = AcpiDbGetCacheInfo (List);
+
+    if (List->ObjectSize)
+    {
+        AcpiOsPrintf (
+            "    Mem:   [Alloc    Free Max    CurSize Outstanding] %8.2X %8.2X %8.2X %8.2X %8.2X\n",
+            List->TotalAllocated,
+            List->TotalFreed,
+            List->MaxOccupied,
+            Outstanding * List->ObjectSize,
+            Outstanding);
+    }
+    else
+    {
+        AcpiOsPrintf (
+            "    Mem:   [Alloc Free Max CurSize Outstanding Total] %8.2X %8.2X %8.2X %8.2X %8.2X %8.2X\n",
+            List->TotalAllocated,
+            List->TotalFreed,
+            List->MaxOccupied,
+            List->CurrentTotalSize,
+            Outstanding,
+            List->TotalSize);
+    }
+#endif
+}
+#endif
+
+
+/*******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+static void
+AcpiDbEnumerateObject (
+    ACPI_OPERAND_OBJECT     *ObjDesc)
+{
+    UINT32                  i;
+
+
+    if (!ObjDesc)
+    {
+        return;
+    }
+
+    /* Enumerate this object first */
+
+    AcpiGbl_NumObjects++;
+
+    if (ObjDesc->Common.Type > ACPI_TYPE_NS_NODE_MAX)
+    {
+        AcpiGbl_ObjTypeCountMisc++;
+    }
+    else
+    {
+        AcpiGbl_ObjTypeCount [ObjDesc->Common.Type]++;
+    }
+
+    /* Count the sub-objects */
+
+    switch (ObjDesc->Common.Type)
+    {
+    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.SystemNotify);
+        AcpiDbEnumerateObject (ObjDesc->Device.DeviceNotify);
+        AcpiDbEnumerateObject (ObjDesc->Device.Handler);
+        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.Handler);
+        break;
+
+    case ACPI_TYPE_POWER:
+
+        AcpiDbEnumerateObject (ObjDesc->PowerResource.SystemNotify);
+        AcpiDbEnumerateObject (ObjDesc->PowerResource.DeviceNotify);
+        break;
+
+    case ACPI_TYPE_PROCESSOR:
+
+        AcpiDbEnumerateObject (ObjDesc->Processor.SystemNotify);
+        AcpiDbEnumerateObject (ObjDesc->Processor.DeviceNotify);
+        AcpiDbEnumerateObject (ObjDesc->Processor.Handler);
+        break;
+
+    case ACPI_TYPE_THERMAL:
+
+        AcpiDbEnumerateObject (ObjDesc->ThermalZone.SystemNotify);
+        AcpiDbEnumerateObject (ObjDesc->ThermalZone.DeviceNotify);
+        AcpiDbEnumerateObject (ObjDesc->ThermalZone.Handler);
+        break;
+
+    default:
+        break;
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbClassifyOneObject
+ *
+ * PARAMETERS:  Callback for WalkNamespace
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Enumerate both the object descriptor (including subobjects) and
+ *              the parent namespace node.
+ *
+ ******************************************************************************/
+
+static 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;
+
+
+#ifdef ACPI_FUTURE_IMPLEMENTATION
+
+    /* 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);
+#endif
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbCountNamespaceObjects
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Count and classify the entire namespace, including all
+ *              namespace nodes and attached objects.
+ *
+ ******************************************************************************/
+
+static 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, NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbDisplayStatistics
+ *
+ * PARAMETERS:  TypeArg         - Subcommand
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Display various statistics
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDbDisplayStatistics (
+    char                    *TypeArg)
+{
+    UINT32                  i;
+    UINT32                  Temp;
+
+
+    if (!TypeArg)
+    {
+        AcpiOsPrintf ("The following subcommands are available:\n    ALLOCATIONS, OBJECTS, MEMORY, MISC, SIZES, TABLES\n");
+        return (AE_OK);
+    }
+
+    AcpiUtStrupr (TypeArg);
+    Temp = AcpiDbMatchArgument (TypeArg, AcpiDbStatTypes);
+    if (Temp == (UINT32) -1)
+    {
+        AcpiOsPrintf ("Invalid or unsupported argument\n");
+        return (AE_OK);
+    }
+
+
+    switch (Temp)
+    {
+    case CMD_STAT_ALLOCATIONS:
+
+#ifdef ACPI_DBG_TRACK_ALLOCATIONS
+        AcpiUtDumpAllocationInfo ();
+#endif
+        break;
+
+    case CMD_STAT_TABLES:
+
+        AcpiOsPrintf ("ACPI Table Information (not implemented):\n\n");
+        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 Statistics (all in hex)---------\n");
+
+        AcpiDbListInfo (AcpiGbl_GlobalList);
+        AcpiDbListInfo (AcpiGbl_NsNodeList);
+#endif
+
+#ifdef ACPI_USE_LOCAL_CACHE
+        AcpiOsPrintf ("\n----Cache Statistics (all in hex)---------\n");
+        AcpiDbListInfo (AcpiGbl_OperandCache);
+        AcpiDbListInfo (AcpiGbl_PsNodeCache);
+        AcpiDbListInfo (AcpiGbl_PsNodeExtCache);
+        AcpiDbListInfo (AcpiGbl_StateCache);
+#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 < ACPI_NUM_MUTEX; i++)
+        {
+            AcpiOsPrintf ("%-28s:       % 7ld\n",
+                AcpiUtGetMutexName (i), AcpiGbl_MutexInfo[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 ("Notify           %3d\n", sizeof (ACPI_OBJECT_NOTIFY_HANDLER));
+        AcpiOsPrintf ("AddressSpace     %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));
+        AcpiOsPrintf ("AcpiObject       %3d\n", sizeof (ACPI_OBJECT));
+
+        break;
+
+
+    case CMD_STAT_STACK:
+#if defined(ACPI_DEBUG_OUTPUT)
+
+        Temp = (UINT32) ACPI_PTR_DIFF (AcpiGbl_EntryStackPointer, AcpiGbl_LowestStackPointer);
+
+        AcpiOsPrintf ("\nSubsystem Stack Usage:\n\n");
+        AcpiOsPrintf ("Entry Stack Pointer          %p\n", AcpiGbl_EntryStackPointer);
+        AcpiOsPrintf ("Lowest Stack Pointer         %p\n", AcpiGbl_LowestStackPointer);
+        AcpiOsPrintf ("Stack Use                    %X (%u)\n", Temp, Temp);
+        AcpiOsPrintf ("Deepest Procedure Nesting    %u\n", AcpiGbl_DeepestNesting);
+#endif
+        break;
+
+    default:
+        break;
+    }
+
+    AcpiOsPrintf ("\n");
+    return (AE_OK);
+}
+
+#endif /* ACPI_DEBUGGER  */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/debugger/dbutils.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/debugger/dbutils.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,526 @@
+/*******************************************************************************
+ *
+ * Module Name: dbutils - AML debugger utilities
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+
+
+#ifdef ACPI_DEBUGGER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dbutils")
+
+/* Local prototypes */
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+ACPI_STATUS
+AcpiDbSecondPassParse (
+    ACPI_PARSE_OBJECT       *Root);
+
+void
+AcpiDbDumpBuffer (
+    UINT32                  Address);
+#endif
+
+static char                 *Converter = "0123456789ABCDEF";
+
+
+/*******************************************************************************
+ *
+ * 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.  Also 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:    AcpiDbDumpExternalObject
+ *
+ * PARAMETERS:  ObjDesc         - External ACPI object to dump
+ *              Level           - Nesting level.
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Dump the contents of an ACPI external object
+ *
+ ******************************************************************************/
+
+void
+AcpiDbDumpExternalObject (
+    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 ("[Null Object] (Type=0)\n");
+        break;
+
+
+    case ACPI_TYPE_INTEGER:
+
+        AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n",
+                    ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
+        break;
+
+
+    case ACPI_TYPE_STRING:
+
+        AcpiOsPrintf ("[String] Length %.2X = ", ObjDesc->String.Length);
+        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)
+        {
+            if (ObjDesc->Buffer.Length > 16)
+            {
+                AcpiOsPrintf ("\n");
+            }
+            AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer),
+                    ObjDesc->Buffer.Length, DB_BYTE_DISPLAY, _COMPONENT);
+        }
+        else
+        {
+            AcpiOsPrintf ("\n");
+        }
+        break;
+
+
+    case ACPI_TYPE_PACKAGE:
+
+        AcpiOsPrintf ("[Package] Contains %u Elements:\n",
+                ObjDesc->Package.Count);
+
+        for (i = 0; i < ObjDesc->Package.Count; i++)
+        {
+            AcpiDbDumpExternalObject (&ObjDesc->Package.Elements[i], Level+1);
+        }
+        break;
+
+
+    case ACPI_TYPE_LOCAL_REFERENCE:
+
+        AcpiOsPrintf ("[Object Reference] = ");
+        AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL);
+        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;
+    }
+
+    AcpiUtStrupr (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:    AcpiDbLocalNsLookup
+ *
+ * PARAMETERS:  Name            - Name to lookup
+ *
+ * RETURN:      Pointer to a namespace node, null on failure
+ *
+ * DESCRIPTION: Lookup a name in the ACPI namespace
+ *
+ * Note: Currently begins search from the root.  Could be enhanced to use
+ * the current prefix (scope) node as the search beginning point.
+ *
+ ******************************************************************************/
+
+ACPI_NAMESPACE_NODE *
+AcpiDbLocalNsLookup (
+    char                    *Name)
+{
+    char                    *InternalPath;
+    ACPI_STATUS             Status;
+    ACPI_NAMESPACE_NODE     *Node = NULL;
+
+
+    AcpiDbPrepNamestring (Name);
+
+    /* Build an internal namestring */
+
+    Status = AcpiNsInternalizeName (Name, &InternalPath);
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiOsPrintf ("Invalid namestring: %s\n", Name);
+        return (NULL);
+    }
+
+    /*
+     * Lookup the name.
+     * (Uses root node as the search starting point)
+     */
+    Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+                    ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiOsPrintf ("Could not locate name: %s, %s\n",
+                Name, AcpiFormatException (Status));
+    }
+
+    ACPI_FREE (InternalPath);
+    return (Node);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbUInt32ToHexString
+ *
+ * PARAMETERS:  Value           - The value to be converted to string
+ *              Buffer          - Buffer for result (not less than 11 bytes)
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Convert the unsigned 32-bit value to the hexadecimal image
+ *
+ * NOTE: It is the caller's responsibility to ensure that the length of buffer
+ *       is sufficient.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbUInt32ToHexString (
+    UINT32                  Value,
+    char                    *Buffer)
+{
+    int                     i;
+
+
+    if (Value == 0)
+    {
+        ACPI_STRCPY (Buffer, "0");
+        return;
+    }
+
+    Buffer[8] = '\0';
+
+    for (i = 7; i >= 0; i--)
+    {
+        Buffer[i] = Converter [Value & 0x0F];
+        Value = Value >> 4;
+    }
+}
+
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+/*******************************************************************************
+ *
+ * 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 (0, 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:    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);
+}
+#endif
+
+#endif /* ACPI_DEBUGGER */
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/debugger/dbxface.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/debugger/dbxface.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,542 @@
+/*******************************************************************************
+ *
+ * Module Name: dbxface - AML Debugger external interfaces
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+
+
+#ifdef ACPI_DEBUGGER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dbxface")
+
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiDbStartCommand (
+    ACPI_WALK_STATE         *WalkState,
+    ACPI_PARSE_OBJECT       *Op);
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+void
+AcpiDbMethodEnd (
+    ACPI_WALK_STATE         *WalkState);
+#endif
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbStartCommand
+ *
+ * PARAMETERS:  WalkState       - Current walk
+ *              Op              - Current executing Op, from AML interpreter
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Enter debugger command loop
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbStartCommand (
+    ACPI_WALK_STATE         *WalkState,
+    ACPI_PARSE_OBJECT       *Op)
+{
+    ACPI_STATUS             Status;
+
+
+    /* TBD: [Investigate] are there 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 */
+
+            Status = AcpiOsGetLine (AcpiGbl_DbLineBuf,
+                ACPI_DB_LINE_BUFFER_SIZE, NULL);
+            if (ACPI_FAILURE (Status))
+            {
+                ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));
+                return (Status);
+            }
+        }
+
+        Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op);
+    }
+
+    /* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */
+
+    return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbSingleStep
+ *
+ * PARAMETERS:  WalkState       - Current walk
+ *              Op              - Current executing op (from aml interpreter)
+ *              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)
+    {
+        /* Force no more single stepping while executing called method */
+
+        AcpiGbl_CmSingleStep = FALSE;
+
+        /*
+         * Set the breakpoint on/before the call, it will stop execution
+         * as soon as we return
+         */
+        WalkState->MethodBreakpoint = 1;  /* Must be non-zero! */
+    }
+
+
+    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 = AcpiOsExecute (OSL_DEBUGGER_THREAD, 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:      None
+ *
+ * DESCRIPTION: Stop debugger
+ *
+ ******************************************************************************/
+
+void
+AcpiDbTerminate (
+    void)
+{
+
+    if (AcpiGbl_DbBuffer)
+    {
+        AcpiOsFree (AcpiGbl_DbBuffer);
+    }
+}
+
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbMethodEnd
+ *
+ * PARAMETERS:  WalkState       - Current walk
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Called at method termination
+ *
+ ******************************************************************************/
+
+void
+AcpiDbMethodEnd (
+    ACPI_WALK_STATE         *WalkState)
+{
+
+    if (!AcpiGbl_CmSingleStep)
+    {
+        return;
+    }
+
+    AcpiOsPrintf ("<Method Terminating>\n");
+
+    AcpiDbStartCommand (WalkState, NULL);
+}
+#endif
+
+#endif /* ACPI_DEBUGGER */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/disassembler/dmbuffer.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,542 @@
+/*******************************************************************************
+ *
+ * Module Name: dmbuffer - AML disassembler, buffer and string support
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+#include <contrib/dev/acpica/include/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+
+
+#ifdef ACPI_DISASSEMBLER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dmbuffer")
+
+/* Local prototypes */
+
+static void
+AcpiDmUnicode (
+    ACPI_PARSE_OBJECT       *Op);
+
+static void
+AcpiDmIsEisaIdElement (
+    ACPI_PARSE_OBJECT       *Op);
+
+
+/*******************************************************************************
+ *
+ * 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 an AML "ByteList" in Hex format. 8 bytes per line, prefixed
+ *              with the hex buffer offset.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDisasmByteList (
+    UINT32                  Level,
+    UINT8                   *ByteData,
+    UINT32                  ByteCount)
+{
+    UINT32                  i;
+
+
+    if (!ByteCount)
+    {
+        return;
+    }
+
+    /* Dump the byte list */
+
+    for (i = 0; i < ByteCount; i++)
+    {
+        /* New line every 8 bytes */
+
+        if (((i % 8) == 0) && (i < ByteCount))
+        {
+            if (i > 0)
+            {
+                AcpiOsPrintf ("\n");
+            }
+
+            AcpiDmIndent (Level);
+            if (ByteCount > 8)
+            {
+                AcpiOsPrintf ("/* %04X */  ", i);
+            }
+        }
+
+        AcpiOsPrintf (" 0x%2.2X", (UINT32) ByteData[i]);
+
+        /* Add comma if there are more bytes to display */
+
+        if (i < (ByteCount -1))
+        {
+            AcpiOsPrintf (",");
+        }
+    }
+
+    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 = (UINT32) Op->Common.Value.Integer;
+
+    /*
+     * 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:
+
+        AcpiDmResourceTemplate (Info, Op->Common.Parent, 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;
+    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 = (UINT32) NextOp->Common.Value.Integer;
+    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[(ACPI_SIZE) 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, FALSE otherwise
+ *
+ * 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 = (UINT32) NextOp->Common.Value.Integer;
+
+    /* 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).
+ *
+ ******************************************************************************/
+
+static 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 (((UINT32) Op->Common.Value.Integer));
+
+
+    AcpiOsPrintf ("\"");
+
+    /* Write every other byte as an ASCII character */
+
+    for (i = 0; i < (WordCount - 1); i++)
+    {
+        AcpiOsPrintf ("%c", (int) WordData[i]);
+    }
+
+    AcpiOsPrintf ("\")");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmIsEisaIdElement
+ *
+ * PARAMETERS:  Op              - Op to be examined
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Determine if an Op (argument to _HID or _CID) can be converted
+ *              to an EISA ID.
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmIsEisaIdElement (
+    ACPI_PARSE_OBJECT       *Op)
+{
+    UINT32                  BigEndianId;
+    UINT32                  Prefix[3];
+    UINT32                  i;
+
+
+    /* The parameter must be either a word or a dword */
+
+    if ((Op->Common.AmlOpcode != AML_DWORD_OP) &&
+        (Op->Common.AmlOpcode != AML_WORD_OP))
+    {
+        return;
+    }
+
+    /* Swap from little-endian to big-endian to simplify conversion */
+
+    BigEndianId = AcpiUtDwordByteSwap ((UINT32) Op->Common.Value.Integer);
+
+    /* 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 */
+
+    Op->Common.DisasmOpcode = ACPI_DASM_EISAID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmIsEisaId
+ *
+ * PARAMETERS:  Op              - Op to be examined
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Determine if a Name() Op can be converted to an EisaId.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmIsEisaId (
+    ACPI_PARSE_OBJECT       *Op)
+{
+    UINT32                  Name;
+    ACPI_PARSE_OBJECT       *NextOp;
+
+
+    /* Get the NameSegment */
+
+    Name = AcpiPsGetName (Op);
+    if (!Name)
+    {
+        return;
+    }
+
+    NextOp = AcpiPsGetDepthNext (NULL, Op);
+    if (!NextOp)
+    {
+        return;
+    }
+
+    /* Check for _HID - has one argument */
+
+    if (ACPI_COMPARE_NAME (&Name, METHOD_NAME__HID))
+    {
+        AcpiDmIsEisaIdElement (NextOp);
+        return;
+    }
+
+    /* Exit if not _CID */
+
+    if (!ACPI_COMPARE_NAME (&Name, METHOD_NAME__CID))
+    {
+        return;
+    }
+
+    /* _CID can contain a single argument or a package */
+
+    if (NextOp->Common.AmlOpcode != AML_PACKAGE_OP)
+    {
+        AcpiDmIsEisaIdElement (NextOp);
+        return;
+    }
+
+    /* _CID with Package: get the package length */
+
+    NextOp = AcpiPsGetDepthNext (NULL, NextOp);
+
+    /* Don't need to use the length, just walk the peer list */
+
+    NextOp = NextOp->Common.Next;
+    while (NextOp)
+    {
+        AcpiDmIsEisaIdElement (NextOp);
+        NextOp = NextOp->Common.Next;
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * 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 -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/disassembler/dmnames.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/disassembler/dmnames.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,453 @@
+/*******************************************************************************
+ *
+ * Module Name: dmnames - AML disassembler, names, namestrings, pathnames
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+
+
+#ifdef ACPI_DISASSEMBLER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dmnames")
+
+/* Local prototypes */
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+void
+AcpiDmDisplayPath (
+    ACPI_PARSE_OBJECT       *Op);
+#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 (
+    UINT32                  Name)
+{
+    UINT32                  i;
+    UINT32                  Length;
+    char                    NewName[4];
+
+
+    /* Copy name locally in case the original name is not writeable */
+
+    *ACPI_CAST_PTR (UINT32, &NewName[0]) = Name;
+
+    /* Ensure that the name is printable, even if we have to fix it */
+
+    AcpiUtRepairName (NewName);
+
+    /* Remove all trailing underscores from the name */
+
+    Length = ACPI_NAME_SIZE;
+    for (i = (ACPI_NAME_SIZE - 1); i != 0; i--)
+    {
+        if (NewName[i] == '_')
+        {
+            Length--;
+        }
+        else
+        {
+            break;
+        }
+    }
+
+    /* Dump the name, up to the start of the trailing underscores */
+
+    for (i = 0; i < Length; i++)
+    {
+        AcpiOsPrintf ("%c", NewName[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_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 and dump 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 (*ACPI_CAST_PTR (UINT32, Name));
+
+        SegCount--;
+        if (SegCount)
+        {
+            /* Not last name, append dot separator */
+
+            AcpiOsPrintf (".");
+        }
+        Name += ACPI_NAME_SIZE;
+    }
+}
+
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+/*******************************************************************************
+ *
+ * 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;
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmValidateName
+ *
+ * PARAMETERS:  Name            - 4 character ACPI name
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Lookup the name
+ *
+ ******************************************************************************/
+
+void
+AcpiDmValidateName (
+    char                    *Name,
+    ACPI_PARSE_OBJECT       *Op)
+{
+
+    if ((!Name) ||
+        (!Op->Common.Parent))
+    {
+        return;
+    }
+
+    if (!Op->Common.Node)
+    {
+        AcpiOsPrintf (
+            " /**** Name not found or not accessible from this scope ****/ ");
+    }
+
+    ACPI_PARSE_OBJECT       *TargetOp;
+
+
+    if ((!Name) ||
+        (!Op->Common.Parent))
+    {
+        return;
+    }
+
+    TargetOp = AcpiPsFind (Op, Name, 0, 0);
+    if (!TargetOp)
+    {
+        /*
+         * Didn't find the name in the parse tree.  This may be
+         * a problem, or it may simply be one of the predefined names
+         * (such as _OS_).  Rather than worry about looking up all
+         * the predefined names, just display the name as given
+         */
+        AcpiOsPrintf (
+            " /**** Name not found or not accessible from this scope ****/ ");
+    }
+}
+#endif
+
+#endif
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/disassembler/dmobject.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/disassembler/dmobject.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,589 @@
+/*******************************************************************************
+ *
+ * Module Name: dmobject - ACPI object decode and display
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+
+
+#ifdef ACPI_DISASSEMBLER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dmnames")
+
+/* Local prototypes */
+
+static void
+AcpiDmDecodeNode (
+    ACPI_NAMESPACE_NODE     *Node);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmDumpMethodInfo
+ *
+ * PARAMETERS:  Status          - Method execution status
+ *              WalkState       - Current state of the parse tree walk
+ *              Op              - Executing parse op
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Called when a method has been aborted because of an error.
+ *              Dumps the method execution stack, and the method locals/args,
+ *              and disassembles the AML opcode that failed.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDumpMethodInfo (
+    ACPI_STATUS             Status,
+    ACPI_WALK_STATE         *WalkState,
+    ACPI_PARSE_OBJECT       *Op)
+{
+    ACPI_PARSE_OBJECT       *Next;
+    ACPI_THREAD_STATE       *Thread;
+    ACPI_WALK_STATE         *NextWalkState;
+    ACPI_NAMESPACE_NODE     *PreviousMethod = NULL;
+
+
+    /* Ignore control codes, they are not errors */
+
+    if ((Status & AE_CODE_MASK) == AE_CODE_CONTROL)
+    {
+        return;
+    }
+
+    /* We may be executing a deferred opcode */
+
+    if (WalkState->DeferredNode)
+    {
+        AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
+        return;
+    }
+
+    /*
+     * If there is no Thread, we are not actually executing a method.
+     * This can happen when the iASL compiler calls the interpreter
+     * to perform constant folding.
+     */
+    Thread = WalkState->Thread;
+    if (!Thread)
+    {
+        return;
+    }
+
+    /* Display exception and method name */
+
+    AcpiOsPrintf ("\n**** Exception %s during execution of method ",
+        AcpiFormatException (Status));
+    AcpiNsPrintNodePathname (WalkState->MethodNode, NULL);
+
+    /* Display stack of executing methods */
+
+    AcpiOsPrintf ("\n\nMethod Execution Stack:\n");
+    NextWalkState = Thread->WalkStateList;
+
+    /* Walk list of linked walk states */
+
+    while (NextWalkState)
+    {
+        AcpiOsPrintf ("    Method [%4.4s] executing: ",
+                AcpiUtGetNodeName (NextWalkState->MethodNode));
+
+        /* First method is the currently executing method */
+
+        if (NextWalkState == WalkState)
+        {
+            if (Op)
+            {
+                /* Display currently executing ASL statement */
+
+                Next = Op->Common.Next;
+                Op->Common.Next = NULL;
+
+                AcpiDmDisassemble (NextWalkState, Op, ACPI_UINT32_MAX);
+                Op->Common.Next = Next;
+            }
+        }
+        else
+        {
+            /*
+             * This method has called another method
+             * NOTE: the method call parse subtree is already deleted at this
+             * point, so we cannot disassemble the method invocation.
+             */
+            AcpiOsPrintf ("Call to method ");
+            AcpiNsPrintNodePathname (PreviousMethod, NULL);
+        }
+
+        PreviousMethod = NextWalkState->MethodNode;
+        NextWalkState = NextWalkState->Next;
+        AcpiOsPrintf ("\n");
+    }
+
+    /* Display the method locals and arguments */
+
+    AcpiOsPrintf ("\n");
+    AcpiDmDisplayLocals (WalkState);
+    AcpiOsPrintf ("\n");
+    AcpiDmDisplayArguments (WalkState);
+    AcpiOsPrintf ("\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmDecodeInternalObject
+ *
+ * PARAMETERS:  ObjDesc         - Object to be displayed
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Short display of an internal object.  Numbers/Strings/Buffers.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDecodeInternalObject (
+    ACPI_OPERAND_OBJECT     *ObjDesc)
+{
+    UINT32                  i;
+
+
+    if (!ObjDesc)
+    {
+        AcpiOsPrintf (" Uninitialized");
+        return;
+    }
+
+    if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
+    {
+        AcpiOsPrintf (" %p [%s]", ObjDesc, AcpiUtGetDescriptorName (ObjDesc));
+        return;
+    }
+
+    AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc));
+
+    switch (ObjDesc->Common.Type)
+    {
+    case ACPI_TYPE_INTEGER:
+
+        AcpiOsPrintf (" %8.8X%8.8X",
+                ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
+        break;
+
+
+    case ACPI_TYPE_STRING:
+
+        AcpiOsPrintf ("(%u) \"%.24s",
+                ObjDesc->String.Length, ObjDesc->String.Pointer);
+
+        if (ObjDesc->String.Length > 24)
+        {
+            AcpiOsPrintf ("...");
+        }
+        else
+        {
+            AcpiOsPrintf ("\"");
+        }
+        break;
+
+
+    case ACPI_TYPE_BUFFER:
+
+        AcpiOsPrintf ("(%u)", 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:    AcpiDmDecodeNode
+ *
+ * PARAMETERS:  Node        - Object to be displayed
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Short display of a namespace node
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmDecodeNode (
+    ACPI_NAMESPACE_NODE     *Node)
+{
+
+    AcpiOsPrintf ("<Node>            Name %4.4s",
+            AcpiUtGetNodeName (Node));
+
+    if (Node->Flags & ANOBJ_METHOD_ARG)
+    {
+        AcpiOsPrintf (" [Method Arg]");
+    }
+    if (Node->Flags & ANOBJ_METHOD_LOCAL)
+    {
+        AcpiOsPrintf (" [Method Local]");
+    }
+
+    switch (Node->Type)
+    {
+    /* These types have no attached object */
+
+    case ACPI_TYPE_DEVICE:
+        AcpiOsPrintf (" Device");
+        break;
+
+    case ACPI_TYPE_THERMAL:
+        AcpiOsPrintf (" Thermal Zone");
+        break;
+
+    default:
+        AcpiDmDecodeInternalObject (AcpiNsGetAttachedObject (Node));
+        break;
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmDisplayInternalObject
+ *
+ * PARAMETERS:  ObjDesc         - Object to be displayed
+ *              WalkState       - Current walk state
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Short display of an internal object
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDisplayInternalObject (
+    ACPI_OPERAND_OBJECT     *ObjDesc,
+    ACPI_WALK_STATE         *WalkState)
+{
+    UINT8                   Type;
+
+
+    AcpiOsPrintf ("%p ", ObjDesc);
+
+    if (!ObjDesc)
+    {
+        AcpiOsPrintf ("<Null Object>\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:
+
+        AcpiDmDecodeNode ((ACPI_NAMESPACE_NODE *) ObjDesc);
+        break;
+
+
+    case ACPI_DESC_TYPE_OPERAND:
+
+        Type = ObjDesc->Common.Type;
+        if (Type > ACPI_TYPE_LOCAL_MAX)
+        {
+            AcpiOsPrintf (" Type %X [Invalid Type]", (UINT32) Type);
+            return;
+        }
+
+        /* Decode the ACPI object type */
+
+        switch (ObjDesc->Common.Type)
+        {
+        case ACPI_TYPE_LOCAL_REFERENCE:
+
+            AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (ObjDesc));
+
+            /* Decode the refererence */
+
+            switch (ObjDesc->Reference.Class)
+            {
+            case ACPI_REFCLASS_LOCAL:
+
+                AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
+                if (WalkState)
+                {
+                    ObjDesc = WalkState->LocalVariables
+                                [ObjDesc->Reference.Value].Object;
+                    AcpiOsPrintf ("%p", ObjDesc);
+                    AcpiDmDecodeInternalObject (ObjDesc);
+                }
+                break;
+
+
+            case ACPI_REFCLASS_ARG:
+
+                AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
+                if (WalkState)
+                {
+                    ObjDesc = WalkState->Arguments
+                                [ObjDesc->Reference.Value].Object;
+                    AcpiOsPrintf ("%p", ObjDesc);
+                    AcpiDmDecodeInternalObject (ObjDesc);
+                }
+                break;
+
+
+            case ACPI_REFCLASS_INDEX:
+
+                switch (ObjDesc->Reference.TargetType)
+                {
+                case ACPI_TYPE_BUFFER_FIELD:
+
+                    AcpiOsPrintf ("%p", ObjDesc->Reference.Object);
+                    AcpiDmDecodeInternalObject (ObjDesc->Reference.Object);
+                    break;
+
+                case ACPI_TYPE_PACKAGE:
+
+                    AcpiOsPrintf ("%p", ObjDesc->Reference.Where);
+                    if (!ObjDesc->Reference.Where)
+                    {
+                        AcpiOsPrintf (" Uninitialized WHERE pointer");
+                    }
+                    else
+                    {
+                        AcpiDmDecodeInternalObject (
+                            *(ObjDesc->Reference.Where));
+                    }
+                    break;
+
+                default:
+
+                    AcpiOsPrintf ("Unknown index target type");
+                    break;
+                }
+                break;
+
+
+            case ACPI_REFCLASS_REFOF:
+
+                if (!ObjDesc->Reference.Object)
+                {
+                    AcpiOsPrintf ("Uninitialized reference subobject pointer");
+                    break;
+                }
+
+                /* Reference can be to a Node or an Operand object */
+
+                switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc->Reference.Object))
+                {
+                case ACPI_DESC_TYPE_NAMED:
+                    AcpiDmDecodeNode (ObjDesc->Reference.Object);
+                    break;
+
+                case ACPI_DESC_TYPE_OPERAND:
+                    AcpiDmDecodeInternalObject (ObjDesc->Reference.Object);
+                    break;
+
+                default:
+                    break;
+                }
+                break;
+
+
+            case ACPI_REFCLASS_NAME:
+
+                AcpiDmDecodeNode (ObjDesc->Reference.Node);
+                break;
+
+
+            case ACPI_REFCLASS_DEBUG:
+            case ACPI_REFCLASS_TABLE:
+
+                AcpiOsPrintf ("\n");
+                break;
+
+
+            default:    /* Unknown reference class */
+
+                AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class);
+                break;
+            }
+            break;
+
+
+        default:
+
+            AcpiOsPrintf ("<Obj>            ");
+            AcpiDmDecodeInternalObject (ObjDesc);
+            break;
+        }
+        break;
+
+
+    default:
+
+        AcpiOsPrintf ("<Not a valid ACPI Object Descriptor> [%s]",
+            AcpiUtGetDescriptorName (ObjDesc));
+        break;
+    }
+
+    AcpiOsPrintf ("\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmDisplayLocals
+ *
+ * PARAMETERS:  WalkState       - State for current method
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display all locals for the currently running control method
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDisplayLocals (
+    ACPI_WALK_STATE         *WalkState)
+{
+    UINT32                  i;
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_NAMESPACE_NODE     *Node;
+
+
+    ObjDesc = WalkState->MethodDesc;
+    Node    = WalkState->MethodNode;
+    if (!Node)
+    {
+        AcpiOsPrintf (
+            "No method node (Executing subtree for buffer or opregion)\n");
+        return;
+    }
+
+    if (Node->Type != ACPI_TYPE_METHOD)
+    {
+        AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
+        return;
+    }
+
+    AcpiOsPrintf ("Local Variables for method [%4.4s]:\n",
+            AcpiUtGetNodeName (Node));
+
+    for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
+    {
+        ObjDesc = WalkState->LocalVariables[i].Object;
+        AcpiOsPrintf ("    Local%X: ", i);
+        AcpiDmDisplayInternalObject (ObjDesc, WalkState);
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmDisplayArguments
+ *
+ * PARAMETERS:  WalkState       - State for current method
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display all arguments for the currently running control method
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDisplayArguments (
+    ACPI_WALK_STATE         *WalkState)
+{
+    UINT32                  i;
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_NAMESPACE_NODE     *Node;
+
+
+    ObjDesc = WalkState->MethodDesc;
+    Node    = WalkState->MethodNode;
+    if (!Node)
+    {
+        AcpiOsPrintf (
+            "No method node (Executing subtree for buffer or opregion)\n");
+        return;
+    }
+
+    if (Node->Type != ACPI_TYPE_METHOD)
+    {
+        AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
+        return;
+    }
+
+    AcpiOsPrintf (
+        "Arguments for Method [%4.4s]:  (%X arguments defined, max concurrency = %X)\n",
+        AcpiUtGetNodeName (Node), ObjDesc->Method.ParamCount, ObjDesc->Method.SyncLevel);
+
+    for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
+    {
+        ObjDesc = WalkState->Arguments[i].Object;
+        AcpiOsPrintf ("    Arg%u:   ", i);
+        AcpiDmDisplayInternalObject (ObjDesc, WalkState);
+    }
+}
+
+#endif
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/disassembler/dmopcode.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/disassembler/dmopcode.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,607 @@
+/*******************************************************************************
+ *
+ * Module Name: dmopcode - AML disassembler, specific AML opcodes
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+
+#ifdef ACPI_DISASSEMBLER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dmopcode")
+
+/* Local prototypes */
+
+static void
+AcpiDmMatchKeyword (
+    ACPI_PARSE_OBJECT       *Op);
+
+
+/*******************************************************************************
+ *
+ * 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 = (UINT8) Op->Common.Value.Integer;
+    Args = Flags & 0x07;
+
+    /* Mark the Op as completed */
+
+    Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+
+    /* 1) Method argument count */
+
+    AcpiOsPrintf (", %u, ", Args);
+
+    /* 2) Serialize rule */
+
+    if (!(Flags & 0x08))
+    {
+        AcpiOsPrintf ("Not");
+    }
+
+    AcpiOsPrintf ("Serialized");
+
+    /* 3) SyncLevel */
+
+    if (Flags & 0xF0)
+    {
+        AcpiOsPrintf (", %u", 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;
+
+
+    Op = Op->Common.Next;
+    Flags = (UINT8) Op->Common.Value.Integer;
+
+    /* Mark the Op as completed */
+
+    Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+
+    AcpiOsPrintf ("%s, ", AcpiGbl_AccessTypes [Flags & 0x07]);
+    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 ((UINT8) Op->Common.Value.Integer);
+}
+
+
+/*******************************************************************************
+ *
+ * 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
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmMatchKeyword (
+    ACPI_PARSE_OBJECT       *Op)
+{
+
+
+    if (((UINT32) Op->Common.Value.Integer) > ACPI_MAX_MATCH_OPCODE)
+    {
+        AcpiOsPrintf ("/* Unknown Match Keyword encoding */");
+    }
+    else
+    {
+        AcpiOsPrintf ("%s", ACPI_CAST_PTR (char,
+            AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer]));
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * 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;
+    ACPI_PARSE_OBJECT       *Child;
+    ACPI_STATUS             Status;
+    UINT8                   *Aml;
+
+
+    if (!Op)
+    {
+        AcpiOsPrintf ("<NULL OP PTR>");
+        return;
+    }
+
+    switch (Op->Common.DisasmOpcode)
+    {
+    case ACPI_DASM_MATCHOP:
+
+        AcpiDmMatchKeyword (Op);
+        return;
+
+    case ACPI_DASM_LNOT_SUFFIX:
+        switch (Op->Common.AmlOpcode)
+        {
+        case AML_LEQUAL_OP:
+            AcpiOsPrintf ("LNotEqual");
+            break;
+
+        case AML_LGREATER_OP:
+            AcpiOsPrintf ("LLessEqual");
+            break;
+
+        case AML_LLESS_OP:
+            AcpiOsPrintf ("LGreaterEqual");
+            break;
+
+        default:
+            break;
+        }
+        Op->Common.DisasmOpcode = 0;
+        Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+        return;
+
+    default:
+        break;
+    }
+
+
+    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
+
+    /* The op and arguments */
+
+    switch (Op->Common.AmlOpcode)
+    {
+    case AML_LNOT_OP:
+
+        Child = Op->Common.Value.Arg;
+        if ((Child->Common.AmlOpcode == AML_LEQUAL_OP) ||
+            (Child->Common.AmlOpcode == AML_LGREATER_OP) ||
+            (Child->Common.AmlOpcode == AML_LLESS_OP))
+        {
+            Child->Common.DisasmOpcode = ACPI_DASM_LNOT_SUFFIX;
+            Op->Common.DisasmOpcode = ACPI_DASM_LNOT_PREFIX;
+        }
+        else
+        {
+            AcpiOsPrintf ("%s", OpInfo->Name);
+        }
+        break;
+
+    case AML_BYTE_OP:
+
+        AcpiOsPrintf ("0x%2.2X", (UINT32) Op->Common.Value.Integer);
+        break;
+
+
+    case AML_WORD_OP:
+
+        if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID)
+        {
+            AcpiDmEisaId ((UINT32) Op->Common.Value.Integer);
+        }
+        else
+        {
+            AcpiOsPrintf ("0x%4.4X", (UINT32) Op->Common.Value.Integer);
+        }
+        break;
+
+
+    case AML_DWORD_OP:
+
+        if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID)
+        {
+            AcpiDmEisaId ((UINT32) Op->Common.Value.Integer);
+        }
+        else
+        {
+            AcpiOsPrintf ("0x%8.8X", (UINT32) Op->Common.Value.Integer);
+        }
+        break;
+
+
+    case AML_QWORD_OP:
+
+        AcpiOsPrintf ("0x%8.8X%8.8X",
+            ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
+        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 (!AcpiGbl_NoResourceDisassembly)
+        {
+            Status = AcpiDmIsResourceTemplate (Op);
+            if (ACPI_SUCCESS (Status))
+            {
+                Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE;
+                AcpiOsPrintf ("ResourceTemplate");
+                break;
+            }
+            else if (Status == AE_AML_NO_RESOURCE_END_TAG)
+            {
+                AcpiOsPrintf ("/**** Is ResourceTemplate, but EndTag not at buffer end ****/ ");
+            }
+        }
+
+        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);
+        break;
+
+
+    case AML_INT_NAMEDFIELD_OP:
+
+        Length = AcpiDmDumpName (Op->Named.Name);
+        AcpiOsPrintf (",%*.s  %u", (unsigned) (5 - Length), " ",
+            (UINT32) Op->Common.Value.Integer);
+        AcpiDmCommaIfFieldMember (Op);
+
+        Info->BitOffset += (UINT32) Op->Common.Value.Integer;
+        break;
+
+
+    case AML_INT_RESERVEDFIELD_OP:
+
+        /* Offset() -- Must account for previous offsets */
+
+        Offset = (UINT32) Op->Common.Value.Integer;
+        Info->BitOffset += Offset;
+
+        if (Info->BitOffset % 8 == 0)
+        {
+            AcpiOsPrintf ("Offset (0x%.2X)", ACPI_DIV_8 (Info->BitOffset));
+        }
+        else
+        {
+            AcpiOsPrintf ("    ,   %u", Offset);
+        }
+
+        AcpiDmCommaIfFieldMember (Op);
+        break;
+
+
+    case AML_INT_ACCESSFIELD_OP:
+    case AML_INT_EXTACCESSFIELD_OP:
+
+        AcpiOsPrintf ("AccessAs (%s, ",
+            AcpiGbl_AccessTypes [(UINT32) (Op->Common.Value.Integer & 0x7)]);
+
+        AcpiDmDecodeAttribute ((UINT8) (Op->Common.Value.Integer >> 8));
+
+        if (Op->Common.AmlOpcode == AML_INT_EXTACCESSFIELD_OP)
+        {
+            AcpiOsPrintf (" (0x%2.2X)", (unsigned) ((Op->Common.Value.Integer >> 16) & 0xFF));
+        }
+
+        AcpiOsPrintf (")");
+        AcpiDmCommaIfFieldMember (Op);
+        break;
+
+
+    case AML_INT_CONNECTION_OP:
+
+        /*
+         * Two types of Connection() - one with a buffer object, the
+         * other with a namestring that points to a buffer object.
+         */
+        AcpiOsPrintf ("Connection (");
+        Child = Op->Common.Value.Arg;
+
+        if (Child->Common.AmlOpcode == AML_INT_BYTELIST_OP)
+        {
+            AcpiOsPrintf ("\n");
+
+            Aml = Child->Named.Data;
+            Length = (UINT32) Child->Common.Value.Integer;
+
+            Info->Level += 1;
+            Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE;
+            AcpiDmResourceTemplate (Info, Op->Common.Parent, Aml, Length);
+
+            Info->Level -= 1;
+            AcpiDmIndent (Info->Level);
+        }
+        else
+        {
+            AcpiDmNamestring (Child->Common.Value.Name);
+        }
+
+        AcpiOsPrintf (")");
+        AcpiDmCommaIfFieldMember (Op);
+        AcpiOsPrintf ("\n");
+
+        Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; /* for now, ignore in AcpiDmAscendingOp */
+        Child->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+        break;
+
+    case AML_INT_BYTELIST_OP:
+
+        AcpiDmByteList (Info, Op);
+        break;
+
+
+    case AML_INT_METHODCALL_OP:
+
+        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 */
+
+        AcpiOsPrintf ("%s", OpInfo->Name);
+
+
+#ifdef ACPI_DEBUGGER
+
+        if ((Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) &&
+            (WalkState) &&
+            (WalkState->Results) &&
+            (WalkState->ResultCount))
+        {
+            AcpiDmDecodeInternalObject (
+                WalkState->Results->Results.ObjDesc [
+                    (WalkState->ResultCount - 1) %
+                        ACPI_RESULTS_FRAME_OBJ_NUM]);
+        }
+#endif
+
+        break;
+    }
+}
+
+#endif  /* ACPI_DISASSEMBLER */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/disassembler/dmresrc.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/disassembler/dmresrc.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,434 @@
+/*******************************************************************************
+ *
+ * Module Name: dmresrc.c - Resource Descriptor disassembly
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+
+#ifdef ACPI_DISASSEMBLER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dbresrc")
+
+
+/* Dispatch tables for Resource disassembly functions */
+
+static ACPI_RESOURCE_HANDLER    AcpiGbl_DmResourceDispatch [] =
+{
+    /* Small descriptors */
+
+    NULL,                           /* 0x00, Reserved */
+    NULL,                           /* 0x01, Reserved */
+    NULL,                           /* 0x02, Reserved */
+    NULL,                           /* 0x03, Reserved */
+    AcpiDmIrqDescriptor,            /* 0x04, ACPI_RESOURCE_NAME_IRQ_FORMAT */
+    AcpiDmDmaDescriptor,            /* 0x05, ACPI_RESOURCE_NAME_DMA_FORMAT */
+    AcpiDmStartDependentDescriptor, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */
+    AcpiDmEndDependentDescriptor,   /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */
+    AcpiDmIoDescriptor,             /* 0x08, ACPI_RESOURCE_NAME_IO_PORT */
+    AcpiDmFixedIoDescriptor,        /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO_PORT */
+    AcpiDmFixedDmaDescriptor,       /* 0x0A, ACPI_RESOURCE_NAME_FIXED_DMA */
+    NULL,                           /* 0x0B, Reserved */
+    NULL,                           /* 0x0C, Reserved */
+    NULL,                           /* 0x0D, Reserved */
+    AcpiDmVendorSmallDescriptor,    /* 0x0E, ACPI_RESOURCE_NAME_SMALL_VENDOR */
+    NULL,                           /* 0x0F, ACPI_RESOURCE_NAME_END_TAG (not used) */
+
+    /* Large descriptors */
+
+    NULL,                           /* 0x00, Reserved */
+    AcpiDmMemory24Descriptor,       /* 0x01, ACPI_RESOURCE_NAME_MEMORY_24 */
+    AcpiDmGenericRegisterDescriptor,/* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */
+    NULL,                           /* 0x03, Reserved */
+    AcpiDmVendorLargeDescriptor,    /* 0x04, ACPI_RESOURCE_NAME_LARGE_VENDOR */
+    AcpiDmMemory32Descriptor,       /* 0x05, ACPI_RESOURCE_NAME_MEMORY_32 */
+    AcpiDmFixedMemory32Descriptor,  /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY_32 */
+    AcpiDmDwordDescriptor,          /* 0x07, ACPI_RESOURCE_NAME_DWORD_ADDRESS_SPACE */
+    AcpiDmWordDescriptor,           /* 0x08, ACPI_RESOURCE_NAME_WORD_ADDRESS_SPACE */
+    AcpiDmInterruptDescriptor,      /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_XRUPT */
+    AcpiDmQwordDescriptor,          /* 0x0A, ACPI_RESOURCE_NAME_QWORD_ADDRESS_SPACE */
+    AcpiDmExtendedDescriptor,       /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS_SPACE */
+    AcpiDmGpioDescriptor,           /* 0x0C, ACPI_RESOURCE_NAME_GPIO */
+    NULL,                           /* 0x0D, Reserved */
+    AcpiDmSerialBusDescriptor       /* 0x0E, ACPI_RESOURCE_NAME_SERIAL_BUS */
+};
+
+
+/* Only used for single-threaded applications */
+/* TBD: remove when name is passed as parameter to the dump functions */
+
+static UINT32               ResourceName;
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmDescriptorName
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Emit a name for the descriptor if one is present (indicated
+ *              by the name being changed from the default name.) A name is only
+ *              emitted if a reference to the descriptor has been made somewhere
+ *              in the original ASL code.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDescriptorName (
+    void)
+{
+
+    if (ResourceName == ACPI_DEFAULT_RESNAME)
+    {
+        return;
+    }
+
+    AcpiOsPrintf ("%4.4s", (char *) &ResourceName);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmDumpInteger*
+ *
+ * PARAMETERS:  Value               - Value to emit
+ *              Name                - Associated name (emitted as a comment)
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Integer output helper functions
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDumpInteger8 (
+    UINT8                   Value,
+    char                    *Name)
+{
+    AcpiOsPrintf ("0x%2.2X,               // %s\n", Value, Name);
+}
+
+void
+AcpiDmDumpInteger16 (
+    UINT16                  Value,
+    char                    *Name)
+{
+    AcpiOsPrintf ("0x%4.4X,             // %s\n", Value, Name);
+}
+
+void
+AcpiDmDumpInteger32 (
+    UINT32                  Value,
+    char                    *Name)
+{
+    AcpiOsPrintf ("0x%8.8X,         // %s\n", Value, Name);
+}
+
+void
+AcpiDmDumpInteger64 (
+    UINT64                  Value,
+    char                    *Name)
+{
+    AcpiOsPrintf ("0x%8.8X%8.8X, // %s\n", ACPI_FORMAT_UINT64 (Value), Name);
+}
+
+
+/*******************************************************************************
+ *
+ * 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 ("%u", i);
+        }
+
+        Mask >>= 1;
+    }
+
+    /* Close list */
+
+    AcpiOsPrintf ("}\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmResourceTemplate
+ *
+ * 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 a Resource Template containing a set of
+ *              Resource Descriptors.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmResourceTemplate (
+    ACPI_OP_WALK_INFO       *Info,
+    ACPI_PARSE_OBJECT       *Op,
+    UINT8                   *ByteData,
+    UINT32                  ByteCount)
+{
+    ACPI_STATUS             Status;
+    UINT32                  CurrentByteOffset;
+    UINT8                   ResourceType;
+    UINT32                  ResourceLength;
+    void                    *Aml;
+    UINT32                  Level;
+    BOOLEAN                 DependentFns = FALSE;
+    UINT8                   ResourceIndex;
+    ACPI_NAMESPACE_NODE     *Node;
+
+
+    Level = Info->Level;
+    ResourceName = ACPI_DEFAULT_RESNAME;
+    Node = Op->Common.Node;
+    if (Node)
+    {
+        Node = Node->Child;
+    }
+
+    for (CurrentByteOffset = 0; CurrentByteOffset < ByteCount;)
+    {
+        Aml = &ByteData[CurrentByteOffset];
+
+        /* Get the descriptor type and length */
+
+        ResourceType = AcpiUtGetResourceType (Aml);
+        ResourceLength = AcpiUtGetResourceLength (Aml);
+
+        /* Validate the Resource Type and Resource Length */
+
+        Status = AcpiUtValidateResource (Aml, &ResourceIndex);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiOsPrintf ("/*** Could not validate Resource, type (%X) %s***/\n",
+                ResourceType, AcpiFormatException (Status));
+            return;
+        }
+
+        /* Point to next descriptor */
+
+        CurrentByteOffset += AcpiUtGetDescriptorLength (Aml);
+
+        /* Descriptor pre-processing */
+
+        switch (ResourceType)
+        {
+        case ACPI_RESOURCE_NAME_START_DEPENDENT:
+
+            /* Finish a previous StartDependentFns */
+
+            if (DependentFns)
+            {
+                Level--;
+                AcpiDmIndent (Level);
+                AcpiOsPrintf ("}\n");
+            }
+            break;
+
+        case ACPI_RESOURCE_NAME_END_DEPENDENT:
+
+            Level--;
+            DependentFns = FALSE;
+            break;
+
+        case ACPI_RESOURCE_NAME_END_TAG:
+
+            /* Normal exit, the resource list is finished */
+
+            if (DependentFns)
+            {
+                /*
+                 * Close an open StartDependentDescriptor. This indicates a
+                 * missing EndDependentDescriptor.
+                 */
+                Level--;
+                DependentFns = FALSE;
+
+                /* Go ahead and insert EndDependentFn() */
+
+                AcpiDmEndDependentDescriptor (Aml, ResourceLength, Level);
+
+                AcpiDmIndent (Level);
+                AcpiOsPrintf (
+                    "/*** Disassembler: inserted missing EndDependentFn () ***/\n");
+            }
+            return;
+
+        default:
+            break;
+        }
+
+        /* Disassemble the resource structure */
+
+        if (Node)
+        {
+            ResourceName = Node->Name.Integer;
+            Node = Node->Peer;
+        }
+
+        AcpiGbl_DmResourceDispatch [ResourceIndex] (
+            Aml, ResourceLength, Level);
+
+        /* Descriptor post-processing */
+
+        if (ResourceType == ACPI_RESOURCE_NAME_START_DEPENDENT)
+        {
+            DependentFns = TRUE;
+            Level++;
+        }
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmIsResourceTemplate
+ *
+ * PARAMETERS:  Op          - Buffer Op to be examined
+ *
+ * RETURN:      Status. AE_OK if valid template
+ *
+ * DESCRIPTION: Walk a byte list to determine if it consists of a valid set
+ *              of resource descriptors.  Nothing is output.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDmIsResourceTemplate (
+    ACPI_PARSE_OBJECT       *Op)
+{
+    ACPI_STATUS             Status;
+    ACPI_PARSE_OBJECT       *NextOp;
+    UINT8                   *Aml;
+    UINT8                   *EndAml;
+    ACPI_SIZE               Length;
+
+
+    /* This op must be a buffer */
+
+    if (Op->Common.AmlOpcode != AML_BUFFER_OP)
+    {
+        return (AE_TYPE);
+    }
+
+    /* Get the ByteData list and length */
+
+    NextOp = Op->Common.Value.Arg;
+    NextOp = NextOp->Common.Next;
+    if (!NextOp)
+    {
+        return (AE_TYPE);
+    }
+
+    Aml = NextOp->Named.Data;
+    Length = (ACPI_SIZE) NextOp->Common.Value.Integer;
+
+    /* Walk the byte list, abort on any invalid descriptor type or length */
+
+    Status = AcpiUtWalkAmlResources (Aml, Length, NULL, &EndAml);
+    if (ACPI_FAILURE (Status))
+    {
+        return (AE_TYPE);
+    }
+
+    /*
+     * For the resource template to be valid, one EndTag must appear
+     * at the very end of the ByteList, not before. (For proper disassembly
+     * of a ResourceTemplate, the buffer must not have any extra data after
+     * the EndTag.)
+     */
+    if ((Aml + Length - sizeof (AML_RESOURCE_END_TAG)) != EndAml)
+    {
+        return (AE_AML_NO_RESOURCE_END_TAG);
+    }
+
+    /*
+     * All resource descriptors are valid, therefore this list appears
+     * to be a valid resource template
+     */
+    return (AE_OK);
+}
+
+#endif
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/disassembler/dmresrcl.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,1052 @@
+/*******************************************************************************
+ *
+ * Module Name: dmresrcl.c - "Large" Resource Descriptor disassembly
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+
+
+#ifdef ACPI_DISASSEMBLER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dbresrcl")
+
+
+/* Common names for address and memory descriptors */
+
+static char                 *AcpiDmAddressNames[] =
+{
+    "Granularity",
+    "Range Minimum",
+    "Range Maximum",
+    "Translation Offset",
+    "Length"
+};
+
+static char                 *AcpiDmMemoryNames[] =
+{
+    "Range Minimum",
+    "Range Maximum",
+    "Alignment",
+    "Length"
+};
+
+
+/* Local prototypes */
+
+static void
+AcpiDmSpaceFlags (
+        UINT8               Flags);
+
+static void
+AcpiDmIoFlags (
+        UINT8               Flags);
+
+static void
+AcpiDmIoFlags2 (
+        UINT8               SpecificFlags);
+
+static void
+AcpiDmMemoryFlags (
+    UINT8                   Flags,
+    UINT8                   SpecificFlags);
+
+static void
+AcpiDmMemoryFlags2 (
+    UINT8                   SpecificFlags);
+
+static void
+AcpiDmResourceSource (
+    AML_RESOURCE            *Resource,
+    ACPI_SIZE               MinimumLength,
+    UINT32                  Length);
+
+static void
+AcpiDmAddressFields (
+    void                    *Source,
+    UINT8                   Type,
+    UINT32                  Level);
+
+static void
+AcpiDmAddressPrefix (
+    UINT8                   Type);
+
+static void
+AcpiDmAddressCommon (
+    AML_RESOURCE            *Resource,
+    UINT8                   Type,
+    UINT32                  Level);
+
+static void
+AcpiDmAddressFlags (
+    AML_RESOURCE            *Resource);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmMemoryFields
+ *
+ * PARAMETERS:  Source              - Pointer to the contiguous data fields
+ *              Type                - 16 or 32 (bit)
+ *              Level               - Current source code indentation level
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Decode fields common to Memory24 and Memory32 descriptors
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmMemoryFields (
+    void                    *Source,
+    UINT8                   Type,
+    UINT32                  Level)
+{
+    UINT32                  i;
+
+
+    for (i = 0; i < 4; i++)
+    {
+        AcpiDmIndent (Level + 1);
+
+        switch (Type)
+        {
+        case 16:
+            AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
+                AcpiDmMemoryNames[i]);
+            break;
+
+        case 32:
+            AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
+                AcpiDmMemoryNames[i]);
+            break;
+
+        default:
+            return;
+        }
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmAddressFields
+ *
+ * PARAMETERS:  Source              - Pointer to the contiguous data fields
+ *              Type                - 16, 32, or 64 (bit)
+ *              Level               - Current source code indentation level
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Decode fields common to address descriptors
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmAddressFields (
+    void                    *Source,
+    UINT8                   Type,
+    UINT32                  Level)
+{
+    UINT32                  i;
+
+
+    AcpiOsPrintf ("\n");
+
+    for (i = 0; i < 5; i++)
+    {
+        AcpiDmIndent (Level + 1);
+
+        switch (Type)
+        {
+        case 16:
+            AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
+                AcpiDmAddressNames[i]);
+            break;
+
+        case 32:
+            AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
+                AcpiDmAddressNames[i]);
+            break;
+
+        case 64:
+            AcpiDmDumpInteger64 (ACPI_CAST_PTR (UINT64, Source)[i],
+                AcpiDmAddressNames[i]);
+            break;
+
+        default:
+            return;
+        }
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmAddressPrefix
+ *
+ * PARAMETERS:  Type                - Descriptor type
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Emit name prefix representing the address descriptor type
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmAddressPrefix (
+    UINT8                   Type)
+{
+
+    switch (Type)
+    {
+    case ACPI_RESOURCE_TYPE_ADDRESS16:
+        AcpiOsPrintf ("Word");
+        break;
+
+    case ACPI_RESOURCE_TYPE_ADDRESS32:
+        AcpiOsPrintf ("DWord");
+        break;
+
+    case ACPI_RESOURCE_TYPE_ADDRESS64:
+        AcpiOsPrintf ("QWord");
+        break;
+
+    case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
+        AcpiOsPrintf ("Extended");
+        break;
+
+    default:
+        return;
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmAddressCommon
+ *
+ * PARAMETERS:  Resource            - Raw AML descriptor
+ *              Type                - Descriptor type
+ *              Level               - Current source code indentation level
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Emit common name and flag fields common to address descriptors
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmAddressCommon (
+    AML_RESOURCE            *Resource,
+    UINT8                   Type,
+    UINT32                  Level)
+{
+    UINT8                   ResourceType;
+    UINT8                   SpecificFlags;
+    UINT8                   Flags;
+
+
+    ResourceType = Resource->Address.ResourceType;
+    SpecificFlags = Resource->Address.SpecificFlags;
+    Flags = Resource->Address.Flags;
+
+    AcpiDmIndent (Level);
+
+    /* Validate ResourceType */
+
+    if ((ResourceType > 2) && (ResourceType < 0xC0))
+    {
+        AcpiOsPrintf ("/**** Invalid Resource Type: 0x%X ****/", ResourceType);
+        return;
+    }
+
+    /* Prefix is either Word, DWord, QWord, or Extended */
+
+    AcpiDmAddressPrefix (Type);
+
+    /* Resource Types above 0xC0 are vendor-defined */
+
+    if (ResourceType > 2)
+    {
+        AcpiOsPrintf ("Space (0x%2.2X, ", ResourceType);
+        AcpiDmSpaceFlags (Flags);
+        AcpiOsPrintf (" 0x%2.2X,", SpecificFlags);
+        return;
+    }
+
+    /* This is either a Memory, IO, or BusNumber descriptor (0,1,2) */
+
+    AcpiOsPrintf ("%s (", AcpiGbl_WordDecode [ResourceType & 0x3]);
+
+    /* Decode the general and type-specific flags */
+
+    if (ResourceType == ACPI_MEMORY_RANGE)
+    {
+        AcpiDmMemoryFlags (Flags, SpecificFlags);
+    }
+    else /* IO range or BusNumberRange */
+    {
+        AcpiDmIoFlags (Flags);
+        if (ResourceType == ACPI_IO_RANGE)
+        {
+            AcpiOsPrintf (" %s,", AcpiGbl_RngDecode [SpecificFlags & 0x3]);
+        }
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmAddressFlags
+ *
+ * PARAMETERS:  Resource        - Raw AML descriptor
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Emit flags common to address descriptors
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmAddressFlags (
+    AML_RESOURCE            *Resource)
+{
+
+    if (Resource->Address.ResourceType == ACPI_IO_RANGE)
+    {
+        AcpiDmIoFlags2 (Resource->Address.SpecificFlags);
+    }
+    else if (Resource->Address.ResourceType == ACPI_MEMORY_RANGE)
+    {
+        AcpiDmMemoryFlags2 (Resource->Address.SpecificFlags);
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmSpaceFlags
+ *
+ * PARAMETERS:  Flags               - Flag byte to be decoded
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Decode the flags specific to Space Address space descriptors
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmSpaceFlags (
+    UINT8                   Flags)
+{
+
+    AcpiOsPrintf ("%s, %s, %s, %s,",
+        AcpiGbl_ConsumeDecode [(Flags & 1)],
+        AcpiGbl_DecDecode [(Flags & 0x2) >> 1],
+        AcpiGbl_MinDecode [(Flags & 0x4) >> 2],
+        AcpiGbl_MaxDecode [(Flags & 0x8) >> 3]);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmIoFlags
+ *
+ * PARAMETERS:  Flags               - Flag byte to be decoded
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Decode the flags specific to IO Address space descriptors
+ *
+ ******************************************************************************/
+
+static 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:    AcpiDmIoFlags2
+ *
+ * PARAMETERS:  SpecificFlags       - "Specific" flag byte to be decoded
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Decode the flags specific to IO Address space descriptors
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmIoFlags2 (
+        UINT8               SpecificFlags)
+{
+
+    AcpiOsPrintf (", %s",
+        AcpiGbl_TtpDecode [(SpecificFlags & 0x10) >> 4]);
+
+    /* TRS is only used if TTP is TypeTranslation */
+
+    if (SpecificFlags & 0x10)
+    {
+        AcpiOsPrintf (", %s",
+            AcpiGbl_TrsDecode [(SpecificFlags & 0x20) >> 5]);
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmMemoryFlags
+ *
+ * PARAMETERS:  Flags               - Flag byte to be decoded
+ *              SpecificFlags       - "Specific" flag byte to be decoded
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Decode flags specific to Memory Address Space descriptors
+ *
+ ******************************************************************************/
+
+static 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:    AcpiDmMemoryFlags2
+ *
+ * PARAMETERS:  SpecificFlags       - "Specific" flag byte to be decoded
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Decode flags specific to Memory Address Space descriptors
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmMemoryFlags2 (
+    UINT8                   SpecificFlags)
+{
+
+    AcpiOsPrintf (", %s, %s",
+        AcpiGbl_MtpDecode [(SpecificFlags & 0x18) >> 3],
+        AcpiGbl_TtpDecode [(SpecificFlags & 0x20) >> 5]);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmResourceSource
+ *
+ * PARAMETERS:  Resource        - Raw AML descriptor
+ *              MinimumLength   - descriptor length without optional fields
+ *              ResourceLength
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Dump optional ResourceSource fields of an address descriptor
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmResourceSource (
+    AML_RESOURCE            *Resource,
+    ACPI_SIZE               MinimumTotalLength,
+    UINT32                  ResourceLength)
+{
+    UINT8                   *AmlResourceSource;
+    UINT32                  TotalLength;
+
+
+    TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
+
+    /* Check if the optional ResourceSource fields are present */
+
+    if (TotalLength <= MinimumTotalLength)
+    {
+        /* The two optional fields are not used */
+
+        AcpiOsPrintf (",, ");
+        return;
+    }
+
+    /* Get a pointer to the ResourceSource */
+
+    AmlResourceSource = ACPI_ADD_PTR (UINT8, Resource, MinimumTotalLength);
+
+    /*
+     * Always emit the ResourceSourceIndex (Byte)
+     *
+     * NOTE: Some ASL compilers always create a 0 byte (in the AML) for the
+     * Index even if the String does not exist. Although this is in violation
+     * of the ACPI specification, it is very important to emit ASL code that
+     * can be compiled back to the identical AML. There may be fields and/or
+     * indexes into the resource template buffer that are compiled to absolute
+     * offsets, and these will be broken if the AML length is changed.
+     */
+    AcpiOsPrintf ("0x%2.2X,", (UINT32) AmlResourceSource[0]);
+
+    /* Make sure that the ResourceSource string exists before dumping it */
+
+    if (TotalLength > (MinimumTotalLength + 1))
+    {
+        AcpiOsPrintf (" ");
+        AcpiUtPrintString ((char *) &AmlResourceSource[1], ACPI_UINT8_MAX);
+    }
+
+    AcpiOsPrintf (", ");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmWordDescriptor
+ *
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Length              - Length of the descriptor in bytes
+ *              Level               - Current source code indentation level
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Decode a Word Address Space descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmWordDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    /* Dump resource name and flags */
+
+    AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS16, Level);
+
+    /* Dump the 5 contiguous WORD values */
+
+    AcpiDmAddressFields (&Resource->Address16.Granularity, 16, Level);
+
+    /* The ResourceSource fields are optional */
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS16), Length);
+
+    /* Insert a descriptor name */
+
+    AcpiDmDescriptorName ();
+
+    /* Type-specific flags */
+
+    AcpiDmAddressFlags (Resource);
+    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 (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    /* Dump resource name and flags */
+
+    AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS32, Level);
+
+    /* Dump the 5 contiguous DWORD values */
+
+    AcpiDmAddressFields (&Resource->Address32.Granularity, 32, Level);
+
+    /* The ResourceSource fields are optional */
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS32), Length);
+
+    /* Insert a descriptor name */
+
+    AcpiDmDescriptorName ();
+
+    /* Type-specific flags */
+
+    AcpiDmAddressFlags (Resource);
+    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 (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    /* Dump resource name and flags */
+
+    AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_ADDRESS64, Level);
+
+    /* Dump the 5 contiguous QWORD values */
+
+    AcpiDmAddressFields (&Resource->Address64.Granularity, 64, Level);
+
+    /* The ResourceSource fields are optional */
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmResourceSource (Resource, sizeof (AML_RESOURCE_ADDRESS64), Length);
+
+    /* Insert a descriptor name */
+
+    AcpiDmDescriptorName ();
+
+    /* Type-specific flags */
+
+    AcpiDmAddressFlags (Resource);
+    AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmExtendedDescriptor
+ *
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Length              - Length of the descriptor in bytes
+ *              Level               - Current source code indentation level
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Decode a Extended Address Space descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmExtendedDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    /* Dump resource name and flags */
+
+    AcpiDmAddressCommon (Resource, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, Level);
+
+    /* Dump the 5 contiguous QWORD values */
+
+    AcpiDmAddressFields (&Resource->ExtAddress64.Granularity, 64, Level);
+
+    /* Extra field for this descriptor only */
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpInteger64 (Resource->ExtAddress64.TypeSpecific,
+        "Type-Specific Attributes");
+
+    /* Insert a descriptor name */
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDescriptorName ();
+
+    /* Type-specific flags */
+
+    AcpiDmAddressFlags (Resource);
+    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 (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    /* Dump name and read/write flag */
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("Memory24 (%s,\n",
+        AcpiGbl_RwDecode [Resource->Memory24.Flags & 1]);
+
+    /* Dump the 4 contiguous WORD values */
+
+    AcpiDmMemoryFields (&Resource->Memory24.Minimum, 16, Level);
+
+    /* Insert a descriptor name */
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * 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 (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    /* Dump name and read/write flag */
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("Memory32 (%s,\n",
+        AcpiGbl_RwDecode [Resource->Memory32.Flags & 1]);
+
+    /* Dump the 4 contiguous DWORD values */
+
+    AcpiDmMemoryFields (&Resource->Memory32.Minimum, 32, Level);
+
+    /* Insert a descriptor name */
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmFixedMemory32Descriptor
+ *
+ * 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
+AcpiDmFixedMemory32Descriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    /* Dump name and read/write flag */
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("Memory32Fixed (%s,\n",
+        AcpiGbl_RwDecode [Resource->FixedMemory32.Flags & 1]);
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpInteger32 (Resource->FixedMemory32.Address, "Address Base");
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpInteger32 (Resource->FixedMemory32.AddressLength, "Address Length");
+
+    /* Insert a descriptor name */
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * 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 (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("Register (");
+    AcpiDmAddressSpace (Resource->GenericReg.AddressSpaceId);
+    AcpiOsPrintf ("\n");
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpInteger8 (Resource->GenericReg.BitWidth, "Bit Width");
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpInteger8 (Resource->GenericReg.BitOffset, "Bit Offset");
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpInteger64 (Resource->GenericReg.Address, "Address");
+
+    /* Optional field for ACPI 3.0 */
+
+    AcpiDmIndent (Level + 1);
+    if (Resource->GenericReg.AccessSize)
+    {
+        AcpiOsPrintf ("0x%2.2X,               // %s\n",
+            Resource->GenericReg.AccessSize, "Access Size");
+        AcpiDmIndent (Level + 1);
+    }
+    else
+    {
+        AcpiOsPrintf (",");
+    }
+
+    /* DescriptorName was added for ACPI 3.0+ */
+
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * 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 (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+    UINT32                  i;
+
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("Interrupt (%s, %s, %s, %s, ",
+        AcpiGbl_ConsumeDecode [(Resource->ExtendedIrq.Flags & 1)],
+        AcpiGbl_HeDecode [(Resource->ExtendedIrq.Flags >> 1) & 1],
+        AcpiGbl_LlDecode [(Resource->ExtendedIrq.Flags >> 2) & 1],
+        AcpiGbl_ShrDecode [(Resource->ExtendedIrq.Flags >> 3) & 1]);
+
+    /*
+     * The ResourceSource fields are optional and appear after the interrupt
+     * list. Must compute length based on length of the list. First xrupt
+     * is included in the struct (reason for -1 below)
+     */
+    AcpiDmResourceSource (Resource,
+        sizeof (AML_RESOURCE_EXTENDED_IRQ) +
+            ((UINT32) Resource->ExtendedIrq.InterruptCount - 1) * sizeof (UINT32),
+        Resource->ExtendedIrq.ResourceLength);
+
+    /* Insert a descriptor name */
+
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (")\n");
+
+    /* Dump the interrupt list */
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("{\n");
+    for (i = 0; i < Resource->ExtendedIrq.InterruptCount; i++)
+    {
+        AcpiDmIndent (Level + 1);
+        AcpiOsPrintf ("0x%8.8X,\n",
+            (UINT32) Resource->ExtendedIrq.Interrupts[i]);
+    }
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("}\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmVendorCommon
+ *
+ * PARAMETERS:  Name                - Descriptor name suffix
+ *              ByteData            - Pointer to the vendor byte data
+ *              Length              - Length of the byte data
+ *              Level               - Current source code indentation level
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Decode a Vendor descriptor, both Large and Small
+ *
+ ******************************************************************************/
+
+void
+AcpiDmVendorCommon (
+    char                    *Name,
+    UINT8                   *ByteData,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    /* Dump macro name */
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("Vendor%s (", Name);
+
+    /* Insert a descriptor name */
+
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (")      // Length = 0x%.2X\n", Length);
+
+    /* Dump the vendor bytes */
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("{\n");
+
+    AcpiDmDisasmByteList (Level + 1, ByteData, Length);
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("}\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmVendorLargeDescriptor
+ *
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Length              - Length of the descriptor in bytes
+ *              Level               - Current source code indentation level
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Decode a Vendor Large descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmVendorLargeDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    AcpiDmVendorCommon ("Long ",
+        ACPI_ADD_PTR (UINT8, Resource, sizeof (AML_RESOURCE_LARGE_HEADER)),
+        Length, Level);
+}
+
+#endif
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/disassembler/dmresrcl2.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,700 @@
+/*******************************************************************************
+ *
+ * Module Name: dmresrcl2.c - "Large" Resource Descriptor disassembly (#2)
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+
+
+#ifdef ACPI_DISASSEMBLER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dbresrcl2")
+
+/* Local prototypes */
+
+static void
+AcpiDmI2cSerialBusDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level);
+
+static void
+AcpiDmSpiSerialBusDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level);
+
+static void
+AcpiDmUartSerialBusDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level);
+
+static void
+AcpiDmGpioCommon (
+    AML_RESOURCE            *Resource,
+    UINT32                  Level);
+
+static void
+AcpiDmDumpRawDataBuffer (
+    UINT8                   *Buffer,
+    UINT32                  Length,
+    UINT32                  Level);
+
+
+/* Dispatch table for the serial bus descriptors */
+
+static ACPI_RESOURCE_HANDLER        SerialBusResourceDispatch [] =
+{
+    NULL,
+    AcpiDmI2cSerialBusDescriptor,
+    AcpiDmSpiSerialBusDescriptor,
+    AcpiDmUartSerialBusDescriptor
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmDumpRawDataBuffer
+ *
+ * PARAMETERS:  Buffer              - Pointer to the data bytes
+ *              Length              - Length of the descriptor in bytes
+ *              Level               - Current source code indentation level
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Dump a data buffer as a RawDataBuffer() object. Used for
+ *              vendor data bytes.
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmDumpRawDataBuffer (
+    UINT8                   *Buffer,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+    UINT32                  Index;
+    UINT32                  i;
+    UINT32                  j;
+
+
+    if (!Length)
+    {
+        return;
+    }
+
+    AcpiOsPrintf ("RawDataBuffer (0x%.2X)  // Vendor Data", Length);
+
+    AcpiOsPrintf ("\n");
+    AcpiDmIndent (Level + 1);
+    AcpiOsPrintf ("{\n");
+    AcpiDmIndent (Level + 2);
+
+    for (i = 0; i < Length;)
+    {
+        for (j = 0; j < 8; j++)
+        {
+            Index = i + j;
+            if (Index >= Length)
+            {
+                goto Finish;
+            }
+
+            AcpiOsPrintf ("0x%2.2X", Buffer[Index]);
+            if ((Index + 1) >= Length)
+            {
+                goto Finish;
+            }
+
+            AcpiOsPrintf (", ");
+        }
+        AcpiOsPrintf ("\n");
+        AcpiDmIndent (Level + 2);
+
+        i += 8;
+    }
+
+Finish:
+    AcpiOsPrintf ("\n");
+    AcpiDmIndent (Level + 1);
+    AcpiOsPrintf ("}");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmGpioCommon
+ *
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *              Level               - Current source code indentation level
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Decode common parts of a GPIO Interrupt descriptor
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmGpioCommon (
+    AML_RESOURCE            *Resource,
+    UINT32                  Level)
+{
+    UINT32                  PinCount;
+    UINT16                  *PinList;
+    UINT8                   *VendorData;
+    UINT32                  i;
+
+
+    /* ResourceSource, ResourceSourceIndex, ResourceType */
+
+    AcpiDmIndent (Level + 1);
+    if (Resource->Gpio.ResSourceOffset)
+    {
+        AcpiUtPrintString (
+            ACPI_ADD_PTR (char, Resource, Resource->Gpio.ResSourceOffset),
+            ACPI_UINT8_MAX);
+    }
+
+    AcpiOsPrintf (", ");
+    AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.ResSourceIndex);
+    AcpiOsPrintf ("%s, ",
+        AcpiGbl_ConsumeDecode [(Resource->Gpio.Flags & 1)]);
+
+    /* Insert a descriptor name */
+
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (",");
+
+    /* Dump the vendor data */
+
+    if (Resource->Gpio.VendorOffset)
+    {
+        AcpiOsPrintf ("\n");
+        AcpiDmIndent (Level + 1);
+        VendorData = ACPI_ADD_PTR (UINT8, Resource,
+            Resource->Gpio.VendorOffset);
+
+        AcpiDmDumpRawDataBuffer (VendorData,
+            Resource->Gpio.VendorLength, Level);
+    }
+
+    AcpiOsPrintf (")\n");
+
+    /* Dump the interrupt list */
+
+    AcpiDmIndent (Level + 1);
+    AcpiOsPrintf ("{   // Pin list\n");
+
+    PinCount = ((UINT32) (Resource->Gpio.ResSourceOffset -
+        Resource->Gpio.PinTableOffset)) /
+        sizeof (UINT16);
+
+    PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
+        Resource->Gpio.PinTableOffset);
+
+    for (i = 0; i < PinCount; i++)
+    {
+        AcpiDmIndent (Level + 2);
+        AcpiOsPrintf ("0x%4.4X%s\n", PinList[i], ((i + 1) < PinCount) ? "," : "");
+    }
+
+    AcpiDmIndent (Level + 1);
+    AcpiOsPrintf ("}\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmGpioIntDescriptor
+ *
+ * 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 GPIO Interrupt descriptor
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmGpioIntDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    /* Dump the GpioInt-specific portion of the descriptor */
+
+    /* EdgeLevel, ActiveLevel, Shared */
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("GpioInt (%s, %s, %s, ",
+        AcpiGbl_HeDecode [(Resource->Gpio.IntFlags & 1)],
+        AcpiGbl_LlDecode [(Resource->Gpio.IntFlags >> 1) & 1],
+        AcpiGbl_ShrDecode [(Resource->Gpio.IntFlags >> 3) & 1]);
+
+    /* PinConfig, DebounceTimeout */
+
+    if (Resource->Gpio.PinConfig <= 3)
+    {
+        AcpiOsPrintf ("%s, ",
+            AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]);
+    }
+    else
+    {
+        AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
+    }
+    AcpiOsPrintf ("0x%4.4X,\n", Resource->Gpio.DebounceTimeout);
+
+    /* Dump the GpioInt/GpioIo common portion of the descriptor */
+
+    AcpiDmGpioCommon (Resource, Level);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmGpioIoDescriptor
+ *
+ * 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 GPIO Interrupt descriptor
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmGpioIoDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    /* Dump the GpioIo-specific portion of the descriptor */
+
+    /* Shared, PinConfig */
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("GpioIo (%s, ",
+        AcpiGbl_ShrDecode [(Resource->Gpio.IntFlags >> 3) & 1]);
+
+    if (Resource->Gpio.PinConfig <= 3)
+    {
+        AcpiOsPrintf ("%s, ",
+            AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]);
+    }
+    else
+    {
+        AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
+    }
+
+    /* DebounceTimeout, DriveStrength, IoRestriction */
+
+    AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DebounceTimeout);
+    AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DriveStrength);
+    AcpiOsPrintf ("%s,\n",
+        AcpiGbl_IorDecode [Resource->Gpio.IntFlags & 3]);
+
+    /* Dump the GpioInt/GpioIo common portion of the descriptor */
+
+    AcpiDmGpioCommon (Resource, Level);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmGpioDescriptor
+ *
+ * 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 GpioInt/GpioIo GPIO Interrupt/IO descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmGpioDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+    UINT8                   ConnectionType;
+
+
+    ConnectionType = Resource->Gpio.ConnectionType;
+
+    switch (ConnectionType)
+    {
+    case AML_RESOURCE_GPIO_TYPE_INT:
+        AcpiDmGpioIntDescriptor (Resource, Length, Level);
+        break;
+
+    case AML_RESOURCE_GPIO_TYPE_IO:
+        AcpiDmGpioIoDescriptor (Resource, Length, Level);
+        break;
+
+    default:
+        AcpiOsPrintf ("Unknown GPIO type\n");
+        break;
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmDumpSerialBusVendorData
+ *
+ * PARAMETERS:  Resource            - Pointer to the resource descriptor
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Dump optional serial bus vendor data
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmDumpSerialBusVendorData (
+    AML_RESOURCE            *Resource,
+    UINT32                  Level)
+{
+    UINT8                   *VendorData;
+    UINT32                  VendorLength;
+
+
+    /* Get the (optional) vendor data and length */
+
+    switch (Resource->CommonSerialBus.Type)
+    {
+    case AML_RESOURCE_I2C_SERIALBUSTYPE:
+
+        VendorLength = Resource->CommonSerialBus.TypeDataLength -
+            AML_RESOURCE_I2C_MIN_DATA_LEN;
+
+        VendorData = ACPI_ADD_PTR (UINT8, Resource,
+            sizeof (AML_RESOURCE_I2C_SERIALBUS));
+        break;
+
+    case AML_RESOURCE_SPI_SERIALBUSTYPE:
+
+        VendorLength = Resource->CommonSerialBus.TypeDataLength -
+            AML_RESOURCE_SPI_MIN_DATA_LEN;
+
+        VendorData = ACPI_ADD_PTR (UINT8, Resource,
+            sizeof (AML_RESOURCE_SPI_SERIALBUS));
+        break;
+
+    case AML_RESOURCE_UART_SERIALBUSTYPE:
+
+        VendorLength = Resource->CommonSerialBus.TypeDataLength -
+            AML_RESOURCE_UART_MIN_DATA_LEN;
+
+        VendorData = ACPI_ADD_PTR (UINT8, Resource,
+            sizeof (AML_RESOURCE_UART_SERIALBUS));
+        break;
+
+    default:
+        return;
+    }
+
+    /* Dump the vendor bytes as a RawDataBuffer object */
+
+    AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmI2cSerialBusDescriptor
+ *
+ * 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 I2C serial bus descriptor
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmI2cSerialBusDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+    UINT32                  ResourceSourceOffset;
+
+
+    /* SlaveAddress, SlaveMode, ConnectionSpeed, AddressingMode */
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("I2cSerialBus (0x%4.4X, %s, 0x%8.8X,\n",
+        Resource->I2cSerialBus.SlaveAddress,
+        AcpiGbl_SmDecode [(Resource->I2cSerialBus.Flags & 1)],
+        Resource->I2cSerialBus.ConnectionSpeed);
+
+    AcpiDmIndent (Level + 1);
+    AcpiOsPrintf ("%s, ",
+        AcpiGbl_AmDecode [(Resource->I2cSerialBus.TypeSpecificFlags & 1)]);
+
+    /* ResourceSource is a required field */
+
+    ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
+        Resource->CommonSerialBus.TypeDataLength;
+
+    AcpiUtPrintString (
+        ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
+        ACPI_UINT8_MAX);
+
+    /* ResourceSourceIndex, ResourceUsage */
+
+    AcpiOsPrintf (",\n");
+    AcpiDmIndent (Level + 1);
+    AcpiOsPrintf ("0x%2.2X, ", Resource->I2cSerialBus.ResSourceIndex);
+
+    AcpiOsPrintf ("%s, ",
+        AcpiGbl_ConsumeDecode [(Resource->I2cSerialBus.Flags >> 1) & 1]);
+
+    /* Insert a descriptor name */
+
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (",\n");
+
+    /* Dump the vendor data */
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpSerialBusVendorData (Resource, Level);
+    AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmSpiSerialBusDescriptor
+ *
+ * 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 SPI serial bus descriptor
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmSpiSerialBusDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+    UINT32                  ResourceSourceOffset;
+
+
+    /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("SpiSerialBus (0x%4.4X, %s, %s, 0x%2.2X,\n",
+        Resource->SpiSerialBus.DeviceSelection,
+        AcpiGbl_DpDecode [(Resource->SpiSerialBus.TypeSpecificFlags >> 1) & 1],
+        AcpiGbl_WmDecode [(Resource->SpiSerialBus.TypeSpecificFlags & 1)],
+        Resource->SpiSerialBus.DataBitLength);
+
+    /* SlaveMode, ConnectionSpeed, ClockPolarity, ClockPhase */
+
+    AcpiDmIndent (Level + 1);
+    AcpiOsPrintf ("%s, 0x%8.8X, %s,\n",
+        AcpiGbl_SmDecode [(Resource->SpiSerialBus.Flags & 1)],
+        Resource->SpiSerialBus.ConnectionSpeed,
+        AcpiGbl_CpoDecode [(Resource->SpiSerialBus.ClockPolarity & 1)]);
+
+    AcpiDmIndent (Level + 1);
+    AcpiOsPrintf ("%s, ",
+        AcpiGbl_CphDecode [(Resource->SpiSerialBus.ClockPhase & 1)]);
+
+    /* ResourceSource is a required field */
+
+    ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
+        Resource->CommonSerialBus.TypeDataLength;
+
+    AcpiUtPrintString (
+        ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
+        ACPI_UINT8_MAX);
+
+    /* ResourceSourceIndex, ResourceUsage */
+
+    AcpiOsPrintf (",\n");
+    AcpiDmIndent (Level + 1);
+    AcpiOsPrintf ("0x%2.2X, ", Resource->SpiSerialBus.ResSourceIndex);
+
+    AcpiOsPrintf ("%s, ",
+        AcpiGbl_ConsumeDecode [(Resource->SpiSerialBus.Flags >> 1) & 1]);
+
+    /* Insert a descriptor name */
+
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (",\n");
+
+    /* Dump the vendor data */
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpSerialBusVendorData (Resource, Level);
+    AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmUartSerialBusDescriptor
+ *
+ * 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 UART serial bus descriptor
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmUartSerialBusDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+    UINT32                  ResourceSourceOffset;
+
+
+    /* ConnectionSpeed, BitsPerByte, StopBits */
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("UartSerialBus (0x%8.8X, %s, %s,\n",
+        Resource->UartSerialBus.DefaultBaudRate,
+        AcpiGbl_BpbDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 4) & 3],
+        AcpiGbl_SbDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 2) & 3]);
+
+    /* LinesInUse, IsBigEndian, Parity, FlowControl */
+
+    AcpiDmIndent (Level + 1);
+    AcpiOsPrintf ("0x%2.2X, %s, %s, %s,\n",
+        Resource->UartSerialBus.LinesEnabled,
+        AcpiGbl_EdDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 7) & 1],
+        AcpiGbl_PtDecode [Resource->UartSerialBus.Parity & 7],
+        AcpiGbl_FcDecode [Resource->UartSerialBus.TypeSpecificFlags & 3]);
+
+    /* ReceiveBufferSize, TransmitBufferSize */
+
+    AcpiDmIndent (Level + 1);
+    AcpiOsPrintf ("0x%4.4X, 0x%4.4X, ",
+        Resource->UartSerialBus.RxFifoSize,
+        Resource->UartSerialBus.TxFifoSize);
+
+    /* ResourceSource is a required field */
+
+    ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
+        Resource->CommonSerialBus.TypeDataLength;
+
+    AcpiUtPrintString (
+        ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
+        ACPI_UINT8_MAX);
+
+    /* ResourceSourceIndex, ResourceUsage */
+
+    AcpiOsPrintf (",\n");
+    AcpiDmIndent (Level + 1);
+    AcpiOsPrintf ("0x%2.2X, ", Resource->UartSerialBus.ResSourceIndex);
+
+    AcpiOsPrintf ("%s, ",
+        AcpiGbl_ConsumeDecode [(Resource->UartSerialBus.Flags >> 1) & 1]);
+
+    /* Insert a descriptor name */
+
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (",\n");
+
+    /* Dump the vendor data */
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpSerialBusVendorData (Resource, Level);
+    AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmSerialBusDescriptor
+ *
+ * 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 I2C/SPI/UART serial bus descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmSerialBusDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    SerialBusResourceDispatch [Resource->CommonSerialBus.Type] (
+        Resource, Length, Level);
+}
+
+#endif
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/disassembler/dmresrcs.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,358 @@
+/*******************************************************************************
+ *
+ * Module Name: dmresrcs.c - "Small" Resource Descriptor disassembly
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/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, either Irq() or IrqNoFlags()
+ *
+ ******************************************************************************/
+
+void
+AcpiDmIrqDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("%s (",
+        AcpiGbl_IrqDecode [Length & 1]);
+
+    /* Decode flags byte if present */
+
+    if (Length & 1)
+    {
+        AcpiOsPrintf ("%s, %s, %s, ",
+            AcpiGbl_HeDecode [Resource->Irq.Flags & 1],
+            AcpiGbl_LlDecode [(Resource->Irq.Flags >> 3) & 1],
+            AcpiGbl_ShrDecode [(Resource->Irq.Flags >> 4) & 1]);
+    }
+
+    /* Insert a descriptor name */
+
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (")\n");
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmBitList (Resource->Irq.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 (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("DMA (%s, %s, %s, ",
+        AcpiGbl_TypDecode [(Resource->Dma.Flags >> 5) & 3],
+        AcpiGbl_BmDecode  [(Resource->Dma.Flags >> 2) & 1],
+        AcpiGbl_SizDecode [(Resource->Dma.Flags >> 0) & 3]);
+
+    /* Insert a descriptor name */
+
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (")\n");
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmBitList (Resource->Dma.DmaChannelMask);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmFixedDmaDescriptor
+ *
+ * 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 FixedDMA descriptor
+ *
+ ******************************************************************************/
+
+void
+AcpiDmFixedDmaDescriptor (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("FixedDMA (0x%4.4X, 0x%4.4X, ",
+        Resource->FixedDma.RequestLines,
+        Resource->FixedDma.Channels);
+
+    if (Resource->FixedDma.Width <= 5)
+    {
+        AcpiOsPrintf ("%s, ",
+            AcpiGbl_DtsDecode [Resource->FixedDma.Width]);
+    }
+    else
+    {
+        AcpiOsPrintf ("%X /* INVALID DMA WIDTH */, ", Resource->FixedDma.Width);
+    }
+
+    /* Insert a descriptor name */
+
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * 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 (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("IO (%s,\n",
+        AcpiGbl_IoDecode [(Resource->Io.Flags & 1)]);
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpInteger16 (Resource->Io.Minimum, "Range Minimum");
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpInteger16 (Resource->Io.Maximum, "Range Maximum");
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpInteger8 (Resource->Io.Alignment, "Alignment");
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpInteger8 (Resource->Io.AddressLength, "Length");
+
+    /* Insert a descriptor name */
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * 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 (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    AcpiDmIndent (Level);
+    AcpiOsPrintf ("FixedIO (\n");
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpInteger16 (Resource->FixedIo.Address, "Address");
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDumpInteger8 (Resource->FixedIo.AddressLength, "Length");
+
+    /* Insert a descriptor name */
+
+    AcpiDmIndent (Level + 1);
+    AcpiDmDescriptorName ();
+    AcpiOsPrintf (")\n");
+}
+
+
+/*******************************************************************************
+ *
+ * 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 (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    AcpiDmIndent (Level);
+
+    if (Length & 1)
+    {
+        AcpiOsPrintf ("StartDependentFn (0x%2.2X, 0x%2.2X)\n",
+            (UINT32) Resource->StartDpf.Flags & 3,
+            (UINT32) (Resource->StartDpf.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 (
+    AML_RESOURCE            *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 (
+    AML_RESOURCE            *Resource,
+    UINT32                  Length,
+    UINT32                  Level)
+{
+
+    AcpiDmVendorCommon ("Short",
+        ACPI_ADD_PTR (UINT8, Resource, sizeof (AML_RESOURCE_SMALL_HEADER)),
+        Length, Level);
+}
+
+#endif
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/disassembler/dmutils.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/disassembler/dmutils.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,321 @@
+/*******************************************************************************
+ *
+ * Module Name: dmutils - AML disassembler utilities
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+
+#ifdef ACPI_ASL_COMPILER
+#include <contrib/dev/acpica/include/acnamesp.h>
+#endif
+
+#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[] =
+{
+    "skip",
+    "?access?"
+};              /* FE = Field Element */
+#endif
+
+/* Operators for Match() */
+
+const char                      *AcpiGbl_MatchOps[] =
+{
+    "MTR",
+    "MEQ",
+    "MLE",
+    "MLT",
+    "MGE",
+    "MGT"
+};
+
+/* Access type decoding */
+
+const char                      *AcpiGbl_AccessTypes[] =
+{
+    "AnyAcc",
+    "ByteAcc",
+    "WordAcc",
+    "DWordAcc",
+    "QWordAcc",
+    "BufferAcc",
+    "InvalidAccType",
+    "InvalidAccType"
+};
+
+/* Lock rule decoding */
+
+const char                      *AcpiGbl_LockRule[] =
+{
+    "NoLock",
+    "Lock"
+};
+
+/* Update rule decoding */
+
+const char                      *AcpiGbl_UpdateRules[] =
+{
+    "Preserve",
+    "WriteAsOnes",
+    "WriteAsZeros",
+    "InvalidUpdateRule"
+};
+
+/* Strings used to decode resource descriptors */
+
+const char                      *AcpiGbl_WordDecode[] =
+{
+    "Memory",
+    "IO",
+    "BusNumber",
+    "UnknownResourceType"
+};
+
+const char                      *AcpiGbl_IrqDecode[] =
+{
+    "IRQNoFlags",
+    "IRQ"
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmDecodeAttribute
+ *
+ * PARAMETERS:  Attribute       - Attribute field of AccessAs keyword
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Decode the AccessAs attribute byte. (Mostly SMBus and
+ *              GenericSerialBus stuff.)
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDecodeAttribute (
+    UINT8                   Attribute)
+{
+
+    switch (Attribute)
+    {
+    case AML_FIELD_ATTRIB_QUICK:
+
+        AcpiOsPrintf ("AttribQuick");
+        break;
+
+    case AML_FIELD_ATTRIB_SEND_RCV:
+
+        AcpiOsPrintf ("AttribSendReceive");
+        break;
+
+    case AML_FIELD_ATTRIB_BYTE:
+
+        AcpiOsPrintf ("AttribByte");
+        break;
+
+    case AML_FIELD_ATTRIB_WORD:
+
+        AcpiOsPrintf ("AttribWord");
+        break;
+
+    case AML_FIELD_ATTRIB_BLOCK:
+
+        AcpiOsPrintf ("AttribBlock");
+        break;
+
+    case AML_FIELD_ATTRIB_MULTIBYTE:
+
+        AcpiOsPrintf ("AttribBytes");
+        break;
+
+    case AML_FIELD_ATTRIB_WORD_CALL:
+
+        AcpiOsPrintf ("AttribProcessCall");
+        break;
+
+    case AML_FIELD_ATTRIB_BLOCK_CALL:
+
+        AcpiOsPrintf ("AttribBlockProcessCall");
+        break;
+
+    case AML_FIELD_ATTRIB_RAW_BYTES:
+
+        AcpiOsPrintf ("AttribRawBytes");
+        break;
+
+    case AML_FIELD_ATTRIB_RAW_PROCESS:
+
+        AcpiOsPrintf ("AttribRawProcessBytes");
+        break;
+
+    default:
+
+        /* A ByteConst is allowed by the grammar */
+
+        AcpiOsPrintf ("0x%2.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 -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/disassembler/dmwalk.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/disassembler/dmwalk.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,935 @@
+/*******************************************************************************
+ *
+ * Module Name: dmwalk - AML disassembly tree walk
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+
+
+#ifdef ACPI_DISASSEMBLER
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("dmwalk")
+
+
+#define DB_FULL_OP_INFO     "[%4.4s] @%5.5X #%4.4X:  "
+
+/* Stub for non-compiler code */
+
+#ifndef ACPI_ASL_COMPILER
+void
+AcpiDmEmitExternals (
+    void)
+{
+    return;
+}
+#endif
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiDmDescendingOp (
+    ACPI_PARSE_OBJECT       *Op,
+    UINT32                  Level,
+    void                    *Context);
+
+static ACPI_STATUS
+AcpiDmAscendingOp (
+    ACPI_PARSE_OBJECT       *Op,
+    UINT32                  Level,
+    void                    *Context);
+
+static UINT32
+AcpiDmBlockType (
+    ACPI_PARSE_OBJECT       *Op);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmDisassemble
+ *
+ * PARAMETERS:  WalkState       - Current state
+ *              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.Flags = 0;
+    Info.Level = 0;
+    Info.Count = 0;
+    Info.WalkState = WalkState;
+    AcpiDmWalkParseTree (Op, AcpiDmDescendingOp, AcpiDmAscendingOp, &Info);
+    return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmWalkParseTree
+ *
+ * PARAMETERS:  Op                      - Root Op object
+ *              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)
+        {
+            if (AscendingCallback)
+            {
+                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:      BlockType - not a block, parens, braces, or even both.
+ *
+ * DESCRIPTION: Type of block for this op (parens or braces)
+ *
+ ******************************************************************************/
+
+static 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:      ListType - has commas or not.
+ *
+ * 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 (BLOCK_NONE);
+
+    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.
+ *
+ ******************************************************************************/
+
+static 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);
+    }
+
+    /* Level 0 is at the Definition Block level */
+
+    if (Level == 0)
+    {
+        /* In verbose mode, print the AML offset, opcode and depth count */
+
+        if (Info->WalkState)
+        {
+            VERBOSE_PRINT ((DB_FULL_OP_INFO,
+                (Info->WalkState->MethodNode ?
+                    Info->WalkState->MethodNode->Name.Ascii : "   "),
+                Op->Common.AmlOffset, (UINT32) Op->Common.AmlOpcode));
+        }
+
+        if (Op->Common.AmlOpcode == AML_SCOPE_OP)
+        {
+            /* This is the beginning of the Definition Block */
+
+            AcpiOsPrintf ("{\n");
+
+            /* Emit all External() declarations here */
+
+            AcpiDmEmitExternals ();
+            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);
+            Info->LastLevel = Level;
+            Info->Count = 0;
+    }
+
+    /*
+     * This is an inexpensive mechanism to try and keep lines from getting
+     * too long. When the limit is hit, start a new line at the previous
+     * indent plus one. A better but more expensive mechanism would be to
+     * keep track of the current column.
+     */
+    Info->Count++;
+    if (Info->Count /*+Info->LastLevel*/ > 10)
+    {
+        Info->Count = 0;
+        AcpiOsPrintf ("\n");
+        AcpiDmIndent (Info->LastLevel + 1);
+    }
+
+    /* Print the opcode name */
+
+    AcpiDmDisassembleOneOp (NULL, Info, Op);
+
+    if ((Op->Common.DisasmOpcode == ACPI_DASM_LNOT_PREFIX) ||
+        (Op->Common.AmlOpcode == AML_INT_CONNECTION_OP))
+    {
+        return (AE_OK);
+    }
+
+    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 (Name);
+                }
+
+                if (Op->Common.AmlOpcode != AML_INT_NAMEDFIELD_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() */
+
+                AcpiDmIsEisaId (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:
+            case AML_DATA_REGION_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 %X\n", Op->Common.AmlOpcode);
+                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 - Bank Name */
+
+                NextOp = AcpiPsGetDepthNext (NULL, NextOp);
+                AcpiDmNamestring (NextOp->Common.Value.Name);
+                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+                AcpiOsPrintf (", ");
+
+                /*
+                 * Bank Value. This is a TermArg in the middle of the parameter
+                 * list, must handle it here.
+                 *
+                 * Disassemble the TermArg parse tree. ACPI_PARSEOP_PARAMLIST
+                 * eliminates newline in the output.
+                 */
+                NextOp = NextOp->Common.Next;
+
+                Info->Flags = ACPI_PARSEOP_PARAMLIST;
+                AcpiDmWalkParseTree (NextOp, AcpiDmDescendingOp, AcpiDmAscendingOp, Info);
+                Info->Flags = 0;
+                Info->Level = Level;
+
+                NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+                AcpiOsPrintf (", ");
+                break;
+
+            case AML_INDEX_FIELD_OP:
+
+                /* Namestring - Data Name */
+
+                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.
+ *
+ ******************************************************************************/
+
+static 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
+                 */
+                if (!(Info->Flags & ACPI_PARSEOP_PARAMLIST))
+                {
+                    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 -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dsargs.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dsargs.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,438 @@
+/******************************************************************************
+ *
+ * Module Name: dsargs - Support for execution of dynamic arguments for static
+ *                       objects (regions, fields, buffer fields, etc.)
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __DSARGS_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#define _COMPONENT          ACPI_DISPATCHER
+        ACPI_MODULE_NAME    ("dsargs")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiDsExecuteArguments (
+    ACPI_NAMESPACE_NODE     *Node,
+    ACPI_NAMESPACE_NODE     *ScopeNode,
+    UINT32                  AmlLength,
+    UINT8                   *AmlStart);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsExecuteArguments
+ *
+ * PARAMETERS:  Node                - Object NS node
+ *              ScopeNode           - Parent NS node
+ *              AmlLength           - Length of executable AML
+ *              AmlStart            - Pointer to the AML
+ *
+ * RETURN:      Status.
+ *
+ * DESCRIPTION: Late (deferred) execution of region or field arguments
+ *
+ ******************************************************************************/
+
+static 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_FUNCTION_TRACE (DsExecuteArguments);
+
+
+    /* 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 (0, NULL, NULL, NULL);
+    if (!WalkState)
+    {
+        Status = AE_NO_MEMORY;
+        goto Cleanup;
+    }
+
+    Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
+                    AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiDsDeleteWalkState (WalkState);
+        goto Cleanup;
+    }
+
+    /* Mark this parse as a deferred opcode */
+
+    WalkState->ParseFlags = ACPI_PARSE_DEFERRED_OP;
+    WalkState->DeferredNode = Node;
+
+    /* Pass1: Parse the entire declaration */
+
+    Status = AcpiPsParseAml (WalkState);
+    if (ACPI_FAILURE (Status))
+    {
+        goto Cleanup;
+    }
+
+    /* Get and init the Op created above */
+
+    Op->Common.Node = Node;
+    AcpiPsDeleteParseTree (Op);
+
+    /* Evaluate the deferred arguments */
+
+    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 (0, NULL, NULL, NULL);
+    if (!WalkState)
+    {
+        Status = AE_NO_MEMORY;
+        goto Cleanup;
+    }
+
+    /* Execute the opcode and arguments */
+
+    Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, AmlStart,
+                    AmlLength, NULL, ACPI_IMODE_EXECUTE);
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiDsDeleteWalkState (WalkState);
+        goto Cleanup;
+    }
+
+    /* Mark this execution as a deferred opcode */
+
+    WalkState->DeferredNode = Node;
+    Status = AcpiPsParseAml (WalkState);
+
+Cleanup:
+    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 Arg Init\n",
+        AcpiUtGetNodeName (Node)));
+
+    /* Execute the AML code for the TermArg arguments */
+
+    Status = AcpiDsExecuteArguments (Node, Node->Parent,
+                ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsGetBankFieldArguments
+ *
+ * PARAMETERS:  ObjDesc         - A valid BankField object
+ *
+ * RETURN:      Status.
+ *
+ * DESCRIPTION: Get BankField BankValue. This implements the late
+ *              evaluation of these field attributes.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDsGetBankFieldArguments (
+    ACPI_OPERAND_OBJECT     *ObjDesc)
+{
+    ACPI_OPERAND_OBJECT     *ExtraDesc;
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE_PTR (DsGetBankFieldArguments, ObjDesc);
+
+
+    if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
+    {
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /* Get the AML pointer (method object) and BankField node */
+
+    ExtraDesc = AcpiNsGetSecondaryObject (ObjDesc);
+    Node = ObjDesc->BankField.Node;
+
+    ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname (ACPI_TYPE_LOCAL_BANK_FIELD,
+        Node, NULL));
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s] BankField Arg Init\n",
+        AcpiUtGetNodeName (Node)));
+
+    /* Execute the AML code for the TermArg arguments */
+
+    Status = AcpiDsExecuteArguments (Node, Node->Parent,
+                ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsGetBufferArguments
+ *
+ * PARAMETERS:  ObjDesc         - A valid Buffer object
+ *
+ * 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_ERROR ((AE_INFO,
+            "No pointer back to namespace node in buffer object %p", ObjDesc));
+        return_ACPI_STATUS (AE_AML_INTERNAL);
+    }
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Buffer Arg 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 Package object
+ *
+ * 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_ERROR ((AE_INFO,
+            "No pointer back to namespace node in package %p", ObjDesc));
+        return_ACPI_STATUS (AE_AML_INTERNAL);
+    }
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Package Arg 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 Arg Init at AML %p\n",
+        AcpiUtGetNodeName (Node), ExtraDesc->Extra.AmlStart));
+
+    /* Execute the argument AML */
+
+    Status = AcpiDsExecuteArguments (Node, ExtraDesc->Extra.ScopeNode,
+                ExtraDesc->Extra.AmlLength, ExtraDesc->Extra.AmlStart);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    Status = AcpiUtAddAddressRange (ObjDesc->Region.SpaceId,
+                 ObjDesc->Region.Address, ObjDesc->Region.Length,
+                 Node);
+    return_ACPI_STATUS (Status);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dscontrol.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,424 @@
+/******************************************************************************
+ *
+ * Module Name: dscontrol - Support for execution control opcodes -
+ *                          if/else/while/return
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __DSCONTROL_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+
+#define _COMPONENT          ACPI_DISPATCHER
+        ACPI_MODULE_NAME    ("dscontrol")
+
+
+/*******************************************************************************
+ *
+ * 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_WHILE_OP:
+
+        /*
+         * If this is an additional iteration of a while loop, continue.
+         * There is no need to allocate a new control state.
+         */
+        if (WalkState->ControlState)
+        {
+            if (WalkState->ControlState->Control.AmlPredicateStart ==
+                (WalkState->ParserState.Aml - 1))
+            {
+                /* Reset the state to start-of-loop */
+
+                WalkState->ControlState->Common.State =
+                    ACPI_CONTROL_CONDITIONAL_EXECUTING;
+                break;
+            }
+        }
+
+        /*lint -fallthrough */
+
+    case AML_IF_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));
+
+        ControlState = WalkState->ControlState;
+        if (ControlState->Common.Value)
+        {
+            /* Predicate was true, the body of the loop was just executed */
+
+            /*
+             * This loop counter mechanism allows the interpreter to escape
+             * possibly infinite loops. This can occur in poorly written AML
+             * when the hardware does not respond within a while loop and the
+             * loop does not implement a timeout.
+             */
+            ControlState->Control.LoopCount++;
+            if (ControlState->Control.LoopCount > ACPI_MAX_LOOP_ITERATIONS)
+            {
+                Status = AE_AML_INFINITE_LOOP;
+                break;
+            }
+
+            /*
+             * Go back and evaluate the predicate and maybe execute the loop
+             * another time
+             */
+            Status = AE_CTRL_PENDING;
+            WalkState->AmlLastWhile = ControlState->Control.AmlPredicateStart;
+            break;
+        }
+
+        /* Predicate was false, terminate this while loop */
+
+        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+            "[WHILE_OP] termination! Op=%p\n",Op));
+
+        /* Pop this control state and free it */
+
+        ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
+        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)
+        {
+            /* Since we have a real Return(), delete any implicit return */
+
+            AcpiDsClearImplicitReturn (WalkState);
+
+            /* Return statement has an immediate operand */
+
+            Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
+            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->ResultCount)
+        {
+            /* Since we have a real Return(), delete any implicit return */
+
+            AcpiDsClearImplicitReturn (WalkState);
+
+            /*
+             * 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) &&
+                ((WalkState->Results->Results.ObjDesc [0])->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
+                ((WalkState->Results->Results.ObjDesc [0])->Reference.Class != ACPI_REFCLASS_INDEX))
+            {
+                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:
+
+        /*
+         * Set the single-step flag. This will cause the debugger (if present)
+         * to break to the console within the AML debugger at the start of the
+         * next AML instruction.
+         */
+        ACPI_DEBUGGER_EXEC (
+            AcpiGbl_CmSingleStep = TRUE);
+        ACPI_DEBUGGER_EXEC (
+            AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n"));
+
+        /* Call to the OSL in case OS wants a piece of the action */
+
+        Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT,
+                    "Executed AML Breakpoint opcode");
+        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_ERROR ((AE_INFO, "Unknown control opcode=0x%X Op=%p",
+            Op->Common.AmlOpcode, Op));
+
+        Status = AE_AML_BAD_OPCODE;
+        break;
+    }
+
+    return (Status);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dsfield.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dsfield.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,748 @@
+/******************************************************************************
+ *
+ * Module Name: dsfield - Dispatcher field routines
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __DSFIELD_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acparser.h>
+
+
+#define _COMPONENT          ACPI_DISPATCHER
+        ACPI_MODULE_NAME    ("dsfield")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiDsGetFieldNames (
+    ACPI_CREATE_FIELD_INFO  *Info,
+    ACPI_WALK_STATE         *WalkState,
+    ACPI_PARSE_OBJECT       *Arg);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsCreateBufferField
+ *
+ * PARAMETERS:  Op                  - Current parse op (CreateXXField)
+ *              WalkState           - Current state
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Execute the CreateField operators:
+ *              CreateBitFieldOp,
+ *              CreateByteFieldOp,
+ *              CreateWordFieldOp,
+ *              CreateDWordFieldOp,
+ *              CreateQWordFieldOp,
+ *              CreateFieldOp       (all of which define a field in a buffer)
+ *
+ ******************************************************************************/
+
+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 (name of the new BufferField)
+     */
+    if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP)
+    {
+        /* For CreateField, name is the 4th argument */
+
+        Arg = AcpiPsGetArg (Op, 3);
+    }
+    else
+    {
+        /* For all other CreateXXXField operators, name is the 3rd argument */
+
+        Arg = AcpiPsGetArg (Op, 2);
+    }
+
+    if (!Arg)
+    {
+        return_ACPI_STATUS (AE_AML_NO_OPERAND);
+    }
+
+    if (WalkState->DeferredNode)
+    {
+        Node = WalkState->DeferredNode;
+        Status = AE_OK;
+    }
+    else
+    {
+        /* Execute flag should always be set when this function is entered */
+
+        if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
+        {
+            return_ACPI_STATUS (AE_AML_INTERNAL);
+        }
+
+        /* Creating new namespace node, should not already exist */
+
+        Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
+                ACPI_NS_ERROR_IF_FOUND;
+
+        /*
+         * Mark node temporary if we are executing a normal control
+         * method. (Don't mark if this is a module-level code method)
+         */
+        if (WalkState->MethodNode &&
+            !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
+        {
+            Flags |= ACPI_NS_TEMPORARY;
+        }
+
+        /* 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_ERROR_NAMESPACE (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.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDsGetFieldNames (
+    ACPI_CREATE_FIELD_INFO  *Info,
+    ACPI_WALK_STATE         *WalkState,
+    ACPI_PARSE_OBJECT       *Arg)
+{
+    ACPI_STATUS             Status;
+    UINT64                  Position;
+    ACPI_PARSE_OBJECT       *Child;
+
+
+    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)
+    {
+        /*
+         * Four types of field elements are handled:
+         * 1) Name - Enters a new named field into the namespace
+         * 2) Offset - specifies a bit offset
+         * 3) AccessAs - changes the access mode/attributes
+         * 4) Connection - Associate a resource template with the field
+         */
+        switch (Arg->Common.AmlOpcode)
+        {
+        case AML_INT_RESERVEDFIELD_OP:
+
+            Position = (UINT64) Info->FieldBitPosition
+                        + (UINT64) Arg->Common.Value.Size;
+
+            if (Position > ACPI_UINT32_MAX)
+            {
+                ACPI_ERROR ((AE_INFO,
+                    "Bit offset within field too large (> 0xFFFFFFFF)"));
+                return_ACPI_STATUS (AE_SUPPORT);
+            }
+
+            Info->FieldBitPosition = (UINT32) Position;
+            break;
+
+        case AML_INT_ACCESSFIELD_OP:
+        case AML_INT_EXTACCESSFIELD_OP:
+            /*
+             * Get new AccessType, AccessAttribute, and AccessLength fields
+             * -- to be used for all field units that follow, until the
+             * end-of-field or another AccessAs keyword is encountered.
+             * NOTE. These three bytes are encoded in the integer value
+             * of the parseop for convenience.
+             *
+             * In FieldFlags, preserve the flag bits other than the
+             * ACCESS_TYPE bits.
+             */
+
+            /* AccessType (ByteAcc, WordAcc, etc.) */
+
+            Info->FieldFlags = (UINT8)
+                ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) |
+                ((UINT8) ((UINT32) (Arg->Common.Value.Integer & 0x07))));
+
+            /* AccessAttribute (AttribQuick, AttribByte, etc.) */
+
+            Info->Attribute = (UINT8) ((Arg->Common.Value.Integer >> 8) & 0xFF);
+
+            /* AccessLength (for serial/buffer protocols) */
+
+            Info->AccessLength = (UINT8) ((Arg->Common.Value.Integer >> 16) & 0xFF);
+            break;
+
+        case AML_INT_CONNECTION_OP:
+            /*
+             * Clear any previous connection. New connection is used for all
+             * fields that follow, similar to AccessAs
+             */
+            Info->ResourceBuffer = NULL;
+            Info->ConnectionNode = NULL;
+
+            /*
+             * A Connection() is either an actual resource descriptor (buffer)
+             * or a named reference to a resource template
+             */
+            Child = Arg->Common.Value.Arg;
+            if (Child->Common.AmlOpcode == AML_INT_BYTELIST_OP)
+            {
+                Info->ResourceBuffer = Child->Named.Data;
+                Info->ResourceLength = (UINT16) Child->Named.Value.Integer;
+            }
+            else
+            {
+                /* Lookup the Connection() namepath, it should already exist */
+
+                Status = AcpiNsLookup (WalkState->ScopeInfo,
+                            Child->Common.Value.Name, ACPI_TYPE_ANY,
+                            ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
+                            WalkState, &Info->ConnectionNode);
+                if (ACPI_FAILURE (Status))
+                {
+                    ACPI_ERROR_NAMESPACE (Child->Common.Value.Name, Status);
+                    return_ACPI_STATUS (Status);
+                }
+            }
+            break;
+
+        case AML_INT_NAMEDFIELD_OP:
+
+            /* Lookup the name, it should already exist */
+
+            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_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status);
+                return_ACPI_STATUS (Status);
+            }
+            else
+            {
+                Arg->Common.Node = Info->FieldNode;
+                Info->FieldBitLength = Arg->Common.Value.Size;
+
+                /*
+                 * If there is no object attached to the node, this node was
+                 * just created and we need to create the field object.
+                 * Otherwise, this was a lookup of an existing node and we
+                 * don't want to create the field object again.
+                 */
+                if (!AcpiNsGetAttachedObject (Info->FieldNode))
+                {
+                    Status = AcpiExPrepFieldValue (Info);
+                    if (ACPI_FAILURE (Status))
+                    {
+                        return_ACPI_STATUS (Status);
+                    }
+                }
+            }
+
+            /* Keep track of bit position for the next field */
+
+            Position = (UINT64) Info->FieldBitPosition
+                        + (UINT64) Arg->Common.Value.Size;
+
+            if (Position > ACPI_UINT32_MAX)
+            {
+                ACPI_ERROR ((AE_INFO,
+                    "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)",
+                    ACPI_CAST_PTR (char, &Info->FieldNode->Name)));
+                return_ACPI_STATUS (AE_SUPPORT);
+            }
+
+            Info->FieldBitPosition += Info->FieldBitLength;
+            break;
+
+        default:
+
+            ACPI_ERROR ((AE_INFO,
+                "Invalid opcode in field list: 0x%X", 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_ERROR_NAMESPACE (Arg->Common.Value.Name, Status);
+            return_ACPI_STATUS (Status);
+        }
+    }
+
+    ACPI_MEMSET (&Info, 0, sizeof (ACPI_CREATE_FIELD_INFO));
+
+    /* Second arg is the field flags */
+
+    Arg = Arg->Common.Next;
+    Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
+    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;
+    UINT32                  Flags;
+
+
+    ACPI_FUNCTION_TRACE_PTR (DsInitFieldObjects, Op);
+
+
+    /* Execute flag should always be set when this function is entered */
+
+    if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE))
+    {
+        if (WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP)
+        {
+            /* BankField Op is deferred, just return OK */
+
+            return_ACPI_STATUS (AE_OK);
+        }
+
+        return_ACPI_STATUS (AE_AML_INTERNAL);
+    }
+
+    /*
+     * Get the FieldList argument for this opcode. This is the start of the
+     * list of field elements.
+     */
+    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);
+    }
+
+    /* Creating new namespace node(s), should not already exist */
+
+    Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE |
+            ACPI_NS_ERROR_IF_FOUND;
+
+    /*
+     * Mark node(s) temporary if we are executing a normal control
+     * method. (Don't mark if this is a module-level code method)
+     */
+    if (WalkState->MethodNode &&
+        !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
+    {
+        Flags |= ACPI_NS_TEMPORARY;
+    }
+
+    /*
+     * Walk the list of entries in the FieldList
+     * Note: FieldList can be of zero length. In this case, Arg will be NULL.
+     */
+    while (Arg)
+    {
+        /*
+         * Ignore OFFSET/ACCESSAS/CONNECTION terms here; we are only interested
+         * in the field names in order to enter them into the namespace.
+         */
+        if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
+        {
+            Status = AcpiNsLookup (WalkState->ScopeInfo,
+                        (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1,
+                        Flags, WalkState, &Node);
+            if (ACPI_FAILURE (Status))
+            {
+                ACPI_ERROR_NAMESPACE ((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;
+        }
+
+        /* Get the next field element 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_ERROR_NAMESPACE (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_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
+        return_ACPI_STATUS (Status);
+    }
+
+    /*
+     * Third arg is the BankValue
+     * This arg is a TermArg, not a constant
+     * It will be evaluated later, by AcpiDsEvalBankFieldOperands
+     */
+    Arg = Arg->Common.Next;
+
+    /* Fourth arg is the field flags */
+
+    Arg = Arg->Common.Next;
+    Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
+
+    /* Each remaining arg is a Named Field */
+
+    Info.FieldType = ACPI_TYPE_LOCAL_BANK_FIELD;
+    Info.RegionNode = RegionNode;
+
+    /*
+     * Use Info.DataRegisterNode to store BankField Op
+     * It's safe because DataRegisterNode will never be used when create bank field
+     * We store AmlStart and AmlLength in the BankField Op for late evaluation
+     * Used in AcpiExPrepFieldValue(Info)
+     *
+     * TBD: Or, should we add a field in ACPI_CREATE_FIELD_INFO, like "void *ParentOp"?
+     */
+    Info.DataRegisterNode = (ACPI_NAMESPACE_NODE*) Op;
+
+    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_ERROR_NAMESPACE (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_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Next arg is the field flags */
+
+    Arg = Arg->Common.Next;
+    Info.FieldFlags = (UINT8) Arg->Common.Value.Integer;
+
+    /* 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 -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dsinit.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dsinit.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,238 @@
+/******************************************************************************
+ *
+ * Module Name: dsinit - Object initialization namespace walk
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __DSINIT_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/actables.h>
+
+#define _COMPONENT          ACPI_DISPATCHER
+        ACPI_MODULE_NAME    ("dsinit")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiDsInitOneObject (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  Level,
+    void                    *Context,
+    void                    **ReturnValue);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsInitOneObject
+ *
+ * PARAMETERS:  ObjHandle       - Node for the object
+ *              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
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDsInitOneObject (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  Level,
+    void                    *Context,
+    void                    **ReturnValue)
+{
+    ACPI_INIT_WALK_INFO     *Info = (ACPI_INIT_WALK_INFO *) Context;
+    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
+    ACPI_OBJECT_TYPE        Type;
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_ENTRY ();
+
+
+    /*
+     * We are only interested in NS nodes owned by the table that
+     * was just loaded
+     */
+    if (Node->OwnerId != Info->OwnerId)
+    {
+        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_EXCEPTION ((AE_INFO, Status,
+                "During Region initialization %p [%4.4s]",
+                ObjHandle, AcpiUtGetNodeName (ObjHandle)));
+        }
+
+        Info->OpRegionCount++;
+        break;
+
+
+    case ACPI_TYPE_METHOD:
+
+        Info->MethodCount++;
+        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 (
+    UINT32                  TableIndex,
+    ACPI_NAMESPACE_NODE     *StartNode)
+{
+    ACPI_STATUS             Status;
+    ACPI_INIT_WALK_INFO     Info;
+    ACPI_TABLE_HEADER       *Table;
+    ACPI_OWNER_ID           OwnerId;
+
+
+    ACPI_FUNCTION_TRACE (DsInitializeObjects);
+
+
+    Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+        "**** Starting initialization of namespace objects ****\n"));
+    ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Parsing all Control Methods:"));
+
+    /* Set all init info to zero */
+
+    ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO));
+
+    Info.OwnerId = OwnerId;
+    Info.TableIndex = TableIndex;
+
+    /* Walk entire namespace from the supplied root */
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /*
+     * We don't use AcpiWalkNamespace since we do not want to acquire
+     * the namespace reader lock.
+     */
+    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX,
+                ACPI_NS_WALK_UNLOCK, AcpiDsInitOneObject, NULL, &Info, NULL);
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace"));
+    }
+    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+
+    Status = AcpiGetTableByIndex (TableIndex, &Table);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
+        "\nTable [%4.4s](id %4.4X) - %u Objects with %u Devices %u Methods %u Regions\n",
+        Table->Signature, OwnerId, Info.ObjectCount,
+        Info.DeviceCount, Info.MethodCount, Info.OpRegionCount));
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+        "%u Methods, %u Regions\n", Info.MethodCount, Info.OpRegionCount));
+
+    return_ACPI_STATUS (AE_OK);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,726 @@
+/******************************************************************************
+ *
+ * Module Name: dsmethod - Parser/Interpreter interface - control method parsing
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __DSMETHOD_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acdisasm.h>
+
+
+#define _COMPONENT          ACPI_DISPATCHER
+        ACPI_MODULE_NAME    ("dsmethod")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiDsCreateMethodMutex (
+    ACPI_OPERAND_OBJECT     *MethodDesc);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsMethodError
+ *
+ * PARAMETERS:  Status          - Execution status
+ *              WalkState       - Current state
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Called on method error. Invoke the global exception handler if
+ *              present, dump the method data if the disassembler is configured
+ *
+ *              Note: Allows the exception handler to change the status code
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDsMethodError (
+    ACPI_STATUS             Status,
+    ACPI_WALK_STATE         *WalkState)
+{
+    ACPI_FUNCTION_ENTRY ();
+
+
+    /* Ignore AE_OK and control exception codes */
+
+    if (ACPI_SUCCESS (Status) ||
+        (Status & AE_CODE_CONTROL))
+    {
+        return (Status);
+    }
+
+    /* Invoke the global exception handler */
+
+    if (AcpiGbl_ExceptionHandler)
+    {
+        /* Exit the interpreter, allow handler to execute methods */
+
+        AcpiExExitInterpreter ();
+
+        /*
+         * Handler can map the exception code to anything it wants, including
+         * AE_OK, in which case the executing method will not be aborted.
+         */
+        Status = AcpiGbl_ExceptionHandler (Status,
+                    WalkState->MethodNode ?
+                        WalkState->MethodNode->Name.Integer : 0,
+                    WalkState->Opcode, WalkState->AmlOffset, NULL);
+        AcpiExEnterInterpreter ();
+    }
+
+    AcpiDsClearImplicitReturn (WalkState);
+
+#ifdef ACPI_DISASSEMBLER
+    if (ACPI_FAILURE (Status))
+    {
+        /* Display method locals/args if disassembler is present */
+
+        AcpiDmDumpMethodInfo (Status, WalkState, WalkState->Op);
+    }
+#endif
+
+    return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsCreateMethodMutex
+ *
+ * PARAMETERS:  ObjDesc             - The method object
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Create a mutex object for a serialized control method
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDsCreateMethodMutex (
+    ACPI_OPERAND_OBJECT     *MethodDesc)
+{
+    ACPI_OPERAND_OBJECT     *MutexDesc;
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (DsCreateMethodMutex);
+
+
+    /* Create the new mutex object */
+
+    MutexDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
+    if (!MutexDesc)
+    {
+        return_ACPI_STATUS (AE_NO_MEMORY);
+    }
+
+    /* Create the actual OS Mutex */
+
+    Status = AcpiOsCreateMutex (&MutexDesc->Mutex.OsMutex);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    MutexDesc->Mutex.SyncLevel = MethodDesc->Method.SyncLevel;
+    MethodDesc->Method.Mutex = MutexDesc;
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsBeginMethodExecution
+ *
+ * PARAMETERS:  MethodNode          - Node of the method
+ *              ObjDesc             - The method object
+ *              WalkState           - current state, NULL if not yet executing
+ *                                    a method.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDsBeginMethodExecution (
+    ACPI_NAMESPACE_NODE     *MethodNode,
+    ACPI_OPERAND_OBJECT     *ObjDesc,
+    ACPI_WALK_STATE         *WalkState)
+{
+    ACPI_STATUS             Status = AE_OK;
+
+
+    ACPI_FUNCTION_TRACE_PTR (DsBeginMethodExecution, MethodNode);
+
+
+    if (!MethodNode)
+    {
+        return_ACPI_STATUS (AE_NULL_ENTRY);
+    }
+
+    /* Prevent wraparound of thread count */
+
+    if (ObjDesc->Method.ThreadCount == ACPI_UINT8_MAX)
+    {
+        ACPI_ERROR ((AE_INFO,
+            "Method reached maximum reentrancy limit (255)"));
+        return_ACPI_STATUS (AE_AML_METHOD_LIMIT);
+    }
+
+    /*
+     * If this method is serialized, we need to acquire the method mutex.
+     */
+    if (ObjDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED)
+    {
+        /*
+         * Create a mutex for the method if it is defined to be Serialized
+         * and a mutex has not already been created. We defer the mutex creation
+         * until a method is actually executed, to minimize the object count
+         */
+        if (!ObjDesc->Method.Mutex)
+        {
+            Status = AcpiDsCreateMethodMutex (ObjDesc);
+            if (ACPI_FAILURE (Status))
+            {
+                return_ACPI_STATUS (Status);
+            }
+        }
+
+        /*
+         * The CurrentSyncLevel (per-thread) must be less than or equal to
+         * the sync level of the method. This mechanism provides some
+         * deadlock prevention
+         *
+         * Top-level method invocation has no walk state at this point
+         */
+        if (WalkState &&
+            (WalkState->Thread->CurrentSyncLevel > ObjDesc->Method.Mutex->Mutex.SyncLevel))
+        {
+            ACPI_ERROR ((AE_INFO,
+                "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%u)",
+                AcpiUtGetNodeName (MethodNode),
+                WalkState->Thread->CurrentSyncLevel));
+
+            return_ACPI_STATUS (AE_AML_MUTEX_ORDER);
+        }
+
+        /*
+         * Obtain the method mutex if necessary. Do not acquire mutex for a
+         * recursive call.
+         */
+        if (!WalkState ||
+            !ObjDesc->Method.Mutex->Mutex.ThreadId ||
+            (WalkState->Thread->ThreadId != ObjDesc->Method.Mutex->Mutex.ThreadId))
+        {
+            /*
+             * Acquire the method mutex. This releases the interpreter if we
+             * block (and reacquires it before it returns)
+             */
+            Status = AcpiExSystemWaitMutex (ObjDesc->Method.Mutex->Mutex.OsMutex,
+                        ACPI_WAIT_FOREVER);
+            if (ACPI_FAILURE (Status))
+            {
+                return_ACPI_STATUS (Status);
+            }
+
+            /* Update the mutex and walk info and save the original SyncLevel */
+
+            if (WalkState)
+            {
+                ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel =
+                    WalkState->Thread->CurrentSyncLevel;
+
+                ObjDesc->Method.Mutex->Mutex.ThreadId = WalkState->Thread->ThreadId;
+                WalkState->Thread->CurrentSyncLevel = ObjDesc->Method.SyncLevel;
+            }
+            else
+            {
+                ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel =
+                    ObjDesc->Method.Mutex->Mutex.SyncLevel;
+            }
+        }
+
+        /* Always increase acquisition depth */
+
+        ObjDesc->Method.Mutex->Mutex.AcquisitionDepth++;
+    }
+
+    /*
+     * Allocate an Owner ID for this method, only if this is the first thread
+     * to begin concurrent execution. We only need one OwnerId, even if the
+     * method is invoked recursively.
+     */
+    if (!ObjDesc->Method.OwnerId)
+    {
+        Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId);
+        if (ACPI_FAILURE (Status))
+        {
+            goto Cleanup;
+        }
+    }
+
+    /*
+     * 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++;
+    AcpiMethodCount++;
+    return_ACPI_STATUS (Status);
+
+
+Cleanup:
+    /* On error, must release the method mutex (if present) */
+
+    if (ObjDesc->Method.Mutex)
+    {
+        AcpiOsReleaseMutex (ObjDesc->Method.Mutex->Mutex.OsMutex);
+    }
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsCallControlMethod
+ *
+ * PARAMETERS:  Thread              - Info for this thread
+ *              ThisWalkState       - Current walk state
+ *              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_WALK_STATE         *NextWalkState = NULL;
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_EVALUATE_INFO      *Info;
+    UINT32                  i;
+
+
+    ACPI_FUNCTION_TRACE_PTR (DsCallControlMethod, ThisWalkState);
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Calling 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, possibly wait on method mutex */
+
+    Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc,
+                ThisWalkState);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Begin method parse/execution. Create a new walk state */
+
+    NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwnerId,
+                        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. Also, null terminate the list of arguments
+     */
+    ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL;
+
+    /*
+     * Allocate and initialize the evaluation information block
+     * TBD: this is somewhat inefficient, should change interface to
+     * DsInitAmlWalk. For now, keeps this struct off the CPU stack
+     */
+    Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
+    if (!Info)
+    {
+        return_ACPI_STATUS (AE_NO_MEMORY);
+    }
+
+    Info->Parameters = &ThisWalkState->Operands[0];
+
+    Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode,
+                ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength,
+                Info, ACPI_IMODE_EXECUTE);
+
+    ACPI_FREE (Info);
+    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,
+        "**** Begin nested execution of [%4.4s] **** WalkState=%p\n",
+        MethodNode->Name.Ascii, NextWalkState));
+
+    /* Invoke an internal method if necessary */
+
+    if (ObjDesc->Method.InfoFlags & ACPI_METHOD_INTERNAL_ONLY)
+    {
+        Status = ObjDesc->Method.Dispatch.Implementation (NextWalkState);
+        if (Status == AE_OK)
+        {
+            Status = AE_CTRL_TERMINATE;
+        }
+    }
+
+    return_ACPI_STATUS (Status);
+
+
+Cleanup:
+
+    /* On error, we must terminate the method properly */
+
+    AcpiDsTerminateControlMethod (ObjDesc, NextWalkState);
+    if (NextWalkState)
+    {
+        AcpiDsDeleteWalkState (NextWalkState);
+    }
+
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsRestartControlMethod
+ *
+ * PARAMETERS:  WalkState           - State for preempted method (caller)
+ *              ReturnDesc          - Return value from the called method
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Restart a method that was preempted by another (nested) method
+ *              invocation.  Handle the return value (if any) from the callee.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDsRestartControlMethod (
+    ACPI_WALK_STATE         *WalkState,
+    ACPI_OPERAND_OBJECT     *ReturnDesc)
+{
+    ACPI_STATUS             Status;
+    int                     SameAsImplicitReturn;
+
+
+    ACPI_FUNCTION_TRACE_PTR (DsRestartControlMethod, WalkState);
+
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+        "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n",
+        AcpiUtGetNodeName (WalkState->MethodNode),
+        WalkState->MethodCallOp, ReturnDesc));
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+        "    ReturnFromThisMethodUsed?=%X ResStack %p Walk %p\n",
+        WalkState->ReturnUsed,
+        WalkState->Results, WalkState));
+
+    /* Did the called method return a value? */
+
+    if (ReturnDesc)
+    {
+        /* Is the implicit return object the same as the return desc? */
+
+        SameAsImplicitReturn = (WalkState->ImplicitReturnObj == ReturnDesc);
+
+        /* Are we actually going to use the return value? */
+
+        if (WalkState->ReturnUsed)
+        {
+            /* Save the return value from the previous method */
+
+            Status = AcpiDsResultPush (ReturnDesc, WalkState);
+            if (ACPI_FAILURE (Status))
+            {
+                AcpiUtRemoveReference (ReturnDesc);
+                return_ACPI_STATUS (Status);
+            }
+
+            /*
+             * Save as THIS method's return value in case it is returned
+             * immediately to yet another method
+             */
+            WalkState->ReturnDesc = ReturnDesc;
+        }
+
+        /*
+         * The following code is the optional support for the so-called
+         * "implicit return". Some AML code assumes that the last value of the
+         * method is "implicitly" returned to the caller, in the absence of an
+         * explicit return value.
+         *
+         * Just save the last result of the method as the return value.
+         *
+         * NOTE: this is optional because the ASL language does not actually
+         * support this behavior.
+         */
+        else if (!AcpiDsDoImplicitReturn (ReturnDesc, WalkState, FALSE) ||
+                 SameAsImplicitReturn)
+        {
+            /*
+             * Delete the return value if it will not be used by the
+             * calling method or remove one reference if the explicit return
+             * is the same as the implicit return value.
+             */
+            AcpiUtRemoveReference (ReturnDesc);
+        }
+    }
+
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsTerminateControlMethod
+ *
+ * PARAMETERS:  MethodDesc          - Method object
+ *              WalkState           - State associated with the method
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Terminate a control method.  Delete everything that the method
+ *              created, delete all locals and arguments, and delete the parse
+ *              tree if requested.
+ *
+ * MUTEX:       Interpreter is locked
+ *
+ ******************************************************************************/
+
+void
+AcpiDsTerminateControlMethod (
+    ACPI_OPERAND_OBJECT     *MethodDesc,
+    ACPI_WALK_STATE         *WalkState)
+{
+
+    ACPI_FUNCTION_TRACE_PTR (DsTerminateControlMethod, WalkState);
+
+
+    /* MethodDesc is required, WalkState is optional */
+
+    if (!MethodDesc)
+    {
+        return_VOID;
+    }
+
+    if (WalkState)
+    {
+        /* Delete all arguments and locals */
+
+        AcpiDsMethodDataDeleteAll (WalkState);
+
+        /*
+         * If method is serialized, release the mutex and restore the
+         * current sync level for this thread
+         */
+        if (MethodDesc->Method.Mutex)
+        {
+            /* Acquisition Depth handles recursive calls */
+
+            MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--;
+            if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth)
+            {
+                WalkState->Thread->CurrentSyncLevel =
+                    MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel;
+
+                AcpiOsReleaseMutex (MethodDesc->Method.Mutex->Mutex.OsMutex);
+                MethodDesc->Method.Mutex->Mutex.ThreadId = 0;
+            }
+        }
+
+        /*
+         * Delete any namespace objects created anywhere within the
+         * namespace by the execution of this method. Unless:
+         * 1) This method is a module-level executable code method, in which
+         *    case we want make the objects permanent.
+         * 2) There are other threads executing the method, in which case we
+         *    will wait until the last thread has completed.
+         */
+        if (!(MethodDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL) &&
+             (MethodDesc->Method.ThreadCount == 1))
+        {
+            /* Delete any direct children of (created by) this method */
+
+            AcpiNsDeleteNamespaceSubtree (WalkState->MethodNode);
+
+            /*
+             * Delete any objects that were created by this method
+             * elsewhere in the namespace (if any were created).
+             * Use of the ACPI_METHOD_MODIFIED_NAMESPACE optimizes the
+             * deletion such that we don't have to perform an entire
+             * namespace walk for every control method execution.
+             */
+            if (MethodDesc->Method.InfoFlags & ACPI_METHOD_MODIFIED_NAMESPACE)
+            {
+                AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId);
+                MethodDesc->Method.InfoFlags &= ~ACPI_METHOD_MODIFIED_NAMESPACE;
+            }
+        }
+    }
+
+    /* Decrement the thread count on the method */
+
+    if (MethodDesc->Method.ThreadCount)
+    {
+        MethodDesc->Method.ThreadCount--;
+    }
+    else
+    {
+        ACPI_ERROR ((AE_INFO,
+            "Invalid zero thread count in method"));
+    }
+
+    /* Are there any other threads currently executing this method? */
+
+    if (MethodDesc->Method.ThreadCount)
+    {
+        /*
+         * Additional threads. Do not release the OwnerId in this case,
+         * we immediately reuse it for the next thread executing this method
+         */
+        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+            "*** Completed execution of one thread, %u threads remaining\n",
+            MethodDesc->Method.ThreadCount));
+    }
+    else
+    {
+        /* This is the only executing thread for this method */
+
+        /*
+         * Support to dynamically change a method from NotSerialized to
+         * Serialized if it appears that the method is incorrectly written and
+         * does not support multiple thread execution. The best example of this
+         * is if such a method creates namespace objects and blocks. A second
+         * thread will fail with an AE_ALREADY_EXISTS exception.
+         *
+         * This code is here because we must wait until the last thread exits
+         * before marking the method as serialized.
+         */
+        if (MethodDesc->Method.InfoFlags & ACPI_METHOD_SERIALIZED_PENDING)
+        {
+            if (WalkState)
+            {
+                ACPI_INFO ((AE_INFO,
+                    "Marking method %4.4s as Serialized because of AE_ALREADY_EXISTS error",
+                    WalkState->MethodNode->Name.Ascii));
+            }
+
+            /*
+             * Method tried to create an object twice and was marked as
+             * "pending serialized". The probable cause is that the method
+             * cannot handle reentrancy.
+             *
+             * The method was created as NotSerialized, but it tried to create
+             * a named object and then blocked, causing the second thread
+             * entrance to begin and then fail. Workaround this problem by
+             * marking the method permanently as Serialized when the last
+             * thread exits here.
+             */
+            MethodDesc->Method.InfoFlags &= ~ACPI_METHOD_SERIALIZED_PENDING;
+            MethodDesc->Method.InfoFlags |= ACPI_METHOD_SERIALIZED;
+            MethodDesc->Method.SyncLevel = 0;
+        }
+
+        /* No more threads, we can free the OwnerId */
+
+        if (!(MethodDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL))
+        {
+            AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId);
+        }
+    }
+
+    return_VOID;
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dsmthdat.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,772 @@
+/*******************************************************************************
+ *
+ * Module Name: dsmthdat - control method arguments and local variables
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __DSMTHDAT_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+
+
+#define _COMPONENT          ACPI_DISPATCHER
+        ACPI_MODULE_NAME    ("dsmthdat")
+
+/* Local prototypes */
+
+static void
+AcpiDsMethodDataDeleteValue (
+    UINT8                   Type,
+    UINT32                  Index,
+    ACPI_WALK_STATE         *WalkState);
+
+static ACPI_STATUS
+AcpiDsMethodDataSetValue (
+    UINT8                   Type,
+    UINT32                  Index,
+    ACPI_OPERAND_OBJECT     *Object,
+    ACPI_WALK_STATE         *WalkState);
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+ACPI_OBJECT_TYPE
+AcpiDsMethodDataGetType (
+    UINT16                  Opcode,
+    UINT32                  Index,
+    ACPI_WALK_STATE         *WalkState);
+#endif
+
+
+/*******************************************************************************
+ *
+ * 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 namespace nodes for
+ *              each - this allows RefOf and DeRefOf to work properly for these
+ *              special data types.
+ *
+ * NOTES:       WalkState fields are initialized to zero by the
+ *              ACPI_ALLOCATE_ZEROED().
+ *
+ *              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_32_TO_32 (&WalkState->Arguments[i].Name, NAMEOF_ARG_NTE);
+        WalkState->Arguments[i].Name.Integer |= (i << 24);
+        WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
+        WalkState->Arguments[i].Type = ACPI_TYPE_ANY;
+        WalkState->Arguments[i].Flags = ANOBJ_METHOD_ARG;
+    }
+
+    /* Init the method locals */
+
+    for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
+    {
+        ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, NAMEOF_LOCAL_NTE);
+
+        WalkState->LocalVariables[i].Name.Integer |= (i << 24);
+        WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
+        WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY;
+        WalkState->LocalVariables[i].Flags = 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%u=%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%u=%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.
+         * Do not copy the arg in order to implement call by reference
+         */
+        Status = AcpiDsMethodDataSetValue (ACPI_REFCLASS_ARG, Index,
+                    Params[Index], WalkState);
+        if (ACPI_FAILURE (Status))
+        {
+            return_ACPI_STATUS (Status);
+        }
+
+        Index++;
+    }
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%u args passed to method\n", Index));
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsMethodDataGetNode
+ *
+ * PARAMETERS:  Type                - Either ACPI_REFCLASS_LOCAL or
+ *                                    ACPI_REFCLASS_ARG
+ *              Index               - Which Local or Arg whose type to get
+ *              WalkState           - Current walk state object
+ *              Node                - Where the node is returned.
+ *
+ * RETURN:      Status and node
+ *
+ * DESCRIPTION: Get the Node associated with a local or arg.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDsMethodDataGetNode (
+    UINT8                   Type,
+    UINT32                  Index,
+    ACPI_WALK_STATE         *WalkState,
+    ACPI_NAMESPACE_NODE     **Node)
+{
+    ACPI_FUNCTION_TRACE (DsMethodDataGetNode);
+
+
+    /*
+     * Method Locals and Arguments are supported
+     */
+    switch (Type)
+    {
+    case ACPI_REFCLASS_LOCAL:
+
+        if (Index > ACPI_METHOD_MAX_LOCAL)
+        {
+            ACPI_ERROR ((AE_INFO,
+                "Local index %u is invalid (max %u)",
+                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 ACPI_REFCLASS_ARG:
+
+        if (Index > ACPI_METHOD_MAX_ARG)
+        {
+            ACPI_ERROR ((AE_INFO,
+                "Arg index %u is invalid (max %u)",
+                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_ERROR ((AE_INFO, "Type %u is invalid", Type));
+        return_ACPI_STATUS (AE_TYPE);
+    }
+
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsMethodDataSetValue
+ *
+ * PARAMETERS:  Type                - Either ACPI_REFCLASS_LOCAL or
+ *                                    ACPI_REFCLASS_ARG
+ *              Index               - Which Local or Arg 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.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDsMethodDataSetValue (
+    UINT8                   Type,
+    UINT32                  Index,
+    ACPI_OPERAND_OBJECT     *Object,
+    ACPI_WALK_STATE         *WalkState)
+{
+    ACPI_STATUS             Status;
+    ACPI_NAMESPACE_NODE     *Node;
+
+
+    ACPI_FUNCTION_TRACE (DsMethodDataSetValue);
+
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+        "NewObj %p Type %2.2X, Refs=%u [%s]\n", Object,
+        Type, Object->Common.ReferenceCount,
+        AcpiUtGetTypeName (Object->Common.Type)));
+
+    /* Get the namespace node for the arg/local */
+
+    Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /*
+     * Increment ref count so object can't be deleted while installed.
+     * NOTE: We do not copy the object in order to preserve the call by
+     * reference semantics of ACPI Control Method invocation.
+     * (See ACPI Specification 2.0C)
+     */
+    AcpiUtAddReference (Object);
+
+    /* Install the object */
+
+    Node->Object = Object;
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsMethodDataGetValue
+ *
+ * PARAMETERS:  Type                - Either ACPI_REFCLASS_LOCAL or
+ *                                    ACPI_REFCLASS_ARG
+ *              Index               - Which localVar or argument to get
+ *              WalkState           - Current walk state object
+ *              DestDesc            - Where Arg or Local value is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Retrieve value of selected Arg or Local for this method
+ *              Used only in AcpiExResolveToValue().
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDsMethodDataGetValue (
+    UINT8                   Type,
+    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_ERROR ((AE_INFO, "Null object descriptor pointer"));
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    /* Get the namespace node for the arg/local */
+
+    Status = AcpiDsMethodDataGetNode (Type, 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.
+         */
+
+        /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */
+
+        if (AcpiGbl_EnableInterpreterSlack)
+        {
+            Object = AcpiUtCreateIntegerObject ((UINT64) 0);
+            if (!Object)
+            {
+                return_ACPI_STATUS (AE_NO_MEMORY);
+            }
+
+            Node->Object = Object;
+        }
+
+        /* Otherwise, return the error */
+
+        else switch (Type)
+        {
+        case ACPI_REFCLASS_ARG:
+
+            ACPI_ERROR ((AE_INFO,
+                "Uninitialized Arg[%u] at node %p",
+                Index, Node));
+
+            return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
+
+        case ACPI_REFCLASS_LOCAL:
+
+            /*
+             * No error message for this case, will be trapped again later to
+             * detect and ignore cases of Store(LocalX,LocalX)
+             */
+            return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
+
+        default:
+
+            ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: 0x%X", Type));
+            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:  Type                - Either ACPI_REFCLASS_LOCAL or
+ *                                    ACPI_REFCLASS_ARG
+ *              Index               - Which localVar or argument to delete
+ *              WalkState           - Current walk state object
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Delete the entry at Opcode:Index.  Inserts
+ *              a null into the stack slot after the object is deleted.
+ *
+ ******************************************************************************/
+
+static void
+AcpiDsMethodDataDeleteValue (
+    UINT8                   Type,
+    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 (Type, 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:  Type                - Either ACPI_REFCLASS_LOCAL or
+ *                                    ACPI_REFCLASS_ARG
+ *              Index               - Which Local or Arg 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 (
+    UINT8                   Type,
+    UINT32                  Index,
+    ACPI_OPERAND_OBJECT     *ObjDesc,
+    ACPI_WALK_STATE         *WalkState)
+{
+    ACPI_STATUS             Status;
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_OPERAND_OBJECT     *CurrentObjDesc;
+    ACPI_OPERAND_OBJECT     *NewObjDesc;
+
+
+    ACPI_FUNCTION_TRACE (DsStoreObjectToLocal);
+    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%u Obj=%p\n",
+        Type, Index, ObjDesc));
+
+    /* Parameter validation */
+
+    if (!ObjDesc)
+    {
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    /* Get the namespace node for the arg/local */
+
+    Status = AcpiDsMethodDataGetNode (Type, 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 the reference count on the object is more than one, we must
+     * take a copy of the object before we store.  A reference count
+     * of exactly 1 means that the object was just created during the
+     * evaluation of an expression, and we can safely use it since it
+     * is not used anywhere else.
+     */
+    NewObjDesc = ObjDesc;
+    if (ObjDesc->Common.ReferenceCount > 1)
+    {
+        Status = AcpiUtCopyIobjectToIobject (ObjDesc, &NewObjDesc, WalkState);
+        if (ACPI_FAILURE (Status))
+        {
+            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 (Type == ACPI_REFCLASS_ARG)
+        {
+            /*
+             * If we have a valid reference object that came from RefOf(),
+             * do the indirect store
+             */
+            if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_OPERAND) &&
+                (CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
+                (CurrentObjDesc->Reference.Class == ACPI_REFCLASS_REFOF))
+            {
+                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+                        "Arg (%p) is an ObjRef(Node), storing in node %p\n",
+                        NewObjDesc, CurrentObjDesc));
+
+                /*
+                 * Store this object to the Node (perform the indirect store)
+                 * NOTE: No implicit conversion is performed, as per the ACPI
+                 * specification rules on storing to Locals/Args.
+                 */
+                Status = AcpiExStoreObjectToNode (NewObjDesc,
+                            CurrentObjDesc->Reference.Object, WalkState,
+                            ACPI_NO_IMPLICIT_CONVERSION);
+
+                /* Remove local reference if we copied the object above */
+
+                if (NewObjDesc != ObjDesc)
+                {
+                    AcpiUtRemoveReference (NewObjDesc);
+                }
+                return_ACPI_STATUS (Status);
+            }
+        }
+
+        /* Delete the existing object before storing the new one */
+
+        AcpiDsMethodDataDeleteValue (Type, Index, WalkState);
+    }
+
+    /*
+     * Install the Obj descriptor (*NewObjDesc) into
+     * the descriptor for the Arg or Local.
+     * (increments the object reference count by one)
+     */
+    Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState);
+
+    /* Remove local reference if we copied the object above */
+
+    if (NewObjDesc != ObjDesc)
+    {
+        AcpiUtRemoveReference (NewObjDesc);
+    }
+
+    return_ACPI_STATUS (Status);
+}
+
+
+#ifdef ACPI_OBSOLETE_FUNCTIONS
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsMethodDataGetType
+ *
+ * PARAMETERS:  Opcode              - Either AML_LOCAL_OP or AML_ARG_OP
+ *              Index               - Which Local or Arg whose type to get
+ *              WalkState           - Current walk state object
+ *
+ * RETURN:      Data type of current value of the selected Arg or Local
+ *
+ * DESCRIPTION: Get the type of the object stored in the Local or Arg
+ *
+ ******************************************************************************/
+
+ACPI_OBJECT_TYPE
+AcpiDsMethodDataGetType (
+    UINT16                  Opcode,
+    UINT32                  Index,
+    ACPI_WALK_STATE         *WalkState)
+{
+    ACPI_STATUS             Status;
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_OPERAND_OBJECT     *Object;
+
+
+    ACPI_FUNCTION_TRACE (DsMethodDataGetType);
+
+
+    /* Get the namespace node for the arg/local */
+
+    Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
+    if (ACPI_FAILURE (Status))
+    {
+        return_VALUE ((ACPI_TYPE_NOT_FOUND));
+    }
+
+    /* Get the object */
+
+    Object = AcpiNsGetAttachedObject (Node);
+    if (!Object)
+    {
+        /* Uninitialized local/arg, return TYPE_ANY */
+
+        return_VALUE (ACPI_TYPE_ANY);
+    }
+
+    /* Get the object type */
+
+    return_VALUE (Object->Type);
+}
+#endif
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dsobject.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dsobject.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,867 @@
+/******************************************************************************
+ *
+ * Module Name: dsobject - Dispatcher object management routines
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __DSOBJECT_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+
+#define _COMPONENT          ACPI_DISPATCHER
+        ACPI_MODULE_NAME    ("dsobject")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiDsBuildInternalObject (
+    ACPI_WALK_STATE         *WalkState,
+    ACPI_PARSE_OBJECT       *Op,
+    ACPI_OPERAND_OBJECT     **ObjDescPtr);
+
+
+#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!
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDsBuildInternalObject (
+    ACPI_WALK_STATE         *WalkState,
+    ACPI_PARSE_OBJECT       *Op,
+    ACPI_OPERAND_OBJECT     **ObjDescPtr)
+{
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_STATUS             Status;
+    ACPI_OBJECT_TYPE        Type;
+
+
+    ACPI_FUNCTION_TRACE (DsBuildInternalObject);
+
+
+    *ObjDescPtr = NULL;
+    if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
+    {
+        /*
+         * This is a 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_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &(Op->Common.Node)));
+            if (ACPI_FAILURE (Status))
+            {
+                /* Check if we are resolving a named reference within a package */
+
+                if ((Status == AE_NOT_FOUND) && (AcpiGbl_EnableInterpreterSlack) &&
+
+                    ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
+                     (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
+                {
+                    /*
+                     * We didn't find the target and we are populating elements
+                     * of a package - ignore if slack enabled. Some ASL code
+                     * contains dangling invalid references in packages and
+                     * expects that no exception will be issued. Leave the
+                     * element as a null element. It cannot be used, but it
+                     * can be overwritten by subsequent ASL code - this is
+                     * typically the case.
+                     */
+                    ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                        "Ignoring unresolved reference in package [%4.4s]\n",
+                        WalkState->ScopeInfo->Scope.Node->Name.Ascii));
+
+                    return_ACPI_STATUS (AE_OK);
+                }
+                else
+                {
+                    ACPI_ERROR_NAMESPACE (Op->Common.Value.String, Status);
+                }
+
+                return_ACPI_STATUS (Status);
+            }
+        }
+
+        /* Special object resolution for elements of a package */
+
+        if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
+            (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
+        {
+            /*
+             * Attempt to resolve the node to a value before we insert it into
+             * the package. If this is a reference to a common data type,
+             * resolve it immediately. According to the ACPI spec, package
+             * elements can only be "data objects" or method references.
+             * Attempt to resolve to an Integer, Buffer, String or Package.
+             * If cannot, return the named reference (for things like Devices,
+             * Methods, etc.) Buffer Fields and Fields will resolve to simple
+             * objects (int/buf/str/pkg).
+             *
+             * NOTE: References to things like Devices, Methods, Mutexes, etc.
+             * will remain as named references. This behavior is not described
+             * in the ACPI spec, but it appears to be an oversight.
+             */
+            ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Op->Common.Node);
+
+            Status = AcpiExResolveNodeToValue (
+                        ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc),
+                        WalkState);
+            if (ACPI_FAILURE (Status))
+            {
+                return_ACPI_STATUS (Status);
+            }
+
+            /*
+             * Special handling for Alias objects. We need to setup the type
+             * and the Op->Common.Node to point to the Alias target. Note,
+             * Alias has at most one level of indirection internally.
+             */
+            Type = Op->Common.Node->Type;
+            if (Type == ACPI_TYPE_LOCAL_ALIAS)
+            {
+                Type = ObjDesc->Common.Type;
+                Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
+                    Op->Common.Node->Object);
+            }
+
+            switch (Type)
+            {
+            /*
+             * For these types, we need the actual node, not the subobject.
+             * However, the subobject did not get an extra reference count above.
+             *
+             * TBD: should ExResolveNodeToValue be changed to fix this?
+             */
+            case ACPI_TYPE_DEVICE:
+            case ACPI_TYPE_THERMAL:
+
+                AcpiUtAddReference (Op->Common.Node->Object);
+
+                /*lint -fallthrough */
+            /*
+             * For these types, we need the actual node, not the subobject.
+             * The subobject got an extra reference count in ExResolveNodeToValue.
+             */
+            case ACPI_TYPE_MUTEX:
+            case ACPI_TYPE_METHOD:
+            case ACPI_TYPE_POWER:
+            case ACPI_TYPE_PROCESSOR:
+            case ACPI_TYPE_EVENT:
+            case ACPI_TYPE_REGION:
+
+                /* We will create a reference object for these types below */
+                break;
+
+            default:
+                /*
+                 * All other types - the node was resolved to an actual
+                 * object, we are done.
+                 */
+                goto Exit;
+            }
+        }
+    }
+
+    /* Create and init a new 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);
+    }
+
+Exit:
+    *ObjDescPtr = ObjDesc;
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * 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);
+
+
+    /*
+     * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
+     * The buffer object already exists (from the NS node), otherwise it must
+     * be created.
+     */
+    ObjDesc = *ObjDescPtr;
+    if (!ObjDesc)
+    {
+        /* 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_ERROR ((AE_INFO,
+                "Expecting bytelist, found AML opcode 0x%X in op %p",
+                ByteList->Common.AmlOpcode, ByteList));
+
+            AcpiUtRemoveReference (ObjDesc);
+            return (AE_TYPE);
+        }
+
+        ByteListLength = (UINT32) ByteList->Common.Value.Integer;
+    }
+
+    /*
+     * 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_DEBUG_PRINT ((ACPI_DB_EXEC,
+            "Buffer defined with zero length in AML, creating\n"));
+    }
+    else
+    {
+        ObjDesc->Buffer.Pointer = ACPI_ALLOCATE_ZEROED (
+                                        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_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsBuildInternalPackageObj
+ *
+ * PARAMETERS:  WalkState       - Current walk state
+ *              Op              - Parser object to be translated
+ *              ElementCount    - Number of elements in the package - this is
+ *                                the NumElements argument to Package()
+ *              ObjDescPtr      - Where the ACPI internal object is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Translate a parser Op package object to the equivalent
+ *              namespace object
+ *
+ * NOTE: The number of elements in the package will be always be the NumElements
+ * count, regardless of the number of elements in the package list. If
+ * NumElements is smaller, only that many package list elements are used.
+ * if NumElements is larger, the Package object is padded out with
+ * objects of type Uninitialized (as per ACPI spec.)
+ *
+ * Even though the ASL compilers do not allow NumElements to be smaller
+ * than the Package list length (for the fixed length package opcode), some
+ * BIOS code modifies the AML on the fly to adjust the NumElements, and
+ * this code compensates for that. This also provides compatibility with
+ * other AML interpreters.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDsBuildInternalPackageObj (
+    ACPI_WALK_STATE         *WalkState,
+    ACPI_PARSE_OBJECT       *Op,
+    UINT32                  ElementCount,
+    ACPI_OPERAND_OBJECT     **ObjDescPtr)
+{
+    ACPI_PARSE_OBJECT       *Arg;
+    ACPI_PARSE_OBJECT       *Parent;
+    ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
+    ACPI_STATUS             Status = AE_OK;
+    UINT32                  i;
+    UINT16                  Index;
+    UINT16                  ReferenceCount;
+
+
+    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;
+    }
+
+    /*
+     * If we are evaluating a Named package object "Name (xxxx, Package)",
+     * the package object already exists, otherwise it must be created.
+     */
+    ObjDesc = *ObjDescPtr;
+    if (!ObjDesc)
+    {
+        ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);
+        *ObjDescPtr = ObjDesc;
+        if (!ObjDesc)
+        {
+            return_ACPI_STATUS (AE_NO_MEMORY);
+        }
+
+        ObjDesc->Package.Node = Parent->Common.Node;
+    }
+
+    /*
+     * Allocate the element array (array of pointers to the individual
+     * objects) based on the NumElements parameter. Add an extra pointer slot
+     * so that the list is always null terminated.
+     */
+    ObjDesc->Package.Elements = ACPI_ALLOCATE_ZEROED (
+        ((ACPI_SIZE) ElementCount + 1) * sizeof (void *));
+
+    if (!ObjDesc->Package.Elements)
+    {
+        AcpiUtDeleteObjectDesc (ObjDesc);
+        return_ACPI_STATUS (AE_NO_MEMORY);
+    }
+
+    ObjDesc->Package.Count = ElementCount;
+
+    /*
+     * Initialize the elements of the package, up to the NumElements count.
+     * Package is automatically padded with uninitialized (NULL) elements
+     * if NumElements is greater than the package list length. Likewise,
+     * Package is truncated if NumElements is less than the list length.
+     */
+    Arg = Op->Common.Value.Arg;
+    Arg = Arg->Common.Next;
+    for (i = 0; Arg && (i < ElementCount); i++)
+    {
+        if (Arg->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP)
+        {
+            if (Arg->Common.Node->Type == ACPI_TYPE_METHOD)
+            {
+                /*
+                 * A method reference "looks" to the parser to be a method
+                 * invocation, so we special case it here
+                 */
+                Arg->Common.AmlOpcode = AML_INT_NAMEPATH_OP;
+                Status = AcpiDsBuildInternalObject (WalkState, Arg,
+                            &ObjDesc->Package.Elements[i]);
+            }
+            else
+            {
+                /* This package element is already built, just get it */
+
+                ObjDesc->Package.Elements[i] =
+                    ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node);
+            }
+        }
+        else
+        {
+            Status = AcpiDsBuildInternalObject (WalkState, Arg,
+                        &ObjDesc->Package.Elements[i]);
+        }
+
+        if (*ObjDescPtr)
+        {
+            /* Existing package, get existing reference count */
+
+            ReferenceCount = (*ObjDescPtr)->Common.ReferenceCount;
+            if (ReferenceCount > 1)
+            {
+                /* Make new element ref count match original ref count */
+
+                for (Index = 0; Index < (ReferenceCount - 1); Index++)
+                {
+                    AcpiUtAddReference ((ObjDesc->Package.Elements[i]));
+                }
+            }
+        }
+
+        Arg = Arg->Common.Next;
+    }
+
+    /* Check for match between NumElements and actual length of PackageList */
+
+    if (Arg)
+    {
+        /*
+         * NumElements was exhausted, but there are remaining elements in the
+         * PackageList. Truncate the package to NumElements.
+         *
+         * Note: technically, this is an error, from ACPI spec: "It is an error
+         * for NumElements to be less than the number of elements in the
+         * PackageList". However, we just print a message and
+         * no exception is returned. This provides Windows compatibility. Some
+         * BIOSs will alter the NumElements on the fly, creating this type
+         * of ill-formed package object.
+         */
+        while (Arg)
+        {
+            /*
+             * We must delete any package elements that were created earlier
+             * and are not going to be used because of the package truncation.
+             */
+            if (Arg->Common.Node)
+            {
+                AcpiUtRemoveReference (
+                    ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node));
+                Arg->Common.Node = NULL;
+            }
+
+            /* Find out how many elements there really are */
+
+            i++;
+            Arg = Arg->Common.Next;
+        }
+
+        ACPI_INFO ((AE_INFO,
+            "Actual Package length (%u) is larger than NumElements field (%u), truncated\n",
+            i, ElementCount));
+    }
+    else if (i < ElementCount)
+    {
+        /*
+         * Arg list (elements) was exhausted, but we did not reach NumElements count.
+         * Note: this is not an error, the package is padded out with NULLs.
+         */
+        ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+            "Package List length (%u) smaller than NumElements count (%u), padded with null elements\n",
+            i, ElementCount));
+    }
+
+    ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
+    Op->Common.Node = ACPI_CAST_PTR (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 = ObjDesc->Common.Type;
+
+    /* 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 (ObjDesc->Common.Type)
+    {
+    case ACPI_TYPE_BUFFER:
+
+        /*
+         * Defer evaluation of Buffer TermArg operand
+         */
+        ObjDesc->Buffer.Node      = ACPI_CAST_PTR (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_CAST_PTR (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_UINT64_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_VERSION;
+                break;
+
+            default:
+
+                ACPI_ERROR ((AE_INFO,
+                    "Unknown constant opcode 0x%X", Opcode));
+                Status = AE_AML_OPERAND_TYPE;
+                break;
+            }
+            break;
+
+
+        case AML_TYPE_LITERAL:
+
+            ObjDesc->Integer.Value = Op->Common.Value.Integer;
+#ifndef ACPI_NO_METHOD_EXECUTION
+            AcpiExTruncateFor32bitTable (ObjDesc);
+#endif
+            break;
+
+
+        default:
+            ACPI_ERROR ((AE_INFO, "Unknown Integer type 0x%X",
+                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:
+
+            /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */
+
+            ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_LOCAL_OP;
+            ObjDesc->Reference.Class = ACPI_REFCLASS_LOCAL;
+
+#ifndef ACPI_NO_METHOD_EXECUTION
+            Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_LOCAL,
+                        ObjDesc->Reference.Value, WalkState,
+                        ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
+                            &ObjDesc->Reference.Object));
+#endif
+            break;
+
+
+        case AML_TYPE_METHOD_ARGUMENT:
+
+            /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */
+
+            ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_ARG_OP;
+            ObjDesc->Reference.Class = ACPI_REFCLASS_ARG;
+
+#ifndef ACPI_NO_METHOD_EXECUTION
+            Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_ARG,
+                        ObjDesc->Reference.Value, WalkState,
+                        ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
+                            &ObjDesc->Reference.Object));
+#endif
+            break;
+
+        default: /* Object name or Debug object */
+
+            switch (Op->Common.AmlOpcode)
+            {
+            case AML_INT_NAMEPATH_OP:
+
+                /* Node was saved in Op */
+
+                ObjDesc->Reference.Node = Op->Common.Node;
+                ObjDesc->Reference.Object = Op->Common.Node->Object;
+                ObjDesc->Reference.Class = ACPI_REFCLASS_NAME;
+                break;
+
+            case AML_DEBUG_OP:
+
+                ObjDesc->Reference.Class = ACPI_REFCLASS_DEBUG;
+                break;
+
+            default:
+
+                ACPI_ERROR ((AE_INFO,
+                    "Unimplemented reference type for AML opcode: 0x%4.4X", Opcode));
+                return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+            }
+            break;
+        }
+        break;
+
+
+    default:
+
+        ACPI_ERROR ((AE_INFO, "Unimplemented data type: 0x%X",
+            ObjDesc->Common.Type));
+
+        Status = AE_AML_OPERAND_TYPE;
+        break;
+    }
+
+    return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dsopcode.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,809 @@
+/******************************************************************************
+ *
+ * Module Name: dsopcode - Dispatcher suport for regions and fields
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __DSOPCODE_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acevents.h>
+#include <contrib/dev/acpica/include/actables.h>
+
+#define _COMPONENT          ACPI_DISPATCHER
+        ACPI_MODULE_NAME    ("dsopcode")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiDsInitBufferField (
+    UINT16                  AmlOpcode,
+    ACPI_OPERAND_OBJECT     *ObjDesc,
+    ACPI_OPERAND_OBJECT     *BufferDesc,
+    ACPI_OPERAND_OBJECT     *OffsetDesc,
+    ACPI_OPERAND_OBJECT     *LengthDesc,
+    ACPI_OPERAND_OBJECT     *ResultDesc);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsInitializeRegion
+ *
+ * PARAMETERS:  ObjHandle       - Region namespace node
+ *
+ * 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
+ *              LengthDesc      - Length of field (CREATE_FIELD_OP only)
+ *              ResultDesc      - Where to store the result
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Perform actual initialization of a buffer field
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDsInitBufferField (
+    UINT16                  AmlOpcode,
+    ACPI_OPERAND_OBJECT     *ObjDesc,
+    ACPI_OPERAND_OBJECT     *BufferDesc,
+    ACPI_OPERAND_OBJECT     *OffsetDesc,
+    ACPI_OPERAND_OBJECT     *LengthDesc,
+    ACPI_OPERAND_OBJECT     *ResultDesc)
+{
+    UINT32                  Offset;
+    UINT32                  BitOffset;
+    UINT32                  BitCount;
+    UINT8                   FieldFlags;
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE_PTR (DsInitBufferField, ObjDesc);
+
+
+    /* Host object must be a Buffer */
+
+    if (BufferDesc->Common.Type != ACPI_TYPE_BUFFER)
+    {
+        ACPI_ERROR ((AE_INFO,
+            "Target of Create Field is not a Buffer object - %s",
+            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_ERROR ((AE_INFO,
+            "(%s) destination not a NS Node [%s]",
+            AcpiPsGetOpcodeName (AmlOpcode),
+            AcpiUtGetDescriptorName (ResultDesc)));
+
+        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 */
+
+        FieldFlags = AML_FIELD_ACCESS_BYTE;
+        BitOffset  = Offset;
+        BitCount   = (UINT32) LengthDesc->Integer.Value;
+
+        /* Must have a valid (>0) bit count */
+
+        if (BitCount == 0)
+        {
+            ACPI_ERROR ((AE_INFO,
+                "Attempt to CreateField of length zero"));
+            Status = AE_AML_OPERAND_VALUE;
+            goto Cleanup;
+        }
+        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_ERROR ((AE_INFO,
+            "Unknown field creation opcode 0x%02X",
+            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_ERROR ((AE_INFO,
+            "Field [%4.4s] at %u exceeds Buffer [%4.4s] size %u (bits)",
+            AcpiUtGetNodeName (ResultDesc),
+            BitOffset + BitCount,
+            AcpiUtGetNodeName (BufferDesc->Buffer.Node),
+            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);
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_ERROR ((AE_INFO, "(%s) bad operand(s), status 0x%X",
+            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);
+    }
+
+    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_FORMAT_NATIVE_UINT (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:    AcpiDsEvalTableRegionOperands
+ *
+ * PARAMETERS:  WalkState       - Current walk
+ *              Op              - A valid region Op object
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Get region address and length.
+ *              Called from AcpiDsExecEndOp during DataTableRegion parse
+ *              tree walk.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDsEvalTableRegionOperands (
+    ACPI_WALK_STATE         *WalkState,
+    ACPI_PARSE_OBJECT       *Op)
+{
+    ACPI_STATUS             Status;
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_OPERAND_OBJECT     **Operand;
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_PARSE_OBJECT       *NextOp;
+    UINT32                  TableIndex;
+    ACPI_TABLE_HEADER       *Table;
+
+
+    ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op);
+
+
+    /*
+     * This is where we evaluate the SignatureString and OemIDString
+     * and OemTableIDString of the DataTableRegion declaration
+     */
+    Node =  Op->Common.Node;
+
+    /* NextOp points to SignatureString op */
+
+    NextOp = Op->Common.Value.Arg;
+
+    /*
+     * Evaluate/create the SignatureString and OemIDString
+     * and OemTableIDString operands
+     */
+    Status = AcpiDsCreateOperands (WalkState, NextOp);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /*
+     * Resolve the SignatureString and OemIDString
+     * and OemTableIDString operands
+     */
+    Status = AcpiExResolveOperands (Op->Common.AmlOpcode,
+                ACPI_WALK_OPERANDS, WalkState);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    Operand = &WalkState->Operands[0];
+
+    /* Find the ACPI table */
+
+    Status = AcpiTbFindTable (Operand[0]->String.Pointer,
+                Operand[1]->String.Pointer, Operand[2]->String.Pointer,
+                &TableIndex);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    AcpiUtRemoveReference (Operand[0]);
+    AcpiUtRemoveReference (Operand[1]);
+    AcpiUtRemoveReference (Operand[2]);
+
+    Status = AcpiGetTableByIndex (TableIndex, &Table);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    ObjDesc = AcpiNsGetAttachedObject (Node);
+    if (!ObjDesc)
+    {
+        return_ACPI_STATUS (AE_NOT_EXIST);
+    }
+
+    ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table);
+    ObjDesc->Region.Length = Table->Length;
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
+        ObjDesc,
+        ACPI_FORMAT_NATIVE_UINT (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 object 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 */
+
+    /*
+     * Set proper index into operand stack for AcpiDsObjStackPush
+     * invoked inside AcpiDsCreateOperand.
+     */
+    WalkState->OperandIndex = WalkState->NumOperands;
+
+    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:    AcpiDsEvalBankFieldOperands
+ *
+ * PARAMETERS:  WalkState       - Current walk
+ *              Op              - A valid BankField Op object
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Get BankField BankValue
+ *              Called from AcpiDsExecEndOp during BankField parse tree walk
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDsEvalBankFieldOperands (
+    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_PARSE_OBJECT       *Arg;
+
+
+    ACPI_FUNCTION_TRACE_PTR (DsEvalBankFieldOperands, Op);
+
+
+    /*
+     * This is where we evaluate the BankValue field of the
+     * BankField declaration
+     */
+
+    /* NextOp points to the op that holds the Region */
+
+    NextOp = Op->Common.Value.Arg;
+
+    /* NextOp points to the op that holds the Bank Register */
+
+    NextOp = NextOp->Common.Next;
+
+    /* NextOp points to the op that holds the Bank Value */
+
+    NextOp = NextOp->Common.Next;
+
+    /*
+     * Set proper index into operand stack for AcpiDsObjStackPush
+     * invoked inside AcpiDsCreateOperand.
+     *
+     * We use WalkState->Operands[0] to store the evaluated BankValue
+     */
+    WalkState->OperandIndex = 0;
+
+    Status = AcpiDsCreateOperand (WalkState, NextOp, 0);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    Status = AcpiExResolveToValue (&WalkState->Operands[0], WalkState);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS,
+        AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 1);
+    /*
+     * Get the BankValue operand and save it
+     * (at Top of stack)
+     */
+    OperandDesc = WalkState->Operands[0];
+
+    /* Arg points to the start Bank Field */
+
+    Arg = AcpiPsGetArg (Op, 4);
+    while (Arg)
+    {
+        /* Ignore OFFSET and ACCESSAS terms here */
+
+        if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
+        {
+            Node = Arg->Common.Node;
+
+            ObjDesc = AcpiNsGetAttachedObject (Node);
+            if (!ObjDesc)
+            {
+                return_ACPI_STATUS (AE_NOT_EXIST);
+            }
+
+            ObjDesc->BankField.Value = (UINT32) OperandDesc->Integer.Value;
+        }
+
+        /* Move to next field in the list */
+
+        Arg = Arg->Common.Next;
+    }
+
+    AcpiUtRemoveReference (OperandDesc);
+    return_ACPI_STATUS (Status);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dsutils.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dsutils.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,937 @@
+/*******************************************************************************
+ *
+ * Module Name: dsutils - Dispatcher utilities
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __DSUTILS_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+
+#define _COMPONENT          ACPI_DISPATCHER
+        ACPI_MODULE_NAME    ("dsutils")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsClearImplicitReturn
+ *
+ * PARAMETERS:  WalkState           - Current State
+ *
+ * RETURN:      None.
+ *
+ * DESCRIPTION: Clear and remove a reference on an implicit return value.  Used
+ *              to delete "stale" return values (if enabled, the return value
+ *              from every operator is saved at least momentarily, in case the
+ *              parent method exits.)
+ *
+ ******************************************************************************/
+
+void
+AcpiDsClearImplicitReturn (
+    ACPI_WALK_STATE         *WalkState)
+{
+    ACPI_FUNCTION_NAME (DsClearImplicitReturn);
+
+
+    /*
+     * Slack must be enabled for this feature
+     */
+    if (!AcpiGbl_EnableInterpreterSlack)
+    {
+        return;
+    }
+
+    if (WalkState->ImplicitReturnObj)
+    {
+        /*
+         * Delete any "stale" implicit return. However, in
+         * complex statements, the implicit return value can be
+         * bubbled up several levels.
+         */
+        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+            "Removing reference on stale implicit return obj %p\n",
+            WalkState->ImplicitReturnObj));
+
+        AcpiUtRemoveReference (WalkState->ImplicitReturnObj);
+        WalkState->ImplicitReturnObj = NULL;
+    }
+}
+
+
+#ifndef ACPI_NO_METHOD_EXECUTION
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsDoImplicitReturn
+ *
+ * PARAMETERS:  ReturnDesc          - The return value
+ *              WalkState           - Current State
+ *              AddReference        - True if a reference should be added to the
+ *                                    return object
+ *
+ * RETURN:      TRUE if implicit return enabled, FALSE otherwise
+ *
+ * DESCRIPTION: Implements the optional "implicit return".  We save the result
+ *              of every ASL operator and control method invocation in case the
+ *              parent method exit.  Before storing a new return value, we
+ *              delete the previous return value.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiDsDoImplicitReturn (
+    ACPI_OPERAND_OBJECT     *ReturnDesc,
+    ACPI_WALK_STATE         *WalkState,
+    BOOLEAN                 AddReference)
+{
+    ACPI_FUNCTION_NAME (DsDoImplicitReturn);
+
+
+    /*
+     * Slack must be enabled for this feature, and we must
+     * have a valid return object
+     */
+    if ((!AcpiGbl_EnableInterpreterSlack) ||
+        (!ReturnDesc))
+    {
+        return (FALSE);
+    }
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+            "Result %p will be implicitly returned; Prev=%p\n",
+            ReturnDesc,
+            WalkState->ImplicitReturnObj));
+
+    /*
+     * Delete any "stale" implicit return value first. However, in
+     * complex statements, the implicit return value can be
+     * bubbled up several levels, so we don't clear the value if it
+     * is the same as the ReturnDesc.
+     */
+    if (WalkState->ImplicitReturnObj)
+    {
+        if (WalkState->ImplicitReturnObj == ReturnDesc)
+        {
+            return (TRUE);
+        }
+        AcpiDsClearImplicitReturn (WalkState);
+    }
+
+    /* Save the implicit return value, add a reference if requested */
+
+    WalkState->ImplicitReturnObj = ReturnDesc;
+    if (AddReference)
+    {
+        AcpiUtAddReference (ReturnDesc);
+    }
+
+    return (TRUE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsIsResultUsed
+ *
+ * PARAMETERS:  Op                  - Current Op
+ *              WalkState           - Current State
+ *
+ * RETURN:      TRUE if result is used, FALSE otherwise
+ *
+ * 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_ERROR ((AE_INFO, "Null Op"));
+        return_UINT8 (TRUE);
+    }
+
+    /*
+     * We know that this operator is not a
+     * Return() operator (would not come here.) The following code is the
+     * optional support for a so-called "implicit return". Some AML code
+     * assumes that the last value of the method is "implicitly" returned
+     * to the caller. Just save the last result as the return value.
+     * NOTE: this is optional because the ASL language does not actually
+     * support this behavior.
+     */
+    (void) AcpiDsDoImplicitReturn (WalkState->ResultObj, WalkState, TRUE);
+
+    /*
+     * Now determine if the parent will use the result
+     *
+     * If there is no parent, or the parent is a ScopeOp, we are executing
+     * at the method level. An executing method typically has no parent,
+     * since each method is parsed separately.  A method invoked externally
+     * via ExecuteControlMethod has a ScopeOp as the parent.
+     */
+    if ((!Op->Common.Parent) ||
+        (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP))
+    {
+        /* No parent, the return value cannot possibly be used */
+
+        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+            "At Method level, result of [%s] not used\n",
+            AcpiPsGetOpcodeName (Op->Common.AmlOpcode)));
+        return_UINT8 (FALSE);
+    }
+
+    /* Get info on the parent. The RootOp is AML_SCOPE */
+
+    ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
+    if (ParentInfo->Class == AML_CLASS_UNKNOWN)
+    {
+        ACPI_ERROR ((AE_INFO,
+            "Unknown parent opcode Op=%p", Op));
+        return_UINT8 (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) ||
+            (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_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_UINT8 (TRUE);
+
+
+ResultNotUsed:
+    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+        "Result of [%s] not used by Parent [%s] Op=%p\n",
+        AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
+        AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op));
+
+    return_UINT8 (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsDeleteResultIfNotUsed
+ *
+ * PARAMETERS:  Op              - Current parse Op
+ *              ResultObj       - Result of the operation
+ *              WalkState       - Current state
+ *
+ * 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_ERROR ((AE_INFO, "Null Op"));
+        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 reference, not by value.  This means
+     * that the actual objects are passed, not copies of the objects.
+     */
+    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 (DsClearOperands, 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       - Current walk state
+ *              Arg             - Parse object for the argument
+ *              ArgIndex        - Which argument (zero based)
+ *
+ * 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) &&
+        !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK))
+    {
+        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 */
+
+        /*
+         * Special handling for BufferField declarations.  This is a deferred
+         * opcode that unfortunately defines the field name as the last
+         * parameter instead of the first.  We get here when we are performing
+         * the deferred execution, so the actual name of the field is already
+         * in the namespace.  We don't want to attempt to look it up again
+         * because we may be executing in a different scope than where the
+         * actual opcode exists.
+         */
+        if ((WalkState->DeferredNode) &&
+            (WalkState->DeferredNode->Type == ACPI_TYPE_BUFFER_FIELD) &&
+            (ArgIndex == (UINT32) ((WalkState->Opcode == AML_CREATE_FIELD_OP) ? 3 : 2)))
+        {
+            ObjDesc = ACPI_CAST_PTR (
+                        ACPI_OPERAND_OBJECT, WalkState->DeferredNode);
+            Status = AE_OK;
+        }
+        else    /* All other opcodes */
+        {
+            /*
+             * 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_ERROR_NAMESPACE (NameString, Status);
+            }
+        }
+
+        /* Free the namestring created above */
+
+        ACPI_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) &&
+            !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK))
+        {
+            /*
+             * 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) || (Arg->Common.Flags & ACPI_PARSEOP_IN_STACK))
+        {
+            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 = AcpiDsResultPop (&ObjDesc, WalkState);
+            if (ACPI_FAILURE (Status))
+            {
+                /*
+                 * Only error is underflow, and this indicates
+                 * a missing or null operand!
+                 */
+                ACPI_EXCEPTION ((AE_INFO, Status,
+                    "Missing or null operand"));
+                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:  WalkState           - Current state
+ *              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;
+    ACPI_PARSE_OBJECT       *Arguments[ACPI_OBJ_NUM_OPERANDS];
+    UINT32                  ArgCount = 0;
+    UINT32                  Index = WalkState->NumOperands;
+    UINT32                  i;
+
+
+    ACPI_FUNCTION_TRACE_PTR (DsCreateOperands, FirstArg);
+
+
+    /* Get all arguments in the list */
+
+    Arg = FirstArg;
+    while (Arg)
+    {
+        if (Index >= ACPI_OBJ_NUM_OPERANDS)
+        {
+            return_ACPI_STATUS (AE_BAD_DATA);
+        }
+
+        Arguments[Index] = Arg;
+        WalkState->Operands [Index] = NULL;
+
+        /* Move on to next argument, if any */
+
+        Arg = Arg->Common.Next;
+        ArgCount++;
+        Index++;
+    }
+
+    Index--;
+
+    /* It is the appropriate order to get objects from the Result stack */
+
+    for (i = 0; i < ArgCount; i++)
+    {
+        Arg = Arguments[Index];
+
+        /* Force the filling of the operand stack in inverse order */
+
+        WalkState->OperandIndex = (UINT8) Index;
+
+        Status = AcpiDsCreateOperand (WalkState, Arg, Index);
+        if (ACPI_FAILURE (Status))
+        {
+            goto Cleanup;
+        }
+
+        Index--;
+
+        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%u (%p) done, Arg1=%p\n",
+            Index, Arg, FirstArg));
+    }
+
+    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
+     */
+    AcpiDsObjStackPopAndDelete (ArgCount, WalkState);
+
+    ACPI_EXCEPTION ((AE_INFO, Status, "While creating Arg %u", Index));
+    return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION:    AcpiDsEvaluateNamePath
+ *
+ * PARAMETERS:  WalkState       - Current state of the parse tree walk,
+ *                                the opcode of current operation should be
+ *                                AML_INT_NAMEPATH_OP
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Translate the -NamePath- parse tree object to the equivalent
+ *              interpreter object, convert it to value, if needed, duplicate
+ *              it, if needed, and push it onto the current result stack.
+ *
+ ****************************************************************************/
+
+ACPI_STATUS
+AcpiDsEvaluateNamePath (
+    ACPI_WALK_STATE         *WalkState)
+{
+    ACPI_STATUS             Status = AE_OK;
+    ACPI_PARSE_OBJECT       *Op = WalkState->Op;
+    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
+    ACPI_OPERAND_OBJECT     *NewObjDesc;
+    UINT8                   Type;
+
+
+    ACPI_FUNCTION_TRACE_PTR (DsEvaluateNamePath, WalkState);
+
+
+    if (!Op->Common.Parent)
+    {
+        /* This happens after certain exception processing */
+
+        goto Exit;
+    }
+
+    if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
+        (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) ||
+        (Op->Common.Parent->Common.AmlOpcode == AML_REF_OF_OP))
+    {
+        /* TBD: Should we specify this feature as a bit of OpInfo->Flags of these opcodes? */
+
+        goto Exit;
+    }
+
+    Status = AcpiDsCreateOperand (WalkState, Op, 0);
+    if (ACPI_FAILURE (Status))
+    {
+        goto Exit;
+    }
+
+    if (Op->Common.Flags & ACPI_PARSEOP_TARGET)
+    {
+        NewObjDesc = *Operand;
+        goto PushResult;
+    }
+
+    Type = (*Operand)->Common.Type;
+
+    Status = AcpiExResolveToValue (Operand, WalkState);
+    if (ACPI_FAILURE (Status))
+    {
+        goto Exit;
+    }
+
+    if (Type == ACPI_TYPE_INTEGER)
+    {
+        /* It was incremented by AcpiExResolveToValue */
+
+        AcpiUtRemoveReference (*Operand);
+
+        Status = AcpiUtCopyIobjectToIobject (*Operand, &NewObjDesc, WalkState);
+        if (ACPI_FAILURE (Status))
+        {
+            goto Exit;
+        }
+    }
+    else
+    {
+        /*
+         * The object either was anew created or is
+         * a Namespace node - don't decrement it.
+         */
+        NewObjDesc = *Operand;
+    }
+
+    /* Cleanup for name-path operand */
+
+    Status = AcpiDsObjStackPop (1, WalkState);
+    if (ACPI_FAILURE (Status))
+    {
+        WalkState->ResultObj = NewObjDesc;
+        goto Exit;
+    }
+
+PushResult:
+
+    WalkState->ResultObj = NewObjDesc;
+
+    Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
+    if (ACPI_SUCCESS (Status))
+    {
+        /* Force to take it from stack */
+
+        Op->Common.Flags |= ACPI_PARSEOP_IN_STACK;
+    }
+
+Exit:
+
+    return_ACPI_STATUS (Status);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dswexec.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dswexec.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,797 @@
+/******************************************************************************
+ *
+ * Module Name: dswexec - Dispatcher method execution callbacks;
+ *                        dispatch to interpreter.
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __DSWEXEC_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acdebug.h>
+
+
+#define _COMPONENT          ACPI_DISPATCHER
+        ACPI_MODULE_NAME    ("dswexec")
+
+/*
+ * Dispatch table for opcode classes
+ */
+static ACPI_EXECUTE_OP      AcpiGbl_OpTypeDispatch [] =
+{
+    AcpiExOpcode_0A_0T_1R,
+    AcpiExOpcode_1A_0T_0R,
+    AcpiExOpcode_1A_0T_1R,
+    AcpiExOpcode_1A_1T_0R,
+    AcpiExOpcode_1A_1T_1R,
+    AcpiExOpcode_2A_0T_0R,
+    AcpiExOpcode_2A_0T_1R,
+    AcpiExOpcode_2A_1T_1R,
+    AcpiExOpcode_2A_2T_1R,
+    AcpiExOpcode_3A_0T_0R,
+    AcpiExOpcode_3A_1T_1R,
+    AcpiExOpcode_6A_0T_1R
+};
+
+
+/*****************************************************************************
+ *
+ * FUNCTION:    AcpiDsGetPredicateValue
+ *
+ * PARAMETERS:  WalkState       - Current state of the parse tree walk
+ *              ResultObj       - if non-zero, pop result from result stack
+ *
+ * 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_OPERAND_OBJECT     *LocalObjDesc = NULL;
+
+
+    ACPI_FUNCTION_TRACE_PTR (DsGetPredicateValue, WalkState);
+
+
+    WalkState->ControlState->Common.State = 0;
+
+    if (ResultObj)
+    {
+        Status = AcpiDsResultPop (&ObjDesc, WalkState);
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_EXCEPTION ((AE_INFO, Status,
+                "Could not get result from predicate evaluation"));
+
+            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_ERROR ((AE_INFO,
+            "No predicate ObjDesc=%p State=%p",
+            ObjDesc, WalkState));
+
+        return_ACPI_STATUS (AE_AML_NO_OPERAND);
+    }
+
+    /*
+     * Result of predicate evaluation must be an Integer
+     * object. Implicitly convert the argument if necessary.
+     */
+    Status = AcpiExConvertToInteger (ObjDesc, &LocalObjDesc, 16);
+    if (ACPI_FAILURE (Status))
+    {
+        goto Cleanup;
+    }
+
+    if (LocalObjDesc->Common.Type != ACPI_TYPE_INTEGER)
+    {
+        ACPI_ERROR ((AE_INFO,
+            "Bad predicate (not an integer) ObjDesc=%p State=%p Type=0x%X",
+            ObjDesc, WalkState, ObjDesc->Common.Type));
+
+        Status = AE_AML_OPERAND_TYPE;
+        goto Cleanup;
+    }
+
+    /* Truncate the predicate to 32-bits if necessary */
+
+    AcpiExTruncateFor32bitTable (LocalObjDesc);
+
+    /*
+     * Save the result of the predicate evaluation on
+     * the control stack
+     */
+    if (LocalObjDesc->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;
+    }
+
+    /* Predicate can be used for an implicit return value */
+
+    (void) AcpiDsDoImplicitReturn (LocalObjDesc, WalkState, TRUE);
+
+
+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 (LocalObjDesc, WalkState));
+
+    /*
+     * Delete the predicate result object (we know that
+     * we don't need it anymore)
+     */
+    if (LocalObjDesc != ObjDesc)
+    {
+        AcpiUtRemoveReference (LocalObjDesc);
+    }
+    AcpiUtRemoveReference (ObjDesc);
+
+    WalkState->ControlState->Common.State = ACPI_CONTROL_NORMAL;
+    return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION:    AcpiDsExecBeginOp
+ *
+ * PARAMETERS:  WalkState       - Current state of the parse tree walk
+ *              OutOp           - Where to 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))
+        {
+            goto ErrorExit;
+        }
+
+        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))
+            {
+                goto ErrorExit;
+            }
+        }
+    }
+
+    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 = 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.
+             *
+             * Note 10/2010: Except for the Scope() op. This opcode does
+             * not actually create a new object, it refers to an existing
+             * object. However, for Scope(), we want to indeed open a
+             * new scope.
+             */
+            if (Op->Common.AmlOpcode != AML_SCOPE_OP)
+            {
+                Status = AcpiDsLoad2BeginOp (WalkState, NULL);
+            }
+            else
+            {
+                Status = AcpiDsScopeStackPush (Op->Named.Node,
+                            Op->Named.Node->Type, WalkState);
+                if (ACPI_FAILURE (Status))
+                {
+                    return_ACPI_STATUS (Status);
+                }
+            }
+        }
+        break;
+
+
+    case AML_CLASS_EXECUTE:
+    case AML_CLASS_CREATE:
+
+        break;
+
+
+    default:
+        break;
+    }
+
+    /* Nothing to do here during method execution */
+
+    return_ACPI_STATUS (Status);
+
+
+ErrorExit:
+    Status = AcpiDsMethodError (Status, WalkState);
+    return_ACPI_STATUS (Status);
+}
+
+
+/*****************************************************************************
+ *
+ * FUNCTION:    AcpiDsExecEndOp
+ *
+ * PARAMETERS:  WalkState       - Current state of the parse tree walk
+ *
+ * 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_ERROR ((AE_INFO, "Unknown opcode 0x%X", Op->Common.AmlOpcode));
+        return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
+    }
+
+    FirstArg = Op->Common.Value.Arg;
+
+    /* Init the walk state */
+
+    WalkState->NumOperands = 0;
+    WalkState->OperandIndex = 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. */
+
+        if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
+        {
+            Status = AcpiDsEvaluateNamePath (WalkState);
+            if (ACPI_FAILURE (Status))
+            {
+                goto Cleanup;
+            }
+        }
+        break;
+
+
+    case AML_CLASS_EXECUTE:     /* Most operators with arguments */
+
+        /* Build resolved operand stack */
+
+        Status = AcpiDsCreateOperands (WalkState, FirstArg);
+        if (ACPI_FAILURE (Status))
+        {
+            goto Cleanup;
+        }
+
+        /*
+         * All opcodes require operand resolution, with the only exceptions
+         * being the ObjectType and SizeOf operators.
+         */
+        if (!(WalkState->OpInfo->Flags & AML_NO_OPERAND_RESOLVE))
+        {
+            /* Resolve all operands */
+
+            Status = AcpiExResolveOperands (WalkState->Opcode,
+                        &(WalkState->Operands [WalkState->NumOperands -1]),
+                        WalkState);
+        }
+
+        if (ACPI_SUCCESS (Status))
+        {
+            /*
+             * 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
+        {
+            /*
+             * Treat constructs of the form "Store(LocalX,LocalX)" as noops when the
+             * Local is uninitialized.
+             */
+            if  ((Status == AE_AML_UNINITIALIZED_LOCAL) &&
+                (WalkState->Opcode == AML_STORE_OP) &&
+                (WalkState->Operands[0]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
+                (WalkState->Operands[1]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
+                (WalkState->Operands[0]->Reference.Class ==
+                 WalkState->Operands[1]->Reference.Class) &&
+                (WalkState->Operands[0]->Reference.Value ==
+                 WalkState->Operands[1]->Reference.Value))
+            {
+                Status = AE_OK;
+            }
+            else
+            {
+                ACPI_EXCEPTION ((AE_INFO, Status,
+                    "While resolving operands for [%s]",
+                    AcpiPsGetOpcodeName (WalkState->Opcode)));
+            }
+        }
+
+        /* 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);
+
+            break;
+
+
+        case AML_TYPE_METHOD_CALL:
+
+            /*
+             * If the method is referenced from within a package
+             * declaration, it is not a invocation of the method, just
+             * a reference to it.
+             */
+            if ((Op->Asl.Parent) &&
+               ((Op->Asl.Parent->Asl.AmlOpcode == AML_PACKAGE_OP) ||
+                (Op->Asl.Parent->Asl.AmlOpcode == AML_VAR_PACKAGE_OP)))
+            {
+                ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+                    "Method Reference in a Package, Op=%p\n", Op));
+
+                Op->Common.Node = (ACPI_NAMESPACE_NODE *) Op->Asl.Value.Arg->Asl.Node;
+                AcpiUtAddReference (Op->Asl.Value.Arg->Asl.Node->Object);
+                return_ACPI_STATUS (AE_OK);
+            }
+
+            ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", Op));
+
+            /*
+             * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.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 (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;
+                }
+            }
+            else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP)
+            {
+                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+                    "Executing DataTableRegion Strings Op=%p\n", Op));
+
+                Status = AcpiDsEvalTableRegionOperands (WalkState, Op);
+                if (ACPI_FAILURE (Status))
+                {
+                    break;
+                }
+            }
+            else if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP)
+            {
+                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+                    "Executing BankField Op=%p\n", Op));
+
+                Status = AcpiDsEvalBankFieldOperands (WalkState, Op);
+                if (ACPI_FAILURE (Status))
+                {
+                    break;
+                }
+            }
+            break;
+
+
+        case AML_TYPE_UNDEFINED:
+
+            ACPI_ERROR ((AE_INFO,
+                "Undefined opcode type Op=%p", 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_ERROR ((AE_INFO,
+                "Unimplemented opcode, class=0x%X type=0x%X Opcode=-0x%X Op=%p",
+                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 ((ACPI_SUCCESS (Status)) &&
+        (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);
+    }
+
+#ifdef _UNDER_DEVELOPMENT
+
+    if (WalkState->ParserState.Aml == WalkState->ParserState.AmlEnd)
+    {
+        AcpiDbMethodEnd (WalkState);
+    }
+#endif
+
+    /* Invoke exception handler on error */
+
+    if (ACPI_FAILURE (Status))
+    {
+        Status = AcpiDsMethodError (Status, WalkState);
+    }
+
+    /* Always clear the object stack */
+
+    WalkState->NumOperands = 0;
+    return_ACPI_STATUS (Status);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dswload.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dswload.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,551 @@
+/******************************************************************************
+ *
+ * Module Name: dswload - Dispatcher first pass namespace load callbacks
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __DSWLOAD_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#ifdef ACPI_ASL_COMPILER
+#include <contrib/dev/acpica/include/acdisasm.h>
+#endif
+
+#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
+ *              OutOp           - Where to return op if a new one is created
+ *
+ * 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_TRACE (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))
+        {
+            *OutOp = Op;
+            return_ACPI_STATUS (AE_OK);
+        }
+
+        /* Check if this object has already been installed in the namespace */
+
+        if (Op->Common.Node)
+        {
+            *OutOp = Op;
+            return_ACPI_STATUS (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]\n", 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));
+#ifdef ACPI_ASL_COMPILER
+        if (Status == AE_NOT_FOUND)
+        {
+            /*
+             * Table disassembly:
+             * Target of Scope() not found. Generate an External for it, and
+             * insert the name into the namespace.
+             */
+            AcpiDmAddToExternalList (Op, Path, ACPI_TYPE_DEVICE, 0);
+            Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
+                       ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT,
+                       WalkState, &Node);
+        }
+#endif
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_ERROR_NAMESPACE (Path, Status);
+            return_ACPI_STATUS (Status);
+        }
+
+        /*
+         * Check to make sure that the target is
+         * one of the opcodes that actually opens a scope
+         */
+        switch (Node->Type)
+        {
+        case ACPI_TYPE_ANY:
+        case ACPI_TYPE_LOCAL_SCOPE:         /* Scope  */
+        case ACPI_TYPE_DEVICE:
+        case ACPI_TYPE_POWER:
+        case ACPI_TYPE_PROCESSOR:
+        case ACPI_TYPE_THERMAL:
+
+            /* These are acceptable types */
+            break;
+
+        case ACPI_TYPE_INTEGER:
+        case ACPI_TYPE_STRING:
+        case ACPI_TYPE_BUFFER:
+
+            /*
+             * These types we will allow, but we will change the type.
+             * This enables some existing code of the form:
+             *
+             *  Name (DEB, 0)
+             *  Scope (DEB) { ... }
+             *
+             * Note: silently change the type here. On the second pass,
+             * we will report a warning
+             */
+            ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                "Type override - [%4.4s] had invalid type (%s) "
+                "for Scope operator, changed to type ANY\n",
+                AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
+
+            Node->Type = ACPI_TYPE_ANY;
+            WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
+            break;
+
+        default:
+
+            /* All other types are an error */
+
+            ACPI_ERROR ((AE_INFO,
+                "Invalid type (%s) for target of "
+                "Scope operator [%4.4s] (Cannot override)",
+                AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
+
+            return_ACPI_STATUS (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.
+         */
+        if (WalkState->DeferredNode)
+        {
+            /* This name is already in the namespace, get the node */
+
+            Node = WalkState->DeferredNode;
+            Status = AE_OK;
+            break;
+        }
+
+        /*
+         * If we are executing a method, do not create any namespace objects
+         * during the load phase, only during execution.
+         */
+        if (WalkState->MethodNode)
+        {
+            Node = NULL;
+            Status = AE_OK;
+            break;
+        }
+
+        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 ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n",
+                    AcpiUtGetTypeName (ObjectType)));
+        }
+        else
+        {
+            ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+                "[%s] Both Find or Create allowed\n",
+                    AcpiUtGetTypeName (ObjectType)));
+        }
+
+        /*
+         * Enter the named type into the internal namespace. We enter the name
+         * as we go downward in the parse tree. Any necessary subobjects that
+         * involve arguments to the opcode must be created as we go back up the
+         * parse tree later.
+         */
+        Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
+                        ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node);
+        if (ACPI_FAILURE (Status))
+        {
+            if (Status == AE_ALREADY_EXISTS)
+            {
+                /* The name already exists in this scope */
+
+                if (Node->Flags & ANOBJ_IS_EXTERNAL)
+                {
+                    /*
+                     * Allow one create on an object or segment that was
+                     * previously declared External
+                     */
+                    Node->Flags &= ~ANOBJ_IS_EXTERNAL;
+                    Node->Type = (UINT8) ObjectType;
+
+                    /* Just retyped a node, probably will need to open a scope */
+
+                    if (AcpiNsOpensScope (ObjectType))
+                    {
+                        Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
+                        if (ACPI_FAILURE (Status))
+                        {
+                            return_ACPI_STATUS (Status);
+                        }
+                    }
+
+                    Status = AE_OK;
+                }
+            }
+
+            if (ACPI_FAILURE (Status))
+            {
+                ACPI_ERROR_NAMESPACE (Path, Status);
+                return_ACPI_STATUS (Status);
+            }
+        }
+        break;
+    }
+
+    /* Common exit */
+
+    if (!Op)
+    {
+        /* Create a new op */
+
+        Op = AcpiPsAllocOp (WalkState->Opcode);
+        if (!Op)
+        {
+            return_ACPI_STATUS (AE_NO_MEMORY);
+        }
+    }
+
+    /* Initialize the op */
+
+#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY))
+    Op->Named.Path = ACPI_CAST_PTR (UINT8, Path);
+#endif
+
+    if (Node)
+    {
+        /*
+         * 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;
+        Op->Named.Name = Node->Name.Integer;
+    }
+
+    AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op);
+    *OutOp = Op;
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsLoad1EndOp
+ *
+ * PARAMETERS:  WalkState       - Current state of the parse tree walk
+ *
+ * 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_TRACE (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_ACPI_STATUS (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 we are executing a method, do not create any namespace objects
+         * during the load phase, only during execution.
+         */
+        if (!WalkState->MethodNode)
+        {
+            if (WalkState->Opcode == AML_FIELD_OP          ||
+                WalkState->Opcode == AML_BANK_FIELD_OP     ||
+                WalkState->Opcode == AML_INDEX_FIELD_OP)
+            {
+                Status = AcpiDsInitFieldObjects (Op, WalkState);
+            }
+        }
+        return_ACPI_STATUS (Status);
+    }
+
+    /*
+     * If we are executing a method, do not create any namespace objects
+     * during the load phase, only during execution.
+     */
+    if (!WalkState->MethodNode)
+    {
+        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_ACPI_STATUS (Status);
+            }
+        }
+        else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP)
+        {
+            Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
+                        ACPI_ADR_SPACE_DATA_TABLE, WalkState);
+            if (ACPI_FAILURE (Status))
+            {
+                return_ACPI_STATUS (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;
+
+            /* Set node type if we have a namespace node */
+
+            if (Op->Common.Node)
+            {
+                Op->Common.Node->Type = (UINT8) ObjectType;
+            }
+        }
+    }
+
+    /*
+     * If we are executing a method, do not create any namespace objects
+     * during the load phase, only during execution.
+     */
+    if (!WalkState->MethodNode)
+    {
+        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] = ACPI_CAST_PTR (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_ACPI_STATUS (Status);
+                }
+            }
+        }
+    }
+
+    /* Pop the scope stack (only if loading a table) */
+
+    if (!WalkState->MethodNode &&
+        AcpiNsOpensScope (ObjectType))
+    {
+        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s): Popping scope for Op %p\n",
+            AcpiUtGetTypeName (ObjectType), Op));
+
+        Status = AcpiDsScopeStackPop (WalkState);
+    }
+
+    return_ACPI_STATUS (Status);
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dswload2.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dswload2.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,747 @@
+/******************************************************************************
+ *
+ * Module Name: dswload2 - Dispatcher second pass namespace load callbacks
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __DSWLOAD2_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acparser.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acevents.h>
+
+#define _COMPONENT          ACPI_DISPATCHER
+        ACPI_MODULE_NAME    ("dswload2")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsLoad2BeginOp
+ *
+ * PARAMETERS:  WalkState       - Current state of the parse tree walk
+ *              OutOp           - Wher to return op if a new one is created
+ *
+ * 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;
+    UINT32                  Flags;
+
+
+    ACPI_FUNCTION_TRACE (DsLoad2BeginOp);
+
+
+    Op = WalkState->Op;
+    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState));
+
+    if (Op)
+    {
+        if ((WalkState->ControlState) &&
+            (WalkState->ControlState->Common.State ==
+                ACPI_CONTROL_CONDITIONAL_EXECUTING))
+        {
+            /* We are executing a while loop outside of a method */
+
+            Status = AcpiDsExecBeginOp (WalkState, OutOp);
+            return_ACPI_STATUS (Status);
+        }
+
+        /* We only care about Namespace opcodes here */
+
+        if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE)   &&
+              (WalkState->Opcode != AML_INT_NAMEPATH_OP)) ||
+            (!(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 = ACPI_CAST_PTR (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:
+
+        /* Special case for Scope(\) -> refers to the Root node */
+
+        if (Op && (Op->Named.Node == AcpiGbl_RootNode))
+        {
+            Node = Op->Named.Node;
+
+            Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
+            if (ACPI_FAILURE (Status))
+            {
+                return_ACPI_STATUS (Status);
+            }
+        }
+        else
+        {
+            /*
+             * 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))
+            {
+#ifdef ACPI_ASL_COMPILER
+                if (Status == AE_NOT_FOUND)
+                {
+                    Status = AE_OK;
+                }
+                else
+                {
+                    ACPI_ERROR_NAMESPACE (BufferPtr, Status);
+                }
+#else
+                ACPI_ERROR_NAMESPACE (BufferPtr, Status);
+#endif
+                return_ACPI_STATUS (Status);
+            }
+        }
+
+        /*
+         * We must check to make sure that the target is
+         * one of the opcodes that actually opens a scope
+         */
+        switch (Node->Type)
+        {
+        case ACPI_TYPE_ANY:
+        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_WARNING ((AE_INFO,
+                "Type override - [%4.4s] had invalid type (%s) "
+                "for Scope operator, changed to type ANY\n",
+                AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
+
+            Node->Type = ACPI_TYPE_ANY;
+            WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
+            break;
+
+        default:
+
+            /* All other types are an error */
+
+            ACPI_ERROR ((AE_INFO,
+                "Invalid type (%s) for target of "
+                "Scope operator [%4.4s] (Cannot override)",
+                AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
+
+            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.
+         *
+         * Note: Name may already exist if we are executing a deferred opcode.
+         */
+        if (WalkState->DeferredNode)
+        {
+            /* This name is already in the namespace, get the node */
+
+            Node = WalkState->DeferredNode;
+            Status = AE_OK;
+            break;
+        }
+
+        Flags = ACPI_NS_NO_UPSEARCH;
+        if (WalkState->PassNumber == ACPI_IMODE_EXECUTE)
+        {
+            /* Execution mode, node cannot already exist, node is temporary */
+
+            Flags |= ACPI_NS_ERROR_IF_FOUND;
+
+            if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
+            {
+                Flags |= ACPI_NS_TEMPORARY;
+            }
+        }
+
+        /* Add new entry or lookup existing entry */
+
+        Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType,
+                    ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node);
+
+        if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY))
+        {
+            ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+                "***New Node [%4.4s] %p is temporary\n",
+                AcpiUtGetNodeName (Node), Node));
+        }
+        break;
+    }
+
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_ERROR_NAMESPACE (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;
+        }
+        *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
+ *
+ * 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;
+    UINT8                   RegionSpace;
+#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));
+
+    /* Check if opcode had an associated namespace object */
+
+    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:
+        /*
+         * If we are executing a method, initialize the field
+         */
+        if (WalkState->MethodNode)
+        {
+            Status = AcpiDsInitFieldObjects (Op, WalkState);
+        }
+
+        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_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:
+        case AML_DATA_REGION_OP:
+
+            if (Op->Common.AmlOpcode == AML_REGION_OP)
+            {
+                RegionSpace = (ACPI_ADR_SPACE_TYPE)
+                      ((Op->Common.Value.Arg)->Common.Value.Integer);
+            }
+            else
+            {
+                RegionSpace = ACPI_ADR_SPACE_DATA_TABLE;
+            }
+
+            /*
+             * The OpRegion is not fully parsed at this time. The 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. The namespace is
+             * unlocked at this point.
+             *
+             * Need to unlock interpreter if it is locked (if we are running
+             * a control method), in order to allow _REG methods to be run
+             * during AcpiEvInitializeRegion.
+             */
+            if (WalkState->MethodNode)
+            {
+                /*
+                 * Executing a method: initialize the region and unlock
+                 * the interpreter
+                 */
+                Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
+                            RegionSpace, WalkState);
+                if (ACPI_FAILURE (Status))
+                {
+                    return (Status);
+                }
+
+                AcpiExExitInterpreter ();
+            }
+
+            Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node),
+                        FALSE);
+            if (WalkState->MethodNode)
+            {
+                AcpiExEnterInterpreter ();
+            }
+
+            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;
+
+
+        case 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] = ACPI_CAST_PTR (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_ACPI_STATUS (Status);
+                }
+            }
+            break;
+
+#endif /* ACPI_NO_METHOD_EXECUTION */
+
+        default:
+            /* All NAMED_COMPLEX opcodes must be handled above */
+            break;
+        }
+        break;
+
+
+    case AML_CLASS_INTERNAL:
+
+        /* case AML_INT_NAMEPATH_OP: */
+        break;
+
+
+    case AML_CLASS_METHOD_CALL:
+
+        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
+            "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
+            WalkState, Op, Node));
+
+        /*
+         * Lookup the method name and save the Node
+         */
+        Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
+                        ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
+                        ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
+                        WalkState, &(NewNode));
+        if (ACPI_SUCCESS (Status))
+        {
+            /*
+             * Make sure that what we found is indeed a method
+             * We didn't search for a method on purpose, to see if the name
+             * would resolve
+             */
+            if (NewNode->Type != ACPI_TYPE_METHOD)
+            {
+                Status = AE_AML_OPERAND_TYPE;
+            }
+
+            /* We could put the returned object (Node) on the object stack for
+             * later, but for now, we will put it in the "op" object that the
+             * parser uses, so we can get it again at the end of this scope
+             */
+            Op->Common.Node = NewNode;
+        }
+        else
+        {
+            ACPI_ERROR_NAMESPACE (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 -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dswscope.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dswscope.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,239 @@
+/******************************************************************************
+ *
+ * Module Name: dswscope - Scope stack manipulation
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __DSWSCOPE_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+
+
+#define _COMPONENT          ACPI_DISPATCHER
+        ACPI_MODULE_NAME    ("dswscope")
+
+
+/****************************************************************************
+ *
+ * FUNCTION:    AcpiDsScopeStackClear
+ *
+ * PARAMETERS:  WalkState       - Current state
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Pop (and free) everything on the scope stack except the
+ *              root scope object (which remains at the stack top.)
+ *
+ ***************************************************************************/
+
+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
+ *              WalkState       - Current state
+ *
+ * RETURN:      Status
+ *
+ * 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_ERROR ((AE_INFO, "Null scope parameter"));
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    /* Make sure object type is valid */
+
+    if (!AcpiUtValidObjectType (Type))
+    {
+        ACPI_WARNING ((AE_INFO,
+            "Invalid object type: 0x%X", Type));
+    }
+
+    /* Allocate a new scope object */
+
+    ScopeInfo = AcpiUtCreateGenericState ();
+    if (!ScopeInfo)
+    {
+        return_ACPI_STATUS (AE_NO_MEMORY);
+    }
+
+    /* Init new scope object */
+
+    ScopeInfo->Common.DescriptorType = 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] (%s)",
+            AcpiUtGetNodeName (OldScopeInfo->Scope.Node),
+            AcpiUtGetTypeName (OldScopeInfo->Common.Value)));
+    }
+    else
+    {
+        ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
+            "[\\___] (%s)", "ROOT"));
+    }
+
+    ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
+        ", New scope -> [%4.4s] (%s)\n",
+        AcpiUtGetNodeName (ScopeInfo->Scope.Node),
+        AcpiUtGetTypeName (ScopeInfo->Common.Value)));
+
+    /* Push new scope object onto stack */
+
+    AcpiUtPushGenericState (&WalkState->ScopeInfo, ScopeInfo);
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/****************************************************************************
+ *
+ * FUNCTION:    AcpiDsScopeStackPop
+ *
+ * PARAMETERS:  WalkState       - Current state
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Pop the scope stack once.
+ *
+ ***************************************************************************/
+
+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] (%s), New scope -> ",
+        (UINT32) WalkState->ScopeDepth,
+        AcpiUtGetNodeName (ScopeInfo->Scope.Node),
+        AcpiUtGetTypeName (ScopeInfo->Common.Value)));
+
+    NewScopeInfo = WalkState->ScopeInfo;
+    if (NewScopeInfo)
+    {
+        ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
+            "[%4.4s] (%s)\n",
+            AcpiUtGetNodeName (NewScopeInfo->Scope.Node),
+            AcpiUtGetTypeName (NewScopeInfo->Common.Value)));
+    }
+    else
+    {
+        ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC,
+            "[\\___] (ROOT)\n"));
+    }
+
+    AcpiUtDeleteGenericState (ScopeInfo);
+    return_ACPI_STATUS (AE_OK);
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/dispatcher/dswstate.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/dispatcher/dswstate.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,846 @@
+/******************************************************************************
+ *
+ * Module Name: dswstate - Dispatcher parse tree walk management routines
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#define __DSWSTATE_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acparser.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#define _COMPONENT          ACPI_DISPATCHER
+        ACPI_MODULE_NAME    ("dswstate")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiDsResultStackPush (
+    ACPI_WALK_STATE         *WalkState);
+
+static ACPI_STATUS
+AcpiDsResultStackPop (
+    ACPI_WALK_STATE         *WalkState);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsResultPop
+ *
+ * PARAMETERS:  Object              - Where to return the popped object
+ *              WalkState           - Current Walk state
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Pop an object off the top of this walk's result stack
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDsResultPop (
+    ACPI_OPERAND_OBJECT     **Object,
+    ACPI_WALK_STATE         *WalkState)
+{
+    UINT32                  Index;
+    ACPI_GENERIC_STATE      *State;
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_NAME (DsResultPop);
+
+
+    State = WalkState->Results;
+
+    /* Incorrect state of result stack */
+
+    if (State && !WalkState->ResultCount)
+    {
+        ACPI_ERROR ((AE_INFO, "No results on result stack"));
+        return (AE_AML_INTERNAL);
+    }
+
+    if (!State && WalkState->ResultCount)
+    {
+        ACPI_ERROR ((AE_INFO, "No result state for result stack"));
+        return (AE_AML_INTERNAL);
+    }
+
+    /* Empty result stack */
+
+    if (!State)
+    {
+        ACPI_ERROR ((AE_INFO, "Result stack is empty! State=%p", WalkState));
+        return (AE_AML_NO_RETURN_VALUE);
+    }
+
+    /* Return object of the top element and clean that top element result stack */
+
+    WalkState->ResultCount--;
+    Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM;
+
+    *Object = State->Results.ObjDesc [Index];
+    if (!*Object)
+    {
+        ACPI_ERROR ((AE_INFO, "No result objects on result stack, State=%p",
+            WalkState));
+        return (AE_AML_NO_RETURN_VALUE);
+    }
+
+    State->Results.ObjDesc [Index] = NULL;
+    if (Index == 0)
+    {
+        Status = AcpiDsResultStackPop (WalkState);
+        if (ACPI_FAILURE (Status))
+        {
+            return (Status);
+        }
+    }
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+        "Obj=%p [%s] Index=%X State=%p Num=%X\n", *Object,
+        AcpiUtGetObjectTypeName (*Object),
+        Index, WalkState, WalkState->ResultCount));
+
+    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_STATUS             Status;
+    UINT32                  Index;
+
+
+    ACPI_FUNCTION_NAME (DsResultPush);
+
+
+    if (WalkState->ResultCount > WalkState->ResultSize)
+    {
+        ACPI_ERROR ((AE_INFO, "Result stack is full"));
+        return (AE_AML_INTERNAL);
+    }
+    else if (WalkState->ResultCount == WalkState->ResultSize)
+    {
+        /* Extend the result stack */
+
+        Status = AcpiDsResultStackPush (WalkState);
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_ERROR ((AE_INFO, "Failed to extend the result stack"));
+            return (Status);
+        }
+    }
+
+    if (!(WalkState->ResultCount < WalkState->ResultSize))
+    {
+        ACPI_ERROR ((AE_INFO, "No free elements in result stack"));
+        return (AE_AML_INTERNAL);
+    }
+
+    State = WalkState->Results;
+    if (!State)
+    {
+        ACPI_ERROR ((AE_INFO, "No result stack frame during push"));
+        return (AE_AML_INTERNAL);
+    }
+
+    if (!Object)
+    {
+        ACPI_ERROR ((AE_INFO,
+            "Null Object! Obj=%p State=%p Num=%u",
+            Object, WalkState, WalkState->ResultCount));
+        return (AE_BAD_PARAMETER);
+    }
+
+    /* Assign the address of object to the top free element of result stack */
+
+    Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM;
+    State->Results.ObjDesc [Index] = Object;
+    WalkState->ResultCount++;
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n",
+        Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object),
+        WalkState, WalkState->ResultCount, WalkState->CurrentResult));
+
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsResultStackPush
+ *
+ * PARAMETERS:  WalkState           - Current Walk state
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Push an object onto the WalkState result stack
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDsResultStackPush (
+    ACPI_WALK_STATE         *WalkState)
+{
+    ACPI_GENERIC_STATE      *State;
+
+
+    ACPI_FUNCTION_NAME (DsResultStackPush);
+
+
+    /* Check for stack overflow */
+
+    if (((UINT32) WalkState->ResultSize + ACPI_RESULTS_FRAME_OBJ_NUM) >
+        ACPI_RESULTS_OBJ_NUM_MAX)
+    {
+        ACPI_ERROR ((AE_INFO, "Result stack overflow: State=%p Num=%u",
+            WalkState, WalkState->ResultSize));
+        return (AE_STACK_OVERFLOW);
+    }
+
+    State = AcpiUtCreateGenericState ();
+    if (!State)
+    {
+        return (AE_NO_MEMORY);
+    }
+
+    State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RESULT;
+    AcpiUtPushGenericState (&WalkState->Results, State);
+
+    /* Increase the length of the result stack by the length of frame */
+
+    WalkState->ResultSize += ACPI_RESULTS_FRAME_OBJ_NUM;
+
+    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
+ *
+ ******************************************************************************/
+
+static 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, "Result stack underflow - State=%p\n",
+            WalkState));
+        return (AE_AML_NO_OPERAND);
+    }
+
+    if (WalkState->ResultSize < ACPI_RESULTS_FRAME_OBJ_NUM)
+    {
+        ACPI_ERROR ((AE_INFO, "Insufficient result stack size"));
+        return (AE_AML_INTERNAL);
+    }
+
+    State = AcpiUtPopGenericState (&WalkState->Results);
+    AcpiUtDeleteGenericState (State);
+
+    /* Decrease the length of result stack by the length of frame */
+
+    WalkState->ResultSize -= ACPI_RESULTS_FRAME_OBJ_NUM;
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+        "Result=%p RemainingResults=%X State=%p\n",
+        State, WalkState->ResultCount, WalkState));
+
+    return (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_ERROR ((AE_INFO,
+            "Object stack overflow! Obj=%p State=%p #Ops=%u",
+            Object, WalkState, WalkState->NumOperands));
+        return (AE_STACK_OVERFLOW);
+    }
+
+    /* Put the object onto the stack */
+
+    WalkState->Operands [WalkState->OperandIndex] = Object;
+    WalkState->NumOperands++;
+
+    /* For the usual order of filling the operand stack */
+
+    WalkState->OperandIndex++;
+
+    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);
+}
+
+
+/*******************************************************************************
+ *
+ * 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_ERROR ((AE_INFO,
+                "Object stack underflow! Count=%X State=%p #Ops=%u",
+                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=%u\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.
+ *
+ ******************************************************************************/
+
+void
+AcpiDsObjStackPopAndDelete (
+    UINT32                  PopCount,
+    ACPI_WALK_STATE         *WalkState)
+{
+    INT32                   i;
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+
+
+    ACPI_FUNCTION_NAME (DsObjStackPopAndDelete);
+
+
+    if (PopCount == 0)
+    {
+        return;
+    }
+
+    for (i = (INT32) PopCount - 1; i >= 0; i--)
+    {
+        if (WalkState->NumOperands == 0)
+        {
+            return;
+        }
+
+        /* Pop the stack and delete an object if present in this stack entry */
+
+        WalkState->NumOperands--;
+        ObjDesc = WalkState->Operands [i];
+        if (ObjDesc)
+        {
+            AcpiUtRemoveReference (WalkState->Operands [i]);
+            WalkState->Operands [i] = NULL;
+        }
+    }
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n",
+        PopCount, WalkState, WalkState->NumOperands));
+}
+
+
+/*******************************************************************************
+ *
+ * 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
+ *              Thread          - Thread state object
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Place the Thread state 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:  Thread      - Current thread state
+ *
+ * RETURN:      A WalkState object popped from the thread's stack
+ *
+ * DESCRIPTION: Remove and return the walkstate object that is at the head of
+ *              the walk stack for the given walk list.  NULL indicates that
+ *              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
+         * Do Not: WalkState->Next = NULL;
+         */
+    }
+
+    return_PTR (WalkState);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDsCreateWalkState
+ *
+ * PARAMETERS:  OwnerId         - ID for object creation
+ *              Origin          - Starting point for this walk
+ *              MethodDesc      - Method object
+ *              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     *MethodDesc,
+    ACPI_THREAD_STATE       *Thread)
+{
+    ACPI_WALK_STATE         *WalkState;
+
+
+    ACPI_FUNCTION_TRACE (DsCreateWalkState);
+
+
+    WalkState = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_WALK_STATE));
+    if (!WalkState)
+    {
+        return_PTR (NULL);
+    }
+
+    WalkState->DescriptorType = ACPI_DESC_TYPE_WALK;
+    WalkState->MethodDesc = MethodDesc;
+    WalkState->OwnerId = OwnerId;
+    WalkState->Origin = Origin;
+    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
+
+    /* 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
+ *              Op              - Current parse op
+ *              MethodNode      - Control method NS node, if any
+ *              AmlStart        - Start of AML
+ *              AmlLength       - Length of AML
+ *              Info            - Method info block (params, etc.)
+ *              PassNumber      - 1, 2, or 3
+ *
+ * RETURN:      Status
+ *
+ * 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_EVALUATE_INFO      *Info,
+    UINT8                   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->PassNumber = PassNumber;
+
+    if (Info)
+    {
+        WalkState->Params = Info->Parameters;
+        WalkState->CallerReturnDesc = &Info->ReturnObject;
+    }
+
+    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 (WalkState->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->DescriptorType != ACPI_DESC_TYPE_WALK)
+    {
+        ACPI_ERROR ((AE_INFO, "%p is not a valid walk state",
+            WalkState));
+        return;
+    }
+
+    /* There should not be any open scopes */
+
+    if (WalkState->ParserState.Scope)
+    {
+        ACPI_ERROR ((AE_INFO, "%p walk still has a scope list",
+            WalkState));
+        AcpiPsCleanupScope (&WalkState->ParserState);
+    }
+
+    /* 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);
+    }
+
+    ACPI_FREE (WalkState);
+    return_VOID;
+}
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evevent.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evevent.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,336 @@
+/******************************************************************************
+ *
+ * Module Name: evevent - Fixed Event handling and dispatch
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acevents.h>
+
+#define _COMPONENT          ACPI_EVENTS
+        ACPI_MODULE_NAME    ("evevent")
+
+#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiEvFixedEventInitialize (
+    void);
+
+static UINT32
+AcpiEvFixedEventDispatch (
+    UINT32                  Event);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvInitializeEvents
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Initialize global data structures for ACPI events (Fixed, GPE)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvInitializeEvents (
+    void)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (EvInitializeEvents);
+
+
+    /* If Hardware Reduced flag is set, there are no fixed events */
+
+    if (AcpiGbl_ReducedHardware)
+    {
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /*
+     * Initialize the Fixed and General Purpose Events. This is done prior to
+     * enabling SCIs to prevent interrupts from occurring before the handlers
+     * are installed.
+     */
+    Status = AcpiEvFixedEventInitialize ();
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_EXCEPTION ((AE_INFO, Status,
+            "Unable to initialize fixed events"));
+        return_ACPI_STATUS (Status);
+    }
+
+    Status = AcpiEvGpeInitialize ();
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_EXCEPTION ((AE_INFO, Status,
+            "Unable to initialize general purpose events"));
+        return_ACPI_STATUS (Status);
+    }
+
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvInstallXruptHandlers
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Install interrupt handlers for the SCI and Global Lock
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvInstallXruptHandlers (
+    void)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (EvInstallXruptHandlers);
+
+
+    /* If Hardware Reduced flag is set, there is no ACPI h/w */
+
+    if (AcpiGbl_ReducedHardware)
+    {
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /* Install the SCI handler */
+
+    Status = AcpiEvInstallSciHandler ();
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_EXCEPTION ((AE_INFO, Status,
+            "Unable to install System Control Interrupt handler"));
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Install the handler for the Global Lock */
+
+    Status = AcpiEvInitGlobalLockHandler ();
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_EXCEPTION ((AE_INFO, Status,
+            "Unable to initialize Global Lock handler"));
+        return_ACPI_STATUS (Status);
+    }
+
+    AcpiGbl_EventsInitialized = TRUE;
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvFixedEventInitialize
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Install the fixed event handlers and disable all fixed events.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiEvFixedEventInitialize (
+    void)
+{
+    UINT32                  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;
+
+        /* Disable the fixed event */
+
+        if (AcpiGbl_FixedEventInfo[i].EnableRegisterId != 0xFF)
+        {
+            Status = AcpiWriteBitRegister (
+                        AcpiGbl_FixedEventInfo[i].EnableRegisterId,
+                        ACPI_DISABLE_EVENT);
+            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 active fixed events
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiEvFixedEventDetect (
+    void)
+{
+    UINT32                  IntStatus = ACPI_INTERRUPT_NOT_HANDLED;
+    UINT32                  FixedStatus;
+    UINT32                  FixedEnable;
+    UINT32                  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_REGISTER_PM1_STATUS, &FixedStatus);
+    (void) AcpiHwRegisterRead (ACPI_REGISTER_PM1_ENABLE, &FixedEnable);
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
+        "Fixed Event 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. Invoke global event
+             * handler if present.
+             */
+            AcpiFixedEventCount[i]++;
+            if (AcpiGbl_GlobalEventHandler)
+            {
+                AcpiGbl_GlobalEventHandler (ACPI_EVENT_TYPE_FIXED, NULL,
+                     i, AcpiGbl_GlobalEventHandlerContext);
+            }
+
+            IntStatus |= AcpiEvFixedEventDispatch (i);
+        }
+    }
+
+    return (IntStatus);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvFixedEventDispatch
+ *
+ * PARAMETERS:  Event               - Event type
+ *
+ * RETURN:      INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
+ *
+ * DESCRIPTION: Clears the status bit for the requested event, calls the
+ *              handler that previously registered for the event.
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiEvFixedEventDispatch (
+    UINT32                  Event)
+{
+
+    ACPI_FUNCTION_ENTRY ();
+
+
+    /* Clear the status bit */
+
+    (void) AcpiWriteBitRegister (
+            AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
+            ACPI_CLEAR_STATUS);
+
+    /*
+     * 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) AcpiWriteBitRegister (
+                AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
+                ACPI_DISABLE_EVENT);
+
+        ACPI_ERROR ((AE_INFO,
+            "No installed handler for fixed event [0x%08X]",
+            Event));
+
+        return (ACPI_INTERRUPT_NOT_HANDLED);
+    }
+
+    /* Invoke the Fixed Event handler */
+
+    return ((AcpiGbl_FixedEventHandlers[Event].Handler)(
+                AcpiGbl_FixedEventHandlers[Event].Context));
+}
+
+#endif /* !ACPI_REDUCED_HARDWARE */
+
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evglock.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evglock.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,377 @@
+/******************************************************************************
+ *
+ * Module Name: evglock - Global Lock support
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acevents.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+
+#define _COMPONENT          ACPI_EVENTS
+        ACPI_MODULE_NAME    ("evglock")
+
+#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
+
+/* Local prototypes */
+
+static UINT32
+AcpiEvGlobalLockHandler (
+    void                    *Context);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvInitGlobalLockHandler
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Install a handler for the global lock release event
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvInitGlobalLockHandler (
+    void)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (EvInitGlobalLockHandler);
+
+
+    /* If Hardware Reduced flag is set, there is no global lock */
+
+    if (AcpiGbl_ReducedHardware)
+    {
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /* Attempt installation of the global lock handler */
+
+    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.
+     */
+    AcpiGbl_GlobalLockPresent = FALSE;
+    if (Status == AE_NO_HARDWARE_RESPONSE)
+    {
+        ACPI_ERROR ((AE_INFO,
+            "No response from Global Lock hardware, disabling lock"));
+
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    Status = AcpiOsCreateLock (&AcpiGbl_GlobalLockPendingLock);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    AcpiGbl_GlobalLockPending = FALSE;
+    AcpiGbl_GlobalLockPresent = TRUE;
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvRemoveGlobalLockHandler
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Remove the handler for the Global Lock
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvRemoveGlobalLockHandler (
+    void)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (EvRemoveGlobalLockHandler);
+
+    AcpiGbl_GlobalLockPresent = FALSE;
+    Status = AcpiRemoveFixedEventHandler (ACPI_EVENT_GLOBAL,
+                AcpiEvGlobalLockHandler);
+
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvGlobalLockHandler
+ *
+ * PARAMETERS:  Context         - From thread interface, not used
+ *
+ * RETURN:      ACPI_INTERRUPT_HANDLED
+ *
+ * DESCRIPTION: Invoked directly from the SCI handler when a global lock
+ *              release interrupt occurs. If there is actually a pending
+ *              request for the lock, signal the waiting thread.
+ *
+ ******************************************************************************/
+
+static UINT32
+AcpiEvGlobalLockHandler (
+    void                    *Context)
+{
+    ACPI_STATUS             Status;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GlobalLockPendingLock);
+
+    /*
+     * If a request for the global lock is not actually pending,
+     * we are done. This handles "spurious" global lock interrupts
+     * which are possible (and have been seen) with bad BIOSs.
+     */
+    if (!AcpiGbl_GlobalLockPending)
+    {
+        goto CleanupAndExit;
+    }
+
+    /*
+     * Send a unit to the global lock semaphore. The actual acquisition
+     * of the global lock will be performed by the waiting thread.
+     */
+    Status = AcpiOsSignalSemaphore (AcpiGbl_GlobalLockSemaphore, 1);
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_ERROR ((AE_INFO, "Could not signal Global Lock semaphore"));
+    }
+
+    AcpiGbl_GlobalLockPending = FALSE;
+
+
+CleanupAndExit:
+
+    AcpiOsReleaseLock (AcpiGbl_GlobalLockPendingLock, Flags);
+    return (ACPI_INTERRUPT_HANDLED);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiEvAcquireGlobalLock
+ *
+ * PARAMETERS:  Timeout         - Max time to wait for the lock, in millisec.
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Attempt to gain ownership of the Global Lock.
+ *
+ * MUTEX:       Interpreter must be locked
+ *
+ * Note: The original implementation allowed multiple threads to "acquire" the
+ * Global Lock, and the OS would hold the lock until the last thread had
+ * released it. However, this could potentially starve the BIOS out of the
+ * lock, especially in the case where there is a tight handshake between the
+ * Embedded Controller driver and the BIOS. Therefore, this implementation
+ * allows only one thread to acquire the HW Global Lock at a time, and makes
+ * the global lock appear as a standard mutex on the OS side.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiEvAcquireGlobalLock (
+    UINT16                  Timeout)
+{
+    ACPI_CPU_FLAGS          Flags;
+    ACPI_STATUS             Status;
+    BOOLEAN                 Acquired = FALSE;
+
+
+    ACPI_FUNCTION_TRACE (EvAcquireGlobalLock);
+
+
+    /*
+     * Only one thread can acquire the GL at a time, the GlobalLockMutex
+     * enforces this. This interface releases the interpreter if we must wait.
+     */
+    Status = AcpiExSystemWaitMutex (AcpiGbl_GlobalLockMutex->Mutex.OsMutex,
+                Timeout);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /*
+     * Update the global lock handle and check for wraparound. The handle is
+     * only used for the external global lock interfaces, but it is updated
+     * here to properly handle the case where a single thread may acquire the
+     * lock via both the AML and the AcpiAcquireGlobalLock interfaces. The
+     * handle is therefore updated on the first acquire from a given thread
+     * regardless of where the acquisition request originated.
+     */
+    AcpiGbl_GlobalLockHandle++;
+    if (AcpiGbl_GlobalLockHandle == 0)
+    {
+        AcpiGbl_GlobalLockHandle = 1;
+    }
+
+    /*
+     * Make sure that a global lock actually exists. If not, just
+     * treat the lock as a standard mutex.
+     */
+    if (!AcpiGbl_GlobalLockPresent)
+    {
+        AcpiGbl_GlobalLockAcquired = TRUE;
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GlobalLockPendingLock);
+
+    do
+    {
+        /* Attempt to acquire the actual hardware lock */
+
+        ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_FACS, Acquired);
+        if (Acquired)
+        {
+            AcpiGbl_GlobalLockAcquired = TRUE;
+            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+                "Acquired hardware Global Lock\n"));
+            break;
+        }
+
+        /*
+         * Did not get the lock. The pending bit was set above, and
+         * we must now wait until we receive the global lock
+         * released interrupt.
+         */
+        AcpiGbl_GlobalLockPending = TRUE;
+        AcpiOsReleaseLock (AcpiGbl_GlobalLockPendingLock, Flags);
+
+        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+            "Waiting for hardware Global Lock\n"));
+
+        /*
+         * Wait for handshake with the global lock interrupt handler.
+         * This interface releases the interpreter if we must wait.
+         */
+        Status = AcpiExSystemWaitSemaphore (AcpiGbl_GlobalLockSemaphore,
+                    ACPI_WAIT_FOREVER);
+
+        Flags = AcpiOsAcquireLock (AcpiGbl_GlobalLockPendingLock);
+
+    } while (ACPI_SUCCESS (Status));
+
+    AcpiGbl_GlobalLockPending = FALSE;
+    AcpiOsReleaseLock (AcpiGbl_GlobalLockPendingLock, Flags);
+
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvReleaseGlobalLock
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Releases ownership of the Global Lock.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvReleaseGlobalLock (
+    void)
+{
+    BOOLEAN                 Pending = FALSE;
+    ACPI_STATUS             Status = AE_OK;
+
+
+    ACPI_FUNCTION_TRACE (EvReleaseGlobalLock);
+
+
+    /* Lock must be already acquired */
+
+    if (!AcpiGbl_GlobalLockAcquired)
+    {
+        ACPI_WARNING ((AE_INFO,
+            "Cannot release the ACPI Global Lock, it has not been acquired"));
+        return_ACPI_STATUS (AE_NOT_ACQUIRED);
+    }
+
+    if (AcpiGbl_GlobalLockPresent)
+    {
+        /* Allow any thread to release the lock */
+
+        ACPI_RELEASE_GLOBAL_LOCK (AcpiGbl_FACS, Pending);
+
+        /*
+         * If the pending bit was set, we must write GBL_RLS to the control
+         * register
+         */
+        if (Pending)
+        {
+            Status = AcpiWriteBitRegister (
+                        ACPI_BITREG_GLOBAL_LOCK_RELEASE, ACPI_ENABLE_EVENT);
+        }
+
+        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Released hardware Global Lock\n"));
+    }
+
+    AcpiGbl_GlobalLockAcquired = FALSE;
+
+    /* Release the local GL mutex */
+
+    AcpiOsReleaseMutex (AcpiGbl_GlobalLockMutex->Mutex.OsMutex);
+    return_ACPI_STATUS (Status);
+}
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evgpe.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evgpe.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,831 @@
+/******************************************************************************
+ *
+ * Module Name: evgpe - General Purpose Event handling and dispatch
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acevents.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#define _COMPONENT          ACPI_EVENTS
+        ACPI_MODULE_NAME    ("evgpe")
+
+#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
+
+/* Local prototypes */
+
+static void ACPI_SYSTEM_XFACE
+AcpiEvAsynchExecuteGpeMethod (
+    void                    *Context);
+
+static void ACPI_SYSTEM_XFACE
+AcpiEvAsynchEnableGpe (
+    void                    *Context);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvUpdateGpeEnableMask
+ *
+ * PARAMETERS:  GpeEventInfo            - GPE to update
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Updates GPE register enable mask based upon whether there are
+ *              runtime references to this GPE
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvUpdateGpeEnableMask (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
+{
+    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
+    UINT32                  RegisterBit;
+
+
+    ACPI_FUNCTION_TRACE (EvUpdateGpeEnableMask);
+
+
+    GpeRegisterInfo = GpeEventInfo->RegisterInfo;
+    if (!GpeRegisterInfo)
+    {
+        return_ACPI_STATUS (AE_NOT_EXIST);
+    }
+
+    RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
+
+    /* Clear the run bit up front */
+
+    ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit);
+
+    /* Set the mask bit only if there are references to this GPE */
+
+    if (GpeEventInfo->RuntimeCount)
+    {
+        ACPI_SET_BIT (GpeRegisterInfo->EnableForRun, (UINT8) RegisterBit);
+    }
+
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvEnableGpe
+ *
+ * PARAMETERS:  GpeEventInfo            - GPE to enable
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Clear a GPE of stale events and enable it.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvEnableGpe (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (EvEnableGpe);
+
+
+    /*
+     * We will only allow a GPE to be enabled if it has either an associated
+     * method (_Lxx/_Exx) or a handler, or is using the implicit notify
+     * feature. Otherwise, the GPE will be immediately disabled by
+     * AcpiEvGpeDispatch the first time it fires.
+     */
+    if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
+        ACPI_GPE_DISPATCH_NONE)
+    {
+        return_ACPI_STATUS (AE_NO_HANDLER);
+    }
+
+    /* Clear the GPE (of stale events) */
+
+    Status = AcpiHwClearGpe (GpeEventInfo);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Enable the requested GPE */
+
+    Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_ENABLE);
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvAddGpeReference
+ *
+ * PARAMETERS:  GpeEventInfo            - Add a reference to this GPE
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
+ *              hardware-enabled.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvAddGpeReference (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
+{
+    ACPI_STATUS             Status = AE_OK;
+
+
+    ACPI_FUNCTION_TRACE (EvAddGpeReference);
+
+
+    if (GpeEventInfo->RuntimeCount == ACPI_UINT8_MAX)
+    {
+        return_ACPI_STATUS (AE_LIMIT);
+    }
+
+    GpeEventInfo->RuntimeCount++;
+    if (GpeEventInfo->RuntimeCount == 1)
+    {
+        /* Enable on first reference */
+
+        Status = AcpiEvUpdateGpeEnableMask (GpeEventInfo);
+        if (ACPI_SUCCESS (Status))
+        {
+            Status = AcpiEvEnableGpe (GpeEventInfo);
+        }
+
+        if (ACPI_FAILURE (Status))
+        {
+            GpeEventInfo->RuntimeCount--;
+        }
+    }
+
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvRemoveGpeReference
+ *
+ * PARAMETERS:  GpeEventInfo            - Remove a reference to this GPE
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Remove a reference to a GPE. When the last reference is
+ *              removed, the GPE is hardware-disabled.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvRemoveGpeReference (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
+{
+    ACPI_STATUS             Status = AE_OK;
+
+
+    ACPI_FUNCTION_TRACE (EvRemoveGpeReference);
+
+
+    if (!GpeEventInfo->RuntimeCount)
+    {
+        return_ACPI_STATUS (AE_LIMIT);
+    }
+
+    GpeEventInfo->RuntimeCount--;
+    if (!GpeEventInfo->RuntimeCount)
+    {
+        /* Disable on last reference */
+
+        Status = AcpiEvUpdateGpeEnableMask (GpeEventInfo);
+        if (ACPI_SUCCESS (Status))
+        {
+            Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE);
+        }
+
+        if (ACPI_FAILURE (Status))
+        {
+            GpeEventInfo->RuntimeCount++;
+        }
+    }
+
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvLowGetGpeInfo
+ *
+ * PARAMETERS:  GpeNumber           - Raw GPE number
+ *              GpeBlock            - A GPE info block
+ *
+ * RETURN:      A GPE EventInfo struct. NULL if not a valid GPE (The GpeNumber
+ *              is not within the specified GPE block)
+ *
+ * DESCRIPTION: Returns the EventInfo struct associated with this GPE. This is
+ *              the low-level implementation of EvGetGpeEventInfo.
+ *
+ ******************************************************************************/
+
+ACPI_GPE_EVENT_INFO *
+AcpiEvLowGetGpeInfo (
+    UINT32                  GpeNumber,
+    ACPI_GPE_BLOCK_INFO     *GpeBlock)
+{
+    UINT32                  GpeIndex;
+
+
+    /*
+     * Validate that the GpeNumber is within the specified GpeBlock.
+     * (Two steps)
+     */
+    if (!GpeBlock ||
+        (GpeNumber < GpeBlock->BlockBaseNumber))
+    {
+        return (NULL);
+    }
+
+    GpeIndex = GpeNumber - GpeBlock->BlockBaseNumber;
+    if (GpeIndex >= GpeBlock->GpeCount)
+    {
+        return (NULL);
+    }
+
+    return (&GpeBlock->EventInfo[GpeIndex]);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvGetGpeEventInfo
+ *
+ * PARAMETERS:  GpeDevice           - Device node. NULL for GPE0/GPE1
+ *              GpeNumber           - Raw GPE number
+ *
+ * RETURN:      A GPE EventInfo struct. NULL if not a valid GPE
+ *
+ * DESCRIPTION: Returns the EventInfo struct associated with this GPE.
+ *              Validates the GpeBlock and the GpeNumber
+ *
+ *              Should be called only when the GPE lists are semaphore locked
+ *              and not subject to change.
+ *
+ ******************************************************************************/
+
+ACPI_GPE_EVENT_INFO *
+AcpiEvGetGpeEventInfo (
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber)
+{
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_GPE_EVENT_INFO     *GpeInfo;
+    UINT32                  i;
+
+
+    ACPI_FUNCTION_ENTRY ();
+
+
+    /* A NULL GpeDevice means use the FADT-defined GPE block(s) */
+
+    if (!GpeDevice)
+    {
+        /* Examine GPE Block 0 and 1 (These blocks are permanent) */
+
+        for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++)
+        {
+            GpeInfo = AcpiEvLowGetGpeInfo (GpeNumber,
+                        AcpiGbl_GpeFadtBlocks[i]);
+            if (GpeInfo)
+            {
+                return (GpeInfo);
+            }
+        }
+
+        /* The GpeNumber was not in the range of either FADT GPE block */
+
+        return (NULL);
+    }
+
+    /* A Non-NULL GpeDevice means this is a GPE Block Device */
+
+    ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) GpeDevice);
+    if (!ObjDesc ||
+        !ObjDesc->Device.GpeBlock)
+    {
+        return (NULL);
+    }
+
+    return (AcpiEvLowGetGpeInfo (GpeNumber, ObjDesc->Device.GpeBlock));
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvGpeDetect
+ *
+ * PARAMETERS:  GpeXruptList        - Interrupt block for this interrupt.
+ *                                    Can have multiple GPE blocks attached.
+ *
+ * RETURN:      INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
+ *
+ * DESCRIPTION: Detect if any GP events have occurred. This function is
+ *              executed at interrupt level.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiEvGpeDetect (
+    ACPI_GPE_XRUPT_INFO     *GpeXruptList)
+{
+    ACPI_STATUS             Status;
+    ACPI_GPE_BLOCK_INFO     *GpeBlock;
+    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
+    UINT32                  IntStatus = ACPI_INTERRUPT_NOT_HANDLED;
+    UINT8                   EnabledStatusByte;
+    UINT32                  StatusReg;
+    UINT32                  EnableReg;
+    ACPI_CPU_FLAGS          Flags;
+    UINT32                  i;
+    UINT32                  j;
+
+
+    ACPI_FUNCTION_NAME (EvGpeDetect);
+
+    /* Check for the case where there are no GPEs */
+
+    if (!GpeXruptList)
+    {
+        return (IntStatus);
+    }
+
+    /*
+     * We need to obtain the GPE lock for both the data structs and registers
+     * Note: Not necessary to obtain the hardware lock, since the GPE
+     * registers are owned by the GpeLock.
+     */
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+
+    /* Examine all GPE blocks attached to this interrupt level */
+
+    GpeBlock = GpeXruptList->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];
+
+            /*
+             * Optimization: If there are no GPEs enabled within this
+             * register, we can safely ignore the entire register.
+             */
+            if (!(GpeRegisterInfo->EnableForRun |
+                  GpeRegisterInfo->EnableForWake))
+            {
+                continue;
+            }
+
+            /* Read the Status Register */
+
+            Status = AcpiHwRead (&StatusReg, &GpeRegisterInfo->StatusAddress);
+            if (ACPI_FAILURE (Status))
+            {
+                goto UnlockAndExit;
+            }
+
+            /* Read the Enable Register */
+
+            Status = AcpiHwRead (&EnableReg, &GpeRegisterInfo->EnableAddress);
+            if (ACPI_FAILURE (Status))
+            {
+                goto UnlockAndExit;
+            }
+
+            ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
+                "Read GPE Register at GPE%02X: Status=%02X, Enable=%02X\n",
+                GpeRegisterInfo->BaseGpeNumber, StatusReg, EnableReg));
+
+            /* Check if there is anything active at all in this register */
+
+            EnabledStatusByte = (UINT8) (StatusReg & EnableReg);
+            if (!EnabledStatusByte)
+            {
+                /* No active GPEs in this register, move on */
+
+                continue;
+            }
+
+            /* Now look at the individual GPEs in this byte register */
+
+            for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
+            {
+                /* Examine one GPE bit */
+
+                if (EnabledStatusByte & (1 << j))
+                {
+                    /*
+                     * Found an active GPE. Dispatch the event to a handler
+                     * or method.
+                     */
+                    IntStatus |= AcpiEvGpeDispatch (GpeBlock->Node,
+                        &GpeBlock->EventInfo[((ACPI_SIZE) i *
+                            ACPI_GPE_REGISTER_WIDTH) + j],
+                        j + GpeRegisterInfo->BaseGpeNumber);
+                }
+            }
+        }
+
+        GpeBlock = GpeBlock->Next;
+    }
+
+UnlockAndExit:
+
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+    return (IntStatus);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvAsynchExecuteGpeMethod
+ *
+ * PARAMETERS:  Context (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 AcpiOsExecute and
+ *              therefore does NOT execute at interrupt level - so that
+ *              the control method itself is not executed in the context of
+ *              an interrupt handler.
+ *
+ ******************************************************************************/
+
+static void ACPI_SYSTEM_XFACE
+AcpiEvAsynchExecuteGpeMethod (
+    void                    *Context)
+{
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo = Context;
+    ACPI_STATUS             Status;
+    ACPI_GPE_EVENT_INFO     *LocalGpeEventInfo;
+    ACPI_EVALUATE_INFO      *Info;
+
+
+    ACPI_FUNCTION_TRACE (EvAsynchExecuteGpeMethod);
+
+
+    /* Allocate a local GPE block */
+
+    LocalGpeEventInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_EVENT_INFO));
+    if (!LocalGpeEventInfo)
+    {
+        ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY,
+            "while handling a GPE"));
+        return_VOID;
+    }
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+    if (ACPI_FAILURE (Status))
+    {
+        return_VOID;
+    }
+
+    /* Must revalidate the GpeNumber/GpeBlock */
+
+    if (!AcpiEvValidGpeEvent (GpeEventInfo))
+    {
+        Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+        return_VOID;
+    }
+
+    /*
+     * Take a snapshot of the GPE info for this level - we copy the info to
+     * prevent a race condition with RemoveHandler/RemoveBlock.
+     */
+    ACPI_MEMCPY (LocalGpeEventInfo, GpeEventInfo,
+        sizeof (ACPI_GPE_EVENT_INFO));
+
+    Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+    if (ACPI_FAILURE (Status))
+    {
+        return_VOID;
+    }
+
+    /* Do the correct dispatch - normal method or implicit notify */
+
+    switch (LocalGpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)
+    {
+    case ACPI_GPE_DISPATCH_NOTIFY:
+
+        /*
+         * Implicit notify.
+         * Dispatch a DEVICE_WAKE 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 (
+                    LocalGpeEventInfo->Dispatch.DeviceNode,
+                    ACPI_NOTIFY_DEVICE_WAKE);
+        break;
+
+    case ACPI_GPE_DISPATCH_METHOD:
+
+        /* Allocate the evaluation information block */
+
+        Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
+        if (!Info)
+        {
+            Status = AE_NO_MEMORY;
+        }
+        else
+        {
+            /*
+             * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the
+             * _Lxx/_Exx control method that corresponds to this GPE
+             */
+            Info->PrefixNode = LocalGpeEventInfo->Dispatch.MethodNode;
+            Info->Flags = ACPI_IGNORE_RETURN_VALUE;
+
+            Status = AcpiNsEvaluate (Info);
+            ACPI_FREE (Info);
+        }
+
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_EXCEPTION ((AE_INFO, Status,
+                "while evaluating GPE method [%4.4s]",
+                AcpiUtGetNodeName (LocalGpeEventInfo->Dispatch.MethodNode)));
+        }
+
+        break;
+
+    default:
+        return_VOID; /* Should never happen */
+    }
+
+    /* Defer enabling of GPE until all notify handlers are done */
+
+    Status = AcpiOsExecute (OSL_NOTIFY_HANDLER,
+                AcpiEvAsynchEnableGpe, LocalGpeEventInfo);
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_FREE (LocalGpeEventInfo);
+    }
+    return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvAsynchEnableGpe
+ *
+ * PARAMETERS:  Context (GpeEventInfo) - Info for this GPE
+ *              Callback from AcpiOsExecute
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Asynchronous clear/enable for GPE. This allows the GPE to
+ *              complete (i.e., finish execution of Notify)
+ *
+ ******************************************************************************/
+
+static void ACPI_SYSTEM_XFACE
+AcpiEvAsynchEnableGpe (
+    void                    *Context)
+{
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo = Context;
+
+
+    (void) AcpiEvFinishGpe (GpeEventInfo);
+
+    ACPI_FREE (GpeEventInfo);
+    return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvFinishGpe
+ *
+ * PARAMETERS:  GpeEventInfo        - Info for this GPE
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Clear/Enable a GPE. Common code that is used after execution
+ *              of a GPE method or a synchronous or asynchronous GPE handler.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvFinishGpe (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
+{
+    ACPI_STATUS             Status;
+
+
+    if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
+            ACPI_GPE_LEVEL_TRIGGERED)
+    {
+        /*
+         * GPE is level-triggered, we clear the GPE status bit after
+         * handling the event.
+         */
+        Status = AcpiHwClearGpe (GpeEventInfo);
+        if (ACPI_FAILURE (Status))
+        {
+            return (Status);
+        }
+    }
+
+    /*
+     * Enable this GPE, conditionally. This means that the GPE will
+     * only be physically enabled if the EnableForRun bit is set
+     * in the EventInfo.
+     */
+    (void) AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_CONDITIONAL_ENABLE);
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvGpeDispatch
+ *
+ * PARAMETERS:  GpeDevice           - Device node. NULL for GPE0/GPE1
+ *              GpeEventInfo        - Info for this GPE
+ *              GpeNumber           - Number relative to the parent GPE block
+ *
+ * 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_NAMESPACE_NODE     *GpeDevice,
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo,
+    UINT32                  GpeNumber)
+{
+    ACPI_STATUS             Status;
+    UINT32                  ReturnValue;
+
+
+    ACPI_FUNCTION_TRACE (EvGpeDispatch);
+
+
+    /* Invoke global event handler if present */
+
+    AcpiGpeCount++;
+    if (AcpiGbl_GlobalEventHandler)
+    {
+        AcpiGbl_GlobalEventHandler (ACPI_EVENT_TYPE_GPE, GpeDevice,
+             GpeNumber, AcpiGbl_GlobalEventHandlerContext);
+    }
+
+    /*
+     * If edge-triggered, clear the GPE status bit now. Note that
+     * level-triggered events are cleared after the GPE is serviced.
+     */
+    if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
+            ACPI_GPE_EDGE_TRIGGERED)
+    {
+        Status = AcpiHwClearGpe (GpeEventInfo);
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_EXCEPTION ((AE_INFO, Status,
+                "Unable to clear GPE%02X", GpeNumber));
+            return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED);
+        }
+    }
+
+    /*
+     * Always disable the GPE so that it does not keep firing before
+     * any asynchronous activity completes (either from the execution
+     * of a GPE method or an asynchronous GPE handler.)
+     *
+     * If there is no handler or method to run, just disable the
+     * GPE and leave it disabled permanently to prevent further such
+     * pointless events from firing.
+     */
+    Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE);
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_EXCEPTION ((AE_INFO, Status,
+            "Unable to disable GPE%02X", GpeNumber));
+        return_UINT32 (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, leave the GPE
+     * disabled.
+     */
+    switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)
+    {
+    case ACPI_GPE_DISPATCH_HANDLER:
+
+        /* Invoke the installed handler (at interrupt level) */
+
+        ReturnValue = GpeEventInfo->Dispatch.Handler->Address (
+            GpeDevice, GpeNumber,
+            GpeEventInfo->Dispatch.Handler->Context);
+
+        /* If requested, clear (if level-triggered) and reenable the GPE */
+
+        if (ReturnValue & ACPI_REENABLE_GPE)
+        {
+            (void) AcpiEvFinishGpe (GpeEventInfo);
+        }
+        break;
+
+    case ACPI_GPE_DISPATCH_METHOD:
+    case ACPI_GPE_DISPATCH_NOTIFY:
+
+        /*
+         * Execute the method associated with the GPE
+         * NOTE: Level-triggered GPEs are cleared after the method completes.
+         */
+        Status = AcpiOsExecute (OSL_GPE_HANDLER,
+                    AcpiEvAsynchExecuteGpeMethod, GpeEventInfo);
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_EXCEPTION ((AE_INFO, Status,
+                "Unable to queue handler for GPE%02X - event disabled",
+                GpeNumber));
+        }
+        break;
+
+    default:
+
+        /*
+         * No handler or method to run!
+         * 03/2010: This case should no longer be possible. We will not allow
+         * a GPE to be enabled if it has no handler or method.
+         */
+        ACPI_ERROR ((AE_INFO,
+            "No handler or method for GPE%02X, disabling event",
+            GpeNumber));
+        break;
+    }
+
+    return_UINT32 (ACPI_INTERRUPT_HANDLED);
+}
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evgpeblk.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evgpeblk.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,550 @@
+/******************************************************************************
+ *
+ * Module Name: evgpeblk - GPE block creation and initialization.
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acevents.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#define _COMPONENT          ACPI_EVENTS
+        ACPI_MODULE_NAME    ("evgpeblk")
+
+#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiEvInstallGpeBlock (
+    ACPI_GPE_BLOCK_INFO     *GpeBlock,
+    UINT32                  InterruptNumber);
+
+static ACPI_STATUS
+AcpiEvCreateGpeInfoBlocks (
+    ACPI_GPE_BLOCK_INFO     *GpeBlock);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvInstallGpeBlock
+ *
+ * PARAMETERS:  GpeBlock                - New GPE block
+ *              InterruptNumber         - Xrupt to be associated with this
+ *                                        GPE block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Install new GPE block with mutex support
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiEvInstallGpeBlock (
+    ACPI_GPE_BLOCK_INFO     *GpeBlock,
+    UINT32                  InterruptNumber)
+{
+    ACPI_GPE_BLOCK_INFO     *NextGpeBlock;
+    ACPI_GPE_XRUPT_INFO     *GpeXruptBlock;
+    ACPI_STATUS             Status;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (EvInstallGpeBlock);
+
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    GpeXruptBlock = AcpiEvGetGpeXruptBlock (InterruptNumber);
+    if (!GpeXruptBlock)
+    {
+        Status = AE_NO_MEMORY;
+        goto UnlockAndExit;
+    }
+
+    /* Install the new block at the end of the list with lock */
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+    if (GpeXruptBlock->GpeBlockListHead)
+    {
+        NextGpeBlock = GpeXruptBlock->GpeBlockListHead;
+        while (NextGpeBlock->Next)
+        {
+            NextGpeBlock = NextGpeBlock->Next;
+        }
+
+        NextGpeBlock->Next = GpeBlock;
+        GpeBlock->Previous = NextGpeBlock;
+    }
+    else
+    {
+        GpeXruptBlock->GpeBlockListHead = GpeBlock;
+    }
+
+    GpeBlock->XruptBlock = GpeXruptBlock;
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+
+
+UnlockAndExit:
+    Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvDeleteGpeBlock
+ *
+ * PARAMETERS:  GpeBlock            - Existing GPE block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Remove a GPE block
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvDeleteGpeBlock (
+    ACPI_GPE_BLOCK_INFO     *GpeBlock)
+{
+    ACPI_STATUS             Status;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (EvInstallGpeBlock);
+
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Disable all GPEs in this block */
+
+    Status = AcpiHwDisableGpeBlock (GpeBlock->XruptBlock, GpeBlock, NULL);
+
+    if (!GpeBlock->Previous && !GpeBlock->Next)
+    {
+        /* This is the last GpeBlock on this interrupt */
+
+        Status = AcpiEvDeleteGpeXrupt (GpeBlock->XruptBlock);
+        if (ACPI_FAILURE (Status))
+        {
+            goto UnlockAndExit;
+        }
+    }
+    else
+    {
+        /* Remove the block on this interrupt with lock */
+
+        Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+        if (GpeBlock->Previous)
+        {
+            GpeBlock->Previous->Next = GpeBlock->Next;
+        }
+        else
+        {
+            GpeBlock->XruptBlock->GpeBlockListHead = GpeBlock->Next;
+        }
+
+        if (GpeBlock->Next)
+        {
+            GpeBlock->Next->Previous = GpeBlock->Previous;
+        }
+        AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+    }
+
+    AcpiCurrentGpeCount -= GpeBlock->GpeCount;
+
+    /* Free the GpeBlock */
+
+    ACPI_FREE (GpeBlock->RegisterInfo);
+    ACPI_FREE (GpeBlock->EventInfo);
+    ACPI_FREE (GpeBlock);
+
+UnlockAndExit:
+    Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvCreateGpeInfoBlocks
+ *
+ * PARAMETERS:  GpeBlock    - New GPE block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Create the RegisterInfo and EventInfo blocks for this GPE block
+ *
+ ******************************************************************************/
+
+static 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;
+    UINT32                  i;
+    UINT32                  j;
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (EvCreateGpeInfoBlocks);
+
+
+    /* Allocate the GPE register information block */
+
+    GpeRegisterInfo = ACPI_ALLOCATE_ZEROED (
+                        (ACPI_SIZE) GpeBlock->RegisterCount *
+                        sizeof (ACPI_GPE_REGISTER_INFO));
+    if (!GpeRegisterInfo)
+    {
+        ACPI_ERROR ((AE_INFO,
+            "Could not allocate the GpeRegisterInfo table"));
+        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_ALLOCATE_ZEROED ((ACPI_SIZE) GpeBlock->GpeCount *
+                    sizeof (ACPI_GPE_EVENT_INFO));
+    if (!GpeEventInfo)
+    {
+        ACPI_ERROR ((AE_INFO,
+            "Could not allocate the GpeEventInfo table"));
+        Status = AE_NO_MEMORY;
+        goto ErrorExit;
+    }
+
+    /* Save the new Info arrays in the GPE block */
+
+    GpeBlock->RegisterInfo = GpeRegisterInfo;
+    GpeBlock->EventInfo    = GpeEventInfo;
+
+    /*
+     * 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.
+     */
+    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));
+
+        ThisRegister->StatusAddress.Address =
+            GpeBlock->BlockAddress.Address + i;
+
+        ThisRegister->EnableAddress.Address =
+            GpeBlock->BlockAddress.Address + i + GpeBlock->RegisterCount;
+
+        ThisRegister->StatusAddress.SpaceId   = GpeBlock->BlockAddress.SpaceId;
+        ThisRegister->EnableAddress.SpaceId   = GpeBlock->BlockAddress.SpaceId;
+        ThisRegister->StatusAddress.BitWidth  = ACPI_GPE_REGISTER_WIDTH;
+        ThisRegister->EnableAddress.BitWidth  = ACPI_GPE_REGISTER_WIDTH;
+        ThisRegister->StatusAddress.BitOffset = 0;
+        ThisRegister->EnableAddress.BitOffset = 0;
+
+        /* Init the EventInfo for each GPE within this register */
+
+        for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
+        {
+            ThisEvent->GpeNumber = (UINT8) (ThisRegister->BaseGpeNumber + j);
+            ThisEvent->RegisterInfo = ThisRegister;
+            ThisEvent++;
+        }
+
+        /* Disable all GPEs within this register */
+
+        Status = AcpiHwWrite (0x00, &ThisRegister->EnableAddress);
+        if (ACPI_FAILURE (Status))
+        {
+            goto ErrorExit;
+        }
+
+        /* Clear any pending GPE events within this register */
+
+        Status = AcpiHwWrite (0xFF, &ThisRegister->StatusAddress);
+        if (ACPI_FAILURE (Status))
+        {
+            goto ErrorExit;
+        }
+
+        ThisRegister++;
+    }
+
+    return_ACPI_STATUS (AE_OK);
+
+
+ErrorExit:
+    if (GpeRegisterInfo)
+    {
+        ACPI_FREE (GpeRegisterInfo);
+    }
+    if (GpeEventInfo)
+    {
+        ACPI_FREE (GpeEventInfo);
+    }
+
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvCreateGpeBlock
+ *
+ * PARAMETERS:  GpeDevice           - Handle to the parent GPE block
+ *              GpeBlockAddress     - Address and SpaceID
+ *              RegisterCount       - Number of GPE register pairs in the block
+ *              GpeBlockBaseNumber  - Starting GPE number for the block
+ *              InterruptNumber     - H/W interrupt for the block
+ *              ReturnGpeBlock      - Where the new block descriptor is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within
+ *              the block are disabled at exit.
+ *              Note: Assumes namespace is locked.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvCreateGpeBlock (
+    ACPI_NAMESPACE_NODE     *GpeDevice,
+    ACPI_GENERIC_ADDRESS    *GpeBlockAddress,
+    UINT32                  RegisterCount,
+    UINT8                   GpeBlockBaseNumber,
+    UINT32                  InterruptNumber,
+    ACPI_GPE_BLOCK_INFO     **ReturnGpeBlock)
+{
+    ACPI_STATUS             Status;
+    ACPI_GPE_BLOCK_INFO     *GpeBlock;
+    ACPI_GPE_WALK_INFO      WalkInfo;
+
+
+    ACPI_FUNCTION_TRACE (EvCreateGpeBlock);
+
+
+    if (!RegisterCount)
+    {
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /* Allocate a new GPE block */
+
+    GpeBlock = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_BLOCK_INFO));
+    if (!GpeBlock)
+    {
+        return_ACPI_STATUS (AE_NO_MEMORY);
+    }
+
+    /* Initialize the new GPE block */
+
+    GpeBlock->Node = GpeDevice;
+    GpeBlock->GpeCount = (UINT16) (RegisterCount * ACPI_GPE_REGISTER_WIDTH);
+    GpeBlock->Initialized = FALSE;
+    GpeBlock->RegisterCount = RegisterCount;
+    GpeBlock->BlockBaseNumber = GpeBlockBaseNumber;
+
+    ACPI_MEMCPY (&GpeBlock->BlockAddress, GpeBlockAddress,
+        sizeof (ACPI_GENERIC_ADDRESS));
+
+    /*
+     * Create the RegisterInfo and EventInfo sub-structures
+     * Note: disables and clears all GPEs in the block
+     */
+    Status = AcpiEvCreateGpeInfoBlocks (GpeBlock);
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_FREE (GpeBlock);
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Install the new block in the global lists */
+
+    Status = AcpiEvInstallGpeBlock (GpeBlock, InterruptNumber);
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_FREE (GpeBlock);
+        return_ACPI_STATUS (Status);
+    }
+
+    AcpiGbl_AllGpesInitialized = FALSE;
+
+    /* Find all GPE methods (_Lxx or_Exx) for this block */
+
+    WalkInfo.GpeBlock = GpeBlock;
+    WalkInfo.GpeDevice = GpeDevice;
+    WalkInfo.ExecuteByOwnerId = FALSE;
+
+    Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice,
+                ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
+                AcpiEvMatchGpeMethod, NULL, &WalkInfo, NULL);
+
+    /* Return the new block */
+
+    if (ReturnGpeBlock)
+    {
+        (*ReturnGpeBlock) = GpeBlock;
+    }
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
+        "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n",
+        (UINT32) GpeBlock->BlockBaseNumber,
+        (UINT32) (GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1)),
+        GpeDevice->Name.Ascii, GpeBlock->RegisterCount,
+        InterruptNumber));
+
+    /* Update global count of currently available GPEs */
+
+    AcpiCurrentGpeCount += GpeBlock->GpeCount;
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvInitializeGpeBlock
+ *
+ * PARAMETERS:  ACPI_GPE_CALLBACK
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Initialize and enable a GPE block. Enable GPEs that have
+ *              associated methods.
+ *              Note: Assumes namespace is locked.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvInitializeGpeBlock (
+    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
+    ACPI_GPE_BLOCK_INFO     *GpeBlock,
+    void                    *Ignored)
+{
+    ACPI_STATUS             Status;
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    UINT32                  GpeEnabledCount;
+    UINT32                  GpeIndex;
+    UINT32                  i;
+    UINT32                  j;
+
+
+    ACPI_FUNCTION_TRACE (EvInitializeGpeBlock);
+
+
+    /*
+     * Ignore a null GPE block (e.g., if no GPE block 1 exists), and
+     * any GPE blocks that have been initialized already.
+     */
+    if (!GpeBlock || GpeBlock->Initialized)
+    {
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /*
+     * Enable all GPEs that have a corresponding method and have the
+     * ACPI_GPE_CAN_WAKE flag unset. Any other GPEs within this block
+     * must be enabled via the acpi_enable_gpe() interface.
+     */
+    GpeEnabledCount = 0;
+
+    for (i = 0; i < GpeBlock->RegisterCount; i++)
+    {
+        for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
+        {
+            /* Get the info block for this particular GPE */
+
+            GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j;
+            GpeEventInfo = &GpeBlock->EventInfo[GpeIndex];
+
+            /*
+             * Ignore GPEs that have no corresponding _Lxx/_Exx method
+             * and GPEs that are used to wake the system
+             */
+            if (((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_NONE) ||
+                ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) ||
+                (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE))
+            {
+                continue;
+            }
+
+            Status = AcpiEvAddGpeReference (GpeEventInfo);
+            if (ACPI_FAILURE (Status))
+            {
+                ACPI_EXCEPTION ((AE_INFO, Status,
+                    "Could not enable GPE 0x%02X",
+                    GpeIndex + GpeBlock->BlockBaseNumber));
+                continue;
+            }
+
+            GpeEnabledCount++;
+        }
+    }
+
+    if (GpeEnabledCount)
+    {
+        ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
+            "Enabled %u GPEs in this block\n", GpeEnabledCount));
+    }
+
+    GpeBlock->Initialized = TRUE;
+    return_ACPI_STATUS (AE_OK);
+}
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evgpeinit.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evgpeinit.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,462 @@
+/******************************************************************************
+ *
+ * Module Name: evgpeinit - System GPE initialization and update
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acevents.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#define _COMPONENT          ACPI_EVENTS
+        ACPI_MODULE_NAME    ("evgpeinit")
+
+#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
+
+/*
+ * Note: History of _PRW support in ACPICA
+ *
+ * Originally (2000 - 2010), the GPE initialization code performed a walk of
+ * the entire namespace to execute the _PRW methods and detect all GPEs
+ * capable of waking the system.
+ *
+ * As of 10/2010, the _PRW method execution has been removed since it is
+ * actually unnecessary. The host OS must in fact execute all _PRW methods
+ * in order to identify the device/power-resource dependencies. We now put
+ * the onus on the host OS to identify the wake GPEs as part of this process
+ * and to inform ACPICA of these GPEs via the AcpiSetupGpeForWake interface. This
+ * not only reduces the complexity of the ACPICA initialization code, but in
+ * some cases (on systems with very large namespaces) it should reduce the
+ * kernel boot time as well.
+ */
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvGpeInitialize
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Initialize the GPE data structures and the FADT GPE 0/1 blocks
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvGpeInitialize (
+    void)
+{
+    UINT32                  RegisterCount0 = 0;
+    UINT32                  RegisterCount1 = 0;
+    UINT32                  GpeNumberMax = 0;
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (EvGpeInitialize);
+
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /*
+     * Initialize the GPE Block(s) 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.Gpe0BlockLength &&
+        AcpiGbl_FADT.XGpe0Block.Address)
+    {
+        /* GPE block 0 exists (has both length and address > 0) */
+
+        RegisterCount0 = (UINT16) (AcpiGbl_FADT.Gpe0BlockLength / 2);
+
+        GpeNumberMax = (RegisterCount0 * ACPI_GPE_REGISTER_WIDTH) - 1;
+
+        /* Install GPE Block 0 */
+
+        Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice,
+                    &AcpiGbl_FADT.XGpe0Block, RegisterCount0, 0,
+                    AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[0]);
+
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_EXCEPTION ((AE_INFO, Status,
+                "Could not create GPE Block 0"));
+        }
+    }
+
+    if (AcpiGbl_FADT.Gpe1BlockLength &&
+        AcpiGbl_FADT.XGpe1Block.Address)
+    {
+        /* GPE block 1 exists (has both length and address > 0) */
+
+        RegisterCount1 = (UINT16) (AcpiGbl_FADT.Gpe1BlockLength / 2);
+
+        /* Check for GPE0/GPE1 overlap (if both banks exist) */
+
+        if ((RegisterCount0) &&
+            (GpeNumberMax >= AcpiGbl_FADT.Gpe1Base))
+        {
+            ACPI_ERROR ((AE_INFO,
+                "GPE0 block (GPE 0 to %u) overlaps the GPE1 block "
+                "(GPE %u to %u) - Ignoring GPE1",
+                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
+        {
+            /* Install GPE Block 1 */
+
+            Status = AcpiEvCreateGpeBlock (AcpiGbl_FadtGpeDevice,
+                        &AcpiGbl_FADT.XGpe1Block, RegisterCount1,
+                        AcpiGbl_FADT.Gpe1Base,
+                        AcpiGbl_FADT.SciInterrupt, &AcpiGbl_GpeFadtBlocks[1]);
+
+            if (ACPI_FAILURE (Status))
+            {
+                ACPI_EXCEPTION ((AE_INFO, Status,
+                    "Could not create GPE Block 1"));
+            }
+
+            /*
+             * GPE0 and GPE1 do not have to be contiguous in the GPE number
+             * space. However, GPE0 always starts at GPE number 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_DEBUG_PRINT ((ACPI_DB_INIT,
+            "There are no GPE blocks defined in the FADT\n"));
+        Status = AE_OK;
+        goto Cleanup;
+    }
+
+    /* Check for Max GPE number out-of-range */
+
+    if (GpeNumberMax > ACPI_GPE_MAX)
+    {
+        ACPI_ERROR ((AE_INFO,
+            "Maximum GPE number from FADT is too large: 0x%X",
+            GpeNumberMax));
+        Status = AE_BAD_VALUE;
+        goto Cleanup;
+    }
+
+Cleanup:
+    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvUpdateGpes
+ *
+ * PARAMETERS:  TableOwnerId        - ID of the newly-loaded ACPI table
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a
+ *              result of a Load() or LoadTable() operation. If new GPE
+ *              methods have been installed, register the new methods.
+ *
+ ******************************************************************************/
+
+void
+AcpiEvUpdateGpes (
+    ACPI_OWNER_ID           TableOwnerId)
+{
+    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo;
+    ACPI_GPE_BLOCK_INFO     *GpeBlock;
+    ACPI_GPE_WALK_INFO      WalkInfo;
+    ACPI_STATUS             Status = AE_OK;
+
+
+    /*
+     * Find any _Lxx/_Exx GPE methods that have just been loaded.
+     *
+     * Any GPEs that correspond to new _Lxx/_Exx methods are immediately
+     * enabled.
+     *
+     * Examine the namespace underneath each GpeDevice within the
+     * GpeBlock lists.
+     */
+    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+    if (ACPI_FAILURE (Status))
+    {
+        return;
+    }
+
+    WalkInfo.Count = 0;
+    WalkInfo.OwnerId = TableOwnerId;
+    WalkInfo.ExecuteByOwnerId = TRUE;
+
+    /* Walk the interrupt level descriptor list */
+
+    GpeXruptInfo = AcpiGbl_GpeXruptListHead;
+    while (GpeXruptInfo)
+    {
+        /* Walk all Gpe Blocks attached to this interrupt level */
+
+        GpeBlock = GpeXruptInfo->GpeBlockListHead;
+        while (GpeBlock)
+        {
+            WalkInfo.GpeBlock = GpeBlock;
+            WalkInfo.GpeDevice = GpeBlock->Node;
+
+            Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD,
+                        WalkInfo.GpeDevice, ACPI_UINT32_MAX,
+                        ACPI_NS_WALK_NO_UNLOCK, AcpiEvMatchGpeMethod,
+                        NULL, &WalkInfo, NULL);
+            if (ACPI_FAILURE (Status))
+            {
+                ACPI_EXCEPTION ((AE_INFO, Status,
+                    "While decoding _Lxx/_Exx methods"));
+            }
+
+            GpeBlock = GpeBlock->Next;
+        }
+
+        GpeXruptInfo = GpeXruptInfo->Next;
+    }
+
+    if (WalkInfo.Count)
+    {
+        ACPI_INFO ((AE_INFO, "Enabled %u new GPEs", WalkInfo.Count));
+    }
+
+    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+    return;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvMatchGpeMethod
+ *
+ * PARAMETERS:  Callback from WalkNamespace
+ *
+ * RETURN:      Status
+ *
+ * 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. Allows a
+ *              per-OwnerId evaluation if ExecuteByOwnerId is TRUE in the
+ *              WalkInfo parameter block.
+ *
+ *              The name of each GPE control method is of the form:
+ *              "_Lxx" or "_Exx", where:
+ *                  L      - means that the GPE is level triggered
+ *                  E      - means that the GPE is edge triggered
+ *                  xx     - is the GPE number [in HEX]
+ *
+ * If WalkInfo->ExecuteByOwnerId is TRUE, we only execute examine GPE methods
+ * with that owner.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvMatchGpeMethod (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  Level,
+    void                    *Context,
+    void                    **ReturnValue)
+{
+    ACPI_NAMESPACE_NODE     *MethodNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
+    ACPI_GPE_WALK_INFO      *WalkInfo = ACPI_CAST_PTR (ACPI_GPE_WALK_INFO, Context);
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    UINT32                  GpeNumber;
+    char                    Name[ACPI_NAME_SIZE + 1];
+    UINT8                   Type;
+
+
+    ACPI_FUNCTION_TRACE (EvMatchGpeMethod);
+
+
+    /* Check if requested OwnerId matches this OwnerId */
+
+    if ((WalkInfo->ExecuteByOwnerId) &&
+        (MethodNode->OwnerId != WalkInfo->OwnerId))
+    {
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /*
+     * Match and decode the _Lxx and _Exx GPE method names
+     *
+     * 1) Extract the method name and null terminate it
+     */
+    ACPI_MOVE_32_TO_32 (Name, &MethodNode->Name.Integer);
+    Name[ACPI_NAME_SIZE] = 0;
+
+    /* 2) Name must begin with an underscore */
+
+    if (Name[0] != '_')
+    {
+        return_ACPI_STATUS (AE_OK); /* Ignore this method */
+    }
+
+    /*
+     * 3) Edge/Level determination is based on the 2nd character
+     *    of the method name
+     */
+    switch (Name[1])
+    {
+    case 'L':
+        Type = ACPI_GPE_LEVEL_TRIGGERED;
+        break;
+
+    case 'E':
+        Type = ACPI_GPE_EDGE_TRIGGERED;
+        break;
+
+    default:
+        /* Unknown method type, just ignore it */
+
+        ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
+            "Ignoring unknown GPE method type: %s "
+            "(name not of form _Lxx or _Exx)", Name));
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /* 4) The last two characters of the name are the hex 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_LOAD,
+            "Could not extract GPE number from name: %s "
+            "(name is not of form _Lxx or _Exx)", Name));
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /* Ensure that we have a valid GPE number for this GPE block */
+
+    GpeEventInfo = AcpiEvLowGetGpeInfo (GpeNumber, WalkInfo->GpeBlock);
+    if (!GpeEventInfo)
+    {
+        /*
+         * This GpeNumber is not valid for this GPE block, just ignore it.
+         * However, it may be valid for a different GPE block, since GPE0
+         * and GPE1 methods both appear under \_GPE.
+         */
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
+            ACPI_GPE_DISPATCH_HANDLER)
+    {
+        /* If there is already a handler, ignore this GPE method */
+
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
+            ACPI_GPE_DISPATCH_METHOD)
+    {
+        /*
+         * If there is already a method, ignore this method. But check
+         * for a type mismatch (if both the _Lxx AND _Exx exist)
+         */
+        if (Type != (GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK))
+        {
+            ACPI_ERROR ((AE_INFO,
+                "For GPE 0x%.2X, found both _L%2.2X and _E%2.2X methods",
+                GpeNumber, GpeNumber, GpeNumber));
+        }
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /*
+     * Add the GPE information from above to the GpeEventInfo block for
+     * use during dispatch of this GPE.
+     */
+    GpeEventInfo->Flags &= ~(ACPI_GPE_DISPATCH_MASK);
+    GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_METHOD);
+    GpeEventInfo->Dispatch.MethodNode = MethodNode;
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_LOAD,
+        "Registered GPE method %s as GPE number 0x%.2X\n",
+        Name, GpeNumber));
+    return_ACPI_STATUS (AE_OK);
+}
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evgpeutil.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evgpeutil.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,425 @@
+/******************************************************************************
+ *
+ * Module Name: evgpeutil - GPE utilities
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acevents.h>
+
+#define _COMPONENT          ACPI_EVENTS
+        ACPI_MODULE_NAME    ("evgpeutil")
+
+
+#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvWalkGpeList
+ *
+ * PARAMETERS:  GpeWalkCallback     - Routine called for each GPE block
+ *              Context             - Value passed to callback
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Walk the GPE lists.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvWalkGpeList (
+    ACPI_GPE_CALLBACK       GpeWalkCallback,
+    void                    *Context)
+{
+    ACPI_GPE_BLOCK_INFO     *GpeBlock;
+    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo;
+    ACPI_STATUS             Status = AE_OK;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (EvWalkGpeList);
+
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+
+    /* Walk the interrupt level descriptor list */
+
+    GpeXruptInfo = AcpiGbl_GpeXruptListHead;
+    while (GpeXruptInfo)
+    {
+        /* Walk all Gpe Blocks attached to this interrupt level */
+
+        GpeBlock = GpeXruptInfo->GpeBlockListHead;
+        while (GpeBlock)
+        {
+            /* One callback per GPE block */
+
+            Status = GpeWalkCallback (GpeXruptInfo, GpeBlock, Context);
+            if (ACPI_FAILURE (Status))
+            {
+                if (Status == AE_CTRL_END) /* Callback abort */
+                {
+                    Status = AE_OK;
+                }
+                goto UnlockAndExit;
+            }
+
+            GpeBlock = GpeBlock->Next;
+        }
+
+        GpeXruptInfo = GpeXruptInfo->Next;
+    }
+
+UnlockAndExit:
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvValidGpeEvent
+ *
+ * PARAMETERS:  GpeEventInfo                - Info for this GPE
+ *
+ * RETURN:      TRUE if the GpeEvent is valid
+ *
+ * DESCRIPTION: Validate a GPE event. DO NOT CALL FROM INTERRUPT LEVEL.
+ *              Should be called only when the GPE lists are semaphore locked
+ *              and not subject to change.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiEvValidGpeEvent (
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo)
+{
+    ACPI_GPE_XRUPT_INFO     *GpeXruptBlock;
+    ACPI_GPE_BLOCK_INFO     *GpeBlock;
+
+
+    ACPI_FUNCTION_ENTRY ();
+
+
+    /* No need for spin lock since we are not changing any list elements */
+
+    /* Walk the GPE interrupt levels */
+
+    GpeXruptBlock = AcpiGbl_GpeXruptListHead;
+    while (GpeXruptBlock)
+    {
+        GpeBlock = GpeXruptBlock->GpeBlockListHead;
+
+        /* Walk the GPE blocks on this interrupt level */
+
+        while (GpeBlock)
+        {
+            if ((&GpeBlock->EventInfo[0] <= GpeEventInfo) &&
+                (&GpeBlock->EventInfo[GpeBlock->GpeCount] > GpeEventInfo))
+            {
+                return (TRUE);
+            }
+
+            GpeBlock = GpeBlock->Next;
+        }
+
+        GpeXruptBlock = GpeXruptBlock->Next;
+    }
+
+    return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvGetGpeDevice
+ *
+ * PARAMETERS:  GPE_WALK_CALLBACK
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE
+ *              block device. NULL if the GPE is one of the FADT-defined GPEs.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvGetGpeDevice (
+    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
+    ACPI_GPE_BLOCK_INFO     *GpeBlock,
+    void                    *Context)
+{
+    ACPI_GPE_DEVICE_INFO    *Info = Context;
+
+
+    /* Increment Index by the number of GPEs in this block */
+
+    Info->NextBlockBaseIndex += GpeBlock->GpeCount;
+
+    if (Info->Index < Info->NextBlockBaseIndex)
+    {
+        /*
+         * The GPE index is within this block, get the node. Leave the node
+         * NULL for the FADT-defined GPEs
+         */
+        if ((GpeBlock->Node)->Type == ACPI_TYPE_DEVICE)
+        {
+            Info->GpeDevice = GpeBlock->Node;
+        }
+
+        Info->Status = AE_OK;
+        return (AE_CTRL_END);
+    }
+
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvGetGpeXruptBlock
+ *
+ * PARAMETERS:  InterruptNumber      - Interrupt for a GPE block
+ *
+ * RETURN:      A GPE interrupt block
+ *
+ * DESCRIPTION: Get or Create a GPE interrupt block. There is one interrupt
+ *              block per unique interrupt level used for GPEs. Should be
+ *              called only when the GPE lists are semaphore locked and not
+ *              subject to change.
+ *
+ ******************************************************************************/
+
+ACPI_GPE_XRUPT_INFO *
+AcpiEvGetGpeXruptBlock (
+    UINT32                  InterruptNumber)
+{
+    ACPI_GPE_XRUPT_INFO     *NextGpeXrupt;
+    ACPI_GPE_XRUPT_INFO     *GpeXrupt;
+    ACPI_STATUS             Status;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (EvGetGpeXruptBlock);
+
+
+    /* No need for lock since we are not changing any list elements here */
+
+    NextGpeXrupt = AcpiGbl_GpeXruptListHead;
+    while (NextGpeXrupt)
+    {
+        if (NextGpeXrupt->InterruptNumber == InterruptNumber)
+        {
+            return_PTR (NextGpeXrupt);
+        }
+
+        NextGpeXrupt = NextGpeXrupt->Next;
+    }
+
+    /* Not found, must allocate a new xrupt descriptor */
+
+    GpeXrupt = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_XRUPT_INFO));
+    if (!GpeXrupt)
+    {
+        return_PTR (NULL);
+    }
+
+    GpeXrupt->InterruptNumber = InterruptNumber;
+
+    /* Install new interrupt descriptor with spin lock */
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+    if (AcpiGbl_GpeXruptListHead)
+    {
+        NextGpeXrupt = AcpiGbl_GpeXruptListHead;
+        while (NextGpeXrupt->Next)
+        {
+            NextGpeXrupt = NextGpeXrupt->Next;
+        }
+
+        NextGpeXrupt->Next = GpeXrupt;
+        GpeXrupt->Previous = NextGpeXrupt;
+    }
+    else
+    {
+        AcpiGbl_GpeXruptListHead = GpeXrupt;
+    }
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+
+    /* Install new interrupt handler if not SCI_INT */
+
+    if (InterruptNumber != AcpiGbl_FADT.SciInterrupt)
+    {
+        Status = AcpiOsInstallInterruptHandler (InterruptNumber,
+                    AcpiEvGpeXruptHandler, GpeXrupt);
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_ERROR ((AE_INFO,
+                "Could not install GPE interrupt handler at level 0x%X",
+                InterruptNumber));
+            return_PTR (NULL);
+        }
+    }
+
+    return_PTR (GpeXrupt);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvDeleteGpeXrupt
+ *
+ * PARAMETERS:  GpeXrupt        - A GPE interrupt info block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Remove and free a GpeXrupt block. Remove an associated
+ *              interrupt handler if not the SCI interrupt.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvDeleteGpeXrupt (
+    ACPI_GPE_XRUPT_INFO     *GpeXrupt)
+{
+    ACPI_STATUS             Status;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (EvDeleteGpeXrupt);
+
+
+    /* We never want to remove the SCI interrupt handler */
+
+    if (GpeXrupt->InterruptNumber == AcpiGbl_FADT.SciInterrupt)
+    {
+        GpeXrupt->GpeBlockListHead = NULL;
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /* Disable this interrupt */
+
+    Status = AcpiOsRemoveInterruptHandler (
+                GpeXrupt->InterruptNumber, AcpiEvGpeXruptHandler);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Unlink the interrupt block with lock */
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+    if (GpeXrupt->Previous)
+    {
+        GpeXrupt->Previous->Next = GpeXrupt->Next;
+    }
+    else
+    {
+        /* No previous, update list head */
+
+        AcpiGbl_GpeXruptListHead = GpeXrupt->Next;
+    }
+
+    if (GpeXrupt->Next)
+    {
+        GpeXrupt->Next->Previous = GpeXrupt->Previous;
+    }
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+
+    /* Free the block */
+
+    ACPI_FREE (GpeXrupt);
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvDeleteGpeHandlers
+ *
+ * PARAMETERS:  GpeXruptInfo        - GPE Interrupt info
+ *              GpeBlock            - Gpe Block info
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Delete all Handler objects found in the GPE data structs.
+ *              Used only prior to termination.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvDeleteGpeHandlers (
+    ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
+    ACPI_GPE_BLOCK_INFO     *GpeBlock,
+    void                    *Context)
+{
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    UINT32                  i;
+    UINT32                  j;
+
+
+    ACPI_FUNCTION_TRACE (EvDeleteGpeHandlers);
+
+
+    /* Examine each GPE Register within the block */
+
+    for (i = 0; i < GpeBlock->RegisterCount; i++)
+    {
+        /* Now look at the individual GPEs in this byte register */
+
+        for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
+        {
+            GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i *
+                ACPI_GPE_REGISTER_WIDTH) + j];
+
+            if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
+                    ACPI_GPE_DISPATCH_HANDLER)
+            {
+                ACPI_FREE (GpeEventInfo->Dispatch.Handler);
+                GpeEventInfo->Dispatch.Handler = NULL;
+                GpeEventInfo->Flags &= ~ACPI_GPE_DISPATCH_MASK;
+            }
+        }
+    }
+
+    return_ACPI_STATUS (AE_OK);
+}
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evmisc.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evmisc.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,377 @@
+/******************************************************************************
+ *
+ * Module Name: evmisc - Miscellaneous event manager support functions
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acevents.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#define _COMPONENT          ACPI_EVENTS
+        ACPI_MODULE_NAME    ("evmisc")
+
+
+/* Local prototypes */
+
+static void ACPI_SYSTEM_XFACE
+AcpiEvNotifyDispatch (
+    void                    *Context);
+
+
+/*******************************************************************************
+ *
+ * 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_THERMAL:
+        /*
+         * These are the ONLY objects that can receive ACPI notifications
+         */
+        return (TRUE);
+
+    default:
+        return (FALSE);
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvQueueNotifyRequest
+ *
+ * PARAMETERS:  Node            - NS node for the notified object
+ *              NotifyValue     - Value from the Notify() request
+ *
+ * RETURN:      Status
+ *
+ * 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 0x03 (Ejection Request), may need to run a device method.
+     * For value 0x02 (Device Wake), if _PRW exists, may need to run
+     *   the _PS0 method.
+     * For value 0x80 (Status Change) on the power button or sleep button,
+     *   initiate soft-off or sleep operation.
+     *
+     * For all cases, simply dispatch the notify to the handler.
+     */
+    ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+        "Dispatching Notify on [%4.4s] (%s) Value 0x%2.2X (%s) Node %p\n",
+        AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type),
+        NotifyValue, AcpiUtGetNotifyName (NotifyValue), Node));
+
+    /* Get the notify object attached to the NS Node */
+
+    ObjDesc = AcpiNsGetAttachedObject (Node);
+    if (ObjDesc)
+    {
+        /* We have the notify object, Get the correct handler */
+
+        switch (Node->Type)
+        {
+        /* Notify is allowed only on these types */
+
+        case ACPI_TYPE_DEVICE:
+        case ACPI_TYPE_THERMAL:
+        case ACPI_TYPE_PROCESSOR:
+
+            if (NotifyValue <= ACPI_MAX_SYS_NOTIFY)
+            {
+                HandlerObj = ObjDesc->CommonNotify.SystemNotify;
+            }
+            else
+            {
+                HandlerObj = ObjDesc->CommonNotify.DeviceNotify;
+            }
+            break;
+
+        default:
+
+            /* All other types are not supported */
+
+            return (AE_TYPE);
+        }
+    }
+
+    /*
+     * If there is a handler to run, schedule the dispatcher.
+     * Check for:
+     * 1) Global system notify handler
+     * 2) Global device notify handler
+     * 3) Per-device notify handler
+     */
+    if ((AcpiGbl_SystemNotify.Handler &&
+            (NotifyValue <= ACPI_MAX_SYS_NOTIFY)) ||
+        (AcpiGbl_DeviceNotify.Handler &&
+            (NotifyValue > ACPI_MAX_SYS_NOTIFY))  ||
+        HandlerObj)
+    {
+        NotifyInfo = AcpiUtCreateGenericState ();
+        if (!NotifyInfo)
+        {
+            return (AE_NO_MEMORY);
+        }
+
+        if (!HandlerObj)
+        {
+            ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+                "Executing system notify handler for Notify (%4.4s, %X) "
+                "node %p\n",
+                AcpiUtGetNodeName (Node), NotifyValue, Node));
+        }
+
+        NotifyInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_NOTIFY;
+        NotifyInfo->Notify.Node = Node;
+        NotifyInfo->Notify.Value = (UINT16) NotifyValue;
+        NotifyInfo->Notify.HandlerObj = HandlerObj;
+
+        Status = AcpiOsExecute (
+                    OSL_NOTIFY_HANDLER, AcpiEvNotifyDispatch, NotifyInfo);
+        if (ACPI_FAILURE (Status))
+        {
+            AcpiUtDeleteGenericState (NotifyInfo);
+        }
+    }
+    else
+    {
+        /* There is no notify handler (per-device or system) for this device */
+
+        ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
+            "No notify handler for Notify (%4.4s, %X) node %p\n",
+            AcpiUtGetNodeName (Node), NotifyValue, Node));
+    }
+
+    return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvNotifyDispatch
+ *
+ * PARAMETERS:  Context         - To be passed to the notify handler
+ *
+ * RETURN:      None.
+ *
+ * DESCRIPTION: Dispatch a device notification event to a previously
+ *              installed handler.
+ *
+ ******************************************************************************/
+
+static 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_SystemNotify.Handler)
+        {
+            GlobalHandler = AcpiGbl_SystemNotify.Handler;
+            GlobalContext = AcpiGbl_SystemNotify.Context;
+        }
+    }
+    else
+    {
+        /* Global driver notification handler */
+
+        if (AcpiGbl_DeviceNotify.Handler)
+        {
+            GlobalHandler = AcpiGbl_DeviceNotify.Handler;
+            GlobalContext = AcpiGbl_DeviceNotify.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->Notify.Handler (NotifyInfo->Notify.Node,
+            NotifyInfo->Notify.Value,
+            HandlerObj->Notify.Context);
+    }
+
+    /* All done with the info object */
+
+    AcpiUtDeleteGenericState (NotifyInfo);
+}
+
+
+#if (!ACPI_REDUCED_HARDWARE)
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiEvTerminate
+ *
+ * PARAMETERS:  none
+ *
+ * RETURN:      none
+ *
+ * DESCRIPTION: Disable events and free memory allocated for table storage.
+ *
+ ******************************************************************************/
+
+void
+AcpiEvTerminate (
+    void)
+{
+    UINT32                  i;
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (EvTerminate);
+
+
+    if (AcpiGbl_EventsInitialized)
+    {
+        /*
+         * Disable all event-related functionality. In all cases, on error,
+         * print a message but obviously we don't abort.
+         */
+
+        /* Disable all fixed events */
+
+        for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
+        {
+            Status = AcpiDisableEvent (i, 0);
+            if (ACPI_FAILURE (Status))
+            {
+                ACPI_ERROR ((AE_INFO,
+                    "Could not disable fixed event %u", (UINT32) i));
+            }
+        }
+
+        /* Disable all GPEs in all GPE blocks */
+
+        Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL);
+
+        /* Remove SCI handler */
+
+        Status = AcpiEvRemoveSciHandler ();
+        if (ACPI_FAILURE(Status))
+        {
+            ACPI_ERROR ((AE_INFO,
+                "Could not remove SCI handler"));
+        }
+
+        Status = AcpiEvRemoveGlobalLockHandler ();
+        if (ACPI_FAILURE(Status))
+        {
+            ACPI_ERROR ((AE_INFO,
+                "Could not remove Global Lock handler"));
+        }
+    }
+
+    /* Deallocate all handler objects installed within GPE info structs */
+
+    Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers, NULL);
+
+    /* Return to original mode if necessary */
+
+    if (AcpiGbl_OriginalMode == ACPI_SYS_MODE_LEGACY)
+    {
+        Status = AcpiDisable ();
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_WARNING ((AE_INFO, "AcpiDisable failed"));
+        }
+    }
+    return_VOID;
+}
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evregion.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evregion.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,1366 @@
+/******************************************************************************
+ *
+ * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#define __EVREGION_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acevents.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+
+#define _COMPONENT          ACPI_EVENTS
+        ACPI_MODULE_NAME    ("evregion")
+
+
+/* Local prototypes */
+
+static BOOLEAN
+AcpiEvHasDefaultHandler (
+    ACPI_NAMESPACE_NODE     *Node,
+    ACPI_ADR_SPACE_TYPE     SpaceId);
+
+static void
+AcpiEvOrphanEcRegMethod (
+    void);
+
+static ACPI_STATUS
+AcpiEvRegRun (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  Level,
+    void                    *Context,
+    void                    **ReturnValue);
+
+static ACPI_STATUS
+AcpiEvInstallHandler (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  Level,
+    void                    *Context,
+    void                    **ReturnValue);
+
+/* These are the address spaces that will get default handlers */
+
+#define ACPI_NUM_DEFAULT_SPACES     4
+
+static UINT8        AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] =
+{
+    ACPI_ADR_SPACE_SYSTEM_MEMORY,
+    ACPI_ADR_SPACE_SYSTEM_IO,
+    ACPI_ADR_SPACE_PCI_CONFIG,
+    ACPI_ADR_SPACE_DATA_TABLE
+};
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvInstallRegionHandlers
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Installs the core subsystem default address space handlers.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvInstallRegionHandlers (
+    void)
+{
+    ACPI_STATUS             Status;
+    UINT32                  i;
+
+
+    ACPI_FUNCTION_TRACE (EvInstallRegionHandlers);
+
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /*
+     * All address spaces (PCI Config, EC, SMBus) are scope dependent and
+     * registration must occur for a specific device.
+     *
+     * In the case of the 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).
+     * Similar for AE_SAME_HANDLER.
+     */
+    for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++)
+    {
+        Status = AcpiEvInstallSpaceHandler (AcpiGbl_RootNode,
+                    AcpiGbl_DefaultAddressSpaces[i],
+                    ACPI_DEFAULT_HANDLER, NULL, NULL);
+        switch (Status)
+        {
+        case AE_OK:
+        case AE_SAME_HANDLER:
+        case AE_ALREADY_EXISTS:
+
+            /* These exceptions are all OK */
+
+            Status = AE_OK;
+            break;
+
+        default:
+
+            goto UnlockAndExit;
+        }
+    }
+
+UnlockAndExit:
+    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvHasDefaultHandler
+ *
+ * PARAMETERS:  Node                - Namespace node for the device
+ *              SpaceId             - The address space ID
+ *
+ * RETURN:      TRUE if default handler is installed, FALSE otherwise
+ *
+ * DESCRIPTION: Check if the default handler is installed for the requested
+ *              space ID.
+ *
+ ******************************************************************************/
+
+static BOOLEAN
+AcpiEvHasDefaultHandler (
+    ACPI_NAMESPACE_NODE     *Node,
+    ACPI_ADR_SPACE_TYPE     SpaceId)
+{
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_OPERAND_OBJECT     *HandlerObj;
+
+
+    /* Must have an existing internal object */
+
+    ObjDesc = AcpiNsGetAttachedObject (Node);
+    if (ObjDesc)
+    {
+        HandlerObj = ObjDesc->Device.Handler;
+
+        /* Walk the linked list of handlers for this object */
+
+        while (HandlerObj)
+        {
+            if (HandlerObj->AddressSpace.SpaceId == SpaceId)
+            {
+                if (HandlerObj->AddressSpace.HandlerFlags &
+                        ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)
+                {
+                    return (TRUE);
+                }
+            }
+
+            HandlerObj = HandlerObj->AddressSpace.Next;
+        }
+    }
+
+    return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvInitializeOpRegions
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Execute _REG methods for all Operation Regions that have
+ *              an installed default region handler.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvInitializeOpRegions (
+    void)
+{
+    ACPI_STATUS             Status;
+    UINT32                  i;
+
+
+    ACPI_FUNCTION_TRACE (EvInitializeOpRegions);
+
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Run the _REG methods for OpRegions in each default address space */
+
+    for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++)
+    {
+        /*
+         * Make sure the installed handler is the DEFAULT handler. If not the
+         * default, the _REG methods will have already been run (when the
+         * handler was installed)
+         */
+        if (AcpiEvHasDefaultHandler (AcpiGbl_RootNode,
+               AcpiGbl_DefaultAddressSpaces[i]))
+        {
+            Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode,
+                        AcpiGbl_DefaultAddressSpaces[i]);
+        }
+    }
+
+    AcpiGbl_RegMethodsExecuted = TRUE;
+
+    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvExecuteRegMethod
+ *
+ * PARAMETERS:  RegionObj           - Region object
+ *              Function            - Passed to _REG: On (1) or Off (0)
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Execute _REG method for a region
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvExecuteRegMethod (
+    ACPI_OPERAND_OBJECT     *RegionObj,
+    UINT32                  Function)
+{
+    ACPI_EVALUATE_INFO      *Info;
+    ACPI_OPERAND_OBJECT     *Args[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);
+    }
+
+    /* Allocate and initialize the evaluation information block */
+
+    Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
+    if (!Info)
+    {
+        return_ACPI_STATUS (AE_NO_MEMORY);
+    }
+
+    Info->PrefixNode = RegionObj2->Extra.Method_REG;
+    Info->Pathname = NULL;
+    Info->Parameters = Args;
+    Info->Flags = ACPI_IGNORE_RETURN_VALUE;
+
+    /*
+     * The _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)
+     */
+    Args[0] = AcpiUtCreateIntegerObject ((UINT64) RegionObj->Region.SpaceId);
+    if (!Args[0])
+    {
+        Status = AE_NO_MEMORY;
+        goto Cleanup1;
+    }
+
+    Args[1] = AcpiUtCreateIntegerObject ((UINT64) Function);
+    if (!Args[1])
+    {
+        Status = AE_NO_MEMORY;
+        goto Cleanup2;
+    }
+
+    Args[2] = NULL; /* Terminate list */
+
+    /* Execute the method, no return value */
+
+    ACPI_DEBUG_EXEC (
+        AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Info->PrefixNode, NULL));
+
+    Status = AcpiNsEvaluate (Info);
+    AcpiUtRemoveReference (Args[1]);
+
+Cleanup2:
+    AcpiUtRemoveReference (Args[0]);
+
+Cleanup1:
+    ACPI_FREE (Info);
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvAddressSpaceDispatch
+ *
+ * PARAMETERS:  RegionObj           - Internal region object
+ *              FieldObj            - Corresponding field. Can be NULL.
+ *              Function            - Read or Write operation
+ *              RegionOffset        - Where in the region to read or write
+ *              BitWidth            - Field width in bits (8, 16, 32, or 64)
+ *              Value               - Pointer to in or out value, must be
+ *                                    a full 64-bit integer
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Dispatch an address space or operation region access to
+ *              a previously installed handler.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvAddressSpaceDispatch (
+    ACPI_OPERAND_OBJECT     *RegionObj,
+    ACPI_OPERAND_OBJECT     *FieldObj,
+    UINT32                  Function,
+    UINT32                  RegionOffset,
+    UINT32                  BitWidth,
+    UINT64                  *Value)
+{
+    ACPI_STATUS             Status;
+    ACPI_ADR_SPACE_HANDLER  Handler;
+    ACPI_ADR_SPACE_SETUP    RegionSetup;
+    ACPI_OPERAND_OBJECT     *HandlerDesc;
+    ACPI_OPERAND_OBJECT     *RegionObj2;
+    void                    *RegionContext = NULL;
+    ACPI_CONNECTION_INFO    *Context;
+
+
+    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.Handler;
+    if (!HandlerDesc)
+    {
+        ACPI_ERROR ((AE_INFO,
+            "No handler for Region [%4.4s] (%p) [%s]",
+            AcpiUtGetNodeName (RegionObj->Region.Node),
+            RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
+
+        return_ACPI_STATUS (AE_NOT_EXIST);
+    }
+
+    Context = HandlerDesc->AddressSpace.Context;
+
+    /*
+     * 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->AddressSpace.Setup;
+        if (!RegionSetup)
+        {
+            /* No initialization routine, exit with error */
+
+            ACPI_ERROR ((AE_INFO,
+                "No init routine for region(%p) [%s]",
+                RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
+            return_ACPI_STATUS (AE_NOT_EXIST);
+        }
+
+        /*
+         * We must exit the interpreter because the region setup will
+         * potentially execute control methods (for example, the _REG method
+         * for this region)
+         */
+        AcpiExExitInterpreter ();
+
+        Status = RegionSetup (RegionObj, ACPI_REGION_ACTIVATE,
+                    Context, &RegionContext);
+
+        /* Re-enter the interpreter */
+
+        AcpiExEnterInterpreter ();
+
+        /* Check for failure of the Region Setup */
+
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_EXCEPTION ((AE_INFO, Status,
+                "During region initialization: [%s]",
+                AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
+            return_ACPI_STATUS (Status);
+        }
+
+        /* Region initialization may have been completed by RegionSetup */
+
+        if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE))
+        {
+            RegionObj->Region.Flags |= AOPOBJ_SETUP_COMPLETE;
+
+            if (RegionObj2->Extra.RegionContext)
+            {
+                /* The handler for this region was already installed */
+
+                ACPI_FREE (RegionContext);
+            }
+            else
+            {
+                /*
+                 * Save the returned context for use in all accesses to
+                 * this particular region
+                 */
+                RegionObj2->Extra.RegionContext = RegionContext;
+            }
+        }
+    }
+
+    /* We have everything we need, we can invoke the address space handler */
+
+    Handler = HandlerDesc->AddressSpace.Handler;
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+        "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
+        &RegionObj->Region.Handler->AddressSpace, Handler,
+        ACPI_FORMAT_NATIVE_UINT (RegionObj->Region.Address + RegionOffset),
+        AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
+
+
+    /*
+     * Special handling for GenericSerialBus and GeneralPurposeIo:
+     * There are three extra parameters that must be passed to the
+     * handler via the context:
+     *   1) Connection buffer, a resource template from Connection() op.
+     *   2) Length of the above buffer.
+     *   3) Actual access length from the AccessAs() op.
+     */
+    if (((RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GSBUS) ||
+            (RegionObj->Region.SpaceId == ACPI_ADR_SPACE_GPIO)) &&
+        Context &&
+        FieldObj)
+    {
+        /* Get the Connection (ResourceTemplate) buffer */
+
+        Context->Connection = FieldObj->Field.ResourceBuffer;
+        Context->Length = FieldObj->Field.ResourceLength;
+        Context->AccessLength = FieldObj->Field.AccessLength;
+    }
+
+    if (!(HandlerDesc->AddressSpace.HandlerFlags &
+            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();
+    }
+
+    /* Call the handler */
+
+    Status = Handler (Function,
+        (RegionObj->Region.Address + RegionOffset), BitWidth, Value,
+        Context, RegionObj2->Extra.RegionContext);
+
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_EXCEPTION ((AE_INFO, Status, "Returned by Handler for [%s]",
+            AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
+    }
+
+    if (!(HandlerDesc->AddressSpace.HandlerFlags &
+            ACPI_ADDR_HANDLER_DEFAULT_INSTALLED))
+    {
+        /*
+         * We just returned from a non-default handler, we must re-enter the
+         * interpreter
+         */
+       AcpiExEnterInterpreter ();
+    }
+
+    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.Handler;
+    if (!HandlerObj)
+    {
+        /* This region has no handler, all done */
+
+        return_VOID;
+    }
+
+    /* Find this region in the handler's list */
+
+    ObjDesc = HandlerObj->AddressSpace.RegionList;
+    LastObjPtr = &HandlerObj->AddressSpace.RegionList;
+
+    while (ObjDesc)
+    {
+        /* Is this the correct Region? */
+
+        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, ACPI_REG_DISCONNECT);
+            if (ACPI_FAILURE (Status))
+            {
+                ACPI_EXCEPTION ((AE_INFO, Status, "from region _REG, [%s]",
+                    AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
+            }
+
+            if (AcpiNsIsLocked)
+            {
+                Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+                if (ACPI_FAILURE (Status))
+                {
+                    return_VOID;
+                }
+            }
+
+            /*
+             * If the region has been activated, call the setup handler with
+             * the deactivate notification
+             */
+            if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE)
+            {
+                RegionSetup = HandlerObj->AddressSpace.Setup;
+                Status = RegionSetup (RegionObj, ACPI_REGION_DEACTIVATE,
+                    HandlerObj->AddressSpace.Context, RegionContext);
+
+                /* Init routine may fail, Just ignore errors */
+
+                if (ACPI_FAILURE (Status))
+                {
+                    ACPI_EXCEPTION ((AE_INFO, Status,
+                        "from region handler - deactivate, [%s]",
+                        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 must be the
+             * region's handler
+             */
+            RegionObj->Region.Handler = NULL;
+            AcpiUtRemoveReference (HandlerObj);
+
+            return_VOID;
+        }
+
+        /* Walk 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_FUNCTION_TRACE (EvAttachRegion);
+
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+        "Adding Region [%4.4s] %p to address handler %p [%s]\n",
+        AcpiUtGetNodeName (RegionObj->Region.Node),
+        RegionObj, HandlerObj,
+        AcpiUtGetRegionName (RegionObj->Region.SpaceId)));
+
+    /* Link this region to the front of the handler's list */
+
+    RegionObj->Region.Next = HandlerObj->AddressSpace.RegionList;
+    HandlerObj->AddressSpace.RegionList = RegionObj;
+
+    /* Install the region's handler */
+
+    if (RegionObj->Region.Handler)
+    {
+        return_ACPI_STATUS (AE_ALREADY_EXISTS);
+    }
+
+    RegionObj->Region.Handler = HandlerObj;
+    AcpiUtAddReference (HandlerObj);
+
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvInstallHandler
+ *
+ * PARAMETERS:  WalkNamespace callback
+ *
+ * DESCRIPTION: This routine installs an address handler into objects that are
+ *              of type Region or Device.
+ *
+ *              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.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiEvInstallHandler (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  Level,
+    void                    *Context,
+    void                    **ReturnValue)
+{
+    ACPI_OPERAND_OBJECT     *HandlerObj;
+    ACPI_OPERAND_OBJECT     *NextHandlerObj;
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_NAME (EvInstallHandler);
+
+
+    HandlerObj = (ACPI_OPERAND_OBJECT  *) Context;
+
+    /* Parameter validation */
+
+    if (!HandlerObj)
+    {
+        return (AE_OK);
+    }
+
+    /* Convert and validate the device handle */
+
+    Node = AcpiNsValidateHandle (ObjHandle);
+    if (!Node)
+    {
+        return (AE_BAD_PARAMETER);
+    }
+
+    /*
+     * We only care about regions and objects that are allowed to have
+     * address space 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)
+    {
+        /* No object, just exit */
+
+        return (AE_OK);
+    }
+
+    /* Devices are handled different than regions */
+
+    if (ObjDesc->Common.Type == ACPI_TYPE_DEVICE)
+    {
+        /* Check if this Device already has a handler for this address space */
+
+        NextHandlerObj = ObjDesc->Device.Handler;
+        while (NextHandlerObj)
+        {
+            /* Found a handler, is it for the same address space? */
+
+            if (NextHandlerObj->AddressSpace.SpaceId ==
+                    HandlerObj->AddressSpace.SpaceId)
+            {
+                ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+                    "Found handler for region [%s] in device %p(%p) "
+                    "handler %p\n",
+                    AcpiUtGetRegionName (HandlerObj->AddressSpace.SpaceId),
+                    ObjDesc, NextHandlerObj, 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);
+            }
+
+            /* Walk the linked list of handlers attached to this device */
+
+            NextHandlerObj = NextHandlerObj->AddressSpace.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);
+    }
+
+    /* Object is a Region */
+
+    if (ObjDesc->Region.SpaceId != HandlerObj->AddressSpace.SpaceId)
+    {
+        /* This region is for a different address space, just 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);
+
+    /* Connect the region to the new handler */
+
+    Status = AcpiEvAttachRegion (HandlerObj, ObjDesc, FALSE);
+    return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvInstallSpaceHandler
+ *
+ * PARAMETERS:  Node            - Namespace node 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.
+ *              Assumes namespace is locked
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvInstallSpaceHandler (
+    ACPI_NAMESPACE_NODE     *Node,
+    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_STATUS             Status;
+    ACPI_OBJECT_TYPE        Type;
+    UINT8                  Flags = 0;
+
+
+    ACPI_FUNCTION_TRACE (EvInstallSpaceHandler);
+
+
+    /*
+     * 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_BAD_PARAMETER;
+            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 attached device object already exists. Make sure the handler
+         * is not already installed.
+         */
+        HandlerObj = ObjDesc->Device.Handler;
+
+        /* Walk the handler list for this device */
+
+        while (HandlerObj)
+        {
+            /* Same SpaceId indicates a handler already installed */
+
+            if (HandlerObj->AddressSpace.SpaceId == SpaceId)
+            {
+                if (HandlerObj->AddressSpace.Handler == Handler)
+                {
+                    /*
+                     * It is (relatively) OK to attempt to install the SAME
+                     * handler twice. This can easily happen with the
+                     * PCI_Config space.
+                     */
+                    Status = AE_SAME_HANDLER;
+                    goto UnlockAndExit;
+                }
+                else
+                {
+                    /* A handler is already installed */
+
+                    Status = AE_ALREADY_EXISTS;
+                }
+                goto UnlockAndExit;
+            }
+
+            /* Walk the linked list of handlers */
+
+            HandlerObj = HandlerObj->AddressSpace.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);
+
+        /* Remove local reference to the object */
+
+        AcpiUtRemoveReference (ObjDesc);
+
+        if (ACPI_FAILURE (Status))
+        {
+            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,
+        AcpiUtGetNodeName (Node), Node, ObjDesc));
+
+    /*
+     * Install the handler
+     *
+     * At this point there is no existing handler. 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;
+    }
+
+    /* Init handler obj */
+
+    HandlerObj->AddressSpace.SpaceId = (UINT8) SpaceId;
+    HandlerObj->AddressSpace.HandlerFlags = Flags;
+    HandlerObj->AddressSpace.RegionList = NULL;
+    HandlerObj->AddressSpace.Node = Node;
+    HandlerObj->AddressSpace.Handler = Handler;
+    HandlerObj->AddressSpace.Context = Context;
+    HandlerObj->AddressSpace.Setup  = Setup;
+
+    /* Install at head of Device.AddressSpace list */
+
+    HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler;
+
+    /*
+     * The Device object is the first reference on the HandlerObj.
+     * Each region that uses the handler adds a reference.
+     */
+    ObjDesc->Device.Handler = HandlerObj;
+
+    /*
+     * Walk the namespace finding all of the regions this
+     * handler will manage.
+     *
+     * 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, back up and search down the remainder
+     * of the branch
+     */
+    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX,
+                ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, NULL,
+                HandlerObj, NULL);
+
+UnlockAndExit:
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvExecuteRegMethods
+ *
+ * PARAMETERS:  Node            - Namespace node for the device
+ *              SpaceId         - The address space ID
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Run all _REG methods for the input Space ID;
+ *              Note: assumes namespace is locked, or system init time.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvExecuteRegMethods (
+    ACPI_NAMESPACE_NODE     *Node,
+    ACPI_ADR_SPACE_TYPE     SpaceId)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (EvExecuteRegMethods);
+
+
+    /*
+     * Run all _REG methods for all Operation Regions for this space ID. This
+     * is a separate walk in order to handle any interdependencies between
+     * regions and _REG methods. (i.e. handlers must be installed for all
+     * regions of this Space ID before we can run any _REG methods)
+     */
+    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX,
+                ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, NULL,
+                &SpaceId, NULL);
+
+    /* Special case for EC: handle "orphan" _REG methods with no region */
+
+    if (SpaceId == ACPI_ADR_SPACE_EC)
+    {
+        AcpiEvOrphanEcRegMethod ();
+    }
+
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvRegRun
+ *
+ * PARAMETERS:  WalkNamespace callback
+ *
+ * DESCRIPTION: Run _REG method for region objects of the requested spaceID
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiEvRegRun (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  Level,
+    void                    *Context,
+    void                    **ReturnValue)
+{
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_ADR_SPACE_TYPE     SpaceId;
+    ACPI_STATUS             Status;
+
+
+    SpaceId = *ACPI_CAST_PTR (ACPI_ADR_SPACE_TYPE, Context);
+
+    /* Convert and validate the device handle */
+
+    Node = AcpiNsValidateHandle (ObjHandle);
+    if (!Node)
+    {
+        return (AE_BAD_PARAMETER);
+    }
+
+    /*
+     * We only care about regions.and objects that are allowed to have address
+     * space handlers
+     */
+    if ((Node->Type != ACPI_TYPE_REGION) &&
+        (Node != AcpiGbl_RootNode))
+    {
+        return (AE_OK);
+    }
+
+    /* Check for an existing internal object */
+
+    ObjDesc = AcpiNsGetAttachedObject (Node);
+    if (!ObjDesc)
+    {
+        /* No object, just exit */
+
+        return (AE_OK);
+    }
+
+    /* Object is a Region */
+
+    if (ObjDesc->Region.SpaceId != SpaceId)
+    {
+        /* This region is for a different address space, just ignore it */
+
+        return (AE_OK);
+    }
+
+    Status = AcpiEvExecuteRegMethod (ObjDesc, ACPI_REG_CONNECT);
+    return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvOrphanEcRegMethod
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Execute an "orphan" _REG method that appears under the EC
+ *              device. This is a _REG method that has no corresponding region
+ *              within the EC device scope. The orphan _REG method appears to
+ *              have been enabled by the description of the ECDT in the ACPI
+ *              specification: "The availability of the region space can be
+ *              detected by providing a _REG method object underneath the
+ *              Embedded Controller device."
+ *
+ *              To quickly access the EC device, we use the EC_ID that appears
+ *              within the ECDT. Otherwise, we would need to perform a time-
+ *              consuming namespace walk, executing _HID methods to find the
+ *              EC device.
+ *
+ ******************************************************************************/
+
+static void
+AcpiEvOrphanEcRegMethod (
+    void)
+{
+    ACPI_TABLE_ECDT         *Table;
+    ACPI_STATUS             Status;
+    ACPI_OBJECT_LIST        Args;
+    ACPI_OBJECT             Objects[2];
+    ACPI_NAMESPACE_NODE     *EcDeviceNode;
+    ACPI_NAMESPACE_NODE     *RegMethod;
+    ACPI_NAMESPACE_NODE     *NextNode;
+
+
+    ACPI_FUNCTION_TRACE (EvOrphanEcRegMethod);
+
+
+    /* Get the ECDT (if present in system) */
+
+    Status = AcpiGetTable (ACPI_SIG_ECDT, 0,
+        ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &Table));
+    if (ACPI_FAILURE (Status))
+    {
+        return_VOID;
+    }
+
+    /* We need a valid EC_ID string */
+
+    if (!(*Table->Id))
+    {
+        return_VOID;
+    }
+
+    /* Namespace is currently locked, must release */
+
+    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+
+    /* Get a handle to the EC device referenced in the ECDT */
+
+    Status = AcpiGetHandle (NULL,
+        ACPI_CAST_PTR (char, Table->Id),
+        ACPI_CAST_PTR (ACPI_HANDLE, &EcDeviceNode));
+    if (ACPI_FAILURE (Status))
+    {
+        goto Exit;
+    }
+
+    /* Get a handle to a _REG method immediately under the EC device */
+
+    Status = AcpiGetHandle (EcDeviceNode,
+        METHOD_NAME__REG, ACPI_CAST_PTR (ACPI_HANDLE, &RegMethod));
+    if (ACPI_FAILURE (Status))
+    {
+        goto Exit;
+    }
+
+    /*
+     * Execute the _REG method only if there is no Operation Region in
+     * this scope with the Embedded Controller space ID. Otherwise, it
+     * will already have been executed. Note, this allows for Regions
+     * with other space IDs to be present; but the code below will then
+     * execute the _REG method with the EC space ID argument.
+     */
+    NextNode = AcpiNsGetNextNode (EcDeviceNode, NULL);
+    while (NextNode)
+    {
+        if ((NextNode->Type == ACPI_TYPE_REGION) &&
+            (NextNode->Object) &&
+            (NextNode->Object->Region.SpaceId == ACPI_ADR_SPACE_EC))
+        {
+            goto Exit; /* Do not execute _REG */
+        }
+        NextNode = AcpiNsGetNextNode (EcDeviceNode, NextNode);
+    }
+
+    /* Evaluate the _REG(EC,Connect) method */
+
+    Args.Count = 2;
+    Args.Pointer = Objects;
+    Objects[0].Type = ACPI_TYPE_INTEGER;
+    Objects[0].Integer.Value = ACPI_ADR_SPACE_EC;
+    Objects[1].Type = ACPI_TYPE_INTEGER;
+    Objects[1].Integer.Value = ACPI_REG_CONNECT;
+
+    Status = AcpiEvaluateObject (RegMethod, NULL, &Args, NULL);
+
+Exit:
+    /* We ignore all errors from above, don't care */
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+    return_VOID;
+}
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evrgnini.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evrgnini.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,732 @@
+/******************************************************************************
+ *
+ * Module Name: evrgnini- ACPI AddressSpace (OpRegion) init
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#define __EVRGNINI_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acevents.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#define _COMPONENT          ACPI_EVENTS
+        ACPI_MODULE_NAME    ("evrgnini")
+
+/* Local prototypes */
+
+static BOOLEAN
+AcpiEvIsPciRootBridge (
+    ACPI_NAMESPACE_NODE     *Node);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvSystemMemoryRegionSetup
+ *
+ * PARAMETERS:  Handle              - Region we are interested in
+ *              Function            - Start or stop
+ *              HandlerContext      - Address space handler context
+ *              RegionContext       - Region specific context
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Setup a SystemMemory operation region
+ *
+ ******************************************************************************/
+
+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)
+        {
+            LocalRegionContext = (ACPI_MEM_SPACE_CONTEXT *) *RegionContext;
+
+            /* Delete a cached mapping if present */
+
+            if (LocalRegionContext->MappedLength)
+            {
+                AcpiOsUnmapMemory (LocalRegionContext->MappedLogicalAddress,
+                    LocalRegionContext->MappedLength);
+            }
+            ACPI_FREE (LocalRegionContext);
+            *RegionContext = NULL;
+        }
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /* Create a new context */
+
+    LocalRegionContext = ACPI_ALLOCATE_ZEROED (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:  Handle              - Region we are interested in
+ *              Function            - Start or stop
+ *              HandlerContext      - Address space handler context
+ *              RegionContext       - Region specific context
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Setup a IO operation region
+ *
+ ******************************************************************************/
+
+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:  Handle              - Region we are interested in
+ *              Function            - Start or stop
+ *              HandlerContext      - Address space handler context
+ *              RegionContext       - Region specific context
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Setup a PCI_Config operation region
+ *
+ * MUTEX:       Assumes namespace is not locked
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEvPciConfigRegionSetup (
+    ACPI_HANDLE             Handle,
+    UINT32                  Function,
+    void                    *HandlerContext,
+    void                    **RegionContext)
+{
+    ACPI_STATUS             Status = AE_OK;
+    UINT64                  PciValue;
+    ACPI_PCI_ID             *PciId = *RegionContext;
+    ACPI_OPERAND_OBJECT     *HandlerObj;
+    ACPI_NAMESPACE_NODE     *ParentNode;
+    ACPI_NAMESPACE_NODE     *PciRootNode;
+    ACPI_NAMESPACE_NODE     *PciDeviceNode;
+    ACPI_OPERAND_OBJECT     *RegionObj = (ACPI_OPERAND_OBJECT  *) Handle;
+
+
+    ACPI_FUNCTION_TRACE (EvPciConfigRegionSetup);
+
+
+    HandlerObj = RegionObj->Region.Handler;
+    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);
+    }
+
+    *RegionContext = NULL;
+    if (Function == ACPI_REGION_DEACTIVATE)
+    {
+        if (PciId)
+        {
+            ACPI_FREE (PciId);
+        }
+        return_ACPI_STATUS (Status);
+    }
+
+    ParentNode = RegionObj->Region.Node->Parent;
+
+    /*
+     * 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 AddressSpace.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->AddressSpace.Node == AcpiGbl_RootNode)
+    {
+        /* Start search from the parent object */
+
+        PciRootNode = ParentNode;
+        while (PciRootNode != AcpiGbl_RootNode)
+        {
+            /* Get the _HID/_CID in order to detect a RootBridge */
+
+            if (AcpiEvIsPciRootBridge (PciRootNode))
+            {
+                /* Install a handler for this PCI root bridge */
+
+                Status = AcpiInstallAddressSpaceHandler (
+                            (ACPI_HANDLE) PciRootNode,
+                            ACPI_ADR_SPACE_PCI_CONFIG,
+                            ACPI_DEFAULT_HANDLER, NULL, NULL);
+                if (ACPI_FAILURE (Status))
+                {
+                    if (Status == AE_SAME_HANDLER)
+                    {
+                        /*
+                         * It is OK if the handler is already installed on the
+                         * root bridge. Still need to return a context object
+                         * for the new PCI_Config operation region, however.
+                         */
+                        Status = AE_OK;
+                    }
+                    else
+                    {
+                        ACPI_EXCEPTION ((AE_INFO, Status,
+                            "Could not install PciConfig handler "
+                            "for Root Bridge %4.4s",
+                            AcpiUtGetNodeName (PciRootNode)));
+                    }
+                }
+                break;
+            }
+
+            PciRootNode = PciRootNode->Parent;
+        }
+
+        /* PCI root bridge not found, use namespace root node */
+    }
+    else
+    {
+        PciRootNode = HandlerObj->AddressSpace.Node;
+    }
+
+    /*
+     * If this region is now initialized, we are done.
+     * (InstallAddressSpaceHandler could have initialized it)
+     */
+    if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE)
+    {
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /* Region is still not initialized. Create a new context */
+
+    PciId = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PCI_ID));
+    if (!PciId)
+    {
+        return_ACPI_STATUS (AE_NO_MEMORY);
+    }
+
+    /*
+     * For PCI_Config space access, we need the segment, bus, device and
+     * function numbers. Acquire them here.
+     *
+     * Find the parent device object. (This allows the operation region to be
+     * within a subscope under the device, such as a control method.)
+     */
+    PciDeviceNode = RegionObj->Region.Node;
+    while (PciDeviceNode && (PciDeviceNode->Type != ACPI_TYPE_DEVICE))
+    {
+        PciDeviceNode = PciDeviceNode->Parent;
+    }
+
+    if (!PciDeviceNode)
+    {
+        ACPI_FREE (PciId);
+        return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+    }
+
+    /*
+     * Get the PCI device and function numbers from the _ADR object
+     * contained in the parent's scope.
+     */
+    Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR,
+                PciDeviceNode, &PciValue);
+
+    /*
+     * 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 (PciValue));
+        PciId->Function = ACPI_LOWORD (ACPI_LODWORD (PciValue));
+    }
+
+    /* The PCI segment number comes from the _SEG method */
+
+    Status = AcpiUtEvaluateNumericObject (METHOD_NAME__SEG,
+                PciRootNode, &PciValue);
+    if (ACPI_SUCCESS (Status))
+    {
+        PciId->Segment = ACPI_LOWORD (PciValue);
+    }
+
+    /* The PCI bus number comes from the _BBN method */
+
+    Status = AcpiUtEvaluateNumericObject (METHOD_NAME__BBN,
+                PciRootNode, &PciValue);
+    if (ACPI_SUCCESS (Status))
+    {
+        PciId->Bus = ACPI_LOWORD (PciValue);
+    }
+
+    /* Complete/update the PCI ID for this device */
+
+    Status = AcpiHwDerivePciId (PciId, PciRootNode, RegionObj->Region.Node);
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_FREE (PciId);
+        return_ACPI_STATUS (Status);
+    }
+
+    *RegionContext = PciId;
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvIsPciRootBridge
+ *
+ * PARAMETERS:  Node            - Device node being examined
+ *
+ * RETURN:      TRUE if device is a PCI/PCI-Express Root Bridge
+ *
+ * DESCRIPTION: Determine if the input device represents a PCI Root Bridge by
+ *              examining the _HID and _CID for the device.
+ *
+ ******************************************************************************/
+
+static BOOLEAN
+AcpiEvIsPciRootBridge (
+    ACPI_NAMESPACE_NODE     *Node)
+{
+    ACPI_STATUS             Status;
+    ACPI_DEVICE_ID          *Hid;
+    ACPI_DEVICE_ID_LIST     *Cid;
+    UINT32                  i;
+    BOOLEAN                 Match;
+
+
+    /* Get the _HID and check for a PCI Root Bridge */
+
+    Status = AcpiUtExecute_HID (Node, &Hid);
+    if (ACPI_FAILURE (Status))
+    {
+        return (FALSE);
+    }
+
+    Match = AcpiUtIsPciRootBridge (Hid->String);
+    ACPI_FREE (Hid);
+
+    if (Match)
+    {
+        return (TRUE);
+    }
+
+    /* The _HID did not match. Get the _CID and check for a PCI Root Bridge */
+
+    Status = AcpiUtExecute_CID (Node, &Cid);
+    if (ACPI_FAILURE (Status))
+    {
+        return (FALSE);
+    }
+
+    /* Check all _CIDs in the returned list */
+
+    for (i = 0; i < Cid->Count; i++)
+    {
+        if (AcpiUtIsPciRootBridge (Cid->Ids[i].String))
+        {
+            ACPI_FREE (Cid);
+            return (TRUE);
+        }
+    }
+
+    ACPI_FREE (Cid);
+    return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvPciBarRegionSetup
+ *
+ * PARAMETERS:  Handle              - Region we are interested in
+ *              Function            - Start or stop
+ *              HandlerContext      - Address space handler context
+ *              RegionContext       - Region specific context
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Setup a PciBAR operation region
+ *
+ * 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:  Handle              - Region we are interested in
+ *              Function            - Start or stop
+ *              HandlerContext      - Address space handler context
+ *              RegionContext       - Region specific context
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Setup a CMOS operation region
+ *
+ * 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:  Handle              - Region we are interested in
+ *              Function            - Start or stop
+ *              HandlerContext      - Address space handler context
+ *              RegionContext       - Region specific context
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Default region initialization
+ *
+ ******************************************************************************/
+
+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.
+ *
+ * MUTEX:       Interpreter should be unlocked, because we may run the _REG
+ *              method for this region.
+ *
+ ******************************************************************************/
+
+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 = RegionObj->Region.Node->Parent;
+    SpaceId = RegionObj->Region.SpaceId;
+
+    /* Setup defaults */
+
+    RegionObj->Region.Handler = 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 = AcpiNsSearchOneScope (
+                *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.Handler;
+                break;
+
+            case ACPI_TYPE_PROCESSOR:
+
+                HandlerObj = ObjDesc->Processor.Handler;
+                break;
+
+            case ACPI_TYPE_THERMAL:
+
+                HandlerObj = ObjDesc->ThermalZone.Handler;
+                break;
+
+            case ACPI_TYPE_METHOD:
+                /*
+                 * If we are executing module level code, the original
+                 * Node's object was replaced by this Method object and we
+                 * saved the handler in the method object.
+                 *
+                 * See AcpiNsExecModuleCode
+                 */
+                if (ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)
+                {
+                    HandlerObj = ObjDesc->Method.Dispatch.Handler;
+                }
+                break;
+
+            default:
+                /* Ignore other objects */
+                break;
+            }
+
+            while (HandlerObj)
+            {
+                /* Is this handler of the correct type? */
+
+                if (HandlerObj->AddressSpace.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);
+
+                    /*
+                     * Tell all users that this region is usable by
+                     * running the _REG method
+                     */
+                    if (AcpiNsLocked)
+                    {
+                        Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+                        if (ACPI_FAILURE (Status))
+                        {
+                            return_ACPI_STATUS (Status);
+                        }
+                    }
+
+                    Status = AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT);
+
+                    if (AcpiNsLocked)
+                    {
+                        Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+                        if (ACPI_FAILURE (Status))
+                        {
+                            return_ACPI_STATUS (Status);
+                        }
+                    }
+
+                    return_ACPI_STATUS (AE_OK);
+                }
+
+                /* Try next handler in the list */
+
+                HandlerObj = HandlerObj->AddressSpace.Next;
+            }
+        }
+
+        /* This node does not have the handler we need; Pop up one level */
+
+        Node = Node->Parent;
+    }
+
+    /* 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 -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evsci.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evsci.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,209 @@
+/*******************************************************************************
+ *
+ * Module Name: evsci - System Control Interrupt configuration and
+ *                      legacy to ACPI mode state transition functions
+ *
+ ******************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acevents.h>
+
+
+#define _COMPONENT          ACPI_EVENTS
+        ACPI_MODULE_NAME    ("evsci")
+
+#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
+
+/* Local prototypes */
+
+static UINT32 ACPI_SYSTEM_XFACE
+AcpiEvSciXruptHandler (
+    void                    *Context);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvSciXruptHandler
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+static UINT32 ACPI_SYSTEM_XFACE
+AcpiEvSciXruptHandler (
+    void                    *Context)
+{
+    ACPI_GPE_XRUPT_INFO     *GpeXruptList = Context;
+    UINT32                  InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED;
+
+
+    ACPI_FUNCTION_TRACE (EvSciXruptHandler);
+
+
+    /*
+     * We are guaranteed by the ACPI CA initialization/shutdown code that
+     * if this interrupt handler is installed, ACPI is enabled.
+     */
+
+    /*
+     * Fixed Events:
+     * Check for and dispatch any Fixed Events that have occurred
+     */
+    InterruptHandled |= AcpiEvFixedEventDetect ();
+
+    /*
+     * General Purpose Events:
+     * Check for and dispatch any GPEs that have occurred
+     */
+    InterruptHandled |= AcpiEvGpeDetect (GpeXruptList);
+
+    AcpiSciCount++;
+    return_UINT32 (InterruptHandled);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvGpeXruptHandler
+ *
+ * PARAMETERS:  Context   - Calling Context
+ *
+ * RETURN:      Status code indicates whether interrupt was handled.
+ *
+ * DESCRIPTION: Handler for GPE Block Device interrupts
+ *
+ ******************************************************************************/
+
+UINT32 ACPI_SYSTEM_XFACE
+AcpiEvGpeXruptHandler (
+    void                    *Context)
+{
+    ACPI_GPE_XRUPT_INFO     *GpeXruptList = Context;
+    UINT32                  InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED;
+
+
+    ACPI_FUNCTION_TRACE (EvGpeXruptHandler);
+
+
+    /*
+     * We are guaranteed by the ACPI CA initialization/shutdown code that
+     * if this interrupt handler is installed, ACPI is enabled.
+     */
+
+    /* GPEs: Check for and dispatch any GPEs that have occurred */
+
+    InterruptHandled |= AcpiEvGpeDetect (GpeXruptList);
+
+    return_UINT32 (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.SciInterrupt,
+                AcpiEvSciXruptHandler, AcpiGbl_GpeXruptListHead);
+    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.SciInterrupt,
+                AcpiEvSciXruptHandler);
+
+    return_ACPI_STATUS (Status);
+}
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evxface.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evxface.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,979 @@
+/******************************************************************************
+ *
+ * Module Name: evxface - External interfaces for ACPI events
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#define __EVXFACE_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acevents.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+
+#define _COMPONENT          ACPI_EVENTS
+        ACPI_MODULE_NAME    ("evxface")
+
+
+/*******************************************************************************
+ *
+ * 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)
+ *                                  ACPI_ALL_NOTIFY:  both system and device
+ *              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 = AcpiNsValidateHandle (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_SystemNotify.Handler)       ||
+            ((HandlerType & ACPI_DEVICE_NOTIFY) &&
+                AcpiGbl_DeviceNotify.Handler))
+        {
+            Status = AE_ALREADY_EXISTS;
+            goto UnlockAndExit;
+        }
+
+        if (HandlerType & ACPI_SYSTEM_NOTIFY)
+        {
+            AcpiGbl_SystemNotify.Node    = Node;
+            AcpiGbl_SystemNotify.Handler = Handler;
+            AcpiGbl_SystemNotify.Context = Context;
+        }
+
+        if (HandlerType & ACPI_DEVICE_NOTIFY)
+        {
+            AcpiGbl_DeviceNotify.Node    = Node;
+            AcpiGbl_DeviceNotify.Handler = Handler;
+            AcpiGbl_DeviceNotify.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.SystemNotify)   ||
+                ((HandlerType & ACPI_DEVICE_NOTIFY) &&
+                    ObjDesc->CommonNotify.DeviceNotify))
+            {
+                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);
+
+            /* Remove local reference to the object */
+
+            AcpiUtRemoveReference (ObjDesc);
+            if (ACPI_FAILURE (Status))
+            {
+                goto UnlockAndExit;
+            }
+        }
+
+        /* Install the handler */
+
+        NotifyObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_NOTIFY);
+        if (!NotifyObj)
+        {
+            Status = AE_NO_MEMORY;
+            goto UnlockAndExit;
+        }
+
+        NotifyObj->Notify.Node    = Node;
+        NotifyObj->Notify.Handler = Handler;
+        NotifyObj->Notify.Context = Context;
+
+        if (HandlerType & ACPI_SYSTEM_NOTIFY)
+        {
+            ObjDesc->CommonNotify.SystemNotify = NotifyObj;
+        }
+
+        if (HandlerType & ACPI_DEVICE_NOTIFY)
+        {
+            ObjDesc->CommonNotify.DeviceNotify = NotifyObj;
+        }
+
+        if (HandlerType == ACPI_ALL_NOTIFY)
+        {
+            /* Extra ref if installed in both */
+
+            AcpiUtAddReference (NotifyObj);
+        }
+    }
+
+
+UnlockAndExit:
+    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInstallNotifyHandler)
+
+
+/*******************************************************************************
+ *
+ * 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)
+ *                                  ACPI_ALL_NOTIFY:  both system and device
+ *              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 = AcpiNsValidateHandle (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 namespace root object\n"));
+
+        if (((HandlerType & ACPI_SYSTEM_NOTIFY) &&
+              !AcpiGbl_SystemNotify.Handler)        ||
+            ((HandlerType & ACPI_DEVICE_NOTIFY) &&
+              !AcpiGbl_DeviceNotify.Handler))
+        {
+            Status = AE_NOT_EXIST;
+            goto UnlockAndExit;
+        }
+
+        if (HandlerType & ACPI_SYSTEM_NOTIFY)
+        {
+            AcpiGbl_SystemNotify.Node    = NULL;
+            AcpiGbl_SystemNotify.Handler = NULL;
+            AcpiGbl_SystemNotify.Context = NULL;
+        }
+
+        if (HandlerType & ACPI_DEVICE_NOTIFY)
+        {
+            AcpiGbl_DeviceNotify.Node    = NULL;
+            AcpiGbl_DeviceNotify.Handler = NULL;
+            AcpiGbl_DeviceNotify.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.SystemNotify;
+            if (!NotifyObj)
+            {
+                Status = AE_NOT_EXIST;
+                goto UnlockAndExit;
+            }
+
+            if (NotifyObj->Notify.Handler != Handler)
+            {
+                Status = AE_BAD_PARAMETER;
+                goto UnlockAndExit;
+            }
+
+            /* Remove the handler */
+
+            ObjDesc->CommonNotify.SystemNotify = NULL;
+            AcpiUtRemoveReference (NotifyObj);
+        }
+
+        if (HandlerType & ACPI_DEVICE_NOTIFY)
+        {
+            NotifyObj = ObjDesc->CommonNotify.DeviceNotify;
+            if (!NotifyObj)
+            {
+                Status = AE_NOT_EXIST;
+                goto UnlockAndExit;
+            }
+
+            if (NotifyObj->Notify.Handler != Handler)
+            {
+                Status = AE_BAD_PARAMETER;
+                goto UnlockAndExit;
+            }
+
+            /* Remove the handler */
+
+            ObjDesc->CommonNotify.DeviceNotify = NULL;
+            AcpiUtRemoveReference (NotifyObj);
+        }
+    }
+
+
+UnlockAndExit:
+    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiRemoveNotifyHandler)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiInstallExceptionHandler
+ *
+ * PARAMETERS:  Handler         - Pointer to the handler function for the
+ *                                event
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Saves the pointer to the handler function
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiInstallExceptionHandler (
+    ACPI_EXCEPTION_HANDLER  Handler)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (AcpiInstallExceptionHandler);
+
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Don't allow two handlers. */
+
+    if (AcpiGbl_ExceptionHandler)
+    {
+        Status = AE_ALREADY_EXISTS;
+        goto Cleanup;
+    }
+
+    /* Install the handler */
+
+    AcpiGbl_ExceptionHandler = Handler;
+
+Cleanup:
+    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInstallExceptionHandler)
+
+
+#if (!ACPI_REDUCED_HARDWARE)
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiInstallGlobalEventHandler
+ *
+ * PARAMETERS:  Handler         - Pointer to the global event handler function
+ *              Context         - Value passed to the handler on each event
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Saves the pointer to the handler function. The global handler
+ *              is invoked upon each incoming GPE and Fixed Event. It is
+ *              invoked at interrupt level at the time of the event dispatch.
+ *              Can be used to update event counters, etc.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiInstallGlobalEventHandler (
+    ACPI_GBL_EVENT_HANDLER  Handler,
+    void                    *Context)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (AcpiInstallGlobalEventHandler);
+
+
+    /* Parameter validation */
+
+    if (!Handler)
+    {
+        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 (AcpiGbl_GlobalEventHandler)
+    {
+        Status = AE_ALREADY_EXISTS;
+        goto Cleanup;
+    }
+
+    AcpiGbl_GlobalEventHandler = Handler;
+    AcpiGbl_GlobalEventHandlerContext = Context;
+
+
+Cleanup:
+    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInstallGlobalEventHandler)
+
+
+/*******************************************************************************
+ *
+ * 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, 0);
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_WARNING ((AE_INFO, "Could not enable fixed event 0x%X", Event));
+
+        /* 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);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInstallFixedEventHandler)
+
+
+/*******************************************************************************
+ *
+ * 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, 0);
+
+    /* Always Remove the handler */
+
+    AcpiGbl_FixedEventHandlers[Event].Handler = NULL;
+    AcpiGbl_FixedEventHandlers[Event].Context = NULL;
+
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_WARNING ((AE_INFO,
+            "Could not write to fixed event enable register 0x%X", Event));
+    }
+    else
+    {
+        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X\n", Event));
+    }
+
+    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiRemoveFixedEventHandler)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiInstallGpeHandler
+ *
+ * PARAMETERS:  GpeDevice       - Namespace node for the GPE (NULL for FADT
+ *                                defined GPEs)
+ *              GpeNumber       - The GPE number within the GPE block
+ *              Type            - Whether this GPE should be treated as an
+ *                                edge- or level-triggered interrupt.
+ *              Address         - Address of the handler
+ *              Context         - Value passed to the handler on each GPE
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Install a handler for a General Purpose Event.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiInstallGpeHandler (
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber,
+    UINT32                  Type,
+    ACPI_GPE_HANDLER        Address,
+    void                    *Context)
+{
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_GPE_HANDLER_INFO   *Handler;
+    ACPI_STATUS             Status;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (AcpiInstallGpeHandler);
+
+
+    /* Parameter validation */
+
+    if ((!Address) || (Type & ~ACPI_GPE_XRUPT_TYPE_MASK))
+    {
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Allocate and init handler object (before lock) */
+
+    Handler = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_HANDLER_INFO));
+    if (!Handler)
+    {
+        Status = AE_NO_MEMORY;
+        goto UnlockAndExit;
+    }
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+
+    /* Ensure that we have a valid GPE number */
+
+    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
+    if (!GpeEventInfo)
+    {
+        Status = AE_BAD_PARAMETER;
+        goto FreeAndExit;
+    }
+
+    /* Make sure that there isn't a handler there already */
+
+    if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
+            ACPI_GPE_DISPATCH_HANDLER)
+    {
+        Status = AE_ALREADY_EXISTS;
+        goto FreeAndExit;
+    }
+
+    Handler->Address = Address;
+    Handler->Context = Context;
+    Handler->MethodNode = GpeEventInfo->Dispatch.MethodNode;
+    Handler->OriginalFlags = (UINT8) (GpeEventInfo->Flags &
+        (ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK));
+
+    /*
+     * If the GPE is associated with a method, it may have been enabled
+     * automatically during initialization, in which case it has to be
+     * disabled now to avoid spurious execution of the handler.
+     */
+    if (((Handler->OriginalFlags & ACPI_GPE_DISPATCH_METHOD) ||
+         (Handler->OriginalFlags & ACPI_GPE_DISPATCH_NOTIFY)) &&
+        GpeEventInfo->RuntimeCount)
+    {
+        Handler->OriginallyEnabled = TRUE;
+        (void) AcpiEvRemoveGpeReference (GpeEventInfo);
+
+        /* Sanity check of original type against new type */
+
+        if (Type != (UINT32) (GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK))
+        {
+            ACPI_WARNING ((AE_INFO, "GPE type mismatch (level/edge)"));
+        }
+    }
+
+    /* Install the handler */
+
+    GpeEventInfo->Dispatch.Handler = Handler;
+
+    /* Setup up dispatch flags to indicate handler (vs. method/notify) */
+
+    GpeEventInfo->Flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK);
+    GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_HANDLER);
+
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+
+
+UnlockAndExit:
+    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+    return_ACPI_STATUS (Status);
+
+FreeAndExit:
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+    ACPI_FREE (Handler);
+    goto UnlockAndExit;
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInstallGpeHandler)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiRemoveGpeHandler
+ *
+ * PARAMETERS:  GpeDevice       - Namespace node for the GPE (NULL for FADT
+ *                                defined GPEs)
+ *              GpeNumber       - The event to remove a handler
+ *              Address         - Address of the handler
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRemoveGpeHandler (
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber,
+    ACPI_GPE_HANDLER        Address)
+{
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_GPE_HANDLER_INFO   *Handler;
+    ACPI_STATUS             Status;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (AcpiRemoveGpeHandler);
+
+
+    /* Parameter validation */
+
+    if (!Address)
+    {
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+
+    /* Ensure that we have a valid GPE number */
+
+    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
+    if (!GpeEventInfo)
+    {
+        Status = AE_BAD_PARAMETER;
+        goto UnlockAndExit;
+    }
+
+    /* Make sure that a handler is indeed installed */
+
+    if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) !=
+            ACPI_GPE_DISPATCH_HANDLER)
+    {
+        Status = AE_NOT_EXIST;
+        goto UnlockAndExit;
+    }
+
+    /* Make sure that the installed handler is the same */
+
+    if (GpeEventInfo->Dispatch.Handler->Address != Address)
+    {
+        Status = AE_BAD_PARAMETER;
+        goto UnlockAndExit;
+    }
+
+    /* Remove the handler */
+
+    Handler = GpeEventInfo->Dispatch.Handler;
+
+    /* Restore Method node (if any), set dispatch flags */
+
+    GpeEventInfo->Dispatch.MethodNode = Handler->MethodNode;
+    GpeEventInfo->Flags &=
+        ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK);
+    GpeEventInfo->Flags |= Handler->OriginalFlags;
+
+    /*
+     * If the GPE was previously associated with a method and it was
+     * enabled, it should be enabled at this point to restore the
+     * post-initialization configuration.
+     */
+    if ((Handler->OriginalFlags & ACPI_GPE_DISPATCH_METHOD) &&
+        Handler->OriginallyEnabled)
+    {
+        (void) AcpiEvAddGpeReference (GpeEventInfo);
+    }
+
+    /* Now we can free the handler object */
+
+    ACPI_FREE (Handler);
+
+
+UnlockAndExit:
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiRemoveGpeHandler)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiAcquireGlobalLock
+ *
+ * PARAMETERS:  Timeout         - How long the caller is willing to wait
+ *              Handle          - Where the handle to the lock is returned
+ *                                (if acquired)
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Acquire the ACPI Global Lock
+ *
+ * Note: Allows callers with the same thread ID to acquire the global lock
+ * multiple times. In other words, externally, the behavior of the global lock
+ * is identical to an AML mutex. On the first acquire, a new handle is
+ * returned. On any subsequent calls to acquire by the same thread, the same
+ * handle is returned.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiAcquireGlobalLock (
+    UINT16                  Timeout,
+    UINT32                  *Handle)
+{
+    ACPI_STATUS             Status;
+
+
+    if (!Handle)
+    {
+        return (AE_BAD_PARAMETER);
+    }
+
+    /* Must lock interpreter to prevent race conditions */
+
+    AcpiExEnterInterpreter ();
+
+    Status = AcpiExAcquireMutexObject (Timeout,
+                AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ());
+
+    if (ACPI_SUCCESS (Status))
+    {
+        /* Return the global lock handle (updated in AcpiEvAcquireGlobalLock) */
+
+        *Handle = AcpiGbl_GlobalLockHandle;
+    }
+
+    AcpiExExitInterpreter ();
+    return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiAcquireGlobalLock)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiReleaseGlobalLock
+ *
+ * PARAMETERS:  Handle      - Returned from AcpiAcquireGlobalLock
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Release the ACPI Global Lock. The handle must be valid.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiReleaseGlobalLock (
+    UINT32                  Handle)
+{
+    ACPI_STATUS             Status;
+
+
+    if (!Handle || (Handle != AcpiGbl_GlobalLockHandle))
+    {
+        return (AE_NOT_ACQUIRED);
+    }
+
+    Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex);
+    return (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiReleaseGlobalLock)
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evxfevnt.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evxfevnt.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,381 @@
+/******************************************************************************
+ *
+ * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#define __EVXFEVNT_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/actables.h>
+
+#define _COMPONENT          ACPI_EVENTS
+        ACPI_MODULE_NAME    ("evxfevnt")
+
+
+#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
+/*******************************************************************************
+ *
+ * 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);
+
+
+    /* ACPI tables must be present */
+
+    if (!AcpiTbTablesLoaded ())
+    {
+        return_ACPI_STATUS (AE_NO_ACPI_TABLES);
+    }
+
+    /* Check current mode */
+
+    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_ERROR ((AE_INFO, "Could not transition to ACPI mode"));
+            return_ACPI_STATUS (Status);
+        }
+
+        ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
+            "Transition to ACPI mode successful\n"));
+    }
+
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiEnable)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDisable
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDisable (
+    void)
+{
+    ACPI_STATUS             Status = AE_OK;
+
+
+    ACPI_FUNCTION_TRACE (AcpiDisable);
+
+
+    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_ERROR ((AE_INFO,
+                "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);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiDisable)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEnableEvent
+ *
+ * PARAMETERS:  Event           - The fixed eventto be enabled
+ *              Flags           - Reserved
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Enable an ACPI event (fixed)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnableEvent (
+    UINT32                  Event,
+    UINT32                  Flags)
+{
+    ACPI_STATUS             Status = AE_OK;
+    UINT32                  Value;
+
+
+    ACPI_FUNCTION_TRACE (AcpiEnableEvent);
+
+
+    /* 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 = AcpiWriteBitRegister (
+                AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
+                ACPI_ENABLE_EVENT);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Make sure that the hardware responded */
+
+    Status = AcpiReadBitRegister (
+                AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    if (Value != 1)
+    {
+        ACPI_ERROR ((AE_INFO,
+            "Could not enable %s event", AcpiUtGetEventName (Event)));
+        return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
+    }
+
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiEnableEvent)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDisableEvent
+ *
+ * PARAMETERS:  Event           - The fixed event to be disabled
+ *              Flags           - Reserved
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Disable an ACPI event (fixed)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDisableEvent (
+    UINT32                  Event,
+    UINT32                  Flags)
+{
+    ACPI_STATUS             Status = AE_OK;
+    UINT32                  Value;
+
+
+    ACPI_FUNCTION_TRACE (AcpiDisableEvent);
+
+
+    /* 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 = AcpiWriteBitRegister (
+                AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
+                ACPI_DISABLE_EVENT);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    Status = AcpiReadBitRegister (
+                AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    if (Value != 0)
+    {
+        ACPI_ERROR ((AE_INFO,
+            "Could not disable %s events", AcpiUtGetEventName (Event)));
+        return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
+    }
+
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiDisableEvent)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiClearEvent
+ *
+ * PARAMETERS:  Event           - The fixed event to be cleared
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Clear an ACPI event (fixed)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiClearEvent (
+    UINT32                  Event)
+{
+    ACPI_STATUS             Status = AE_OK;
+
+
+    ACPI_FUNCTION_TRACE (AcpiClearEvent);
+
+
+    /* 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 = AcpiWriteBitRegister (
+                AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
+                ACPI_CLEAR_STATUS);
+
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiClearEvent)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiGetEventStatus
+ *
+ * PARAMETERS:  Event           - The fixed event
+ *              EventStatus     - 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,
+    ACPI_EVENT_STATUS       *EventStatus)
+{
+    ACPI_STATUS             Status = AE_OK;
+
+
+    ACPI_FUNCTION_TRACE (AcpiGetEventStatus);
+
+
+    if (!EventStatus)
+    {
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    /* Decode the Fixed Event */
+
+    if (Event > ACPI_EVENT_MAX)
+    {
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    /* Get the status of the requested fixed event */
+
+    Status = AcpiReadBitRegister (
+                AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus);
+
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetEventStatus)
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evxfgpe.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evxfgpe.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,903 @@
+/******************************************************************************
+ *
+ * Module Name: evxfgpe - External Interfaces for General Purpose Events (GPEs)
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#define __EVXFGPE_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acevents.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+
+#define _COMPONENT          ACPI_EVENTS
+        ACPI_MODULE_NAME    ("evxfgpe")
+
+
+#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiUpdateAllGpes
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Complete GPE initialization and enable all GPEs that have
+ *              associated _Lxx or _Exx methods and are not pointed to by any
+ *              device _PRW methods (this indicates that these GPEs are
+ *              generally intended for system or device wakeup. Such GPEs
+ *              have to be enabled directly when the devices whose _PRW
+ *              methods point to them are set up for wakeup signaling.)
+ *
+ * NOTE: Should be called after any GPEs are added to the system. Primarily,
+ * after the system _PRW methods have been run, but also after a GPE Block
+ * Device has been added or if any new GPE methods have been added via a
+ * dynamic table load.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiUpdateAllGpes (
+    void)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (AcpiUpdateGpes);
+
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    if (AcpiGbl_AllGpesInitialized)
+    {
+        goto UnlockAndExit;
+    }
+
+    Status = AcpiEvWalkGpeList (AcpiEvInitializeGpeBlock, NULL);
+    if (ACPI_SUCCESS (Status))
+    {
+        AcpiGbl_AllGpesInitialized = TRUE;
+    }
+
+UnlockAndExit:
+    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiUpdateAllGpes)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEnableGpe
+ *
+ * PARAMETERS:  GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
+ *              GpeNumber           - GPE level within the GPE block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
+ *              hardware-enabled.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnableGpe (
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber)
+{
+    ACPI_STATUS             Status = AE_BAD_PARAMETER;
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (AcpiEnableGpe);
+
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+
+    /* Ensure that we have a valid GPE number */
+
+    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
+    if (GpeEventInfo)
+    {
+        Status = AcpiEvAddGpeReference (GpeEventInfo);
+    }
+
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiEnableGpe)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDisableGpe
+ *
+ * PARAMETERS:  GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
+ *              GpeNumber           - GPE level within the GPE block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Remove a reference to a GPE. When the last reference is
+ *              removed, only then is the GPE disabled (for runtime GPEs), or
+ *              the GPE mask bit disabled (for wake GPEs)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDisableGpe (
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber)
+{
+    ACPI_STATUS             Status = AE_BAD_PARAMETER;
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (AcpiDisableGpe);
+
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+
+    /* Ensure that we have a valid GPE number */
+
+    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
+    if (GpeEventInfo)
+    {
+        Status = AcpiEvRemoveGpeReference (GpeEventInfo);
+    }
+
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiDisableGpe)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiSetGpe
+ *
+ * PARAMETERS:  GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
+ *              GpeNumber           - GPE level within the GPE block
+ *              Action              - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
+ *              the reference count mechanism used in the AcpiEnableGpe and
+ *              AcpiDisableGpe interfaces -- and should be used with care.
+ *
+ * Note: Typically used to disable a runtime GPE for short period of time,
+ * then re-enable it, without disturbing the existing reference counts. This
+ * is useful, for example, in the Embedded Controller (EC) driver.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiSetGpe (
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber,
+    UINT8                   Action)
+{
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_STATUS             Status;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (AcpiSetGpe);
+
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+
+    /* Ensure that we have a valid GPE number */
+
+    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
+    if (!GpeEventInfo)
+    {
+        Status = AE_BAD_PARAMETER;
+        goto UnlockAndExit;
+    }
+
+    /* Perform the action */
+
+    switch (Action)
+    {
+    case ACPI_GPE_ENABLE:
+        Status = AcpiEvEnableGpe (GpeEventInfo);
+        break;
+
+    case ACPI_GPE_DISABLE:
+        Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE);
+        break;
+
+    default:
+        Status = AE_BAD_PARAMETER;
+        break;
+    }
+
+UnlockAndExit:
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiSetGpe)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiSetupGpeForWake
+ *
+ * PARAMETERS:  WakeDevice          - Device associated with the GPE (via _PRW)
+ *              GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
+ *              GpeNumber           - GPE level within the GPE block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Mark a GPE as having the ability to wake the system. This
+ *              interface is intended to be used as the host executes the
+ *              _PRW methods (Power Resources for Wake) in the system tables.
+ *              Each _PRW appears under a Device Object (The WakeDevice), and
+ *              contains the info for the wake GPE associated with the
+ *              WakeDevice.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiSetupGpeForWake (
+    ACPI_HANDLE             WakeDevice,
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber)
+{
+    ACPI_STATUS             Status = AE_BAD_PARAMETER;
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_NAMESPACE_NODE     *DeviceNode;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (AcpiSetupGpeForWake);
+
+
+    /* Parameter Validation */
+
+    if (!WakeDevice)
+    {
+        /*
+         * By forcing WakeDevice to be valid, we automatically enable the
+         * implicit notify feature on all hosts.
+         */
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    /* Handle root object case */
+
+    if (WakeDevice == ACPI_ROOT_OBJECT)
+    {
+        DeviceNode = AcpiGbl_RootNode;
+    }
+    else
+    {
+        DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, WakeDevice);
+    }
+
+    /* Validate WakeDevice is of type Device */
+
+    if (DeviceNode->Type != ACPI_TYPE_DEVICE)
+    {
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+
+    /* Ensure that we have a valid GPE number */
+
+    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
+    if (GpeEventInfo)
+    {
+        /*
+         * If there is no method or handler for this GPE, then the
+         * WakeDevice will be notified whenever this GPE fires (aka
+         * "implicit notify") Note: The GPE is assumed to be
+         * level-triggered (for windows compatibility).
+         */
+        if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
+                ACPI_GPE_DISPATCH_NONE)
+        {
+            GpeEventInfo->Flags =
+                (ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED);
+            GpeEventInfo->Dispatch.DeviceNode = DeviceNode;
+        }
+
+        GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE;
+        Status = AE_OK;
+    }
+
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiSetupGpeForWake)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiSetGpeWakeMask
+ *
+ * PARAMETERS:  GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
+ *              GpeNumber           - GPE level within the GPE block
+ *              Action              - Enable or Disable
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit. The GPE must
+ *              already be marked as a WAKE GPE.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiSetGpeWakeMask (
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber,
+    UINT8                   Action)
+{
+    ACPI_STATUS             Status = AE_OK;
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_GPE_REGISTER_INFO  *GpeRegisterInfo;
+    ACPI_CPU_FLAGS          Flags;
+    UINT32                  RegisterBit;
+
+
+    ACPI_FUNCTION_TRACE (AcpiSetGpeWakeMask);
+
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+
+    /*
+     * Ensure that we have a valid GPE number and that this GPE is in
+     * fact a wake GPE
+     */
+    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
+    if (!GpeEventInfo)
+    {
+        Status = AE_BAD_PARAMETER;
+        goto UnlockAndExit;
+    }
+
+    if (!(GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE))
+    {
+        Status = AE_TYPE;
+        goto UnlockAndExit;
+    }
+
+    GpeRegisterInfo = GpeEventInfo->RegisterInfo;
+    if (!GpeRegisterInfo)
+    {
+        Status = AE_NOT_EXIST;
+        goto UnlockAndExit;
+    }
+
+    RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
+
+    /* Perform the action */
+
+    switch (Action)
+    {
+    case ACPI_GPE_ENABLE:
+        ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
+        break;
+
+    case ACPI_GPE_DISABLE:
+        ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
+        break;
+
+    default:
+        ACPI_ERROR ((AE_INFO, "%u, Invalid action", Action));
+        Status = AE_BAD_PARAMETER;
+        break;
+    }
+
+UnlockAndExit:
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiSetGpeWakeMask)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiClearGpe
+ *
+ * PARAMETERS:  GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
+ *              GpeNumber           - GPE level within the GPE block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Clear an ACPI event (general purpose)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiClearGpe (
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber)
+{
+    ACPI_STATUS             Status = AE_OK;
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (AcpiClearGpe);
+
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+
+    /* Ensure that we have a valid GPE number */
+
+    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
+    if (!GpeEventInfo)
+    {
+        Status = AE_BAD_PARAMETER;
+        goto UnlockAndExit;
+    }
+
+    Status = AcpiHwClearGpe (GpeEventInfo);
+
+UnlockAndExit:
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiClearGpe)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiGetGpeStatus
+ *
+ * PARAMETERS:  GpeDevice           - Parent GPE Device. NULL for GPE0/GPE1
+ *              GpeNumber           - GPE level within the GPE block
+ *              EventStatus         - Where the current status of the event
+ *                                    will be returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Get the current status of a GPE (signalled/not_signalled)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetGpeStatus (
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber,
+    ACPI_EVENT_STATUS       *EventStatus)
+{
+    ACPI_STATUS             Status = AE_OK;
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (AcpiGetGpeStatus);
+
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+
+    /* Ensure that we have a valid GPE number */
+
+    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
+    if (!GpeEventInfo)
+    {
+        Status = AE_BAD_PARAMETER;
+        goto UnlockAndExit;
+    }
+
+    /* Obtain status on the requested GPE number */
+
+    Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus);
+
+UnlockAndExit:
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiFinishGpe
+ *
+ * PARAMETERS:  GpeDevice           - Namespace node for the GPE Block
+ *                                    (NULL for FADT defined GPEs)
+ *              GpeNumber           - GPE level within the GPE block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Clear and conditionally reenable a GPE. This completes the GPE
+ *              processing. Intended for use by asynchronous host-installed
+ *              GPE handlers. The GPE is only reenabled if the EnableForRun bit
+ *              is set in the GPE info.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiFinishGpe (
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber)
+{
+    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
+    ACPI_STATUS             Status;
+    ACPI_CPU_FLAGS          Flags;
+
+
+    ACPI_FUNCTION_TRACE (AcpiFinishGpe);
+
+
+    Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+
+    /* Ensure that we have a valid GPE number */
+
+    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
+    if (!GpeEventInfo)
+    {
+        Status = AE_BAD_PARAMETER;
+        goto UnlockAndExit;
+    }
+
+    Status = AcpiEvFinishGpe (GpeEventInfo);
+
+UnlockAndExit:
+    AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiFinishGpe)
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiDisableAllGpes
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiDisableAllGpes (
+    void)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (AcpiDisableAllGpes);
+
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    Status = AcpiHwDisableAllGpes ();
+    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiDisableAllGpes)
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiEnableAllRuntimeGpes
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiEnableAllRuntimeGpes (
+    void)
+{
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes);
+
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    Status = AcpiHwEnableAllRuntimeGpes ();
+    (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
+
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiEnableAllRuntimeGpes)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiInstallGpeBlock
+ *
+ * PARAMETERS:  GpeDevice           - Handle to the parent GPE Block Device
+ *              GpeBlockAddress     - Address and SpaceID
+ *              RegisterCount       - Number of GPE register pairs in the block
+ *              InterruptNumber     - H/W interrupt for the block
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Create and Install a block of GPE registers. The GPEs are not
+ *              enabled here.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiInstallGpeBlock (
+    ACPI_HANDLE             GpeDevice,
+    ACPI_GENERIC_ADDRESS    *GpeBlockAddress,
+    UINT32                  RegisterCount,
+    UINT32                  InterruptNumber)
+{
+    ACPI_STATUS             Status;
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_GPE_BLOCK_INFO     *GpeBlock;
+
+
+    ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock);
+
+
+    if ((!GpeDevice)       ||
+        (!GpeBlockAddress) ||
+        (!RegisterCount))
+    {
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    Node = AcpiNsValidateHandle (GpeDevice);
+    if (!Node)
+    {
+        Status = AE_BAD_PARAMETER;
+        goto UnlockAndExit;
+    }
+
+    /*
+     * For user-installed GPE Block Devices, the GpeBlockBaseNumber
+     * is always zero
+     */
+    Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount,
+                0, InterruptNumber, &GpeBlock);
+    if (ACPI_FAILURE (Status))
+    {
+        goto UnlockAndExit;
+    }
+
+    /* Install block in the DeviceObject attached to the node */
+
+    ObjDesc = AcpiNsGetAttachedObject (Node);
+    if (!ObjDesc)
+    {
+        /*
+         * No object, create a new one (Device nodes do not always have
+         * an attached object)
+         */
+        ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE);
+        if (!ObjDesc)
+        {
+            Status = AE_NO_MEMORY;
+            goto UnlockAndExit;
+        }
+
+        Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE);
+
+        /* Remove local reference to the object */
+
+        AcpiUtRemoveReference (ObjDesc);
+        if (ACPI_FAILURE (Status))
+        {
+            goto UnlockAndExit;
+        }
+    }
+
+    /* Now install the GPE block in the DeviceObject */
+
+    ObjDesc->Device.GpeBlock = GpeBlock;
+
+
+UnlockAndExit:
+    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiRemoveGpeBlock
+ *
+ * PARAMETERS:  GpeDevice           - Handle to the parent GPE Block Device
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Remove a previously installed block of GPE registers
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiRemoveGpeBlock (
+    ACPI_HANDLE             GpeDevice)
+{
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_STATUS             Status;
+    ACPI_NAMESPACE_NODE     *Node;
+
+
+    ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock);
+
+
+    if (!GpeDevice)
+    {
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    Node = AcpiNsValidateHandle (GpeDevice);
+    if (!Node)
+    {
+        Status = AE_BAD_PARAMETER;
+        goto UnlockAndExit;
+    }
+
+    /* Get the DeviceObject attached to the node */
+
+    ObjDesc = AcpiNsGetAttachedObject (Node);
+    if (!ObjDesc ||
+        !ObjDesc->Device.GpeBlock)
+    {
+        return_ACPI_STATUS (AE_NULL_OBJECT);
+    }
+
+    /* Delete the GPE block (but not the DeviceObject) */
+
+    Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock);
+    if (ACPI_SUCCESS (Status))
+    {
+        ObjDesc->Device.GpeBlock = NULL;
+    }
+
+UnlockAndExit:
+    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiGetGpeDevice
+ *
+ * PARAMETERS:  Index               - System GPE index (0-CurrentGpeCount)
+ *              GpeDevice           - Where the parent GPE Device is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
+ *              gpe device indicates that the gpe number is contained in one of
+ *              the FADT-defined gpe blocks. Otherwise, the GPE block device.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiGetGpeDevice (
+    UINT32                  Index,
+    ACPI_HANDLE             *GpeDevice)
+{
+    ACPI_GPE_DEVICE_INFO    Info;
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (AcpiGetGpeDevice);
+
+
+    if (!GpeDevice)
+    {
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    if (Index >= AcpiCurrentGpeCount)
+    {
+        return_ACPI_STATUS (AE_NOT_EXIST);
+    }
+
+    /* Setup and walk the GPE list */
+
+    Info.Index = Index;
+    Info.Status = AE_NOT_EXIST;
+    Info.GpeDevice = NULL;
+    Info.NextBlockBaseIndex = 0;
+
+    Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice);
+    return_ACPI_STATUS (Info.Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice)
+
+#endif /* !ACPI_REDUCED_HARDWARE */
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/events/evxfregn.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/events/evxfregn.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,313 @@
+/******************************************************************************
+ *
+ * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and
+ *                         Address Spaces.
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EVXFREGN_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/acevents.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.
+ *
+ * NOTE: This function should only be called after AcpiEnableSubsystem has
+ * been called. This is because any _REG methods associated with the Space ID
+ * are executed here, and these methods can only be safely executed after
+ * the default handlers have been installed and the hardware has been
+ * initialized (via AcpiEnableSubsystem.)
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiInstallAddressSpaceHandler (
+    ACPI_HANDLE             Device,
+    ACPI_ADR_SPACE_TYPE     SpaceId,
+    ACPI_ADR_SPACE_HANDLER  Handler,
+    ACPI_ADR_SPACE_SETUP    Setup,
+    void                    *Context)
+{
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_STATUS             Status;
+
+
+    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 = AcpiNsValidateHandle (Device);
+    if (!Node)
+    {
+        Status = AE_BAD_PARAMETER;
+        goto UnlockAndExit;
+    }
+
+    /* Install the handler for all Regions for this Space ID */
+
+    Status = AcpiEvInstallSpaceHandler (Node, SpaceId, Handler, Setup, Context);
+    if (ACPI_FAILURE (Status))
+    {
+        goto UnlockAndExit;
+    }
+
+    /*
+     * For the default SpaceIDs, (the IDs for which there are default region handlers
+     * installed) Only execute the _REG methods if the global initialization _REG
+     * methods have already been run (via AcpiInitializeObjects). In other words,
+     * we will defer the execution of the _REG methods for these SpaceIDs until
+     * execution of AcpiInitializeObjects. This is done because we need the handlers
+     * for the default spaces (mem/io/pci/table) to be installed before we can run
+     * any control methods (or _REG methods). There is known BIOS code that depends
+     * on this.
+     *
+     * For all other SpaceIDs, we can safely execute the _REG methods immediately.
+     * This means that for IDs like EmbeddedController, this function should be called
+     * only after AcpiEnableSubsystem has been called.
+     */
+    switch (SpaceId)
+    {
+    case ACPI_ADR_SPACE_SYSTEM_MEMORY:
+    case ACPI_ADR_SPACE_SYSTEM_IO:
+    case ACPI_ADR_SPACE_PCI_CONFIG:
+    case ACPI_ADR_SPACE_DATA_TABLE:
+
+        if (!AcpiGbl_RegMethodsExecuted)
+        {
+            /* We will defer execution of the _REG methods for this space */
+            goto UnlockAndExit;
+        }
+        break;
+
+    default:
+        break;
+    }
+
+    /* Run all _REG methods for this address space */
+
+    Status = AcpiEvExecuteRegMethods (Node, SpaceId);
+
+
+UnlockAndExit:
+    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+    return_ACPI_STATUS (Status);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiInstallAddressSpaceHandler)
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiRemoveAddressSpaceHandler
+ *
+ * PARAMETERS:  Device          - Handle for the device
+ *              SpaceId         - The address space ID
+ *              Handler         - Address of the handler
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Remove a previously installed handler.
+ *
+ ******************************************************************************/
+
+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 = AcpiNsValidateHandle (Device);
+    if (!Node ||
+        ((Node->Type != ACPI_TYPE_DEVICE)    &&
+         (Node->Type != ACPI_TYPE_PROCESSOR) &&
+         (Node->Type != ACPI_TYPE_THERMAL)   &&
+         (Node != AcpiGbl_RootNode)))
+    {
+        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.Handler;
+    LastObjPtr = &ObjDesc->Device.Handler;
+    while (HandlerObj)
+    {
+        /* We have a handler, see if user requested this one */
+
+        if (HandlerObj->AddressSpace.SpaceId == SpaceId)
+        {
+            /* Handler must be the same as the installed handler */
+
+            if (HandlerObj->AddressSpace.Handler != Handler)
+            {
+                Status = AE_BAD_PARAMETER;
+                goto UnlockAndExit;
+            }
+
+            /* Matched SpaceId, 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->AddressSpace.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: Just grab the head because the
+                 * DetachRegion removed the previous head.
+                 */
+                RegionObj = HandlerObj->AddressSpace.RegionList;
+
+            }
+
+            /* Remove this Handler object from the list */
+
+            *LastObjPtr = HandlerObj->AddressSpace.Next;
+
+            /* Now we can delete the handler object */
+
+            AcpiUtRemoveReference (HandlerObj);
+            goto UnlockAndExit;
+        }
+
+        /* Walk the linked list of handlers */
+
+        LastObjPtr = &HandlerObj->AddressSpace.Next;
+        HandlerObj = HandlerObj->AddressSpace.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);
+}
+
+ACPI_EXPORT_SYMBOL (AcpiRemoveAddressSpaceHandler)
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exconfig.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exconfig.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,688 @@
+/******************************************************************************
+ *
+ * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes)
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#define __EXCONFIG_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+#include <contrib/dev/acpica/include/acnamesp.h>
+#include <contrib/dev/acpica/include/actables.h>
+#include <contrib/dev/acpica/include/acdispat.h>
+#include <contrib/dev/acpica/include/acevents.h>
+
+
+#define _COMPONENT          ACPI_EXECUTER
+        ACPI_MODULE_NAME    ("exconfig")
+
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiExAddTable (
+    UINT32                  TableIndex,
+    ACPI_NAMESPACE_NODE     *ParentNode,
+    ACPI_OPERAND_OBJECT     **DdbHandle);
+
+static ACPI_STATUS
+AcpiExRegionRead (
+    ACPI_OPERAND_OBJECT     *ObjDesc,
+    UINT32                  Length,
+    UINT8                   *Buffer);
+
+
+/*******************************************************************************
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExAddTable (
+    UINT32                  TableIndex,
+    ACPI_NAMESPACE_NODE     *ParentNode,
+    ACPI_OPERAND_OBJECT     **DdbHandle)
+{
+    ACPI_OPERAND_OBJECT     *ObjDesc;
+    ACPI_STATUS             Status;
+    ACPI_OWNER_ID           OwnerId;
+
+
+    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);
+    }
+
+    /* Init the table handle */
+
+    ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
+    ObjDesc->Reference.Class = ACPI_REFCLASS_TABLE;
+    *DdbHandle = ObjDesc;
+
+    /* Install the new table into the local data structures */
+
+    ObjDesc->Reference.Value = TableIndex;
+
+    /* Add the table to the namespace */
+
+    Status = AcpiNsLoadTable (TableIndex, ParentNode);
+    if (ACPI_FAILURE (Status))
+    {
+        AcpiUtRemoveReference (ObjDesc);
+        *DdbHandle = NULL;
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Execute any module-level code that was found in the table */
+
+    AcpiExExitInterpreter ();
+    AcpiNsExecModuleCodeList ();
+    AcpiExEnterInterpreter ();
+
+    /*
+     * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is
+     * responsible for discovering any new wake GPEs by running _PRW methods
+     * that may have been loaded by this table.
+     */
+    Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
+    if (ACPI_SUCCESS (Status))
+    {
+        AcpiEvUpdateGpes (OwnerId);
+    }
+
+    return_ACPI_STATUS (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiExLoadTableOp
+ *
+ * PARAMETERS:  WalkState           - Current state with operands
+ *              ReturnDesc          - Where to store the return object
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Load an ACPI table from the RSDT/XSDT
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExLoadTableOp (
+    ACPI_WALK_STATE         *WalkState,
+    ACPI_OPERAND_OBJECT     **ReturnDesc)
+{
+    ACPI_STATUS             Status;
+    ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
+    ACPI_NAMESPACE_NODE     *ParentNode;
+    ACPI_NAMESPACE_NODE     *StartNode;
+    ACPI_NAMESPACE_NODE     *ParameterNode = NULL;
+    ACPI_OPERAND_OBJECT     *DdbHandle;
+    ACPI_TABLE_HEADER       *Table;
+    UINT32                  TableIndex;
+
+
+    ACPI_FUNCTION_TRACE (ExLoadTableOp);
+
+
+    /* Validate lengths for the SignatureString, OEMIDString, OEMTableID */
+
+    if ((Operand[0]->String.Length > ACPI_NAME_SIZE) ||
+        (Operand[1]->String.Length > ACPI_OEM_ID_SIZE) ||
+        (Operand[2]->String.Length > ACPI_OEM_TABLE_ID_SIZE))
+    {
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    /* Find the ACPI table in the RSDT/XSDT */
+
+    Status = AcpiTbFindTable (Operand[0]->String.Pointer,
+                              Operand[1]->String.Pointer,
+                              Operand[2]->String.Pointer, &TableIndex);
+    if (ACPI_FAILURE (Status))
+    {
+        if (Status != AE_NOT_FOUND)
+        {
+            return_ACPI_STATUS (Status);
+        }
+
+        /* Table not found, return an Integer=0 and AE_OK */
+
+        DdbHandle = AcpiUtCreateIntegerObject ((UINT64) 0);
+        if (!DdbHandle)
+        {
+            return_ACPI_STATUS (AE_NO_MEMORY);
+        }
+
+        *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 = AcpiNsGetNode (StartNode, Operand[3]->String.Pointer,
+                    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 = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer,
+                    ACPI_NS_SEARCH_PARENT, &ParameterNode);
+        if (ACPI_FAILURE (Status))
+        {
+            return_ACPI_STATUS (Status);
+        }
+    }
+
+    /* Load the table into the namespace */
+
+    Status = AcpiExAddTable (TableIndex, 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);
+
+            AcpiUtRemoveReference (DdbHandle);
+            return_ACPI_STATUS (Status);
+        }
+    }
+
+    Status = AcpiGetTableByIndex (TableIndex, &Table);
+    if (ACPI_SUCCESS (Status))
+    {
+        ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:"));
+        AcpiTbPrintTableHeader (0, Table);
+    }
+
+    /* Invoke table handler if present */
+
+    if (AcpiGbl_TableHandler)
+    {
+        (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table,
+                    AcpiGbl_TableHandlerContext);
+    }
+
+    *ReturnDesc = DdbHandle;
+    return_ACPI_STATUS  (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiExRegionRead
+ *
+ * PARAMETERS:  ObjDesc         - Region descriptor
+ *              Length          - Number of bytes to read
+ *              Buffer          - Pointer to where to put the data
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Read data from an operation region. The read starts from the
+ *              beginning of the region.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiExRegionRead (
+    ACPI_OPERAND_OBJECT     *ObjDesc,
+    UINT32                  Length,
+    UINT8                   *Buffer)
+{
+    ACPI_STATUS             Status;
+    UINT64                  Value;
+    UINT32                  RegionOffset = 0;
+    UINT32                  i;
+
+
+    /* Bytewise reads */
+
+    for (i = 0; i < Length; i++)
+    {
+        Status = AcpiEvAddressSpaceDispatch (ObjDesc, NULL, ACPI_READ,
+                    RegionOffset, 8, &Value);
+        if (ACPI_FAILURE (Status))
+        {
+            return (Status);
+        }
+
+        *Buffer = (UINT8) Value;
+        Buffer++;
+        RegionOffset++;
+    }
+
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiExLoadOp
+ *
+ * PARAMETERS:  ObjDesc         - Region or Buffer/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
+ *
+ * NOTE: Region Fields (Field, BankField, IndexFields) are resolved to buffer
+ *       objects before this code is reached.
+ *
+ *       If source is an operation region, it must refer to SystemMemory, as
+ *       per the ACPI specification.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExLoadOp (
+    ACPI_OPERAND_OBJECT     *ObjDesc,
+    ACPI_OPERAND_OBJECT     *Target,
+    ACPI_WALK_STATE         *WalkState)
+{
+    ACPI_OPERAND_OBJECT     *DdbHandle;
+    ACPI_TABLE_HEADER       *Table;
+    ACPI_TABLE_DESC         TableDesc;
+    UINT32                  TableIndex;
+    ACPI_STATUS             Status;
+    UINT32                  Length;
+
+
+    ACPI_FUNCTION_TRACE (ExLoadOp);
+
+
+    ACPI_MEMSET (&TableDesc, 0, sizeof (ACPI_TABLE_DESC));
+
+    /* Source Object can be either an OpRegion or a Buffer/Field */
+
+    switch (ObjDesc->Common.Type)
+    {
+    case ACPI_TYPE_REGION:
+
+        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+            "Load table from Region %p\n", ObjDesc));
+
+        /* Region must be SystemMemory (from ACPI spec) */
+
+        if (ObjDesc->Region.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY)
+        {
+            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 (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID))
+        {
+            Status = AcpiDsGetRegionArguments (ObjDesc);
+            if (ACPI_FAILURE (Status))
+            {
+                return_ACPI_STATUS (Status);
+            }
+        }
+
+        /* Get the table header first so we can get the table length */
+
+        Table = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER));
+        if (!Table)
+        {
+            return_ACPI_STATUS (AE_NO_MEMORY);
+        }
+
+        Status = AcpiExRegionRead (ObjDesc, sizeof (ACPI_TABLE_HEADER),
+                    ACPI_CAST_PTR (UINT8, Table));
+        Length = Table->Length;
+        ACPI_FREE (Table);
+
+        if (ACPI_FAILURE (Status))
+        {
+            return_ACPI_STATUS (Status);
+        }
+
+        /* Must have at least an ACPI table header */
+
+        if (Length < sizeof (ACPI_TABLE_HEADER))
+        {
+            return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
+        }
+
+        /*
+         * The original implementation simply mapped the table, with no copy.
+         * However, the memory region is not guaranteed to remain stable and
+         * we must copy the table to a local buffer. For example, the memory
+         * region is corrupted after suspend on some machines. Dynamically
+         * loaded tables are usually small, so this overhead is minimal.
+         *
+         * The latest implementation (5/2009) does not use a mapping at all.
+         * We use the low-level operation region interface to read the table
+         * instead of the obvious optimization of using a direct mapping.
+         * This maintains a consistent use of operation regions across the
+         * entire subsystem. This is important if additional processing must
+         * be performed in the (possibly user-installed) operation region
+         * handler. For example, AcpiExec and ASLTS depend on this.
+         */
+
+        /* Allocate a buffer for the table */
+
+        TableDesc.Pointer = ACPI_ALLOCATE (Length);
+        if (!TableDesc.Pointer)
+        {
+            return_ACPI_STATUS (AE_NO_MEMORY);
+        }
+
+        /* Read the entire table */
+
+        Status = AcpiExRegionRead (ObjDesc, Length,
+                    ACPI_CAST_PTR (UINT8, TableDesc.Pointer));
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_FREE (TableDesc.Pointer);
+            return_ACPI_STATUS (Status);
+        }
+
+        TableDesc.Address = ObjDesc->Region.Address;
+        break;
+
+
+    case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */
+
+        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
+            "Load table from Buffer or Field %p\n", ObjDesc));
+
+        /* Must have at least an ACPI table header */
+
+        if (ObjDesc->Buffer.Length < sizeof (ACPI_TABLE_HEADER))
+        {
+            return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
+        }
+
+        /* Get the actual table length from the table header */
+
+        Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer);
+        Length = Table->Length;
+
+        /* Table cannot extend beyond the buffer */
+
+        if (Length > ObjDesc->Buffer.Length)
+        {
+            return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
+        }
+        if (Length < sizeof (ACPI_TABLE_HEADER))
+        {
+            return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
+        }
+
+        /*
+         * Copy the table from the buffer because the buffer could be modified
+         * or even deleted in the future
+         */
+        TableDesc.Pointer = ACPI_ALLOCATE (Length);
+        if (!TableDesc.Pointer)
+        {
+            return_ACPI_STATUS (AE_NO_MEMORY);
+        }
+
+        ACPI_MEMCPY (TableDesc.Pointer, Table, Length);
+        TableDesc.Address = ACPI_TO_INTEGER (TableDesc.Pointer);
+        break;
+
+
+    default:
+        return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
+    }
+
+    /* Validate table checksum (will not get validated in TbAddTable) */
+
+    Status = AcpiTbVerifyChecksum (TableDesc.Pointer, Length);
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_FREE (TableDesc.Pointer);
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Complete the table descriptor */
+
+    TableDesc.Length = Length;
+    TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED;
+
+    /* Install the new table into the local data structures */
+
+    Status = AcpiTbAddTable (&TableDesc, &TableIndex);
+    if (ACPI_FAILURE (Status))
+    {
+        /* Delete allocated table buffer */
+
+        AcpiTbDeleteTable (&TableDesc);
+        return_ACPI_STATUS (Status);
+    }
+
+    /*
+     * Add the table to the namespace.
+     *
+     * Note: Load the table objects relative to the root of the namespace.
+     * This appears to go against the ACPI specification, but we do it for
+     * compatibility with other ACPI implementations.
+     */
+    Status = AcpiExAddTable (TableIndex, AcpiGbl_RootNode, &DdbHandle);
+    if (ACPI_FAILURE (Status))
+    {
+        /* On error, TablePtr was deallocated above */
+
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Store the DdbHandle into the Target operand */
+
+    Status = AcpiExStore (DdbHandle, Target, WalkState);
+    if (ACPI_FAILURE (Status))
+    {
+        (void) AcpiExUnloadTable (DdbHandle);
+
+        /* TablePtr was deallocated above */
+
+        AcpiUtRemoveReference (DdbHandle);
+        return_ACPI_STATUS (Status);
+    }
+
+    ACPI_INFO ((AE_INFO, "Dynamic OEM Table Load:"));
+    AcpiTbPrintTableHeader (0, TableDesc.Pointer);
+
+    /* Remove the reference by added by AcpiExStore above */
+
+    AcpiUtRemoveReference (DdbHandle);
+
+    /* Invoke table handler if present */
+
+    if (AcpiGbl_TableHandler)
+    {
+        (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, TableDesc.Pointer,
+                    AcpiGbl_TableHandlerContext);
+    }
+
+    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_OK;
+    ACPI_OPERAND_OBJECT     *TableDesc = DdbHandle;
+    UINT32                  TableIndex;
+    ACPI_TABLE_HEADER       *Table;
+
+
+    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.
+     *
+     * Handle must be a valid operand object of type reference. Also, the
+     * DdbHandle must still be marked valid (table has not been previously
+     * unloaded)
+     */
+    if ((!DdbHandle) ||
+        (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) ||
+        (DdbHandle->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) ||
+        (!(DdbHandle->Common.Flags & AOPOBJ_DATA_VALID)))
+    {
+        return_ACPI_STATUS (AE_BAD_PARAMETER);
+    }
+
+    /* Get the table index from the DdbHandle */
+
+    TableIndex = TableDesc->Reference.Value;
+
+    /* Ensure the table is still loaded */
+
+    if (!AcpiTbIsTableLoaded (TableIndex))
+    {
+        return_ACPI_STATUS (AE_NOT_EXIST);
+    }
+
+    /* Invoke table handler if present */
+
+    if (AcpiGbl_TableHandler)
+    {
+        Status = AcpiGetTableByIndex (TableIndex, &Table);
+        if (ACPI_SUCCESS (Status))
+        {
+            (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, Table,
+                        AcpiGbl_TableHandlerContext);
+        }
+    }
+
+    /* Delete the portion of the namespace owned by this table */
+
+    Status = AcpiTbDeleteNamespaceByOwner (TableIndex);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    (void) AcpiTbReleaseOwnerId (TableIndex);
+    AcpiTbSetTableLoadedFlag (TableIndex, FALSE);
+
+    /*
+     * Invalidate the handle. We do this because the handle may be stored
+     * in a named object and may not be actually deleted until much later.
+     */
+    DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID;
+    return_ACPI_STATUS (AE_OK);
+}
+
diff -r b0485aae1c00 -r 4bbaa78c297d head/sys/contrib/dev/acpica/components/executer/exconvrt.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/head/sys/contrib/dev/acpica/components/executer/exconvrt.c	Fri Mar 02 17:09:07 2012 +0200
@@ -0,0 +1,754 @@
+/******************************************************************************
+ *
+ * Module Name: exconvrt - Object conversion routines
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2012, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+
+#define __EXCONVRT_C__
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+#include <contrib/dev/acpica/include/acinterp.h>
+#include <contrib/dev/acpica/include/amlcode.h>
+
+
+#define _COMPONENT          ACPI_EXECUTER
+        ACPI_MODULE_NAME    ("exconvrt")
+
+/* Local prototypes */
+
+static UINT32
+AcpiExConvertToAscii (
+    UINT64                  Integer,
+    UINT16                  Base,
+    UINT8                   *String,
+    UINT8                   MaxLength);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiExConvertToInteger
+ *
+ * PARAMETERS:  ObjDesc         - Object to be converted. Must be an
+ *                                Integer, Buffer, or String
+ *              ResultDesc      - Where the new Integer object is returned
+ *              Flags           - Used for string conversion
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Convert an ACPI Object to an integer.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiExConvertToInteger (
+    ACPI_OPERAND_OBJECT     *ObjDesc,
+    ACPI_OPERAND_OBJECT     **ResultDesc,
+    UINT32                  Flags)
+{
+    ACPI_OPERAND_OBJECT     *ReturnDesc;
+    UINT8                   *Pointer;
+    UINT64                  Result;
+    UINT32                  i;
+    UINT32                  Count;
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc);
+
+
+    switch (ObjDesc->Common.Type)
+    {
+    case ACPI_TYPE_INTEGER:
+
+        /* No conversion necessary */
+
+        *ResultDesc = ObjDesc;
+        return_ACPI_STATUS (AE_OK);
+
+    case ACPI_TYPE_BUFFER:
+    case ACPI_TYPE_STRING:
+
+        /* Note: Takes advantage of common buffer/string fields */
+
+        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;
+
+    /* String conversion is different than Buffer conversion */
+
+    switch (ObjDesc->Common.Type)
+    {
+    case ACPI_TYPE_STRING:
+
+        /*
+         * Convert string to an integer - for most cases, the string must be
+         * hexadecimal as per the ACPI specification. The only exception (as
+         * of ACPI 3.0) is that the ToInteger() operator allows both decimal
+         * and hexadecimal strings (hex prefixed with "0x").
+         */
+        Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, &Result);
+        if (ACPI_FAILURE (Status))
+        {
+            return_ACPI_STATUS (Status);
+        }
+        break;
+
+
+    case ACPI_TYPE_BUFFER:
+
+        /* Check for zero-length buffer */
+
+        if (!Count)
+        {
+            return_ACPI_STATUS (AE_AML_BUFFER_LIMIT);
+        }
+
+        /* Transfer no more than an integer's worth of data */
+
+        if (Count > AcpiGbl_IntegerByteWidth)
+        {
+            Count = AcpiGbl_IntegerByteWidth;
+        }
+
+        /*
+         * Convert buffer to an integer - 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 |= (((UINT64) Pointer[i]) << (i * 8));
+        }
+        break;
+
+
+    default:
+
+        /* No other types can get here */
+